@@ -17,13 +17,17 @@ module FastScapeContext
1717 double precision :: sealevel, poro1, poro2, zporo1, zporo2, ratio, layer, kdsea1, kdsea2
1818 integer , dimension (:), allocatable :: stack, ndon, rec
1919 integer , dimension (:,:), allocatable :: don
20- logical :: runSPL, runAdvect, runDiffusion, runMarine, runStrati
21- real :: timeSPL, timeAdvect, timeDiffusion, timeMarine, timeStrati
20+ logical :: runSPL, runAdvect, runDiffusion, runStrati, runUplift, runMarine
21+ real :: timeSPL, timeAdvect, timeDiffusion, timeStrati, timeUplift, timeMarine
2222 double precision , dimension (:,:), allocatable :: reflector
2323 double precision , dimension (:,:,:), allocatable :: fields
2424 integer nfield, nfreq, nreflector, nfreqref, ireflector
2525 double precision :: vexref
26- double precision , dimension (:), allocatable :: lake_depth
26+ logical :: SingleFlowDirection
27+ double precision , dimension (:), allocatable :: lake_depth, hwater
28+ integer , dimension (:), allocatable :: mnrec,mstack
29+ integer , dimension (:,:), allocatable :: mrec
30+ double precision , dimension (:,:), allocatable :: mwrec,mlrec
2731
2832 contains
2933
@@ -36,8 +40,9 @@ subroutine Init()
3640 timeSPL = 0 .
3741 timeAdvect = 0 .
3842 timeDiffusion = 0 .
39- timeMarine = 0 .
40- timeStrati = 0 .
43+ timeStrati = 0 .
44+ timeMarine = 0 .
45+ timeUplift = 0 .
4146
4247 end subroutine Init
4348
@@ -56,7 +61,7 @@ subroutine SetUp()
5661
5762 allocate (h(nn),u(nn),vx(nn),vy(nn),stack(nn),ndon(nn),rec (nn),don(8 ,nn),catch0(nn),catch(nn),precip(nn))
5863 allocate (length(nn),a(nn),erate(nn),etot(nn),b(nn),Sedflux(nn),Fmix(nn),kf(nn),kd(nn))
59- allocate (lake_depth(nn))
64+ allocate (lake_depth(nn),hwater(nn),mrec( 8 ,nn),mnrec(nn),mwrec( 8 ,nn),mlrec( 8 ,nn),mstack(nn) )
6065
6166 h2(1 :nx,1 :ny) = > h
6267 b2(1 :nx,1 :ny) = > b
@@ -84,8 +89,9 @@ subroutine SetUp()
8489 runSPL = .false.
8590 runAdvect = .false.
8691 runDiffusion = .false.
92+ runStrati = .false.
8793 runMarine = .false.
88- runStrati = .false.
94+ runUplift = .false.
8995
9096 nGSStreamPowerLaw = 0
9197 nGSMarine = 0
@@ -123,6 +129,13 @@ subroutine Destroy()
123129 if (allocated (reflector)) deallocate (reflector)
124130 if (allocated (fields)) deallocate (fields)
125131 if (allocated (lake_depth)) deallocate (lake_depth)
132+ if (allocated (hwater)) deallocate (hwater)
133+ if (allocated (mrec)) deallocate (mrec)
134+ if (allocated (mnrec)) deallocate (mnrec)
135+ if (allocated (mwrec)) deallocate (mwrec)
136+ if (allocated (mlrec)) deallocate (mlrec)
137+ if (allocated (mstack)) deallocate (mstack)
138+
126139
127140 return
128141
@@ -411,6 +424,11 @@ subroutine SetErosionalParam (kkf,kkfsed,mm,nnn,kkd,kkdsed,gg1,gg2,pp)
411424 g1 = gg1
412425 g2 = gg2
413426 p = pp
427+ SingleFlowDirection = .false.
428+ if (pp.lt. - 1.5d0 ) then
429+ SingleFlowDirection = .true.
430+ p = 1.d0
431+ endif
414432
415433 if (maxval (kd).gt. tiny (kd).or. kdsed.gt. tiny (kdsed)) runDiffusion = .true.
416434
@@ -534,6 +552,7 @@ subroutine Debug ()
534552 if (runDiffusion) write (* ,* ) ' Diffusion:' ,timeDiffusion
535553 if (runMarine) write (* ,* ) ' Marine:' ,timeMarine
536554 if (runAdvect) write (* ,* ) ' Advection:' ,timeAdvect
555+ if (runUplift) write (* ,* ) ' Uplift:' ,timeUplift
537556 if (runStrati) write (* ,* ) ' Strati:' ,timeStrati
538557
539558 end subroutine Debug
@@ -559,6 +578,8 @@ subroutine SetU (up)
559578 double precision , intent (in ) :: up(* )
560579 integer i
561580
581+ runUplift = .true.
582+
562583 do i= 1 ,nn
563584 u(i) = up(i)
564585 enddo
@@ -674,7 +695,7 @@ subroutine Make_VTK (f, vex)
674695#ifdef ON_WINDOWS
675696 call system (' if not exist "VTK" mkdir VTK' )
676697#else
677- call system (" mkdir -p VTK" )
698+ call system (" mkdir -p VTK" )
678699#endif
679700
680701 write (nxc,' (i6)' ) nx
@@ -753,7 +774,7 @@ subroutine Activate_Strati (nstepp, nreflectorp, nfreqp, vexp)
753774
754775 fields= 0.d0
755776
756- ! call Strati (h, b, Fmix, nx, ny, xl, yl, reflector, nreflector, ireflector, 0, &
777+ ! call Strati (b, Fmix, nx, ny, xl, yl, reflector, nreflector, ireflector, 0, &
757778 ! fields, nfield, vexref, dt*nfreqref, stack, rec, length, sealevel)
758779
759780 runStrati = .true.
@@ -803,10 +824,7 @@ subroutine compute_fluxes (tectonic_flux, erosion_flux, boundary_flux)
803824 double precision , intent (out ) :: tectonic_flux, erosion_flux, boundary_flux
804825 double precision :: surf
805826 logical , dimension (:), allocatable :: bc
806- double precision , dimension (:), allocatable :: hwater,flux
807- double precision , dimension (:,:), allocatable :: mwrec,mlrec
808- integer , dimension (:), allocatable :: mnrec,mstack
809- integer , dimension (:,:), allocatable :: mrec
827+ double precision , dimension (:), allocatable :: flux
810828 character * 4 :: cbc
811829 integer ij,ijk,k
812830
@@ -816,17 +834,29 @@ subroutine compute_fluxes (tectonic_flux, erosion_flux, boundary_flux)
816834 erosion_flux = sum (erate)* surf
817835
818836 ! computes receiver and stack information for multi-direction flow
819- allocate (mrec(8 ,nn), mnrec(nn), mwrec(8 ,nn), mlrec(8 ,nn), mstack(nn), hwater(nn), flux(nn), bc(nn) )
820- call find_mult_rec (h, rec, stack, hwater, mrec, mnrec, mwrec, mlrec, mstack, nx, ny, xl/ (nx-1 ), yl/ (ny-1 ), p, ibc)
837+ ! allocate (mrec(8,nn), mnrec(nn), mwrec(8,nn), mlrec(8,nn), mstack(nn), hwater(nn)
838+ ! call find_mult_rec (h, rec, stack, hwater, mrec, mnrec, mwrec, mlrec, mstack, nx, ny, xl/(nx-1), yl/(ny-1), p, ibc)
821839 ! computes sediment flux
840+ allocate (flux(nn), bc(nn))
841+
822842 flux = erate
823- do ij = 1 , nn
824- ijk = mstack(ij)
825- flux(ijk)= max (0.d0 ,flux(ijk))
826- do k = 1 , mnrec(ijk)
827- flux(mrec(k,ijk)) = flux(mrec(k,ijk)) + flux(ijk)* mwrec(k,ijk)
843+
844+ if (SingleFlowDirection) then
845+ do ij = nn ,1 , - 1
846+ ijk = stack(ij)
847+ flux(ijk)= max (0.d0 ,flux(ijk))
848+ flux(rec (ijk)) = flux(rec (ijk)) + flux(ijk)
828849 enddo
829- enddo
850+ else
851+ do ij = 1 , nn
852+ ijk = mstack(ij)
853+ flux(ijk)= max (0.d0 ,flux(ijk))
854+ do k = 1 , mnrec(ijk)
855+ flux(mrec(k,ijk)) = flux(mrec(k,ijk)) + flux(ijk)* mwrec(k,ijk)
856+ enddo
857+ enddo
858+ endif
859+
830860 ! compute boundary flux
831861 write (cbc,' (i4)' ) ibc
832862 bc= .FALSE.
@@ -836,7 +866,7 @@ subroutine compute_fluxes (tectonic_flux, erosion_flux, boundary_flux)
836866 if (cbc(3 :3 ).eq. ' 1' ) bc(nx* (ny - 1 ) + 1 :nn) = .TRUE.
837867 boundary_flux = sum (flux,bc)* surf
838868
839- deallocate (mrec, mnrec, mwrec, mlrec, mstack, hwater, flux, bc)
869+ deallocate (flux, bc)
840870
841871 end subroutine compute_fluxes
842872
0 commit comments