phys_sza.F90 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. !
  2. ! Solar zenith stuff.
  3. !
  4. module phys_sza
  5. implicit none
  6. ! --- in/out ------------------------------
  7. private
  8. public :: cos_sza
  9. contains
  10. ! =======================================================
  11. !
  12. ! Return cos( solar_zenith_angle ) given :
  13. ! o daynr : januari 1 = 1, ..., december 31 = 365|366
  14. ! o hour, minutes, seconds
  15. ! o lon, lat in degrees
  16. !
  17. real function cos_sza( daynr, hour, minu, sec, lon, lat )
  18. use binas, only : pi, deg2rad
  19. ! --- in/out --------------------------------
  20. integer, intent(in) :: daynr
  21. integer, intent(in) :: hour, minu, sec
  22. real, intent(in) :: lon ! deg [-180,180]
  23. real, intent(in) :: lat ! deg [ -90, 90]
  24. ! --- const ---------------------------------
  25. real, parameter :: piby = pi / 180.0
  26. real, parameter :: obliq = 23.45 * piby
  27. ! --- local ---------------------------------
  28. real :: deday, delta
  29. real :: time
  30. real :: lonnoon
  31. ! --- begin -------------------------------------
  32. deday = 4.88 + 2.0*pi*real(daynr)/365.0
  33. delta = asin( sin(obliq) * sin(deday) )
  34. ! seconds after 00:00
  35. time = hour*3600.0 + minu*60.0 + sec
  36. ! longitude at which it is noon at current time:
  37. ! 00:00 pi 180 E
  38. ! 06:00 pi/2 90 E
  39. ! 12:00 0 0
  40. ! 18:00 -pi/2 90 W
  41. ! 24:00 -pi 180 W
  42. lonnoon = pi - 2.0*pi * real(time)/86400.0
  43. ! result:
  44. cos_sza = sin(delta)*sin(lat*deg2rad) + cos(delta)*cos(lat*deg2rad)*cos(lon*deg2rad-lonnoon)
  45. end function cos_sza
  46. end module phys_sza