[268] | 1 | MODULE trcini |
---|
[945] | 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE trcini *** |
---|
| 4 | !! TOP : Manage the passive tracer initialization |
---|
| 5 | !!====================================================================== |
---|
[2715] | 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 |
---|
[274] | 10 | !!---------------------------------------------------------------------- |
---|
[1011] | 11 | #if defined key_top |
---|
| 12 | !!---------------------------------------------------------------------- |
---|
| 13 | !! 'key_top' TOP models |
---|
| 14 | !!---------------------------------------------------------------------- |
---|
[2715] | 15 | !! trc_init : Initialization for passive tracer |
---|
| 16 | !! top_alloc : allocate the TOP arrays |
---|
[1011] | 17 | !!---------------------------------------------------------------------- |
---|
[3294] | 18 | USE oce_trc ! shared variables between ocean and passive tracers |
---|
| 19 | USE trc ! passive tracers common variables |
---|
[2528] | 20 | USE trcnam ! Namelist read |
---|
[3294] | 21 | USE daymod ! calendar manager |
---|
[1011] | 22 | USE prtctl_trc ! Print control passive tracers (prt_ctl_trc_init routine) |
---|
[5836] | 23 | USE trcrst |
---|
[4306] | 24 | USE lib_mpp ! distribued memory computing library |
---|
[5385] | 25 | USE trcice ! tracers in sea ice |
---|
[7646] | 26 | USE trcbc, only : trc_bc_ini ! generalized Boundary Conditions |
---|
[10880] | 27 | USE trcstp ! for time level indices (to be initialised) |
---|
[4306] | 28 | |
---|
[335] | 29 | IMPLICIT NONE |
---|
| 30 | PRIVATE |
---|
[1011] | 31 | |
---|
[2528] | 32 | PUBLIC trc_init ! called by opa |
---|
[268] | 33 | |
---|
[2715] | 34 | !!---------------------------------------------------------------------- |
---|
[9598] | 35 | !! NEMO/TOP 4.0 , NEMO Consortium (2018) |
---|
[2715] | 36 | !! $Id$ |
---|
[10068] | 37 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[2715] | 38 | !!---------------------------------------------------------------------- |
---|
[335] | 39 | CONTAINS |
---|
[1011] | 40 | |
---|
[11758] | 41 | SUBROUTINE trc_init( Kbb, Kmm, Kaa ) |
---|
[1011] | 42 | !!--------------------------------------------------------------------- |
---|
[2528] | 43 | !! *** ROUTINE trc_init *** |
---|
[335] | 44 | !! |
---|
[1011] | 45 | !! ** Purpose : Initialization of the passive tracer fields |
---|
| 46 | !! |
---|
| 47 | !! ** Method : - read namelist |
---|
| 48 | !! - control the consistancy |
---|
| 49 | !! - compute specific initialisations |
---|
| 50 | !! - set initial tracer fields (either read restart |
---|
| 51 | !! or read data or analytical formulation |
---|
| 52 | !!--------------------------------------------------------------------- |
---|
[11758] | 53 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa ! time level indices |
---|
[3294] | 54 | ! |
---|
[9124] | 55 | IF( ln_timing ) CALL timing_start('trc_init') |
---|
[3294] | 56 | ! |
---|
[945] | 57 | IF(lwp) WRITE(numout,*) |
---|
[2528] | 58 | IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers' |
---|
[9169] | 59 | IF(lwp) WRITE(numout,*) '~~~~~~~~' |
---|
[3294] | 60 | ! |
---|
[5836] | 61 | CALL trc_ini_ctl ! control |
---|
| 62 | CALL trc_nam ! read passive tracers namelists |
---|
[7646] | 63 | CALL top_alloc() ! allocate TOP arrays |
---|
[10880] | 64 | |
---|
[5836] | 65 | ! |
---|
[7646] | 66 | IF(.NOT.ln_trcdta ) ln_trc_ini(:) = .FALSE. |
---|
[4152] | 67 | ! |
---|
[3294] | 68 | IF(lwp) WRITE(numout,*) |
---|
[7646] | 69 | IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
| 70 | IF(lwp) WRITE(numout,*) |
---|
[5836] | 71 | ! |
---|
[11758] | 72 | CALL trc_ini_sms( Kmm ) ! SMS |
---|
[10975] | 73 | CALL trc_ini_trp ! passive tracers transport |
---|
| 74 | CALL trc_ice_ini ! Tracers in sea ice |
---|
[5836] | 75 | ! |
---|
[10570] | 76 | IF( lwm .AND. sn_cfctl%l_trcstat ) THEN |
---|
| 77 | CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea ) |
---|
| 78 | ENDIF |
---|
[5836] | 79 | ! |
---|
[11758] | 80 | CALL trc_ini_state( Kbb, Kmm, Kaa ) ! passive tracers initialisation : from a restart or from clim |
---|
[5836] | 81 | ! |
---|
[11758] | 82 | CALL trc_ini_inv( Kmm ) ! Inventories |
---|
[8542] | 83 | ! |
---|
[9124] | 84 | IF( ln_timing ) CALL timing_stop('trc_init') |
---|
[5836] | 85 | ! |
---|
| 86 | END SUBROUTINE trc_init |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | SUBROUTINE trc_ini_ctl |
---|
| 90 | !!---------------------------------------------------------------------- |
---|
| 91 | !! *** ROUTINE trc_ini_ctl *** |
---|
| 92 | !! ** Purpose : Control + ocean volume |
---|
| 93 | !!---------------------------------------------------------------------- |
---|
| 94 | INTEGER :: jk ! dummy loop indices |
---|
| 95 | ! |
---|
| 96 | ! Define logical parameter ton control dirunal cycle in TOP |
---|
| 97 | l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 ) |
---|
[7646] | 98 | l_trcdm2dc = l_trcdm2dc .AND. .NOT. l_offline |
---|
[5836] | 99 | IF( l_trcdm2dc .AND. lwp ) CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.', & |
---|
| 100 | & 'Computation of a daily mean shortwave for some biogeochemical models ' ) |
---|
| 101 | ! |
---|
| 102 | END SUBROUTINE trc_ini_ctl |
---|
| 103 | |
---|
| 104 | |
---|
[10963] | 105 | SUBROUTINE trc_ini_inv( Kmm ) |
---|
[5836] | 106 | !!---------------------------------------------------------------------- |
---|
| 107 | !! *** ROUTINE trc_ini_stat *** |
---|
| 108 | !! ** Purpose : passive tracers inventories at initialsation phase |
---|
| 109 | !!---------------------------------------------------------------------- |
---|
[10963] | 110 | INTEGER, INTENT(in) :: Kmm ! time level index |
---|
| 111 | INTEGER :: jk, jn ! dummy loop indices |
---|
[5836] | 112 | CHARACTER (len=25) :: charout |
---|
| 113 | !!---------------------------------------------------------------------- |
---|
[9169] | 114 | ! |
---|
| 115 | IF(lwp) WRITE(numout,*) |
---|
| 116 | IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories' |
---|
| 117 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~' |
---|
| 118 | ! |
---|
| 119 | ! ! masked grid volume |
---|
[3294] | 120 | DO jk = 1, jpk |
---|
[10963] | 121 | cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk) |
---|
[3294] | 122 | END DO |
---|
[9169] | 123 | ! ! total volume of the ocean |
---|
[10425] | 124 | areatot = glob_sum( 'trcini', cvol(:,:,:) ) |
---|
[5836] | 125 | ! |
---|
[9169] | 126 | trai(:) = 0._wp ! initial content of all tracers |
---|
[5836] | 127 | DO jn = 1, jptra |
---|
[10963] | 128 | trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:) ) |
---|
[5836] | 129 | END DO |
---|
[1011] | 130 | |
---|
[5836] | 131 | IF(lwp) THEN ! control print |
---|
| 132 | WRITE(numout,*) |
---|
[9169] | 133 | WRITE(numout,*) ' ==>>> Total number of passive tracer jptra = ', jptra |
---|
| 134 | WRITE(numout,*) ' Total volume of ocean = ', areatot |
---|
| 135 | WRITE(numout,*) ' Total inital content of all tracers ' |
---|
[5836] | 136 | WRITE(numout,*) |
---|
| 137 | DO jn = 1, jptra |
---|
| 138 | WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn) |
---|
| 139 | ENDDO |
---|
| 140 | WRITE(numout,*) |
---|
| 141 | ENDIF |
---|
| 142 | IF(lwp) WRITE(numout,*) |
---|
| 143 | IF(ln_ctl) THEN ! print mean trends (used for debugging) |
---|
| 144 | CALL prt_ctl_trc_init |
---|
| 145 | WRITE(charout, FMT="('ini ')") |
---|
| 146 | CALL prt_ctl_trc_info( charout ) |
---|
[10963] | 147 | CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kmm), mask=tmask, clinfo=ctrcnm ) |
---|
[5836] | 148 | ENDIF |
---|
[9169] | 149 | 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10) |
---|
[5836] | 150 | ! |
---|
| 151 | END SUBROUTINE trc_ini_inv |
---|
| 152 | |
---|
| 153 | |
---|
[10975] | 154 | SUBROUTINE trc_ini_sms( Kmm ) |
---|
[5836] | 155 | !!---------------------------------------------------------------------- |
---|
| 156 | !! *** ROUTINE trc_ini_sms *** |
---|
| 157 | !! ** Purpose : SMS initialisation |
---|
| 158 | !!---------------------------------------------------------------------- |
---|
[7646] | 159 | USE trcini_pisces ! PISCES initialisation |
---|
| 160 | USE trcini_cfc ! CFC initialisation |
---|
| 161 | USE trcini_c14 ! C14 initialisation |
---|
| 162 | USE trcini_age ! age initialisation |
---|
| 163 | USE trcini_my_trc ! MY_TRC initialisation |
---|
| 164 | ! |
---|
[10975] | 165 | INTEGER, INTENT(in) :: Kmm ! time level indices |
---|
[7646] | 166 | INTEGER :: jn |
---|
[5836] | 167 | !!---------------------------------------------------------------------- |
---|
| 168 | ! |
---|
[7646] | 169 | ! Pass sn_tracer fields to specialized arrays |
---|
| 170 | DO jn = 1, jp_bgc |
---|
| 171 | ctrcnm (jn) = TRIM( sn_tracer(jn)%clsname ) |
---|
| 172 | ctrcln (jn) = TRIM( sn_tracer(jn)%cllname ) |
---|
| 173 | ctrcun (jn) = TRIM( sn_tracer(jn)%clunit ) |
---|
| 174 | ln_trc_ini(jn) = sn_tracer(jn)%llinit |
---|
| 175 | ln_trc_sbc(jn) = sn_tracer(jn)%llsbc |
---|
| 176 | ln_trc_cbc(jn) = sn_tracer(jn)%llcbc |
---|
| 177 | ln_trc_obc(jn) = sn_tracer(jn)%llobc |
---|
| 178 | END DO |
---|
| 179 | ! |
---|
[10975] | 180 | IF( ln_pisces ) CALL trc_ini_pisces( Kmm ) ! PISCES model |
---|
| 181 | IF( ln_my_trc ) CALL trc_ini_my_trc( Kmm ) ! MY_TRC model |
---|
| 182 | IF( ll_cfc ) CALL trc_ini_cfc ( Kmm ) ! CFC's |
---|
| 183 | IF( ln_c14 ) CALL trc_ini_c14 ( Kmm ) ! C14 model |
---|
| 184 | IF( ln_age ) CALL trc_ini_age ( Kmm ) ! AGE |
---|
[7646] | 185 | ! |
---|
| 186 | IF(lwp) THEN ! control print |
---|
| 187 | WRITE(numout,*) |
---|
[9169] | 188 | WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers' |
---|
| 189 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
| 190 | WRITE(numout,*) ' ID NAME INI SBC CBC OBC' |
---|
[7646] | 191 | DO jn = 1, jptra |
---|
| 192 | WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn) |
---|
| 193 | END DO |
---|
| 194 | ENDIF |
---|
[9169] | 195 | 9001 FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2) |
---|
[7646] | 196 | ! |
---|
[5836] | 197 | END SUBROUTINE trc_ini_sms |
---|
[2528] | 198 | |
---|
[9169] | 199 | |
---|
[5836] | 200 | SUBROUTINE trc_ini_trp |
---|
| 201 | !!---------------------------------------------------------------------- |
---|
| 202 | !! *** ROUTINE trc_ini_trp *** |
---|
| 203 | !! |
---|
| 204 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 205 | !!---------------------------------------------------------------------- |
---|
| 206 | USE trcdmp , ONLY: trc_dmp_ini |
---|
| 207 | USE trcadv , ONLY: trc_adv_ini |
---|
| 208 | USE trcldf , ONLY: trc_ldf_ini |
---|
| 209 | USE trcrad , ONLY: trc_rad_ini |
---|
[10375] | 210 | USE trcsink, ONLY: trc_sink_ini |
---|
[5836] | 211 | ! |
---|
| 212 | INTEGER :: ierr |
---|
| 213 | !!---------------------------------------------------------------------- |
---|
| 214 | ! |
---|
| 215 | IF( ln_trcdmp ) CALL trc_dmp_ini ! damping |
---|
| 216 | CALL trc_adv_ini ! advection |
---|
| 217 | CALL trc_ldf_ini ! lateral diffusion |
---|
[9019] | 218 | ! ! vertical diffusion: always implicit time stepping scheme |
---|
[5836] | 219 | CALL trc_rad_ini ! positivity of passive tracers |
---|
[10375] | 220 | CALL trc_sink_ini ! Vertical sedimentation of particles |
---|
[5836] | 221 | ! |
---|
| 222 | END SUBROUTINE trc_ini_trp |
---|
[5385] | 223 | |
---|
[1254] | 224 | |
---|
[10963] | 225 | SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa ) |
---|
[5836] | 226 | !!---------------------------------------------------------------------- |
---|
| 227 | !! *** ROUTINE trc_ini_state *** |
---|
| 228 | !! ** Purpose : Initialisation of passive tracer concentration |
---|
| 229 | !!---------------------------------------------------------------------- |
---|
| 230 | USE zpshde ! partial step: hor. derivative (zps_hde routine) |
---|
| 231 | USE trcrst ! passive tracers restart |
---|
| 232 | USE trcdta ! initialisation from files |
---|
| 233 | ! |
---|
[10963] | 234 | INTEGER, INTENT(in) :: Kbb, Kmm, Kaa ! time level index |
---|
| 235 | INTEGER :: jn, jl ! dummy loop indices |
---|
[5836] | 236 | !!---------------------------------------------------------------------- |
---|
| 237 | ! |
---|
[10963] | 238 | IF( ln_trcdta ) CALL trc_dta_ini( jptra ) ! set initial tracers values |
---|
[9169] | 239 | ! |
---|
[10963] | 240 | IF( ln_my_trc ) CALL trc_bc_ini ( jptra, Kmm ) ! set tracers Boundary Conditions |
---|
[9169] | 241 | ! |
---|
| 242 | ! |
---|
[9019] | 243 | IF( ln_rsttr ) THEN ! restart from a file |
---|
[2528] | 244 | ! |
---|
[10963] | 245 | CALL trc_rst_read( Kbb, Kmm ) |
---|
[2528] | 246 | ! |
---|
[9019] | 247 | ELSE ! Initialisation of tracer from a file that may also be used for damping |
---|
| 248 | !!gm BUG ? if damping and restart, what's happening ? |
---|
[7646] | 249 | IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN |
---|
| 250 | ! update passive tracers arrays with input data read from file |
---|
[6607] | 251 | DO jn = 1, jptra |
---|
[7646] | 252 | IF( ln_trc_ini(jn) ) THEN |
---|
[3294] | 253 | jl = n_trc_index(jn) |
---|
[10963] | 254 | CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) ) |
---|
[6701] | 255 | ! |
---|
[7646] | 256 | ! deallocate data structure if data are not used for damping |
---|
| 257 | IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN |
---|
[9169] | 258 | IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run' |
---|
[7646] | 259 | DEALLOCATE( sf_trcdta(jl)%fnow ) |
---|
[6701] | 260 | IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta ) |
---|
| 261 | ! |
---|
| 262 | ENDIF |
---|
[3294] | 263 | ENDIF |
---|
[9019] | 264 | END DO |
---|
[6309] | 265 | ! |
---|
[2528] | 266 | ENDIF |
---|
[3294] | 267 | ! |
---|
[10963] | 268 | tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm) |
---|
[2528] | 269 | ! |
---|
[1011] | 270 | ENDIF |
---|
[9169] | 271 | ! |
---|
[10963] | 272 | tr(:,:,:,:,Kaa) = 0._wp |
---|
| 273 | ! ! Partial top/bottom cell: GRADh(tr(Kmm)) |
---|
[5836] | 274 | END SUBROUTINE trc_ini_state |
---|
[1177] | 275 | |
---|
[9019] | 276 | |
---|
[2715] | 277 | SUBROUTINE top_alloc |
---|
| 278 | !!---------------------------------------------------------------------- |
---|
| 279 | !! *** ROUTINE top_alloc *** |
---|
| 280 | !! |
---|
| 281 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 282 | !!---------------------------------------------------------------------- |
---|
| 283 | USE trc , ONLY: trc_alloc |
---|
[4990] | 284 | USE trdtrc_oce , ONLY: trd_trc_oce_alloc |
---|
| 285 | #if defined key_trdmxl_trc |
---|
| 286 | USE trdmxl_trc , ONLY: trd_mxl_trc_alloc |
---|
[2715] | 287 | #endif |
---|
| 288 | ! |
---|
[9169] | 289 | INTEGER :: ierr ! local integer |
---|
[2715] | 290 | !!---------------------------------------------------------------------- |
---|
| 291 | ! |
---|
[6140] | 292 | ierr = trc_alloc() |
---|
[4990] | 293 | ierr = ierr + trd_trc_oce_alloc() |
---|
| 294 | #if defined key_trdmxl_trc |
---|
| 295 | ierr = ierr + trd_mxl_trc_alloc() |
---|
[2715] | 296 | #endif |
---|
| 297 | ! |
---|
[10425] | 298 | CALL mpp_sum( 'trcini', ierr ) |
---|
[2715] | 299 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' ) |
---|
| 300 | ! |
---|
| 301 | END SUBROUTINE top_alloc |
---|
| 302 | |
---|
[1011] | 303 | #else |
---|
| 304 | !!---------------------------------------------------------------------- |
---|
| 305 | !! Empty module : No passive tracer |
---|
| 306 | !!---------------------------------------------------------------------- |
---|
| 307 | CONTAINS |
---|
[2528] | 308 | SUBROUTINE trc_init ! Dummy routine |
---|
| 309 | END SUBROUTINE trc_init |
---|
[1011] | 310 | #endif |
---|
| 311 | |
---|
[335] | 312 | !!====================================================================== |
---|
[268] | 313 | END MODULE trcini |
---|