diff --git a/.github/common/install-python-std.sh b/.github/common/install-python-std.sh new file mode 100755 index 00000000..ca916ab3 --- /dev/null +++ b/.github/common/install-python-std.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +pip install wheel +pip install meson ninja diff --git a/.github/common/prms_build_check.py b/.github/common/prms_build_check.py new file mode 100644 index 00000000..2fdb1337 --- /dev/null +++ b/.github/common/prms_build_check.py @@ -0,0 +1,12 @@ +import os +import sys + +exe_name = "prms" +if sys.platform == "win32": + exe_name += ".exe" +fpth = os.path.join("..", "..", "bin", exe_name) + +assert os.path.isfile(fpth), f"{fpth} does not exist" +assert os.access(fpth, os.X_OK), f"{fpth} is not executable" + +print(f"\nprms executable has been build.\n\tand is located at...'{fpth}'\n") diff --git a/.github/intel-scripts/README.md b/.github/intel-scripts/README.md new file mode 100644 index 00000000..e78bd4be --- /dev/null +++ b/.github/intel-scripts/README.md @@ -0,0 +1,17 @@ +These scripts install the ifort compiler on the CI machines. + +The content has been directly copied from the Intel OneAPI-CI examples, found +here: + +https://github.com/oneapi-src/oneapi-ci + +Note that on Linux and macOS, shell scripts must be marked as executable: not +doing so for these scripts will result in a permission error during the GitHub +Action. Windows does not have such a permission system, but you can mark a +script nonetheless with git: + +``` +git update-index --chmod=+x {name_of_script} +``` + +Then commit and push. diff --git a/.github/intel-scripts/cache_exclude_linux.sh b/.github/intel-scripts/cache_exclude_linux.sh new file mode 100755 index 00000000..0e835d28 --- /dev/null +++ b/.github/intel-scripts/cache_exclude_linux.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +#shellcheck disable=SC2010 +LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) + +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/compiler/lib/ia32_lin +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/bin/ia32 +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/emu +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/oclfpga \ No newline at end of file diff --git a/.github/intel-scripts/cache_exclude_windows.sh b/.github/intel-scripts/cache_exclude_windows.sh new file mode 100644 index 00000000..f396a94a --- /dev/null +++ b/.github/intel-scripts/cache_exclude_windows.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +#shellcheck disable=SC2010 +LATEST_VERSION=$(ls -1 "C:\Program Files (x86)\Intel\oneAPI\compiler" | grep -v latest | sort | tail -1) + +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\compiler\lib\ia32_win" +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\bin\intel64_ia32" +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\emu" +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\oclfpga" +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\ocloc" +rm -rf "C:\Program Files (x86)\Intel\oneAPI\compiler\'$LATEST_VERSION'\windows\lib\x86" \ No newline at end of file diff --git a/.github/intel-scripts/ifortvars_windows.bat b/.github/intel-scripts/ifortvars_windows.bat new file mode 100644 index 00000000..93618bbe --- /dev/null +++ b/.github/intel-scripts/ifortvars_windows.bat @@ -0,0 +1,17 @@ +REM SPDX-FileCopyrightText: 2020 Intel Corporation +REM +REM SPDX-License-Identifier: MIT + +set LANGUAGE=%1 +set VS_VER=%2 + +IF "%VS_VER%"=="2017_build_tools" ( +@call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" +) + +IF "%VS_VER%"=="2019_build_tools" ( +@call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat" +) + +for /f "tokens=* usebackq" %%f in (`dir /b "C:\Program Files (x86)\Intel\oneAPI\compiler\" ^| findstr /V latest ^| sort`) do @set "LATEST_VERSION=%%f" +@call "C:\Program Files (x86)\Intel\oneAPI\compiler\%LATEST_VERSION%\env\vars.bat" diff --git a/.github/intel-scripts/install_linux.sh b/.github/intel-scripts/install_linux.sh new file mode 100755 index 00000000..52794472 --- /dev/null +++ b/.github/intel-scripts/install_linux.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +URL=$1 +COMPONENTS=$2 + +curl --output webimage.sh --url "$URL" --retry 5 --retry-delay 5 +chmod +x webimage.sh +./webimage.sh -x -f webimage_extracted --log extract.log +rm -rf webimage.sh +WEBIMAGE_NAME=$(ls -1 webimage_extracted/) +if [ -z "$COMPONENTS" ]; then + sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --log-dir=. + installer_exit_code=$? +else + sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=. + installer_exit_code=$? +fi +rm -rf webimage_extracted +exit $installer_exit_code \ No newline at end of file diff --git a/.github/intel-scripts/install_macos.sh b/.github/intel-scripts/install_macos.sh new file mode 100755 index 00000000..729080ef --- /dev/null +++ b/.github/intel-scripts/install_macos.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +URL=$1 +COMPONENTS=$2 + +curl --output webimage.dmg --url "$URL" --retry 5 --retry-delay 5 +hdiutil attach webimage.dmg +if [ -z "$COMPONENTS" ]; then + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. + installer_exit_code=$? +else + sudo /Volumes/"$(basename "$URL" .dmg)"/bootstrapper.app/Contents/MacOS/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --log-dir=. + installer_exit_code=$? +fi +hdiutil detach /Volumes/"$(basename "$URL" .dmg)" -quiet +exit $installer_exit_code \ No newline at end of file diff --git a/.github/intel-scripts/install_windows.bat b/.github/intel-scripts/install_windows.bat new file mode 100644 index 00000000..d3e0a1d8 --- /dev/null +++ b/.github/intel-scripts/install_windows.bat @@ -0,0 +1,15 @@ +REM SPDX-FileCopyrightText: 2020 Intel Corporation +REM +REM SPDX-License-Identifier: MIT + +set URL=%1 +set COMPONENTS=%2 + +curl.exe --output webimage.exe --url %URL% --retry 5 --retry-delay 5 +start /b /wait webimage.exe -s -x -f webimage_extracted --log extract.log +del webimage.exe +if "%COMPONENTS%"=="" ( + webimage_extracted\bootstrapper.exe -s --action install --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 --log-dir=. +) else ( + webimage_extracted\bootstrapper.exe -s --action install --components=%COMPONENTS% --eula=accept -p=NEED_VS2017_INTEGRATION=0 -p=NEED_VS2019_INTEGRATION=0 --log-dir=. +) \ No newline at end of file diff --git a/.github/workflows/ci-tests-gfortran-latest.yml b/.github/workflows/ci-tests-gfortran-latest.yml new file mode 100644 index 00000000..dbbb3722 --- /dev/null +++ b/.github/workflows/ci-tests-gfortran-latest.yml @@ -0,0 +1,72 @@ +name: ci - gfortran - latest version + +on: + push: + branches: + - '5.3*' + pull_request: + branches: + - '5.3*' + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Setup Python + uses: actions/setup-python@v2.3.1 + with: + python-version: 3.9 + + - name: Setup symbolic links on Linux + if: runner.os == 'Linux' + run: | + sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran + sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc + sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ + + - name: Setup symbolic link to gfortran on macOS + if: runner.os == 'macOS' + shell: bash + run: | + sudo ln -fs /usr/local/bin/gfortran-10 /usr/local/bin/gfortran + sudo ln -fs /usr/local/bin/gcc-10 /usr/local/bin/gcc + sudo ln -fs /usr/local/bin/g++-10 /usr/local/bin/g++ + + - name: Print GNU compiler versions + run: | + gfortran --version + gcc --version + g++ --version + + - name: Install python packages + run: | + .github/common/install-python-std.sh + + - name: Build and Install (Linux or macOS) + if: runner.os == 'Linux' || runner.os == 'macOS' + run: | + meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin + meson install -C builddir + + - name: Build and Install (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + meson setup builddir -Ddebug=false --prefix=%CD% --libdir=bin + meson install -C builddir + + - name: Test for build success + working-directory: ./.github/common + run: | + python prms_build_check.py diff --git a/.github/workflows/ci-tests-ifort.yml b/.github/workflows/ci-tests-ifort.yml new file mode 100644 index 00000000..993529e5 --- /dev/null +++ b/.github/workflows/ci-tests-ifort.yml @@ -0,0 +1,124 @@ +# Parts of configuration file are based on the examples in this repository: +# https://github.com/oneapi-src/oneapi-ci +# +# Which have the following copyright: +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +name: ci - ifort + +on: + push: + branches: + - '5.3*' + pull_request: + branches: + - '5.3*' + +env: + WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18417/w_HPCKit_p_2022.1.0.93_offline.exe + LINUX_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18438/l_HPCKit_p_2022.1.1.97_offline.sh + MACOS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/18341/m_HPCKit_p_2022.1.0.86_offline.dmg + WINDOWS_FORTRAN_COMPONENTS: intel.oneapi.win.ifort-compiler + LINUX_FORTRAN_COMPONENTS_WEB: intel.oneapi.lin.ifort-compiler + MACOS_FORTRAN_COMPONENTS: intel.oneapi.mac.ifort-compiler + FC: ifort + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + - os: macos-latest + - os: windows-2019 + defaults: + run: + shell: bash + + steps: + - name: Checkout repo + uses: actions/checkout@v2.3.4 + + - name: Setup Python + uses: actions/setup-python@v2.3.1 + with: + python-version: 3.9 + + - name: cache install ifort on linux + if: runner.os == 'Linux' + id: cache-install-linux + uses: actions/cache@v2 + with: + path: | + /opt/intel/oneapi + key: install-${{ env.LINUX_HPCKIT_URL }}-${{ env.LINUX_FORTRAN_COMPONENTS_WEB }}-compiler-${{ hashFiles('**/.github/intel-scripts/cache_exclude_linux.sh') }} + + - name: install ifort on linux + if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true' + run: | + .github/intel-scripts/install_linux.sh $LINUX_HPCKIT_URL $LINUX_FORTRAN_COMPONENTS_WEB + + - name: cache install ifort on macos + if: runner.os == 'macOS' + id: cache-install-macos + uses: actions/cache@v2 + with: + path: /opt/intel/oneapi + key: install-${{ env.MACOS_HPCKIT_URL }}-${{ env.MACOS_FORTRAN_COMPONENTS }} + + - name: install ifort on macos + if: runner.os == 'macOS' && steps.cache-install-macos.outputs.cache-hit != 'true' + run: | + .github/intel-scripts/install_macos.sh $MACOS_HPCKIT_URL $MACOS_FORTRAN_COMPONENTS + + - name: cache install ifort on windows + if: runner.os == 'Windows' + id: cache-install-windows + uses: actions/cache@v2 + with: + path: C:\Program Files (x86)\Intel\oneAPI + key: install-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_FORTRAN_COMPONENTS }}-compiler-${{ hashFiles('**/.github/intel-scripts/cache_exclude_windows.sh') }} + + - name: install ifort on windows + if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true' + run: | + .github/intel-scripts/install_windows.bat $WINDOWS_HPCKIT_URL $WINDOWS_FORTRAN_COMPONENTS + + - name: Install python packages + run: | + .github/common/install-python-std.sh + + - name: Build prms (Linux or macOS) + if: runner.os == 'Linux' || runner.os == 'macOS' + run: | + source /opt/intel/oneapi/setvars.sh + meson setup builddir -Ddebug=false --prefix=$(pwd) --libdir=bin + meson install -C builddir + + - name: Build prms (Windows) + if: runner.os == 'Windows' + shell: cmd + run: | + call ".github/intel-scripts/ifortvars_windows.bat" + meson setup builddir -Ddebug=false --prefix=%CD% --libdir=bin + meson install -C builddir + + - name: Test for build success + working-directory: ./.github/common + run: | + python prms_build_check.py + + - name: exclude unused files from cache on linux + if: runner.os == 'Linux' && steps.cache-install-linux.outputs.cache-hit != 'true' + run: | + .github/intel-scripts/cache_exclude_linux.sh + + - name: exclude unused files from cache on windows + if: runner.os == 'Windows' && steps.cache-install-windows.outputs.cache-hit != 'true' + shell: bash + run: | + .github/intel-scripts/cache_exclude_windows.sh diff --git a/.gitignore b/.gitignore index 2fa838c3..252ab1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,13 @@ *.mod *.a prms/prms + +# meson temporary files +builddir/ + +# built executables +bin/prms +bin/prms.exe + +# pycharm +.idea/ diff --git a/bin/readme.txt b/bin/readme.txt new file mode 100644 index 00000000..667e1860 --- /dev/null +++ b/bin/readme.txt @@ -0,0 +1,2 @@ +bin directory for built prms executable + diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..d159dbf4 --- /dev/null +++ b/meson.build @@ -0,0 +1,86 @@ +project( + 'PRMS', + 'fortran', + version: '5.3.0', + meson_version: '>= 0.59.0', + default_options : [ + 'b_vscrt=static_from_buildtype', # Link runtime libraries statically on Windows + 'optimization=2', + 'fortran_std=f2008', +]) + +if get_option('optimization') == '3' + error('Only optimization levels <= 2 are supported') +endif + +if get_option('optimization') == '2' + profile = 'release' +else + profile = 'develop' +endif + +message('The used profile is:', profile) + + +fc = meson.get_compiler('fortran') +fc_id = fc.get_id() +compile_args = [] +link_args = [] + +# Command line options for gfortran +if fc_id == 'gcc' + # General options + compile_args += ['-pedantic', + '-fall-intrinsics', + '-Wcharacter-truncation', + '-Wno-unused-dummy-argument', # This makes problems with OOP + '-Wno-intrinsic-shadow', # We shadow intrinsics with methods, which should be fine + '-Wno-maybe-uninitialized', # "Uninitialized" flags produce false positives with allocatables + '-Wno-uninitialized', + ] + + # Options specific to profile + if profile == 'release' + compile_args += ['-ffpe-summary=overflow', '-ffpe-trap=overflow,zero,invalid'] + elif profile == 'develop' + compile_args += ['-fcheck=all', '-ffpe-trap=overflow,zero,invalid,denormal'] + endif + + # Define OS with gfortran for OS specific code + # These are identical to pre-defined macros available with ifort + system = build_machine.system() + if system == 'linux' + compile_args += '-D__linux__' + elif system == 'darwin' + compile_args += '-D__APPLE__' + elif system == 'windows' + compile_args += '-D_WIN32' + endif +endif + +# Command line options for ifort +if fc_id == 'intel-cl' + # windows + compile_args += ['/fpe:0', # Activate all floating point exceptions + '/fpp', # Activate preprocessing + '/Qdiag-disable:7416', # f2008 warning + '/Qdiag-disable:7025', # f2008 warning + '/Qdiag-disable:5268', # Line too long + ] + link_args += ['/ignore:4217', # access through ddlimport might be inefficient + '/ignore:4286' # same as 4217, but more general + ] +elif fc_id == 'intel' + # linux and macOS + compile_args += ['-fpe0', # Activate all floating point exceptions + '-diag-disable:7416', # f2008 warning + '-diag-disable:7025', # f2008 warning + '-diag-disable:5268', # Line too long + ] + link_args += '-static-intel' +endif + +add_project_arguments(fc.get_supported_arguments(compile_args), language: 'fortran') +add_project_link_arguments(fc.get_supported_arguments(link_args), language: 'fortran') + +subdir('prms') diff --git a/prms/intcp.f90 b/prms/intcp.f90 index 8757bcf0..53a38a87 100644 --- a/prms/intcp.f90 +++ b/prms/intcp.f90 @@ -237,7 +237,9 @@ INTEGER FUNCTION intinit() Gain_inches = 0.0 Gain_inches_hru = 0.0 ELSE - Irr_type = 0 + IF (ALLOCATED(Irr_type)) then + Irr_type = 0 + END IF ENDIF Net_apply = 0.0 diff --git a/prms/meson.build b/prms/meson.build new file mode 100644 index 00000000..324abf2b --- /dev/null +++ b/prms/meson.build @@ -0,0 +1,74 @@ +prms_sources = files( + 'c_utils_prms.f90', + 'prms_constants.f90', + 'c_read_parameter_file.f90', + 'prms_module.f90', + 'setup_param.f90', + 'c_prms_time.f90', + 'sm_mmf_utils.f90', + 'convert_params.f90', + 'c_mmf_utils.f90', + 'c_read_control_file.f90', + 'c_read_data_file.f90', + 'call_modules.f90', + 'sm_read_parameter_file.f90', + 'obs.f90', + 'basin.f90', + 'water_use_read.f90', + 'nhru_summary.f90', + 'basin_summary.f90', + 'sm_prms_time.f90', + 'nsegment_summary.f90', + 'cascade.f90', + 'nsub_summary.f90', + 'map_results.f90', + 'soltab.f90', + 'sm_utils_prms.f90', + 'climateflow.f90', + 'potet_hamon.f90', + 'temp_1sta_laps.f90', + 'ide_dist.f', + 'potet_hs.f90', + 'temp_dist2.f90', + 'intcp.f90', + 'potet_jh.f90', + 'temp_map.f90', + 'xyz_dist.f', + 'potet_pan.f90', + 'transp_frost.f90', + 'transp_tindex.f90', + 'climate_hru.f90', + 'srunoff.f90', + 'potet_pm_sta.f90', + 'statvar_out.f90', + 'potet_pt.f90', + 'write_climate_hru.f90', + 'precip_1sta_laps.f90', + 'ddsolrad.f90', + 'precip_dist2.f90', + 'frost_date.f90', + 'sm_read_data_file.f90', + 'precip_map.f90', + 'gwflow.f90', + 'strmflow.f90', + 'ccsolrad.f90', + 'snowcomp.f90', + 'soilzone.f90', + 'prms_summary.f90', + 'soilzone_ag.f90', + 'potet_pm.f90', + 'glacr_melt.f90', + 'dynamic_param_read.f90', + 'routing.f90', + 'muskingum.f90', + 'stream_temp.f90', + 'muskingum_lake.f90', + 'sm_read_control_file.f90', + 'subbasin.f90', + 'basin_sum.f90', + 'water_balance.f90', + 'strmflow_in_out.f90', + 'prms_fortran.f90' +) + +executable('prms', [prms_sources], install: true) diff --git a/prms/obs.f90 b/prms/obs.f90 index 50db153f..37ae3315 100644 --- a/prms/obs.f90 +++ b/prms/obs.f90 @@ -59,7 +59,8 @@ INTEGER FUNCTION obssetdims() & 'Maximum number of lake elevations for any rating table data set')/=0 ) CALL read_error(7, 'nlakeelev') IF ( decldim('nwind', 0, MAXDIM, 'Number of wind-speed measurement stations')/=0 ) CALL read_error(7, 'nwind') IF ( decldim('nhumid', 0, MAXDIM, 'Number of relative humidity measurement stations')/=0 ) CALL read_error(7, 'nhumid') - IF ( decldim('nstream_temp', 0, MAXDIM, 'Number of stream temperature replacement segments')/=0 ) CALL read_error(7, 'nstream_temp') + IF ( decldim('nstream_temp', 0, MAXDIM, 'Number of stream temperature replacement segments')/=0 ) & + CALL read_error(7, 'nstream_temp') END FUNCTION obssetdims diff --git a/prms/snowcomp.f90 b/prms/snowcomp.f90 index 5a3983a1..13cc0b73 100644 --- a/prms/snowcomp.f90 +++ b/prms/snowcomp.f90 @@ -1,4 +1,4 @@ -!*********************************************************************** +!*********************************************************************** ! Initiates development of a snowpack and simulates snow accumulation ! and depletion processes using an energy-budget approach ! @@ -1112,7 +1112,7 @@ INTEGER FUNCTION snorun() ! Could use equation from Swinbank 63 using Temp, a is -13.638, b is 6.148 ! temparature is halfway between the minimum and average temperature for the day !temp = (Tminc(i)+Tavgc(i))*0.5 - !emis = ((temp+273.16)**(Emis_coefb-4.0))*(10.0**(Emis_coefa+1.0))/5.670373E−8 ! /by Stefan Boltzmann in SI units + !emis = ((temp+273.16)**(Emis_coefb-4.0))*(10.0**(Emis_coefa+1.0))/5.670373E-8 ! /by Stefan Boltzmann in SI units ! If there is any precipitation in the HRU, reset the ! emissivity to 1 IF ( Hru_ppt(i)>0.0 ) emis = 1.0 ! [fraction of radiation] @@ -1865,7 +1865,7 @@ SUBROUTINE calin(Cal, Pkwater_equiv, Pk_def, Pk_temp, & IF ( Active_glacier>OFF ) THEN IF ( pmlt>apk_ice ) THEN !fractionate density with snow/active layer melting vs extra ice underneath melting - Pk_den = Pk_den*SNGL(apk_ice/pmlt) + 0.917*SNGL((pmlt-apk_ice)/pmlt) + Pk_den = Pk_den*(apk_ice/pmlt) + 0.917*((pmlt-apk_ice)/pmlt) apk_ice = pmlt Pk_ice = apmlt Pkwater_equiv = apmlt diff --git a/prms/soilzone.f90 b/prms/soilzone.f90 index 6e94c478..792ee410 100644 --- a/prms/soilzone.f90 +++ b/prms/soilzone.f90 @@ -580,7 +580,8 @@ INTEGER FUNCTION szinit() IF ( Soil_lower_stor_max(i)>0.0 ) Soil_lower_ratio(i) = Soil_lower(i)/Soil_lower_stor_max(i) IF ( Soil_zone_max(i) > 0.0 ) Basin_sz_stor_frac = Basin_sz_stor_frac + DBLE( Soil_moist_tot(i)/Soil_zone_max(i)*hruarea ) !RGN added to avoid divide by zero 1/20/2022 Basin_soil_lower_stor_frac = Basin_soil_lower_stor_frac + DBLE( Soil_lower_ratio(i)*perv_area ) - IF ( Soil_rechr_max(i)>0.0 ) Basin_soil_rechr_stor_frac = Basin_soil_rechr_stor_frac + DBLE( Soil_rechr(i)/Soil_rechr_max(i)*perv_area ) + IF ( Soil_rechr_max(i)>0.0 ) Basin_soil_rechr_stor_frac = Basin_soil_rechr_stor_frac + & + DBLE( Soil_rechr(i)/Soil_rechr_max(i)*perv_area ) Basin_soil_moist = Basin_soil_moist + DBLE( Soil_moist(i)*perv_area ) Basin_soil_moist_tot = Basin_soil_moist_tot + DBLE( Soil_moist_tot(i)*hruarea ) Basin_soil_rechr = Basin_soil_rechr + DBLE( Soil_rechr(i)*perv_area ) @@ -1007,7 +1008,8 @@ INTEGER FUNCTION szrun() IF ( Soil_zone_max(i) > 0.0 ) Basin_sz_stor_frac = Basin_sz_stor_frac + DBLE( Soil_moist_tot(i)/Soil_zone_max(i)*harea ) !RGN added to avoid divide by zero. 1/20/2022 Basin_sz_stor_frac = Basin_sz_stor_frac + DBLE( Soil_moist_tot(i)/Soil_zone_max(i)*harea ) Basin_soil_lower_stor_frac = Basin_soil_lower_stor_frac + DBLE( Soil_lower_ratio(i)*perv_area ) - IF ( Soil_rechr_max(i)>0.0 ) Basin_soil_rechr_stor_frac = Basin_soil_rechr_stor_frac + DBLE( Soil_rechr(i)/Soil_rechr_max(i)*perv_area ) + IF ( Soil_rechr_max(i)>0.0 ) Basin_soil_rechr_stor_frac = Basin_soil_rechr_stor_frac + & + DBLE( Soil_rechr(i)/Soil_rechr_max(i)*perv_area ) Recharge(i) = Soil_to_gw(i) + Ssr_to_gw(i) IF ( Dprst_flag==1 ) Recharge(i) = Recharge(i) + SNGL( Dprst_seep_hru(i) ) Basin_recharge = Basin_recharge + DBLE( Recharge(i)*harea ) diff --git a/prms/soltab.f90 b/prms/soltab.f90 index dc97768b..f5251055 100644 --- a/prms/soltab.f90 +++ b/prms/soltab.f90 @@ -1,4 +1,4 @@ -!*********************************************************************** +!*********************************************************************** ! Compute potential solar radiation and sunlight hours for each HRU for ! each day of year; modification of soltab_prms ! @@ -6,9 +6,9 @@ ! Swift, L.W., Jr., 1976, Algorithm for solar radiation on mountain ! slopes: Water Resources Research, v. 12, no. 1, p. 108-112. ! -! Lee, R., 1963, Evaluation of solar beam irradiation as a climatic parameter -! of mountain watersheds, Colorado State University Hydrology Papers, 2, -! 50 pp. +! Lee, R., 1963, Evaluation of solar beam irradiation as a climatic +! parameter of mountain watersheds, Colorado State University +! Hydrology Papers, 2, 50 pp. !*********************************************************************** MODULE PRMS_SOLTAB USE PRMS_CONSTANTS, ONLY: DAYS_IN_YEAR, MAX_DAYS_PER_YEAR diff --git a/prms/stream_temp.f90 b/prms/stream_temp.f90 index 26557db9..5da92b97 100644 --- a/prms/stream_temp.f90 +++ b/prms/stream_temp.f90 @@ -784,7 +784,7 @@ INTEGER FUNCTION stream_temp_run() ! On restart, sometimes soltab_potsw comes in as zero. It should never be zero as ! this results in divide by 0.0 if (Soltab_potsw(jday, j) <= 10.0) then - ccov = 1.0 - (Swrad(j) / sngl(10.0) * sngl(Hru_cossl(j))) + ccov = 1.0 - (Swrad(j) / 10.0 * sngl(Hru_cossl(j))) else ccov = 1.0 - (Swrad(j) / sngl(Soltab_potsw(jday, j)) * sngl(Hru_cossl(j))) endif