use zio
integer :: nx, ny, nz
integer :: iopes, iocomm, distarray, filedesc
integer :: ndims, unit, recl, rec, ret
character(len=6) :: file, access
...
!... Begin ZioLib.
ret = zio_init(mpi_comm_world)
!... Create an I/O staging communicator made of iopes procs.
!... These processors will actually access disk file for I/O.
!... iopes must be between 1 and the total number of processors
!... (both inclusive).
iopes = 4
ret = zio_new_iocomm(iocomm,iopes)
!... Create a descriptor for a distributed array.
ndims = 3 ! number of dimensions for array
... ! loff(1:ndims) and lsize(1:ndims), grid offsets
... ! and local sizes of the distributed array of
... ! the current process, are defined here.
ret = zio_new_distarray(distarray,ndims,loff,lsize)
!... Open a file. Variables will be written to 'file' using the I/O
!... staging communicator associated with iocomm. This I/O channel is
!... called 'filedesc'.
unit = 10 ! file unit
file = 'myfile' ! file name
access = 'direct' ! access mode
recl = nx * ny * 8 ! record length in bytes
ret = zio_uf_open(filedesc,iocomm,unit,file,access=access,recl=recl)
!... Write t, whose data distribution must be 'distarray', to the file.
rec = 1 ! global staring record number
ret = zio_uf_write_double(filedesc,distarray,t,rec)
!... Close the file.
ret = zio_uf_close(filedesc)
!... Open a file. Variables will be read from 'file' using the I/O
!... staging communicator associated with iocomm. This I/O channel is
!... called 'filedesc'.
unit = 11 ! file unit
file = 'myfile' ! file name
access = 'direct' ! access mode
recl = nx * ny * 8 ! record length in bytes
ret = zio_uf_open(filedesc,iocomm,unit,file,access=access,recl=recl)
!... Read into t, whose data distribution must be 'distarray', from the file.
rec = 1 ! global staring record number
ret = zio_uf_read_double(filedesc,distarray,t,rec)
!... Close the file.
ret = zio_uf_close(filedesc)
!... End ZioLib.
ret = zio_end()
use zio
integer :: nx, ny, nz
integer :: iopes, iocomm, distarray, filedesc
integer :: ndims, ret, old_fillmode, lon_id, lat_id, lev_id, dim_id(3)
...
!... Begin ZioLib.
ret = zio_init(mpi_comm_world)
!... Create an I/O staging communicator made of iopes procs.
!... These processors will actually access disk file for I/O.
!... iopes must be between 1 and the total number of processors
!... (both inclusive).
iopes = 4
ret = zio_new_iocomm(iocomm,iopes)
!... Create a descriptor for a distributed array.
ndims = 3 ! number of dimensions for array
... ! loff(1:ndims) and lsize(1:ndims), grid offsets
... ! and local sizes of the distributed array of
... ! the current process, are defined here.
ret = zio_new_distarray(distarray,ndims,loff,lsize)
!... Add the variable's distributed array descriptor to the descriptor list
!... maintained by ZioLib.
ret = zio_add_to_list('t',distarray)
!... Variables will be written to 'myfile.nc' using the I/O staging
!... communicator associated with iocomm.
!... This I/O channel is called 'filedesc'.
ret = zio_nf_create('myfile.nc',NF_WRITE,iocomm,filedesc)
!... Set the fill mode, define dimensions, and define a variable.
ret = zio_nf_set_fill(filedesc, NF_FILL, old_fillmode)
ret = zio_nf_def_dim(filedesc,'longitude',nx,lon_id)
ret = zio_nf_def_dim(filedesc,'latitude', ny,lat_id)
ret = zio_nf_def_dim(filedesc,'level', nz,lev_id)
dim_id(1) = lon_id
dim_id(2) = lat_id
dim_id(3) = lev_id
ret = zio_nf_def_var(filedesc,'t',NF_DOUBLE,3,dim_id,t_id)
ret = zio_nf_enddef(filedesc)
!... Write t.
ret = zio_nf_put_var_double(filedesc,t_id,t)
!... Close the file.
ret = zio_nf_close(filedesc)
!... Variables will be read from 'myfile.nc' using the I/O staging communicator
!... associated with iocomm. This I/O channel is called 'filedesc'.
ret = zio_nf_open('myfile.nc',NF_NOWRITE,iocomm,filedesc)
!... Inquire for variable ID.
ret = zio_nf_inq_varid(filedesc,'t',t_id)
!... Read t.
ret = zio_nf_get_var_double(filedesc,t_id,t)
!... Close the file.
ret = zio_nf_close(filedesc)
!... End ZioLib.
ret = zio_end()
Last modified on February 10, 2003.