From 2e46ea6d7b9bf48bf0a3838cf523b9e1a155953c Mon Sep 17 00:00:00 2001 From: wrongkindofdoctor Date: Tue, 18 Aug 2020 14:47:03 -0400 Subject: [PATCH] removed errant .true. in save_restart call removed use_fms2 optional arguments in save_restart, restore_state, and create_file made use_fms2 a MOM_restart module variable Update MOM_state_initialization.F90 Remove space. Update MOM_ice_shelf.F90 Add space. Update MOM_driver.F90 Add space Update mom_surface_forcing_mct.F90 remove whitespace Update ocean_model_MOM.F90 Add space Update mom_ocean_model_nuopc.F90 Add space Update MOM_surface_forcing.F90 Add space Changes needed work ESM4 to run with new io --- .../MOM_surface_forcing_gfdl.F90 | 6 ++-- config_src/coupled_driver/ocean_model_MOM.F90 | 10 +++--- config_src/mct_driver/mom_ocean_model_mct.F90 | 11 +++---- .../mct_driver/mom_surface_forcing_mct.F90 | 6 ++-- config_src/mct_driver/ocn_comp_mct.F90 | 2 +- .../nuopc_driver/mom_ocean_model_nuopc.F90 | 13 +++----- .../mom_surface_forcing_nuopc.F90 | 6 ++-- config_src/solo_driver/MOM_driver.F90 | 10 +++--- .../solo_driver/MOM_surface_forcing.F90 | 7 ++-- src/framework/MOM_io.F90 | 9 +++-- src/framework/MOM_read_data_fms2.F90 | 33 +++++++------------ src/framework/MOM_restart.F90 | 22 +++++++------ src/ice_shelf/MOM_ice_shelf.F90 | 7 ++-- .../MOM_state_initialization.F90 | 4 +-- 14 files changed, 58 insertions(+), 88 deletions(-) diff --git a/config_src/coupled_driver/MOM_surface_forcing_gfdl.F90 b/config_src/coupled_driver/MOM_surface_forcing_gfdl.F90 index 4a730d6e6d..7075fb7c10 100644 --- a/config_src/coupled_driver/MOM_surface_forcing_gfdl.F90 +++ b/config_src/coupled_driver/MOM_surface_forcing_gfdl.F90 @@ -1224,8 +1224,7 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, & if (.not.associated(CS)) return if (.not.associated(CS%restart_CSp)) return - ! 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.) + call save_restart(directory, Time, G, CS%restart_CSp, time_stamped) end subroutine forcing_save_restart @@ -1590,9 +1589,8 @@ 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, use_fms2=.true.) + G, CS%restart_CSp) endif endif diff --git a/config_src/coupled_driver/ocean_model_MOM.F90 b/config_src/coupled_driver/ocean_model_MOM.F90 index ff365a9e78..082099158c 100644 --- a/config_src/coupled_driver/ocean_model_MOM.F90 +++ b/config_src/coupled_driver/ocean_model_MOM.F90 @@ -684,9 +684,8 @@ 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, use_fms2=.true.) + OS%restart_CSp, .true., GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir, .true.) if (OS%use_ice_shelf) then @@ -694,9 +693,8 @@ subroutine ocean_model_restart(OS, timestamp) 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, use_fms2=.true.) + OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir) if (OS%use_ice_shelf) then @@ -748,8 +746,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 - ! 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 save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir) diff --git a/config_src/mct_driver/mom_ocean_model_mct.F90 b/config_src/mct_driver/mom_ocean_model_mct.F90 index 3c75cb12eb..f8a4a19532 100644 --- a/config_src/mct_driver/mom_ocean_model_mct.F90 +++ b/config_src/mct_driver/mom_ocean_model_mct.F90 @@ -690,9 +690,8 @@ 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, use_fms2=.true.) + OS%restart_CSp, GV=OS%GV, filename=restartname) 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 @@ -701,9 +700,8 @@ 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, use_fms2=.true.) + OS%restart_CSp, .true., GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir, .true.) if (OS%use_ice_shelf) then @@ -711,9 +709,8 @@ subroutine ocean_model_restart(OS, timestamp, restartname) 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, use_fms2=.true.) + OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir) if (OS%use_ice_shelf) then @@ -769,7 +766,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, use_fms2=.true.) + call save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir) diff --git a/config_src/mct_driver/mom_surface_forcing_mct.F90 b/config_src/mct_driver/mom_surface_forcing_mct.F90 index 88b7f01654..a42a8c3015 100644 --- a/config_src/mct_driver/mom_surface_forcing_mct.F90 +++ b/config_src/mct_driver/mom_surface_forcing_mct.F90 @@ -1001,8 +1001,7 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, & if (.not.associated(CS)) return if (.not.associated(CS%restart_CSp)) return - ! 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.) + call save_restart(directory, Time, G, CS%restart_CSp, time_stamped) end subroutine forcing_save_restart @@ -1326,9 +1325,8 @@ 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, use_fms2=.true.) + G, CS%restart_CSp) endif endif diff --git a/config_src/mct_driver/ocn_comp_mct.F90 b/config_src/mct_driver/ocn_comp_mct.F90 index 9f1912d79f..b1ce9a60c0 100644 --- a/config_src/mct_driver/ocn_comp_mct.F90 +++ b/config_src/mct_driver/ocn_comp_mct.F90 @@ -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, use_fms2=.true.) + glb%ocn_state%restart_CSp, .false., filename=restartname, GV=glb%ocn_state%GV) ! write name of restart file in the rpointer file nu = shr_file_getUnit() diff --git a/config_src/nuopc_driver/mom_ocean_model_nuopc.F90 b/config_src/nuopc_driver/mom_ocean_model_nuopc.F90 index a8765bdc08..9946aec4f9 100644 --- a/config_src/nuopc_driver/mom_ocean_model_nuopc.F90 +++ b/config_src/nuopc_driver/mom_ocean_model_nuopc.F90 @@ -686,9 +686,8 @@ 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, use_fms2=.true.) + OS%restart_CSp, GV=OS%GV, filename=restartname) 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 @@ -697,9 +696,8 @@ 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, use_fms2=.true.) + OS%restart_CSp, .true., GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir, .true.) if (OS%use_ice_shelf) then @@ -707,9 +705,8 @@ subroutine ocean_model_restart(OS, timestamp, restartname) 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, use_fms2=.true.) + OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, OS%Time, & OS%dirs%restart_output_dir) if (OS%use_ice_shelf) then @@ -763,8 +760,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 - ! 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 save_restart(restart_dir, Time, OS%grid, OS%restart_CSp, GV=OS%GV) call forcing_save_restart(OS%forcing_CSp, OS%grid, Time, restart_dir) diff --git a/config_src/nuopc_driver/mom_surface_forcing_nuopc.F90 b/config_src/nuopc_driver/mom_surface_forcing_nuopc.F90 index a565da3d93..3d49c66ce6 100644 --- a/config_src/nuopc_driver/mom_surface_forcing_nuopc.F90 +++ b/config_src/nuopc_driver/mom_surface_forcing_nuopc.F90 @@ -1000,8 +1000,7 @@ subroutine forcing_save_restart(CS, G, Time, directory, time_stamped, & if (.not.associated(CS)) return if (.not.associated(CS%restart_CSp)) return - ! NOTE: use_fms2=.true. routes routine to fms2 IO interface - call save_restart(directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.) + call save_restart(directory, Time, G, CS%restart_CSp, time_stamped) end subroutine forcing_save_restart @@ -1331,9 +1330,8 @@ 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, use_fms2=.true.) + G, CS%restart_CSp) endif endif diff --git a/config_src/solo_driver/MOM_driver.F90 b/config_src/solo_driver/MOM_driver.F90 index c6fbe0e4e6..f180cd9717 100644 --- a/config_src/solo_driver/MOM_driver.F90 +++ b/config_src/solo_driver/MOM_driver.F90 @@ -583,18 +583,16 @@ 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, use_fms2=.true.) + restart_CSp, .true., GV=GV) 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, use_fms2=.true.) + restart_CSp, GV=GV) 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, & @@ -618,8 +616,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.") - ! 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.) + + call save_restart(dirs%restart_output_dir, Time, grid, restart_CSp, GV=GV) if (use_ice_shelf) call ice_shelf_save_restart(ice_shelf_CSp, Time, & dirs%restart_output_dir) ! Write ocean solo restart file. diff --git a/config_src/solo_driver/MOM_surface_forcing.F90 b/config_src/solo_driver/MOM_surface_forcing.F90 index 5b10ea46e4..0a56abb681 100644 --- a/config_src/solo_driver/MOM_surface_forcing.F90 +++ b/config_src/solo_driver/MOM_surface_forcing.F90 @@ -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 - ! NOTE: use_fms2=.true. routes routine to fms2 IO interface - call save_restart(directory, Time, G, CS%restart_CSp, time_stamped, use_fms2=.true.) + + call save_restart(directory, Time, G, CS%restart_CSp, time_stamped) end subroutine forcing_save_restart @@ -1925,9 +1925,8 @@ 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, use_fms2=.true.) + G, CS%restart_CSp) endif endif diff --git a/src/framework/MOM_io.F90 b/src/framework/MOM_io.F90 index b36e8e5dd8..c4246f5d20 100644 --- a/src/framework/MOM_io.F90 +++ b/src/framework/MOM_io.F90 @@ -385,12 +385,11 @@ end subroutine create_file_old !> This routine opens a netcdf file in "write" or "overwrite" mode, registers the global diagnostic axes, and writes !! the axis data and metadata to the file -subroutine create_file_fms2_filename(filename, vars, numVariables, use_fms2, register_time, G, DG, GV, checksums, & +subroutine create_file_fms2_filename(filename, vars, numVariables, register_time, G, DG, GV, checksums, & is_restart) character(len=*), intent(in) :: filename !< full path to the netcdf file type(vardesc), dimension(:), intent(in) :: vars !< structures describing the output integer, intent(in) :: numVariables !< number of variables to write to the file - logical, intent(in) :: use_fms2 !< flag indicating whether to use this routine logical, optional, intent(in) :: register_time !< if .true., register a time dimension to the file type(ocean_grid_type), optional, intent(in) :: G !< ocean horizontal grid structure; G or dG !! is required if the new file uses any @@ -467,7 +466,7 @@ subroutine create_file_fms2_filename(filename, vars, numVariables, use_fms2, reg if (.not. check_if_open(fileObjDD)) & file_open_successDD=fms2_open_file(fileObjDD, filename_temp, trim(nc_mode), Domain%mpp_domain, & - is_restart=is_restart_file) + is_restart=is_restart_file, dont_add_res_to_filename=.true.) else ! get the pes associated with the file. !>\note this is required so that only pe(1) is identified as the root pe to create the file @@ -480,7 +479,7 @@ subroutine create_file_fms2_filename(filename, vars, numVariables, use_fms2, reg if (.not. check_if_open(fileObjNoDD)) & file_open_successNoDD=fms2_open_file(fileObjNoDD, filename_temp, trim(nc_mode), & - is_restart=is_restart_file, pelist=pelist) + is_restart=is_restart_file, pelist=pelist, dont_add_res_to_filename=.true.) endif ! allocate the output data variable dimension attributes allocate(dim_names(numVariables,4)) @@ -745,7 +744,7 @@ subroutine create_file_fms2_fileobj(filename, fileObjDD, vars, numVariables, reg if (.not. check_if_open(fileObjDD)) & !write(output_unit, '(A)'), "Create_file: Opening file ", trim(filename_temp) file_open_successDD=fms2_open_file(fileObjDD, filename_temp, trim(nc_mode), Domain%mpp_domain, & - is_restart=is_restart_file) + is_restart=is_restart_file, dont_add_res_to_filename=.true.) ! allocate the output data variable dimension attributes allocate(dim_names(numVariables,4)) dim_names(:,:) = "" diff --git a/src/framework/MOM_read_data_fms2.F90 b/src/framework/MOM_read_data_fms2.F90 index d15d5a3085..e5d20ccc57 100644 --- a/src/framework/MOM_read_data_fms2.F90 +++ b/src/framework/MOM_read_data_fms2.F90 @@ -76,13 +76,12 @@ module MOM_read_data_fms2 !> This routine calls the fms_io read_data subroutine to read 1-D domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_1d_DD(filename, fieldname, data, domain, use_fms2, start_index, edge_lengths, & +subroutine MOM_read_data_1d_DD(filename, fieldname, data, domain, start_index, edge_lengths, & timelevel, scale, x_position, y_position, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:), intent(inout) :: data !< The 1-dimensional data array to pass to read_data type(MOM_domain_type), intent(in) :: domain !< MOM domain attribute with the mpp_domain decomposition - logical, intent(in) :: use_fms2 !< flag to distinguish interface from the old write_field interface integer, dimension(1), optional, intent(in) :: start_index !< starting index of data buffer. Default is 1 integer, dimension(1), optional, intent(in) :: edge_lengths !< number of data values to read in !! default is the variable size @@ -188,13 +187,12 @@ end subroutine MOM_read_data_1d_DD !> This routine calls the fms_io read_data subroutine to read 2-D domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_2d_DD(filename, fieldname, data, domain, use_fms2, start_index, edge_lengths, & +subroutine MOM_read_data_2d_DD(filename, fieldname, data, domain,start_index, edge_lengths, & timelevel, scale, x_position, y_position, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:), intent(inout) :: data !< The 2-dimensional data array to pass to read_data type(MOM_domain_type), intent(in) :: domain !< MOM domain attribute with the mpp_domain decomposition - logical, intent(in) :: use_fms2 !< flag to distinguish interface from the old write_field interface integer, dimension(2), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(2), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -323,13 +321,12 @@ end subroutine MOM_read_data_2d_DD !> This routine calls the fms_io read_data subroutine to read 3-D domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_3d_DD(filename, fieldname, data, domain, use_fms2, start_index, edge_lengths, & +subroutine MOM_read_data_3d_DD(filename, fieldname, data, domain, start_index, edge_lengths, & timelevel, scale, x_position, y_position, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:,:), intent(inout) :: data !< The 3-dimensional data array to pass to read_data type(MOM_domain_type), intent(in) :: domain !< MOM domain attribute with the mpp_domain decomposition - logical, intent(in) :: use_fms2 !< flag indicating whether to use this routine integer, dimension(3), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(3), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -460,13 +457,12 @@ end subroutine MOM_read_data_3d_DD !> This routine calls the fms_io read_data subroutine to read 4-D domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_4d_DD(filename, fieldname, data, domain, use_fms2, start_index, edge_lengths, & +subroutine MOM_read_data_4d_DD(filename, fieldname, data, domain, start_index, edge_lengths, & timelevel, scale, x_position, y_position, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:,:,:), intent(inout) :: data !< The 1-dimensional data array to pass to read_data type(MOM_domain_type), intent(in) :: domain !< MOM domain attribute with the mpp_domain decomposition - logical, intent(in) :: use_fms2 !< flag indicating whether to use this routine integer, dimension(4), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(4), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -600,11 +596,10 @@ end subroutine MOM_read_data_4d_DD !!> This routine calls the fms_io read_data subroutine to read a scalar (0-D) field named "fieldname" !! from file "filename". -subroutine MOM_read_data_scalar(filename, fieldname, data, use_fms2, leave_file_open) +subroutine MOM_read_data_scalar(filename, fieldname, data, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, intent(inout) :: data !< data buffer to pass to read_data - logical, intent(in) :: use_fms2 !< flag distinguishing interface from old MOM_read_data logical, optional, intent(in) :: leave_file_open !< if .true., leave file open ! local integer :: i @@ -649,12 +644,11 @@ end subroutine MOM_read_data_scalar !> This routine calls the fms_io read_data subroutine to read 1-D non-domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_1d_noDD(filename, fieldname, data, use_fms2, start_index, & +subroutine MOM_read_data_1d_noDD(filename, fieldname, data, start_index, & edge_lengths, timelevel, scale, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:), intent(inout) :: data !< The 1-dimensional data array to pass to read_data - logical, intent(in) :: use_fms2 !< flag to distinguish interface from old MOM_read_data interface integer, dimension(1), optional, intent(in) :: start_index !< starting index of data buffer. Default is 1 integer, dimension(1), optional, intent(in) :: edge_lengths !< number of data values to read in; default is !! the variable size @@ -748,12 +742,11 @@ end subroutine MOM_read_data_1d_noDD !> This routine calls the fms_io read_data subroutine to read 2-D non-domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_2d_noDD(filename, fieldname, data, use_fms2, start_index, & +subroutine MOM_read_data_2d_noDD(filename, fieldname, data, start_index, & edge_lengths, timelevel, scale, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:), intent(inout) :: data !< The 2-dimensional data array to pass to read_data - logical, intent(in) :: use_fms2 !< flag to distinguish interface from old MOM_read_data interface integer, dimension(2), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(2), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -842,12 +835,11 @@ end subroutine MOM_read_data_2d_noDD !> This routine calls the fms_io read_data subroutine to read 3-D non-domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_3d_noDD(filename, fieldname, data, use_fms2, start_index, & +subroutine MOM_read_data_3d_noDD(filename, fieldname, data, start_index, & edge_lengths, timelevel, scale, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:,:), intent(inout) :: data !< The 3-dimensional data array to pass to read_data - logical, intent(in) :: use_fms2 !< flag to distinguish interface from old MOM_read_data interface integer, dimension(3), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(3), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -935,12 +927,11 @@ end subroutine MOM_read_data_3d_noDD !> This routine calls the fms_io read_data subroutine to read 4-D non-domain-decomposed data field named "fieldname" !! from file "filename". The routine multiplies the data by "scale" if the optional argument is included in the call. -subroutine MOM_read_data_4d_noDD(filename, fieldname, data, use_fms2, start_index, & +subroutine MOM_read_data_4d_noDD(filename, fieldname, data, start_index, & edge_lengths, timelevel, scale, leave_file_open) character(len=*), intent(in) :: filename !< The name of the file to read character(len=*), intent(in) :: fieldname !< The variable name of the data in the file real, dimension(:,:,:,:), intent(inout) :: data !< The 4-dimensional data array to pass to read_data - logical, intent(in) :: use_fms2 !< flag to distinguish interface from old MOM_read_data interface integer, dimension(4), optional, intent(in) :: start_index !< starting indices of data buffer. Default is 1 integer, dimension(4), optional, intent(in) :: edge_lengths !< number of data values to read in. !! Default values are the variable dimension sizes @@ -1191,7 +1182,7 @@ end subroutine MOM_read_data_2d_supergrid !! 2-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for !! "stagger" include CGRID_NE, BGRID_NE, and AGRID. subroutine MOM_read_vector_2d_fms2(filename, u_fieldname, v_fieldname, u_data, v_data, MOM_Domain, & - use_fms2, timelevel, stagger, scale, leave_file_open) + timelevel, stagger, scale, leave_file_open) character(len=*), intent(in) :: filename !< name of the netcdf file to read character(len=*), intent(in) :: u_fieldname !< The variable name of the u data in the file character(len=*), intent(in) :: v_fieldname !< The variable name of the v data in the file @@ -1200,7 +1191,6 @@ subroutine MOM_read_vector_2d_fms2(filename, u_fieldname, v_fieldname, u_data, v real, dimension(:,:), intent(inout) :: v_data !< The 2 dimensional array into which the !! v-component of the data should be read type(MOM_domain_type), intent(in) :: MOM_Domain !< The MOM_Domain that describes the decomposition - logical, intent(in) :: use_fms2 !< flag indicating whether to use this routine integer, optional, intent(in) :: timelevel !< The time level in the file to read integer, optional, intent(in) :: stagger !< A flag indicating where this vector is discretized real, optional, intent(in) :: scale !< A scaling factor that the fields are multiplied @@ -1320,7 +1310,7 @@ end subroutine MOM_read_vector_2d_fms2 !! 3-D data fields with names given by "[uv]_fieldname" from file "filename". Valid values for !! "stagger" include CGRID_NE, BGRID_NE, and AGRID. subroutine MOM_read_vector_3d_fms2(filename, u_fieldname, v_fieldname, u_data, v_data, MOM_Domain, & - use_fms2, timelevel, stagger, scale, leave_file_open) + timelevel, stagger, scale, leave_file_open) character(len=*), intent(in) :: filename !< name of the netcdf file to read character(len=*), intent(in) :: u_fieldname !< The variable name of the u data in the file character(len=*), intent(in) :: v_fieldname !< The variable name of the v data in the file @@ -1329,7 +1319,6 @@ subroutine MOM_read_vector_3d_fms2(filename, u_fieldname, v_fieldname, u_data, v real, dimension(:,:,:), intent(inout) :: v_data !< The 3 dimensional array into which the !! v-component of the data should be read type(MOM_domain_type), intent(in) :: MOM_Domain !< The MOM_Domain that describes the decomposition - logical, intent(in) :: use_fms2 !< flag indicating whether to call this routine integer, optional, intent(in) :: timelevel !< The time level in the file to read integer, optional, intent(in) :: stagger !< A flag indicating where this vector is discretized real, optional, intent(in) :: scale !< A scaling factor that the fields are multiplied diff --git a/src/framework/MOM_restart.F90 b/src/framework/MOM_restart.F90 index f9dc13758e..a9242b08a4 100644 --- a/src/framework/MOM_restart.F90 +++ b/src/framework/MOM_restart.F90 @@ -38,6 +38,8 @@ module MOM_restart use platform_mod implicit none ; private +logical :: use_fms2 = .true. !< Flag to use fms2-io interfaces + public restart_init, restart_end, restore_state, register_restart_field public save_restart, query_initialized, restart_init_end, vardesc public restart_files_exist, determine_is_new_run, is_new_run @@ -863,7 +865,7 @@ function query_initialized_4d_name(f_ptr, name, CS) result(query_initialized) end function query_initialized_4d_name !> wrapper routine for save_restart_old, save_restart_fms2, and write_initial_conditions_file -subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, use_fms2, write_ic) +subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, write_ic) character(len=*), intent(in) :: directory !< The directory where the restart files !! are to be written type(time_type), intent(in) :: time !< The current model time @@ -874,18 +876,16 @@ subroutine save_restart(directory, time, G, CS, time_stamped, filename, GV, use_ !! to the restart file names. character(len=*), optional, intent(in) :: filename !< A filename that overrides the name in CS%restartfile. type(verticalGrid_type), optional, intent(in) :: GV !< The ocean's vertical grid structure - logical, optional, intent(in) :: use_fms2 !< flag to call save_restart_fms2 logical, optional, intent(in) :: write_ic !< flag to call write_initial_conditions ! local logical :: write_initcond, call_fms2 write_initcond = .false. call_fms2 = .false. - if (present(use_fms2)) call_fms2 = use_fms2 if (present(write_ic)) write_initcond = write_ic if (write_initcond) then call write_initial_conditions(directory, time, G, CS, time_stamped=time_stamped, filename=filename, GV=GV) - elseif (call_fms2) then + elseif (use_fms2) then call save_restart_fms2(directory, time, G, CS, time_stamped=time_stamped, filename=filename, GV=GV) else call save_restart_old(directory, time, G, CS, time_stamped=time_stamped, filename=filename, GV=GV) @@ -1616,7 +1616,7 @@ subroutine write_initial_conditions(directory, time, G, CS, time_stamped, filena end subroutine write_initial_conditions !> wrapper routine for restore_state_old and restore_state_fms2 -subroutine restore_state(filename, directory, day, G, CS, use_fms2) +subroutine restore_state(filename, directory, day, G, CS) character(len=*), intent(in) :: filename !< The list of restart file names or a single !! character 'r' to read automatically named files. character(len=*), intent(in) :: directory !< The directory in which to find restart files @@ -1624,9 +1624,7 @@ subroutine restore_state(filename, directory, day, G, CS, use_fms2) type(ocean_grid_type), intent(in) :: G !< The ocean's grid structure type(MOM_restart_CS), pointer :: CS !< The control structure returned by a previous !! call to restart_init. - logical, optional, intent(in) :: use_fms2 !< if .true., call restore_state_fms2 - - if (present(use_fms2) .and. use_fms2) then + if (use_fms2) then call restore_state_fms2(filename, directory, day, G, CS) else call restore_state_old(filename, directory, day, G, CS) @@ -1936,9 +1934,12 @@ subroutine restore_state_fms2(filename, directory, day, G, CS) ! Open the restart file. if (.not.(check_if_open(fileObjRead))) & fileOpenSuccess=fms2_open_file(fileObjRead, trim(unit_path(n)), "read", & - G%domain%mpp_domain, is_restart=.true.) - if (fileOpenSuccess) & + G%domain%mpp_domain, is_restart=.true., dont_add_res_to_filename=.true.) + if (fileOpenSuccess) then call MOM_error(NOTE, "MOM_restart_fms2: MOM run restarted using : "//trim(unit_path(n))) + else + call MOM_error(FATAL, "MOM_restart_fms2: Error opening file: "//trim(unit_path(n))) + endif call get_dimension_size(fileObjRead, "Time", ntime) @@ -2005,6 +2006,7 @@ subroutine restore_state_fms2(filename, directory, day, G, CS) missing_fields = missing_fields+1 cycle endif + cycle endif ! Get the variable's "domain position." num_dims = 0 diff --git a/src/ice_shelf/MOM_ice_shelf.F90 b/src/ice_shelf/MOM_ice_shelf.F90 index fe9a5bc75f..feaebadfc7 100644 --- a/src/ice_shelf/MOM_ice_shelf.F90 +++ b/src/ice_shelf/MOM_ice_shelf.F90 @@ -1512,9 +1512,8 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, forces, fl elseif (.not.new_sim) then ! This line calls a subroutine that reads the initial conditions from a restart file. call MOM_mesg("MOM_ice_shelf.F90, initialize_ice_shelf: Restoring ice shelf from file.") - ! NOTE: use_fms2=.true. routes routine to fms2 IO interface call restore_state(dirs%input_filename, dirs%restart_input_dir, Time, & - G, CS%restart_CSp, use_fms2=.true.) + G, CS%restart_CSp) if ((US%m_to_Z_restart /= 0.0) .and. (US%m_to_Z_restart /= US%m_to_Z)) then Z_rescale = US%m_to_Z / US%m_to_Z_restart @@ -1781,8 +1780,8 @@ subroutine ice_shelf_save_restart(CS, Time, directory, time_stamped, filename_su if (present(directory)) then ; restart_dir = directory else ; restart_dir = CS%restart_output_dir ; endif - ! NOTE: first use_fms2=.true. routes routine to fms2 IO interface - call save_restart(restart_dir, Time, CS%grid, CS%restart_CSp, time_stamped, use_fms2=.true.) + + call save_restart(restart_dir, Time, CS%grid, CS%restart_CSp, time_stamped) end subroutine ice_shelf_save_restart diff --git a/src/initialization/MOM_state_initialization.F90 b/src/initialization/MOM_state_initialization.F90 index 983c008473..9f505325bf 100644 --- a/src/initialization/MOM_state_initialization.F90 +++ b/src/initialization/MOM_state_initialization.F90 @@ -481,10 +481,8 @@ subroutine MOM_initialize_state(u, v, h, tv, Time, G, GV, US, PF, dirs, & if (.not.new_sim) then ! This block restores the state from a restart file. ! This line calls a subroutine that reads the initial conditions ! from a previously generated file. - - ! NOTE: use_fms2=.true. routes routine to fms2 IO interface call restore_state(dirs%input_filename, dirs%restart_input_dir, Time, & - G, restart_CS, use_fms2=.true.) + G, restart_CS) if (present(Time_in)) Time = Time_in if ((GV%m_to_H_restart /= 0.0) .and. (GV%m_to_H_restart /= GV%m_to_H)) then H_rescale = GV%m_to_H / GV%m_to_H_restart