Skip to content

Commit

Permalink
Merge pull request #105 from NCAR/mvertens/mom6_validation
Browse files Browse the repository at this point in the history
changes needed for mom6 validation
  • Loading branch information
alperaltuntas authored Jun 27, 2019
2 parents 91d0e26 + 3f7e9f6 commit 3f8c425
Show file tree
Hide file tree
Showing 2 changed files with 289 additions and 310 deletions.
139 changes: 67 additions & 72 deletions config_src/nuopc_driver/mom_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1803,16 +1803,6 @@ subroutine ModelAdvance(gcomp, rc)
file=__FILE__)) &
return ! bail out

call ESMF_GridCompGetInternalState(gcomp, ocean_internalstate, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

Ice_ocean_boundary => ocean_internalstate%ptr%ice_ocean_boundary_type_ptr
ocean_public => ocean_internalstate%ptr%ocean_public_type_ptr
ocean_state => ocean_internalstate%ptr%ocean_state_type_ptr

! HERE THE MODEL ADVANCES: currTime -> currTime + timeStep

call ESMF_ClockPrint(clock, options="currTime", &
Expand All @@ -1835,8 +1825,7 @@ subroutine ModelAdvance(gcomp, rc)
return ! bail out

call ESMF_TimePrint(currTime + timeStep, &
preString="--------------------------------> to: ", &
unit=msgString, rc=rc)
preString="--------------------------------> to: ", unit=msgString, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
Expand Down Expand Up @@ -1869,83 +1858,89 @@ subroutine ModelAdvance(gcomp, rc)
do_advance = .true.
endif

! If the second cpl tstep of a startup run, step back a cpl tstep and advance for two cpl tsteps
if (currTime == startTime + timeStep) then
call ESMF_LogWrite("MOM6 - Stepping back one coupling timestep", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
Time = esmf2fms_time(currTime-timeStep) ! i.e., startTime
if (do_advance) then
! If the second cpl tstep of a startup run, step back a cpl tstep and advance for two cpl tsteps
if (currTime == startTime + timeStep) then
call ESMF_LogWrite("MOM6 - Stepping back one coupling timestep", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
Time = esmf2fms_time(currTime-timeStep) ! i.e., startTime

call ESMF_LogWrite("MOM6 - doubling the coupling timestep", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
Time_step_coupled = 2 * esmf2fms_time(timeStep)
endif
end if

call ESMF_LogWrite("MOM6 - doubling the coupling timestep", ESMF_LOGMSG_INFO, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
Time_step_coupled = 2 * esmf2fms_time(timeStep)
endif
endif
endif

if (do_advance) then

!---------------
! Write diagnostics for import
!---------------
call ESMF_GridCompGetInternalState(gcomp, ocean_internalstate, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

if(write_diagnostics) then
call NUOPC_Write(importState, fileNamePrefix='field_ocn_import_', &
timeslice=import_slice, relaxedFlag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
import_slice = import_slice + 1
endif
Ice_ocean_boundary => ocean_internalstate%ptr%ice_ocean_boundary_type_ptr
ocean_public => ocean_internalstate%ptr%ocean_public_type_ptr
ocean_state => ocean_internalstate%ptr%ocean_state_type_ptr

!---------------
! Get ocean grid
!---------------
!---------------
! Write diagnostics for import
!---------------

call get_ocean_grid(ocean_state, ocean_grid)
if (write_diagnostics) then
call NUOPC_Write(importState, fileNamePrefix='field_ocn_import_', &
timeslice=import_slice, relaxedFlag=.true., rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
import_slice = import_slice + 1
endif

!---------------
! Import data
!---------------
!---------------
! Get ocean grid
!---------------

call shr_file_setLogUnit (logunit)
call get_ocean_grid(ocean_state, ocean_grid)

!---------------
! Import data
!---------------

if (cesm_coupled) then
call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, runtype=runtype, rc=rc)
else
call mom_import(ocean_public, ocean_grid, importState, ice_ocean_boundary, rc=rc)
endif
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

!---------------
! Update MOM6
!---------------
!---------------
! Update MOM6
!---------------

if(profile_memory) call ESMF_VMLogMemInfo("Entering MOM update_ocean_model: ")
if (do_advance) then
call update_ocean_model(Ice_ocean_boundary, ocean_state, ocean_public, Time, Time_step_coupled)
endif
if(profile_memory) call ESMF_VMLogMemInfo("Leaving MOM update_ocean_model: ")
if(profile_memory) call ESMF_VMLogMemInfo("Entering MOM update_ocean_model: ")
call update_ocean_model(Ice_ocean_boundary, ocean_state, ocean_public, Time, Time_step_coupled)
if(profile_memory) call ESMF_VMLogMemInfo("Leaving MOM update_ocean_model: ")

!---------------
! Export Data
!---------------
!---------------
! Export Data
!---------------

call mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out
call mom_export(ocean_public, ocean_grid, ocean_state, exportState, clock, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, &
file=__FILE__)) &
return ! bail out

call shr_file_setLogUnit (logunit)
endif

!---------------
! If restart alarm is ringing - write restart file
Expand Down
Loading

0 comments on commit 3f8c425

Please sign in to comment.