[Dart-dev] DART/branches Revision: 11590

dart at ucar.edu dart at ucar.edu
Tue May 2 17:55:35 MDT 2017


nancy at ucar.edu
2017-05-02 17:55:34 -0600 (Tue, 02 May 2017)
34
query to find the unlimited dim.




Modified: DART/branches/model_mod_changes/assimilation_code/location/utilities/location_io_mod.f90
===================================================================
--- DART/branches/model_mod_changes/assimilation_code/location/utilities/location_io_mod.f90	2017-05-02 22:55:18 UTC (rev 11589)
+++ DART/branches/model_mod_changes/assimilation_code/location/utilities/location_io_mod.f90	2017-05-02 23:55:34 UTC (rev 11590)
@@ -77,9 +77,13 @@
 character(len=32) :: context = 'nc_write_location_atts'
 
 
-! define the rank/dimension of the location information
-rc = nf90_def_dim(ncid=ncFileID, name='location', len=dimlen, dimid=LocDimID)
-call nc_check(rc, context, 'def_dim:location', fname)
+! define the rank/dimension of the location information.
+! an initial size of 0 signals we are using the unlimited dim
+! and don't need to define a separate one.
+if (dimlen /= 0) then
+   rc = nf90_def_dim(ncid=ncFileID, name='location', len=dimlen, dimid=LocDimID)
+   call nc_check(rc, context, 'def_dim:location', fname)
+endif
 
 if (LocationDims > 1) then
    rc = nf90_def_dim(ncid=ncFileID, name='locdim', len=LocationDims, dimid=LDimID)
@@ -135,11 +139,14 @@
 integer,                     intent(in) :: ncFileID    ! handle to the netcdf file
 character(len=*), optional,  intent(in) :: fname       ! file name (for printing purposes)
 
-integer :: VarID, rc
+integer :: VarID, unlimID, rc
 character(len=32) :: context = 'nc_write_location_vert'
 
-rc = nf90_def_var(ncid=ncFileID, name='which_vert', xtype=nf90_int, &
-                  dimids=(/ nf90_unlimited /), varid=VarID)
+rc = nf90_inquire(ncFileID, UnlimitedDimID=unlimID)
+call nc_check(rc, context, 'inquire:unlimited_dim', fname)
+
+rc = nf90_def_var(ncFileID, name='which_vert', xtype=nf90_int, &
+                  dimids=(/ unlimID /), varid=VarID)
 call nc_check(rc, context, 'def_var:which_vert', fname)
 
 rc = nf90_put_att(ncFileID, VarID, 'long_name', 'vertical coordinate system code')


More information about the Dart-dev mailing list