model_handling

Module Contents

Classes

ModelTypes

Available model types

GridTypes

ModelHandlerBase

Base class for all specific model handler.

Functions

get_model_handler(global_settings, model)

Method to get a single model handler.

get_model_handlers(global_settings)

Method to get handlers for all models that have input folders.

class model_handling.ModelTypes

Available model types

atmosphere = atmosphere

Identifier for atmospheric models.

Note that there can be only one atmospheric model in a coupled run.

bottom = bottom

Identifier for bottom models as ocean or land models.

In contrast to the atmosphere there can be several bottom models in a coupled run.

flux_calculator = flux_calculator

Reserved only for the flux_calculator.

other = other

Components, tools that are not coupled, as e.g. the int2lm tool.

class model_handling.GridTypes
t_grid = t_grid
u_grid = u_grid
v_grid = v_grid
model_handling.get_model_handler(global_settings, model)

Method to get a single model handler.

This method imports the model-specific handling module model_handling_ABCD.py where ABCD is a four letter acronym of the model.

Parameters
  • global_settings (class:GlobalSettings) – Object containing the global settings

  • model (str) – Name of the model’s input folder, usually model_domain, e.g. MOM5_Baltic. IMPORTANT: model names can only have four letters as e.g. MOM5, CCLM, GETM etc.

Returns

Specific model handler object

Return type

class:ModelHandler

model_handling.get_model_handlers(global_settings)

Method to get handlers for all models that have input folders.

This method checks the input folder and creates model handler objects for found models. If there is one atmospheric model and at least one bottom model the run will be interpreted as a coupled run. In that case the flux_calculator is added to the models.

Parameters

global_settings (class:GlobalSettings) – Object containing the global settings

Returns

Dictionary of specific model handler objects. The keys of the dictionary are the names of the input folders

Return type

dict

class model_handling.ModelHandlerBase(model_type, global_settings, my_directory, grids=[GridTypes.t_grid])

Base class for all specific model handler.

This constructor must be called in the constructor of the child class as e.g. ModelHandlerBase.__init__(self, model_handling.ModelTypes.bottom, global_settings, my_directory) The child class must be implmented as ModelHandler in a python module called model_handling_ABCD.py where ABCD is a four letter acronym of your model.

Parameters
  • global_settings (class:GlobalSettings) – Object containing the global settings

  • my_directory (str) – Name of the model’s input folder, usually model_domain, e.g. MOM5_Baltic. IMPORTANT: model names can only have four letters as e.g. MOM5, CCLM, GETM etc.

  • model_type (str) – Must be one of attributes of class ModelTypes

create_work_directory(self, work_directory_root, start_date, end_date)

Method to perform model-specific steps for creating the work directory.

This method is overwritten by the child class and will be called after the work directory has been created and the content of the input folder has been copied to that work directory.

It should typically do:

  • Copy the executable(s) to the work directory (not into subfolders)

  • Apply current start date and end date to input files

Parameters
  • work_directory_root (str) – Is the local work directory common to all models, thus it is one lvel above my_directory

  • start_date (str) – Start date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

  • end_date (str) – End date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

check_for_success(self, work_directory_root, start_date, end_date)

Method to check if model run was successful or not.

This method is overwritten by the child class and will be called after the MPI task has finished.

It should typically do:

  • Check for the existence of some specific output files.

Parameters
  • work_directory_root (str) – Is the local work directory common to all models, thus it is one lvel above my_directory

  • start_date (str) – Start date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

  • end_date (str) – End date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

Returns

True if model has finished successfully, False otherwise

Return type

bool

move_results(self, work_directory_root, start_date, end_date)

Method to move results from work to output folder.

This method is overwritten by the child class and will be called after the check_for_success method has returned True.

It should typically do:

  • Move all files you want to keep that are used or produced by your model.

Parameters
  • work_directory_root (str) – Is the local work directory common to all models, thus it is one lvel above my_directory

  • start_date (str) – Start date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

  • end_date (str) – End date of the current working period, format YYYYMMDD, e.g. 20220325 for the 25th of March 2022

grid_convert_to_SCRIP(self)
get_model_executable(self)

Method to get the name of the model’s excutable.

This method is overwritten by the child class and will be called when the MPI run script is created.

It should typically do:

  • Return the name of the executable that is located in your work directory after create_work_directory has been called.

Returns

Name of the excutable, e.g. “fms_MOM_SIS.x”

Return type

str

get_num_threads(self)

Method to get the number of threads the model is using.

This method is overwritten by the child class and will be called when the paralleization layout is created.

It should typically do:

  • Return the number of threads using e.g. settings in the model’s input files.

Returns

Number of used threads

Return type

int