module fd4_globaldef_mod
module fd4_vartab_mod
module fd4_domain_mod
module fd4_metadata_mod
module fd4_couple_mod
module fd4_mpi_mod
module netcdf
Types:
public type fd4_netcdf4_cplarray
public type fd4_netdf4_step_def
public type fd4_netcdf4_comm
Variables:
integer (kind=i_k), private, parameter :: MAX_STEP_DEF = 4
Subroutines and functions:
public subroutine fd4_netcdf4_open (nfcomm, domain, filename, nfields, idx, st, err, int_opt, opt_decomp, opt_maxvol, fillvalue_opt)
private subroutine fd4_netcdf4_add_step_def (nfcomm, st, err)
public subroutine fd4_netcdf4_close (nfcomm, err)
public subroutine fd4_netcdf4_write (nfcomm, err, st_opt)
How it works: Create couple context to map the data into a new decomposition which is better suited for I/O. Ideally only decomposed in last dimension (z) with one block for each I/O rank. This may result in much less blocks than ranks, which could require too much memory per I/O rank. In these cases, decomposition in more than one dimensions in required.
TODO:
Author: Matthias Lieber
public type fd4_netcdf4_cplarray
integer (kind=i_k) :: idx
real (kind=r_k), pointer, dimension (:,:,:) :: a3 => null ()
real (kind=r_k), pointer, dimension (:,:,:,:) :: a4 => null ()
end type fd4_netcdf4_cplarray
type for a coupling array
public type fd4_netdf4_step_def
integer (kind=i_k), pointer, dimension (:) :: st => null ()
integer (kind=i_k) :: stsum
type (fd4_couple) :: cpl
end type fd4_netdf4_step_def
Components:| st | time step indexes of the data fields to write |
| stsum | check sum of the time steps for quick searching |
| cpl | couple context to map data into decomposotion better suited for I/O |
public type fd4_netcdf4_comm
type (fd4_domain), pointer :: domain => null ()
integer :: ncid
integer, dimension (0:4) :: dimids
integer, pointer, dimension (:) :: varid => null ()
integer (kind=i_k) :: rec
integer (kind=i_k), pointer, dimension (:) :: idx => null ()
logical :: interpolate
integer (kind=i_k) :: maxnbins
type (fd4_netdf4_step_def), dimension (MAX_STEP_DEF) :: sd
integer (kind=i_k), dimension (3) :: decomp
integer :: iocomm = MPI_COMM_NULL
integer :: nioprocs = 0
integer :: iorank = -1
type (fd4_netcdf4_cplarray), pointer, dimension (:) :: cplarray => null ()
integer (kind=i_k), dimension (3,2) :: abnd = -1
integer (kind=i_k), dimension (3) :: ext = -1
integer (kind=i_k) :: step_def = 0
integer, pointer, dimension (:) :: io2fd4rank => null ()
end type fd4_netcdf4_comm
Components:| domain | the domain which owns the blocks |
| ncid | NetCDF file handle |
| dimids | NetCDF dimension IDs |
| varid | NetCDF variable IDs |
| rec | current output record (output time step) |
| idx | field indices of the data fields to write |
| interpolate | interpolate face vars to center? |
| maxnbins | max number of bins |
| sd | couple context and time step indexes for each step definition |
| decomp | rectangular 3D domain decomposition for I/O |
| iocomm | MPI communicator for processes performing I/O |
| nioprocs | number of I/O processes |
| iorank | rank in iocomm |
| cplarray | array of local couple arrays |
| abnd | bounds of couple arrays of this rank |
| ext | extent of couple arrays of this rank |
| step_def | number of time step index definitions |
| io2fd4rank | map from io ranks to FD4 ranks (only allocated if req.) |
public subroutine fd4_netcdf4_open (nfcomm, domain, filename, nfields, idx, st, err, int_opt, opt_decomp, opt_maxvol, fillvalue_opt)
type (fd4_netcdf4_comm), intent(inout) :: nfcomm
type (fd4_domain), intent(inout) :: domain
character (len=*), intent(in) :: filename
integer (kind=i_k), intent(in) :: nfields
integer (kind=i_k), intent(in), dimension (nfields) :: idx
integer (kind=i_k), intent(in), dimension (nfields) :: st
integer (kind=i_k), intent(out) :: err
logical, optional, intent(in) :: int_opt
integer (kind=i_k), optional, intent(in), dimension (3) :: opt_decomp
integer (kind=i8k), optional, intent(in) :: opt_maxvol
real (kind=r_k), optional, intent(in), dimension (nfields) :: fillvalue_opt
end subroutine fd4_netcdf4_open
Parameters:| nfcomm | FD4 NetCDF4 I/O Communicator |
| domain | the domain |
| filename | name of the file to write |
| nfields | number of data fields to write |
| idx | field indices of the data fields to write |
| st | time step indices of the data fields to write |
| err | error status: 0...ok |
| int_opt | interpolate face vars to center? |
| opt_decomp | I/O decomposition (default: full in z direction) |
| opt_maxvol | maximum volume of one I/O partition in byte (default: 128MiB) |
| fillvalue_opt | optional fill value of each variable, default: vnull |
private subroutine fd4_netcdf4_add_step_def (nfcomm, st, err)
type (fd4_netcdf4_comm), intent(inout), target :: nfcomm
integer (kind=i_k), intent(in), dimension (:) :: st
integer (kind=i_k), intent(out) :: err
end subroutine fd4_netcdf4_add_step_def
Parameters:| nfcomm | FD4 NetCDF4 I/O Communicator |
| st | time step indices of the data fields to write |
| err | error status: 0...ok |
*TODO:*
public subroutine fd4_netcdf4_close (nfcomm, err)
type (fd4_netcdf4_comm), intent(inout) :: nfcomm
integer (kind=i_k), intent(out) :: err
end subroutine fd4_netcdf4_close
Parameters:| nfcomm | FD4 NetCDF4 I/O Communicator |
| err | error status: 0...ok |
public subroutine fd4_netcdf4_write (nfcomm, err, st_opt)
type (fd4_netcdf4_comm), intent(inout) :: nfcomm
integer (kind=i_k), intent(out) :: err
integer (kind=i_k), optional, intent(in), dimension (:) :: st_opt
end subroutine fd4_netcdf4_write
Parameters:| nfcomm | FD4 NetCDF4 I/O Communicator |
| err | error status: 0...ok |
| st_opt | time step indices of the data fields to write |
The optional st_opt parameter will overwrite the values given to fd4_netcdf4_open and create a new set of time step indexes.