request for sample program and advice

Hi.  I'm an oceanographer trying to figure out whether netCDF can
store some of my data.  Before wading through manuals, I'm hoping to
get some advice on the general suitability of netCDF to my data.  If
it's suitable, perhaps some kind soul could send me a sample
programme to get me started.  (PS: this isn't a total waste of time
... if this programme is useful to me, it will be good for the FAQ
also, and then the next beginner wouldn't have to bother anyone.)

DESCRIPTION OF MY DATA:
I've two datasets I'd like to represent:
        (1) gridded data, say with surface T and S filling a
            lat/lon/time grid
        (2) profile data, with T, S, ... at non-uniform depths, for
            stations at random (lat,lon,time) positions

QUESTIONS:
(a) Am I right in presuming that (1) is easier to represent than (2)?
    In fact, is netCDF suitable for the second task?
(b) Restricting attention to dataset (1) now, for simplicity, I wonder
    whether there is a sample programme I could use to translate my
    present datafiles (in some weird format that I can already read)
    into netCDF?  To make it less confusing, I wonder whether anybody
    could fill in the "Task 1/2/3" blanks in this C programme for me?
    For simplicity -- and so as to make this programme self-contained,
    I create fake data here.

    (By the way, such a programme would make a nice addition to the
    FAQ!) 

        /* Sample program demonstrating creation of netCDF file */
        /* Data are temperature T(x,y,t) and salinity S(x,y,t) */
        #include <stdio.h>
        #include "netcdf.h"   /* ??? is this right ??? */
        main() {
            float T[5][10];   /* "Temperature", units "degrees C" */
            float S[5][10];   /* "Salinity", unitless */
            float lat[10];    /* "Latitude", units "degrees North" */
            float lon[5];     /* "Longitude", units "degrees East" */
            float time[100];  /* "Time", units "days" */
            int i, j, t;
            /* Define lat and lon */
            for (i = 0; i < 5; i++) {
                lon[i] = 2.0 * i;
            }
            for (j = 0; j < 10; j++) {
                lat[j] = 1.0 * j;
            }
            /* 
             ??? 
             ??? Task 1: Create netCDF file and do bookkeeping on
             ??? units, ranges, etc.
             ??? 
             */
            for (t = 0; t < 100; t++) {
                /* Create T and S arrays at this "time" */
                time[t] = 2.0 * t;
                for (i = 0; i < 5; i++) {
                    for (j = 0; j < 10; j++) {
                        T[i][j] = lon[i] + 5 + time[t] / 10.0;
                        S[i][j] = lat[j] + 34.0 + time[t] / 10.0;
                    }
                }
                /* 
                 ???
                 ??? Task 2: put (lat,lon,time,T[][],S[][]) in netCDF file
                 ??? 
                 */
            }
            /*
             ??? 
             ??? Task 3: Finish bookkeeping on netCDF file
             ???
             */
            exit(0);
        }


Dan Kelley                   | kelley@xxxxxxxxxxx         (902)494-1694
Oceanography Department      | "Let the world wait, while we procrastinate;
Dalhousie University         | it's too hot now"
Halifax, NS, CANADA, B3H 4J1 | Michael Franks ('Dragonfly summer')



  • 1994 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: