MONC
modelsynopsis.F90
Go to the documentation of this file.
1 
10  use mpi, only : mpi_wtime
11  implicit none
12 
13 #ifndef TEST_MODE
14  private
15 #endif
16 
18  double precision :: start_time
19 
21 
22 contains
23 
27  modelsynopsis_get_descriptor%name="model_synopsis"
32  end function modelsynopsis_get_descriptor
33 
34  subroutine initialisation_callback(current_state)
35  type(model_state_type), target, intent(inout) :: current_state
36 
37  reporting_frequency=options_get_integer(current_state%options_database, "display_synopsis_frequency")
38  previous_ts=current_state%timestep
39  start_time=mpi_wtime()
40  end subroutine initialisation_callback
41 
47  subroutine timestep_callback(current_state)
48  type(model_state_type), target, intent(inout) :: current_state
49 
50  double precision :: end_time
51 
52  if (mod(current_state%timestep, reporting_frequency)==0 .and. log_is_master()) then
53  end_time=mpi_wtime()
54  call log_newline()
55  call log_log(log_info, "Number of completed timesteps "//conv_to_string(current_state%timestep))
56  call log_log(log_info, "Completed "//trim(conv_to_string((current_state%timestep-previous_ts)+1))//&
57  " timesteps in "//trim(conv_to_string(int((end_time-start_time) * 1000)))//"ms")
58  call log_log(log_info, "Model time "//trim(conv_to_string(current_state%time, 5))//" seconds; dtm="//&
59  trim(conv_to_string(current_state%dtm, 5)))
60  previous_ts=current_state%timestep
61  start_time=mpi_wtime()
62  end if
63  end subroutine timestep_callback
64 
67  subroutine finalisation_callback(current_state)
68  type(model_state_type), target, intent(inout) :: current_state
69 
70  if (log_is_master()) then
71  call log_newline()
72  if (current_state%termination_reason == time_termination_reason) then
73  call log_log(log_info, "Model run complete due to model time "//&
74  trim(conv_to_string(current_state%time, 2))//" exceeding limit of "//&
75  trim(conv_to_string(options_get_real(current_state%options_database, "termination_time"), 2)))
76  else if (current_state%termination_reason == timestep_termination_reason) then
77  call log_log(log_info, "Model run complete due to timestep completion, model time is "//&
78  trim(conv_to_string(current_state%time, 2)))
79  else if (current_state%termination_reason == message_termination_reason) then
80  call log_log(log_info, "Model run complete due to messages file containing termination command, model time is "//&
81  trim(conv_to_string(current_state%time, 2)))
82  else if (current_state%termination_reason == walltime_termination_reason) then
83  call log_log(log_info, "Model run complete due to walltime limit of '"//&
84  trim(options_get_string(current_state%options_database, "walltime_limit"))//"' reached, model time is "//&
85  trim(conv_to_string(current_state%time, 2)))
86  else
87  call log_log(log_info, "Model run complete due to unknown reason, model time is "//&
88  trim(conv_to_string(current_state%time, 2)))
89  end if
90  end if
91  end subroutine finalisation_callback
92 end module modelsynopsis_mod
conversions_mod
Conversion between common inbuilt FORTRAN data types.
Definition: conversions.F90:5
modelsynopsis_mod::start_time
double precision start_time
Definition: modelsynopsis.F90:18
modelsynopsis_mod::initialisation_callback
subroutine initialisation_callback(current_state)
Definition: modelsynopsis.F90:35
logging_mod::log_newline
subroutine, public log_newline()
Will log a new line to the stdout.
Definition: logging.F90:91
state_mod::timestep_termination_reason
integer, parameter, public timestep_termination_reason
Definition: state.F90:17
optionsdatabase_mod::options_get_integer
integer function, public options_get_integer(options_database, key, index)
Retrieves an integer value from the database that matches the provided key.
Definition: optionsdatabase.F90:217
modelsynopsis_mod::previous_ts
integer previous_ts
Definition: modelsynopsis.F90:17
logging_mod::log_info
integer, parameter, public log_info
Log INFO, WARNING and ERROR messages.
Definition: logging.F90:13
logging_mod::log_log
subroutine, public log_log(level, message, str)
Logs a message at the specified level. If the level is above the current level then the message is ig...
Definition: logging.F90:75
modelsynopsis_mod::modelsynopsis_get_descriptor
type(component_descriptor_type) function, public modelsynopsis_get_descriptor()
Provides a description of this component for the core to register.
Definition: modelsynopsis.F90:27
modelsynopsis_mod
Displays information about the current state_mod of the model run.
Definition: modelsynopsis.F90:2
monc_component_mod
Interfaces and types that MONC components must specify.
Definition: monc_component.F90:6
optionsdatabase_mod::options_get_string
character(len=string_length) function, public options_get_string(options_database, key, index)
Retrieves a string value from the database that matches the provided key.
Definition: optionsdatabase.F90:280
modelsynopsis_mod::reporting_frequency
integer reporting_frequency
Definition: modelsynopsis.F90:17
conversions_mod::conv_to_string
Converts data types to strings.
Definition: conversions.F90:38
state_mod::model_state_type
The ModelState which represents the current state of a run.
Definition: state.F90:39
state_mod::time_termination_reason
integer, parameter, public time_termination_reason
The constants defining the reason why the model has terminated.
Definition: state.F90:17
logging_mod::log_is_master
logical function, public log_is_master()
Determines whether the process is the master logging process. This might be preferable rather than ca...
Definition: logging.F90:66
logging_mod
Logging utility.
Definition: logging.F90:2
state_mod::walltime_termination_reason
integer, parameter, public walltime_termination_reason
Definition: state.F90:17
datadefn_mod
Contains common definitions for the data and datatypes used by MONC.
Definition: datadefn.F90:2
modelsynopsis_mod::timestep_callback
subroutine timestep_callback(current_state)
Timestep callback hook which performs the halo swapping for each prognostic field.
Definition: modelsynopsis.F90:48
modelsynopsis_mod::finalisation_callback
subroutine finalisation_callback(current_state)
Called at the end of the MONC run, will log the reason why the model is terminating.
Definition: modelsynopsis.F90:68
state_mod::message_termination_reason
integer, parameter, public message_termination_reason
Definition: state.F90:17
optionsdatabase_mod
Manages the options database. Contains administration functions and deduce runtime options from the c...
Definition: optionsdatabase.F90:7
monc_component_mod::component_descriptor_type
Description of a component.
Definition: monc_component.F90:42
optionsdatabase_mod::options_get_real
real(kind=default_precision) function, public options_get_real(options_database, key, index)
Retrieves a real value from the database that matches the provided key.
Definition: optionsdatabase.F90:91
datadefn_mod::default_precision
integer, parameter, public default_precision
MPI communication type which we use for the prognostic and calculation data.
Definition: datadefn.F90:17
state_mod
The model state which represents the current state of a run.
Definition: state.F90:2