Skip to content

koseiohara/ctlget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CTLGET

Control file reader for Fortran.

Install and Build

Install the source code by cloning this repository:

git clone https://github.com/koseiohara/ctlget.git
cd ctlget

This library can be built by Makefile.

Makefile

Rewrite the Makefile for your environment:

cd src
vim Makefile

you 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 install

libctlget.a and ctlget.mod will be copied to ${DIR}/lib and ${DIR}/include, respectively.

Tools

ctlget

function init(ctlname, linemax, columnmax) result(output)
    character(*), intent(in) :: ctlname
    integer     , intent(in), optional :: linemax       ! DEFAULT : 100
    integer     , intent(in), optional :: columnmax     ! DEFAULT : 256

Constructor 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)

get_dset

subroutine get_dset(self, output)
    class(ctl)  , intent(in)  :: self
    character(*), intent(out) :: output

output is the name of the target binary file.

get_title

subroutine get_title(self, output)
    class(ctl), intent(in)    :: self
    character(*), intent(out) :: output

output is the title written in the target control file.

get_undef

subroutine get_undef(self, undef, undef_char)
    class(ctl), intent(in) :: self
    real(real32), intent(out), optional :: undef
    character(*), intent(out), optional :: undef_char

undef is the value for undefined grids, its type is real32. undef_char is same as undef, but its type is character.

get_options

subroutine get_options(self, output)
    class(ctl)  , intent(inout) :: self
    character(*), intent(out)   :: output

output is the options written in the target control file.

isYrev

function isYrev(self) result(output)
    class(ctl), intent(inout) :: self
    logical :: output

output is a logical value, .TRUE. if the order of y is reversed.

isZrev

function isZrev(self) result(output)
    class(ctl), intent(inout) :: self
    logical :: output

output is a logical value, .TRUE. if the order of z is reversed.

includeLeap

function includeLeap(self) result(output)
    class(ctl), intent(inout) :: self
    logical :: output

output is a logical value, .TRUE. if data include leap days.

get_endian

subroutine get_endian(self, output)
    class(ctl)  , intent(inout) :: self
    character(*), intent(out)   :: output

output is the endian of data, "little", "big", or "native".

get_gridnum

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 :: nz

nx, ny, and nz are number of grids.

get_nt

subroutine get_nt(self, output)
    class(ctl), intent(in)  :: self
    integer   , intent(out) :: output

output is the number of timesteps.

get_x

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()

get_y

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()

get_z

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()

get_xinfo

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 :: islinear

xmin 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.

get_yinfo

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 :: islinear

ymin 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.

get_zinfo

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 :: islinear

zmin 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.

get_tini

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).

get_dt

subroutine get_dt(self, dt, unit)
    class(ctl)  , intent(in)  :: self
    integer     , intent(out) :: dt
    character(*), intent(out), optional :: unit

dt is the increment to calendar and unit is its unit. One of "mn", "hr", "dy", "mo", or "yr" will be substituted to unit.

get_nvars

subroutine get_nvars(self, output)
    class(ctl), intent(in)  :: self
    integer   , intent(out) :: output

output is the number of variables defined in the target control file.

get_var_idx

subroutine get_var_idx(self, var, output)
    class(ctl)  , intent(in)  :: self
    character(*), intent(in)  :: var
    integer     , intent(out) :: output

var is the name of target variable. output is its index.

get_var_name

subroutine get_var_name(self, idx, output)
    class(ctl)  , intent(in)  :: self
    integer     , intent(in)  :: idx
    character(*), intent(out) :: output

idx is the index of target variable. output is its name.

get_var_description

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 :: var

output 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.

About

Get parameters from control files of GrADS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors