CH-Earth / summa

Structure for Unifying Multiple Modeling Alternatives:
http://www.ral.ucar.edu/projects/summa
GNU General Public License v3.0
80 stars 105 forks source link

time utilities #124

Open martynpclark opened 8 years ago

martynpclark commented 8 years ago

In read_force.f90 the time utilities can be improved. Specifically, it is possible to generalize the code

 ! compute the number of days in the current year
 yearLength = 365
 if(mod(time_data(iLookTIME%iyyy),4) == 0)then
  yearLength = 366
  if(mod(time_data(iLookTIME%iyyy),100) == 0)then
   yearLength = 365
   if(mod(time_data(iLookTIME%iyyy),400) == 0)then
    yearLength = 366
   endif
  endif
 endif

This can be done by adding a daysinyear(year) function that returns number of days and create an isleapyear(year) function that returns .false. or .true.. We should consider supporting multiple calendars.

martynpclark commented 8 years ago

Consider making the routine compcalday less cryptic.

bartnijssen commented 7 years ago

Include

gutmann commented 7 years ago

If it is helpful, I have code to parse netdf time attributes in GARD: https://github.com/NCAR/GARD/blob/master/src/timing/time_io.f90 bugfixes, comments, welcome.

jhamman commented 7 years ago

@gutmann's is probably best but just add another reference, here's a pretty simple (but complete) implementation in C: https://github.com/UW-Hydro/VIC/blob/master/vic/drivers/shared_all/src/vic_time.c