ODB(3L) Senya Basin ODB(3L) NAME ODB - Ordinary Data Base - a simplified interface to NetCDF INTRODUCTION The purpose of this library is to help users to get access to a data stored in a popular data formats like NetCDF or HDF. Our objective was to give a user the simplest interface we could think of as well as help in maintaining some obvious data structures widely used in the Oceanographic community. TWO SIMPLE EXAMPLES. Reading a NetCDF/HDF File. ========================== If you have a NetCDF(or HDF) file GCMoutput.cdf which has a variable temp among others (like salt, vel, dens). We will assume that you know the dimensions of temp (NX = 360 and NY = 180) obtained by using ncdump for example. The fragment of a Fortran code which does this will be the following: dimension temp(360,180) c.....................open a file call odb_open (idfile, 'GCMoutout.cdf', 0) c.....................read the data for temperature call odb_rdvar (idfile, 'temp', temp) c.....................close the file call odb_close (idfile) Writing a NetCDF File. ====================== In order to make it easier for Fortran-programmers to understand the usage of the ODB library we have included a Fortran fragment which writes similar information, but in a form which is undocumented as well as a machine-dependent binary. Fortran Unformatted File: NetCDF File: parameter(MX=45, MY=32, MT=12) parameter (MX=45,MY=32,MT=12) real aa(MX,MY), real aa(MX,MY), * xx(MX), yy(MY), tt(MT) * xx(MX),yy(MY),tt(MT) open (unit = 1, file = 'abc', call odb_open (idf, 'abc', 1) * form = 'unformatted') call odb_wrdesc(idf, 'The Super-Duper GCM'// * 'Temperature; 0.0001 sec of run') write (1) MX, MY, MT call odb_setxyt(idf, 'longitude',MX,xx, * 'latitude',MY,yy, 'Time',MT,tt, 'TEMP') write (1) xx write (1) yy write (1) tt do IT = 1, MT do IT = 1, MT call compute (MX, MY, IT, aa) call compute (MX, MY, IT, aa) write (1) aa call odb_wrxy (idf, IT, 'TEMP', aa) enddo enddo close (1) call odb_close (idf) SYNOPSIS odb_open(idf, file, key) - opens a file idf - /output/ integer variable used to store the file identifier file - character string: file name key - 0-read only, 1-update or create; 2-always re-create odb_dfgr(idf, gname, nn) - defines a grid with a given name & dimension idf - from previos call to odb_open gname - character grid name (one word) nn - grid's dimension (integer) odb_dfvar?(idf, gn1, gn2, ... gnN, vname) - defines a variable based on a specific set of grids gn1...gnN - grid names from the previous call to odb_dfgr vname - variable's name (one word) odb_setxyt(idf,xunits,NX,xx,yunits,NY,yy,tunits,NT,tt,vname) - defines a variable based on X,Y and T grids. [x|y|t]units - units names for X, Y, and T grids NX, NY, NT - number of points for X, Y, T grids xx, yy, tt - arrays with values for X,Y and T grid data(real) vname - variable's name (one word) odb_wrgr(idf, gname, xx) - writes the gridpoints values to a NetCDF file. gname - grid's name xx - array with grid's data (real) odb_wrvar(idf, vname, var) - writes the values of a variable to NetCDF file. vname - variable's name var - array of data (real by default.) odb_rdgr(idf, gname, nx, xx) - reads the gridpoints values from a NetCDF file gname - /input/ grid's name nn - /output/ grid's dimension xx - /output/ array with grid's data (real) odb_rdvar(idf, vname, var) - reads the values of a variable vname - variable's name var - array to br filled by the data (real) odb_set?attr(idf, vname, aname, val) - write an attribute for a variable vname - variable's name aname - attribute name val - attribute value (if ? =c - character; =r real; =i integer; =d double) odb_wrdesc(idf, desc) - write a description for the file desc - description character string. COMPILATION If you are going to read or write/create a NetCDF files. add the following libraries to your f77 options list: -lodb -lnetcdf -lsun (Use -lodb -lnetcdfdf -ldf -lsun if you want to read HDF files as well). Example: f77 -o abc abc.f -lodb -lnetcdf -lsun COMMENTS senya@rainbow.ldgo.columbia.edu Release 0.0.1 1993