chgres_cube  1.13.0
All Data Structures Namespaces Files Functions Variables Pages
utils.F90 File Reference

Contains utility routines. More...

Go to the source code of this file.

Functions/Subroutines

subroutine utilities::check_cnwat (cnwat, i_input, j_input)
 When using GEFS data, some points on the target grid have unreasonable canpy moisture content, so zero out any locations with unrealistic canopy moisture values (>0.5). More...
 
subroutine utilities::check_soilt (soilt, landmask, skint, ICET_DEFAULT, i_input, j_input, lsoil_input)
 Check for and replace certain values in soil temperature. More...
 
subroutine utilities::dint2p (PPIN, XXIN, NPIN, PPOUT, XXOUT, NPOUT, LINLOG, XMSG, IER)
 Pressure to presure vertical interpolation for tracers with linear or lnP interpolation. More...
 
subroutine utilities::error_handler (string, rc)
 General error handler. More...
 
subroutine utilities::handle_grib_error (vname, lev, method, value, varnum, read_from_input, iret, var, var8, var3d)
 Handle GRIB2 read error based on the user selected method in the varmap file. More...
 
subroutine utilities::netcdf_err (err, string)
 Error handler for netcdf. More...
 
recursive subroutine utilities::quicksort (a, first, last)
 Sort an array of values. More...
 
subroutine utilities::to_lower (strIn)
 Convert from upper to lowercase. More...
 
character(len=len(strin)) function utilities::to_upper (strIn)
 Convert string from lower to uppercase. More...
 

Detailed Description

Contains utility routines.

Definition in file utils.F90.

Function/Subroutine Documentation

◆ check_cnwat()

subroutine utilities::check_cnwat ( real(esmf_kind_r8), dimension(i_input,j_input), intent(inout)  cnwat,
integer, intent(in)  i_input,
integer, intent(in)  j_input 
)

When using GEFS data, some points on the target grid have unreasonable canpy moisture content, so zero out any locations with unrealistic canopy moisture values (>0.5).

Parameters
cnwat[input] 2-dimensional canopy moisture content
i_input[in] i-dimension of input grid
j_input[in] j-dimension of input grid
Author
Larissa Reames CIMMS/NSSL

Definition at line 265 of file utils.F90.

◆ check_soilt()

subroutine utilities::check_soilt ( real(esmf_kind_r8), dimension(i_input,j_input,lsoil_input), intent(inout)  soilt,
integer(esmf_kind_i4), dimension(i_input,j_input), intent(in)  landmask,
real(esmf_kind_r8), dimension(i_input,j_input), intent(in)  skint,
real, intent(in)  ICET_DEFAULT,
integer, intent(in)  i_input,
integer, intent(in)  j_input,
integer, intent(in)  lsoil_input 
)

Check for and replace certain values in soil temperature.

At open water points (landmask=0) use skin temperature as a filler value. At land points (landmask=1) with excessive soil temperature, replace soil temperature with skin temperature. In GEFSv12.0 data there are some erroneous missing values at land points which this corrects. At sea ice points (landmask=2), store a default ice column temperature because grib2 files do not have ice column temperature which FV3 expects at these points.

Parameters
soilt[inout] 3-dimensional soil temperature arrray
landmask[in] landmask of the input grid
skint[in] 2-dimensional skin temperature array
ICET_DEFAULT[in] Default temperature to apply at ice points
i_input[in] i-dimension of input grid
j_input[in] j-dimension of input grid
lsoil_input[in] soil layers dimension of input grid
Author
Larissa Reames CIMMS/NSSL

Definition at line 230 of file utils.F90.

◆ dint2p()

subroutine utilities::dint2p ( real*8, dimension(npin)  PPIN,
real*8, dimension(npin)  XXIN,
integer  NPIN,
real*8, dimension(npout)  PPOUT,
real*8, dimension(npout)  XXOUT,
integer  NPOUT,
integer  LINLOG,
real*8  XMSG,
integer  IER 
)

Pressure to presure vertical interpolation for tracers with linear or lnP interpolation.

Input tracers on pres levels are interpolated to the target output pressure levels. The matching levels of input and output will keep the same. Extrapolation is also allowed but needs caution. The routine is mostly for GFSV16 combined grib2 input when spfh has missing levels in low and mid troposphere from U/T/HGT/DZDT.

Parameters
[in]ppin1d input pres levs
[in]xxin1d input tracer
[in]npinnumber of input levs
[in]ppout1d target pres levs
[out]xxout1d interpolated tracer
[in]npoutnumber of target levs
[in]linloginterp method.1:linear;not 1:log;neg:extrp allowed
[in]xmsgfill values of missing levels (-999.0)
[out]iererror status. non 0: failed interpolation
Author
Jili Dong NCEP/EMC
Date
2021/07/30

Definition at line 301 of file utils.F90.

◆ error_handler()

subroutine utilities::error_handler ( character(len=*), intent(in)  string,
integer, intent(in)  rc 
)

General error handler.

Parameters
[in]stringerror message
[in]rcerror status code

Definition at line 13 of file utils.F90.

◆ handle_grib_error()

subroutine utilities::handle_grib_error ( character(len=20), intent(in)  vname,
character(len=20), intent(in)  lev,
character(len=20), intent(in)  method,
real(esmf_kind_r4), intent(in)  value,
integer, intent(in)  varnum,
logical, dimension(:), intent(inout)  read_from_input,
integer, intent(inout)  iret,
real(esmf_kind_r4), dimension(:,:), intent(inout), optional  var,
real(esmf_kind_r8), dimension(:,:), intent(inout), optional  var8,
real(esmf_kind_r8), dimension(:,:,:), intent(inout), optional  var3d 
)

Handle GRIB2 read error based on the user selected method in the varmap file.

Parameters
[in]vnamegrib2 variable name
[in]levgrib2 variable level
[in]methodhow missing data is handled
[in]valuefill value for missing data
[in]varnumgrib2 variable number
[in,out]iretreturn status code
[in,out]var4-byte array of corrected data
[in,out]var88-byte array of corrected data
[in,out]var3d3-d array of corrected data
[in,out]read_from_inputlogical array indicating if variable was read in
Author
Larissa Reames

Definition at line 121 of file utils.F90.

◆ netcdf_err()

subroutine utilities::netcdf_err ( integer, intent(in)  err,
character(len=*), intent(in)  string 
)

Error handler for netcdf.

Parameters
[in]errerror status code
[in]stringerror message

Definition at line 35 of file utils.F90.

◆ quicksort()

recursive subroutine utilities::quicksort ( real*8, dimension(*)  a,
integer  first,
integer  last 
)

Sort an array of values.

Parameters
athe sorted array
firstthe first value of sorted array
lastthe last value of sorted array
Author
Jili Dong NOAA/EMC

Definition at line 187 of file utils.F90.

◆ to_lower()

subroutine utilities::to_lower ( character(len=*), intent(inout)  strIn)

Convert from upper to lowercase.

Author
Clive Page

Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012)

Parameters
[in,out]strInstring to convert

Definition at line 88 of file utils.F90.

◆ to_upper()

character(len=len(strin)) function utilities::to_upper ( character(len=*), intent(in)  strIn)

Convert string from lower to uppercase.

Author
Clive Page

Adapted from http://www.star.le.ac.uk/~cgp/fortran.html (25 May 2012)

Parameters
[in]strInstring to convert
Returns
strOut string in uppercase

Definition at line 63 of file utils.F90.