Skip to content

Commit

Permalink
Merge depo_mass (SED3D work) back to master and close out.
Browse files Browse the repository at this point in the history
Special thanks to la Rochelle group (Baptiste M, Xavier B. et al.)
Squashed commit of the following:

commit 6d261ae
Author: Joseph Zhang <yinglong@james.hpc.vims.edu>
Date:   Wed May 6 12:23:03 2020 -0400

    update notes

commit 7f731dc
Author: Joseph Zhang <yjzhang@vims.edu>
Date:   Sat Apr 25 14:32:34 2020 -0400

    remove old info in sflux_input.txt

commit 2687835
Author: Joseph Zhang <yjzhang@vims.edu>
Date:   Sat Apr 25 14:20:29 2020 -0400

    Fixed the issue with NARR linker (not sure why this got clobbered)

commit 80e7392
Author: Joseph Zhang <yjzhang@vims.edu>
Date:   Fri Apr 24 10:05:12 2020 -0400

    Revert to old approach for depositional mass (c/o Baptiste Mengual).
    Testing....
  • Loading branch information
Joseph Zhang committed May 6, 2020
1 parent 1b42b19 commit e703189
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/Hydro/schism_step.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4585,7 +4585,7 @@ subroutine schism_step(it)
if(itur==5) then !1018:itur==5
bigf1=bigf1+(TDxz(nvrt,isd)-TDxz(kbs(isd)+1,isd)) !/i34(i)
bigf2=bigf2+(TDyz(nvrt,isd)-TDyz(kbs(isd)+1,isd)) !/i34(i)
!Error: Hai, shouldn't there be botf[1,2] also?
!Assume botf1=botf2
endif
#endif /*USE_SED*/

Expand Down
5 changes: 3 additions & 2 deletions src/Readme.beta_notes
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ eb00a00 (Mar 31, 2020): add 12th tracer model (USE_DVD of Klingbeil); if invoked
cd9664a (Mar 16, 2020): [1st PR from Baptiste Mengual] added iof_sed(12:15) for new SED code. In sediment.in:
new options for various parameters and a few new parameters;
sed_morph=1 requires imorphogrid.gr3 (a scale applied to depth change at each node);
7506147 (Mar 1, 2020): add limiter for settling vel to avoid char line out of bnd;
73f7451 (Jan 14, 2020): changed ifltyp=3 to be consistent with '5' (i.e., now the amp/phases should be variable along open bnd);
also morp factors are replaced by a single 'sed_morph_fac' fro all classes;
73f7451 (Jan 14, 2020): changed ifltype=3 to be consistent with '5' (i.e., now the amp/phases should be variable along open bnd);
59741d4 (Jan 9, 2020): added another pre-proc flag 'ipre2' for more diagnostic outputs (can be used with >1 CPU; stops
after outputs);
4e2eb86 (Dec 11, 2019): added optional flags 'iadjust_mass_consv0' to enforce mass conservation for each of (11) tracer models;
Expand Down Expand Up @@ -425,6 +425,7 @@ git versions:
(104) eb00a00 (Mar 31, 2020): added 12th tracer model (USE_DVD of Klingbeil)
(105) aaf1306 (April 4, 2020): added hybrid ELM transport for efficiency (via branch hybrid_ELM);
(106) 40955ab (April 16, 2020): replaced the fatal error in nadv=2 (aptivity trap) with exit
(107) (April 24, 2020): reverted to old simple approach for deposional mass (c/o Baptiste Mengual);

---------------------------------------------------------------
Auto-test history:
Expand Down
117 changes: 56 additions & 61 deletions src/Sediment/sediment.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1000,72 +1000,67 @@ subroutine sediment(it,moitn,mxitn,rtol,dave,tot_bedmass)

select case(ised_bc_bot)
case(1) !Warner
!Depositional mass (kg/m/m) in a time step; use
!semi-Lagrangian to calculate depo_mss=\int w_s*c^* dt
cff=ze(nvrt,i)-ze(kbe(i),i) !total depth
cff1=ze(kbe(i)+1,i)-ze(kbe(i),i) !bottom cell thickness

if(cff1.LE.0.d0) then
WRITE(errmsg,*)'SED, wrong bottom layer0:',cff,ze(kbe(i)+1,i),ze(kbe(i),i)
CALL parallel_abort(errmsg)
endif

!Limit ratio between reference depth and bottom depth
!ta=min(0.5d0,relath*cff/cff1) !usually the relath is 0.01; for natural river, it should be even smaller

!aref=ta*we(kbe(i)+1,i) !w-vel. at ref. height
!Estimate the starting pt
cff8=(ze(kbe(i)+1,i)+ze(kbe(i),i))/2 !bottom half cell -starting pt of ELM
cff9=cff8+Wsed(ised)*dt !>cff8; foot of char.
if(cff9<=cff8) call parallel_abort('SED: (9)')
Ksed=nvrt+1 !init. for abnormal case
do k=kbe(i)+2,nvrt
if(cff9<=(ze(k,i)+ze(k-1,i))/2) then
Ksed=k
exit
endif
enddo !k

depo_mss=0 !(min(cff9,cff8)-ze(kbe(i),i))*tr_el(indx,kbe(i)+1,i)
do k=kbe(i)+2,min(nvrt,Ksed)
cff7=(ze(k-2,i)+ze(k-1,i))/2
cff8=(ze(k,i)+ze(k-1,i))/2
if(cff9<cff7) then
WRITE(errmsg,*)'SED, wrong cff9:',cff9,cff7,ielg(i),ised,k
CALL parallel_abort(errmsg)
endif

if(cff9<cff8) then
cff5=(cff9-cff7)/(cff8-cff7) !ratio
if(cff5<0.or.cff5>1) then
WRITE(errmsg,*)'SED, wrong ratio:',cff5,ielg(i),ised,k
CALL parallel_abort(errmsg)
endif
cff6=(1-cff5)*tr_el(indx,k-1,i)+cff5*tr_el(indx,k,i) !conc @upper layer
else
cff6=tr_el(indx,k,i)
endif

depo_mss=depo_mss+(cff6+tr_el(indx,k-1,i))/2*(min(cff9,cff8)-cff7) !>=0
!depo_mss=depo_mss+cff6*(min(cff9,cff8)-cff7) !>=0 (lower depos. flux)
enddo !k

!Deal with above F.S. case
if(Ksed==nvrt+1) then
cff7=(ze(nvrt,i)+ze(nvrt-1,i))/2
depo_mss=depo_mss+(min(ze(nvrt,i),cff9)-cff7)*tr_el(indx,nvrt,i)
endif
!Depositional mass (kg/m/m) in a time step
! cff=ze(nvrt,i)-ze(kbe(i),i) !total depth
! cff1=ze(kbe(i)+1,i)-ze(kbe(i),i) !bottom cell thickness
!
! if(cff1.LE.0.d0) then
! WRITE(errmsg,*)'SED, wrong bottom layer0:',cff,ze(kbe(i)+1,i),ze(kbe(i),i)
! CALL parallel_abort(errmsg)
! endif
!
! !Limit ratio between reference depth and bottom depth
! !ta=min(0.5d0,relath*cff/cff1) !usually the relath is 0.01; for natural river, it should be even smaller
!
! !aref=ta*we(kbe(i)+1,i) !w-vel. at ref. height
! !Estimate the starting pt
! cff8=(ze(kbe(i)+1,i)+ze(kbe(i),i))/2 !bottom half cell -starting pt of ELM
! cff9=cff8+Wsed(ised)*dt !>cff8; foot of char.
! if(cff9<=cff8) call parallel_abort('SED: (9)')
! Ksed=nvrt+1 !init. for abnormal case
! do k=kbe(i)+2,nvrt
! if(cff9<=(ze(k,i)+ze(k-1,i))/2) then
! Ksed=k
! exit
! endif
! enddo !k
!
! depo_mss=0 !(min(cff9,cff8)-ze(kbe(i),i))*tr_el(indx,kbe(i)+1,i)
! do k=kbe(i)+2,min(nvrt,Ksed)
! cff7=(ze(k-2,i)+ze(k-1,i))/2
! cff8=(ze(k,i)+ze(k-1,i))/2
! if(cff9<cff7) then
! WRITE(errmsg,*)'SED, wrong cff9:',cff9,cff7,ielg(i),ised,k
! CALL parallel_abort(errmsg)
! endif
!
! if(cff9<cff8) then
! cff5=(cff9-cff7)/(cff8-cff7) !ratio
! if(cff5<0.or.cff5>1) then
! WRITE(errmsg,*)'SED, wrong ratio:',cff5,ielg(i),ised,k
! CALL parallel_abort(errmsg)
! endif
! cff6=(1-cff5)*tr_el(indx,k-1,i)+cff5*tr_el(indx,k,i) !conc @upper layer
! else
! cff6=tr_el(indx,k,i)
! endif
!
! depo_mss=depo_mss+(cff6+tr_el(indx,k-1,i))/2*(min(cff9,cff8)-cff7) !>=0
! !depo_mss=depo_mss+cff6*(min(cff9,cff8)-cff7) !>=0 (lower depos. flux)
! enddo !k
!
! !Deal with above F.S. case
! if(Ksed==nvrt+1) then
! cff7=(ze(nvrt,i)+ze(nvrt-1,i))/2
! depo_mss=depo_mss+(min(ze(nvrt,i),cff9)-cff7)*tr_el(indx,nvrt,i)
! endif

!BM: Correction of depo_mss, otherwise conservativity
! issues occur
!Error: this will change conservation
!depo_mss=dt*Wsed(ised)*tr_el(indx,kbe(i)+1,i) !s * m/s * kg/m3
depo_mss=dt*Wsed(ised)*tr_el(indx,kbe(i)+1,i) !s * m/s * kg/m3

!BM: output
depflxel(i,ised)=depo_mss/dt ! en kg/m2/s

!Apply a scale to depo_mss
!depo_mss=depo_mss*depo_scale
depflxel(i,ised)=depo_mss/dt ! en kg/m2/s

! - Compute erosion, eros_mss (kg/m/m) following
! (original erosion flux is in kg/m/m/s; note dt below)
Expand Down
18 changes: 7 additions & 11 deletions src/Utility/Sflux_nc/NARR_util/make_sflux_links.csh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#### On a new system, change util_bin and data_grandparent below
######## define locations and names for utilities ######################

set util_bin = ~yinglong/SELFE/svn/trunk/src/Utility/Sflux_nc/NARR_util/src/
set util_bin = ~yinglong/git/schism/src/Utility/Sflux_nc/NARR_util/src/
set cjd_util = $util_bin'cjd/cjd'


Expand Down Expand Up @@ -103,8 +103,7 @@ set src_1 = ""
set src_2 = ""
set domain_1 = "."
set domain_2 = "."
#set data_grandparent = '/home/workspace/ccalmr37/sflux_data/'
set data_grandparent = '/home/dogami/'
set data_grandparent = '~yinglong/vims20/'

if ($data_source_code == "1") then
set src_1 = "nam"
Expand Down Expand Up @@ -186,11 +185,6 @@ echo " " $dest_dir$inputs_file

cat > $dest_dir$inputs_file << EOF
&sflux_inputs
start_year = $year_start,
start_month = $month_start,
start_day = $day_start,
start_hour = $start_hour,
utc_start = $utc_start,
/
EOF

Expand Down Expand Up @@ -229,12 +223,14 @@ foreach file_type (air rad prc)
foreach in_file (`ls $src_1'_'$file_type$domain_1$date_string'.nc'`)
set type_counter = `echo \($type_counter + 1\) | bc` >& /dev/null

if ($type_counter >= 100) then
if ($type_counter >= 1000) then
set type_counter_label = $type_counter
else if ($type_counter >= 10) then
else if ($type_counter >= 100) then
set type_counter_label = 0$type_counter
else
else if ($type_counter >= 10) then
set type_counter_label = 00$type_counter
else
set type_counter_label = 000$type_counter
endif

set link_name = sflux_$file_type"_1."$type_counter_label.nc
Expand Down

0 comments on commit e703189

Please sign in to comment.