Driver Component#
The driver component contains some convenience modules that can be used to help construct the driver layer of an application. Applications can use some or all of the driver component, mixing and matching as necessary.
Bear in mind that the driver component only supports typical usage. If your specific needs are not covered, then your application will need its own specific driver code. The driver component may act as a starting point for application specific driver code, but it should not be modified with any application specific logic.
Logging#
The logging component driver_log_mod provides procedures for
initialising and finalising the logging system using
the namelist configuration options of an application.
The init_logger procedure takes two arguments that are passed
directly to the logging system: an MPI communicator and a name that
will be used when constructing the name of the output log files.
The procedure reads the options that define whether the application is configured to write to rank zero only, and the logging level for the application. These are passed to the relevant calls of the logging system.
Warning
Several model applications configure the logging system based on namelist input. That means that namelists must be read prior to the logging system being initialised. The namelist code does include some calls to output log messages if there are errors in the namelist. Since the logger will not have been initialised, these error messages will appear in the standard output rather than in the PET output files.
Once initialised Logging may proceed as normal.
When you have logged the last thing you care to log call final_logger. This
takes a string which should be the same as the name passed to init_logger.
Reading Namelist Configuration Files#
Applications that use the extended Rose metadata to define their inputs can run the LFRic Configurator as part of the application build process. The Configurator generates all the code required to read namelist configuration files.
config_mod files
When examining code in existing LFRic applications you may come
across regular references to modules named with the suffix
_config_mod, from which configuration options are extracted. These
are the modules that are generated by the Configurator. Therefore,
they cannot be found in the code bases of the application! See the
section on how to use configuration information for details of these files.
The driver_config_mod component provides procedures for reading the
configuration files created by the Configurator.
Initialising#
Call the init_config procedure to read the namelist configuration.
use driver_config_mod, only: init_config
type(namelist_collection_type) :: configuration
<snip>
call init_config(filename, required_namelists, configuration)
Arguments are as follows:
filename: The file containing the namelist configuration.required_namelists: A list of character strings containing the name of all the namelists that the application must read.configurationAnamelist_collection_typewhich will be loaded with the contents of the namelist configuration file.
After reading the configuration file, the procedure checks whether all
the namelists in the required_namelists array were present in the
file, and reports an error if any are missing.
Once initialisation completes, applications can access
configuration information from the namelist_collection_type
configuration object or direct from the
config_mod files.