# mom_write_cputime module reference¶

A module to monitor the overall CPU time used by MOM6 and project when to stop the model.

More…

## Data Types¶

 write_cputime_cs A control structure that regulates the writing of CPU time.

## Functions/Subroutines¶

 write_cputime_start_clock() Evaluate the CPU time returned by SYSTEM_CLOCK at the start of a run. mom_write_cputime_init() Initialize the MOM_write_cputime module. mom_write_cputime_end() Close the MOM_write_cputime module. write_cputime() This subroutine assesses how much CPU time the model has taken and determines how long the model should be run before it saves a restart file and stops itself.

## Detailed Description¶

By Robert Hallberg, May 2006.

This file contains the subroutine (write_cputime) that writes the summed CPU time across all processors to an output file. In addition, write_cputime estimates how many more time steps can be taken before 95% of the available CPU time is used, so that the model can be checkpointed at that time.

## Type Documentation¶

type mom_write_cputime/write_cputime_cs

A control structure that regulates the writing of CPU time.

Type fields
• % maxcpu [real] :: The maximum amount of cpu time per processor for which MOM should run before saving a restart file and quiting with a return value that indicates that further execution is required to complete the simulation, in wall-clock seconds.

• % start_time [type(time_type)] :: The start time of the simulation. Start_time is set in MOM_initialization.F90.

• % startup_cputime [real] :: The CPU time used in the startup phase of the model.

• % prev_cputime [real] :: The last measured CPU time.

• % dn_dcpu_min [real] :: The minimum derivative of timestep with CPU time.

• % cputime2 [real] :: The accumulated cpu time.

• % previous_calls [integer] :: The number of times write_CPUtime has been called.

• % prev_n [integer] :: The value of n from the last call.

• % filecpu_ascii [integer] :: The unit number of the CPU time file.

• % cpufile [character (len=200)] :: The name of the CPU time file.

## Function/Subroutine Documentation¶

subroutine mom_write_cputime/write_cputime_start_clock(CS)

Evaluate the CPU time returned by SYSTEM_CLOCK at the start of a run.

Parameters

cs :: The control structure set up by a previous call to MOM_write_cputime_init.

Call to

clocks_per_sec max_ticks

Called from

mom_main

subroutine mom_write_cputime/mom_write_cputime_init(param_file, directory, Input_start_time, CS)

Initialize the MOM_write_cputime module.

Parameters
• param_file :: [in] A structure to parse for run-time parameters

• directory :: [in] The directory where the CPU time file goes.

• input_start_time :: [in] The start model time of the simulation.

• cs :: A pointer that may be set to point to the control structure for this module.

Call to

clocks_per_sec max_ticks

Called from

mom_main

subroutine mom_write_cputime/mom_write_cputime_end(CS)

Close the MOM_write_cputime module.

Parameters

cs :: The control structure set up by a previous call to MOM_write_cputime_init.

Called from

write_cputime

subroutine mom_write_cputime/write_cputime(day, n, CS, nmax, call_end)

This subroutine assesses how much CPU time the model has taken and determines how long the model should be run before it saves a restart file and stops itself. Optionally this may also be used to trigger this module’s end routine.

Parameters
• day :: [inout] The current model time.

• n :: [in] The time step number of the current execution.

• cs :: The control structure set up by a previous call to MOM_write_cputime_init.

• nmax :: [inout] The number of iterations after which to stop so that the simulation will not run out of CPU time.

• call_end :: [in] If true, also call MOM_write_cputime_end.

Call to

clocks_per_sec max_ticks mom_error_handler::mom_error mom_write_cputime_end

Called from

mom_main