Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
37 changes: 33 additions & 4 deletions .github/workflows/extbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ jobs:
FC: mpifort
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
CDEPS_VERSION: cdeps1.0.15
steps:
- uses: actions/checkout@v3
# Build the ESMF library, if the cache contains a previous build
Expand Down Expand Up @@ -50,14 +52,14 @@ jobs:
key: ${{ runner.os }}-${{ env.PIO_VERSION }}.pio
- name: Build ParallelIO
if: steps.cache-ParallelIO.outputs.cache-hit != 'true'
uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@9390e30e29d4ebbfbef0fc72162cacd9e8f25e4e
uses: NCAR/ParallelIO/.github/actions/parallelio_cmake@pio2_6_0
with:
parallelio_version: ${{ env.ParallelIO_VERSION }}
enable_fortran: True
install_prefix: $HOME/pio
- name: Build ESMF
if: steps.cache-esmf.outputs.cache-hit != 'true'
uses: ESCOMP/CDEPS/.github/actions/buildesmf@e06246b560d3132170bb1a5443fa3d65dfbd2040
uses: ESCOMP/CDEPS/.github/actions/buildesmf@cdeps1.0.15
with:
esmf_version: ${{ env.ESMF_VERSION }}
esmf_bopt: g
Expand All @@ -67,6 +69,29 @@ jobs:
netcdf_fortran_path: /usr
pnetcdf_path: /usr
parallelio_path: $HOME/pio
- name: Cache CDEPS
id: cache-cdeps
uses: actions/cache@v3
with:
path: $HOME/cdeps
key: ${{ runner.os }}-${{ env.CDEPS_VERSION }}.cdeps

- name: checkout CDEPS
uses: actions/checkout@v3
with:
repository: ESCOMP/CDEPS
path: cdeps-src
ref: ${{ env.CDEPS_VERSION }}
- name: Build CDEPS
if: steps.cache-cdeps.outputs.cache-hit != 'true'
uses: ESCOMP/CDEPS/.github/actions/buildcdeps@cdeps1.0.15
with:
esmfmkfile: $HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
pio_path: $HOME/pio
src_root: $HOME/cdeps-src
cmake_flags: " -Wno-dev -DCMAKE_BUILD_TYPE=DEBUG -DWERROR=ON -DCMAKE_Fortran_FLAGS=\"-DCPRGNU -g -Wall \
-ffree-form -ffree-line-length-none -fallow-argument-mismatch \""

- name: Build CMEPS
run: |
export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk
Expand All @@ -76,3 +101,7 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_Fortran_FLAGS="-g -Wall -Werror -ffree-form -ffree-line-length-none -Wno-unused-dummy-argument" ../
make VERBOSE=1
popd

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
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
15 changes: 15 additions & 0 deletions mediator/med.F90
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd
use esmFlds, only : med_fldlist_init1, med_fld_GetFldInfo, med_fldList_entry_type
use med_phases_history_mod, only : med_phases_history_init
use med_methods_mod , only : mediator_checkfornans

! input/output variables
type(ESMF_GridComp) :: gcomp
Expand Down Expand Up @@ -916,6 +917,20 @@ subroutine AdvertiseFields(gcomp, importState, exportState, clock, rc)
end if
end do ! end of ncomps loop

! Should mediator check for NaNs?
Comment thread
jedwards4b marked this conversation as resolved.
call NUOPC_CompAttributeGet(gcomp, name="check_for_nans", value=cvalue, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
read(cvalue, *) mediator_checkfornans
if(maintask) then
write(logunit,*) ' check_for_nans is ',mediator_checkfornans
if(mediator_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


if (profile_memory) call ESMF_VMLogMemInfo("Leaving "//trim(subname))
call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO)

Expand Down
15 changes: 8 additions & 7 deletions mediator/med_methods_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module med_methods_mod
end interface med_methods_check_for_nans

! used/reused in module

logical, public :: mediator_checkfornans ! set in med.F90 AdvertiseFields
logical :: isPresent
character(len=1024) :: msgString
type(ESMF_FieldStatus_Flag) :: status
Expand Down Expand Up @@ -2506,12 +2506,12 @@ 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(FB, maintask, logunit, rc)
use ESMF, only : ESMF_FieldBundle, ESMF_Field, ESMF_FieldBundleGet, ESMF_FieldGet
! input/output variables
type(ESMF_FieldBundle) , intent(in) :: FB
logical , intent(in) :: maintask
integer , intent(in) :: logunit
integer , intent(inout) :: rc

! local variables
Expand All @@ -2532,9 +2532,10 @@ subroutine med_methods_FB_check_for_nans(FB, rc)

#ifndef CESMCOUPLED
! For now only CESM uses shr_infnan_isnan - so until other models provide this
RETURN
mediator_checkfornans = .false.
#endif

if(.not. mediator_checkfornans) return

Comment on lines 2533 to +2534

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change in how you set the config variable, we can remove the CESMCOUPLED ifdef here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I haven't done that yet is that the github ext test doesn't include the cdeps library and thus the share code. I am working on updating the github test to include that and then will remove the ifdefs once I have that working. I got pulled into another issue though so it may be a day or two before I can get back to this, for now I'll convert this PR to draft.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks. I was worried I was holding you up by not testing this yet.

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(is_local%wrap%FBExp(compatm), 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_glc_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ subroutine med_phases_prep_glc_avg(gcomp, rc)
endif
end if

! Check for nans in fields export to atm
! Check for nans in fields export to glc
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(is_local%wrap%FBExp(compglc(ns)), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
end do

Expand Down
4 changes: 2 additions & 2 deletions mediator/med_phases_prep_ice_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ subroutine med_phases_prep_ice(gcomp, rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
end if

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

if (dbug_flag > 5) then
Expand Down
6 changes: 3 additions & 3 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 @@ -128,8 +128,8 @@ subroutine med_phases_prep_lnd(gcomp, rc)
! Set first call logical to false
first_call = .false.

! Check for nans in fields export to atm
call FB_check_for_nans(is_local%wrap%FBExp(complnd), rc=rc)
! Check for nans in fields export to lnd
call FB_check_for_nans(is_local%wrap%FBExp(complnd), 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_ocn_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ subroutine med_phases_prep_ocn_avg(gcomp, rc)
call FB_copy(is_local%wrap%FBExp(compocn), is_local%wrap%FBExpAccumOcn, rc=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)
! Check for nans in fields export to ocn
call FB_check_for_nans(is_local%wrap%FBExp(compocn), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! zero accumulator
Expand Down
4 changes: 2 additions & 2 deletions mediator/med_phases_prep_rof_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ subroutine med_phases_prep_rof(gcomp, rc)
FBfrac=is_local%wrap%FBFrac(comprof), FBin=FBlndAccum2rof_r, fldListTo=fldList, rc=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)
! Check for nans in fields export to rof
call FB_check_for_nans(is_local%wrap%FBExp(comprof), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

if (dbug_flag > 1) then
Expand Down
4 changes: 2 additions & 2 deletions mediator/med_phases_prep_wav_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ subroutine med_phases_prep_wav_avg(gcomp, rc)
call FB_copy(is_local%wrap%FBExp(compwav), is_local%wrap%FBExpAccumWav, rc=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)
! Check for nans in fields export to wav
call FB_check_for_nans(is_local%wrap%FBExp(compwav), maintask, logunit, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return

! zero accumulator
Expand Down