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_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/TOP – NEMO

source: NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/TOP/trcini.F90 @ 13257

Last change on this file since 13257 was 13257, checked in by orioltp, 4 years ago

Updated with trunk at r13245 and small change allocating variables in icb_oce.F90.

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