Skip to content

Commit 3ce81f4

Browse files
authored
Merge pull request #35 from jiandewang/feature/update-to-GFDL-20200811
Feature/update to gfdl 20200909 commit
2 parents eb58a2e + fbfa05b commit 3ce81f4

13 files changed

Lines changed: 662 additions & 540 deletions

config_src/mct_driver/mom_ocean_model_mct.F90

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,57 @@ module MOM_ocean_model_mct
1111
! This code is a stop-gap wrapper of the MOM6 code to enable it to be called
1212
! in the same way as MOM4.
1313

14-
use MOM, only : initialize_MOM, step_MOM, MOM_control_struct, MOM_end
15-
use MOM, only : extract_surface_state, allocate_surface_state, finish_MOM_initialization
16-
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
17-
use MOM, only : get_ocean_stocks, step_offline
18-
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
19-
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
20-
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
21-
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
22-
use MOM_domains, only : TO_ALL, Omit_Corners
23-
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
24-
use MOM_error_handler, only : callTree_enter, callTree_leave
25-
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
26-
use MOM_forcing_type, only : allocate_forcing_type
27-
use MOM_forcing_type, only : forcing, mech_forcing
28-
use MOM_forcing_type, only : forcing_accumulate, copy_common_forcing_fields
29-
use MOM_forcing_type, only : copy_back_forcing_fields, set_net_mass_forcing
30-
use MOM_forcing_type, only : set_derived_forcing_fields
31-
use MOM_forcing_type, only : forcing_diagnostics, mech_forcing_diags
32-
use MOM_get_input, only : Get_MOM_Input, directories
33-
use MOM_grid, only : ocean_grid_type
34-
use MOM_io, only : close_file, file_exists, read_data, write_version_number
35-
use MOM_marine_ice, only : iceberg_forces, iceberg_fluxes, marine_ice_init, marine_ice_CS
36-
use MOM_restart, only : MOM_restart_CS, save_restart
37-
use MOM_string_functions, only : uppercase
38-
use MOM_surface_forcing_mct, only : surface_forcing_init, convert_IOB_to_fluxes
39-
use MOM_surface_forcing_mct, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
40-
use MOM_surface_forcing_mct, only : ice_ocean_boundary_type, surface_forcing_CS
41-
use MOM_surface_forcing_mct, only : forcing_save_restart
42-
use MOM_time_manager, only : time_type, get_time, set_time, operator(>)
43-
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
44-
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=)
45-
use MOM_time_manager, only : operator(<), real_to_time_type, time_type_to_real
46-
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
47-
use MOM_tracer_flow_control, only : call_tracer_flux_init
48-
use MOM_unit_scaling, only : unit_scale_type
49-
use MOM_variables, only : surface
50-
use MOM_verticalGrid, only : verticalGrid_type
51-
use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
52-
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
53-
use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
54-
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
55-
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
56-
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
57-
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
58-
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
59-
use fms_mod, only : stdout
60-
use mpp_mod, only : mpp_chksum
61-
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
62-
use MOM_wave_interface, only: wave_parameters_CS, MOM_wave_interface_init
63-
use MOM_wave_interface, only: MOM_wave_interface_init_lite, Update_Surface_Waves
14+
use MOM, only : initialize_MOM, step_MOM, MOM_control_struct, MOM_end
15+
use MOM, only : extract_surface_state, allocate_surface_state, finish_MOM_initialization
16+
use MOM, only : get_MOM_state_elements, MOM_state_is_synchronized
17+
use MOM, only : get_ocean_stocks, step_offline
18+
use MOM_constants, only : CELSIUS_KELVIN_OFFSET, hlf
19+
use MOM_diag_mediator, only : diag_ctrl, enable_averaging, disable_averaging
20+
use MOM_diag_mediator, only : diag_mediator_close_registration, diag_mediator_end
21+
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
22+
use MOM_domains, only : TO_ALL, Omit_Corners
23+
use MOM_error_handler, only : MOM_error, FATAL, WARNING, is_root_pe
24+
use MOM_error_handler, only : callTree_enter, callTree_leave
25+
use MOM_file_parser, only : get_param, log_version, close_param_file, param_file_type
26+
use MOM_forcing_type, only : allocate_forcing_type
27+
use MOM_forcing_type, only : forcing, mech_forcing
28+
use MOM_forcing_type, only : forcing_accumulate, copy_common_forcing_fields
29+
use MOM_forcing_type, only : copy_back_forcing_fields, set_net_mass_forcing
30+
use MOM_forcing_type, only : set_derived_forcing_fields
31+
use MOM_forcing_type, only : forcing_diagnostics, mech_forcing_diags
32+
use MOM_get_input, only : Get_MOM_Input, directories
33+
use MOM_grid, only : ocean_grid_type
34+
use MOM_io, only : close_file, file_exists, read_data, write_version_number
35+
use MOM_marine_ice, only : iceberg_forces, iceberg_fluxes, marine_ice_init, marine_ice_CS
36+
use MOM_restart, only : MOM_restart_CS, save_restart
37+
use MOM_string_functions, only : uppercase
38+
use MOM_surface_forcing_mct, only : surface_forcing_init, convert_IOB_to_fluxes
39+
use MOM_surface_forcing_mct, only : convert_IOB_to_forces, ice_ocn_bnd_type_chksum
40+
use MOM_surface_forcing_mct, only : ice_ocean_boundary_type, surface_forcing_CS
41+
use MOM_surface_forcing_mct, only : forcing_save_restart
42+
use MOM_time_manager, only : time_type, get_time, set_time, operator(>)
43+
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
44+
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=)
45+
use MOM_time_manager, only : operator(<), real_to_time_type, time_type_to_real
46+
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
47+
use MOM_tracer_flow_control, only : call_tracer_flux_init
48+
use MOM_unit_scaling, only : unit_scale_type
49+
use MOM_variables, only : surface
50+
use MOM_verticalGrid, only : verticalGrid_type
51+
use MOM_ice_shelf, only : initialize_ice_shelf, shelf_calc_flux, ice_shelf_CS
52+
use MOM_ice_shelf, only : add_shelf_forces, ice_shelf_end, ice_shelf_save_restart
53+
use coupler_types_mod, only : coupler_1d_bc_type, coupler_2d_bc_type
54+
use coupler_types_mod, only : coupler_type_spawn, coupler_type_write_chksums
55+
use coupler_types_mod, only : coupler_type_initialized, coupler_type_copy_data
56+
use coupler_types_mod, only : coupler_type_set_diags, coupler_type_send_data
57+
use mpp_domains_mod, only : domain2d, mpp_get_layout, mpp_get_global_domain
58+
use mpp_domains_mod, only : mpp_define_domains, mpp_get_compute_domain, mpp_get_data_domain
59+
use fms_mod, only : stdout
60+
use mpp_mod, only : mpp_chksum
61+
use MOM_EOS, only : gsw_sp_from_sr, gsw_pt_from_ct
62+
use MOM_wave_interface, only : wave_parameters_CS, MOM_wave_interface_init
63+
use MOM_wave_interface, only : MOM_wave_interface_init_lite, Update_Surface_Waves
64+
use time_interp_external_mod, only : time_interp_external_init
6465

6566
! MCT specfic routines
6667
use MOM_domains, only : MOM_infra_end
@@ -265,6 +266,8 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
265266
OS%is_ocean_pe = Ocean_sfc%is_ocean_pe
266267
if (.not.OS%is_ocean_pe) return
267268

269+
call time_interp_external_init
270+
268271
OS%Time = Time_in
269272
call initialize_MOM(OS%Time, Time_init, param_file, OS%dirs, OS%MOM_CSp, &
270273
OS%restart_CSp, Time_in, offline_tracer_mode=OS%offline_tracer_mode, &

config_src/mct_driver/ocn_comp_mct.F90

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
119119
integer :: year, month, day, hour, minute, seconds, seconds_n, seconds_d, rc
120120
character(len=240) :: runid !< Run ID
121121
character(len=32) :: runtype !< Run type
122-
character(len=240) :: restartfile !< Path/Name of restart file
122+
character(len=512) :: restartfile !< Path/Name of restart file
123+
character(len=2048) :: restartfiles !< Path/Name of restart files.
124+
!! (same as restartfile if a single restart file is to be read in)
123125
integer :: nu !< i/o unit to read pointer file
124126
character(len=240) :: restart_pointer_file !< File name for restart pointer file
125127
character(len=240) :: restartpath !< Path of the restart file
@@ -164,6 +166,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
164166
!logical :: lsend_precip_fact !< If T,send precip_fact to cpl for use in fw balance
165167
!! (partially-coupled option)
166168
character(len=128) :: err_msg !< Error message
169+
integer :: iostat
167170

168171
! set the cdata pointers:
169172
call seq_cdata_setptrs(cdata_o, id=MOM_MCT_ID, mpicom=mpicom_ocn, &
@@ -296,15 +299,27 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
296299
nu = shr_file_getUnit()
297300
restart_pointer_file = trim(glb%pointer_filename)
298301
if (is_root_pe()) write(glb%stdout,*) 'Reading ocn pointer file: ',restart_pointer_file
302+
restartfile = ""; restartfiles = "";
299303
open(nu, file=restart_pointer_file, form='formatted', status='unknown')
300-
read(nu,'(a)') restartfile
304+
do
305+
read(nu,'(a)', iostat=iostat) restartfile
306+
if (len(trim(restartfiles))>1 .and. iostat<0) then
307+
exit ! done reading restart files list.
308+
else if (iostat/=0) then
309+
call MOM_error(FATAL, 'Error reading rpointer.ocn')
310+
endif
311+
! check if the length of restartfiles variable is sufficient:
312+
if (len(restartfiles)-len(trim(restartfiles)) < len(trim(restartfile))) then
313+
call MOM_error(FATAL, "Restart file name(s) too long.")
314+
endif
315+
restartfiles = trim(restartfiles) // " " // trim(restartfile)
316+
enddo
301317
close(nu)
302-
!restartfile = trim(restartpath) // trim(restartfile)
303318
if (is_root_pe()) then
304-
write(glb%stdout,*) 'Reading restart file: ',trim(restartfile)
319+
write(glb%stdout,*) 'Reading restart file(s): ',trim(restartfiles)
305320
end if
306321
call shr_file_freeUnit(nu)
307-
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfile))
322+
call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfiles))
308323
endif
309324
if (is_root_pe()) then
310325
write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========'
@@ -434,6 +449,9 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
434449
integer :: ocn_cpl_dt !< one ocn coupling interval in seconds. (to be received from cesm)
435450
real (kind=8) :: mom_cpl_dt !< one ocn coupling interval in seconds. (internal)
436451
integer :: ncouple_per_day !< number of ocean coupled call in one day (non-dim)
452+
integer :: num_rest_files !< number of restart files written
453+
integer :: i
454+
character(len=8) :: suffix
437455

438456
! reset shr logging to ocn log file:
439457
if (is_root_pe()) then
@@ -534,14 +552,28 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)
534552
write(restartname,'(A,".mom6.r.",I4.4,"-",I2.2,"-",I2.2,"-",I5.5)') trim(runid), year, month, day, seconds
535553

536554
call save_restart(glb%ocn_state%dirs%restart_output_dir, glb%ocn_state%Time, glb%grid, &
537-
glb%ocn_state%restart_CSp, .false., filename=restartname, GV=glb%ocn_state%GV)
555+
glb%ocn_state%restart_CSp, .false., filename=restartname, GV=glb%ocn_state%GV, &
556+
num_rest_files=num_rest_files)
538557

539558
! write name of restart file in the rpointer file
540559
nu = shr_file_getUnit()
541560
if (is_root_pe()) then
542561
restart_pointer_file = trim(glb%pointer_filename)
543562
open(nu, file=restart_pointer_file, form='formatted', status='unknown')
544563
write(nu,'(a)') trim(restartname) //'.nc'
564+
565+
if (num_rest_files > 1) then
566+
! append i.th restart file name to rpointer
567+
do i=1, num_rest_files-1
568+
if (i < 10) then
569+
write(suffix,'("_",I1)') i
570+
else
571+
write(suffix,'("_",I2)') i
572+
endif
573+
write(nu,'(a)') trim(restartname) // trim(suffix) // '.nc'
574+
enddo
575+
endif
576+
545577
close(nu)
546578
write(glb%stdout,*) 'ocn restart pointer file written: ',trim(restartname)
547579
endif

config_src/nuopc_driver/mom_cap.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module MOM_cap_mod
1515
use mpp_mod, only: stdlog, stdout, mpp_root_pe, mpp_clock_id
1616
use mpp_mod, only: mpp_clock_begin, mpp_clock_end, MPP_CLOCK_SYNC
1717
use mpp_mod, only: MPP_CLOCK_DETAILED, CLOCK_COMPONENT, MAXPES
18-
use time_interp_external_mod, only: time_interp_external_init
1918
use time_manager_mod, only: set_calendar_type, time_type, increment_date
2019
use time_manager_mod, only: set_time, set_date, get_time, get_date, month_name
2120
use time_manager_mod, only: GREGORIAN, JULIAN, NOLEAP, THIRTY_DAY_MONTHS, NO_CALENDAR
@@ -1559,6 +1558,7 @@ subroutine ModelAdvance(gcomp, rc)
15591558
return
15601559
endif
15611560
write(writeunit,'(a)') trim(restartname)//'.nc'
1561+
15621562
if (num_rest_files > 1) then
15631563
! append i.th restart file name to rpointer
15641564
do i=1, num_rest_files-1
@@ -1737,7 +1737,6 @@ subroutine ModelSetRunClock(gcomp, rc)
17371737
line=__LINE__, file=__FILE__, rcToReturn=rc)
17381738
return
17391739
endif
1740-
17411740
! not used in nems
17421741
call NUOPC_CompAttributeGet(gcomp, name="restart_ymd", value=cvalue, &
17431742
isPresent=isPresent, isSet=isSet, rc=rc)
@@ -1811,6 +1810,8 @@ subroutine ocean_model_finalize(gcomp, rc)
18111810
type(TIME_TYPE) :: Time
18121811
type(ESMF_Clock) :: clock
18131812
type(ESMF_Time) :: currTime
1813+
type(ESMF_Alarm), allocatable :: alarmList(:)
1814+
integer :: alarmCount
18141815
character(len=64) :: timestamp
18151816
logical :: write_restart
18161817
character(len=*),parameter :: subname='(MOM_cap:ocean_model_finalize)'

config_src/nuopc_driver/mom_ocean_model_nuopc.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module MOM_ocean_model_nuopc
3939
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
4040
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=)
4141
use MOM_time_manager, only : operator(<), real_to_time_type, time_type_to_real
42+
use time_interp_external_mod,only : time_interp_external_init
4243
use MOM_tracer_flow_control, only : call_tracer_register, tracer_flow_control_init
4344
use MOM_tracer_flow_control, only : call_tracer_flux_init
4445
use MOM_unit_scaling, only : unit_scale_type
@@ -267,6 +268,8 @@ subroutine ocean_model_init(Ocean_sfc, OS, Time_init, Time_in, gas_fields_ocn, i
267268
OS%is_ocean_pe = Ocean_sfc%is_ocean_pe
268269
if (.not.OS%is_ocean_pe) return
269270

271+
call time_interp_external_init
272+
270273
OS%Time = Time_in
271274
call initialize_MOM(OS%Time, Time_init, param_file, OS%dirs, OS%MOM_CSp, &
272275
OS%restart_CSp, Time_in, offline_tracer_mode=OS%offline_tracer_mode, &

0 commit comments

Comments
 (0)