Control file reader for Fortran.
Install the source code by cloning this repository:
git clone https://github.com/koseiohara/ctlget.git
cd ctlgetThis library can be built by Makefile.
Rewrite the Makefile for your environment:
cd src
vim Makefileyou can change the definitions of DIR, FC, and FLAGS.
${DIR}/lib and ${DIR}/include are needed.
After making these settings, execute the makefile
make
make installlibctlget.a and ctlget.mod will be copied to ${DIR}/lib and ${DIR}/include, respectively.
- ctlget
- get_dset
- get_title
- get_undef
- get_options
- isYrev
- isZrev
- includeLeap
- get_endian
- get_gridnum
- get_nt
- get_x
- get_y
- get_z
- get_xinfo
- get_yinfo
- get_zinfo
- get_tini
- get_dt
- get_nvars
- get_var_idx
- get_var_name
- get_var_description
function init(ctlname, linemax, columnmax) result(output)
character(*), intent(in) :: ctlname
integer , intent(in), optional :: linemax ! DEFAULT : 100
integer , intent(in), optional :: columnmax ! DEFAULT : 256Constructor of this class.
ctlname is the name of the target control file.
linemax and columnmax is the maximum allowable number of lines/columns in the file, respectively (default : 100 and 256).
For example, if linemax=100 is substituted, lines after line 100 will not be read.
Although the name of function is init, you can call this routine by ctlget like
example = ctlget(ctlname, 100)subroutine get_dset(self, output)
class(ctl) , intent(in) :: self
character(*), intent(out) :: outputoutput is the name of the target binary file.
subroutine get_title(self, output)
class(ctl), intent(in) :: self
character(*), intent(out) :: outputoutput is the title written in the target control file.
subroutine get_undef(self, undef, undef_char)
class(ctl), intent(in) :: self
real(real32), intent(out), optional :: undef
character(*), intent(out), optional :: undef_charundef is the value for undefined grids, its type is real32.
undef_char is same as undef, but its type is character.
subroutine get_options(self, output)
class(ctl) , intent(inout) :: self
character(*), intent(out) :: outputoutput is the options written in the target control file.
function isYrev(self) result(output)
class(ctl), intent(inout) :: self
logical :: outputoutput is a logical value, .TRUE. if the order of y is reversed.
function isZrev(self) result(output)
class(ctl), intent(inout) :: self
logical :: outputoutput is a logical value, .TRUE. if the order of z is reversed.
function includeLeap(self) result(output)
class(ctl), intent(inout) :: self
logical :: outputoutput is a logical value, .TRUE. if data include leap days.
subroutine get_endian(self, output)
class(ctl) , intent(inout) :: self
character(*), intent(out) :: outputoutput is the endian of data, "little", "big", or "native".
subroutine get_gridnum(self, nx, ny, nz)
class(ctl), intent(in) :: self
integer , intent(out), optional :: nx
integer , intent(out), optional :: ny
integer , intent(out), optional :: nznx, ny, and nz are number of grids.
subroutine get_nt(self, output)
class(ctl), intent(in) :: self
integer , intent(out) :: outputoutput is the number of timesteps.
subroutine get_x(self, output)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: output(:)output is the x-coordinate, its size is nx obtained by get_gridnum()
subroutine get_y(self, output)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: output(:)output is the y-coordinate, its size is ny obtained by get_gridnum()
subroutine get_z(self, output)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: output(:)output is the z-coordinate, its size is nz obtained by get_gridnum()
subroutine get_xinfo(self, xmin, dx, islinear)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: xmin
real(real32), intent(out) :: dx
logical , intent(out), optional :: islinearxmin is the minimum value of xaxis.
dx is the differences between adjacent coordinates.
islinear is .TRUE. if x-axis is linear. If islinear=.FALSE., xmin and dx are 0.
subroutine get_yinfo(self, ymin, dy, islinear)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: ymin
real(real32), intent(out) :: dy
logical , intent(out), optional :: islinearymin is the minimum value of yaxis.
dy is the differences between adjacent coordinates.
islinear is .TRUE. if y-axis is linear. If islinear=.FALSE., ymin and dy are 0.
subroutine get_zinfo(self, zmin, dz, islinear)
class(ctl) , intent(in) :: self
real(real32), intent(out) :: zmin
real(real32), intent(out) :: dz
logical , intent(out), optional :: islinearzmin is the minimum value of zaxis.
dz is the differences between adjacent coordinates.
islinear is .TRUE. if z-axis is linear. If islinear=.FALSE., zmin and dz are 0.
subroutine get_tini(self, calendar)
class(ctl), intent(in) :: self
integer , intent(out) :: calendar(5)Each element of calendar contains the initial date and time information (year, month, day, hour, and minute).
subroutine get_dt(self, dt, unit)
class(ctl) , intent(in) :: self
integer , intent(out) :: dt
character(*), intent(out), optional :: unitdt is the increment to calendar and unit is its unit.
One of "mn", "hr", "dy", "mo", or "yr" will be substituted to unit.
subroutine get_nvars(self, output)
class(ctl), intent(in) :: self
integer , intent(out) :: outputoutput is the number of variables defined in the target control file.
subroutine get_var_idx(self, var, output)
class(ctl) , intent(in) :: self
character(*), intent(in) :: var
integer , intent(out) :: outputvar is the name of target variable.
output is its index.
subroutine get_var_name(self, idx, output)
class(ctl) , intent(in) :: self
integer , intent(in) :: idx
character(*), intent(out) :: outputidx is the index of target variable.
output is its name.
subroutine get_var_description(self, output, idx, var)
class(ctl) , intent(in) :: self
character(*), intent(out) :: output
integer , intent(in), optional :: idx
character(*), intent(in), optional :: varoutput is the description (attribute value) of target variable.
idx is the index of target variable.
var is the name of target variable.
Variable can be specified by idx or var.