Demo: Code to read and write NetCDF in a model driver

Zhichang Guo & Paul Dirmeyer

Due to the need to describe the complex nature of land surface processes, land surface schemes have many input/output variables and parameters. Modelers have to expend a lot of effort to work on data input/output. For example, certain decisions have to be made to deal with various configurations of input variables based on their availabilities. Here, I will introduce several programs developed and publicly provided by our group, which might be helpful for model I/O parts.
1. Two modules for NetCDF handling
2. A sample program and demo
 

Two modules for F90 NetCDF handling:

 
---> drv_input_mod
    ---> drv_readnf_mod
    ---> drv_readcon
    ---> drv_almaparse
The input model has several functions:
  • drv_readcon - This routine reads the run control deck, which contains all of the run-specific parameters, file paths (or URLs for DODS use), etc. that are controlled from outside the model. All input data files (forcing, BCs) are listed here, as well as names for output files.
  • drv_almaparse - This is the primary means of opening, checking and cataloging contents of NetCDF input files for the LSS driver.  The ALMA standard table is read by this program.  All required model inputs are resolved and mapped to input files automatically - the user need not worry about what files contain which variables.
  • drv_readnf_mod - generic reading of NetCDF data by arbitrary variable name from any of multiple input files.  Handles grids and gathered (GDT) data sets.
---> drv_output_mod
    ---> drv_table_mod
    ---> drv_writenf_mod
    ---> drv_almagen
    ---> drv_almaout
The output model has several functions:
  • drv_table_mod - This routine reads the ASCII output tables to determine frequency, location and selection of output variables.
  • drv_almagen - Generates all of the ALMA-standard metadata for NetCDF output files.
  • drv_almaout - Coordinates the data output, based on the output tables.
  • drv_writenf_mod - Module for generic writing of NetCDF output.

  •  

Advantages of using these two modules:

A sample program:

Main program
 use drv_dat_mod
 use drv_input_mod
 use drv_output_mod

 call drv_readcon
 call drv_allocate_alma
 call drv_almaparse
 call drv_gsp2d
 call drv_almagen
 
A makefile exists for the sample program.  See the directory listing for access to all of the files.

Tables to use for ALMA/NetCDF output generation:

 
outvar This is the table of ALMA output variables, with ranges, etc. specified per ALMA standards.  The table allows for specification of the frequency of output (at the forcing interval, or at an averaging interval specified in the control deck.
gph This table specifies latitudes and longitudes where Grid Point Histories (a.k.a. MOLTS) should be saved.  The model grid box encompassing the location is used in drv_table_mod (i.e. no interpolation of model results to the exact grid point is performed)

Other useful routines:

drv_timestamp - Converts between Y/M/D H:M:S and seconds from arbitrary origin time set at start of integration.

drv_postproc - fills ALMA output registers with model results.  This code is very SSiB specific, but it is structured just like the ALMA output tables (V1.2 in this case), and would make a very good template to follow to produce the data for the drv_output_mod module described above.

drv_finterp - This routine performs time interpolation of atmospheric forcing data (adtt seconds period) to dtt seconds model time-step for one forcing data interval. Interpolation is performed based on the value of trp_flag:




gswp@cola.iges.org
Global Soil Wetness Project
COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA
+1-301-595-7000
Fax +1-301-595-9793

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

A portion of GSWP2 is supported by the National Aeronautics and Space Administration (NAG5-11579).