next up previous
Next: C Interface Up: Evolution Previous: Evolution

FORTRAN Interface

The FORTRAN interface for evolution data files comprises eight routines, four for writing, two for reading, and two for closing. All routines return zero on error and one on success. The following program fragment provides declarations and sample calls for the writing routines.

       integer  ret, gft_write, gft_write_brief
       integer  gft_write_bbox, gft_write_full
       integer  gft_close, gft_close_all
       real*8   time, data(10,10,10)
       integer  shape(3), rank, i, j, k
       character*5 cnames(3)
       real*8   bbox(6), coords(10,3)
       
       time=1.2
       rank=3
       shape(1)=10
       shape(2)=10
       shape(3)=10
       do i=1,shape(1)
         do j=1,shape(2)
           do k=1,shape(3)
             data(k,j,i)=i*j*k
           end do
         end do
       end do
       ret=gft_write('My function 1',time,shape,rank,data)
       time=2.1
       ret=gft_write_brief('My function 1',time,shape,rank,data)
       bbox(1)=0.0
       bbox(2)=10.0
       bbox(3)=1.2
       bbox(4)=103.5
       bbox(5)=2.0
       bbox(6)=58.1
       ret=gft_write_bbox('My function 2',time,shape,rank,bbox,data)
       cnames(1)='x'
       cnames(2)='y'
       cnames(3)='z'
       do i=1,shape(1)
         coords(i,1)= 1 + .1*i
       end do
       do j=1,shape(2)
         coords(i,2)= 2 + .2*j
       end do
       do k=1,shape(3)
         coords(i,3)= 3 + .3*k
       end do
       ret=gft_write_full('My function 3',time,shape,cnames,rank,coords,data)
       ret=gft_close('My function 2')
       ret=gft_close_all()
The routines gft_write and gft_write_brief are identical.

The first parameter for each call is the grid function name. The file name is formed from the grid function name by removing blanks and appending .hdf. Thus, the first two calls would write to the file Myfunction1.hdf. Each grid function has its own evolution data file.

The time parameter contains the time at which the data is valid. Each time should only appear once in a file and the time levels should be written sequentially from earliest times to latest times. These conditions are not enforced.

The shape parameter is an integer array containing the sizes of each dimension of the data. The rank parameter is the number of dimensions of the data. The data parameter contains the values of the grid function at a single time.

The bbox parameter is a real*8 array of length 2*rank. It contains the coordinate bounding box. The bbox(1) is the minimum for coordinate 1, bbox(2) is the maximum for coordinate 1, bbox(3) is the minimum for coordinate 2, etc.

The cnames parameter is an array of strings containing the names of the coordinates. The names can be any length.

The coords parameter is an array of real*8 containing the coordinate values. The first shape(1) elements of coords contain the values of coordinate 1. The next shape(2) elements contain the values of coordinate 2, etc.

The routines gft_write and gft_write_bbox name the coordinates 'x', 'y', and 'z'. The routine gft_write sets the values of the ith coordinate to be the integers from 1 to shape(i).

The routine gft_close will close the named file if it is open. The routine gft_close_all will close all open HDF files. All files must be closed before the program exits, or data will be lost.

The two reading routines are similar to the writing routines. Sample calls follow:

       integer  ret, gft_read_brief
       integer  gft_read_full, gft_close_all
       real*8   time, data(10,10,10)
       integer  shape(3), rank, lev
       character*5 cnames(3)
       real*8   coords(10,3)
       
       lev=1
       ret=gft_read_brief('My function 1',lev,data)
       lev=2
       ret=gft_read_brief('My function 1',lev,data)
       lev=1
       rank=3
       ret=gft_read_full('My function 3',lev,shape,cnames,rank,time,coords,data)
       ret=gft_close_all()

The grid function name is treated the same way as for the writing routines. The lev parameter specifies which time level to read. This parameter starts at 1 and goes to the number of levels in the file. The rank is passed in to gft_read_full, but all other parameters are read from the file.

Both functions return zero on error and one on success.



next up previous
Next: C Interface Up: Evolution Previous: Evolution



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