sedmbc.F90 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. MODULE sedmbc
  2. #if defined key_sed
  3. !!======================================================================
  4. !! *** MODULE sedmbc ***
  5. !! Sediment : mass balance calculation
  6. !!=====================================================================
  7. !!----------------------------------------------------------------------
  8. !! sed_mbc :
  9. !!----------------------------------------------------------------------
  10. !! * Modules used
  11. USE sed ! sediment global variable
  12. USE seddsr
  13. IMPLICIT NONE
  14. PRIVATE
  15. !! * Routine accessibility
  16. PUBLIC sed_mbc
  17. !! * Module variables
  18. REAL(wp), DIMENSION(jpsol) :: rain_tot ! total input rain
  19. REAL(wp), DIMENSION(jpsol) :: fromsed_tot ! tota input from sediment
  20. REAL(wp), DIMENSION(jpsol) :: tosed_tot ! total output from sediment
  21. REAL(wp), DIMENSION(jpsol) :: rloss_tot ! total rain loss
  22. REAL(wp), DIMENSION(jpwat) :: diss_in_tot ! total input in pore water
  23. REAL(wp), DIMENSION(jpwat) :: diss_out_tot ! total output from pore water
  24. REAL(wp) :: cons_tot_o2 ! cumulative o2 consomation
  25. REAL(wp) :: sour_tot_no3 ! cumulative no3 source
  26. REAL(wp) :: cons_tot_no3 ! cumulative no3 consomation
  27. REAL(wp) :: sour_tot_c13 ! cumulative o2 source
  28. REAL(wp) :: src13p
  29. REAL(wp) :: src13ca
  30. !! $Id: sedmbc.F90 2355 2015-05-20 07:11:50Z ufla $
  31. CONTAINS
  32. SUBROUTINE sed_mbc( kt )
  33. !!----------------------------------------------------------------------
  34. !! *** ROUTINE sed_mbc ***
  35. !!
  36. !! ** Purpose : computation of total tracer inventories for checking
  37. !! mass conservation.
  38. !!
  39. !!
  40. !! ** Method : tracer inventories of each reservoir are computed and added
  41. !! subsequently.
  42. !!
  43. !! History :
  44. !! ! 04-10 (N. Emprin, M. Gehlen ) Original code
  45. !! ! 06-07 (C. Ethe) Re-organization
  46. !!----------------------------------------------------------------------
  47. !! Arguments
  48. INTEGER, INTENT(in) :: kt ! time step
  49. !! local declarations
  50. INTEGER :: ji,js, jw, jk
  51. REAL(wp) :: zinit, zfinal
  52. REAL(wp) :: zinput, zoutput
  53. REAL(wp) :: zdsw, zvol
  54. REAL, DIMENSION(jpsol) :: zsolcp_inv_i, zsolcp_inv_f
  55. REAL, DIMENSION(jpwat) :: zpwcp_inv_i, zpwcp_inv_f
  56. REAL(wp) :: zdelta_sil, zdelta_clay
  57. REAL(wp) :: zdelta_co2, zdelta_oxy
  58. REAL(wp) :: zdelta_po4, zdelta_no3
  59. REAL(wp) :: zdelta_c13, zdelta_c13b
  60. !!----------------------------------------------------------------------
  61. ! Initilization
  62. !---------------
  63. IF( kt == nitsed000 ) THEN
  64. cons_tot_o2 = 0.
  65. sour_tot_no3 = 0.
  66. cons_tot_no3 = 0.
  67. sour_tot_c13 = 0.
  68. DO js = 1, jpsol
  69. rain_tot (js) = 0.
  70. fromsed_tot(js) = 0.
  71. tosed_tot (js) = 0.
  72. rloss_tot (js) = 0.
  73. ENDDO
  74. DO jw = 1, jpwat
  75. diss_in_tot (jw) = 0.
  76. diss_out_tot(jw) = 0.
  77. ENDDO
  78. src13p = rc13P * pdb
  79. src13ca = rc13Ca * pdb
  80. ENDIF
  81. ! Calculation of the cumulativ input and output
  82. ! for mass balance check
  83. !----------------------------------------------
  84. ! cumulativ solid
  85. DO js = 1, jpsol
  86. DO ji = 1, jpoce
  87. ! input [mol]
  88. rain_tot (js) = rain_tot (js) + dtsed * rainrm_dta(ji,js)
  89. fromsed_tot(js) = fromsed_tot(js) + fromsed(ji,js)
  90. ! output [mol]
  91. tosed_tot (js) = tosed_tot (js) + tosed(ji,js)
  92. rloss_tot (js) = rloss_tot (js) + rloss(ji,js)
  93. ENDDO
  94. ENDDO
  95. ! cumulativ dissolved
  96. DO jw = 1, jpwat
  97. DO ji = 1, jpoce
  98. ! input [mol]
  99. diss_in_tot (jw) = diss_in_tot (jw) + pwcp_dta(ji,jw) * 1.e-3 * dzkbot(ji)
  100. ! output [mol]
  101. diss_out_tot(jw) = diss_out_tot(jw) + tokbot(ji,jw)
  102. ENDDO
  103. ENDDO
  104. ! cumulativ o2 and no3 consomation
  105. DO ji = 1, jpoce
  106. cons_tot_o2 = cons_tot_o2 + cons_o2 (ji)
  107. sour_tot_no3 = sour_tot_no3 + sour_no3(ji)
  108. cons_tot_no3 = cons_tot_no3 + cons_no3(ji)
  109. sour_tot_c13 = sour_tot_c13 + sour_c13(ji)
  110. ENDDO
  111. ! Mass balance check
  112. !---------------------
  113. IF( kt == nitsedend ) THEN
  114. ! initial and final inventories for solid component (mole/dx.dy) in sediment
  115. zsolcp_inv_i(:) = 0.
  116. zsolcp_inv_f(:) = 0.
  117. zpwcp_inv_i (:) = 0.
  118. zpwcp_inv_f (:) = 0.
  119. DO js = 1, jpsol
  120. zdsw = dens / mol_wgt(js)
  121. DO jk = 2, jpksed
  122. DO ji = 1, jpoce
  123. zvol = vols3d(ji,jk) * zdsw
  124. zsolcp_inv_i(js) = zsolcp_inv_i(js) + solcp0(ji,jk,js) * zvol
  125. zsolcp_inv_f(js) = zsolcp_inv_f(js) + solcp (ji,jk,js) * zvol
  126. ENDDO
  127. END DO
  128. ENDDO
  129. ! initial and final inventories for dissolved component (mole/dx.dy) in sediment
  130. DO jw = 1, jpwat
  131. DO jk = 2, jpksed
  132. DO ji = 1, jpoce
  133. zvol = volw3d(ji,jk) * 1.e-3
  134. zpwcp_inv_i(jw) = zpwcp_inv_i(jw) + pwcp0(ji,jk,jw) * zvol
  135. zpwcp_inv_f(jw) = zpwcp_inv_f(jw) + pwcp (ji,jk,jw) * zvol
  136. ENDDO
  137. END DO
  138. ENDDO
  139. ! mass balance for Silica/opal
  140. zinit = zsolcp_inv_i(jsopal) + zpwcp_inv_i(jwsil)
  141. zfinal = zsolcp_inv_f(jsopal) + zpwcp_inv_f(jwsil)
  142. zinput = rain_tot (jsopal) + diss_in_tot (jwsil)
  143. zoutput = tosed_tot (jsopal) + rloss_tot (jsopal) + diss_out_tot(jwsil)
  144. zdelta_sil = ( zfinal + zoutput ) - ( zinit + zinput )
  145. ! mass balance for Clay
  146. zinit = zsolcp_inv_i(jsclay)
  147. zfinal = zsolcp_inv_f(jsclay)
  148. zinput = rain_tot (jsclay) + fromsed_tot(jsclay)
  149. zoutput = tosed_tot (jsclay) + rloss_tot (jsclay)
  150. zdelta_clay= ( zfinal + zoutput ) - ( zinit + zinput )
  151. ! mass balance for carbon ( carbon in POC, CaCo3, DIC )
  152. zinit = zsolcp_inv_i(jspoc) + zsolcp_inv_i(jscal) + zpwcp_inv_i(jwdic)
  153. zfinal = zsolcp_inv_f(jspoc) + zsolcp_inv_f(jscal) + zpwcp_inv_f(jwdic)
  154. zinput = rain_tot (jspoc) + rain_tot (jscal) + diss_in_tot(jwdic)
  155. zoutput = tosed_tot (jspoc) + tosed_tot (jscal) + diss_out_tot(jwdic) &
  156. & + rloss_tot (jspoc) + rloss_tot (jscal)
  157. zdelta_co2 = ( zfinal + zoutput ) - ( zinit + zinput )
  158. ! mass balance for oxygen : O2 is in POC remineralization
  159. zinit = zpwcp_inv_i(jwoxy)
  160. zfinal = zpwcp_inv_f(jwoxy)
  161. zinput = diss_in_tot(jwoxy)
  162. zoutput = diss_out_tot(jwoxy) + cons_tot_o2
  163. zdelta_oxy = ( zfinal + zoutput ) - ( zinit + zinput )
  164. ! mass balance for phosphate ( PO4 in POC and dissolved phosphates )
  165. zinit = zsolcp_inv_i(jspoc) * spo4r + zpwcp_inv_i(jwpo4)
  166. zfinal = zsolcp_inv_f(jspoc) * spo4r + zpwcp_inv_f(jwpo4)
  167. zinput = rain_tot (jspoc) * spo4r + diss_in_tot(jwpo4)
  168. zoutput = tosed_tot (jspoc) * spo4r + diss_out_tot(jwpo4) &
  169. & + rloss_tot (jspoc) * spo4r
  170. zdelta_po4 = ( zfinal + zoutput ) - ( zinit + zinput )
  171. ! mass balance for Nitrate
  172. zinit = zpwcp_inv_i (jwno3)
  173. zfinal = zpwcp_inv_f (jwno3)
  174. zinput = diss_in_tot (jwno3) + sour_tot_no3
  175. zoutput = diss_out_tot(jwno3) + cons_tot_no3
  176. zdelta_no3 = ( zfinal + zoutput ) - ( zinit + zinput )
  177. ! mass balance for DIC13
  178. zinit = zpwcp_inv_i(jwc13) &
  179. & + src13p * zsolcp_inv_i(jspoc) + src13Ca * zsolcp_inv_i(jscal)
  180. zfinal = zpwcp_inv_f(jwc13) &
  181. & + src13p * zsolcp_inv_f(jspoc) + src13Ca * zsolcp_inv_f(jscal)
  182. zinput = diss_in_tot (jwc13) &
  183. & + src13p * rain_tot(jspoc) + src13Ca * rain_tot(jscal)
  184. zoutput = diss_out_tot(jwc13) &
  185. & + src13p * tosed_tot(jspoc) + src13Ca * tosed_tot(jscal) &
  186. & + src13p * rloss_tot(jspoc) + src13Ca * rloss_tot(jscal)
  187. zdelta_c13 = ( zfinal + zoutput ) - ( zinit + zinput )
  188. ! other mass balance for DIC13
  189. zinit = zpwcp_inv_i (jwc13)
  190. zfinal = zpwcp_inv_f (jwc13)
  191. zinput = diss_in_tot (jwc13) + sour_tot_c13
  192. zoutput = diss_out_tot(jwc13)
  193. zdelta_c13b= ( zfinal + zoutput ) - ( zinit + zinput )
  194. END IF
  195. IF( kt == nitsedend) THEN
  196. WRITE(numsed,*)
  197. WRITE(numsed,*)'================== General mass balance ================== '
  198. WRITE(numsed,*)' '
  199. WRITE(numsed,*)' '
  200. WRITE(numsed,*)' Initial total solid Masses (mole/dx.dy) (k=2-11) '
  201. WRITE(numsed,*)' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  202. WRITE(numsed,*)' Opale, Clay, POC, CaCO3, C13'
  203. WRITE(numsed,'(4x,5(1PE10.3,2X))')zsolcp_inv_i(jsopal),zsolcp_inv_i(jsclay),zsolcp_inv_i(jspoc), &
  204. & zsolcp_inv_i(jscal),( src13P * zsolcp_inv_i(jspoc) + src13Ca * zsolcp_inv_i(jscal) )
  205. WRITE(numsed,*)' '
  206. WRITE(numsed,*)' Initial total dissolved Masses (mole/dx.dy) (k=2-11) '
  207. WRITE(numsed,*)' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  208. WRITE(numsed,*)' Si, O2, DIC, Nit Phos, DIC13'
  209. WRITE(numsed,'(4x,6(1PE10.3,2X))') zpwcp_inv_i(jwsil), zpwcp_inv_i(jwoxy), &
  210. & zpwcp_inv_i(jwdic), zpwcp_inv_i(jwno3), zpwcp_inv_i(jwpo4), zpwcp_inv_i(jwc13)
  211. WRITE(numsed,*)' '
  212. WRITE(numsed,*)' Solid inputs : Opale, Clay, POC, CaCO3, C13'
  213. WRITE(numsed,'(A4,10X,5(1PE10.3,2X))')'Rain : ',rain_tot(jsopal),rain_tot(jsclay),rain_tot(jspoc),&
  214. & rain_tot(jscal),( src13P * rain_tot(jspoc) + src13Ca * rain_tot(jscal) )
  215. WRITE(numsed,'(A12,6x,4(1PE10.3,2X))')' From Sed : ',fromsed_tot(jsopal), fromsed_tot(jsclay), &
  216. & fromsed_tot(jspoc), fromsed_tot(jscal)
  217. WRITE(numsed,*)'Diss. inputs : Si, O2, DIC, Nit, Phos, DIC13'
  218. WRITE(numsed,'(A9,1x,6(1PE10.3,2X))')' From Pisc : ', diss_in_tot(jwsil), &
  219. & diss_in_tot(jwoxy), diss_in_tot(jwdic), diss_in_tot(jwno3), diss_in_tot(jwpo4), &
  220. & diss_in_tot(jwc13)
  221. WRITE(numsed,*)' '
  222. WRITE(numsed,*)'Solid output : Opale, Clay, POC, CaCO3, C13'
  223. WRITE(numsed,'(A6,8x,5(1PE10.3,2X))')'To sed', tosed_tot(jsopal),tosed_tot(jsclay),tosed_tot(jspoc),&
  224. & tosed_tot(jscal),( src13P * tosed_tot(jspoc) + src13Ca * tosed_tot(jscal) )
  225. WRITE(numsed,'(A5,9x,5(1PE10.3,2X))')'Perdu', rloss_tot(jsopal),rloss_tot(jsclay),rloss_tot(jspoc),&
  226. & rloss_tot(jscal),( src13P * rloss_tot(jspoc) + src13Ca * rloss_tot(jscal) )
  227. WRITE(numsed,*)'Diss. output : Si, O2, DIC, Nit, Phos, DIC13 '
  228. WRITE(numsed,'(A7,2x,6(1PE10.3,2X))')'To kbot', diss_out_tot(jwsil), &
  229. & diss_out_tot(jwoxy), diss_out_tot(jwdic), diss_out_tot(jwno3), diss_out_tot(jwpo4), &
  230. & diss_out_tot(jwc13)
  231. WRITE(numsed,*)' '
  232. WRITE(numsed,*)' Total consomation in POC remineralization [mol]: O2, NO3'
  233. WRITE(numsed,'(51x,2(1PE10.3,2X))') cons_tot_o2,cons_tot_no3
  234. WRITE(numsed,*)' '
  235. WRITE(numsed,*)'Final solid Masses (mole/dx.dy) (k=2-11)'
  236. WRITE(numsed,*)' Opale, Clay, POC, CaCO3, C13'
  237. WRITE(numsed,'(4x,5(1PE10.3,2X))')zsolcp_inv_f(jsopal),zsolcp_inv_f(jsclay),zsolcp_inv_f(jspoc), &
  238. & zsolcp_inv_f(jscal),( src13P * zsolcp_inv_f(jspoc) + src13Ca * zsolcp_inv_f(jscal) )
  239. WRITE(numsed,*)' '
  240. WRITE(numsed,*)'Final dissolved Masses (mole/dx.dy) (k=2-11)'
  241. WRITE(numsed,*)' Si, O2, DIC, Nit, Phos, DIC13'
  242. WRITE(numsed,'(4x,6(1PE10.3,2X))') zpwcp_inv_f(jwsil), zpwcp_inv_f(jwoxy), &
  243. & zpwcp_inv_f(jwdic), zpwcp_inv_f(jwno3), zpwcp_inv_f(jwpo4), zpwcp_inv_f(jwc13)
  244. WRITE(numsed,*)' '
  245. WRITE(numsed,*)'Delta : Opale, Clay, C, O, N, P, C13'
  246. WRITE(numsed,'(7x,7(1PE11.3,1X))') zdelta_sil, zdelta_clay, zdelta_co2, zdelta_oxy, zdelta_no3,&
  247. & zdelta_po4, zdelta_c13
  248. WRITE(numsed,*)' '
  249. WRITE(numsed,*)'deltaC13bis : ',zdelta_c13b
  250. WRITE(numsed,*)'=========================================================================='
  251. WRITE(numsed,*)' Composition of final sediment for point jpoce'
  252. WRITE(numsed,*)' ========================================='
  253. WRITE(numsed,*)'Opale, Clay, POC, CaCo3, hipor, pH, co3por'
  254. DO jk = 1,jpksed
  255. WRITE(numsed,'(4(F8.4,4X),3(1PE10.3,2X))') solcp(jpoce,jk,jsopal)*100.,solcp(jpoce,jk,jsclay)*100.,&
  256. & solcp(jpoce,jk,jspoc)*100.,solcp(jpoce,jk,jscal)*100.,&
  257. & hipor(jpoce,jk),-LOG10(hipor(jpoce,jk)/densSW(jpoce)),co3por(jpoce,jk)
  258. ENDDO
  259. WRITE(numsed,*)'Silicic A., Oxygen, DIC, Nitrats, Phosphats, Alkal., DIC13'
  260. DO jk = 1, jpksed
  261. WRITE(numsed,'(8(1PE10.3,2X))')pwcp(jpoce,jk,jwsil),pwcp(jpoce,jk,jwoxy),&
  262. & pwcp(jpoce,jk,jwdic),pwcp(jpoce,jk,jwno3),pwcp(jpoce,jk,jwpo4),pwcp(jpoce,jk,jwalk),pwcp(jpoce,jk,jwc13)
  263. ENDDO
  264. WRITE(numsed,*)'densSW at the end : ',densSW(jpoce)
  265. WRITE(numsed,*)'=========================================================================='
  266. ENDIF
  267. END SUBROUTINE sed_mbc
  268. #else
  269. !!======================================================================
  270. !! MODULE sedmbc : Dummy module
  271. !!======================================================================
  272. !! $Id: sedmbc.F90 2355 2015-05-20 07:11:50Z ufla $
  273. CONTAINS
  274. SUBROUTINE sed_mbc( kt ) ! Empty routine
  275. INTEGER, INTENT(in) :: kt
  276. WRITE(*,*) 'sed_mbc: You should not have seen this print! error?', kt
  277. END SUBROUTINE sed_mbc
  278. #endif
  279. END MODULE sedmbc