MONC
Functions/Subroutines | Variables
configuration_checkpoint_netcdf_parser_mod Module Reference

Loads in the configuration stored in a NetCDF checkpoint file for the model to start from. More...

Functions/Subroutines

subroutine, public parse_configuration_checkpoint_netcdf (options_database, checkpoint_name, communicator)
 Will parse the NetCDF checkpoint file and loads the configuration into the options database. More...
 
subroutine load_options (options_database, ncid)
 Will read in and initialise the options database from the contents of the checkpoint file. More...
 
subroutine remove_null_terminator_from_string (net_cdf_string)
 Removes NetCDF C style null termination of string. This is placed right at the end, after any spaces so trim will not actually trim any spaces due to null terminator. More...
 
integer function get_number_of_options (ncid)
 Retrieves the number of option key-value pairs that are present in the checkpoint file. More...
 

Variables

character(len= *), parameter options_key ="options_database"
 The options key which references the configuration. More...
 
character(len= *), parameter options_dim_key ="number_options"
 Options dimension key. More...
 

Detailed Description

Loads in the configuration stored in a NetCDF checkpoint file for the model to start from.

Function/Subroutine Documentation

◆ get_number_of_options()

integer function configuration_checkpoint_netcdf_parser_mod::get_number_of_options ( integer, intent(in)  ncid)
private

Retrieves the number of option key-value pairs that are present in the checkpoint file.

Parameters
ncidThe NetCDF file id
Returns
The number of options that will be read in

Definition at line 89 of file checkpointnetcdfparser.F90.

90  integer, intent(in) :: ncid
91 
92  integer :: options_dimid, options_dim
93  call check_netcdf_status(nf90_inq_dimid(ncid, options_dim_key, options_dimid))
94  call check_netcdf_status(nf90_inquire_dimension(ncid, options_dimid, len=options_dim))
95  get_number_of_options=options_dim
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_options()

subroutine configuration_checkpoint_netcdf_parser_mod::load_options ( type(hashmap_type), intent(inout)  options_database,
integer, intent(in)  ncid 
)
private

Will read in and initialise the options database from the contents of the checkpoint file.

Parameters
options_databaseThe options database to store the values into
ncidThe NetCDF file id

Definition at line 44 of file checkpointnetcdfparser.F90.

45  type(hashmap_type), intent(inout) :: options_database
46  integer, intent(in) :: ncid
47 
48  integer :: i, options_id, number_options
49  character(len=STRING_LENGTH) :: key, value
50 
51  number_options=get_number_of_options(ncid)
52  call check_netcdf_status(nf90_inq_varid(ncid, options_key, options_id))
53 
54  do i=1, number_options
55  call check_netcdf_status(nf90_get_var(ncid, options_id, key, (/ 1, 1, i /)))
56  call check_netcdf_status(nf90_get_var(ncid, options_id, value, (/ 1, 2, i /)))
57  ! NetCDF does C style null termination right at the end, need to remove this so can trim spaces etc
58  call remove_null_terminator_from_string(key)
59  call remove_null_terminator_from_string(value)
60  if (conv_is_integer(trim(value))) then
61  call options_add(options_database, trim(key), conv_to_integer(trim(value)))
62  else if (conv_is_real(trim(value))) then
63  call options_add(options_database, trim(key), conv_single_real_to_double(conv_to_real(trim(value))))
64  else if (conv_is_logical(trim(value))) then
65  call options_add(options_database, trim(key), conv_to_logical(trim(value)))
66  else
67  call options_add(options_database, trim(key), trim(value))
68  end if
69  end do
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_configuration_checkpoint_netcdf()

subroutine, public configuration_checkpoint_netcdf_parser_mod::parse_configuration_checkpoint_netcdf ( type(hashmap_type), intent(inout)  options_database,
character(*), intent(in)  checkpoint_name,
integer, intent(in)  communicator 
)

Will parse the NetCDF checkpoint file and loads the configuration into the options database.

Parameters
options_databaseThe options database
checkpoint_nameName of the checkpoint file
communicatorMPI communicator for parallel IO

Definition at line 29 of file checkpointnetcdfparser.F90.

30  type(hashmap_type), intent(inout) :: options_database
31  character(*), intent(in) :: checkpoint_name
32  integer, intent(in) :: communicator
33 
34  integer :: ncid
35 
36  call check_netcdf_status(nf90_open(path = checkpoint_name, mode = nf90_nowrite, ncid = ncid))
37  call load_options(options_database, ncid)
38  call check_netcdf_status(nf90_close(ncid))
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_null_terminator_from_string()

subroutine configuration_checkpoint_netcdf_parser_mod::remove_null_terminator_from_string ( character(len=*), intent(inout)  net_cdf_string)
private

Removes NetCDF C style null termination of string. This is placed right at the end, after any spaces so trim will not actually trim any spaces due to null terminator.

Parameters
netCDFStringThe NetCDF string to remove the null terminator from which is modified

Definition at line 75 of file checkpointnetcdfparser.F90.

76  character(len=*), intent(inout) :: net_cdf_string
77  integer :: i
78  do i=1,len(net_cdf_string)
79  if (iachar(net_cdf_string(i:i)) == 0) then
80  net_cdf_string(i:len(net_cdf_string)) = ' '
81  exit
82  end if
83  end do
Here is the caller graph for this function:

Variable Documentation

◆ options_dim_key

character(len=*), parameter configuration_checkpoint_netcdf_parser_mod::options_dim_key ="number_options"
private

Options dimension key.

Definition at line 19 of file checkpointnetcdfparser.F90.

◆ options_key

character(len=*), parameter configuration_checkpoint_netcdf_parser_mod::options_key ="options_database"
private

The options key which references the configuration.

Definition at line 19 of file checkpointnetcdfparser.F90.

19  character(len=*), parameter :: OPTIONS_KEY="options_database", & !< The options key which references the configuration
20  options_dim_key="number_options"