New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trcini.F90 in NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/TOP – NEMO

source: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/TOP/trcini.F90 @ 12960

Last change on this file since 12960 was 12960, checked in by smasson, 4 years ago

Extra_Halo: additional bugfixes and developments, see #2366

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