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