Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions cime_config/namelist_definition_drv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,22 @@
</values>
</entry>

<entry id="water_tracers_variables_not_checked">
<type>char</type>
<category>water_tracers</category>
<group>ALLCOMP_attributes</group>
<desc>
Colon-delimited list of variables for which water tracer consistency checks should be skipped.

Each entry must match the variable name passed to shr_wtracers_check_tracer_ratios.
For checks of mediator fields, these are of the form FieldBundleName%FieldName.
For example: "FBImpatm%Sa_shum_wtracers:FBExprof%Flrl_irrig_wtracers".
</desc>
<values>
<value></value>
</values>
</entry>

<!-- =========================== -->
<!-- CLOCK Attributes -->
<!-- =========================== -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
water_tracer_initial_ratios = "0.1:2"
water_tracers_do_checks = .true.

! Tracers currently aren't mapped properly for irrigation
! (https://github.com/escomp/cmeps/issues/675), so bypass tracer checks for this field
water_tracers_variables_not_checked = "FBExprof%Flrl_irrig_wtracers"
26 changes: 16 additions & 10 deletions mediator/med_methods_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2795,6 +2795,7 @@ subroutine med_methods_FB_check_wtracers(FB, rc)
integer :: fieldrank
logical :: hasSuffix
logical :: isPresentNonTracer
logical :: check_skipped
type(ESMF_Field) :: fieldTracers
type(ESMF_Field) :: fieldNonTracer

Expand Down Expand Up @@ -2831,9 +2832,16 @@ subroutine med_methods_FB_check_wtracers(FB, rc)
if (hasSuffix) then
call ESMF_FieldBundleGet(FB, fieldName=fieldNameNonTracer, isPresent=isPresentNonTracer, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
if (isPresentNonTracer) then
if (.not. isPresentNonTracer) then
! This is the situation for a small number of fields where we have a tracer
! field without a corresponding non-tracer field.
if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": Skipping check for <" // trim(FBName)//"%"//trim(fieldNameList(n)) // &
"> which has no corresponding non-tracer field", ESMF_LOGMSG_INFO)
end if
Comment on lines +2835 to +2841

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This looks like a bigger diff than it really is: The conditional has been rearranged so that this .not. isPresentNonTracer is the first block, and then the standard case is in the else. This made sense at first because there were going to be multiple skip conditions so it was going to look like:

if (.not. isPresentNonTracer) then
   ...
else if (variable_in_skip_list) then
   ...
else
   ! standard case, not skipped
end if

It ended up making more sense to put the variable-in-skip-list check inside the main code branch - because it was simplest to check/set this in the wtracers_check_tracer_ratios call - but I felt like I marginally liked this conditional block arrangement better because it lends itself better to possible future changes (such as new ways to skip a variable), and I had already done testing with this code structure, so I decided to leave this change in place.

else
if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": Checking <" // trim(fieldNameList(n)) // &
call ESMF_LogWrite(trim(subname)//": Checking <" // trim(FBName)//"%"//trim(fieldNameList(n)) // &
"> against <" // trim(fieldNameNonTracer) // ">", &
ESMF_LOGMSG_INFO)
end if
Expand All @@ -2852,26 +2860,24 @@ subroutine med_methods_FB_check_wtracers(FB, rc)
call ESMF_FieldGet(fieldNonTracer, farrayPtr=dataNonTracer1d, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call wtracers_check_tracer_ratios(dataTracers2d, dataNonTracer1d, &
trim(FBName)//":"//trim(fieldNameList(n)))
trim(FBName)//"%"//trim(fieldNameList(n)), check_skipped=check_skipped)
else if (fieldrank == 2) then
call ESMF_FieldGet(fieldTracers, farrayPtr=dataTracers3d, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call ESMF_FieldGet(fieldNonTracer, farrayPtr=dataNonTracer2d, rc=rc)
if (chkerr(rc,__LINE__,u_FILE_u)) return
call wtracers_check_tracer_ratios(dataTracers3d, dataNonTracer2d, &
trim(FBName)//":"//trim(fieldNameList(n)))
trim(FBName)//"%"//trim(fieldNameList(n)), check_skipped=check_skipped)
else
write(msg,'(a,i0)') subname//": ERROR: unhandled field rank ", fieldrank
call shr_log_error(msg, &
line=__LINE__, file=u_FILE_u, rc=rc)
return
end if
else
! This is the situation for a small number of fields where we have a tracer
! field without a corresponding non-tracer field.
if (dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": Skipping check for <" // trim(fieldNameList(n)) // &
"> which has no corresponding non-tracer field", ESMF_LOGMSG_INFO)

if (check_skipped .and. dbug_flag > 5) then
call ESMF_LogWrite(trim(subname)//": Skipping check for <" // trim(FBName)//"%"//trim(fieldNameList(n)) // &
"> which is in the list of variables not to check", ESMF_LOGMSG_INFO)
end if
end if
end if
Expand Down
12 changes: 8 additions & 4 deletions ufs/wtracers_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ subroutine wtracers_get_bulk_fieldname(fieldname, is_wtracer_field, bulk_fieldna
end subroutine wtracers_get_bulk_fieldname

!-----------------------------------------------------------------------
subroutine wtracers_check_tracer_ratios_1d(tracers, bulk, name)
subroutine wtracers_check_tracer_ratios_1d(tracers, bulk, variable_name, check_skipped)
!
! !DESCRIPTION:
! Check tracer ratios (tracer/bulk) against expectations
Expand All @@ -104,14 +104,16 @@ subroutine wtracers_check_tracer_ratios_1d(tracers, bulk, name)
! !ARGUMENTS
real(r8), intent(in) :: tracers(:,:) ! dimensioned [tracerNum, gridcell]
real(r8), intent(in) :: bulk(:)
character(len=*), intent(in) :: name ! for diagnostic output
character(len=*), intent(in) :: variable_name
logical, intent(out) :: check_skipped ! true if the check was skipped
!-----------------------------------------------------------------------

! Do nothing
check_skipped = .true.
end subroutine wtracers_check_tracer_ratios_1d

!-----------------------------------------------------------------------
subroutine wtracers_check_tracer_ratios_2d(tracers, bulk, name)
subroutine wtracers_check_tracer_ratios_2d(tracers, bulk, variable_name, check_skipped)
!
! !DESCRIPTION:
! Check tracer ratios (tracer/bulk) against expectations for 2-d bulk arrays
Expand All @@ -121,10 +123,12 @@ subroutine wtracers_check_tracer_ratios_2d(tracers, bulk, name)
! !ARGUMENTS
real(r8), intent(in) :: tracers(:,:,:) ! dimensioned [ungriddedDim, tracerNum, gridcell]
real(r8), intent(in) :: bulk(:,:) ! dimensioned [ungriddedDim, gridcell]
character(len=*), intent(in) :: name ! for diagnostic output
character(len=*), intent(in) :: variable_name
logical, intent(out) :: check_skipped ! true if the check was skipped
!-----------------------------------------------------------------------

! Do nothing
check_skipped = .true.
end subroutine wtracers_check_tracer_ratios_2d

end module wtracers_mod
Loading