[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 |
---|
| 26 | USE sbc_oce |
---|
[5385] | 27 | USE trcice ! tracers in sea ice |
---|
[6140] | 28 | USE trcbc, only : trc_bc_init ! generalized Boundary Conditions |
---|
[4306] | 29 | |
---|
[335] | 30 | IMPLICIT NONE |
---|
| 31 | PRIVATE |
---|
[1011] | 32 | |
---|
[2528] | 33 | PUBLIC trc_init ! called by opa |
---|
[268] | 34 | |
---|
[2715] | 35 | !!---------------------------------------------------------------------- |
---|
| 36 | !! NEMO/TOP 4.0 , NEMO Consortium (2011) |
---|
| 37 | !! $Id$ |
---|
| 38 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 39 | !!---------------------------------------------------------------------- |
---|
[335] | 40 | CONTAINS |
---|
[1011] | 41 | |
---|
[2528] | 42 | SUBROUTINE trc_init |
---|
[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 | !!--------------------------------------------------------------------- |
---|
[3294] | 54 | ! |
---|
| 55 | IF( nn_timing == 1 ) CALL timing_start('trc_init') |
---|
| 56 | ! |
---|
[945] | 57 | IF(lwp) WRITE(numout,*) |
---|
[2528] | 58 | IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers' |
---|
[945] | 59 | IF(lwp) WRITE(numout,*) '~~~~~~~' |
---|
[1011] | 60 | |
---|
[3294] | 61 | ! |
---|
[5836] | 62 | CALL top_alloc() ! allocate TOP arrays |
---|
| 63 | ! |
---|
| 64 | CALL trc_ini_ctl ! control |
---|
| 65 | ! |
---|
| 66 | CALL trc_nam ! read passive tracers namelists |
---|
| 67 | ! |
---|
[3294] | 68 | IF(lwp) WRITE(numout,*) |
---|
[4152] | 69 | ! |
---|
| 70 | IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' ) ! calendar |
---|
| 71 | ! |
---|
[3294] | 72 | IF(lwp) WRITE(numout,*) |
---|
[5836] | 73 | ! |
---|
| 74 | CALL trc_ini_sms ! SMS |
---|
| 75 | ! |
---|
| 76 | CALL trc_ini_trp ! passive tracers transport |
---|
| 77 | ! |
---|
| 78 | CALL trc_ice_ini ! Tracers in sea ice |
---|
| 79 | ! |
---|
| 80 | IF( lwp ) & |
---|
| 81 | & CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea ) |
---|
| 82 | ! |
---|
| 83 | CALL trc_ini_state ! passive tracers initialisation : from a restart or from clim |
---|
| 84 | ! |
---|
| 85 | IF( nn_dttrc /= 1 ) CALL trc_sub_ini ! Initialize variables for substepping passive tracers |
---|
| 86 | ! |
---|
| 87 | CALL trc_ini_inv ! Inventories |
---|
| 88 | ! |
---|
| 89 | IF( nn_timing == 1 ) CALL timing_stop('trc_init') |
---|
| 90 | ! |
---|
| 91 | END SUBROUTINE trc_init |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | SUBROUTINE trc_ini_ctl |
---|
| 95 | !!---------------------------------------------------------------------- |
---|
| 96 | !! *** ROUTINE trc_ini_ctl *** |
---|
| 97 | !! ** Purpose : Control + ocean volume |
---|
| 98 | !!---------------------------------------------------------------------- |
---|
| 99 | INTEGER :: jk ! dummy loop indices |
---|
| 100 | ! |
---|
| 101 | ! Define logical parameter ton control dirunal cycle in TOP |
---|
| 102 | l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 ) |
---|
| 103 | l_trcdm2dc = l_trcdm2dc .AND. .NOT. lk_offline |
---|
| 104 | IF( l_trcdm2dc .AND. lwp ) CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.', & |
---|
| 105 | & 'Computation of a daily mean shortwave for some biogeochemical models ' ) |
---|
| 106 | ! |
---|
| 107 | END SUBROUTINE trc_ini_ctl |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | SUBROUTINE trc_ini_inv |
---|
| 111 | !!---------------------------------------------------------------------- |
---|
| 112 | !! *** ROUTINE trc_ini_stat *** |
---|
| 113 | !! ** Purpose : passive tracers inventories at initialsation phase |
---|
| 114 | !!---------------------------------------------------------------------- |
---|
| 115 | INTEGER :: jk, jn ! dummy loop indices |
---|
| 116 | CHARACTER (len=25) :: charout |
---|
| 117 | !!---------------------------------------------------------------------- |
---|
[3294] | 118 | ! ! masked grid volume |
---|
| 119 | DO jk = 1, jpk |
---|
[6140] | 120 | cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk) |
---|
[3294] | 121 | END DO |
---|
[6140] | 122 | IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:) ! degrad option: reduction by facvol |
---|
[3294] | 123 | ! ! total volume of the ocean |
---|
| 124 | areatot = glob_sum( cvol(:,:,:) ) |
---|
[5836] | 125 | ! |
---|
| 126 | trai(:) = 0._wp ! initial content of all tracers |
---|
| 127 | DO jn = 1, jptra |
---|
| 128 | trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) ) |
---|
| 129 | END DO |
---|
[1011] | 130 | |
---|
[5836] | 131 | IF(lwp) THEN ! control print |
---|
| 132 | WRITE(numout,*) |
---|
| 133 | WRITE(numout,*) |
---|
| 134 | WRITE(numout,*) ' *** Total number of passive tracer jptra = ', jptra |
---|
| 135 | WRITE(numout,*) ' *** Total volume of ocean = ', areatot |
---|
| 136 | WRITE(numout,*) ' *** Total inital content of all tracers ' |
---|
| 137 | WRITE(numout,*) |
---|
| 138 | DO jn = 1, jptra |
---|
| 139 | WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn) |
---|
| 140 | ENDDO |
---|
| 141 | WRITE(numout,*) |
---|
| 142 | ENDIF |
---|
| 143 | IF(lwp) WRITE(numout,*) |
---|
| 144 | IF(ln_ctl) THEN ! print mean trends (used for debugging) |
---|
| 145 | CALL prt_ctl_trc_init |
---|
| 146 | WRITE(charout, FMT="('ini ')") |
---|
| 147 | CALL prt_ctl_trc_info( charout ) |
---|
| 148 | CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm ) |
---|
| 149 | ENDIF |
---|
| 150 | 9000 FORMAT(' tracer nb : ',i2,' name :',a10,' initial content :',e18.10) |
---|
| 151 | ! |
---|
| 152 | END SUBROUTINE trc_ini_inv |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | SUBROUTINE trc_ini_sms |
---|
| 156 | !!---------------------------------------------------------------------- |
---|
| 157 | !! *** ROUTINE trc_ini_sms *** |
---|
| 158 | !! ** Purpose : SMS initialisation |
---|
| 159 | !!---------------------------------------------------------------------- |
---|
| 160 | USE trcini_cfc ! CFC initialisation |
---|
| 161 | USE trcini_pisces ! PISCES initialisation |
---|
| 162 | USE trcini_c14b ! C14 bomb initialisation |
---|
| 163 | USE trcini_my_trc ! MY_TRC initialisation |
---|
| 164 | !!---------------------------------------------------------------------- |
---|
[3294] | 165 | IF( lk_pisces ) CALL trc_ini_pisces ! PISCES bio-model |
---|
| 166 | IF( lk_cfc ) CALL trc_ini_cfc ! CFC tracers |
---|
| 167 | IF( lk_c14b ) CALL trc_ini_c14b ! C14 bomb tracer |
---|
| 168 | IF( lk_my_trc ) CALL trc_ini_my_trc ! MY_TRC tracers |
---|
[5836] | 169 | ! |
---|
| 170 | END SUBROUTINE trc_ini_sms |
---|
[2528] | 171 | |
---|
[5836] | 172 | SUBROUTINE trc_ini_trp |
---|
| 173 | !!---------------------------------------------------------------------- |
---|
| 174 | !! *** ROUTINE trc_ini_trp *** |
---|
| 175 | !! |
---|
| 176 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 177 | !!---------------------------------------------------------------------- |
---|
| 178 | USE trcdmp , ONLY: trc_dmp_ini |
---|
| 179 | USE trcadv , ONLY: trc_adv_ini |
---|
| 180 | USE trcldf , ONLY: trc_ldf_ini |
---|
| 181 | USE trczdf , ONLY: trc_zdf_ini |
---|
| 182 | USE trcrad , ONLY: trc_rad_ini |
---|
| 183 | ! |
---|
| 184 | INTEGER :: ierr |
---|
| 185 | !!---------------------------------------------------------------------- |
---|
| 186 | ! |
---|
| 187 | IF( ln_trcdmp ) CALL trc_dmp_ini ! damping |
---|
| 188 | CALL trc_adv_ini ! advection |
---|
| 189 | CALL trc_ldf_ini ! lateral diffusion |
---|
| 190 | CALL trc_zdf_ini ! vertical diffusion |
---|
| 191 | CALL trc_rad_ini ! positivity of passive tracers |
---|
| 192 | ! |
---|
| 193 | END SUBROUTINE trc_ini_trp |
---|
[5385] | 194 | |
---|
[1254] | 195 | |
---|
[5836] | 196 | SUBROUTINE trc_ini_state |
---|
| 197 | !!---------------------------------------------------------------------- |
---|
| 198 | !! *** ROUTINE trc_ini_state *** |
---|
| 199 | !! ** Purpose : Initialisation of passive tracer concentration |
---|
| 200 | !!---------------------------------------------------------------------- |
---|
| 201 | USE zpshde ! partial step: hor. derivative (zps_hde routine) |
---|
| 202 | USE trcrst ! passive tracers restart |
---|
| 203 | USE trcdta ! initialisation from files |
---|
| 204 | ! |
---|
| 205 | INTEGER :: jk, jn, jl ! dummy loop indices |
---|
| 206 | REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrcdta ! 4D workspace |
---|
| 207 | !!---------------------------------------------------------------------- |
---|
| 208 | ! |
---|
[6140] | 209 | ! Initialisation of tracers Initial Conditions |
---|
[4230] | 210 | IF( ln_trcdta ) CALL trc_dta_init(jptra) |
---|
[1011] | 211 | |
---|
[6140] | 212 | ! Initialisation of tracers Boundary Conditions |
---|
| 213 | IF( lk_my_trc ) CALL trc_bc_init(jptra) |
---|
| 214 | |
---|
[2528] | 215 | IF( ln_rsttr ) THEN |
---|
| 216 | ! |
---|
| 217 | CALL trc_rst_read ! restart from a file |
---|
| 218 | ! |
---|
[1011] | 219 | ELSE |
---|
[3294] | 220 | ! |
---|
| 221 | IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN ! Initialisation of tracer from a file that may also be used for damping |
---|
| 222 | ! |
---|
[4230] | 223 | CALL wrk_alloc( jpi, jpj, jpk, ztrcdta ) ! Memory allocation |
---|
[3294] | 224 | ! |
---|
| 225 | DO jn = 1, jptra |
---|
| 226 | IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 227 | jl = n_trc_index(jn) |
---|
[4230] | 228 | CALL trc_dta( nit000, sf_trcdta(jl),rf_trfac(jl) ) ! read tracer data at nit000 |
---|
| 229 | ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:) |
---|
| 230 | trn(:,:,:,jn) = ztrcdta(:,:,:) * tmask(:,:,:) |
---|
| 231 | IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN !== deallocate data structure ==! |
---|
| 232 | ! (data used only for initialisation) |
---|
| 233 | IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run' |
---|
| 234 | DEALLOCATE( sf_trcdta(jl)%fnow ) ! arrays in the structure |
---|
| 235 | IF( sf_trcdta(jl)%ln_tint ) DEALLOCATE( sf_trcdta(jl)%fdta ) |
---|
| 236 | ! |
---|
| 237 | ENDIF |
---|
[3294] | 238 | ENDIF |
---|
| 239 | ENDDO |
---|
[4230] | 240 | CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta ) |
---|
[2528] | 241 | ENDIF |
---|
[3294] | 242 | ! |
---|
[2528] | 243 | trb(:,:,:,:) = trn(:,:,:,:) |
---|
| 244 | ! |
---|
[1011] | 245 | ENDIF |
---|
[2528] | 246 | |
---|
[2715] | 247 | tra(:,:,:,:) = 0._wp |
---|
[5836] | 248 | ! ! Partial top/bottom cell: GRADh(trn) |
---|
| 249 | END SUBROUTINE trc_ini_state |
---|
[1177] | 250 | |
---|
[2715] | 251 | SUBROUTINE top_alloc |
---|
| 252 | !!---------------------------------------------------------------------- |
---|
| 253 | !! *** ROUTINE top_alloc *** |
---|
| 254 | !! |
---|
| 255 | !! ** Purpose : Allocate all the dynamic arrays of the OPA modules |
---|
| 256 | !!---------------------------------------------------------------------- |
---|
| 257 | USE trc , ONLY: trc_alloc |
---|
[4990] | 258 | USE trdtrc_oce , ONLY: trd_trc_oce_alloc |
---|
| 259 | #if defined key_trdmxl_trc |
---|
| 260 | USE trdmxl_trc , ONLY: trd_mxl_trc_alloc |
---|
[2715] | 261 | #endif |
---|
| 262 | ! |
---|
| 263 | INTEGER :: ierr |
---|
| 264 | !!---------------------------------------------------------------------- |
---|
| 265 | ! |
---|
[6140] | 266 | ierr = trc_alloc() |
---|
[4990] | 267 | ierr = ierr + trd_trc_oce_alloc() |
---|
| 268 | #if defined key_trdmxl_trc |
---|
| 269 | ierr = ierr + trd_mxl_trc_alloc() |
---|
[2715] | 270 | #endif |
---|
| 271 | ! |
---|
| 272 | IF( lk_mpp ) CALL mpp_sum( ierr ) |
---|
| 273 | IF( ierr /= 0 ) CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' ) |
---|
| 274 | ! |
---|
| 275 | END SUBROUTINE top_alloc |
---|
| 276 | |
---|
[1011] | 277 | #else |
---|
| 278 | !!---------------------------------------------------------------------- |
---|
| 279 | !! Empty module : No passive tracer |
---|
| 280 | !!---------------------------------------------------------------------- |
---|
| 281 | CONTAINS |
---|
[2528] | 282 | SUBROUTINE trc_init ! Dummy routine |
---|
| 283 | END SUBROUTINE trc_init |
---|
[1011] | 284 | #endif |
---|
| 285 | |
---|
[335] | 286 | !!====================================================================== |
---|
[268] | 287 | END MODULE trcini |
---|