next up previous
Next: C Interface Up: Initial Data Previous: Initial Data

FORTRAN Interface

The FORTRAN interface for the initial data routines comprises twelve routines, six for writing and six for reading. These routines allow the reading and writing of parameters as well as grid functions.

The following program fragment writes and then reads initial data for three grid functions.

     integer gft_write_id_str_p, gft_write_id_float_p
     integer gft_write_id_int_p, gft_write_idata
     integer gft_write_1idata, gft_write_2idata
     integer gft_read_id_str_p, gft_read_id_float_p
     integer gft_read_id_int_p, gft_read_idata
     integer gft_read_1idata, gft_read_2idata
     integer ret, start
     character*20 name(2)
     real*8  time
     integer rank, shape(1)
     real*8  A_n(101), A_np1(101)
     real*8  B_nm1(101), B_n(101), B_np1(101)
     real*8  C_nm1(101), C_n(101), C_np1(101), C_np2(101)
     
     name(1)='test name 1'
     name(2)='test name 2'
     ret=gft_write_id_str_p('sample','names',name,2)
     start=15
     ret=gft_write_id_int_p('sample','start',start,1)
     time=1.2
     ret=gft_write_id_float_p('sample','time',time,1)
c    set grid functions
     rank=1
     shape(1)=101
c    initial data for a two level function
     ret=gft_write_1idata('sample','A',shape,rank,A_n)
c    initial data for a three level function
     ret=gft_write_2idata('sample','B',shape,rank,B_nm1,B_n)
c    initial data for an n level function
     ret=gft_write_idata('sample','C[0]',shape,rank,C_nm1)
     ret=gft_write_idata('sample.hdf','C[1]',shape,rank,C_n)
     ret=gft_write_idata('sample','C[2]',shape,rank,C_np1)
     ret=gft_close('sample')
c    or ret=gft_close_all()
     rank=1
     shape(1)=101
     ret=gft_read_id_str_p('sample','names',name,2)
     ret=gft_read_id_int_p('sample','start',start,1)
     ret=gft_read_id_float_p('sample','time',time,1)
     ret=gft_read_1idata('sample','A',shape,rank,A_n)
     ret=gft_read_2idata('sample','B',shape,rank,B_nm1,B_n)
     ret=gft_read_idata('sample','C[0]',shape,rank,C_nm1)
     ret=gft_read_idata('sample','C[1]',shape,rank,C_n)
     ret=gft_read_idata('sample','C[2]',shape,rank,C_np1)
     ret=gft_close_all()

Since one file contains all the initial data, two names must be passed to each call, the file name and the item name. File names will have .hdf appended if it is not already there.

The parameter writing and reading functions take two additional parameters, an array of parameters and the array length.

The grid function writing and reading functions take shape and rank information and either write or read the grid function(s). The grid function name passed to the routines gft_read_idata and gft_write_idata must have [n] appended to it, where n is an integer. A value of 0 means the first (earliest) time level, then 1, 2, etc. Initial data need only be written for m-1 time levels, where m is the number of time levels carried for a particular grid function. All m levels can be written, but the RNPL generated program will only read the first m-1.

All routines return zero on failure and one on success.



Robert Marsa
Fri Jul 14 13:58:46 CDT 1995