[Dart-dev] DART/branches Revision: 12476

dart at ucar.edu dart at ucar.edu
Mon Apr 2 09:20:25 MDT 2018


nancy at ucar.edu
2018-04-02 09:20:25 -0600 (Mon, 02 Apr 2018)
255
added a get routine for an array of character strings (the netcdf format
of prepbufr files has a variable like this) and a test for integer vs real 
variable types (the MADIS mesonet converter has changed the type of the time 
variable in recent files).




Modified: DART/branches/nsc_updates/observations/obs_converters/utilities/obs_utilities_mod.f90
===================================================================
--- DART/branches/nsc_updates/observations/obs_converters/utilities/obs_utilities_mod.f90	2018-04-02 15:13:59 UTC (rev 12475)
+++ DART/branches/nsc_updates/observations/obs_converters/utilities/obs_utilities_mod.f90	2018-04-02 15:20:25 UTC (rev 12476)
@@ -33,6 +33,7 @@
           getvarshape,      &
           getvar_real,      &
           getvar_int,       &
+          getvar_char,      &
           get_short_as_r8,  &
           get_int_as_r8,    &
           get_or_fill_real, &
@@ -44,12 +45,15 @@
           getvar_int_1d_1val,      &
           getvar_real_2d_slice,    &
           get_or_fill_QC_2d_slice, &
+          is_variable_integer,     &
+          is_variable_real,        &
           query_varname,    &
           set_missing_name
 
 !>@todo FIXME there is no documentation for this module
 
-! module global storage
+!>@todo FIXME should this default to 'missing_value'?  i think yes.
+! module global storage - set with 'set_missing_name()' routine.
 character(len=NF90_MAX_NAME) :: missing_name = ''
 
 ! version controlled file description for error handling, do not edit
@@ -290,8 +294,7 @@
 
 !--------------------------------------------------------------------
 !> sets the name of the attribute that describes missing values.  
-!> in some cases it is _FillValue but in others it is something 
-!> nonstandard like 'missing_value'.
+!> in some cases it is _FillValue but in others it is 'missing_value'.
 !>
 !> name - string name of attribute that holds the missing value
 !>
@@ -401,6 +404,24 @@
 !>            in the missing value attribute if that arg is present.
 !>            gets the entire array, no start or count specified.
 !>
+!> FIXME: this code handles scale and offset ok, but like most of the other
+!> routines here it doesn't check for 'missing_value' which many obs files
+!> have either in addition to the _FillValue or instead of it.
+!> e.g. a dump from a MADIS mesonet file:
+!>
+!> double observationTime ( recNum )
+!>  long_name : time of observation
+!>  units : seconds since 1970-1-1 00:00:00.0
+!>  _FillValue : 3.40282346e+38
+!>  missing_value : -9999
+!>  standard_name : time 
+!> 
+!> i've most commonly encountered the "missing_value" in the actual data 
+!> for obs files, not the fill value.  we need a routine that looks for missing, 
+!> then fill, and decides what to do if there are both.  or use the routine
+!> that was already here 'set_missing_value' and the calling code tells us
+!> which attribute name this particular netcdf file is using.
+!>
 !>  ncid    - open netcdf file handle
 !>  varname - string name of netcdf variable
 !>  darray  - output array.  real(r8)
@@ -418,6 +439,7 @@
 integer(i2) :: FillValue
 real(r8)    :: scale_factor, add_offset
 integer     :: offset_exists, scaling_exists, fill_exists
+!>@todo FIXME need missing_exists or something
 
 ! read the data for the requested array, and get the fill value
 call nc_check( nf90_inq_varid(ncid, varname, varid), &
@@ -426,6 +448,7 @@
  offset_exists = nf90_get_att(ncid, varid, 'add_offset',   add_offset)
 scaling_exists = nf90_get_att(ncid, varid, 'scale_factor', scale_factor)
    fill_exists = nf90_get_att(ncid, varid, '_FillValue',   FillValue)
+!  miss_exists = nf90_get_att(ncid, varid, 'missing_value', miss_value)
 
 call nc_check( nf90_get_var(ncid, varid, shortarray), &
                'get_short_as_r8', 'getting var '// trim(varname))
@@ -597,6 +620,71 @@
 
 
 !--------------------------------------------------------------------
+!>   getvar_char - subroutine that inquires, gets the variable, and fills 
+!>            in the missing value attribute if that arg is present.
+!>            gets the entire array, no start or count specified.
+!>
+!>      ncid - open netcdf file handle
+!>      varname - string name of netcdf variable
+!>      darray - output array.  character
+!>      dmiss - value that signals a missing value  char, optional
+!>
+!>     created 11 Mar 2010,  nancy collins,  ncar/image
+
+subroutine getvar_char(ncid, varname, darray, dmiss)
+
+ integer,            intent(in)   :: ncid
+ character(len = *), intent(in)   :: varname
+ character(len = *), intent(out)  :: darray(:)
+ character, optional, intent(out)  :: dmiss


More information about the Dart-dev mailing list