[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Kepner's program



Hi Mike,

>       Hello.  A while back, you sent me a copy of Kepner's fortran program
> to create a netCDF data file.  I used the general format of his program to
> create another program that converts our data files into netCDF format.
> However, some of the commands in Kepner's program are not completely clear
> to me.  Could you explain what arr_id, start, x_id, y_id, and count are for?

arr_id is a netcdf variable ID.  x_id and y_id are netCDF dimension IDs.
These are small integers used to identify variables and dimensions in
subsequent netCDF calls, so they don't have to be referred to by their
names.  Another name for such numeric IDs of named objects is "handles".
They serve a similar purpose to logical unit numbers in Fortran I/O, so that
you can refer to an open file or I/O device with a small number once it has
been opened rather than a file name.  Names are nice for humans, but small
numbers are preferable for identifying objects in library interfaces, since
they take up a small fixed amount of space and can be compared for
equality in a small fixed amount of time.

count is a variable used to describe the shape of an array cross-section
(also called a "hyperslab" in the netCDF documentation) by giving the length
of edges in each dimension of the data that is to be written with an NCVPT
call.

> MY program works fine but I would like to understand more fully how it works
> since all the subroutines make it difficult to follow.  

I recommend reading the chapters "Components of a NetCDF File" and "Using
the NetCDF Library" in the NetCDF User's Guide.  This explains the purpose
of variables, dimensions, and attributes, as well as typical sequences of
subroutine calls from both Fortran and C.

>       Would you happen to have any suggestions how I can assign latitude
> and longitude values to these grid points so that our copy of
> Visualization and Computation System (VCS) can plot the gridded data on a
> world map using the lat-lon values?  Our grid uses lat=40 and lon=49 but I
> would like to convert this into lat-lon values of -176.25 to 183.75
> long. and -86.6 to 86.6 lat..  Basically, in order to do this, the program
> must set the first and last values of the x and y dimensions in degrees (
> ex: first value for x dimension, or long., would be -176.25).  Here's what
> I have up to now.  I realize that you might not be able to help here since
> you might be unfamiliar with what`s needed by VCS.

Sorry, but you're right about my complete lack of familiarity with VCS.  It
sounds like you need to use coordinate variables for the latitude and
longitude dimensions.  These are just variables that have the same name as
the dimension and store the latitude and longitude coordinates of the grid.
You would need an extra call to NCVDEF for each of these, and you would have
to store the coordinate values with calls to NCVPT for each variable.  The
User's Guide also has some more information about coordinate variables.

I've appended an example of the CDL for a file that uses lat and lon
coordinate variables.

______________________________________________________________________________

Russ Rew                                           UCAR Unidata Program
address@hidden                              http://www.unidata.ucar.edu


netcdf ops_t {          // NMC Oceanographic Products Set on A-D grids
                        // Sea Surface Temperature

dimensions:
    lat = 73;                   // pole values are replicated
    lon = 73;
    frtime = unlimited;         // forecast time
    timelen = 20;               // Length of reference time strings

variables:

    float       SST(frtime,lat,lon);    // Sea surface temp at 0Z
                SST:long_name = "sea surface temp at 0Z";
                SST:units = "degK";
                SST:valid_range = 0.f, 400.f;
                SST:_FillValue = -9999.0f;

    float       lat(lat);
                lat:long_name = "latitude";
                lat:units = "degrees_north";

    float       lon(lon);
                lon:long_name = "longitude";
                lon:units = "degrees_east";

    int         frtime(frtime);                 // forecast times
                frtime:long_name = "forecast time";
                frtime:units = "hours";

    char        reftime(timelen);               // Reference time of forecasts
                reftime:long_name = "reference time";
                reftime:units = "text_time";    // "yyyy mm dd hh:mm"

    int         grib_center(frtime);            // Identification of center
                grib_center:long_name = "center ID";
                grib_center:units = "WMO centers table";

    int         grib_model(frtime);             // Model identification
                grib_model:long_name = "model ID";
                grib_model:units = "(allocated by center)";

    :history = "created by Unidata LDM from HDS broadcast";
    :title = "NMC Oceanographic Products Set: Sea Surface Temperature";

data:

 lon = -180,-175,-170,-165,-160,-155,-150,-145,-140,-135,-130,-125,
       -120,-115,-110,-105,-100, -95, -90, -85, -80, -75, -70, -65,
        -60, -55, -50, -45, -40, -35, -30, -25, -20, -15, -10,  -5,
          0,   5,  10,  15,  20,  25,  30,  35,  40,  45,  50,  55,
         60,  65,  70,  75,  80,  85,  90,  95, 100, 105, 110, 115,
        120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180;

 lat = -90.0,-87.5,-85.0,-82.5,-80.0,-77.5,-75.0,-72.5,
       -70.0,-67.5,-65.0,-62.5,-60.0,-57.5,-55.0,-52.5,
       -50.0,-47.5,-45.0,-42.5,-40.0,-37.5,-35.0,-32.5,
       -30.0,-27.5,-25.0,-22.5,-20.0,-17.5,-15.0,-12.5,
       -10.0, -7.5, -5.0, -2.5,  0.0,  2.5,  5.0,  7.5,
        10.0, 12.5, 15.0, 17.5, 20.0, 22.5, 25.0, 27.5,
        30.0, 32.5, 35.0, 37.5, 40.0, 42.5, 45.0, 47.5,
        50.0, 52.5, 55.0, 57.5, 60.0, 62.5, 65.0, 67.5,
        70.0, 72.5, 75.0, 77.5, 80.0, 82.5, 85.0, 87.5, 90.0;

 reftime = "yyyy mm dd hh:mm" ;

 // expect at least the following forecast hours
 // frtime =   0 ;
}