diff --git a/mediator/med_phases_prep_glc_mod.F90 b/mediator/med_phases_prep_glc_mod.F90 index 91ced9ef..b0f4c084 100644 --- a/mediator/med_phases_prep_glc_mod.F90 +++ b/mediator/med_phases_prep_glc_mod.F90 @@ -41,7 +41,6 @@ module med_phases_prep_glc_mod use med_methods_mod , only : FB_check_for_nans => med_methods_FB_check_for_nans use med_methods_mod , only : field_getdata2d => med_methods_Field_getdata2d use med_methods_mod , only : field_getdata1d => med_methods_Field_getdata1d - use med_methods_mod , only : fldchk => med_methods_FB_FldChk use med_methods_mod , only : med_methods_FB_check_wtracers use med_field_info_mod , only : med_field_info_type, med_field_info_array_from_state use med_utils_mod , only : chkerr => med_utils_ChkErr @@ -640,16 +639,20 @@ subroutine med_phases_prep_glc_avg(gcomp, rc) ! Average and map data from land (and possibly ocean) if (do_avg) then - ! Always average import from accumulated land import data - if (lndAccum2glc_cnt > 0) then - ! If accumulation count is greater than 0, do the averaging - call fldbun_average(FB=FBlndAccum2glc_l, count=lndAccum2glc_cnt, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - else - ! If accumulation count is 0, then simply set the averaged field bundle values from the land - ! to the import field bundle values - call fldbun_copy(FBout=FBlndAccum2glc_l, FBin=is_local%wrap%FBImp(complnd,complnd), rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return + if (ESMF_FieldBundleIsCreated(FBlndAccum2glc_l)) then + ! Average import from accumulated land import data as long as the accumulator has + ! been created (if accum_lnd2glc is false, the accumulator isn't created, but this + ! subroutine may still be called). + if (lndAccum2glc_cnt > 0) then + ! If accumulation count is greater than 0, do the averaging + call fldbun_average(FB=FBlndAccum2glc_l, count=lndAccum2glc_cnt, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + else + ! If accumulation count is 0, then simply set the averaged field bundle values from the land + ! to the import field bundle values + call fldbun_copy(FBout=FBlndAccum2glc_l, FBin=is_local%wrap%FBImp(complnd,complnd), rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + end if end if if (is_local%wrap%ocn2glc_coupling) then