Skip to content

Commit fdbb234

Browse files
authored
Merge pull request #2051 from slevis-lmwg/nag_test_fixes
Fixes for failing nag tests
2 parents 311ed6d + d8f8b1e commit fdbb234

File tree

8 files changed

+91
-16
lines changed

8 files changed

+91
-16
lines changed

doc/ChangeLog

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,63 @@
11
===============================================================
2+
Tag name: ctsm5.1.dev139
3+
Originator(s): slevis (Samuel Levis)
4+
Date: Fri Aug 25 16:47:45 MDT 2023
5+
One-line Summary: Fix problems uncovered by nag -nan tests
6+
7+
Purpose and description of changes
8+
----------------------------------
9+
10+
Fix problems uncovered by adding the -nan compilation flag for the Nag
11+
compiler.
12+
13+
14+
Significant changes to scientifically-supported configurations
15+
--------------------------------------------------------------
16+
17+
Does this tag change answers significantly for any of the following physics configurations?
18+
(Details of any changes will be given in the "Answer changes" section below.)
19+
20+
[Put an [X] in the box for any configuration with significant answer changes.]
21+
22+
[ ] clm5_1
23+
24+
[ ] clm5_0
25+
26+
[ ] ctsm5_0-nwp
27+
28+
[ ] clm4_5
29+
30+
31+
Bugs fixed or introduced
32+
------------------------
33+
CTSM issues fixed (include CTSM Issue #):
34+
Makes progress on issue #1994 (same title)
35+
36+
37+
Testing summary:
38+
----------------
39+
40+
[PASS means all tests PASS; OK means tests PASS other than expected fails.]
41+
42+
regular tests (aux_clm: https://github.com/ESCOMP/CTSM/wiki/System-Testing-Guide#pre-merge-system-testing):
43+
44+
cheyenne ---- OK
45+
izumi ------- PASS
46+
47+
48+
Answer changes
49+
--------------
50+
51+
Changes answers relative to baseline: No
52+
53+
54+
Other details
55+
-------------
56+
Pull Requests that document the changes (include PR ids):
57+
https://github.com/ESCOMP/ctsm/pull/2051
58+
59+
===============================================================
60+
===============================================================
261
Tag name: ctsm5.1.dev138
362
Originator(s): slevis (Samuel Levis,UCAR/TSS,303-665-1310)
463
Date: Fri Aug 25 14:44:22 MDT 2023

doc/ChangeSum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Tag Who Date Summary
22
============================================================================================================================
3+
ctsm5.1.dev139 slevis 08/28/2023 Fix problems uncovered by nag -nan tests
34
ctsm5.1.dev138 slevis 08/25/2023 Refactor max_patch_per_col and maxsoil_patches loops
45
ctsm5.1.dev137 slevis 08/23/2023 Surface roughness modifications
56
ctsm5.1.dev136 multiple 08/22/2023 Change order of history fields to improve performance on derecho

src/biogeochem/CNVegNitrogenStateType.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,6 @@ subroutine Summary_nitrogenstate(this, bounds, num_soilc, filter_soilc, num_soil
11451145
this%totn_p2c_col(bounds%begc:bounds%endc))
11461146
end if
11471147

1148-
11491148
end subroutine Summary_nitrogenstate
11501149

11511150
!-----------------------------------------------------------------------

src/biogeochem/NutrientCompetitionFlexibleCNMod.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,6 @@ subroutine calc_plant_nitrogen_demand(this, bounds, &
13651365
frootn => cnveg_nitrogenstate_inst%frootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N
13661366
livestemn_to_retransn => cnveg_nitrogenflux_inst%livestemn_to_retransn_patch,& ! Output: [real(r8) (:) ]
13671367
sminn_vr => soilbiogeochem_nitrogenstate_inst%sminn_vr_col , & ! Input: [real(r8) (:,:) ] (gN/m3) soil mineral N
1368-
btran => energyflux_inst%btran_patch , & ! Input: [real(r8) (:) ] transpiration wetness factor (0 to 1)
13691368
t_scalar => soilbiogeochem_carbonflux_inst%t_scalar_col & ! Input: [real(r8) (:,:) ] soil temperature scalar for decomp
13701369
)
13711370

src/biogeophys/FrictionVelocityMod.F90

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,13 @@ subroutine FrictionVelocity(this, lbn, ubn, fn, filtern, &
750750
real(r8) , intent(in) :: ur ( lbn: ) ! wind speed at reference height [m/s] [lbn:ubn]
751751
real(r8) , intent(in) :: um ( lbn: ) ! wind speed including the stablity effect [m/s] [lbn:ubn]
752752
real(r8) , intent(out) :: ustar ( lbn: ) ! friction velocity [m/s] [lbn:ubn]
753-
real(r8) , intent(out) :: temp1 ( lbn: ) ! relation for potential temperature profile [lbn:ubn]
754-
real(r8) , intent(out) :: temp12m ( lbn: ) ! relation for potential temperature profile applied at 2-m [lbn:ubn]
755-
real(r8) , intent(out) :: temp2 ( lbn: ) ! relation for specific humidity profile [lbn:ubn]
756-
real(r8) , intent(out) :: temp22m ( lbn: ) ! relation for specific humidity profile applied at 2-m [lbn:ubn]
753+
! temp1, temp12m, temp2, temp22m are "inout" rather than "out" to
754+
! prevent returning nan when the code returns from this subroutine
755+
! before assigning values to these variables
756+
real(r8) , intent(inout) :: temp1 ( lbn: ) ! relation for potential temperature profile [lbn:ubn]
757+
real(r8) , intent(inout) :: temp12m ( lbn: ) ! relation for potential temperature profile applied at 2-m [lbn:ubn]
758+
real(r8) , intent(inout) :: temp2 ( lbn: ) ! relation for specific humidity profile [lbn:ubn]
759+
real(r8) , intent(inout) :: temp22m ( lbn: ) ! relation for specific humidity profile applied at 2-m [lbn:ubn]
757760
real(r8) , intent(inout) :: fm ( lbn: ) ! diagnose 10m wind (DUST only) [lbn:ubn]
758761
logical , intent(in), optional :: landunit_index ! optional argument that defines landunit or pft level
759762
!

src/biogeophys/PhotosynthesisMod.F90

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,10 @@ subroutine hybrid(x0, p, iv, c, gb_mol, je, cair, oair, lmr_z, par_z,&
22662266
real(r8), intent(in) :: cair ! Atmospheric CO2 partial pressure (Pa)
22672267
real(r8), intent(in) :: oair ! Atmospheric O2 partial pressure (Pa)
22682268
integer, intent(in) :: p, iv, c ! pft, c3/c4, and column index
2269-
real(r8), intent(out) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
2269+
! gs_mol is "inout" rather than "out" to
2270+
! prevent returning nan when the code returns from this subroutine
2271+
! before assigning a value to this variable
2272+
real(r8), intent(inout) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
22702273
integer, intent(out) :: iter !number of iterations used, for record only
22712274
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
22722275
type(photosyns_type), intent(inout) :: photosyns_inst
@@ -2378,7 +2381,10 @@ subroutine brent(x, x1,x2,f1, f2, tol, ip, iv, ic, gb_mol, je, cair, oair,&
23782381
real(r8), intent(in) :: oair ! Atmospheric O2 partial pressure (Pa)
23792382
real(r8), intent(in) :: rh_can ! inside canopy relative humidity
23802383
integer, intent(in) :: ip, iv, ic ! pft, c3/c4, and column index
2381-
real(r8), intent(out) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
2384+
! gs_mol is "inout" rather than "out" to
2385+
! prevent returning nan when the code returns from this subroutine
2386+
! before assigning a value to this variable
2387+
real(r8), intent(inout) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
23822388
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
23832389
type(photosyns_type), intent(inout) :: photosyns_inst
23842390
!
@@ -2568,7 +2574,10 @@ subroutine ci_func(ci, fval, p, iv, c, gb_mol, je, cair, oair, lmr_z, par_z,&
25682574
real(r8) , intent(in) :: rh_can ! canopy air realtive humidity
25692575
integer , intent(in) :: p, iv, c ! pft, vegetation type and column indexes
25702576
real(r8) , intent(out) :: fval ! return function of the value f(ci)
2571-
real(r8) , intent(out) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
2577+
! gs_mol is "inout" rather than "out" to
2578+
! prevent returning nan when the code returns from this subroutine
2579+
! before assigning a value to this variable
2580+
real(r8) , intent(inout) :: gs_mol ! leaf stomatal conductance (umol H2O/m**2/s)
25722581
type(atm2lnd_type) , intent(in) :: atm2lnd_inst
25732582
type(photosyns_type) , intent(inout) :: photosyns_inst
25742583
!
@@ -2706,7 +2715,6 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, &
27062715
use clm_varpar , only : nlevsoi
27072716
use pftconMod , only : nbrdlf_dcd_tmp_shrub, npcropmin
27082717
use ColumnType , only : col
2709-
use shr_infnan_mod , only : shr_infnan_isnan
27102718

27112719
!
27122720
! !ARGUMENTS:
@@ -2724,7 +2732,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, &
27242732
real(r8) , intent(in) :: leafn( bounds%begp: ) ! leaf N (gN/m2)
27252733
real(r8) , intent(out) :: bsun( bounds%begp: ) ! sunlit canopy transpiration wetness factor (0 to 1)
27262734
real(r8) , intent(out) :: bsha( bounds%begp: ) ! shaded canopy transpiration wetness factor (0 to 1)
2727-
real(r8) , intent(out) :: btran( bounds%begp: ) ! transpiration wetness factor (0 to 1) [pft]
2735+
real(r8) , intent(inout) :: btran( bounds%begp: ) ! transpiration wetness factor (0 to 1) [pft]
27282736
real(r8) , intent(in) :: froot_carbon( bounds%begp: ) ! fine root carbon (gC/m2) [pft]
27292737
real(r8) , intent(in) :: croot_carbon( bounds%begp: ) ! live coarse root carbon (gC/m2) [pft]
27302738

@@ -3477,6 +3485,7 @@ subroutine PhotosynthesisHydraulicStress ( bounds, fn, filterp, &
34773485
else
34783486
gsminsun = nan
34793487
gsminsha = nan
3488+
call endrun( 'ERROR:: Photosynthesis::PhotosynthesisHydraulicStress must choose stomatalcond_mtd method' )
34803489
end if
34813490
call calcstress(p,c,vegwp(p,:),bsun(p),bsha(p),gb_mol(p),gsminsun, gsminsha, &
34823491
qsatl(p),qaf(p), atm2lnd_inst,canopystate_inst,waterdiagnosticbulk_inst, &
@@ -4064,8 +4073,11 @@ subroutine brent_PHS(xsun, x1sun, x2sun, f1sun, f2sun, xsha, x1sha, x2sha, f1sha
40644073
real(r8), intent(in) :: lmr_z_sun, lmr_z_sha ! canopy layer: leaf maintenance respiration rate (umol CO2/m**2/s)
40654074
real(r8), intent(in) :: par_z_sun, par_z_sha ! par absorbed per unit lai for canopy layer (w/m**2)
40664075
real(r8), intent(in) :: rh_can ! inside canopy relative humidity
4067-
real(r8), intent(out) :: gs_mol_sun ! sunlit leaf stomatal conductance (umol H2O/m**2/s)
4068-
real(r8), intent(out) :: gs_mol_sha ! shaded leaf stomatal conductance (umol H2O/m**2/s)
4076+
! gs_mol_s* are "inout" rather than "out" to
4077+
! prevent returning nan when the code returns from this subroutine
4078+
! before assigning values to these variables
4079+
real(r8), intent(inout) :: gs_mol_sun ! sunlit leaf stomatal conductance (umol H2O/m**2/s)
4080+
real(r8), intent(inout) :: gs_mol_sha ! shaded leaf stomatal conductance (umol H2O/m**2/s)
40694081
real(r8), intent(inout) :: bsun ! sunlit canopy transpiration wetness factor (0 to 1)
40704082
real(r8), intent(inout) :: bsha ! shaded canopy transpiration wetness factor (0 to 1)
40714083
real(r8), intent(in) :: qsatl ! leaf specific humidity [kg/kg]
@@ -4344,6 +4356,7 @@ subroutine ci_func_PHS(x,cisun, cisha, fvalsun, fvalsha, p, iv, c, bsun, bsha, b
43444356
gs_mol_sun = bbb(p)
43454357
else
43464358
gs_mol_sun = nan
4359+
call endrun( 'ERROR:: Photosynthesis::ci_func_PHS must choose stomatalcond_mtd method' )
43474360
end if
43484361
gs_mol_sun = max( bsun*gs_mol_sun, 1._r8)
43494362
fvalsun = 0._r8 ! really tho? zqz
@@ -4355,6 +4368,7 @@ subroutine ci_func_PHS(x,cisun, cisha, fvalsun, fvalsha, p, iv, c, bsun, bsha, b
43554368
gs_mol_sha = bbb(p)
43564369
else
43574370
gs_mol_sha = nan
4371+
call endrun( 'ERROR:: Photosynthesis::ci_func_PHS must choose stomatalcond_mtd method' )
43584372
end if
43594373
gs_mol_sha = max( bsha*gs_mol_sha, 1._r8)
43604374
fvalsha = 0._r8

src/main/clm_initializeMod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ subroutine initialize2(ni,nj)
340340
end if
341341

342342
! Pass model timestep info to FATES
343-
call CLMFatesTimesteps()
343+
if (use_fates) call CLMFatesTimesteps()
344344

345345
! Initialize daylength from the previous time step (needed so prev_dayl can be set correctly)
346346
call t_startf('init_orbd')

src/main/surfrdUtilsMod.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ subroutine check_sums_equal_1(arr, lb, name, caller, ier, sumto)
4545
character(len=*), intent(in) :: name ! name of array
4646
character(len=*), intent(in) :: caller ! identifier of caller, for more meaningful error messages
4747
integer, optional, intent(out):: ier ! Return an error code rather than abort
48-
real(r8), optional, intent(out):: sumto(lb:) ! The value the array should sum to (1.0 if not provided)
48+
real(r8), optional, intent(in):: sumto(lb:) ! The value the array should sum to (1.0 if not provided)
4949
!
5050
! !LOCAL VARIABLES:
5151
logical :: found
@@ -63,7 +63,7 @@ subroutine check_sums_equal_1(arr, lb, name, caller, ier, sumto)
6363
if( present(ier) ) ier = 0
6464
found = .false.
6565

66-
do nl = lbound(arr, 1), ub
66+
do nl = lb, ub
6767
if (abs(sum(arr(nl,:)) - TotalSum(nl)) > eps) then
6868
found = .true.
6969
nindx = nl

0 commit comments

Comments
 (0)