Skip to content

Commit

Permalink
converted save_restart and restore_state to interface that call versi…
Browse files Browse the repository at this point in the history
…ons of the routines with the fms-io or fms2-io interfaces

added module use statments for fms2_io and MOM_io helper routines to MOM_restart
added use_fms2=.true. arguments to save_restart and restore_state calls
added write_ic=.true. to the save_restart call in MOM.F90

added module MOM_axis with routines to define and register axes and their metadata
added module MOM_read_data_fms2.F90 with wrappers for fms2_io read_data interfaces and required routines
added module MOM_write_field_fms2.F90 with wrappers for fms2_io write_data interfaces
updated module use statments in MOM_io and MOM_restart to reference routines in MOM_read_data_fms2, MOM_write_field_fms2, and MOM_axis
made write_field and create_file interfaces in MOM_io
added create_file routines to MOM_io that accept file names or file objects to create/overwrite netcdf files that will be written to via write_field calls

fixed compile-time errors
added new MOM_read_data routines to MOM_read_data interface in MOM_io
added placeholder call for new write_field routines to MOM_io

changed use_fms2 to a required first argument in save_restart_fms2 and restore_state_fms2
changed write_ic to a required argument in write_initial_conditions

fixed the layer and interface checks in MOM_get_diagnostic_axis_data

commented out manual checksum registration in save_restart_fms2 so that internal fms2-io checksum computation is used

added checks for time units to restore_state and save_restart
added logic to make the restart time 1 to save_restart_fms2 if there is an abnormally large value passed to the routine
added interface routine file_exists_FMS2 that uses the fms2_io file_exists call

added subroutine get_num_restart_files to MOM_restart that searches for known variants of the input file names and returns then number of restart files available for querying, and the optional list of filepaths
added loop to search the files for all mandatory variables in the list of file paths returned to by cal to get_num_restart_files
added calls to get the variable dimension names and pass them as arguments to register_restart_field in restore_state_fms2

removed exit from inner variable loop in restore_state_fms2
code cleanup

moved missing_fields=0 outside of the CS loop in restore_state_fms2

moved missing_fields=0 outside of the CS loop in restore_state_fms2

converted save_restart and restore_state to interface that call versions of the routines with the fms-io or fms2-io interfaces
added module use statments for fms2_io and MOM_io helper routines to MOM_restart
added use_fms2=.true. arguments to save_restart and restore_state calls
added write_ic=.true. to the save_restart call in MOM.F90

added module MOM_axis with routines to define and register axes and their metadata
added module MOM_read_data_fms2.F90 with wrappers for fms2_io read_data interfaces and required routines
added module MOM_write_field_fms2.F90 with wrappers for fms2_io write_data interfaces
updated module use statments in MOM_io and MOM_restart to reference routines in MOM_read_data_fms2, MOM_write_field_fms2, and MOM_axis
made write_field and create_file interfaces in MOM_io
added create_file routines to MOM_io that accept file names or file objects to create/overwrite netcdf files that will be written to via write_field calls

fixed compile-time errors
added new MOM_read_data routines to MOM_read_data interface in MOM_io
added placeholder call for new write_field routines to MOM_io

changed use_fms2 to a required first argument in save_restart_fms2 and restore_state_fms2
changed write_ic to a required argument in write_initial_conditions

fixed the layer and interface checks in MOM_get_diagnostic_axis_data

commented out manual checksum registration in save_restart_fms2 so that internal fms2-io checksum computation is used

added checks for time units to restore_state and save_restart
added logic to make the restart time 1 to save_restart_fms2 if there is an abnormally large value passed to the routine
added interface routine file_exists_FMS2 that uses the fms2_io file_exists call

added subroutine get_num_restart_files to MOM_restart that searches for known variants of the input file names and returns then number of restart files available for querying, and the optional list of filepaths
added loop to search the files for all mandatory variables in the list of file paths returned to by cal to get_num_restart_files
added calls to get the variable dimension names and pass them as arguments to register_restart_field in restore_state_fms2

removed exit from inner variable loop in restore_state_fms2
code cleanup

removed test workflow directory

moved missing_fields=0 outside of the CS loop in restore_state_fms2

converted save_restart and restore_state to interface that call versions of the routines with the fms-io or fms2-io interfaces
added module use statments for fms2_io and MOM_io helper routines to MOM_restart
added use_fms2=.true. arguments to save_restart and restore_state calls
added write_ic=.true. to the save_restart call in MOM.F90

added module MOM_axis with routines to define and register axes and their metadata
added module MOM_read_data_fms2.F90 with wrappers for fms2_io read_data interfaces and required routines
added module MOM_write_field_fms2.F90 with wrappers for fms2_io write_data interfaces
updated module use statments in MOM_io and MOM_restart to reference routines in MOM_read_data_fms2, MOM_write_field_fms2, and MOM_axis
made write_field and create_file interfaces in MOM_io
added create_file routines to MOM_io that accept file names or file objects to create/overwrite netcdf files that will be written to via write_field calls

fixed compile-time errors
added new MOM_read_data routines to MOM_read_data interface in MOM_io
added placeholder call for new write_field routines to MOM_io

changed use_fms2 to a required first argument in save_restart_fms2 and restore_state_fms2
changed write_ic to a required argument in write_initial_conditions

fixed the layer and interface checks in MOM_get_diagnostic_axis_data

commented out manual checksum registration in save_restart_fms2 so that internal fms2-io checksum computation is used

added checks for time units to restore_state and save_restart
added logic to make the restart time 1 to save_restart_fms2 if there is an abnormally large value passed to the routine
added interface routine file_exists_FMS2 that uses the fms2_io file_exists call

added subroutine get_num_restart_files to MOM_restart that searches for known variants of the input file names and returns then number of restart files available for querying, and the optional list of filepaths
added loop to search the files for all mandatory variables in the list of file paths returned to by cal to get_num_restart_files
added calls to get the variable dimension names and pass them as arguments to register_restart_field in restore_state_fms2

removed exit from inner variable loop in restore_state_fms2
code cleanup

removed test workflow directory

removed white space

updated FMS tag in .testing Makefile
fixed argument comments to use doxygen style in MOM_write_field_fms2

code cleanup

removed \TODO from MOM_restart
fixed documentation for module variables in MOM_read_data_fms2 and MOM_write_field_fms2

removed doxygenized TODO statements

removed new MOM_read_data routines from interface, and commented out calls in MOM_io
fixed doxygen definitions

more doxygen fixes

changed save_restart and restore_state to wrapper routines with opitional use_fms2 and write_ic arguments
added use_fms2=.true. and write_ic=.true. to save_restart and restore_state calls

removed the error messages from append_substring
tried reordering the write_ic and use_fms2 checks in save_restart to fix error with invalid memory reference in the MOM.F90 call to save_restart-write_initial_conditions
  • Loading branch information
wrongkindofdoctor committed Aug 24, 2020
1 parent 40047fa commit 5c2daa5
Show file tree
Hide file tree
Showing 20 changed files with 5,313 additions and 83 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/hola_tierra.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MKMF := $(abspath $(DEPS)/mkmf/bin/mkmf)

# FMS framework
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS_COMMIT ?= 2019.01.03
FMS_COMMIT ?= 2020.03-alpha1
FMS := $(DEPS)/fms

#---
Expand Down
6 changes: 4 additions & 2 deletions config_src/coupled_driver/MOM_surface_forcing_gfdl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,8 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, &

if (.not.associated(CS)) return
if (.not.associated(CS%restart_CSp)) return
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface; omit this argument to use the old interface
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.)

end subroutine forcing_save_restart

Expand Down Expand Up @@ -1589,8 +1590,9 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, wind_stagger)
if ((dirs%input_filename(1:1) == 'n') .and. &
(LEN_TRIM(dirs%input_filename) == 1)) new_sim = .true.
if (.not.new_sim) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface; omit this argument to use the old interface
call restore_state(dirs%input_filename, dirs%restart_input_dir, Time_frc, &
G, CS%restart_CSp)
G, CS%restart_CSp, use_fms2=.true.)
endif
endif

Expand Down
10 changes: 6 additions & 4 deletions config_src/coupled_driver/ocean_model_MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,19 @@ subroutine ocean_model_restart(OS, timestamp)
"restart files can only be created after the buoyancy forcing is applied.")

if (BTEST(OS%Restart_control,1)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, .true., GV=OS%GV)
OS%restart_CSp, .true., GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir, .true.)
if (OS%use_ice_shelf) then
call ice_shelf_save_restart(OS%Ice_shelf_CSp, OS%Time, OS%dirs%restart_output_dir, .true.)
endif
endif
if (BTEST(OS%Restart_control,0)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, GV=OS%GV)
OS%restart_CSp, GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir)
if (OS%use_ice_shelf) then
Expand Down Expand Up @@ -746,8 +748,8 @@ subroutine ocean_model_save_restart(OS, Time, directory, filename_suffix)

if (present(directory)) then ; restart_dir = directory
else ; restart_dir = OS%dirs%restart_output_dir ; endif

call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV, use_fms2=.true.)

call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir)

Expand Down
11 changes: 7 additions & 4 deletions config_src/mct_driver/mom_ocean_model_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,9 @@ subroutine ocean_model_restart(OS, timestamp, restartname)
"restart files can only be created after the buoyancy forcing is applied.")

if (present(restartname)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, GV=OS%GV, filename=restartname)
OS%restart_CSp, GV=OS%GV, filename=restartname, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir) ! Is this needed?
if (OS%use_ice_shelf) then
Expand All @@ -700,17 +701,19 @@ subroutine ocean_model_restart(OS, timestamp, restartname)
endif
else
if (BTEST(OS%Restart_control,1)) then
! NOTE:use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, .true., GV=OS%GV)
OS%restart_CSp, .true., GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir, .true.)
if (OS%use_ice_shelf) then
call ice_shelf_save_restart(OS%Ice_shelf_CSp, OS%Time, OS%dirs%restart_output_dir, .true.)
endif
endif
if (BTEST(OS%Restart_control,0)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, GV=OS%GV)
OS%restart_CSp, GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir)
if (OS%use_ice_shelf) then
Expand Down Expand Up @@ -766,7 +769,7 @@ subroutine ocean_model_save_restart(OS, Time, directory, filename_suffix)
if (present(directory)) then ; restart_dir = directory
else ; restart_dir = OS%dirs%restart_output_dir ; endif

call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV)
call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV, use_fms2=.true.)

call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir)

Expand Down
6 changes: 4 additions & 2 deletions config_src/mct_driver/mom_surface_forcing_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,8 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, &

if (.not.associated(CS)) return
if (.not.associated(CS%restart_CSp)) return
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(.true., directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.)

end subroutine forcing_save_restart

Expand Down Expand Up @@ -1325,8 +1326,9 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,
if ((dirs%input_filename(1:1) == 'n') .and. &
(LEN_TRIM(dirs%input_filename) == 1)) new_sim = .true.
if (.not.new_sim) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call restore_state(dirs%input_filename, dirs%restart_input_dir, Time_frc, &
G, CS%restart_CSp)
G, CS%restart_CSp, use_fms2=.true.)
endif
endif

Expand Down
2 changes: 1 addition & 1 deletion config_src/mct_driver/ocn_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
write(restartname,'(A,".mom6.r.",I4.4,"-",I2.2,"-",I2.2,"-",I5.5)') trim(runid), year, month, day, seconds

call save_restart(glb%ocn_state%dirs%restart_output_dir, glb%ocn_state%Time, glb%grid, &
glb%ocn_state%restart_CSp, .false., filename=restartname, GV=glb%ocn_state%GV)
glb%ocn_state%restart_CSp, .false., filename=restartname, GV=glb%ocn_state%GV, use_fms2=.true.)

! write name of restart file in the rpointer file
nu = shr_file_getUnit()
Expand Down
13 changes: 8 additions & 5 deletions config_src/nuopc_driver/mom_ocean_model_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,9 @@ subroutine ocean_model_restart(OS, timestamp, restartname)
"restart files can only be created after the buoyancy forcing is applied.")

if (present(restartname)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, GV=OS%GV, filename=restartname)
OS%restart_CSp, GV=OS%GV, filename=restartname, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir) ! Is this needed?
if (OS%use_ice_shelf) then
Expand All @@ -696,17 +697,19 @@ subroutine ocean_model_restart(OS, timestamp, restartname)
endif
else
if (BTEST(OS%Restart_control,1)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, .true., GV=OS%GV)
OS%restart_CSp, .true., GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir, .true.)
if (OS%use_ice_shelf) then
call ice_shelf_save_restart(OS%Ice_shelf_CSp, OS%Time, OS%dirs%restart_output_dir, .true.)
endif
endif
if (BTEST(OS%Restart_control,0)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(OS%dirs%restart_output_dir, OS%Time, OS%grid, &
OS%restart_CSp, GV=OS%GV)
OS%restart_CSp, GV=OS%GV, use_fms2=.true.)
call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, &
OS%dirs%restart_output_dir)
if (OS%use_ice_shelf) then
Expand Down Expand Up @@ -760,8 +763,8 @@ subroutine ocean_model_save_restart(OS, Time, directory, filename_suffix)

if (present(directory)) then ; restart_dir = directory
else ; restart_dir = OS%dirs%restart_output_dir ; endif

call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV, use_fms2=.true.)

call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir)

Expand Down
6 changes: 4 additions & 2 deletions config_src/nuopc_driver/mom_surface_forcing_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, &

if (.not.associated(CS)) return
if (.not.associated(CS%restart_CSp)) return
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.)

end subroutine forcing_save_restart

Expand Down Expand Up @@ -1330,8 +1331,9 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, restore_salt,
if ((dirs%input_filename(1:1) == 'n') .and. &
(LEN_TRIM(dirs%input_filename) == 1)) new_sim = .true.
if (.not.new_sim) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call restore_state(dirs%input_filename, dirs%restart_input_dir, Time_frc, &
G, CS%restart_CSp)
G, CS%restart_CSp, use_fms2=.true.)
endif
endif

Expand Down
10 changes: 6 additions & 4 deletions config_src/solo_driver/MOM_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,18 @@ program MOM_main
if ((permit_incr_restart) .and. (fluxes%fluxes_used) .and. &
(Time + (Time_step_ocean/2) > restart_time)) then
if (BTEST(Restart_control,1)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(dirs%restart_output_dir, Time, grid, &
restart_CSp, .true., GV=GV)
restart_CSp, .true., GV=GV, use_fms2=.true.)
call forcing_save_restart(surface_forcing_CSp, grid, Time, &
dirs%restart_output_dir, .true.)
if (use_ice_shelf) call ice_shelf_save_restart(ice_shelf_CSp, Time, &
dirs%restart_output_dir, .true.)
endif
if (BTEST(Restart_control,0)) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(dirs%restart_output_dir, Time, grid, &
restart_CSp, GV=GV)
restart_CSp, GV=GV, use_fms2=.true.)
call forcing_save_restart(surface_forcing_CSp, grid, Time, &
dirs%restart_output_dir)
if (use_ice_shelf) call ice_shelf_save_restart(ice_shelf_CSp, Time, &
Expand All @@ -616,8 +618,8 @@ program MOM_main
"End of MOM_main reached with unused buoyancy fluxes. "//&
"For conservation, the ocean restart files can only be "//&
"created after the buoyancy forcing is applied.")

call save_restart(dirs%restart_output_dir, Time, grid, restart_CSp, GV=GV)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(dirs%restart_output_dir, Time, grid, restart_CSp, GV=GV, use_fms2=.true.)
if (use_ice_shelf) call ice_shelf_save_restart(ice_shelf_CSp, Time, &
dirs%restart_output_dir)
! Write ocean solo restart file.
Expand Down
7 changes: 4 additions & 3 deletions config_src/solo_driver/MOM_surface_forcing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1524,8 +1524,8 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, &

if (.not.associated(CS)) return
if (.not.associated(CS%restart_CSp)) return

call save_restart(directory, Time, G, CS%restart_CSp, time_stamped)
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call save_restart(directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.)

end subroutine forcing_save_restart

Expand Down Expand Up @@ -1925,8 +1925,9 @@ subroutine surface_forcing_init(Time, G, US, param_file, diag, CS, tracer_flow_C
if ((dirs%input_filename(1:1) == 'n') .and. &
(LEN_TRIM(dirs%input_filename) == 1)) new_sim = .true.
if (.not.new_sim) then
! NOTE: use_fms2=.true. routes routine to fms2 IO interface
call restore_state(dirs%input_filename, dirs%restart_input_dir, Time_frc, &
G, CS%restart_CSp)
G, CS%restart_CSp, use_fms2=.true.)
endif
endif

Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2782,9 +2782,9 @@ subroutine finish_MOM_initialization(Time, dirs, CS, restart_CSp)
call find_eta(CS%h, CS%tv, G, GV, US, z_interface, eta_to_m=1.0)
call register_restart_field(z_interface, "eta", .true., restart_CSp_tmp, &
"Interface heights", "meter", z_grid='i')

! NOTE: write_ic=.true. routes routine to fms2 IO write_initial_conditions interface
call save_restart(dirs%output_directory, Time, CS%G_in, &
restart_CSp_tmp, filename=CS%IC_file, GV=GV)
restart_CSp_tmp, filename=CS%IC_file, GV=GV, write_ic=.true.)
deallocate(z_interface)
deallocate(restart_CSp_tmp)
endif
Expand Down
Loading

0 comments on commit 5c2daa5

Please sign in to comment.