Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
CXX: mpicxx
CPPFLAGS: "-I/usr/include -I/usr/local/include"
# Versions of all dependencies can be updated here
ESMF_VERSION: v8.4.0
ESMF_VERSION: v8.4.2
PNETCDF_VERSION: checkpoint.1.12.3
NETCDF_FORTRAN_VERSION: v4.6.0
PIO_VERSION: pio2_5_10
PIO_VERSION: pio2_6_0
steps:
- uses: actions/checkout@v3
# Build the ESMF library, if the cache contains a previous build
Expand Down
11 changes: 11 additions & 0 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,17 @@
<value>$ESMF_VERBOSITY_LEVEL</value>
</values>
</entry>
<entry id="check_for_nans">
<type>logical</type>
<category>performance</category>
<group>MED_attributes</group>
<desc>
Check for NaN values in fields returned from mediator to components. This has a small performance impact.
</desc>
<values>
<value>.true.</value>
</values>
</entry>
<entry id="atm_nx" modify_via_xml="ATM_NX">
<type>integer</type>
<category>control</category>
Expand Down
38 changes: 31 additions & 7 deletions mediator/med_methods_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2506,12 +2506,14 @@ subroutine med_methods_FB_getmesh(FB, mesh, rc)
end subroutine med_methods_FB_getmesh

!-----------------------------------------------------------------------------
subroutine med_methods_FB_check_for_nans(FB, rc)

use ESMF, only : ESMF_FieldBundle, ESMF_Field, ESMF_FieldBundleGet, ESMF_FieldGet

subroutine med_methods_FB_check_for_nans(gcomp, FB, maintask, logunit, rc)
Comment thread
jedwards4b marked this conversation as resolved.
Outdated
use ESMF, only : ESMF_FieldBundle, ESMF_Field, ESMF_FieldBundleGet, ESMF_FieldGet, ESMF_GridComp
use NUOPC, only : NUOPC_CompAttributeGet
! input/output variables
type(ESMF_GridComp) , intent(in) :: gcomp
type(ESMF_FieldBundle) , intent(in) :: FB
logical , intent(in) :: maintask
integer , intent(in) :: logunit
integer , intent(inout) :: rc

! local variables
Expand All @@ -2526,15 +2528,37 @@ subroutine med_methods_FB_check_for_nans(FB, rc)
character(len=CS) :: nancount_char
character(len=CL) :: msg_error
logical :: nanfound
logical, save :: checkfornans
logical, save :: firstcall=.true.
character(len=CL) :: cvalue
character(len=*), parameter :: subname='(med_methods_FB_check_for_nans)'
! ----------------------------------------------
rc = ESMF_SUCCESS

#ifndef CESMCOUPLED
#ifdef CESMCOUPLED
if (firstcall) then
call NUOPC_CompAttributeGet(gcomp, name="check_for_nans", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue, *) checkfornans
firstcall = .false.
if(maintask) then
write(logunit,*) ' check_for_nans is ',checkfornans
if(checkfornans) then
write(logunit,*) ' Fields will be checked for NaN values when passed from mediator to component'
else
write(logunit,*) ' Fields will NOT be checked for NaN values when passed from mediator to component'
endif
endif
endif
#else
! For now only CESM uses shr_infnan_isnan - so until other models provide this
RETURN
cvalue = ".false."
checkfornans = .false.
if(firstcall) write(logunit,*) ' Fields will NOT be checked for NaN values when passed from mediator to component'
firstcall = .false.
#endif

if(.not. checkfornans) return

call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

Expand Down
4 changes: 2 additions & 2 deletions mediator/med_phases_prep_atm_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module med_phases_prep_atm_mod
use med_methods_mod , only : FB_check_for_nans => med_methods_FB_check_for_nans
use med_merge_mod , only : med_merge_auto
use med_map_mod , only : med_map_field_packed
use med_internalstate_mod , only : InternalState, maintask
use med_internalstate_mod , only : InternalState, maintask, logunit
use med_internalstate_mod , only : compatm, compocn, compice, compname, coupling_mode
use esmFlds , only : med_fldlist_GetfldListTo, med_fldlist_type
use perf_mod , only : t_startf, t_stopf
Expand Down Expand Up @@ -245,7 +245,7 @@ subroutine med_phases_prep_atm(gcomp, rc)
end if

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(compatm), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(compatm), maintask, logunit, rc=rc)
Comment thread
jedwards4b marked this conversation as resolved.
Outdated
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug_flag > 5) then
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_prep_glc_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ subroutine med_phases_prep_glc_avg(gcomp, rc)

! Check for nans in fields export to atm
do ns = 1,is_local%wrap%num_icesheets
call FB_check_for_nans(is_local%wrap%FBExp(compglc(ns)), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(compglc(ns)), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end do

Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_prep_ice_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ subroutine med_phases_prep_ice(gcomp, rc)
end if

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(compice), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(compice), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug_flag > 5) then
Expand Down
4 changes: 2 additions & 2 deletions mediator/med_phases_prep_lnd_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ subroutine med_phases_prep_lnd(gcomp, rc)
use med_utils_mod , only : chkerr => med_utils_ChkErr
use med_constants_mod , only : dbug_flag => med_constants_dbug_flag
use med_internalstate_mod , only : complnd, compatm
use med_internalstate_mod , only : InternalState, maintask
use med_internalstate_mod , only : InternalState, maintask, logunit
use med_merge_mod , only : med_merge_auto
use perf_mod , only : t_startf, t_stopf

Expand Down Expand Up @@ -129,7 +129,7 @@ subroutine med_phases_prep_lnd(gcomp, rc)
first_call = .false.

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(complnd), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(complnd), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug_flag > 5) then
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_prep_ocn_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ subroutine med_phases_prep_ocn_avg(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(compocn), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(compocn), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! zero accumulator
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_prep_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ subroutine med_phases_prep_rof(gcomp, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(comprof), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(comprof), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug_flag > 1) then
Expand Down
2 changes: 1 addition & 1 deletion mediator/med_phases_prep_wav_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ subroutine med_phases_prep_wav_avg(gcomp, rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(compwav), rc=rc)
call FB_check_for_nans(gcomp, is_local%wrap%FBExp(compwav), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! zero accumulator
Expand Down