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

Reads forcing input data. More...

Functions/Subroutines

subroutine, public read_nc (folder, nrows, ncols, varname, mask, data, target_period, lower, upper, nctimestep, filename, nocheck, maskout, is_meteo, bound_error, ntstepforcingday)
 Reads forcing input in NetCDF file format.
 
subroutine, public read_const_nc (folder, nrows, ncols, varname, data, filename)
 Reads time independent forcing input in NetCDF file format.
 
subroutine, public read_weights_nc (folder, nrows, ncols, varname, data, mask, lower, upper, nocheck, maskout, filename, bound_error)
 Reads weights for meteo forcings input in NetCDF file format.
 
subroutine get_time_vector_and_select (var, fname, inctimestep, time_start, time_cnt, target_period)
 Extract time vector in unit julian hours and get supposed time step in hours.
 

Detailed Description

Reads forcing input data.

This module is to read forcing input data contained in netcdf files, e.g. temperature, precipitation, total_runoff, lai. Timesteps can be hourly, daily, monthly, and annual. The module provides a subroutine for NetCDF files only. First, the dimensions given are cross-checked with header.txt information. Second, the data of the specified period are read from the specified directory. If the optional lower and/or upper bound for the data values is given, the read data are checked for validity. The program is stopped if any value lies out of range.

Changelog
  • Stephan Thober Sep 2015
    • separated routines for netcdf files from routines for binary files
  • Stephan Thober Jan 2017
    • added reading weights for disaggregation of daily meteorological values to hourly ones
  • Robert Schweppe Nov 2017
    • switched to mo_netcdf library and restuctured routines
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
  • Sebastian Müller Mar 2023
    • documentation update
    • added bound_error to control if an error is raised if boundaries are violated
Authors
Juliane Mai
Date
Dec 2012


Function/Subroutine Documentation

◆ get_time_vector_and_select()

subroutine mo_read_nc::get_time_vector_and_select ( type(ncvariable), intent(in) var,
character(256), intent(in) fname,
integer(i4), intent(out) inctimestep,
integer(i4), intent(out) time_start,
integer(i4), intent(out) time_cnt,
type(period), intent(in), optional target_period )
private

Extract time vector in unit julian hours and get supposed time step in hours.

Changelog
  • Matthias Cuntz & Juliane Mai Nov 2014
    • time int or double
  • Stephan Thober Sep 2015
    • added read for hourly data
  • Robert Schweppe Nov 2017
    • restructured routine, reads vector now
  • Maren Kaluza May 2018
    • fixed bug in time reading
  • Stephan Thober Aug 2020
    • fixed hourly reading
  • Stephan Thober Jan 2022
    • deactivated monthly and annual reading added nTstepForcingDay for hourly reading
Authors
Matthias Zink
Date
Oct 2012
Parameters
[in]varvariable of interest
[in]fnamefname of ncfile for error message
[out]inctimestepflag for requested time step
[out]time_starttime_start index of time selection
[out]time_cnttime_count of indexes of time selection
[in]target_periodreference period

Definition at line 487 of file mo_read_nc.f90.

Referenced by read_nc().

Here is the caller graph for this function:

◆ read_const_nc()

subroutine, public mo_read_nc::read_const_nc ( character(len=*), intent(in) folder,
integer(i4), intent(in) nrows,
integer(i4), intent(in) ncols,
character(len=*), intent(in) varname,
real(dp), dimension(:,:), intent(out), allocatable data,
character(256), intent(in), optional filename )

Reads time independent forcing input in NetCDF file format.

Reads time independent netCDF forcing files.
First, the dimensions given are cross-checked with header.txt information. Second, the data of the specified period are read from the specified directory. If the optional lower and/or upper bound for the data values is given, the read data are checked for validity. The program is stopped if any value lies out of range.
If the optinal argument nocheck is true, the data are not checked for coverage with the input mask. Additionally in this case an mask of vild data points can be received from the routine in maskout.

Note
Files have to be called like defined in mo_files. Furthermore the variable names have to be called like they are defined in the declaration of this subroutine. The NetCDF file has to have 2 dimensions:
  1. x, 2. y, It is expected that the variables (especially)within the NetCDF files contain an unit attribute. The timestep has to be equidistant.
Author
Lennart Schueler, heavily influenced by read_nc
Date
May 2018
Parameters
[in]folderfolder where data are stored
[in]nrowsnumber of rows of data fields:
[in]ncolsnumber of columns of data fields:
[in]varnamename of NetCDF variable
[out]datadata read in
[in]filenamename of file, defaults to varName

Definition at line 272 of file mo_read_nc.f90.

Referenced by mo_mrm_riv_temp_class::init_area(), and mo_mrm_read_data::mrm_read_bankfull_runoff().

Here is the caller graph for this function:

◆ read_nc()

subroutine, public mo_read_nc::read_nc ( character(len = *), intent(in) folder,
integer(i4), intent(in) nrows,
integer(i4), intent(in) ncols,
character(len = *), intent(in) varname,
logical, dimension(:, :), intent(in) mask,
real(dp), dimension(:, :, :), intent(out), allocatable data,
type(period), intent(in), optional target_period,
real(dp), intent(in), optional lower,
real(dp), intent(in), optional upper,
integer(i4), intent(in), optional nctimestep,
character(256), intent(in), optional filename,
logical, intent(in), optional nocheck,
logical, dimension(:, :, :), intent(out), optional, allocatable maskout,
logical, intent(in), optional is_meteo,
logical, intent(in), optional bound_error,
integer(i4), intent(inout), optional ntstepforcingday )

Reads forcing input in NetCDF file format.

Reads netCDF forcing files. First, the dimensions given are cross-checked with header.txt information. Second, the data of the specified period are read from the specified directory. If the optional lower and/or upper bound for the data values is given, the read data are checked for validity. The program is stopped if any value lies out of range. If the optinal argument nocheck is true, the data are not checked for coverage with the input mask. Additionally in this case an mask of vild data points can be received from the routine in maskout.

Changelog
  • Stephan Thober Nov 2013
    • only read required chunk from nc file
  • Matthias Cuntz & Juliane Mai Nov 2014 - read daily, monthly or yearly files
  • Matthias Zink Mar 2014
    • added optional nocheck flag and optional maskout
  • Stephan Thober Sep 2015
    • added read for hourly data
  • Robert Schweppe Nov 2017
    • switched to mo_netcdf library and restuctured routines
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
  • Sebastian Müller Mar 2023
    • added bound_error to control if an error is raised if boundaries are violated
    • add nTstepForcingDay as argument to be independent of global variables
Authors
Matthias Zink
Date
May 2013
Parameters
[in]folderName of the folder where data are stored
[in]nrowsNumber of datapoints in longitudinal direction
[in]ncolsNumber of datapoints in latitudinal direction
[in]varnameName of variable name to read
[in]maskmask of valid data fields
[out]dataData matrixdim_1 = longitude, dim_2 = latitude, dim_3 = time
[in]target_periodPeriod the data are needed for
[in]lowerLower bound for check of validity of data values
[in]upperUpper bound for check of validity of data values
[in]nctimesteptimestep in netcdf file
[in]filenamename of file, defaults to varName
[in]nocheck.TRUE. if check for nodata values deactivated, default = .FALSE. - check is done
[out]maskoutmask of validdata points
[in]is_meteological whether meteorology is currently read
[in]bound_error.FALSE. to only warn about bound (lower, upper) violations, default = .TRUE. - raise an error
[in,out]ntstepforcingdayNumber of datapoints in longitudinal direction

Definition at line 66 of file mo_read_nc.f90.

References get_time_vector_and_select().

Referenced by mo_meteo_helper::meteo_forcings_wrapper(), mo_mrm_read_data::mrm_read_total_runoff(), mo_prepare_gridded_lai::prepare_gridded_daily_lai_data(), and mo_read_optional_data::readoptidataobs().

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

◆ read_weights_nc()

subroutine, public mo_read_nc::read_weights_nc ( character(len = *), intent(in) folder,
integer(i4), intent(in) nrows,
integer(i4), intent(in) ncols,
character(len = *), intent(in) varname,
real(dp), dimension(:, :, :, :), intent(out), allocatable data,
logical, dimension(:, :), intent(in) mask,
real(dp), intent(in), optional lower,
real(dp), intent(in), optional upper,
logical, intent(in), optional nocheck,
logical, dimension(:, :, :, :), intent(out), optional, allocatable maskout,
character(256), intent(in), optional filename,
logical, intent(in), optional bound_error )

Reads weights for meteo forcings input in NetCDF file format.

Reads netCDF weight files. First, the dimensions given are cross-checked with header.txt information. If the optional lower and/or upper bound for the data values is given, the read data are checked for validity. The program is stopped if any value lies out of range. If the optinal argument nocheck is true, the data are not checked for coverage with the input mask. Additionally in this case an mask of vild data points can be received from the routine in maskout.

Changelog
  • Robert Schweppe Nov 2017
    • switched to mo_netcdf library and restuctured routine
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
  • Sebastian Müller Mar 2023
    • added bound_error to control if an error is raised if boundaries are violated
Authors
Stephan Thober & Matthias Zink
Date
Jan 2017
Parameters
[in]folderName of the folder where data are stored
[in]nrowsNumber of datapoints in longitudinal direction
[in]ncolsNumber of datapoints in latitudinal direction
[in]varnameName of variable name to read
[out]dataData matrixdim_1 = longitude, dim_2 = latitude, dim_3 = months, dim_4 = hours
[in]maskmask of valid data fields
[in]lowerLower bound for check of validity of data values
[in]upperUpper bound for check of validity of data values
[in]nocheck.TRUE. if check for nodata values deactivateddefault = .FALSE. - check is done
[in]filenamename of variable, defaults to fileName
[out]maskout! mask of validdata points
[in]bound_error.FALSE. to only warn about bound (lower, upper) violations, default = .TRUE. - raise an error

Definition at line 343 of file mo_read_nc.f90.

Referenced by mo_meteo_helper::meteo_weights_wrapper().

Here is the caller graph for this function: