[Dart-dev] DART/branches Revision: 13011
dart at ucar.edu
dart at ucar.edu
Tue Mar 12 11:07:01 MDT 2019
thoar at ucar.edu
2019-03-12 11:07:01 -0600 (Tue, 12 Mar 2019)
416
Enhanced support for electron density observations, including a test data file.
Fixed error when creating a 'time' dimension in write_model_time() that was
causing the bgrid test to fail.
Extended support (untested) to handle updating existing scalar time variables.
The obs_def_oxygen_ion_density_mod.f90 may not be needed ...
Fixed some namelists to accurately reflect the test being performed in test_dart.csh
Modified: DART/branches/recam/assimilation_code/modules/io/dart_time_io_mod.f90
===================================================================
--- DART/branches/recam/assimilation_code/modules/io/dart_time_io_mod.f90 2019-03-11 19:57:26 UTC (rev 13010)
+++ DART/branches/recam/assimilation_code/modules/io/dart_time_io_mod.f90 2019-03-12 17:07:01 UTC (rev 13011)
@@ -88,7 +88,7 @@
! Since the time variable is known to have only 1 dimension, we know it is the first one.
-ios = nf90_inquire_dimension(ncid, dimids(1), len=ntimes)
+ios = nf90_inquire_dimension(ncid, dimIDs(1), len=ntimes)
call nc_check(ios, 'read_model_time', 'inquire_dimension for time dimension from "'//trim(filename) )
! read the last one
@@ -202,16 +202,26 @@
integer, intent(in) :: ncid
type(time_type), intent(in) :: dart_time
+character(len=*), parameter :: routine = 'write_model_time'
integer :: ios
-integer :: xtype, numdims, ntimes
+integer :: numdims, ntimes
integer :: VarID
integer :: dart_days, dart_seconds
+integer :: unlimitedDimId
+logical :: has_unlimited, time_is_unlimited
+
real(digits12) :: model_time
integer, dimension(NF90_MAX_VAR_DIMS) :: dimIDs
-character (len=NF90_MAX_NAME) :: dart_calendar, file_calendar
+character (len=NF90_MAX_NAME) :: dart_calendar, var_calendar
+! If there is no unlimited dimension, unlimitedDimID = -1
+ios = nf90_inquire(ncid, unlimitedDimId=unlimitedDimId )
+call nc_check(ios,routine,'checking unlimited dimension')
+
+has_unlimited = (unlimitedDimID /= -1)
+
! this is used in many error messages below. set it here, and
! don't reuse string3 here, please.
write(string3,*)'You may need to supply a model-specific "write_model_time()" to write the time.'
@@ -221,36 +231,48 @@
! if the file doesn't already have a "time" variable, we make one
if (ios /= NF90_NOERR) then
- call error_handler(E_MSG,'write_model_time','no time variable found in file', &
+ call error_handler(E_MSG, routine, 'no variable "time" found in file', &
source, revision, revdate, text2='creating one')
! begin define mode
ios = nf90_Redef(ncid)
- call nc_check(ios, "write_model_time", "redef")
+ call nc_check(ios, routine, "redef")
! check to see if there is a time dimension
- ios = nf90_inq_dimid(ncid, "time", dimIds(1))
+ ! if it does not exist create it
+ ios = nf90_inq_dimid(ncid, "time", dimIDs(1))
+ if (ios /= NF90_NOERR) then
- ! if time dimension does not exist create it
- if (ios /= NF90_NOERR) then
- call nc_check(nf90_def_dim(ncid, "time", nf90_unlimited, dimIds(1)), &
- "write_model_time def_var dimension time")
+ ! If there is already an unlimited dimension, just make a
+ ! time dimension of 'normal' size. If there is no unlimited dim already
+ ! make the time variable 'unlimited'.
+
+ if (has_unlimited) then
+ ios = nf90_def_dim(ncid, "time", 1, dimIDs(1))
+ call nc_check(ios, routine, 'def_dim singleton dimension time')
+ else
+ ios = nf90_def_dim(ncid, "time", nf90_unlimited, dimIDs(1))
+ call nc_check(ios, routine, 'def_dim unlimited dimension time')
+ has_unlimited = .true.
+ unlimitedDimID = dimIDs(1)
+ endif
+
endif
! make the time variable be dimensioned time(time) which is the
! netCDF convention for coordinate variables (variables with the
! same name as a dimension).
- ios = nf90_def_var(ncid, name="time", xtype=nf90_double, dimids=dimIds(1), varid=VarID)
- call nc_check(ios, "write_model_time", "time def_var")
+ ios = nf90_def_var(ncid, name="time", xtype=nf90_double, dimids=dimIDs(1), varid=VarID)
+ call nc_check(ios, routine, "time def_var")
! define time attributes consistent with CF convention
ios = nf90_put_att(ncid, VarID, "long_name", "valid time of the model state")
- call nc_check(ios, "write_model_time", "time long_name")
+ call nc_check(ios, routine, "time long_name")
call get_calendar_string(dart_calendar)
if (dart_calendar == 'NO_CALENDAR') then
ios = nf90_put_att(ncid, VarID, "calendar", "none")
- call nc_check(ios, "write_model_time", "calendar long_name")
+ call nc_check(ios, routine, "calendar long_name")
! ncview (actually, probably udunits2) crashes or errors out or
More information about the Dart-dev
mailing list