[Dart-dev] DART/branches Revision: 11429
dart at ucar.edu
dart at ucar.edu
Mon Apr 3 14:41:28 MDT 2017
nancy at ucar.edu
2017-04-03 14:41:28 -0600 (Mon, 03 Apr 2017)
122
revamp the netcdf location write routines to try to simplify
them and yet support the variations in code that uses them.
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-04-03 19:52:09 UTC (rev 11428)
+++ DART/branches/model_mod_changes/assimilation_code/location/utilities/location_io_mod.f90 2017-04-03 20:41:28 UTC (rev 11429)
@@ -65,36 +65,48 @@
!>@todo FIXME does the last arg need to be an optional actual dim?
!>or an additional dim? check obs_seq_verify for usage
-subroutine nc_write_location_atts( ncFileID, fname, use_unlimited_dim )
+subroutine nc_write_location_atts(ncFileID, dimlen, use_dimID, fname)
-integer, intent(in) :: ncFileID ! handle to the netcdf file
-character(len=*), intent(in) :: fname ! file name (for printing purposes)
-logical, optional, intent(in) :: use_unlimited_dim ! if true, query and use unlimdim
+integer, intent(in) :: ncFileID ! handle to the netcdf file
+integer, intent(in) :: dimlen ! number of locations to be created
+integer, optional, intent(in) :: use_dimID ! if other than locations dim, use this
+character(len=*), optional, intent(in) :: fname ! file name (for error printing purposes)
-integer :: unlimDimID, LocDimID, VarID
+integer :: LocDimID, LDimID, VarID
+integer :: rc
-logical :: unlimited
-unlimited = .false.
-if (present(use_unlimited_dim)) unlimited = use_unlimited_dim
-
! define the rank/dimension of the location information
-call nc_check(nf90_def_dim(ncid=ncFileID, name='location', len=LocationDims, &
- dimid = LocDimID), 'nc_write_location_atts', 'def_dim:location '//trim(fname))
+rc = nf90_def_dim(ncid=ncFileID, name='location', len=dimlen, dimid=LocDimID)
+call checkit(rc, 'nc_write_location_atts', 'def_dim:location', fname)
+if (LocationDims > 1) then
+ rc = nf90_def_dim(ncid=ncFileID, name='locdim', len=LocationDims, dimid=LDimID)
+ call checkit(rc, 'nc_write_location_atts', 'def_dim:locdim', fname)
+endif
+
! Define the location variable and attributes
-if (unlimited) then
- call nc_check(nf90_Inquire(ncFileID, unlimitedDimId=unlimDimID), &
- 'nc_write_model_atts', 'nf90_Inquire')
-
- call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
- dimids=(/ LocDimID, unlimDimID /), varid=VarID), &
- 'nc_write_location_atts', 'location:def_var')
+if (LocationDims > 1) then
+ if (present(use_dimID)) then
+ call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+ dimids=(/ LDimID, use_dimID /), varid=VarID), &
+ 'nc_write_location_atts', 'location:def_var')
+ else
+ call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+ dimids=(/ LDimID, LocDimID /), varid=VarID), &
+ 'nc_write_location_atts', 'location:def_var')
+ endif
else
- call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
- dimids=(/ LocDimID /), varid=VarID), &
- 'nc_write_location_atts', 'location:def_var')
+ if (present(use_dimID)) then
+ call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+ dimids=(/ use_dimID /), varid=VarID), &
+ 'nc_write_location_atts', 'location:def_var')
+ else
+ call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+ dimids=(/ LocDimID /), varid=VarID), &
+ 'nc_write_location_atts', 'location:def_var')
+ endif
endif
call nc_check(nf90_put_att(ncFileID, VarID, 'description', 'location coordinates'), &
@@ -143,6 +155,7 @@
!----------------------------------------------------------------------------
!> Return the LocationVarID and WhichVertVarID variables from a given netCDF file.
+!>@todo FIXME why do we need this?
!>
!> ncFileId the netcdf file descriptor
!> fname the name of the netcdf file (for error messages only)
@@ -149,17 +162,17 @@
!> LocationVarID the integer ID of the 'location' variable in the netCDF file
!> WhichVertVarID the integer ID of the 'which_vert' variable in the netCDF file
-subroutine nc_get_location_varids( ncFileID, fname, LocationVarID, WhichVertVarID )
+subroutine nc_get_location_varids(ncFileID, LocationVarID, WhichVertVarID, fname)
-integer, intent(in) :: ncFileID ! handle to the netcdf file
-character(len=*), intent(in) :: fname ! file name (for printing purposes)
-integer, intent(out) :: LocationVarID
-integer, optional, intent(out) :: WhichVertVarID
+integer, intent(in) :: ncFileID ! handle to the netcdf file
+integer, intent(out) :: LocationVarID
+integer, optional, intent(out) :: WhichVertVarID
+character(len=*), optional, intent(in) :: fname ! file name (for printing purposes)
integer :: rc
-call nc_check(nf90_inq_varid(ncFileID, 'location', varid=LocationVarID), &
More information about the Dart-dev
mailing list