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_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP – NEMO

source: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcini.F90 @ 14644

Last change on this file since 14644 was 14644, checked in by sparonuz, 3 years ago

Merge trunk -r14642:HEAD

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