5.13.2-dev0
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_nc_output Module Reference

Creates NetCDF output for different fluxes and state variables of mHM. More...

Data Types

interface  outputdataset
 
interface  outputvariable
 

Functions/Subroutines

character(3) function, public data_dtype (double_precision)
 Output variable dtype for single or double precision.
 
character(16) function, dimension(3), public data_dims ()
 Output variable dimension names.
 
type(outputvariable) function newoutputvariable (nc, name, dtype, dims, ncells, mask, deflate_level, avg)
 Initialize OutputVariable.
 
subroutine updatevariable (self, data)
 Update OutputVariable.
 
subroutine writevariabletimestep (self, current_time_step)
 Write timestep to file.
 
type(outputdataset) function newoutputdataset (idomain, level, file_name, double_precision, outputs_frequence, time_reference)
 Initialize OutputDataset.
 
subroutine writetimestep (self, current_time_step)
 Write all accumulated data.
 
subroutine close (self)
 Close the file.
 
type(ncdataset) function createoutputfile (idomain, level, file_name, double_precision, outputs_frequence, time_reference)
 Create and initialize output file for X & Y coordinate system.
 
subroutine, public set_attributes (var, long_name, unit, double_precision, add_coords, standard_name, axis, bounds)
 Write output variable attributes.
 

Detailed Description

Creates NetCDF output for different fluxes and state variables of mHM.

NetCDF is first initialized and later on variables are put to the NetCDF.

Changelog
  • David Schaefer Aug 2015
    • major rewrite
  • Stephan Thober Oct 2015
    • adapted to mRM
  • O. Rakovec, R. Kumar Nov 2017
    • added project description for the netcdf outputs
  • S. Mueller, Dec 2022
    • unified module for mHM and mRM
Authors
Matthias Zink
Date
Apr 2013

Function/Subroutine Documentation

◆ close()

subroutine mo_nc_output::close ( class(outputdataset self)
private

Close the file.

Close the file associated with variable of type(OutputDataset)

Changelog
  • Stephan Thober Oct 2015
    • adapted to mRM
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
Authors
Rohini Kumar & Stephan Thober
Date
August 2013

Definition at line 273 of file mo_nc_output.f90.

◆ createoutputfile()

type(ncdataset) function mo_nc_output::createoutputfile ( integer(i4), intent(in)  idomain,
type(grid), dimension(:), intent(in), allocatable  level,
character(*), intent(in)  file_name,
logical, intent(in)  double_precision,
integer(i4), intent(in)  outputs_frequence,
integer(i4), intent(in)  time_reference 
)
private

Create and initialize output file for X & Y coordinate system.

Create output file, write all non-dynamic variables and global attributes for the given domain for X & Y coordinate system

Changelog
  • Stephan Thober Oct 2015
    • adapted to mRM
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
  • Pallav Shrestha Mar 2020
    • output file lat and lon are 1d or 2d based on coordinate system
Returns
type(NcDataset)
Authors
David Schaefer
Date
June 2015
Parameters
[in]idomainselected domain
[in]levellevel definitions for all domains
[in]file_namelong name of the variable
[in]double_precisionmask on desired level
[in]outputs_frequencewrite out frequence (-3, -2, -1, 0, >0)
[in]time_referencetime stamp reference (0: begin, 1: center, 2: end of time interval)

Definition at line 301 of file mo_nc_output.f90.

References mo_common_variables::contact, mo_common_variables::conventions, data_dtype(), mo_common_variables::dirout, mo_common_mhm_mrm_variables::evalper, mo_grid::geocoordinates(), mo_common_variables::history, mo_common_variables::iflag_cordinate_sys, mo_grid::mapcoordinates(), mo_common_variables::mhm_details, mo_common_variables::project_details, set_attributes(), mo_common_variables::setup_description, mo_common_variables::simulation_type, mo_common_mhm_mrm_variables::timestep, and mo_file::version.

Referenced by newoutputdataset().

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

◆ data_dims()

character(16) function, dimension(3), public mo_nc_output::data_dims

Output variable dimension names.

Returns
(X, Y, T) names tuple

Definition at line 94 of file mo_nc_output.f90.

References data_dims(), and mo_common_variables::iflag_cordinate_sys.

Referenced by data_dims(), mo_mrm_write_fluxes_states::gw_outputdataset(), mo_write_fluxes_states::mhm_outputdataset(), and mo_mrm_write_fluxes_states::mrm_outputdataset().

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

◆ data_dtype()

character(3) function, public mo_nc_output::data_dtype ( logical, intent(in)  double_precision)

Output variable dtype for single or double precision.

Returns
"f64" or "f32"
Parameters
[in]double_precisionflag to use double precision

Definition at line 82 of file mo_nc_output.f90.

References data_dtype().

Referenced by createoutputfile(), data_dtype(), mo_mrm_write_fluxes_states::gw_outputdataset(), mo_write_fluxes_states::mhm_outputdataset(), and mo_mrm_write_fluxes_states::mrm_outputdataset().

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

◆ newoutputdataset()

type(outputdataset) function mo_nc_output::newoutputdataset ( integer(i4), intent(in)  idomain,
type(grid), dimension(:), intent(in), allocatable, target  level,
character(*), intent(in)  file_name,
logical, intent(in)  double_precision,
integer(i4), intent(in)  outputs_frequence,
integer(i4), intent(in)  time_reference 
)
private

Initialize OutputDataset.

Create and initialize the output file. If new a new output variable needs to be written, this is the first of two procedures to change (second: updateDataset)

Changelog
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
  • Sebastian Mueller Jul 2020
    • added output for river temperature
Returns
type(OutputDataset)
Authors
Matthias Zink
Date
Apr 2013
Parameters
[in]idomaindomain id
[in]levellevel definitions for all domains
[in]file_namelong name of the variable
[in]double_precisionmask on desired level
[in]outputs_frequencewrite out frequence (-3, -2, -1, 0, >0)
[in]time_referencetime stamp reference (0: begin, 1: center, 2: end of time interval)

Definition at line 189 of file mo_nc_output.f90.

References createoutputfile(), and mo_common_mhm_mrm_variables::timestep.

Here is the call graph for this function:

◆ newoutputvariable()

type(outputvariable) function mo_nc_output::newoutputvariable ( type(ncdataset), intent(in)  nc,
character(*), intent(in)  name,
character(*), intent(in)  dtype,
character(16), dimension(3), intent(in)  dims,
integer(i4), intent(in)  ncells,
logical, dimension(:, :), intent(in), target  mask,
integer(i4), intent(in)  deflate_level,
logical, intent(in), optional  avg 
)
private

Initialize OutputVariable.

Modifications:

  • David Schaefer Nov 2017 - added NcVariable initialization
  • Robert Schweppe Jun 2018 - refactoring and reformatting
    Returns
    type(OutputVariable)
    Authors
    David Schaefer
    Date
    June 2015
    Parameters
    [in]ncNcDataset which contains the variable
    [in]namename of the variable
    [in]dtypedata type of the variable
    [in]dimsdimensions of the variable (by name)
    [in]ncellsnumber of cells in domain
    [in]maskmask of the variable
    [in]deflate_leveldeflate level for compression
    [in]avgflag to average the data before writing

Definition at line 111 of file mo_nc_output.f90.

◆ set_attributes()

subroutine, public mo_nc_output::set_attributes ( type(ncvariable), intent(inout)  var,
character(*), intent(in), optional  long_name,
character(*), intent(in), optional  unit,
logical, intent(in), optional  double_precision,
logical, intent(in), optional  add_coords,
character(*), intent(in), optional  standard_name,
character(*), intent(in), optional  axis,
character(*), intent(in), optional  bounds 
)

Write output variable attributes.

Modifications:

  • Robert Schweppe Jun 2018 - refactoring and reformatting
    Authors
    David Schaefer
    Date
    June 2015
    Parameters
    [in,out]varNetCDF variable
    [in]long_namelong name of the variable
    [in]unitunit of the variable
    [in]double_precisionprecision flag, if missing, no fill-value and missing-value is written
    [in]add_coordswhether to add the "coordiantes" attribute "lat lon", .true. by defult
    [in]standard_namestandard name of the variable
    [in]axisaxis attribute
    [in]boundsbounds attribute

Definition at line 463 of file mo_nc_output.f90.

References mo_common_constants::nodata_dp.

Referenced by createoutputfile(), mo_mrm_write_fluxes_states::gw_outputdataset(), mo_write_fluxes_states::mhm_outputdataset(), and mo_mrm_write_fluxes_states::mrm_outputdataset().

Here is the caller graph for this function:

◆ updatevariable()

subroutine mo_nc_output::updatevariable ( class(outputvariable), intent(inout)  self,
real(dp), dimension(:), intent(in)  data 
)
private

Update OutputVariable.

Add the array given as actual argument to the derived type's component 'data'

Changelog
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
Returns
type(OutputVariable)
Authors
David Schaefer
Date
June 2015
Parameters
[in]datadata for current time step

Definition at line 140 of file mo_nc_output.f90.

◆ writetimestep()

subroutine mo_nc_output::writetimestep ( class(outputdataset), intent(inout), target  self,
integer(i4), intent(in)  current_time_step 
)
private

Write all accumulated data.

Write all accumulated and potentially averaged data to disk.

Changelog
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
Authors
David Schaefer
Date
June 2015
Parameters
[in]current_time_stepThe model timestep to write

Definition at line 228 of file mo_nc_output.f90.

◆ writevariabletimestep()

subroutine mo_nc_output::writevariabletimestep ( class(outputvariable), intent(inout)  self,
integer(i4), intent(in)  current_time_step 
)
private

Write timestep to file.

Write the content of the derived types's component 'data' to file, average if necessary

Changelog
  • Robert Schweppe Jun 2018
    • refactoring and reformatting
Authors
David Schafer
Date
June 2015
Parameters
[in]current_time_stepindex along the time dimension of the netcdf variable

Definition at line 158 of file mo_nc_output.f90.

References mo_common_constants::nodata_dp.