From 8bcf36938073b6541d6689fd0a3c2b6d317882e7 Mon Sep 17 00:00:00 2001 From: wknoben Date: Mon, 14 Sep 2020 19:22:15 -0600 Subject: [PATCH 1/3] Updated read_force.f90 to correctly report netcdf reading error The error message in ``` ! read forcing data for all HRUs if(simultaneousRead)then err=nf90_get_var(ncid,forcFileInfo(iFile)%data_id(ivar),dataVec,start=(/ixHRUfile_min,iRead/),count=(/nHRUlocal,1/)) if(err/=nf90_noerr)then; message=trim(message)//'problem reading forcing data: '//trim(varname)//'/'//trim(nf90_strerror(err)); return; endif endif ``` needs variable `varName`. This variable is undefined in the current code and thus this error message attempts to print an undefined string. This fix gets the varName before the reading error can occur and this ensures a readable error message. --- build/source/engine/read_force.f90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/source/engine/read_force.f90 b/build/source/engine/read_force.f90 index 1296b01d3..bf3435a60 100755 --- a/build/source/engine/read_force.f90 +++ b/build/source/engine/read_force.f90 @@ -486,6 +486,10 @@ subroutine readForcingData(currentJulday,ncId,iFile,iRead,nHRUlocal,time_data,fo ! get index in forcing structure iVar = forcFileInfo(iFile)%var_ix(iNC) checkForce(iVar) = .true. + + ! get variable name for error reporting + err=nf90_inquire_variable(ncid,iNC,name=varName) + if(err/=nf90_noerr)then; message=trim(message)//'problem reading forcing variable name from netCDF: '//trim(nf90_strerror(err)); return; endif ! read forcing data for all HRUs if(simultaneousRead)then From 40dd335f3d0701d721e249efe2a7fa39089ff370 Mon Sep 17 00:00:00 2001 From: Martyn Clark Date: Wed, 16 Sep 2020 14:23:18 -0600 Subject: [PATCH 2/3] avoid very small stability values --- build/source/engine/vegNrgFlux.f90 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/source/engine/vegNrgFlux.f90 b/build/source/engine/vegNrgFlux.f90 index e6eb0de86..47bfba9a9 100755 --- a/build/source/engine/vegNrgFlux.f90 +++ b/build/source/engine/vegNrgFlux.f90 @@ -3140,6 +3140,7 @@ subroutine aStability(& integer(i4b),intent(out) :: err ! error code character(*),intent(out) :: message ! error message ! local + real(dp), parameter :: verySmall=1.e-10_dp ! a very small number (avoid stability of zero) real(dp) :: dRiBulk_dAirTemp ! derivative in the bulk Richardson number w.r.t. air temperature (K-1) real(dp) :: dRiBulk_dSfcTemp ! derivative in the bulk Richardson number w.r.t. surface temperature (K-1) real(dp) :: bPrime ! scaled "b" parameter for stability calculations in Louis (1979) @@ -3188,11 +3189,11 @@ subroutine aStability(& case(standard) ! compute surface-atmosphere exchange coefficient (-) if(RiBulk < critRichNumber) stabilityCorrection = (1._dp - 5._dp*RiBulk)**2._dp - if(RiBulk >= critRichNumber) stabilityCorrection = epsilon(stabilityCorrection) + if(RiBulk >= critRichNumber) stabilityCorrection = verySmall ! compute derivative in surface-atmosphere exchange coefficient w.r.t. temperature (K-1) if(computeDerivative)then if(RiBulk < critRichNumber) dStabilityCorrection_dRich = (-5._dp) * 2._dp*(1._dp - 5._dp*RiBulk) - if(RiBulk >= critRichNumber) dStabilityCorrection_dRich = 0._dp + if(RiBulk >= critRichNumber) dStabilityCorrection_dRich = verySmall end if ! (Louis 1979) From 4057d855b19bb1f340775da7a468d971b1282204 Mon Sep 17 00:00:00 2001 From: Martyn Clark Date: Wed, 16 Sep 2020 17:11:32 -0600 Subject: [PATCH 3/3] output the choice of soil and veg tables as global attributes --- build/source/engine/mDecisions.f90 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/source/engine/mDecisions.f90 b/build/source/engine/mDecisions.f90 index eaabef181..684250027 100755 --- a/build/source/engine/mDecisions.f90 +++ b/build/source/engine/mDecisions.f90 @@ -299,6 +299,11 @@ subroutine mDecisions(err,message) OPT_RAD=3 ! option for canopy radiation OPT_ALB=2 ! option for snow albedo + ! set zero option for thee category tables + ! NOTE: we want to keep track of these decisions, but not used in the physics routines + model_decisions(iLookDECISIONS%soilCatTbl)%iDecision = 0 + model_decisions(iLookDECISIONS%vegeParTbl)%iDecision = 0 + ! identify the choice of function for the soil moisture control on stomatal resistance select case(trim(model_decisions(iLookDECISIONS%soilStress)%cDecision)) case('NoahType'); model_decisions(iLookDECISIONS%soilStress)%iDecision = NoahType ! thresholded linear function of volumetric liquid water content