Skip to content

Commit

Permalink
Ignore empty output bundle (#679)
Browse files Browse the repository at this point in the history
* If the output bundle has no fields do not attempt to get a grid
* Comment out return status check after recover_fields
  • Loading branch information
DusanJovic-NOAA committed Jul 28, 2023
1 parent 6d17939 commit 1158696
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
14 changes: 10 additions & 4 deletions fv3_cap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ subroutine ModelAdvance_phase2(gcomp, rc)
character(240) :: msgString

type(ESMF_Clock) :: clock, clock_out
integer :: fieldCount

!-----------------------------------------------------------------------------

Expand Down Expand Up @@ -1147,12 +1148,17 @@ subroutine ModelAdvance_phase2(gcomp, rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
endif

! execute the routehandle from fcstFB -> wrtFB (either Regrid() or Redist())
call ESMF_FieldBundleSMM(fcstFB(j), wrtFB(j,n_group), &
routehandle=routehandle(j, n_group), &
termorderflag=(/ESMF_TERMORDER_SRCSEQ/), rc=rc)
! execute the routehandle from fcstFB -> wrtFB (either Regrid() or Redist()), only if there are fields in the bundle
call ESMF_FieldBundleGet(fcstFB(j), fieldCount=fieldCount, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

if (fieldCount > 0) then
call ESMF_FieldBundleSMM(fcstFB(j), wrtFB(j,n_group), &
routehandle=routehandle(j, n_group), &
termorderflag=(/ESMF_TERMORDER_SRCSEQ/), rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
end if

enddo

call ESMF_VMEpochExit(rc=rc)
Expand Down
20 changes: 16 additions & 4 deletions io/module_wrt_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,14 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
endif

! deal with all of the Fields inside this fcstFB
call ESMF_FieldBundleGet(fcstFB, fieldCount=fieldCount, grid=fcstGrid, rc=rc)
call ESMF_FieldBundleGet(fcstFB, fieldCount=fieldCount, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

if (fieldCount > 0) then

call ESMF_FieldBundleGet(fcstFB, grid=fcstGrid, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

allocate(fcstField(fieldCount))
call ESMF_FieldBundleGet(fcstFB, fieldList=fcstField, &
itemorderflag=ESMF_ITEMORDER_ADDORDER, rc=rc)
Expand Down Expand Up @@ -1979,6 +1982,11 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)

!recover fields from cartesian vector and sfc pressure
call recover_fields(file_bundle,rc)
! FIXME rrfs_smoke_conus13km_fast_phy32_qr crashes with teh following error in recover_fields
! 20230720 121647.816 ERROR PET147 ESMF_Grid.F90:20442 ESMF_GridGetCoord2DR8 Arguments are incompatible - - farrayPtr typekind does not match Grid typekind
! 20230720 121647.816 ERROR PET147 module_wrt_grid_comp.F90:2450 Arguments are incompatible - Passing error in return code

! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
enddo
!
!-----------------------------------------------------------------------
Expand Down Expand Up @@ -2426,10 +2434,14 @@ subroutine recover_fields(file_bundle,rc)
real(ESMF_KIND_R8) :: coslon, sinlon, sinlat
!
! get filed count
call ESMF_FieldBundleGet(file_bundle, fieldCount=fieldCount, &
grid=fieldGrid, rc=rc)
call ESMF_FieldBundleGet(file_bundle, fieldCount=fieldCount, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
!

if (fieldCount == 0) return

call ESMF_FieldBundleGet(file_bundle, grid=fieldGrid, rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

call ESMF_LogWrite("call recover field on wrt comp",ESMF_LOGMSG_INFO,rc=RC)
call ESMF_GridGet(fieldgrid, dimCount=gridDimCount, rc=rc)

Expand Down

0 comments on commit 1158696

Please sign in to comment.