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