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/trunk/src/TOP – NEMO

source: NEMO/trunk/src/TOP/trcini.F90

Last change on this file was 15446, checked in by cetlod, 2 years ago

Minor bugfixes mostly related to PISCES/SED module

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