1 |
# $Header: $ |
2 |
# $Name: $ |
3 |
|
4 |
API Discussions: |
5 |
================ |
6 |
|
7 |
As discussed in our group meeting of 2003-12-17 (AJA, CNH, JMC, AM, |
8 |
PH, EH3), the NetCDF interface should resemble the following FORTRAN |
9 |
subroutines: |
10 |
|
11 |
1) "stubs" of the form: MNC_WV_[G|L]2D_R[S|L] () |
12 |
|
13 |
2) MNC_INIT_VGRID('V_GRID_TYPE', nx, ny, nz, zc, zg) |
14 |
|
15 |
3) MNC_INIT_HGRID('H_GRID_TYPE', nx, ny, xc, yc, xg, yg) |
16 |
|
17 |
4) MNC_INIT_VAR('file', 'Vname', 'Vunits', 'H_GTYPE', 'V_GTYPE', PREC, FillVal) |
18 |
|
19 |
5) MNC_WRITE_VAR('file', 'Vname', var, bi, bj, myThid) |
20 |
|
21 |
This is a reasonable start but its inflexible since it isn't easily |
22 |
generalized to grids with dimensions other than [2,3,4] or grids with |
23 |
non-horizontal orientations (eg. vertical slices). |
24 |
|
25 |
|
26 |
Generalizing what we would like to write as "variables defined on 1-D |
27 |
to n-D grids", one can imagine a small number of objects containing |
28 |
all the relevant information: |
29 |
|
30 |
a dimension: [ name, size, units ] |
31 |
a grid: [ name, 1+ dim-ref ] |
32 |
a variable: [ name, units, *1* grid-ref, data ] |
33 |
an attribute: [ name, units, data ] |
34 |
a NetCDF file: [ name, 0+ attr, 0+ grid-ref, 0+ var-ref ] |
35 |
|
36 |
which can then be manipulated (created, associated, destroyed, etc.) |
37 |
using a simple interface such as: |
38 |
|
39 |
MNC_INIT( myThid ) |
40 |
|
41 |
MNC_FILE_CREATE( fname, myThid ) |
42 |
MNC_FILE_OPEN( fname, itype, myThid ) |
43 |
MNC_FILE_ADD_ATTR_STR( fname, atname, sval, myThid ) |
44 |
MNC_FILE_ADD_ATTR_DBL( fname, atname, len, dval, myThid ) |
45 |
MNC_FILE_ADD_ATTR_REAL(fname, atname, len, rval, myThid ) |
46 |
MNC_FILE_ADD_ATTR_INT( fname, atname, len, ival, myThid ) |
47 |
MNC_FILE_ADD_ATTR_ANY( fname, atname, atype, cs,len,dv,rv,iv, myThid ) |
48 |
... |
49 |
MNC_FILE_READ_HEADER( fname, myThid ) |
50 |
|
51 |
MNC_DIM_INIT( fname, dname, dlen, myThid ) |
52 |
|
53 |
MNC_GRID_INIT( fname, gname, ndim, dnames, myThid ) |
54 |
|
55 |
MNC_VAR_INIT_DBL( fname, gname, vname, units, myThid ) |
56 |
MNC_VAR_INIT_REAL( fname, gname, vname, units, myThid ) |
57 |
MNC_VAR_INIT_INT( fname, gname, vname, units, myThid ) |
58 |
MNC_VAR_INIT_ANY( fname, gname, vname, units, type, myThid ) |
59 |
MNC_VAR_ADD_ATTR_STR( fname, vname, atname, sval, myThid ) |
60 |
MNC_VAR_ADD_ATTR_DBL( fname, vname, atname, nv, dval, myThid ) |
61 |
MNC_VAR_ADD_ATTR_REAL( fname, vname, atname, nv, rval, myThid ) |
62 |
MNC_VAR_ADD_ATTR_INT( fname, vname, atname, nv, ival, myThid ) |
63 |
MNC_VAR_ADD_ATTR_ANY( fname, vname, atname, atype, cs,len,dv,rv,iv, myThid ) |
64 |
MNC_VAR_WRITE_DBL( fname, vname, var, myThid ) |
65 |
MNC_VAR_WRITE_REAL( fname, vname, var, myThid ) |
66 |
MNC_VAR_WRITE_INT( fname, vname, var, myThid ) |
67 |
MNC_VAR_WRITE_ANY( fname, vname, vtype, dv, rv, iv, myThid ) |
68 |
... |
69 |
MNC_VAR_READ( fname, vname, var, myThid ) |
70 |
|
71 |
MNC_FILE_SYNC( fname, myThid ) |
72 |
MNC_FILE_CLOSE( fname, myThid ) |
73 |
|
74 |
|
75 |
Heres a further "convenience wrapper" written on top of the above UI: |
76 |
|
77 |
MNC_CW_INIT( Gtype, Htype, Hsub, Vtype, Ttype, wHalo, myThid ) |
78 |
|
79 |
with pre-defined - xy - - n |
80 |
combinations: U x c t y |
81 |
'Cen_xy_c_t_Hn' V y i |
82 |
'U_xy_i_t_Hn', Cen |
83 |
'Cor_x_-_-_Hy' Cor |
84 |
|
85 |
MNC_CW_SET_UDIM( fbname, udim, myThid ) |
86 |
|
87 |
MNC_CW_RX_W( 'R|D|I', fbname,bi,bj, vtype, indu, var, myThid ) |
88 |
MNC_CW_RX_R( 'R|D|I', fbname,bi,bj, vtype, indu, var, myThid ) |
89 |
| |
90 |
+-- RX = 'RL', 'RS', or 'I' |
91 |
|
92 |
MNC_COMP_VTYPE_VAR( ind_vt, ind_fv_ids, ires, myThid ) |
93 |
|
94 |
|
95 |
|
96 |
To-Do: |
97 |
====== |
98 |
|
99 |
1) NAMING -- We should (as much as possible) try to name variables so |
100 |
that they are in agreement with the CF naming conventions. |
101 |
|
102 |
2) UNITS -- as with the names we need to follow conventions |
103 |
|
104 |
3) CNH pointed out that grid interpolation needs to be handled |
105 |
"on-the-fly" since pre-processing would result in overly large |
106 |
input files. We need an interpolation API... |
107 |
|
108 |
|