sedadv.F90 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. MODULE sedadv
  2. #if defined key_sed
  3. !!======================================================================
  4. !! *** MODULE sedadv ***
  5. !! Sediment : vertical advection and burial
  6. !!=====================================================================
  7. !! * Modules used
  8. !!----------------------------------------------------------------------
  9. !! sed_adv :
  10. !!----------------------------------------------------------------------
  11. USE sed ! sediment global variable
  12. PUBLIC sed_adv
  13. !! * Module variable
  14. INTEGER, PARAMETER :: nztime = jpksed ! number of time step between sunrise and sunset
  15. REAL(wp), DIMENSION(jpksed), SAVE :: dvolsp, dvolsm
  16. REAL(wp), DIMENSION(jpksed), SAVE :: c2por, ckpor
  17. REAL(wp) :: cpor
  18. REAL(wp) :: por1clay
  19. REAL(wp) :: eps = 1.e-13
  20. !! $Id: sedadv.F90 2355 2015-05-20 07:11:50Z ufla $
  21. CONTAINS
  22. SUBROUTINE sed_adv( kt )
  23. !!-------------------------------------------------------------------------
  24. !! *** ROUTINE sed_adv ***
  25. !!
  26. !! ** Purpose : vertical solid sediment advection and burial
  27. !!
  28. !! ** Method : At each grid point the 1-dimensional solid sediment column
  29. !! is shifted according the rain added to the top layer and
  30. !! the gaps produced through redissolution so that in the end
  31. !! the original sediment mixed layer geometry is reestablished.
  32. !!
  33. !!
  34. !! History :
  35. !! ! 98-08 (E. Maier-Reimer, Christoph Heinze ) Original code
  36. !! ! 04-10 (N. Emprin, M. Gehlen ) F90
  37. !! ! 06-04 (C. Ethe) Re-organization
  38. !!-------------------------------------------------------------------------
  39. !!* Arguments
  40. INTEGER, INTENT(in) :: &
  41. kt ! time step
  42. ! * local variables
  43. INTEGER :: ji, jk, js
  44. INTEGER :: jn, ntimes, ikwneg
  45. REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zsolcpno
  46. REAL(wp), DIMENSION(: ), ALLOCATABLE :: zfilled, zfull, zfromup, zempty
  47. REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zgap, zwb
  48. REAL(wp), DIMENSION(:,:), ALLOCATABLE :: zrainrf
  49. REAL(wp), DIMENSION(nztime) :: zraipush
  50. REAL(wp) :: zkwnup, zkwnlo, zfrac, zfromce, zrest
  51. !------------------------------------------------------------------------
  52. IF( kt == nitsed000 ) THEN
  53. WRITE(numsed,*) ' '
  54. WRITE(numsed,*) ' sed_adv : vertical sediment advection '
  55. WRITE(numsed,*) ' '
  56. por1clay = dens * por1(jpksed) * dz(jpksed) / mol_wgt(jsclay)
  57. cpor = por1(jpksed) / por1(2)
  58. DO jk = 2, jpksed
  59. c2por(jk) = por1(2) / por1(jk)
  60. ckpor(jk) = por1(jpksed) / por1(jk)
  61. ENDDO
  62. DO jk = jpksedm1, 2, -1
  63. dvolsp(jk) = vols(jk+1) / vols(jk)
  64. ENDDO
  65. DO jk = 3, jpksed
  66. dvolsm(jk) = vols(jk-1) / vols(jk)
  67. ENDDO
  68. ENDIF
  69. ALLOCATE( zsolcpno(jpksed,jpsol), zrainrf(jpoce,jpsol) )
  70. ALLOCATE( zfilled(jpksed), zfull(jpksed), zfromup(jpksed), zempty(jpksed) )
  71. ALLOCATE( zgap (jpoce,jpksed) , zwb(jpoce,jpksed) )
  72. ! Initialization of data for mass balance calculation
  73. !---------------------------------------------------
  74. fromsed(:,:) = 0.
  75. tosed (:,:) = 0.
  76. rloss (:,:) = 0.
  77. ! Initiate gap
  78. !--------------
  79. zgap(:,:) = 0.
  80. DO js = 1, jpsol
  81. DO jk = 1, jpksed
  82. DO ji = 1, jpoce
  83. zgap(ji,jk) = zgap(ji,jk) + solcp(ji,jk,js)
  84. END DO
  85. ENDDO
  86. ENDDO
  87. zgap(1:jpoce,1:jpksed) = 1. - zgap(1:jpoce,1:jpksed)
  88. ! Initiate burial rates
  89. !-----------------------
  90. zwb(:,:) = 0.
  91. DO jk = 2, jpksed
  92. zfrac = dtsed / ( dens * por1(jk) )
  93. DO ji = 1, jpoce
  94. zwb(ji,jk) = zfrac * raintg(ji)
  95. END DO
  96. ENDDO
  97. DO ji = 1, jpoce
  98. zwb(ji,2) = zwb(ji,2) - zgap(ji,2) * dz(2)
  99. ENDDO
  100. DO jk = 3, jpksed
  101. zfrac = por1(jk-1) / por1(jk)
  102. DO ji = 1, jpoce
  103. zwb(ji,jk) = zwb(ji,jk-1) * zfrac - zgap(ji,jk) * dz(jk)
  104. END DO
  105. ENDDO
  106. zrainrf(:,:) = 0.
  107. DO ji = 1, jpoce
  108. IF( raintg(ji) /= 0. ) &
  109. & zrainrf(ji,:) = rainrg(ji,:) / raintg(ji)
  110. ENDDO
  111. ! Computation of full and empty solid fraction in each layer
  112. ! for all 'burial' case
  113. !----------------------------------------------------------
  114. DO ji = 1, jpoce
  115. ! computation of total weight fraction in sediment
  116. !-------------------------------------------------
  117. zfilled(:) = 0.
  118. DO js = 1, jpsol
  119. DO jk = 2, jpksed
  120. zfilled(jk) = zfilled(jk) + solcp(ji,jk,js)
  121. ENDDO
  122. ENDDO
  123. DO js = 1, jpsol
  124. DO jk = 2, jpksed
  125. zsolcpno(jk,js) = solcp(ji,jk,js) / zfilled(jk)
  126. ENDDO
  127. ENDDO
  128. ! burial 3 cases:
  129. ! zwb > 0 ==> rain > total rection loss
  130. ! zwb = 0 ==> rain = 0
  131. ! zwb < 0 ==> rain > 0 and rain < total reaction loss
  132. !----------------------------------------------------------------
  133. IF( zwb(ji,jpksed) > 0. ) THEN
  134. zfull (jpksed) = zfilled(jpksed)
  135. zempty(jpksed) = 1. - zfull(jpksed)
  136. DO jk = jpksedm1, 2, -1
  137. zfull (jk) = zfilled(jk)
  138. zfull (jk) = zfull(jk) - zempty(jk+1) * dvolsp(jk)
  139. zempty(jk) = 1. - zfull(jk)
  140. ENDDO
  141. ! Computation of solid sediment species
  142. !--------------------------------------
  143. ! push entire sediment column downward to account rest of rain
  144. DO js = 1, jpsol
  145. DO jk = jpksed, 3, -1
  146. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
  147. ENDDO
  148. solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
  149. DO jk = 2, jpksed
  150. zsolcpno(jk,js) = solcp(ji,jk,js)
  151. END DO
  152. ENDDO
  153. zrest = zwb(ji,jpksed) * cpor
  154. ! what is remaining is less than dz(2)
  155. IF( zrest <= dz(2) ) THEN
  156. zfromup(2) = zrest / dz(2)
  157. DO jk = 3, jpksed
  158. zfromup(jk) = zwb(ji,jpksed) * ckpor(jk) / dz(jk)
  159. ENDDO
  160. DO js = 1, jpsol
  161. zfromce = 1. - zfromup(2)
  162. solcp(ji,2,js) = zfromce * zsolcpno(2,js) + zfromup(2) * zrainrf(ji,js)
  163. DO jk = 3, jpksed
  164. zfromce = 1. - zfromup(jk)
  165. solcp(ji,jk,js) = zfromce * zsolcpno(jk,js) + zfromup(jk) * zsolcpno(jk-1,js)
  166. ENDDO
  167. fromsed(ji,js) = 0.
  168. ! quantities to push in deeper sediment
  169. tosed (ji,js) = zsolcpno(jpksed,js) &
  170. & * zwb(ji,jpksed) * dens * por1(jpksed) / mol_wgt(js)
  171. ENDDO
  172. ELSE ! what is remaining is great than dz(2)
  173. ntimes = INT( zrest / dz(2) ) + 1
  174. IF( ntimes > nztime ) THEN
  175. WRITE( numsed,* ) ' sedadv : rest too large at sediment point ji = ', ji
  176. STOP
  177. ENDIF
  178. zraipush(1) = dz(2)
  179. zrest = zrest - zraipush(1)
  180. DO jn = 2, ntimes
  181. IF( zrest >= dz(2) ) THEN
  182. zraipush(jn) = dz(2)
  183. zrest = zrest - zraipush(jn)
  184. ELSE
  185. zraipush(jn) = zrest
  186. zrest = 0.
  187. ENDIF
  188. ENDDO
  189. DO jn = 1, ntimes
  190. DO js = 1, jpsol
  191. DO jk = 2, jpksed
  192. zsolcpno(jk,js) = solcp(ji,jk,js)
  193. END DO
  194. ENDDO
  195. zfromup(2) = zraipush(jn) / dz(2)
  196. DO jk = 3, jpksed
  197. zfromup(jk) = ( zraipush(jn) / dz(jk) ) * c2por(jk)
  198. ENDDO
  199. DO js = 1, jpsol
  200. zfromce = 1. - zfromup(2)
  201. solcp(ji,2,js) = zfromce * zsolcpno(2,js) + zfromup(2) * zrainrf(ji,js)
  202. DO jk = 3, jpksed
  203. zfromce = 1. - zfromup(jk)
  204. solcp(ji,jk,js) = zfromce * zsolcpno(jk,js) + zfromup(jk) * zsolcpno(jk-1,js)
  205. ENDDO
  206. fromsed(ji,js) = 0.
  207. tosed (ji,js) = tosed(ji,js) + zsolcpno(jpksed,js) * zraipush(jn) &
  208. & * dens * por1(2) / mol_wgt(js)
  209. ENDDO
  210. ENDDO
  211. ENDIF
  212. ELSE IF( raintg(ji) < eps ) THEN ! rain = 0
  213. !! Nadia rloss(:,:) = rainrm(:,:) bug ??????
  214. rloss(ji,1:jpsol) = rainrm(ji,1:jpsol)
  215. zfull (2) = zfilled(2)
  216. zempty(2) = 1. - zfull(2)
  217. DO jk = 3, jpksed
  218. zfull (jk) = zfilled(jk)
  219. zfull (jk) = zfull (jk) - zempty(jk-1) * dvolsm(jk)
  220. zempty(jk) = 1. - zfull(jk)
  221. ENDDO
  222. ! fill boxes with weight fraction from underlying box
  223. DO js = 1, jpsol
  224. DO jk = 2, jpksedm1
  225. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js)
  226. END DO
  227. solcp(ji,jpksed,js) = zsolcpno(jpksed,js) * zfull(jpksed)
  228. tosed (ji,js) = 0.
  229. fromsed(ji,js) = 0.
  230. ENDDO
  231. ! for the last layer, one make go up clay
  232. solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
  233. !! C. Heinze fromsed(ji,jsclay) = zempty(jpksed) * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
  234. fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
  235. ELSE ! rain > 0 and rain < total reaction loss
  236. DO jk = 2, jpksed
  237. zfull (jk) = zfilled(jk)
  238. zempty(jk) = 1. - zfull(jk)
  239. ENDDO
  240. ! Determination of indice of layer - ikwneg - where advection is reversed
  241. !------------------------------------------------------------------------
  242. iflag: DO jk = 2, jpksed
  243. IF( zwb(ji,jk) < 0. ) THEN
  244. ikwneg = jk
  245. EXIT iflag
  246. ENDIF
  247. ENDDO iflag
  248. ! computation of zfull and zempty
  249. ! 3 cases : a/ ikwneg=2, b/ikwneg=3...jpksedm1, c/ikwneg=jpksed
  250. !-------------------------------------------------------------
  251. IF( ikwneg == 2 ) THEN ! advection is reversed in the first sediment layer
  252. zkwnup = rdtsed(ikwneg) * raintg(ji) / dz(ikwneg)
  253. zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
  254. zfull (ikwneg+1) = zfilled(ikwneg+1) - zkwnlo * dvolsm(ikwneg+1)
  255. zempty(ikwneg+1) = 1. - zfull(ikwneg+1)
  256. DO jk = ikwneg+2, jpksed
  257. zfull (jk) = zfilled(jk) - zempty(jk-1) * dvolsm(jk)
  258. zempty(jk) = 1. - zfull(jk)
  259. ENDDO
  260. DO js = 1, jpsol
  261. solcp(ji,2,js) = zfull(2) * zsolcpno(2,js)+ zkwnlo * zsolcpno(3,js) &
  262. & + zkwnup * zrainrf(ji,js)
  263. DO jk = 3, jpksedm1
  264. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js)
  265. ENDDO
  266. solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
  267. tosed(ji,js) = 0.
  268. fromsed(ji,js) = 0.
  269. ENDDO
  270. solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
  271. !! C. Heinze fromsed(ji,jsclay) = zempty(jpksed) * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
  272. fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
  273. ELSE IF( ikwneg == jpksed ) THEN
  274. zkwnup = ABS( zwb(ji,ikwneg-1) ) * dvolsm(ikwneg) / dz(ikwneg)
  275. zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
  276. zfull (ikwneg-1) = zfilled(ikwneg-1) - zkwnup * dvolsp(ikwneg-1)
  277. zempty(ikwneg-1) = 1. - zfull(ikwneg-1)
  278. DO jk = ikwneg-2, 2, -1
  279. zfull (jk) = zfilled(jk) - zempty(jk+1) * dvolsp(jk)
  280. zempty(jk) = 1. - zfull(jk)
  281. ENDDO
  282. DO js = 1, jpsol
  283. solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
  284. ENDDO
  285. DO js = 1, jpsol
  286. DO jk = jpksedm1, 3, -1
  287. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
  288. ENDDO
  289. solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js) &
  290. & + zkwnup * zsolcpno(jpksedm1,js)
  291. tosed(ji,js) = 0.
  292. fromsed(ji,js) = 0.
  293. ENDDO
  294. solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zkwnlo * 1.
  295. ! Heinze fromsed(ji,jsclay) = zkwnlo * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
  296. fromsed(ji,jsclay) = zkwnlo * 1.* por1clay
  297. ELSE ! 2 < ikwneg(ji) <= jpksedm1
  298. zkwnup = ABS( zwb(ji,ikwneg-1) ) * por1(ikwneg-1) / ( dz(ikwneg) * por1(ikwneg) )
  299. zkwnlo = ABS( zwb(ji,ikwneg) ) / dz(ikwneg)
  300. IF( ikwneg > 3 ) THEN
  301. zfull (ikwneg-1) = zfilled(ikwneg-1) - zkwnup * dvolsp(ikwneg-1)
  302. zempty(ikwneg-1) = 1. - zfull(ikwneg-1)
  303. DO jk = ikwneg-2, 2, -1
  304. zfull (jk) = zfilled(jk) - zempty(jk+1) * dvolsp(jk)
  305. zempty(jk) = 1. - zfull(jk)
  306. ENDDO
  307. DO js = 1, jpsol
  308. solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
  309. ENDDO
  310. DO js = 1, jpsol
  311. DO jk = ikwneg-1, 3, -1
  312. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk-1,js)
  313. ENDDO
  314. ENDDO
  315. ELSE ! ikw = 3
  316. zfull (2) = zfilled(2) - zkwnup * dvolsm(3)
  317. zempty(2) = 1. - zfull(2)
  318. DO js = 1, jpsol
  319. solcp(ji,2,js) = zfull(2) * zsolcpno(2,js) + zempty(2) * zrainrf(ji,js)
  320. ENDDO
  321. ENDIF
  322. IF( ikwneg < jpksedm1) THEN
  323. zfull (ikwneg+1) = zfilled(ikwneg+1) - zkwnlo * dvolsm(ikwneg+1)
  324. zempty(ikwneg+1) = 1. - zfull(ikwneg+1)
  325. DO jk = ikwneg+2, jpksed
  326. zfull (jk) = zfilled(jk) - zempty(jk-1) * dvolsm(jk)
  327. zempty(jk) = 1. - zfull(jk)
  328. ENDDO
  329. DO js = 1, jpsol
  330. DO jk = ikwneg+1, jpksedm1
  331. solcp(ji,jk,js) = zfull(jk) * zsolcpno(jk,js) + zempty(jk) * zsolcpno(jk+1,js)
  332. ENDDO
  333. solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
  334. ENDDO
  335. solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
  336. ELSE
  337. zfull (jpksed) = zfilled(jpksed) - zkwnlo * dvolsm(jpksed)
  338. zempty(jpksed) = 1. - zfull(jpksed)
  339. DO js = 1, jpsol
  340. solcp(ji,jpksed,js) = zfull(jpksed) * zsolcpno(jpksed,js)
  341. ENDDO
  342. solcp(ji,jpksed,jsclay) = solcp(ji,jpksed,jsclay) + zempty(jpksed) * 1.
  343. ENDIF ! jpksedm1
  344. ! ikwneg = jpksedm1 ; ikwneg+1 = jpksed ; ikwneg-1 = jpksed - 2
  345. DO js = 1, jpsol
  346. solcp(ji,ikwneg,js) = zfull(ikwneg) * zsolcpno(ikwneg ,js) &
  347. & + zkwnup * zsolcpno(ikwneg-1,js) &
  348. & + zkwnlo * zsolcpno(ikwneg+1,js)
  349. tosed (ji,js) = 0.
  350. fromsed(ji,js) = 0.
  351. ENDDO
  352. ! Heinze fromsed(ji,jsclay) = zempty * 1. * dens * por1(jpksed) / mol_wgt(jsclay)
  353. fromsed(ji,jsclay) = zempty(jpksed) * 1. * por1clay
  354. ENDIF ! ikwneg(ji) = 2
  355. ENDIF ! zwb > 0
  356. ENDDO ! ji = 1, jpoce
  357. rainrm(:,:) = 0.
  358. rainrg(:,:) = 0.
  359. raintg(:) = 0.
  360. DEALLOCATE( zsolcpno )
  361. DEALLOCATE( zrainrf )
  362. DEALLOCATE( zfilled )
  363. DEALLOCATE( zfull )
  364. DEALLOCATE( zfromup )
  365. DEALLOCATE( zempty )
  366. DEALLOCATE( zgap )
  367. DEALLOCATE( zwb )
  368. END SUBROUTINE sed_adv
  369. #else
  370. !!======================================================================
  371. !! MODULE sedbtb : Dummy module
  372. !!======================================================================
  373. !! $Id: sedadv.F90 2355 2015-05-20 07:11:50Z ufla $
  374. CONTAINS
  375. SUBROUTINE sed_adv( kt ) ! Empty routine
  376. INTEGER, INTENT(in) :: kt
  377. WRITE(*,*) 'sed_adv: You should not have seen this print! error?', kt
  378. END SUBROUTINE sed_adv
  379. !!======================================================================
  380. #endif
  381. END MODULE sedadv