Skip to content

Commit

Permalink
fix: prevent negative values from entering calculation in 'calculate_…
Browse files Browse the repository at this point in the history
…fraction_exposed_and_wetted_soil_fc'
  • Loading branch information
smwesten-usgs committed Jan 29, 2024
1 parent 6a69fa1 commit 76f6dfb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
Empty file modified build/denali/gfortran/run_cmake_gfortran.sh
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ elif fc_id == 'intel'
# linux and macOS
compile_args += ['-fpe0', # Activate all floating point exceptions
'-fpp',
'-debug',
'-no-heap-arrays',
'-traceback',
'-diag-disable:7416', # f2008 warning
Expand Down
6 changes: 3 additions & 3 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# optimization_level 1: DEBUG; optimization_level 2: RELEASE
option('optimization_level', type : 'integer', min : 1, max : 2, value : 1)
option('optimization_level', type : 'integer', min : 1, max : 2, value : 2)

option('swb_major_version', type : 'string', value : '"2"', description : 'project major version number')
option('swb_minor_version', type : 'string', value : '"3"', description : 'project minor version number')
option('swb_patch_version', type : 'string', value : '"2"', description : 'project patch version number')
option('swb_version', type : 'string', value : 'v2.3.2-rc0', description : 'project version')
option('swb_patch_version', type : 'string', value : '"3"', description : 'project patch version number')
option('swb_version', type : 'string', value : 'v2.3.3-rc0', description : 'project version')
6 changes: 3 additions & 3 deletions src/actual_et__fao56__two_stage.F90
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ end function calculate_evaporation_reduction_coefficient_Kr
!> This function estimates the fraction of the ground covered by
!> vegetation during the growing season
!> @note Implemented as equation 76, FAO-56, Allen and others
elemental function calculate_fraction_exposed_and_wetted_soil_fc( landuse_index, Kcb, current_plant_height) result ( few )
impure elemental function calculate_fraction_exposed_and_wetted_soil_fc( landuse_index, Kcb, current_plant_height) result ( few )

! [ ARGUMENTS ]
integer (c_int), intent(in) :: landuse_index
Expand All @@ -180,9 +180,9 @@ elemental function calculate_fraction_exposed_and_wetted_soil_fc( landuse_index,
real (c_double) :: denominator
real (c_double) :: exponent

numerator = Kcb - KCB_l( KCB_MIN, landuse_index)
numerator = max(Kcb - KCB_l( KCB_MIN, landuse_index), 0.0_c_double)
denominator = KCB_l( KCB_MID, landuse_index) - KCB_l( KCB_MIN, landuse_index)
exponent = 1.0 + 0.5 * current_plant_height * M_PER_FOOT
exponent = 1.0_c_double + 0.5_c_double * current_plant_height * M_PER_FOOT

if( denominator > 0.0_c_double ) then
fc = ( numerator / denominator ) ** exponent
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ if system == 'windows'
]
else
dependencies = [
meson.get_compiler('cpp').find_library('netcdf')
meson.get_compiler('c').find_library('netcdf', dirs : ['/opt/cray/pe/netcdf/4.8.1.1/intel/19.1/lib'])
]
endif

Expand Down
2 changes: 2 additions & 0 deletions src/model_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,8 @@ subroutine model_dump_variables( this, unitnum, indx_start, indx_end )

enddo

flush(unit=unitnum)

end subroutine model_dump_variables

!--------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 76f6dfb

Please sign in to comment.