[Dart-dev] DART/branches Revision: 11430

dart at ucar.edu dart at ucar.edu
Tue Apr 4 11:08:21 MDT 2017


nancy at ucar.edu
2017-04-04 11:08:19 -0600 (Tue, 04 Apr 2017)
474
make the calendar type 'none' instead of 'no calendar'
for models which don't have a seasonality or an actual
calendar.  but the real key is to make the units be 'days'
and NOT 'days since xxx' because that causes postprocessing
tools to try to interpret the 'days since' attribute
relative to a calendar. it fails in various ways on
various versions of ncview/udunits2, including crashing.
making the 'units' be simply 'days' makes the plots
have a reasonable axis label.




Modified: DART/branches/rma_trunk/assimilation_code/modules/io/dart_time_io_mod.f90
===================================================================
--- DART/branches/rma_trunk/assimilation_code/modules/io/dart_time_io_mod.f90	2017-04-03 20:41:28 UTC (rev 11429)
+++ DART/branches/rma_trunk/assimilation_code/modules/io/dart_time_io_mod.f90	2017-04-04 17:08:19 UTC (rev 11430)
@@ -237,19 +237,16 @@
 
    call get_calendar_string(dart_calendar)
    if (dart_calendar == 'NO_CALENDAR') then
-      ios = nf90_put_att(ncid, VarID, "calendar", "no_calendar")
+      ios = nf90_put_att(ncid, VarID, "calendar", "none")
       call nc_check(ios, "write_model_time", "calendar long_name")
 
-      ! version 2.1.7 of ncview crashes if there is a 'days since' units attribute.
-      ! it doesn't recognize 'no_calendar', tries to use the standard calendar,
-      ! and then flips out when the year is 0000.  our solution for now is to
-      ! remove the units attribute for no_calendar.  this behaves differently in 
-      ! different versions of ncview (e.g 2.1.1 is fine), so be careful testing.  
-      ! this code also appears in single_file_io_mod.f90 - we need to consolidate 
-      ! it in a single location - but until then, updates need to be made both places.
-      !ios = nf90_put_att(ncid, VarID, "units", "days since 0000-01-01 00:00:00")
-      !call nc_check(ios, "write_model_time", "units long_name")
+      ! ncview (actually, probably udunits2) crashes or errors out or 
+      ! displays misleading plot axes if you use 'days since ...' as the units.
+      ! if you simply use 'days' it works much better.
 
+      ios = nf90_put_att(ncid, VarID, "units", "days")
+      call nc_check(ios, "write_model_time", "units long_name")
+
    else if (dart_calendar == 'GREGORIAN') then
       ios = nf90_put_att(ncid, VarID, "calendar", "gregorian")
       call nc_check(ios, "write_model_time", "calendar long_name")

Modified: DART/branches/rma_trunk/assimilation_code/modules/io/single_file_io_mod.f90
===================================================================
--- DART/branches/rma_trunk/assimilation_code/modules/io/single_file_io_mod.f90	2017-04-03 20:41:28 UTC (rev 11429)
+++ DART/branches/rma_trunk/assimilation_code/modules/io/single_file_io_mod.f90	2017-04-04 17:08:19 UTC (rev 11430)
@@ -994,19 +994,15 @@
    call nc_check(nf90_put_att(my_ncid, TimeVarID, "calendar", "no_leap" ), &
               'nc_write_calendar_atts', 'put_att calendar '//trim(ncFileID%fname))
 case default
-   call nc_check(nf90_put_att(my_ncid, TimeVarID, "calendar", "no_calendar" ), &
+   call nc_check(nf90_put_att(my_ncid, TimeVarID, "calendar", "none" ), &
               'nc_write_calendar_atts', 'put_att calendar '//trim(ncFileID%fname))
 
-   ! version 2.1.7 of ncview crashes if there is a 'days since' units attribute.
-   ! it doesn't recognize 'no_calendar', tries to use the standard calendar,
-   ! and then flips out when the year is 0000.  our solution for now is to
-   ! remove the units attribute for no_calendar.  this behaves differently in 
-   ! different versions of ncview (e.g 2.1.1 is fine), so be careful testing.  
-   ! this code also appears in dart_time_io_mod.f90 - we need to consolidate 
-   ! it in a single location - but until then, updates need to be made both places.
-   !call nc_check(nf90_put_att(my_ncid, TimeVarID, "units", &
-   !           'days since 0000-01-01 00:00:00'), &
-   !           'nc_write_calendar_atts', 'put_att units '//trim(ncFileID%fname))
+   ! ncview (actually, probably udunits2) crashes or errors out or
+   ! displays misleading plot axes if you use 'days since ...' as the units.
+   ! if you simply use 'days' it works much better.
+
+   call nc_check(nf90_put_att(my_ncid, TimeVarID, "units", "days"), &
+               'nc_write_calendar_atts', 'put_att units '//trim(ncFileID%fname))
 end select
 
 end function nc_write_calendar_atts


More information about the Dart-dev mailing list