MONC
Functions/Subroutines | Variables
checkpointer_mod Module Reference

Checkpointing NetCDF functionality. More...

Functions/Subroutines

type(component_descriptor_type) function, public checkpointer_get_descriptor ()
 Provides registry information for the component. More...
 
subroutine initialisation_callback (current_state)
 Initialisation hook, if appropriate (depends on command line arguments) then will read in an existing checkpoint file and use this as the basis for model state. More...
 
subroutine timestep_callback (current_state)
 The timestep hook will dump out model state_mod to a checkpoint file. More...
 
subroutine finalisation_callback (current_state)
 Called on termination to write out the status of the model run to checkpoint. More...
 
subroutine perform_checkpoint_dump (current_state)
 Performs the checkpoint dump and timings. This can be called as part of the timestep or at the end of a model run. More...
 
subroutine log_dump_stats (current_state, start_time, end_time)
 Will dump out the model dump statistics. More...
 
subroutine generate_unique_filename (current_state, new_name)
 Generates a unique filename based upon the base one specified and the number of completed timesteps. More...
 

Variables

character(len=string_length), save checkpoint_file
 The checkpoint write file base name. More...
 
logical, save unique_per_dump
 Whether to make each model dump a unique filename. More...
 
logical, save enable_write
 
integer, save checkpoint_frequency
 

Detailed Description

Checkpointing NetCDF functionality.

Both reads and initalises the model based upon a checkpoint and writes (dumps) model status to a checkpoint

Function/Subroutine Documentation

◆ checkpointer_get_descriptor()

type(component_descriptor_type) function, public checkpointer_mod::checkpointer_get_descriptor ( )

Provides registry information for the component.

Returns
The component descriptor that describes this component

Definition at line 32 of file checkpointer.F90.

32  checkpointer_get_descriptor%name="checkpointer"
33  checkpointer_get_descriptor%version=0.1
34  checkpointer_get_descriptor%initialisation=>initialisation_callback
35  checkpointer_get_descriptor%timestep=>timestep_callback
36  checkpointer_get_descriptor%finalisation=>finalisation_callback
Here is the call graph for this function:

◆ finalisation_callback()

subroutine checkpointer_mod::finalisation_callback ( type(model_state_type), intent(inout), target  current_state)
private

Called on termination to write out the status of the model run to checkpoint.

Parameters
current_stateThe current model state

Definition at line 78 of file checkpointer.F90.

78  type(model_state_type), target, intent(inout) :: current_state
79 
80  if (enable_write) call perform_checkpoint_dump(current_state)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_unique_filename()

subroutine checkpointer_mod::generate_unique_filename ( type(model_state_type), intent(inout)  current_state,
character(len=string_length), intent(out)  new_name 
)
private

Generates a unique filename based upon the base one specified and the number of completed timesteps.

Parameters
current_stateThe current model state
newNameThe new name that is produced by this subroutine

Definition at line 123 of file checkpointer.F90.

123  type(model_state_type), intent(inout) :: current_state
124  character(len=STRING_LENGTH), intent(out) :: new_name
125 
126  integer :: dot_posn
127 
128  dot_posn=index(checkpoint_file, ".")
129  if (dot_posn .gt. 0) then
130  new_name = checkpoint_file(1:dot_posn-1)
131  else
132  new_name=checkpoint_file
133  end if
134  new_name=trim(new_name)//"_"//trim(conv_to_string(current_state%timestep))
135  if (dot_posn .gt. 0) then
136  new_name=trim(new_name)//checkpoint_file(dot_posn:len(checkpoint_file))
137  end if
Here is the caller graph for this function:

◆ initialisation_callback()

subroutine checkpointer_mod::initialisation_callback ( type(model_state_type), intent(inout), target  current_state)
private

Initialisation hook, if appropriate (depends on command line arguments) then will read in an existing checkpoint file and use this as the basis for model state.

Parameters
current_stateThe current model state

Definition at line 43 of file checkpointer.F90.

43  type(model_state_type), target, intent(inout) :: current_state
44 
45  character(len=STRING_LENGTH) :: internal_write_mode
46 
47  checkpoint_frequency=options_get_integer(current_state%options_database, "checkpoint_frequency")
48  checkpoint_file=options_get_string(current_state%options_database, "checkpoint_file")
49  unique_per_dump=options_get_logical(current_state%options_database, "checkpoint_unique_per_dump")
50  internal_write_mode=options_get_string(current_state%options_database, "checkpoint_internal_write")
51  if (trim(internal_write_mode) .eq. "always") then
52  enable_write=.true.
53  else if (trim(internal_write_mode) .eq. "never") then
54  enable_write=.false.
55  else
56  ! Auto mode
57  enable_write=.not. current_state%io_server_enabled
58  end if
59 
60  if (options_has_key(current_state%options_database, "checkpoint")) then
61  call read_checkpoint_file(current_state, options_get_string(current_state%options_database, "checkpoint"))
62  end if
Here is the caller graph for this function:

◆ log_dump_stats()

subroutine checkpointer_mod::log_dump_stats ( type(model_state_type), intent(inout)  current_state,
real  start_time,
real  end_time 
)
private

Will dump out the model dump statistics.

Parameters
current_stateThe current model state
startTimeThe start CPU time of the dump
endTimeThe end CPU time of the dump

Definition at line 111 of file checkpointer.F90.

111  type(model_state_type), intent(inout) :: current_state
112  real :: start_time, end_time
113 
114  call log_master_newline()
115  call log_master_log(log_info, "Model dump completed in "//trim(conv_to_string(int((end_time-start_time)*1000)))//"ms")
Here is the caller graph for this function:

◆ perform_checkpoint_dump()

subroutine checkpointer_mod::perform_checkpoint_dump ( type(model_state_type), intent(inout), target  current_state)
private

Performs the checkpoint dump and timings. This can be called as part of the timestep or at the end of a model run.

Parameters
current_stateThe current model state

Definition at line 87 of file checkpointer.F90.

87  type(model_state_type), target, intent(inout) :: current_state
88 
89  character(len=STRING_LENGTH) :: unique_fn
90  real :: start_dump_time, end_dump_time
91  integer :: ierr
92 
93  call cpu_time(start_dump_time)
94  if (unique_per_dump) then
95  call generate_unique_filename(current_state, unique_fn)
96  call write_checkpoint_file(current_state, unique_fn)
97  else
98  call write_checkpoint_file(current_state, checkpoint_file)
99  end if
100  ! Barrier here to ensure all processes dumped before log_log stats (is there a better way?)
101  call mpi_barrier(current_state%parallel%monc_communicator, ierr)
102  call cpu_time(end_dump_time)
103  call log_dump_stats(current_state, start_dump_time, end_dump_time)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timestep_callback()

subroutine checkpointer_mod::timestep_callback ( type(model_state_type), intent(inout), target  current_state)
private

The timestep hook will dump out model state_mod to a checkpoint file.

Parameters
current_stateThe current model state

Definition at line 68 of file checkpointer.F90.

68  type(model_state_type), target, intent(inout) :: current_state
69 
70  if (enable_write .and. checkpoint_frequency .gt. 0) then
71  if (mod(current_state%timestep, checkpoint_frequency) == 0) call perform_checkpoint_dump(current_state)
72  end if
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ checkpoint_file

character(len=string_length), save checkpointer_mod::checkpoint_file
private

The checkpoint write file base name.

Definition at line 20 of file checkpointer.F90.

20  character(len=STRING_LENGTH), save :: checkpoint_file

◆ checkpoint_frequency

integer, save checkpointer_mod::checkpoint_frequency
private

Definition at line 23 of file checkpointer.F90.

23  integer, save :: checkpoint_frequency

◆ enable_write

logical, save checkpointer_mod::enable_write
private

Definition at line 21 of file checkpointer.F90.

◆ unique_per_dump

logical, save checkpointer_mod::unique_per_dump
private

Whether to make each model dump a unique filename.

Definition at line 21 of file checkpointer.F90.

21  logical, save :: unique_per_dump, & !< Whether to make each model dump a unique filename
22  enable_write