trcdmp.F90 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. MODULE trcdmp
  2. !!======================================================================
  3. !! *** MODULE trcdmp ***
  4. !! Ocean physics: internal restoring trend on passive tracers
  5. !!======================================================================
  6. !! History : OPA ! 1991-03 (O. Marti, G. Madec) Original code
  7. !! ! 1996-01 (G. Madec) statement function for e3
  8. !! ! 1997-05 (H. Loukos) adapted for passive tracers
  9. !! NEMO 9.0 ! 2004-03 (C. Ethe) free form + modules
  10. !! 3.2 ! 2007-02 (C. Deltel) Diagnose ML trends for passive tracers
  11. !! 3.3 ! 2010-06 (C. Ethe, G. Madec) merge TRA-TRC
  12. !!----------------------------------------------------------------------
  13. #if defined key_top
  14. !!----------------------------------------------------------------------
  15. !! trc_dmp : update the tracer trend with the internal damping
  16. !! trc_dmp_init : initialization, namlist read, parameters control
  17. !!----------------------------------------------------------------------
  18. USE oce_trc ! ocean dynamics and tracers variables
  19. USE trc ! ocean passive tracers variables
  20. USE trcnam_trp ! passive tracers transport namelist variables
  21. USE trcdta
  22. USE tradmp
  23. USE prtctl_trc ! Print control for debbuging
  24. USE trdtra
  25. USE trd_oce
  26. USE iom
  27. IMPLICIT NONE
  28. PRIVATE
  29. PUBLIC trc_dmp ! routine called by step.F90
  30. PUBLIC trc_dmp_clo ! routine called by step.F90
  31. PUBLIC trc_dmp_alloc ! routine called by nemogcm.F90
  32. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: restotr ! restoring coeff. on tracers (s-1)
  33. INTEGER, PARAMETER :: npncts = 8 ! number of closed sea
  34. INTEGER, DIMENSION(npncts) :: nctsi1, nctsj1 ! south-west closed sea limits (i,j)
  35. INTEGER, DIMENSION(npncts) :: nctsi2, nctsj2 ! north-east closed sea limits (i,j)
  36. !! * Substitutions
  37. # include "top_substitute.h90"
  38. !!----------------------------------------------------------------------
  39. !! NEMO/TOP 3.3 , NEMO Consortium (2010)
  40. !! $Id: trcdmp.F90 5506 2015-06-29 15:19:38Z clevy $
  41. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  42. !!----------------------------------------------------------------------
  43. CONTAINS
  44. INTEGER FUNCTION trc_dmp_alloc()
  45. !!----------------------------------------------------------------------
  46. !! *** ROUTINE trc_dmp_alloc ***
  47. !!----------------------------------------------------------------------
  48. ALLOCATE( restotr(jpi,jpj,jpk) , STAT=trc_dmp_alloc )
  49. !
  50. IF( trc_dmp_alloc /= 0 ) CALL ctl_warn('trc_dmp_alloc: failed to allocate array')
  51. !
  52. END FUNCTION trc_dmp_alloc
  53. SUBROUTINE trc_dmp( kt )
  54. !!----------------------------------------------------------------------
  55. !! *** ROUTINE trc_dmp ***
  56. !!
  57. !! ** Purpose : Compute the passive tracer trend due to a newtonian damping
  58. !! of the tracer field towards given data field and add it to the
  59. !! general tracer trends.
  60. !!
  61. !! ** Method : Newtonian damping towards trdta computed
  62. !! and add to the general tracer trends:
  63. !! trn = tra + restotr * (trdta - trb)
  64. !! The trend is computed either throughout the water column
  65. !! (nlmdmptr=0) or in area of weak vertical mixing (nlmdmptr=1) or
  66. !! below the well mixed layer (nlmdmptr=2)
  67. !!
  68. !! ** Action : - update the tracer trends tra with the newtonian
  69. !! damping trends.
  70. !! - save the trends ('key_trdmxl_trc')
  71. !!----------------------------------------------------------------------
  72. !!
  73. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  74. !!
  75. INTEGER :: ji, jj, jk, jn, jl ! dummy loop indices
  76. REAL(wp) :: ztra ! temporary scalars
  77. CHARACTER (len=22) :: charout
  78. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrtrd
  79. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrcdta ! 3D workspace
  80. !!----------------------------------------------------------------------
  81. !
  82. IF( nn_timing == 1 ) CALL timing_start('trc_dmp')
  83. !
  84. ! 0. Initialization (first time-step only)
  85. ! --------------
  86. IF( kt == nittrc000 ) CALL trc_dmp_init
  87. IF( l_trdtrc ) CALL wrk_alloc( jpi, jpj, jpk, ztrtrd ) ! temporary save of trends
  88. !
  89. IF( nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping
  90. !
  91. CALL wrk_alloc( jpi, jpj, jpk, ztrcdta ) ! Memory allocation
  92. ! ! ===========
  93. DO jn = 1, jptra ! tracer loop
  94. ! ! ===========
  95. IF( l_trdtrc ) ztrtrd(:,:,:) = tra(:,:,:,jn) ! save trends
  96. !
  97. IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file
  98. jl = n_trc_index(jn)
  99. CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta ) ! read tracer data at nit000
  100. SELECT CASE ( nn_zdmp_tr )
  101. !
  102. CASE( 0 ) !== newtonian damping throughout the water column ==!
  103. DO jk = 1, jpkm1
  104. DO jj = 2, jpjm1
  105. DO ji = fs_2, fs_jpim1 ! vector opt.
  106. ztra = restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
  107. tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
  108. END DO
  109. END DO
  110. END DO
  111. !
  112. CASE ( 1 ) !== no damping in the turbocline (avt > 5 cm2/s) ==!
  113. DO jk = 1, jpkm1
  114. DO jj = 2, jpjm1
  115. DO ji = fs_2, fs_jpim1 ! vector opt.
  116. IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
  117. ztra = restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
  118. tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
  119. ENDIF
  120. END DO
  121. END DO
  122. END DO
  123. !
  124. CASE ( 2 ) !== no damping in the mixed layer ==!
  125. DO jk = 1, jpkm1
  126. DO jj = 2, jpjm1
  127. DO ji = fs_2, fs_jpim1 ! vector opt.
  128. IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
  129. ztra = restotr(ji,jj,jk) * ( ztrcdta(ji,jj,jk) - trb(ji,jj,jk,jn) )
  130. tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn) + ztra
  131. END IF
  132. END DO
  133. END DO
  134. END DO
  135. !
  136. END SELECT
  137. !
  138. ENDIF
  139. !
  140. IF( l_trdtrc ) THEN
  141. ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
  142. CALL trd_tra( kt, 'TRC', jn, jptra_dmp, ztrtrd )
  143. END IF
  144. ! ! ===========
  145. END DO ! tracer loop
  146. ! ! ===========
  147. CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
  148. ENDIF
  149. !
  150. IF( l_trdtrc ) CALL wrk_dealloc( jpi, jpj, jpk, ztrtrd )
  151. ! ! print mean trends (used for debugging)
  152. IF( ln_ctl ) THEN
  153. WRITE(charout, FMT="('dmp ')") ; CALL prt_ctl_trc_info(charout)
  154. CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
  155. ENDIF
  156. !
  157. IF( nn_timing == 1 ) CALL timing_stop('trc_dmp')
  158. !
  159. END SUBROUTINE trc_dmp
  160. SUBROUTINE trc_dmp_clo( kt )
  161. !!---------------------------------------------------------------------
  162. !! *** ROUTINE trc_dmp_clo ***
  163. !!
  164. !! ** Purpose : Closed sea domain initialization
  165. !!
  166. !! ** Method : if a closed sea is located only in a model grid point
  167. !! we restore to initial data
  168. !!
  169. !! ** Action : nctsi1(), nctsj1() : south-west closed sea limits (i,j)
  170. !! nctsi2(), nctsj2() : north-east Closed sea limits (i,j)
  171. !!----------------------------------------------------------------------
  172. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  173. !
  174. INTEGER :: ji , jj, jk, jn, jl, jc ! dummy loop indicesa
  175. INTEGER :: isrow ! local index
  176. REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrcdta ! 3D workspace
  177. !!----------------------------------------------------------------------
  178. IF( kt == nit000 ) THEN
  179. ! initial values
  180. nctsi1(:) = 1 ; nctsi2(:) = 1
  181. nctsj1(:) = 1 ; nctsj2(:) = 1
  182. ! set the closed seas (in data domain indices)
  183. ! -------------------
  184. IF( cp_cfg == "orca" ) THEN
  185. !
  186. SELECT CASE ( jp_cfg )
  187. ! ! =======================
  188. CASE ( 1 ) ! eORCA_R1 configuration
  189. ! ! =======================
  190. isrow = 332 - jpjglo
  191. !
  192. ! Caspian Sea
  193. nctsi1(1) = 333 ; nctsj1(1) = 243 - isrow
  194. nctsi2(1) = 342 ; nctsj2(1) = 274 - isrow
  195. ! ! Lake Superior
  196. nctsi1(2) = 198 ; nctsj1(2) = 258 - isrow
  197. nctsi2(2) = 204 ; nctsj2(2) = 262 - isrow
  198. ! ! Lake Michigan
  199. nctsi1(3) = 201 ; nctsj1(3) = 250 - isrow
  200. nctsi2(3) = 203 ; nctsj2(3) = 256 - isrow
  201. ! ! Lake Huron
  202. nctsi1(4) = 204 ; nctsj1(4) = 252 - isrow
  203. nctsi2(4) = 209 ; nctsj2(4) = 256 - isrow
  204. ! ! Lake Erie
  205. nctsi1(5) = 206 ; nctsj1(5) = 249 - isrow
  206. nctsi2(5) = 209 ; nctsj2(5) = 251 - isrow
  207. ! ! Lake Ontario
  208. nctsi1(6) = 210 ; nctsj1(6) = 252 - isrow
  209. nctsi2(6) = 212 ; nctsj2(6) = 252 - isrow
  210. ! ! Victoria Lake
  211. nctsi1(7) = 321 ; nctsj1(7) = 180 - isrow
  212. nctsi2(7) = 322 ; nctsj2(7) = 189 - isrow
  213. ! ! Baltic Sea
  214. nctsi1(8) = 297 ; nctsj1(8) = 270 - isrow
  215. nctsi2(8) = 308 ; nctsj2(8) = 293 - isrow
  216. !
  217. ! ! =======================
  218. CASE ( 2 ) ! ORCA_R2 configuration
  219. ! ! =======================
  220. ! ! Caspian Sea
  221. nctsi1(1) = 11 ; nctsj1(1) = 103
  222. nctsi2(1) = 17 ; nctsj2(1) = 112
  223. ! ! Great North American Lakes
  224. nctsi1(2) = 97 ; nctsj1(2) = 107
  225. nctsi2(2) = 103 ; nctsj2(2) = 111
  226. ! ! Black Sea 1 : west part of the Black Sea
  227. nctsi1(3) = 174 ; nctsj1(3) = 107
  228. nctsi2(3) = 181 ; nctsj2(3) = 112
  229. ! ! Black Sea 2 : est part of the Black Sea
  230. nctsi1(4) = 2 ; nctsj1(4) = 107
  231. nctsi2(4) = 6 ; nctsj2(4) = 112
  232. ! ! Baltic Sea
  233. nctsi1(5) = 145 ; nctsj1(5) = 116
  234. nctsi2(5) = 150 ; nctsj2(5) = 126
  235. ! ! =======================
  236. CASE ( 4 ) ! ORCA_R4 configuration
  237. ! ! =======================
  238. ! ! Caspian Sea
  239. nctsi1(1) = 4 ; nctsj1(1) = 53
  240. nctsi2(1) = 4 ; nctsj2(1) = 56
  241. ! ! Great North American Lakes
  242. nctsi1(2) = 49 ; nctsj1(2) = 55
  243. nctsi2(2) = 51 ; nctsj2(2) = 56
  244. ! ! Black Sea
  245. nctsi1(3) = 88 ; nctsj1(3) = 55
  246. nctsi2(3) = 91 ; nctsj2(3) = 56
  247. ! ! Baltic Sea
  248. nctsi1(4) = 75 ; nctsj1(4) = 59
  249. nctsi2(4) = 76 ; nctsj2(4) = 61
  250. ! ! =======================
  251. CASE ( 025 ) ! ORCA_R025 configuration
  252. ! ! =======================
  253. ! Caspian + Aral sea
  254. nctsi1(1) = 1330 ; nctsj1(1) = 645
  255. nctsi2(1) = 1400 ; nctsj2(1) = 795
  256. ! ! Azov Sea
  257. nctsi1(2) = 1284 ; nctsj1(2) = 722
  258. nctsi2(2) = 1304 ; nctsj2(2) = 747
  259. !
  260. END SELECT
  261. !
  262. ENDIF
  263. !
  264. ! convert the position in local domain indices
  265. ! --------------------------------------------
  266. DO jc = 1, npncts
  267. nctsi1(jc) = mi0( nctsi1(jc) )
  268. nctsj1(jc) = mj0( nctsj1(jc) )
  269. nctsi2(jc) = mi1( nctsi2(jc) )
  270. nctsj2(jc) = mj1( nctsj2(jc) )
  271. END DO
  272. !
  273. ENDIF
  274. ! Restore close seas values to initial data
  275. IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping
  276. !
  277. IF(lwp) WRITE(numout,*)
  278. IF(lwp) WRITE(numout,*) ' trc_dmp_clo : Restoring of nutrients on close seas at time-step kt = ', kt
  279. IF(lwp) WRITE(numout,*)
  280. !
  281. CALL wrk_alloc( jpi, jpj, jpk, ztrcdta ) ! Memory allocation
  282. !
  283. DO jn = 1, jptra
  284. IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file
  285. jl = n_trc_index(jn)
  286. CALL trc_dta( kt, sf_trcdta(jl), rf_trfac(jl), ztrcdta ) ! read tracer data at nit000
  287. DO jc = 1, npncts
  288. DO jk = 1, jpkm1
  289. DO jj = nctsj1(jc), nctsj2(jc)
  290. DO ji = nctsi1(jc), nctsi2(jc)
  291. trn(ji,jj,jk,jn) = ztrcdta(ji,jj,jk)
  292. trb(ji,jj,jk,jn) = trn(ji,jj,jk,jn)
  293. ENDDO
  294. ENDDO
  295. ENDDO
  296. ENDDO
  297. ENDIF
  298. ENDDO
  299. CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
  300. ENDIF
  301. !
  302. END SUBROUTINE trc_dmp_clo
  303. SUBROUTINE trc_dmp_init
  304. !!----------------------------------------------------------------------
  305. !! *** ROUTINE trc_dmp_init ***
  306. !!
  307. !! ** Purpose : Initialization for the newtonian damping
  308. !!
  309. !! ** Method : read the nammbf namelist and check the parameters
  310. !! called by trc_dmp at the first timestep (nittrc000)
  311. !!----------------------------------------------------------------------
  312. !
  313. INTEGER :: imask !local file handle
  314. IF( nn_timing == 1 ) CALL timing_start('trc_dmp_init')
  315. !
  316. !Allocate arrays
  317. IF( trc_dmp_alloc() /= 0 ) CALL ctl_stop( 'STOP', 'trc_dmp_init: unable to allocate arrays' )
  318. IF( lzoom ) nn_zdmp_tr = 0 ! restoring to climatology at closed north or south boundaries
  319. SELECT CASE ( nn_zdmp_tr )
  320. CASE ( 0 ) ; IF(lwp) WRITE(numout,*) ' tracer damping throughout the water column'
  321. CASE ( 1 ) ; IF(lwp) WRITE(numout,*) ' no tracer damping in the turbocline (avt > 5 cm2/s)'
  322. CASE ( 2 ) ; IF(lwp) WRITE(numout,*) ' no tracer damping in the mixed layer'
  323. CASE DEFAULT
  324. WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
  325. CALL ctl_stop(ctmp1)
  326. END SELECT
  327. IF( .NOT. ln_tradmp ) &
  328. & CALL ctl_stop( 'passive trace damping need key_tradmp to compute damping coef.' )
  329. !
  330. ! ! Read damping coefficients from file
  331. !Read in mask from file
  332. CALL iom_open ( cn_resto_tr, imask)
  333. CALL iom_get ( imask, jpdom_autoglo, 'resto', restotr)
  334. CALL iom_close( imask )
  335. !
  336. IF( nn_timing == 1 ) CALL timing_stop('trc_dmp_init')
  337. !
  338. END SUBROUTINE trc_dmp_init
  339. #else
  340. !!----------------------------------------------------------------------
  341. !! Dummy module : No passive tracer
  342. !!----------------------------------------------------------------------
  343. CONTAINS
  344. SUBROUTINE trc_dmp( kt ) ! Empty routine
  345. INTEGER, INTENT(in) :: kt
  346. WRITE(*,*) 'trc_dmp: You should not have seen this print! error?', kt
  347. END SUBROUTINE trc_dmp
  348. #endif
  349. !!======================================================================
  350. END MODULE trcdmp