Skip to content

Commit

Permalink
Revert "Merge pull request #3 from Mike-Fuchs/main"
Browse files Browse the repository at this point in the history
This reverts commit 5bb0c80, reversing
changes made to c2f2175.
  • Loading branch information
tugraskan committed Jul 24, 2024
1 parent 5bb0c80 commit a65eb10
Show file tree
Hide file tree
Showing 28 changed files with 174 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/aqu_1d_control.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ subroutine aqu_1d_control
use pesticide_data_module
use aqu_pesticide_module
use salt_module
use salt_aquifer_module
use cs_aquifer_module
use salt_aquifer
use cs_aquifer
use ch_pesticide_module

implicit none
Expand Down
2 changes: 1 addition & 1 deletion src/aqu_cs_output.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subroutine aqu_cs_output(iaq) !rtb cs
use basin_module
use aquifer_module
use hydrograph_module, only : ob, sp_ob1
use cs_aquifer_module
use cs_aquifer
use constituent_mass_module

implicit none
Expand Down
8 changes: 3 additions & 5 deletions src/aqu_initial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ subroutine aqu_initial
use constituent_mass_module
use aqu_pesticide_module
use salt_module !rtb salt
use salt_aquifer_module !rtb salt
use salt_aquifer !rtb salt
use cs_module !rtb cs
use cs_aquifer_module !rtb cs
use cs_aquifer !rtb cs

implicit none

Expand Down Expand Up @@ -122,9 +122,7 @@ subroutine aqu_initial
allocate (aqupst_a(iaq)%pest(cs_db%num_pests))
allocate (cs_aqu(iaq)%path(cs_db%num_paths))
allocate (cs_aqu(iaq)%hmet(cs_db%num_metals))
cs_aqu(iaq)%pest = 0.
cs_aqu(iaq)%path = 0.
cs_aqu(iaq)%hmet = 0.
allocate (cs_aqu(iaq)%salt(cs_db%num_salts))
end if
!salts !rtb salt
if (cs_db%num_salts > 0) then
Expand Down
2 changes: 1 addition & 1 deletion src/aqu_salt_output.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ subroutine aqu_salt_output(iaq)
use basin_module
use aquifer_module
use hydrograph_module, only : ob, sp_ob1
use salt_aquifer_module
use salt_aquifer
use constituent_mass_module

implicit none
Expand Down
3 changes: 1 addition & 2 deletions src/ch_rtpest.f90
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ subroutine ch_rtpest

!! calculate fraction of soluble and sorbed pesticide
frsol = 1. / (1. + kd * sedcon)
frsol = max(min(frsol,1.),0.)
frsrb = 1. - frsol

!! ASSUME DENSITY=2.6E6; KD2=KD1
Expand All @@ -161,7 +160,7 @@ subroutine ch_rtpest
!! calculate amount of pesticide that undergoes chemical or biological degradation on day in reach
pest_init = chpstmass
if (pest_init > 1.e-12) then
pest_end = chpstmass * Exp(-.693 / pestdb(jpst)%aq_hlife * tday)
pest_end = chpstmass * (pestcp(jpst)%decay_a * tday)
chpstmass = pest_end
chpst%pest(ipest)%react = pest_init - pest_end
!! add decay to daughter pesticides
Expand Down
2 changes: 1 addition & 1 deletion src/cs_aquifer_module.f90 → src/cs_aquifer.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!module for constituent mass balance in aquifers (rtb cs)
module cs_aquifer_module
module cs_aquifer

implicit none

Expand Down
2 changes: 1 addition & 1 deletion src/cs_balance.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ subroutine cs_balance !rtb cs
use time_module
use constituent_mass_module
use cs_module
use cs_aquifer_module
use cs_aquifer
use res_cs_module, only : wetcs_d,rescs_d
use ch_cs_module, only: chcs_d
use gwflow_module, only : gw_solute_flag,gwsol_ss,ncell,ncell,gw_state,gwsol_state
Expand Down
2 changes: 1 addition & 1 deletion src/cs_divert.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ subroutine cs_divert(iwallo,idmd,dem_id) !rtb cs
use hru_module, only : hru
use basin_module, only : bsn_cc
use cs_module !rtb cs
use cs_aquifer_module !rtb cs
use cs_aquifer !rtb cs
use ch_cs_module !rtb cs
use res_cs_module !rtb cs
use constituent_mass_module
Expand Down
2 changes: 1 addition & 1 deletion src/cs_irrig.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ subroutine cs_irrig(iwallo,idmd,ihru) !rtb cs
use hydrograph_module, only : irrig,res,sp_ob1,ob
use hru_module, only : hru
use cs_module !rtb cs
use cs_aquifer_module !rtb cs
use cs_aquifer !rtb cs
use ch_cs_module !rtb cs
use res_cs_module !rtb cs
use basin_module, only : bsn_cc
Expand Down
2 changes: 1 addition & 1 deletion src/cs_rctn_aqu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subroutine cs_rctn_aqu !rtb cs
use cs_data_module
use organic_mineral_mass_module
use cs_module
use cs_aquifer_module
use cs_aquifer

implicit none

Expand Down
2 changes: 1 addition & 1 deletion src/cs_sorb_aqu.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subroutine cs_sorb_aqu !rtb cs
use aquifer_module
use organic_mineral_mass_module
use constituent_mass_module
use cs_aquifer_module
use cs_aquifer
use cs_data_module

implicit none
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/header_const.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subroutine header_const !rtb cs
use ch_cs_module
use res_cs_module
use cs_module
use cs_aquifer_module
use cs_aquifer

implicit none

Expand Down
2 changes: 1 addition & 1 deletion src/header_salt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subroutine header_salt
use ch_salt_module
use res_salt_module
use salt_module
use salt_aquifer_module
use salt_aquifer

implicit none

Expand Down
File renamed without changes.
136 changes: 136 additions & 0 deletions src/main.f90.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
program main

use time_module
use hydrograph_module
use maximum_data_module
use calibration_data_module

implicit none

integer :: date_time(8) ! |
character*10 b(3) ! |

prog = " SWAT+ @TODAY@ MODULAR Rev @YEAR@.@SWAT_VERSION@"

write (*,1000)
open (9003,file='simulation.out')
write (9003,1000)
1000 format(1x," SWAT+ ",/, &
& " Revision @SWAT_VERSION@ ",/, &
& " Soil & Water Assessment Tool ",/, &
& "@CMAKE_Fortran_COMPILER_ID@ (@CMAKE_Fortran_COMPILER_VERSION@), @ISO@, @CMAKE_HOST_SYSTEM_NAME@",/, &
& " Program reading . . . executing",/)

open (888,file="erosion.txt",recl = 1500)

!!!! for Luis only
! open (7777,file='res1_out.txt',recl=1500)
! write (7777,7778)
!7778 format (9x,'DAY',8x,'YEAR',10x,'RES',7x,'VOL m^3',4x,'INFLO m^3',5x,'OUTFLO m^3',5x,'PREC m^3',7x,'EVAP m^3', &
! 8x,'AREA ha')
!!!! for Luis only

call proc_bsn
call proc_date_time
call proc_db
call proc_read

call hyd_connect
call exco_db_read
call dr_db_read

call cli_lapse
call object_read_output

call om_water_init
call pest_cha_res_read
call path_cha_res_read
call salt_cha_read !rtb salt
call cs_cha_read !rtb cs

call lsu_read_elements !defining landscape units by hru

call proc_hru
call proc_cha
call proc_aqu

!! read decision table data for conditional management
call dtbl_lum_read

call hru_lte_read

call proc_cond

call res_read_weir !moved from proc_res Jaehak 2023
call dtbl_res_read
call dtbl_scen_read
! input scenarios used in simulation
call cal_cond_read

! read manure allocation inputs
call manure_allocation_read

call dtbl_flocon_read

! read water treatment and water allocation files - before hru lum tables
call treat_read_om
call water_allocation_read

call hru_dtbl_actions_init

! read reservoir and wetland data
call proc_res
call wet_read_hyd
call wet_read
call wet_read_salt_cs
if (db_mx%wet_dat > 0) call wet_all_initial
if (bsn_cc%i_fpwet == 2) call wet_fp_init

call proc_cal

call proc_open

! compute unit hydrograph parameters for subdaily runoff
call unit_hyd_ru_hru

call dr_ru

call hyd_connect_out

! save initial time settings for soft calibration runs
time_init = time

!! simulate watershed processes
if (time%step < 0) then
!! export coefficient - average annual
time%end_sim = 1
call command
else
call time_control
end if

if (cal_soft == "y") call calsoft_control

if (cal_hard == "y") then
deallocate (cal_upd)
call cal_parmchg_read
call calhard_control
end if

!! write output for SWIFT input
if (bsn_cc%swift_out == 1) call swift_output

!! write successful completion to screen and file
write (*,1001)
write (9003,1001)
open (107,file="success.fin")

call DATE_AND_TIME (b(1), b(2), b(3), date_time)
write (*,1234) date_time(2), date_time(3), date_time(1), date_time(5), date_time(6), date_time(7)
write (9003,1234) date_time(2), date_time(3), date_time(1), date_time(5), date_time(6), date_time(7)
1234 format(/," Date of Sim", 2x,i2,"/",i2,"/",i4, " Time",2x,i2,":",i2,":",i2)

write (107,1001)
1001 format (/," Execution successfully completed ")

end
14 changes: 5 additions & 9 deletions src/pest_decay.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ subroutine pest_decay
real :: pest_end !kg/ha |amount of pesticide present at end of day
real :: pst_decay !kg/ha |amount of pesticide decay in soil layer during day
real :: pst_decay_s !kg/ha |amount of pesticide decay in soil profile during day
real :: pst_decay_f !kg/ha |amount of pesticide decay in foliage during day
real :: metab_decay !kg/ha |amount of metabolite decay in soil layer during day

j = ihru
Expand Down Expand Up @@ -70,27 +69,24 @@ subroutine pest_decay
hpestb_d(j)%pest(k)%decay_s = pst_decay_s

!! calculate degradation on plant foliage
pst_decay_f = 0.
!! adjust foliar pesticide for wash off
!! adjust foliar pesticide for wash off
do ipl = 1, pcom(j)%npl
pest_init = cs_pl(j)%pl_on(ipl)%pest(k)
if (pest_init > 1.e-12) then
pest_end = pest_init * pestcp(ipest_db)%decay_f
cs_pl(j)%pl_on(ipl)%pest(k) = pest_end
pst_decay = (pest_init - pest_end)
pst_decay_f = pst_decay_f + pst_decay
hpestb_d(j)%pest(k)%decay_f = pest_init - pest_end
!! add decay to daughter pesticides
do imeta = 1, pestcp(ipest_db)%num_metab
ipseq = pestcp(ipest_db)%daughter(imeta)%num
ipdb = cs_db%pest_num(ipseq)
mol_wt_rto = pestdb(ipdb)%mol_wt / pestdb(ipest_db)%mol_wt
metab_decay = pst_decay * pestcp(ipest_db)%daughter(imeta)%foliar_fr * mol_wt_rto
hpestb_d(j)%pest(ipseq)%metab_f = hpestb_d(j)%pest(ipseq)%metab_f + metab_decay
cs_pl(j)%pl_on(ipl)%pest(ipseq) = cs_pl(j)%pl_on(ipl)%pest(ipseq) + metab_decay
hpestb_d(j)%pest(ipseq)%metab_f = hpestb_d(j)%pest(ipseq)%metab_f + (pest_init - pest_end) * &
pestcp(ipest_db)%daughter(imeta)%soil_fr * mol_wt_rto
cs_pl(j)%pl_on(ipl)%pest(ipseq) = cs_pl(j)%pl_on(ipl)%pest(ipseq) + hpestb_d(j)%pest(ipseq)%metab_f
end do
end if
end do
hpestb_d(j)%pest(k)%decay_f = pst_decay_f
end if
end do

Expand Down
1 change: 0 additions & 1 deletion src/pest_lch.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ subroutine pest_lch
hpestb_d(j)%pest(k)%perc = 0.
hpestb_d(j)%pest(k)%surq = 0.
hpestb_d(j)%pest(k)%latq = 0.
hpestb_d(j)%pest(k)%tileq = 0.
end do

do ly = 1, soil(j)%nly
Expand Down
2 changes: 1 addition & 1 deletion src/pest_pl_up.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subroutine pest_pl_up
if (cs_pl(j)%pl_on(ipl)%pest(k) >= 0.0001) then
if (ipest_db > 0) then
do ly = 1, soil(j)%nly
pest_up = pestdb(ipest_db)%pl_uptake * pcom(j)%plcur(ipl)%uptake(ly) / soil(j)%phys(ly)%st &
pest_up = pestdb(ipest_db)%pl_uptake * pcom(j)%plcur(ipl)%uptake(ly) / soil(j)%phys(k)%st &
* cs_soil(j)%ly(ly)%pest(k)
if (pest_up > cs_soil(j)%ly(ly)%pest(k)) pest_up = cs_soil(j)%ly(ly)%pest(k)
cs_soil(j)%ly(ly)%pest(k) = cs_soil(j)%ly(ly)%pest(k) - pest_up
Expand Down
6 changes: 2 additions & 4 deletions src/pest_soil_tot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ subroutine pest_soil_tot
if (cs_db%num_pests == 0) return

do k = 1, cs_db%num_pests
hpestb_d(j)%pest(k)%plant = 0.
hpestb_d(j)%pest(k)%in_plant = 0.
do ipl = 1, pcom(j)%npl
hpestb_d(j)%pest(k)%plant = hpestb_d(j)%pest(k)%plant + cs_pl(j)%pl_on(ipl)%pest(k)
hpestb_d(j)%pest(k)%in_plant = hpestb_d(j)%pest(k)%in_plant + cs_pl(j)%pl_in(ipl)%pest(k)
hpestb_d(j)%pest(k)%plant = cs_pl(j)%pl_on(ipl)%pest(k)
hpestb_d(j)%pest(k)%in_plant = cs_pl(j)%pl_in(ipl)%pest(k)
end do
hpestb_d(j)%pest(k)%soil = 0.
do ly = 1, soil(j)%nly
Expand Down
3 changes: 1 addition & 2 deletions src/pest_washp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ subroutine pest_washp
do k = 1, cs_db%num_pests
ipest_db = cs_db%pest_num(k)
!! adjust foliar pesticide for wash off
hpestb_d(j)%pest(k)%wash = 0.
do ipl = 1, pcom(j)%npl
if (cs_pl(j)%pl_on(ipl)%pest(k) >= 0.0001) then
if (ipest_db > 0) then
pest_soil = pestdb(ipest_db)%washoff * cs_pl(j)%pl_on(ipl)%pest(k)
if (pest_soil > cs_pl(j)%pl_on(ipl)%pest(k)) pest_soil = cs_pl(j)%pl_on(ipl)%pest(k)
cs_soil(j)%ly(1)%pest(k) = cs_soil(j)%ly(1)%pest(k) + pest_soil
cs_pl(j)%pl_on(ipl)%pest(k) = cs_pl(j)%pl_on(ipl)%pest(k) - pest_soil
hpestb_d(j)%pest(k)%wash = hpestb_d(j)%pest(k)%wash + pest_soil
hpestb_d(j)%pest(k)%wash = pest_soil
end if
end if
end do
Expand Down
2 changes: 1 addition & 1 deletion src/pl_grow.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ subroutine pl_grow

!! check for start and end of dormancy of temp-based growth plant
idp = pcom(j)%plcur(ipl)%idplt
if (pldb(idp)%trig == "temp_gro" .and. pcom(j)%plcur(ipl)%gro == "y") then
if (pldb(idp)%trig == "temp_gro") then
call pl_dormant
end if

Expand Down
9 changes: 8 additions & 1 deletion src/pl_waterup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,14 @@ subroutine pl_waterup
sum = epmax(ipl) * (1. - Exp(-uptake%water_dis * gx / pcom(j)%plg(ipl)%root_dep)) / uptake%water_norm
end if

wuse = sum - sump * (1. - pcom(j)%plcur(ipl)%epco)
pcom(j)%plcur(ipl)%epco = 0.9
!! let second layer compensate - 10 mm layer causes problems wehn root depth is shallow
if (k == 2) then
wuse = sum !epco is always 1.0 for second layer
else
wuse = sum - sump * (1. - pcom(j)%plcur(ipl)%epco)
end if

! adjust for impervious area
ulu = hru(j)%luse%urb_lu
!wuse = wuse * urbdb(ulu)%fcimp
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/salt_aquifer_module.f90 → src/salt_aquifer.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module salt_aquifer_module
module salt_aquifer

implicit none

Expand Down
Loading

0 comments on commit a65eb10

Please sign in to comment.