SUEWS API Site
Documentation of SUEWS source code
Functions/Subroutines
modsolarcalc Module Reference

Functions/Subroutines

real(kind(1d0)) function min_zenith (lat, doy)
 
real(kind(1d0)) function local_apparent_time (lng, dectime)
 
subroutine solar_angles (lat, lng, timezone, dectime, decl, zenith, azimuth)
 
subroutine solar_times (lat, lng, timezone, dectime, sunrise, sunset, snoon)
 
real(kind(1d0)) function kdown_surface (doy, zenith)
 
real function, dimension(365) smithlambda (lat)
 
real(kind(1d0)) function transmissivity_cd (P, Td, G, zenith)
 
real(kind(1d0)) function solar_esdist (doy)
 

Function/Subroutine Documentation

◆ kdown_surface()

real(kind(1d0)) function modsolarcalc::kdown_surface ( integer  doy,
real(kind(1d0))  zenith 
)

Definition at line 345 of file suews_phys_estm.f95.

References mathconstants::pi, and solar_esdist().

345  ! Calculates ground level solar irradiance clear sky
346  ! assuming transmissivity = 1
347  ! let it report zero if zenith >= 90
348  REAL(KIND(1d0)) ::zenith, isurf
349  INTEGER ::doy
350  REAL(KIND(1d0))::rmean, rse, cosz, itoa
351 
352  rmean = 149.6 !Stull 1998
353  rse = solar_esdist(doy)
354  IF (zenith < pi/2.) THEN
355  cosz = cos(zenith)
356  itoa = 1370*(rmean/rse)**2 !top of the atmosphere
357  isurf = itoa*cosz !ground level solar irradiance in W/m2
358  ELSE
359  isurf = 0.
360  ENDIF
361 
real(kind(1d0)) function solar_esdist(doy)
real(kind(1d0)), parameter pi
Here is the call graph for this function:

◆ local_apparent_time()

real(kind(1d0)) function modsolarcalc::local_apparent_time ( real(kind(1d0))  lng,
real(kind(1d0))  dectime 
)

Definition at line 276 of file suews_phys_estm.f95.

References mathconstants::pi.

276  !Oke, 1989, equation of time elsewhere
277  REAL(KIND(1d0)) ::lng, dectime, la_time
278  REAL(KIND(1d0)) ::gamma, eqtime, lmst
279 
280  lmst = dectime - 4.*lng/60./1440.
281  gamma = 2.*pi/365.*(lmst - 1.)
282  eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
283  & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
284  la_time = lmst + eqtime/1440.
real(kind(1d0)) dectime
real(kind(1d0)), parameter pi

◆ min_zenith()

real(kind(1d0)) function modsolarcalc::min_zenith ( real(kind(1d0))  lat,
integer  doy 
)

Definition at line 262 of file suews_phys_estm.f95.

References mathconstants::dtr, and mathconstants::pi.

262  !returns max zenith
263  !returns zenith in radians for lat, lng in degrees
264  REAL(KIND(1d0)) ::lat, dectime, zmin
265  REAL(KIND(1d0)) ::latr, decl
266  INTEGER :: doy
267  dectime = float(doy)
268  latr = lat*dtr
269  decl = 0.409*cos(2*pi*(dectime - 173)/365.25)
270  zmin = pi/2.-asin(sin(latr)*sin(decl) - cos(latr)*cos(decl)*(-1))
real(kind(1d0)), parameter dtr
real(kind(1d0)) dectime
real(kind(1d0)), parameter pi

◆ smithlambda()

real function, dimension(365) modsolarcalc::smithlambda ( integer  lat)

Definition at line 366 of file suews_phys_estm.f95.

366  !read kriged data based on Smith 1966 (JAM)
367  INTEGER :: lat, ios
368  REAL, DIMENSION(365):: g
369 
370  OPEN (99, file="Smith1966.grd", access="direct", action="read", recl=365*4, iostat=ios)
371  IF (ios /= 0) THEN
372  print *, "Iostat=", ios, " reading Smith1966.grd"
373  stop
374  ENDIF
375  READ (99, rec=lat + 1, iostat=ios) g
376  IF (ios /= 0) print *, "Iostat=", ios, " reading Smith1966.grd"
377  CLOSE (99)

◆ solar_angles()

subroutine modsolarcalc::solar_angles ( real, intent(in)  lat,
real, intent(in)  lng,
real, intent(in)  timezone,
real, intent(in)  dectime,
real(kind(1d0)), intent(out)  decl,
real(kind(1d0)), intent(out)  zenith,
real(kind(1d0)), intent(out)  azimuth 
)

Definition at line 289 of file suews_phys_estm.f95.

References mathconstants::pi.

289 
290  REAL, INTENT(in) ::lat, lng, timezone, dectime
291  INTEGER ::doy, hour, mn
292  REAL(KIND(1d0)), INTENT(out) ::decl, zenith, azimuth
293  REAL(KIND(1d0)) ::ha, latr, eqtime, tst, &
294  time_offset, gamma !!!!!FO!!!!! lngr, phi, theta
295 
296  latr = lat*pi/180.
297  doy = floor(dectime)
298  hour = floor((dectime - doy)*24.)
299  mn = floor((dectime - doy - hour/24.)*60.) !!!Check this
300 
301  gamma = 2.*pi/365.25463*(doy - 1.+(hour - 12.)/24.)
302  eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
303  & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
304  decl = 6.918e-3 - 0.399912*cos(gamma) + 0.070257*sin(gamma)&
305  & - 0.006758*cos(2.*gamma) + 9.07e-4*sin(2.*gamma) - 2.697e-3*cos(3.*gamma)&
306  & + 1.48e-3*sin(3.*gamma)
307  time_offset = eqtime - 4.*lng + 60.*timezone
308  tst = hour*60.+mn + time_offset
309  ha = (tst/4.) - 180.
310  ha = ha*pi/180.
311 
312  zenith = acos(sin(latr)*sin(decl) + cos(latr)*cos(decl)*cos(ha))
313  azimuth = pi + acos((sin(latr)*cos(zenith) - sin(decl))/(cos(latr)*sin(zenith)))
314 
315  RETURN
real(kind(1d0)) dectime
real(kind(1d0)), parameter pi

◆ solar_esdist()

real(kind(1d0)) function modsolarcalc::solar_esdist ( integer  doy)

Definition at line 458 of file suews_phys_estm.f95.

References mathconstants::pi.

Referenced by kdown_surface().

458  !from Stull, 1998
459  INTEGER ::doy
460  REAL(KIND(1d0)) ::rse
461  REAL(KIND(1d0)) ::ma, nu, e, a
462 
463  e = 0.0167
464  a = 146.457
465 
466  ma = 2.*pi*(doy - 3)/365.25463 !Mean anomaly
467  nu = ma + 0.0333988*sin(ma) + .0003486*sin(2.*ma) + 5e-6*sin(3.*ma) !true anomaly
468  rse = a*(1 - e*e)/(1 + e*cos(nu))
469 
real(kind(1d0)), parameter pi
Here is the caller graph for this function:

◆ solar_times()

subroutine modsolarcalc::solar_times ( real(kind(1d0)), intent(in)  lat,
real(kind(1d0)), intent(in)  lng,
real(kind(1d0)), intent(in)  timezone,
real(kind(1d0)), intent(in)  dectime,
real(kind(1d0)), intent(out)  sunrise,
real(kind(1d0)), intent(out)  sunset,
real(kind(1d0)), intent(out)  snoon 
)

Definition at line 320 of file suews_phys_estm.f95.

References mathconstants::dtr, mathconstants::pi, and mathconstants::rtd.

320  ! for sunrise and sunset ha = ha(zenith=90)
321  ! timezone is offset to GMT e.g. -5 for EST
322 
323  REAL(KIND(1d0)), INTENT(in) ::lat, lng, timezone, dectime
324  INTEGER ::doy
325  REAL(KIND(1d0)), INTENT(out) ::sunrise, sunset, snoon
326  REAL(KIND(1d0)) :: ha, latr, eqtime, gamma, zenith, decl
327  latr = lat*dtr
328  zenith = 90.833*dtr
329  doy = floor(dectime)
330  gamma = 2.*pi/365.*(float(doy) - 0.5) !fractional year
331  eqtime = 229.18*(7.5e-5 + 1.868e-3*cos(gamma) - 0.032077*sin(gamma)&
332  & - 0.014615*cos(2.*gamma) - 0.040849*sin(2.*gamma))
333  decl = 6.918e-3 - 0.399912*cos(gamma) + 0.070257*sin(gamma)&
334  & - 0.006758*cos(2.*gamma) + 9.07e-4*sin(2.*gamma) - 2.697e-3*cos(3.*gamma)&
335  & + 1.48e-3*sin(3.*gamma)
336  ha = acos(cos(zenith)/(cos(latr)*cos(decl)) - tan(latr)*tan(decl))
337  ha = ha*rtd
338  sunrise = (720.-4.*(lng - ha) - eqtime)/60.-timezone
339  sunset = (720.-4.*(lng + ha) - eqtime)/60.-timezone
340  snoon = (720.-4.*lng - eqtime)/60.-timezone
341  RETURN
real(kind(1d0)), parameter dtr
real(kind(1d0)), parameter rtd
real(kind(1d0)) dectime
real(kind(1d0)), parameter pi

◆ transmissivity_cd()

real(kind(1d0)) function modsolarcalc::transmissivity_cd ( real(kind(1d0))  P,
real(kind(1d0))  Td,
real(kind(1d0))  G,
real(kind(1d0))  zenith 
)

Definition at line 381 of file suews_phys_estm.f95.

References mathconstants::dtr.

381  ! bulk atmospheric transmissivity (Crawford and Duchon, 1999)
382  ! P = pressure (hPa)
383  ! Td = dewpoint (C)
384  ! G parameter is empirical value from Smith 1966 (JAM)
385  ! zenith in radians
386 
387  ! integer ::doy !!!!!FO!!!!!
388  REAL(KIND(1d0)) ::p, td, zenith, g, trans
389  REAL(KIND(1d0))::m, trtpg, u, tw, ta, cosz
390  REAL(KIND(1d0))::tdf
391 
392  IF (zenith > 80.*dtr) THEN
393  cosz = cos(80.*dtr)
394  ELSE
395  cosz = cos(zenith)
396  ENDIF
397  tdf = td*1.8 + 32. !celsius to fahrenheit
398  ! Transmission coefficients
399  m = 35*cosz/sqrt(1224.*cosz*cosz + 1) !optical air mass at p=1013 mb
400  trtpg = 1.021 - 0.084*sqrt(m*(0.000949*p + 0.051)) !first two trans coeff
401  u = exp(0.113 - log(g + 1) + 0.0393*tdf) !precipitable water
402  tw = 1 - 0.077*(u*m)**0.3 !vapor transmission coe3ff.
403  ta = 0.935**m !4th trans coeff
404  trans = trtpg*tw*ta !bulk atmospherics transmissivity
real(kind(1d0)), parameter dtr