From 52b018bb9adf9c026e8aa3b3bad2e09c75b07472 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 15 Aug 2019 14:46:33 -0600 Subject: [PATCH 1/5] Add time0 and timenow in MCT --- config_src/mct_driver/ocn_comp_mct.F90 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/config_src/mct_driver/ocn_comp_mct.F90 b/config_src/mct_driver/ocn_comp_mct.F90 index 5b581e0427..d7d66b32f6 100644 --- a/config_src/mct_driver/ocn_comp_mct.F90 +++ b/config_src/mct_driver/ocn_comp_mct.F90 @@ -111,6 +111,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) ! local variables type(time_type) :: time0 !< Model start time + type(time_type) :: timenow !< Model current time type(ESMF_time) :: time_var !< ESMF_time variable to query time type(ESMF_time) :: time_in_ESMF !< Initial time for ocean type(ESMF_timeInterval) :: ocn_cpl_interval !< Ocean coupling interval @@ -202,11 +203,16 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) call set_calendar_type(NOLEAP) !TODO: confirm this - ! Get the initial time - call ESMF_ClockGet(EClock, currTime=time_var, rc=rc) + ! Get start time + call ESMF_ClockGet(EClock, StartTime=time_var, rc=rc) call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc) time0 = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg) + ! Get current time + call ESMF_ClockGet(EClock, currTime=time_var, rc=rc) + call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc) + timenow = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg) + ! Debugging clocks if (debug .and. is_root_pe()) then write(glb%stdout,*) 'ocn_init_mct, current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,seconds @@ -279,7 +285,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) runtype = get_runtype() if (runtype == "initial") then ! startup (new run) - 'n' is needed below since we don't specify input_filename in input.nml - call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file = 'n') + call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, timenow, input_restart_file = 'n') else ! hybrid or branch or continuos runs ! get output path root call seq_infodata_GetData( glb%infodata, outPathRoot=restartpath ) @@ -295,7 +301,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) write(glb%stdout,*) 'Reading restart file: ',trim(restartfile) end if call shr_file_freeUnit(nu) - call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time0, input_restart_file=trim(restartfile)) + call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, timenow, input_restart_file=trim(restartfile)) endif if (is_root_pe()) then write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========' From bd5760550192f146d4cd9e130fb91441c7d85d30 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Thu, 15 Aug 2019 15:18:02 -0600 Subject: [PATCH 2/5] Add time0 and timenow in NUOPC --- config_src/nuopc_driver/mom_cap.F90 | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/config_src/nuopc_driver/mom_cap.F90 b/config_src/nuopc_driver/mom_cap.F90 index d6a7837c83..b9ac3c0814 100644 --- a/config_src/nuopc_driver/mom_cap.F90 +++ b/config_src/nuopc_driver/mom_cap.F90 @@ -737,8 +737,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) type(ice_ocean_boundary_type), pointer :: Ice_ocean_boundary => NULL() type(ocean_internalstate_wrapper) :: ocean_internalstate type(ocean_grid_type), pointer :: ocean_grid => NULL() - type(time_type) :: Run_len ! length of experiment - type(time_type) :: Time + type(time_type) :: Run_len !< length of experiment + type(time_type) :: time0 !< Model start time + type(time_type) :: timenow !< Model current time type(time_type) :: Time_restart type(time_type) :: DT integer :: DT_OCEAN @@ -841,7 +842,23 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! this ocean connector will be driven at set interval DT = set_time (DT_OCEAN, 0) - Time = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) + ! get current time + timenow = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) + + ! get start/reference time + call ESMF_ClockGet(CLOCK, refTime=MyTime, RC=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, & + file=__FILE__)) & + return ! bail out + + call ESMF_TimeGet (MyTime, YY=YEAR, MM=MONTH, DD=DAY, H=HOUR, M=MINUTE, S=SECOND, RC=rc ) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, & + file=__FILE__)) & + return ! bail out + + time0 = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) ! rsd need to figure out how to get this without share code !call shr_nuopc_get_component_instance(gcomp, inst_suffix, inst_index) @@ -971,9 +988,9 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ocean_public%is_ocean_pe = .true. if (len_trim(restartfile) > 0) then - call ocean_model_init(ocean_public, ocean_state, Time, Time, input_restart_file=trim(restartfile)) + call ocean_model_init(ocean_public, ocean_state, time0, timenow, input_restart_file=trim(restartfile)) else - call ocean_model_init(ocean_public, ocean_state, Time, Time) + call ocean_model_init(ocean_public, ocean_state, time0, timenow) endif call ocean_model_init_sfc(ocean_state, ocean_public) From 4191689d3d213190bef81a1bd8f94a376efc87fc Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Fri, 16 Aug 2019 13:55:06 -0600 Subject: [PATCH 3/5] Deletes unecessary if statement --- config_src/nuopc_driver/mom_cap.F90 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/config_src/nuopc_driver/mom_cap.F90 b/config_src/nuopc_driver/mom_cap.F90 index b9ac3c0814..e4afba6524 100644 --- a/config_src/nuopc_driver/mom_cap.F90 +++ b/config_src/nuopc_driver/mom_cap.F90 @@ -845,6 +845,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! get current time timenow = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) + if (is_root_pe()) then + write(logunit,*) subname//'current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second + endif + ! get start/reference time call ESMF_ClockGet(CLOCK, refTime=MyTime, RC=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & @@ -860,6 +864,10 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) time0 = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) + if (is_root_pe()) then + write(logunit,*) subname//'start time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second + endif + ! rsd need to figure out how to get this without share code !call shr_nuopc_get_component_instance(gcomp, inst_suffix, inst_index) !inst_name = "OCN"//trim(inst_suffix) @@ -987,11 +995,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) endif ocean_public%is_ocean_pe = .true. - if (len_trim(restartfile) > 0) then - call ocean_model_init(ocean_public, ocean_state, time0, timenow, input_restart_file=trim(restartfile)) - else - call ocean_model_init(ocean_public, ocean_state, time0, timenow) - endif + + call ocean_model_init(ocean_public, ocean_state, time0, timenow, input_restart_file=trim(restartfile)) call ocean_model_init_sfc(ocean_state, ocean_public) From 52225e34a6d87bd26c7a9f57f79ab3c08d0f07cd Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Fri, 16 Aug 2019 15:35:36 -0600 Subject: [PATCH 4/5] Deletes blank line contains spaces --- config_src/nuopc_driver/mom_cap.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/config_src/nuopc_driver/mom_cap.F90 b/config_src/nuopc_driver/mom_cap.F90 index e4afba6524..d1681bed25 100644 --- a/config_src/nuopc_driver/mom_cap.F90 +++ b/config_src/nuopc_driver/mom_cap.F90 @@ -995,7 +995,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) endif ocean_public%is_ocean_pe = .true. - call ocean_model_init(ocean_public, ocean_state, time0, timenow, input_restart_file=trim(restartfile)) call ocean_model_init_sfc(ocean_state, ocean_public) From b61053bdf594357b5f6135ff9fde64fd481aa6b4 Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Fri, 16 Aug 2019 16:04:23 -0600 Subject: [PATCH 5/5] Replaces timenow with time_start and corrects comments. --- config_src/mct_driver/ocn_comp_mct.F90 | 12 ++++++------ config_src/nuopc_driver/mom_cap.F90 | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config_src/mct_driver/ocn_comp_mct.F90 b/config_src/mct_driver/ocn_comp_mct.F90 index d7d66b32f6..a7495d7a7f 100644 --- a/config_src/mct_driver/ocn_comp_mct.F90 +++ b/config_src/mct_driver/ocn_comp_mct.F90 @@ -109,9 +109,9 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) type(mct_aVect) , intent(inout) :: o2x_o !< Fluxes from ocean to coupler, computed by ocean character(len=*), optional , intent(in) :: NLFilename !< Namelist filename - ! local variables - type(time_type) :: time0 !< Model start time - type(time_type) :: timenow !< Model current time + ! local variable + type(time_type) :: time0 !< Start time of coupled model's calendar. + type(time_type) :: time_start !< The time at which to initialize the ocean model type(ESMF_time) :: time_var !< ESMF_time variable to query time type(ESMF_time) :: time_in_ESMF !< Initial time for ocean type(ESMF_timeInterval) :: ocn_cpl_interval !< Ocean coupling interval @@ -211,7 +211,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) ! Get current time call ESMF_ClockGet(EClock, currTime=time_var, rc=rc) call ESMF_TimeGet(time_var, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc) - timenow = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg) + time_start = set_date(year, month, day, hour, minute, seconds, err_msg=err_msg) ! Debugging clocks if (debug .and. is_root_pe()) then @@ -285,7 +285,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) runtype = get_runtype() if (runtype == "initial") then ! startup (new run) - 'n' is needed below since we don't specify input_filename in input.nml - call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, timenow, input_restart_file = 'n') + call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file = 'n') else ! hybrid or branch or continuos runs ! get output path root call seq_infodata_GetData( glb%infodata, outPathRoot=restartpath ) @@ -301,7 +301,7 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename ) write(glb%stdout,*) 'Reading restart file: ',trim(restartfile) end if call shr_file_freeUnit(nu) - call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, timenow, input_restart_file=trim(restartfile)) + call ocean_model_init(glb%ocn_public, glb%ocn_state, time0, time_start, input_restart_file=trim(restartfile)) endif if (is_root_pe()) then write(glb%stdout,'(/12x,a/)') '======== COMPLETED MOM INITIALIZATION ========' diff --git a/config_src/nuopc_driver/mom_cap.F90 b/config_src/nuopc_driver/mom_cap.F90 index d1681bed25..aa034e7d36 100644 --- a/config_src/nuopc_driver/mom_cap.F90 +++ b/config_src/nuopc_driver/mom_cap.F90 @@ -738,8 +738,8 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) type(ocean_internalstate_wrapper) :: ocean_internalstate type(ocean_grid_type), pointer :: ocean_grid => NULL() type(time_type) :: Run_len !< length of experiment - type(time_type) :: time0 !< Model start time - type(time_type) :: timenow !< Model current time + type(time_type) :: time0 !< Start time of coupled model's calendar. + type(time_type) :: time_start !< The time at which to initialize the ocean model type(time_type) :: Time_restart type(time_type) :: DT integer :: DT_OCEAN @@ -843,7 +843,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! this ocean connector will be driven at set interval DT = set_time (DT_OCEAN, 0) ! get current time - timenow = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) + time_start = set_date (YEAR,MONTH,DAY,HOUR,MINUTE,SECOND) if (is_root_pe()) then write(logunit,*) subname//'current time: y,m,d-',year,month,day,'h,m,s=',hour,minute,second @@ -995,7 +995,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) endif ocean_public%is_ocean_pe = .true. - call ocean_model_init(ocean_public, ocean_state, time0, timenow, input_restart_file=trim(restartfile)) + call ocean_model_init(ocean_public, ocean_state, time0, time_start, input_restart_file=trim(restartfile)) call ocean_model_init_sfc(ocean_state, ocean_public)