[Dart-dev] DART/branches Revision: 11024

dart at ucar.edu dart at ucar.edu
Tue Feb 7 14:54:13 MST 2017


thoar at ucar.edu
2017-02-07 14:54:13 -0700 (Tue, 07 Feb 2017)
60
This works for models that use the 'no calendar' calendar.




Modified: DART/branches/rma_single_file/io/dart_time_io_mod.f90
===================================================================
--- DART/branches/rma_single_file/io/dart_time_io_mod.f90	2017-02-07 20:24:57 UTC (rev 11023)
+++ DART/branches/rma_single_file/io/dart_time_io_mod.f90	2017-02-07 21:54:13 UTC (rev 11024)
@@ -14,9 +14,9 @@
 
 use types_mod,        only : r8, digits12
 use time_manager_mod, only : time_type, set_time, get_time, print_time, &
-                             set_calendar_type, set_date
+                             set_calendar_type, set_date, get_calendar_string
 
-use utilities_mod,    only : nc_check, E_MSG, E_ERR, error_handler
+use utilities_mod,    only : nc_check, E_MSG, E_ERR, error_handler, to_upper
 
 use typeSizes
 use netcdf
@@ -39,8 +39,8 @@
 
 !--------------------------------------------------------------------
 !> Make a stab at reading the time from the input file
+!> and setting the calendar
 
-
 function read_model_time(filename)
 
 character(len=*), intent(in) :: filename
@@ -55,7 +55,7 @@
 
 integer, dimension(NF90_MAX_VAR_DIMS) :: dimIDs
 character(len=NF90_MAX_NAME)          :: varname,dimname
-character(len=256) :: calendar
+character(len=256) :: file_calendar, dart_calendar
 character(len=256) :: unitstring
 
 call nc_check( nf90_open(filename, NF90_NOWRITE, ncid), &
@@ -92,16 +92,37 @@
 ios = nf90_get_var(ncid, VarID, model_time)
 call nc_check(ios, 'read_model_time','get_var time' )
 
-!>@todo calendar madness ... what calendar is DART already using
+!>@todo calendar madness 
 
-ios = nf90_get_att(ncid, VarID, 'calendar', calendar)
+call get_calendar_string(dart_calendar)
 
-if (ios == NF90_NOERR) then
-   call set_calendar_type(trim(calendar))
-else
-   call set_calendar_type('no calendar')
+ios = nf90_get_att(ncid, VarID, 'calendar', file_calendar)
+if (ios /= NF90_NOERR) file_calendar = 'no_calendar'
+if (trim(file_calendar) == 'no calendar') file_calendar = 'no_calendar'
+call to_upper(file_calendar)
+
+if (trim(dart_calendar) /= trim(file_calendar) ) then
+      write(*,*)trim(dart_calendar)
+      write(*,*)trim(file_calendar)
+      write(string1,*)'I dunno what to do.'
+      call error_handler(E_ERR, 'read_model_time:', string1, source,revision, revdate)
 endif
 
+if ( trim(file_calendar) == 'NO_CALENDAR' ) then
+
+   days    = floor(model_time(ntimes))
+   seconds = (model_time(ntimes)-real(days,r8))*86400
+   read_model_time = set_time(seconds, days)
+
+   call print_time(read_model_time,'read_model_time')
+
+   call nc_check( nf90_close(ncid) , 'read_model_time closing : ', filename)
+   return
+endif
+
+!>@todo where does DART normally set the calendar now?
+call set_calendar_type(trim(file_calendar))
+
 ios = nf90_get_att(ncid, VarID, 'units', unitstring)
 call nc_check(ios, 'read_model_time', 'get_att time units "'//trim(filename)//'"')
 
@@ -145,14 +166,7 @@
 ! time_offset  = set_time(some_seconds, some_days)  ! seconds, days
 ! spinup_end   = base_time + time_offset
 
-days    = floor(model_time(ntimes))
-seconds = (model_time(ntimes)-real(days,r8))*86400
-read_model_time = set_time(seconds, days)
 
-call print_time(read_model_time,'read_model_time')
-
-call nc_check( nf90_close(ncid) , 'read_model_time closing : ', filename)
-
 deallocate( model_time )
 
 end function read_model_time
@@ -182,7 +196,6 @@
 call get_time(dart_time, dart_seconds, dart_days)
 model_time = real(dart_days,digits12) + real(dart_seconds,digits12)/86400.0_digits12
 
-
 ios = nf90_inq_varid(ncid, "time", VarID)
 if (ios /= NF90_NOERR) then


More information about the Dart-dev mailing list