trcini.F90 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. MODULE trcini
  2. !!======================================================================
  3. !! *** MODULE trcini ***
  4. !! TOP : Manage the passive tracer initialization
  5. !!======================================================================
  6. !! History : - ! 1991-03 (O. Marti) original code
  7. !! 1.0 ! 2005-03 (O. Aumont, A. El Moussaoui) F90
  8. !! 2.0 ! 2005-10 (C. Ethe, G. Madec) revised architecture
  9. !! 4.0 ! 2011-01 (A. R. Porter, STFC Daresbury) dynamical allocation
  10. !!----------------------------------------------------------------------
  11. #if defined key_top
  12. !!----------------------------------------------------------------------
  13. !! 'key_top' TOP models
  14. !!----------------------------------------------------------------------
  15. !! trc_init : Initialization for passive tracer
  16. !! top_alloc : allocate the TOP arrays
  17. !!----------------------------------------------------------------------
  18. USE oce_trc ! shared variables between ocean and passive tracers
  19. USE trc ! passive tracers common variables
  20. USE trcrst ! passive tracers restart
  21. USE trcnam ! Namelist read
  22. USE trcini_cfc ! CFC initialisation
  23. USE trcini_pisces ! PISCES initialisation
  24. USE trcini_c14b ! C14 bomb initialisation
  25. USE trcini_age ! AGE initialisation
  26. USE trcini_my_trc ! MY_TRC initialisation
  27. USE trcdta ! initialisation from files
  28. USE daymod ! calendar manager
  29. USE prtctl_trc ! Print control passive tracers (prt_ctl_trc_init routine)
  30. USE trcsub ! variables to substep passive tracers
  31. USE lib_mpp ! distribued memory computing library
  32. USE sbc_oce
  33. USE trcice ! tracers in sea ice
  34. IMPLICIT NONE
  35. PRIVATE
  36. PUBLIC trc_init ! called by opa
  37. !! * Substitutions
  38. # include "domzgr_substitute.h90"
  39. !!----------------------------------------------------------------------
  40. !! NEMO/TOP 4.0 , NEMO Consortium (2011)
  41. !! $Id$
  42. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  43. !!----------------------------------------------------------------------
  44. CONTAINS
  45. SUBROUTINE trc_init
  46. !!---------------------------------------------------------------------
  47. !! *** ROUTINE trc_init ***
  48. !!
  49. !! ** Purpose : Initialization of the passive tracer fields
  50. !!
  51. !! ** Method : - read namelist
  52. !! - control the consistancy
  53. !! - compute specific initialisations
  54. !! - set initial tracer fields (either read restart
  55. !! or read data or analytical formulation
  56. !!---------------------------------------------------------------------
  57. INTEGER :: jk, jn, jl ! dummy loop indices
  58. CHARACTER (len=25) :: charout
  59. !!---------------------------------------------------------------------
  60. !
  61. IF( nn_timing == 1 ) CALL timing_start('trc_init')
  62. !
  63. IF(lwp) WRITE(numout,*)
  64. IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
  65. IF(lwp) WRITE(numout,*) '~~~~~~~'
  66. CALL top_alloc() ! allocate TOP arrays
  67. l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
  68. l_trcdm2dc = l_trcdm2dc .AND. .NOT. lk_offline
  69. IF( l_trcdm2dc .AND. lwp ) &
  70. & CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. &
  71. & Computation of a daily mean shortwave for some biogeochemical models) ')
  72. IF( nn_cla == 1 ) &
  73. & CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
  74. CALL trc_nam ! read passive tracers namelists
  75. !
  76. IF(lwp) WRITE(numout,*)
  77. !
  78. IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar
  79. !
  80. IF(lwp) WRITE(numout,*)
  81. ! masked grid volume
  82. ! ! masked grid volume
  83. DO jk = 1, jpk
  84. cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
  85. END DO
  86. IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol
  87. ! ! total volume of the ocean
  88. areatot = glob_sum( cvol(:,:,:) )
  89. IF( lk_pisces ) CALL trc_ini_pisces ! PISCES bio-model
  90. IF( lk_my_trc ) CALL trc_ini_my_trc ! MY_TRC tracers
  91. IF( lk_cfc ) CALL trc_ini_cfc ! CFC tracers
  92. IF( lk_c14b ) CALL trc_ini_c14b ! C14 bomb tracer
  93. IF( lk_age ) CALL trc_ini_age ! AGE tracer
  94. CALL trc_ice_ini ! Tracers in sea ice
  95. IF( lwp ) THEN
  96. !
  97. CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
  98. !
  99. ENDIF
  100. IF( ln_trcdta ) CALL trc_dta_init(jptra)
  101. IF( ln_rsttr ) THEN
  102. !
  103. CALL trc_rst_read ! restart from a file
  104. !
  105. ELSE
  106. !
  107. IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping
  108. !
  109. DO jn = 1, jptra
  110. IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file
  111. jl = n_trc_index(jn)
  112. CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) ) ! read tracer data at nit000
  113. trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:)
  114. IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN !== deallocate data structure ==!
  115. ! (data used only for initialisation)
  116. IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
  117. DEALLOCATE( sf_trcdta(jl)%fnow ) ! arrays in the structure
  118. IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta )
  119. !
  120. ENDIF
  121. ENDIF
  122. ENDDO
  123. !
  124. ENDIF
  125. !
  126. trb(:,:,:,:) = trn(:,:,:,:)
  127. !
  128. ENDIF
  129. tra(:,:,:,:) = 0._wp
  130. !
  131. IF( nn_dttrc /= 1 ) CALL trc_sub_ini ! Initialize variables for substepping passive tracers
  132. !
  133. trai(:) = 0._wp ! initial content of all tracers
  134. DO jn = 1, jptra
  135. trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) )
  136. END DO
  137. IF(lwp) THEN ! control print
  138. WRITE(numout,*)
  139. WRITE(numout,*)
  140. WRITE(numout,*) ' *** Total number of passive tracer jptra = ', jptra
  141. WRITE(numout,*) ' *** Total volume of ocean = ', areatot
  142. WRITE(numout,*) ' *** Total inital content of all tracers '
  143. WRITE(numout,*)
  144. DO jn = 1, jptra
  145. WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
  146. ENDDO
  147. WRITE(numout,*)
  148. ENDIF
  149. IF(lwp) WRITE(numout,*)
  150. IF(ln_ctl) THEN ! print mean trends (used for debugging)
  151. CALL prt_ctl_trc_init
  152. WRITE(charout, FMT="('ini ')")
  153. CALL prt_ctl_trc_info( charout )
  154. CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
  155. ENDIF
  156. 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10)
  157. !
  158. IF( nn_timing == 1 ) CALL timing_stop('trc_init')
  159. !
  160. END SUBROUTINE trc_init
  161. SUBROUTINE top_alloc
  162. !!----------------------------------------------------------------------
  163. !! *** ROUTINE top_alloc ***
  164. !!
  165. !! ** Purpose : Allocate all the dynamic arrays of the OPA modules
  166. !!----------------------------------------------------------------------
  167. USE trcadv , ONLY: trc_adv_alloc ! TOP-related alloc routines...
  168. USE trc , ONLY: trc_alloc
  169. USE trcnxt , ONLY: trc_nxt_alloc
  170. USE trczdf , ONLY: trc_zdf_alloc
  171. USE trdtrc_oce , ONLY: trd_trc_oce_alloc
  172. #if defined key_trdmxl_trc
  173. USE trdmxl_trc , ONLY: trd_mxl_trc_alloc
  174. #endif
  175. !
  176. INTEGER :: ierr
  177. !!----------------------------------------------------------------------
  178. !
  179. ierr = trc_adv_alloc() ! Start of TOP-related alloc routines...
  180. ierr = ierr + trc_alloc ()
  181. ierr = ierr + trc_nxt_alloc()
  182. ierr = ierr + trc_zdf_alloc()
  183. ierr = ierr + trd_trc_oce_alloc()
  184. #if defined key_trdmxl_trc
  185. ierr = ierr + trd_mxl_trc_alloc()
  186. #endif
  187. !
  188. IF( lk_mpp ) CALL mpp_sum( ierr )
  189. IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
  190. !
  191. END SUBROUTINE top_alloc
  192. #else
  193. !!----------------------------------------------------------------------
  194. !! Empty module : No passive tracer
  195. !!----------------------------------------------------------------------
  196. CONTAINS
  197. SUBROUTINE trc_init ! Dummy routine
  198. END SUBROUTINE trc_init
  199. #endif
  200. !!======================================================================
  201. END MODULE trcini