Skip to content

Commit

Permalink
Merge pull request #15 from crazyzlj/dev
Browse files Browse the repository at this point in the history
Update to 2012rev692
  • Loading branch information
crazyzlj authored Nov 29, 2023
2 parents db67f30 + d694937 commit 29c504b
Show file tree
Hide file tree
Showing 27 changed files with 169 additions and 144 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/deploy_images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Create and publish SWAT Docker images

# Configures this workflow to run every time a change is pushed to the branches.
on:
push:
branches:
- '**' # matches every branch

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
#
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion VERSIONS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION_MAJOR 2012
VERSION_MINOR 689
VERSION_MINOR 692
VERSION_PATCH
2 changes: 2 additions & 0 deletions src/allocate_parms.f
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ subroutine allocate_parms
do ihru = 1, mhru
allocate (ppet(ihru)%precip(ppet(ihru)%ndays))
allocate (ppet(ihru)%pet(ppet(ihru)%ndays))
ppet(ihru)%precip = 0.
ppet(ihru)%pet = 0.
end do

!! Srini 11_1_22
Expand Down
8 changes: 5 additions & 3 deletions src/alph.f
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ subroutine alph(iwave)
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!! SWAT: Expo, Atri
!! SWAT: Exp, Atri

!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

Expand Down Expand Up @@ -101,7 +101,8 @@ subroutine alph(iwave)
endif

ajp = 0.
ajp = 1. - Expo(-125. / (preceff + 5.))
xx = (-125. / (preceff + 5.))
ajp = 1. - Exp(xx)
if (ised_det == 0) then
al5 = Atri(ab, amp_r(i_mo,hru_sub(j)), ajp, rndseed(idg(6),j))
else
Expand Down Expand Up @@ -153,7 +154,8 @@ subroutine alph(iwave)
endif

ajp = 0.
ajp = 1. - Expo(-125. / (preceff + 5.))
xx = (-125. / (preceff + 5.))
ajp = 1. - Exp(xx)
if (ised_det == 0) then
al5 = Atri(ab, amp_r(i_mo,hru_sub(j)), ajp,
& rndseed(idg(6),j))
Expand Down
6 changes: 4 additions & 2 deletions src/command.f
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ subroutine command
case (0)
return
case (1)
call subbasin
call print_hyd
if (isub_sav == 0) then
call subbasin
call print_hyd
end if
case (2)
call route
if (dtp_onoff(inum1)==1) call bmp_det_pond !route detention pond J.Jeong feb 2010
Expand Down
5 changes: 3 additions & 2 deletions src/eiusle.f
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ subroutine eiusle

!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!! Intrinsic: Log, Log10
!! SWAT: Expo, Atri
!! SWAT: Exp, Atri

!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

Expand All @@ -63,7 +63,8 @@ subroutine eiusle

preceff = precipday !- snomlt - ovrlnd(j)
if (preceff > 1.e-4) then
ajp = 1. - Expo(-125. / preceff)
xx = (-125. / preceff)
ajp = 1. - Exp(xx)
xa = Atri(ab, amp_r(i_mo,hru_sub(j)), ajp, rndseed(idg(4),j))
xb = -2. * Log(1. - xa)
pkrf30 = 2. * preceff * xa
Expand Down
4 changes: 2 additions & 2 deletions src/etact.f
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ subroutine etact

!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!! Intrinsic: Exp, Min, Max
!! SWAT: Expo
!! SWAT: Exp

!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

Expand Down Expand Up @@ -263,7 +263,7 @@ subroutine etact
evzp = evz
if (sol_st(ly,j) < sol_fc(ly,j)) then
xx = 2.5 * (sol_st(ly,j) - sol_fc(ly,j)) / sol_fc(ly,j)
sev = sev * Expo(xx)
sev = sev * Exp(xx)
end if
sev = Min(sev, sol_st(ly,j) * etco)
Expand Down
35 changes: 0 additions & 35 deletions src/expo.f

This file was deleted.

3 changes: 2 additions & 1 deletion src/hruallo.f
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ subroutine hruallo
read (10,6000) titldum
end do

do kk = 1, 1000
!! do kk = 1, 1000
do kk = 1, 2000 !!!!!!! nbs 8/25/23
read (10,6300,iostat=eof) mgt_op, mgt1i
if (eof < 0) exit
if (mgt_op == 1) then
Expand Down
5 changes: 2 additions & 3 deletions src/main.f
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ program main

use parm
implicit none
!prog = "SWAT Dec 1 VER 2022/Merge Rev 663/Rev 687"
prog = "SWAT May 10 VER 2023/Rev 689"
prog = "SWAT Nov 14 VER 2023/Rev 692"
write (*,1000)
1000 format(1x," SWAT2022 ",/,
& " Rev. 688 ",/,
& " Rev. 692 ",/,
& " Soil & Water Assessment Tool ",/,
& " PC Version ",/,
& " Program reading from file.cio . . . executing",/)
Expand Down
10 changes: 3 additions & 7 deletions src/modparm.f
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module parm
integer :: curday_mon = 0 !! |current day into the monsoon period
integer :: ndays = 30 !! |number of days for precip/pet moving average
real :: trig = 0.5 !!mm/mm |precip/pet ratio to trigger plant/restart
real :: precip_sum !!mm |sum of precip during moving average period
real :: pet_sum !!mm |sum of pet during moving average period
real :: precip_sum = 0. !!mm |sum of precip during moving average period
real :: pet_sum = 0. !!mm |sum of pet during moving average period
real, dimension (:), allocatable :: precip !!mm |precip dimensioned by ndays
real, dimension (:), allocatable :: pet !!mm |pet dimensioned by ndays
real :: rto = 0 !! |sum of precip/sum of pet
Expand All @@ -26,6 +26,7 @@ module parm
real*8, dimension (:), allocatable :: tmp_win1, tmp_win2,
& tmp_sum1, tmp_sum2, tmp_spr1,
& tmp_spr2, tmp_fal1, tmp_fal2
integer :: isub_sav

real*8 :: wtmp
real*8, dimension (12) :: pcpmm
Expand Down Expand Up @@ -1037,11 +1038,6 @@ real*8 function ee(tk) result (r_ee)
real*8, intent (in) :: tk
end
function expo (xx) result (r_expo)
real*8 :: xx
real*8 :: r_expo
end function
real*8 Function fcgd(xx)
real*8, intent (in) :: xx
End function
Expand Down
8 changes: 5 additions & 3 deletions src/pgenhr.f
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subroutine pgenhr(jj)

!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!! Intrinsic: Log
!! SWAT: Atri, Expo
!! SWAT: Atri, Exp

!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

Expand All @@ -81,14 +81,16 @@ subroutine pgenhr(jj)
ab = 0.02083
ajp = 0.
al5 = 0.
ajp = 1. - Expo(-125. / (subp(jj) + 5.))
xx = (-125. / (subp(jj) + 5.))
ajp = 1. - Exp(xx)
al5 = Atri(ab, amp_r(i_mo,hru_sub(jj)), ajp, rndseed(10,jj))

!! need peak rainfall rate
!! calculate peak rate using same method as that for peak runoff
altc = 0.
pkrr = 0.
altc = 1. - Expo(2. * tconc(jj) * Log(1. - al5))
xx = (2. * tconc(jj) * Log(1. - al5))
altc = 1. - Exp(xx)
pkrr = altc * subp(jj) / tconc(jj) !! mm/h


Expand Down
8 changes: 5 additions & 3 deletions src/pkq.f
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ subroutine pkq(iwave)
!! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

!! ~ ~ ~ SUBROUTINES/FUNCTIONS CALLED ~ ~ ~
!! Intrinsic: Log, Expo
!! Intrinsic: Log, Exp

!! ~ ~ ~ ~ ~ ~ END SPECIFICATIONS ~ ~ ~ ~ ~ ~

Expand All @@ -56,12 +56,14 @@ subroutine pkq(iwave)

if (iwave > 0) then
!! subbasin sediment calculations
altc = 1. - Expo(2. * sub_tc(iwave) * Log(1. - al5))
xx = (2. * sub_tc(iwave) * Log(1. - al5))
altc = 1. - Exp(xx)
peakr = altc * (sub_qd(iwave) + sub_tran(iwave)) / sub_tc(iwave) !! mm/h
peakr = peakr * sub_km(iwave) / 3.6 !! m^3/s
else
!! HRU sediment calculations
altc = 1. - Expo(2. * tconc(j) * Log(1. - al5))
xx = (2. * tconc(j) * Log(1. - al5))
altc = 1. - Exp(xx)
peakr = altc * qday / tconc(j) !! mm/h
peakr = peakr * hru_km(j) / 3.6 !! m^3/s
end if
Expand Down
8 changes: 4 additions & 4 deletions src/plantop.f
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ subroutine plantop
endif

!! compare maximum rooting depth in soil to maximum rooting depth of plant
nly = sol_nly(j)
sol_zmx(ihru) = sol_z(nly,j)
plt_zmx = 1000. * rdmx(idplt(j))
sol_zmx(ihru) = Min(sol_zmx(ihru),plt_zmx)
!nly = sol_nly(j)
!sol_zmx(ihru) = sol_z(nly,j)
!plt_zmx = 1000. * rdmx(idplt(j))
!sol_zmx(ihru) = Min(sol_zmx(ihru),plt_zmx)

!! reset curve number if given in .mgt file
if (cnop > 0.) call curno(cnop,j)
Expand Down
4 changes: 4 additions & 0 deletions src/readbsn.f
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ subroutine readbsn
eof = 0
escobsn = 0.
epcobsn = 0.
isub_sav = 0
r2adj_bsn = 0. !D. Moriasi 4/8/2014
wwqfile = ""
numlu=1
Expand Down Expand Up @@ -607,8 +608,11 @@ subroutine readbsn
read (103,*,iostat=eof) sfsedmean
if (eof < 0) exit
read (103,*,iostat=eof) sfsedstdev
if (eof < 0) exit
read (103,*,iostat=eof) salt_num
if (eof < 0) exit
read (103,*,iostat=eof) isub_sav
if (eof < 0) exit
exit
!! Drainmod input variables - 01/2006
end do
Expand Down
12 changes: 6 additions & 6 deletions src/readfig.f
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,19 @@ subroutine readfig
day_in = ""
read (102,5100) day_in
call caps(day_in)
if (inum1s(idum) <= 10 .and. inum1s(idum) > 0) then
open (40+inum1s(idum),file=day_in,recl=350)
!if (inum1s(idum) <= 10 .and. inum1s(idum) > 0) then
open (30000+inum1s(idum),file=day_in,recl=350)
if (inum3s(idum) == 0) then
write (40+inum1s(idum),5400) title
write (40+inum1s(idum),5500)
write (30000+inum1s(idum),5400) title
write (30000+inum1s(idum),5500)
else
iida = 0
iida = idaf
call xmon
write (40+inum1s(idum),5501) iyr, i_mo,
write (30000+inum1s(idum),5501) iyr, i_mo,
& (iida - ndays(i_mo))
end if
end if
!end if

case (10) !! icode = 10 RECDAY command: read in daily values
!! with water in cms and rest in tons
Expand Down
11 changes: 11 additions & 0 deletions src/readfile.f
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,17 @@ subroutine readfile
write (142,4998)
4998 format(t17,'AVE WATER',/,t3,'Day',t7,'Year',t18,'DEPTH(m)')
end if

!!!!!open Srin/Arun new output file from subbasin.f (monsoon_plt.out)
open (144, file="monsoon_plt.out", recl=600)
write (144, 1999)
1999 format(2x,'Sub',2x,'Hru',2x,'Year',3x,'Mon',3x,'Day',
*' AREAkm2', 13x,'CPNM', 4x, " PLANT",
*' PRECIPD ', ' PET_DAY ', ' RTO', ' PRECIPSUM',
*' PET_SUM ',
*' SOL_SW',/,70x,' (mm) ',' (mm) ',10x,' (mm) ',
*' (mm) ',' (mm) ')
!!!!!open Srin/Arun new output file from subbasin.f

!! Code for output.mgt file
! 0=no print 1=print
Expand Down
4 changes: 2 additions & 2 deletions src/readpnd.f
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ subroutine readpnd
read (104,*,iostat=eof) (lid_lus(k),k=1,mudb)
if (eof < 0) exit
nlid(i)=1
do while (is_numeric(lid_lus(nlid(i))) .eqv. .TRUE.)
!do while (is_numeric(lid_lus(nlid(i)))== .TRUE.)
nlid(i)=nlid(i) + 1
END DO
!END DO
nlid(i) = nlid(i) - 1
backspace(104)
backspace(104)
Expand Down
Loading

0 comments on commit 29c504b

Please sign in to comment.