[Dart-dev] DART/branches Revision: 11932

dart at ucar.edu dart at ucar.edu
Tue Sep 12 12:57:25 MDT 2017


thoar at ucar.edu
2017-09-12 12:57:24 -0600 (Tue, 12 Sep 2017)
385
The convert from the COAMPS HDF5 file to an old-format DART state vector runs ...
however, we need a netCDF file. The complication is that the DART state vector
has variables in it that are derived from the HDF5 file, so reading directly from
the HDF5 file and building the derived variables pretty much violates the RMA paradigm
of reading a list of variables (and shapes) directly.




Modified: DART/branches/coamps/assimilation_code/modules/io/state_structure_mod.f90
===================================================================
--- DART/branches/coamps/assimilation_code/modules/io/state_structure_mod.f90	2017-09-08 17:07:55 UTC (rev 11931)
+++ DART/branches/coamps/assimilation_code/modules/io/state_structure_mod.f90	2017-09-12 18:57:24 UTC (rev 11932)
@@ -528,8 +528,8 @@
    ret = nf90_inq_varid(ncfile, domain%variable(ivar)%varname,    &
                                 domain%variable(ivar)%io_info%netcdf_id)
 
-   call nc_check(ret, 'load_variable_ids, nf90_inq_var_id', &
-                 trim(domain%variable(ivar)%varname))
+   write(string1,*)'domain variable number ',ivar,' "'//trim(domain%variable(ivar)%varname)//'" from file "'//trim(domain%info_file)//'"'
+   call nc_check(ret, 'load_variable_ids, nf90_inq_var_id', string1) 
 
 enddo
 

Modified: DART/branches/coamps/assimilation_code/modules/utilities/netcdf_utilities_mod.f90
===================================================================
--- DART/branches/coamps/assimilation_code/modules/utilities/netcdf_utilities_mod.f90	2017-09-08 17:07:55 UTC (rev 11931)
+++ DART/branches/coamps/assimilation_code/modules/utilities/netcdf_utilities_mod.f90	2017-09-12 18:57:24 UTC (rev 11932)
@@ -40,6 +40,7 @@
           nc_define_double_variable,    &
           nc_put_variable,              &
           nc_get_variable,              &
+          nc_get_variable_info,         &
           nc_add_global_creation_time,  &
           nc_redef,                     &
           nc_enddef,                    &
@@ -846,8 +847,69 @@
 
 end subroutine nc_get_real_3d
 
+
 !--------------------------------------------------------------------
+!> Query and return information about a netCDF variable given the variable name.
+!> Optionally returns the type of variable, the number of dimensions, 
+!> the dimension names and lengths, the number of attributes (but not the attribute values (yet))
+
+subroutine nc_get_variable_info(ncid, varname, xtype, ndims, dimlens, dimnames, nAtts, &
+                                context, filename)
+
+integer,          intent(in)            :: ncid
+character(len=*), intent(in)            :: varname
+integer,          intent(out), optional :: xtype
+integer,          intent(out), optional :: ndims
+integer,          intent(out), optional :: dimlens(:)
+character(len=*), intent(out), optional :: dimnames(:)
+integer,          intent(out), optional :: nAtts
+character(len=*), intent(in) , optional :: context
+character(len=*), intent(in) , optional :: filename
+
+character(len=*), parameter :: routine = 'nc_get_variable_shape'
+integer :: ret, varid, dimid, ii
+
+integer :: myxtype
+integer :: myndims
+integer :: mydimids(NF90_MAX_VAR_DIMS)
+integer :: mydimlens(NF90_MAX_VAR_DIMS)
+integer :: mynAtts
+character(len=NF90_MAX_NAME) :: mydimnames(NF90_MAX_VAR_DIMS)
+
+ret = nf90_inq_varid(ncid, varname, varid)
+call nc_check(ret, routine, 'inq_varid for '//trim(varname), context, filename)
+
+ret = nf90_inquire_variable(ncid, varid, xtype=myxtype, ndims=myndims, &
+                            dimids=mydimids, nAtts=mynAtts) 
+call nc_check(ret, routine, 'inquire_variable for '//trim(varname), context, filename)
+
+if (present(dimlens) .or. present(dimnames)) then  ! more work to do 
+
+   !>@todo do we want to make sure dimlens, dimnames are long enough
+   dimlens  = 0
+   dimnames = ''
+
+   do ii = 1,myndims
+
+      dimid = mydimids(ii)
+      ret = nf90_inquire_dimension(ncid, dimid, name=mydimnames(ii), len=mydimlens(ii))
+
+      write(msgstring1,*)'inquire_dimension ',ii,' for "'//trim(varname)//'"'
+      call nc_check(ret, routine, msgstring1, context, filename)
+
+   enddo
+endif
+
+if (present(   xtype)) xtype    = myxtype
+if (present(   ndims)) ndims    = myndims
+if (present(   nAtts)) nAtts    = mynAtts
+if (present( dimlens)) dimlens(1:ndims)  = mydimlens(1:ndims)
+if (present(dimnames)) dimnames(1:ndims) = mydimnames(1:ndims)
+
+end subroutine nc_get_variable_info
+
 !--------------------------------------------------------------------
+!--------------------------------------------------------------------
 ! misc section: file operations, standard timestamp routine
 
 subroutine nc_add_global_creation_time(ncid, context, filename)

Modified: DART/branches/coamps/models/coamps_nest/coamps_statevec_mod.f90
===================================================================


More information about the Dart-dev mailing list