From 80a5ad544d8997931dde7fa7c8ebad56612ed299 Mon Sep 17 00:00:00 2001 From: Ufuk Turuncoglu Date: Fri, 19 Apr 2024 14:28:34 -0500 Subject: [PATCH] minor fix for standalone build --- model/src/wav_shr_mod.F90 | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/model/src/wav_shr_mod.F90 b/model/src/wav_shr_mod.F90 index 0780852b3..2d4c1149f 100644 --- a/model/src/wav_shr_mod.F90 +++ b/model/src/wav_shr_mod.F90 @@ -26,6 +26,7 @@ module wav_shr_mod use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent + use ESMF , only : ESMF_FieldStatus_Flag, ESMF_FIELDSTATUS_COMPLETE use NUOPC , only : NUOPC_CompAttributeGet use NUOPC_Model , only : NUOPC_ModelGet use wav_kind_mod , only : r8 => shr_kind_r8, i8 => shr_kind_i8, cl=>shr_kind_cl, cs=>shr_kind_cs @@ -486,6 +487,7 @@ subroutine state_reset(State, reset_value, rc) ! local variables integer :: i,j,n type(ESMF_Field) :: lfield + type(ESMF_FieldStatus_Flag) :: lstatus integer :: fieldCount integer :: lrank character(ESMF_MAXSTR), allocatable :: lfieldnamelist(:) @@ -507,19 +509,24 @@ subroutine state_reset(State, reset_value, rc) call ESMF_StateGet(State, itemName=trim(lfieldnamelist(n)), field=lfield, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call field_getfldptr(lfield, fldptr1=fldptr1, fldptr2=fldptr2, rank=lrank, rc=rc) + call ESMF_FieldGet(lfield, status=lstatus, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (lrank == 0) then - ! no local data - elseif (lrank == 1) then - fldptr1 = reset_value - elseif (lrank == 2) then - fldptr2 = reset_value - else - call ESMF_LogWrite(trim(subname)//": ERROR in rank "//trim(lfieldnamelist(n)), ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return + if (lstatus == ESMF_FIELDSTATUS_COMPLETE) then + call field_getfldptr(lfield, fldptr1=fldptr1, fldptr2=fldptr2, rank=lrank, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + if (lrank == 0) then + ! no local data + elseif (lrank == 1) then + fldptr1 = reset_value + elseif (lrank == 2) then + fldptr2 = reset_value + else + call ESMF_LogWrite(trim(subname)//": ERROR in rank "//trim(lfieldnamelist(n)), ESMF_LOGMSG_ERROR) + rc = ESMF_FAILURE + return + endif endif enddo