Skip to content

Commit

Permalink
Merge pull request #129 from ESCOMP/mvertens/fix_preplnd_bug
Browse files Browse the repository at this point in the history
fixed bugs in med_phases_prep_lnd and med_phases_diag_mod
  • Loading branch information
jedwards4b authored Nov 10, 2020
2 parents 8372158 + fd5e23c commit 0315cae
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 183 deletions.
11 changes: 8 additions & 3 deletions cime_config/runseq/runseq_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ def gen_runseq(case, coupling_times):
if (cpl_seq_option == 'RASM'):
runseq.add_action("MED med_phases_prep_ocn_map" , med_to_ocn)
if cpl_add_aoflux:
runseq.add_action("MED med_phases_aofluxes_run" , run_ocn and run_atm and (med_to_ocn or med_to_atm))
runseq.add_action("MED med_phases_aofluxes_run" , run_ocn and run_atm and (med_to_ocn or med_to_atm))
runseq.add_action("MED med_phases_prep_ocn_merge" , med_to_ocn)
runseq.add_action("MED med_phases_prep_ocn_accum_fast" , med_to_ocn)
runseq.add_action("MED med_phases_ocnalb_run" , (run_ocn and run_atm and (med_to_ocn or med_to_atm)) and not xcompset)
runseq.add_action("MED med_phases_diag_ocn" , run_ocn and diag_mode)

runseq.add_action("MED med_phases_prep_lnd" , med_to_lnd)
runseq.add_action("MED -> LND :remapMethod=redist" , med_to_lnd)
runseq.add_action("MED med_phases_prep_ice" , med_to_ice)
Expand All @@ -108,18 +110,21 @@ def gen_runseq(case, coupling_times):
runseq.add_action("ROF" , run_rof and not rof_outer_loop)
runseq.add_action("WAV" , run_wav)
runseq.add_action("OCN" , run_ocn and not ocn_outer_loop)

if coupling_mode == 'hafs':
runseq.add_action("OCN -> MED :remapMethod=redist:ignoreUnmatchedIndices=true" , run_ocn and not ocn_outer_loop)
else:
runseq.add_action("OCN -> MED :remapMethod=redist" , run_ocn and not ocn_outer_loop)

if (cpl_seq_option == 'TIGHT'):
runseq.add_action("MED med_phases_prep_ocn_map" , med_to_ocn)
if cpl_add_aoflux:
runseq.add_action("MED med_phases_aofluxes_run" , run_ocn and run_atm)
runseq.add_action("MED med_phases_aofluxes_run" , run_ocn and run_atm)
runseq.add_action("MED med_phases_prep_ocn_merge" , med_to_ocn)
runseq.add_action("MED med_phases_prep_ocn_accum_fast" , med_to_ocn)
runseq.add_action("MED med_phases_ocnalb_run" , (run_ocn and run_atm) and not xcompset)
runseq.add_action("MED med_phases_diag_ocn" , run_ocn and diag_mode and not ocn_outer_loop)
runseq.add_action("MED med_phases_diag_ocn" , run_ocn and diag_mode)

runseq.add_action("LND -> MED :remapMethod=redist" , run_lnd)
runseq.add_action("ICE -> MED :remapMethod=redist" , run_ice)
runseq.add_action("MED med_phases_diag_ice_ice2med" , run_ice and diag_mode)
Expand Down
74 changes: 67 additions & 7 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ subroutine SetServices(gcomp, rc)
use ESMF , only: ESMF_SUCCESS, ESMF_GridCompSetEntryPoint
use ESMF , only: ESMF_METHOD_INITIALIZE, ESMF_METHOD_RUN
use ESMF , only: ESMF_GridComp, ESMF_MethodRemove
use NUOPC , only: NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize, NUOPC_NOOP
use NUOPC , only: NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize, NUOPC_NoOP
use NUOPC_Mediator , only: mediator_routine_SS => SetServices
use NUOPC_Mediator , only: mediator_routine_Run => routine_Run
use NUOPC_Mediator , only: mediator_label_DataInitialize => label_DataInitialize
Expand Down Expand Up @@ -190,6 +190,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_history_write", specRoutine=med_phases_history_write, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_history_write", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! setup mediator restart phase
Expand All @@ -201,6 +204,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_restart_write", specRoutine=med_phases_restart_write, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_restart_write", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! setup mediator profile phase
Expand All @@ -212,6 +218,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_profile", specRoutine=med_phases_profile, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_profile", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! prep routines for atm
Expand All @@ -234,20 +243,29 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_prep_ocn_map", specRoutine=med_phases_prep_ocn_map, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_prep_ocn_map", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_prep_ocn_merge"/), userRoutine=mediator_routine_Run, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_prep_ocn_merge", specRoutine=med_phases_prep_ocn_merge, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_prep_ocn_merge", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_prep_ocn_accum_fast"/), userRoutine=mediator_routine_Run, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_prep_ocn_accum_fast", specRoutine=med_phases_prep_ocn_accum_fast, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_prep_ocn_accum_fast", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_prep_ocn_accum_avg"/), userRoutine=mediator_routine_Run, rc=rc)
Expand Down Expand Up @@ -295,6 +313,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_prep_rof_accum", specRoutine=med_phases_prep_rof_accum, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_prep_rof_accum", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! prep routines for wav
Expand Down Expand Up @@ -324,6 +345,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_prep_glc_accum", specRoutine=med_phases_prep_glc_accum, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_prep_glc_accum", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! phase routine for ocean albedo computation
Expand All @@ -335,6 +359,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_ocnalb_run", specRoutine=med_phases_ocnalb_run, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_ocnalb_run", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! phase routine for ocn/atm flux computation
Expand All @@ -346,6 +373,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_aofluxes_run", specRoutine=med_phases_aofluxes_run, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_aofluxes_run", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! phase routine for updating fractions
Expand All @@ -357,6 +387,9 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_fraction_set", specRoutine=med_fraction_set, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_fraction_set", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! phase routines for budget diagnostics
Expand All @@ -367,54 +400,81 @@ subroutine SetServices(gcomp, rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_atm", specRoutine=med_phases_diag_atm, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_atm", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_lnd"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_lnd", specRoutine=med_phases_diag_lnd, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_lnd", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_rof"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_rof", specRoutine=med_phases_diag_rof, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_rof", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_ocn"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_ocn", specRoutine=med_phases_diag_ocn, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_ocn", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_glc"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_glc", specRoutine=med_phases_diag_glc, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_glc", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_ice_ice2med"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_ice_ice2med", specRoutine=med_phases_diag_ice_ice2med, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_ice_ice2med", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_ice_med2ice"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_ice_med2ice", specRoutine=med_phases_diag_ice_med2ice, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_ice_med2ice", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_accum"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaselabel="med_phases_diag_accum", specRoutine=med_phases_diag_accum, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_accum", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, &
phaseLabelList=(/"med_phases_diag_print"/), userRoutine=mediator_routine_Run, rc=rc)
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, &
specPhaseLabel="med_phases_diag_print", specRoutine=med_phases_diag_print, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, &
specPhaselabel="med_phases_diag_print", specRoutine=NUOPC_NoOp, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

!------------------
! attach specializing method(s)
Expand Down Expand Up @@ -2382,15 +2442,15 @@ subroutine med_grid_write(grid, fileName, rc)
use ESMF, only : ESMF_SUCCESS, ESMF_GRIDITEM_MASK, ESMF_GRIDITEM_AREA

! input/output variables
type(ESMF_Grid), intent(in) :: grid
character(len=*) :: fileName
integer, intent(out) :: rc
type(ESMF_Grid) , intent(in) :: grid
character(len=*), intent(in) :: fileName
integer , intent(out) :: rc

! local variables
type(ESMF_Array) :: array
type(ESMF_Array) :: array
type(ESMF_ArrayBundle) :: arrayBundle
integer :: tileCount
logical :: isPresent
integer :: tileCount
logical :: isPresent
character(len=*), parameter :: subname=' (module_MED_map:med_grid_write) '
!-------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 0315cae

Please sign in to comment.