5.13.3-dev0
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_read_spatial_data Module Reference

Reads spatial input data. More...

Data Types

interface  read_spatial_data_ascii
 Reads spatial data files of ASCII format. More...
 
interface  read_spatial_data_nc
 Reads spatial data files of nc format. More...
 
interface  read_spatial_data_nc_or_ascii
 Reads spatial data files of nc or ASCII format. More...
 

Functions/Subroutines

subroutine read_spatial_data_ascii_dp (filename, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, data, mask)
 TODO: add description.
 
subroutine read_spatial_data_ascii_i4 (filename, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, data, mask)
 TODO: add description.
 
subroutine, public read_header_ascii (filename, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, header_nodata)
 Reads header lines of ASCII files.
 
subroutine, public check_header (ncols, nrows, xllcorner, yllcorner, cellsize, ref_ncols, ref_nrows, ref_xllcorner, ref_yllcorner, ref_cellsize, tolerance, context)
 
subroutine, public read_header_nc_or_ascii (filepath, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, header_nodata, varname)
 Read header information from either NetCDF or ASCII depending on file name/presence.
 
subroutine, public check_uniform_axis (var, cellsize, origin, increasing, tol)
 check if given axis is a uniform axis.
 
logical function is_x_axis (var)
 check if given variable is a x-axis.
 
logical function is_y_axis (var)
 check if given variable is a y-axis.
 
logical function is_lon_coord (var)
 check if given variable is a lon coordinate.
 
logical function is_lat_coord (var)
 check if given variable is a lat coordinate.
 
subroutine, public get_header_info_from_nc (ncname, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, header_nodata, mask, var)
 Read NetCDF header information (matching read_header_ascii signature)
 
character(len=256) function determine_data_var_name (nc, ncname)
 
subroutine read_spatial_data_nc_i4 (ncname, data, maskout, ncols, nrows, xllcorner, yllcorner, cellsize, nodata_value, varname)
 Read file from filepath.
 
subroutine read_spatial_data_nc_dp (ncname, data, maskout, ncols, nrows, xllcorner, yllcorner, cellsize, nodata_value, varname)
 Read file from filepath.
 
subroutine read_spatial_data_nc_or_ascii_dp (filepath, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, data, maskout, out_ncols, out_nrows, out_xllcorner, out_yllcorner, out_cellsize, out_nodata_value)
 Read file from filepath.
 
subroutine read_spatial_data_nc_or_ascii_i4 (filepath, fileunit, header_ncols, header_nrows, header_xllcorner, header_yllcorner, header_cellsize, data, maskout, out_ncols, out_nrows, out_xllcorner, out_yllcorner, out_cellsize, out_nodata_value)
 Read file from filepath.
 

Detailed Description

Reads spatial input data.

This module is to read spatial input data, e.g. dem, aspect, flow direction. The module provides a subroutine for ASCII files. (Subroutine for NetCDF files will come with release 5.1). The data are read from the specified directory.

Authors
Juliane Mai
Date
Dec 2012


Function/Subroutine Documentation

◆ check_header()

subroutine, public mo_read_spatial_data::check_header ( integer(i4), intent(in) ncols,
integer(i4), intent(in) nrows,
real(dp), intent(in) xllcorner,
real(dp), intent(in) yllcorner,
real(dp), intent(in) cellsize,
integer(i4), intent(in) ref_ncols,
integer(i4), intent(in) ref_nrows,
real(dp), intent(in) ref_xllcorner,
real(dp), intent(in) ref_yllcorner,
real(dp), intent(in) ref_cellsize,
real(dp), intent(in), optional tolerance,
character(*), intent(in), optional context )

Definition at line 447 of file mo_read_spatial_data.f90.

References mo_common_constants::defaulttolerance_dp.

Referenced by mo_meteo_handler::init_level2(), mo_read_spatial_data::read_spatial_data_ascii::read_spatial_data_ascii_dp(), and mo_read_spatial_data::read_spatial_data_ascii::read_spatial_data_ascii_i4().

Here is the caller graph for this function:

◆ check_uniform_axis()

subroutine, public mo_read_spatial_data::check_uniform_axis ( type(ncvariable), intent(in) var,
real(dp), intent(out), optional cellsize,
real(dp), intent(out), optional origin,
logical, intent(out), optional increasing,
real(dp), intent(in), optional tol )

check if given axis is a uniform axis.

Authors
Sebastian Müller
Date
Mar 2024
Parameters
[in]varNetCDF variable for corresponding axis
[out]cellsizecellsize of the uniform axis
[out]originorigin of the axis vertices
[out]increasingwhether the axis has increasing values
[in]toltolerance for cell size comparisson (default: 1.e-7)

Definition at line 559 of file mo_read_spatial_data.f90.

Referenced by get_header_info_from_nc().

Here is the caller graph for this function:

◆ determine_data_var_name()

character(len=256) function mo_read_spatial_data::determine_data_var_name ( class(ncdataset), intent(in) nc,
character(len=*), intent(in) ncname )
private

Definition at line 845 of file mo_read_spatial_data.f90.

Referenced by get_header_info_from_nc(), mo_read_spatial_data::read_spatial_data_nc::read_spatial_data_nc_dp(), and mo_read_spatial_data::read_spatial_data_nc::read_spatial_data_nc_i4().

Here is the caller graph for this function:

◆ get_header_info_from_nc()

subroutine, public mo_read_spatial_data::get_header_info_from_nc ( character(*), intent(in) ncname,
integer(i4), intent(in) fileunit,
integer(i4), intent(out) header_ncols,
integer(i4), intent(out) header_nrows,
real(dp), intent(out) header_xllcorner,
real(dp), intent(out) header_yllcorner,
real(dp), intent(out) header_cellsize,
real(dp), intent(out) header_nodata,
logical, dimension(:,:), intent(out), optional, allocatable mask,
character(*), intent(in), optional var )

Read NetCDF header information (matching read_header_ascii signature)

Reads grid metadata (ncols, nrows, corner, cellsize, nodata) from a NetCDF file.

Authors
Sebastian Müller, Simon Lüdke
Date
Mar 2024 / Feb 2025
Parameters
[in]ncnameNetCDF filename
[in]fileunitUnused (kept for signature compatibility)
[out]header_ncolsnumber of columns
[out]header_nrowsnumber of rows
[out]header_xllcornerlower left x
[out]header_yllcornerlower left y
[out]header_cellsizecell size
[out]header_nodatanodata value
[in]varoptional variable name

Definition at line 742 of file mo_read_spatial_data.f90.

References check_uniform_axis(), determine_data_var_name(), is_lat_coord(), is_lon_coord(), is_x_axis(), and is_y_axis().

Referenced by read_header_nc_or_ascii(), mo_read_spatial_data::read_spatial_data_nc::read_spatial_data_nc_dp(), and mo_read_spatial_data::read_spatial_data_nc::read_spatial_data_nc_i4().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_lat_coord()

logical function mo_read_spatial_data::is_lat_coord ( type(ncvariable), intent(in) var)
private

check if given variable is a lat coordinate.

Returns
logical :: is_lat_coord
Authors
Sebastian Müller
Date
Mar 2024
Parameters
[in]varNetCDF variable to check

Definition at line 710 of file mo_read_spatial_data.f90.

References is_lat_coord().

Referenced by get_header_info_from_nc(), and is_lat_coord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_lon_coord()

logical function mo_read_spatial_data::is_lon_coord ( type(ncvariable), intent(in) var)
private

check if given variable is a lon coordinate.

Returns
logical :: is_lon_coord
Authors
Sebastian Müller
Date
Mar 2024
Parameters
[in]varNetCDF variable to check

Definition at line 678 of file mo_read_spatial_data.f90.

References is_lon_coord().

Referenced by get_header_info_from_nc(), and is_lon_coord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_x_axis()

logical function mo_read_spatial_data::is_x_axis ( type(ncvariable), intent(in) var)
private

check if given variable is a x-axis.

Returns
logical :: is_x_axis
Authors
Sebastian Müller
Date
Mar 2024
Parameters
[in]varNetCDF variable to check

Definition at line 632 of file mo_read_spatial_data.f90.

References is_x_axis().

Referenced by get_header_info_from_nc(), and is_x_axis().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_y_axis()

logical function mo_read_spatial_data::is_y_axis ( type(ncvariable), intent(in) var)
private

check if given variable is a y-axis.

Returns
logical :: is_y_axis
Authors
Sebastian Müller
Date
Mar 2024
Parameters
[in]varNetCDF variable to check

Definition at line 655 of file mo_read_spatial_data.f90.

References is_y_axis().

Referenced by get_header_info_from_nc(), and is_y_axis().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_header_ascii()

subroutine, public mo_read_spatial_data::read_header_ascii ( character(len = *), intent(in) filename,
integer(i4), intent(in) fileunit,
integer(i4), intent(out) header_ncols,
integer(i4), intent(out) header_nrows,
real(dp), intent(out) header_xllcorner,
real(dp), intent(out) header_yllcorner,
real(dp), intent(out) header_cellsize,
real(dp), intent(out) header_nodata )

Reads header lines of ASCII files.

Reads header lines of ASCII files, e.g. dem, aspect, flow direction.

Parameters
[in]character(len = *) :: filenameName of file and its location
[in]integer(i4) :: fileunitFile unit for open file
[out]integer(i4) :: header_nColsReference number of columns
[out]integer(i4) :: header_nRowsReference number of rows
[out]real(dp) :: header_xllcornerReference lower left corner (x)
[out]real(dp) :: header_yllcornerReference lower left corner (y)
[out]real(dp) :: header_cellsizeReference cell size [m]
[out]real(dp) :: header_nodataReference nodata value
Authors
Juliane Mai
Date
Jan 2013

Definition at line 398 of file mo_read_spatial_data.f90.

References mo_common_constants::nodata_dp.

Referenced by mo_meteo_handler::init_level2(), read_header_nc_or_ascii(), mo_read_spatial_data::read_spatial_data_ascii::read_spatial_data_ascii_dp(), mo_read_spatial_data::read_spatial_data_ascii::read_spatial_data_ascii_i4(), mo_read_spatial_data::read_spatial_data_nc_or_ascii::read_spatial_data_nc_or_ascii_dp(), and mo_read_spatial_data::read_spatial_data_nc_or_ascii::read_spatial_data_nc_or_ascii_i4().

Here is the caller graph for this function:

◆ read_header_nc_or_ascii()

subroutine, public mo_read_spatial_data::read_header_nc_or_ascii ( character(len=*), intent(in) filepath,
integer(i4), intent(in) fileunit,
integer(i4), intent(out) header_ncols,
integer(i4), intent(out) header_nrows,
real(dp), intent(out) header_xllcorner,
real(dp), intent(out) header_yllcorner,
real(dp), intent(out) header_cellsize,
real(dp), intent(out) header_nodata,
character(len=*), intent(in), optional varname )

Read header information from either NetCDF or ASCII depending on file name/presence.

Authors
Simon Lüdke
Date
Feb 2025

Definition at line 522 of file mo_read_spatial_data.f90.

References get_header_info_from_nc(), and read_header_ascii().

Referenced by mo_common_read_data::read_dem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_spatial_data_ascii_dp()

subroutine mo_read_spatial_data::read_spatial_data_ascii_dp ( character(len = *), intent(in) filename,
integer(i4), intent(in) fileunit,
integer(i4), intent(in) header_ncols,
integer(i4), intent(in) header_nrows,
real(dp), intent(in) header_xllcorner,
real(dp), intent(in) header_yllcorner,
real(dp), intent(in) header_cellsize,
real(dp), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), allocatable mask )
private

TODO: add description.

TODO: add description

Parameters
[in]character(len = *) :: filenamefilename with location
[in]integer(i4) :: fileunitunit for opening the file
[in]integer(i4) :: header_nColsnumber of columns of data fields:
[in]integer(i4) :: header_nRowsnumber of rows of data fields:
[in]real(dp) :: header_xllcornerheader read in lower left corner
[in]real(dp) :: header_yllcornerheader read in lower left corner
[in]real(dp) :: header_cellsizeheader read in cellsize
[out]real(dp), dimension(:, :) :: datadata
[out]logical, dimension(:, :) :: maskmask
Authors
Robert Schweppe
Date
Jun 2018

Definition at line 139 of file mo_read_spatial_data.f90.

◆ read_spatial_data_ascii_i4()

subroutine mo_read_spatial_data::read_spatial_data_ascii_i4 ( character(len = *), intent(in) filename,
integer(i4), intent(in) fileunit,
integer(i4), intent(in) header_ncols,
integer(i4), intent(in) header_nrows,
real(dp), intent(in) header_xllcorner,
real(dp), intent(in) header_yllcorner,
real(dp), intent(in) header_cellsize,
integer(i4), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), allocatable mask )
private

TODO: add description.

TODO: add description

Parameters
[in]character(len = *) :: filenamefilename with location
[in]integer(i4) :: fileunitunit for opening the file
[in]integer(i4) :: header_nColsnumber of columns of data fields:
[in]integer(i4) :: header_nRowsnumber of rows of data fields:
[in]real(dp) :: header_xllcornerheader read in lower left corner
[in]real(dp) :: header_yllcornerheader read in lower left corner
[in]real(dp) :: header_cellsizeheader read in cellsize
[out]integer(i4), dimension(:, :) :: datadata
[out]logical, dimension(:, :) :: maskmask
Authors
Robert Schweppe
Date
Jun 2018

Definition at line 268 of file mo_read_spatial_data.f90.

◆ read_spatial_data_nc_dp()

subroutine mo_read_spatial_data::read_spatial_data_nc_dp ( character(len=*), intent(in) ncname,
real(dp), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), optional, allocatable maskout,
integer(i4), intent(out) ncols,
integer(i4), intent(out) nrows,
real(dp), intent(out) xllcorner,
real(dp), intent(out) yllcorner,
real(dp), intent(out) cellsize,
real(dp), intent(out) nodata_value,
character(len=*), intent(in), optional varname )
private

Read file from filepath.

If there is a nc file with the correct name it is prefered over the asci file.

TODO: add description

Authors
Simon Lüdke
Date
June 2025

Definition at line 981 of file mo_read_spatial_data.f90.

◆ read_spatial_data_nc_i4()

subroutine mo_read_spatial_data::read_spatial_data_nc_i4 ( character(len=*), intent(in) ncname,
integer(i4), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), optional, allocatable maskout,
integer(i4), intent(out) ncols,
integer(i4), intent(out) nrows,
real(dp), intent(out) xllcorner,
real(dp), intent(out) yllcorner,
real(dp), intent(out) cellsize,
real(dp), intent(out) nodata_value,
character(len=*), intent(in), optional varname )
private

Read file from filepath.

If there is a nc file with the correct name it is prefered over the asci file.

TODO: add description

Authors
Simon Lüdke
Date
June 2025

Definition at line 908 of file mo_read_spatial_data.f90.

◆ read_spatial_data_nc_or_ascii_dp()

subroutine mo_read_spatial_data::read_spatial_data_nc_or_ascii_dp ( character(len = *), intent(in) filepath,
integer(i4), intent(in) fileunit,
integer(i4), intent(in) header_ncols,
integer(i4), intent(in) header_nrows,
real(dp), intent(in) header_xllcorner,
real(dp), intent(in) header_yllcorner,
real(dp), intent(in) header_cellsize,
real(dp), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), optional, allocatable maskout,
integer(i4), intent(out), optional out_ncols,
integer(i4), intent(out), optional out_nrows,
real(dp), intent(out), optional out_xllcorner,
real(dp), intent(out), optional out_yllcorner,
real(dp), intent(out), optional out_cellsize,
real(dp), intent(out), optional out_nodata_value )
private

Read file from filepath.

If there is a nc file with the correct name it is prefered over the asci file.

TODO: add description

Authors
Simon Lüdke
Date
June 2025

Definition at line 1056 of file mo_read_spatial_data.f90.

◆ read_spatial_data_nc_or_ascii_i4()

subroutine mo_read_spatial_data::read_spatial_data_nc_or_ascii_i4 ( character(len = *), intent(in) filepath,
integer(i4), intent(in) fileunit,
integer(i4), intent(in) header_ncols,
integer(i4), intent(in) header_nrows,
real(dp), intent(in) header_xllcorner,
real(dp), intent(in) header_yllcorner,
real(dp), intent(in) header_cellsize,
integer(i4), dimension(:, :), intent(out), allocatable data,
logical, dimension(:, :), intent(out), optional, allocatable maskout,
integer(i4), intent(out), optional out_ncols,
integer(i4), intent(out), optional out_nrows,
real(dp), intent(out), optional out_xllcorner,
real(dp), intent(out), optional out_yllcorner,
real(dp), intent(out), optional out_cellsize,
real(dp), intent(out), optional out_nodata_value )
private

Read file from filepath.

If there is a nc file with the correct name it is prefered over the asci file.

TODO: add description

Authors
Simon Lüdke
Date
June 2025

Definition at line 1176 of file mo_read_spatial_data.f90.