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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/TOP/trcini.F90 @ 12193

Last change on this file since 12193 was 12193, checked in by davestorkey, 4 years ago

2019/dev_r11943_MERGE_2019: Merge in dev_r12072_TOP-01_ENHANCE-11_cethe

  • Property svn:keywords set to Id
File size: 14.0 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_ini_ctl   ! control
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_ctl
89      !!----------------------------------------------------------------------
90      !!                     ***  ROUTINE trc_ini_ctl  ***
91      !! ** Purpose :        Control  + ocean volume
92      !!----------------------------------------------------------------------
93      INTEGER ::   jk    ! dummy loop indices
94      !
95      ! Define logical parameter ton control dirunal cycle in TOP
96      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
97      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
98      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
99         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
100      !
101   END SUBROUTINE trc_ini_ctl
102
103
104   SUBROUTINE trc_ini_inv( Kmm )
105      !!----------------------------------------------------------------------
106      !!                     ***  ROUTINE trc_ini_stat  ***
107      !! ** Purpose :      passive tracers inventories at initialsation phase
108      !!----------------------------------------------------------------------
109      INTEGER, INTENT(in) ::   Kmm    ! time level index
110      INTEGER             ::  jk, jn  ! dummy loop indices
111      CHARACTER (len=25) :: charout
112      !!----------------------------------------------------------------------
113      !
114      IF(lwp) WRITE(numout,*)
115      IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories'
116      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
117      !
118      !                          ! masked grid volume
119      DO jk = 1, jpk
120         cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk)
121      END DO
122      !                          ! total volume of the ocean
123      areatot = glob_sum( 'trcini', cvol(:,:,:) )
124      !
125      trai(:) = 0._wp            ! initial content of all tracers
126      DO jn = 1, jptra
127         trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:)   )
128      END DO
129
130      IF(lwp) THEN               ! control print
131         WRITE(numout,*)
132         WRITE(numout,*) '   ==>>>   Total number of passive tracer jptra = ', jptra
133         WRITE(numout,*) '           Total volume of ocean                = ', areatot
134         WRITE(numout,*) '           Total inital content of all tracers '
135         WRITE(numout,*)
136         DO jn = 1, jptra
137            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
138         ENDDO
139         WRITE(numout,*)
140      ENDIF
141      IF(lwp) WRITE(numout,*)
142      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
143         CALL prt_ctl_trc_init
144         WRITE(charout, FMT="('ini ')")
145         CALL prt_ctl_trc_info( charout )
146         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kmm), mask=tmask, clinfo=ctrcnm )
147      ENDIF
1489000  FORMAT('      tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
149      !
150   END SUBROUTINE trc_ini_inv
151
152
153   SUBROUTINE trc_ini_sms( Kmm )
154      !!----------------------------------------------------------------------
155      !!                     ***  ROUTINE trc_ini_sms  ***
156      !! ** Purpose :   SMS initialisation
157      !!----------------------------------------------------------------------
158      USE trcini_pisces  ! PISCES   initialisation
159      USE trcini_cfc     ! CFC      initialisation
160      USE trcini_c14     ! C14  initialisation
161      USE trcini_age     ! age initialisation
162      USE trcini_my_trc  ! MY_TRC   initialisation
163      !
164      INTEGER, INTENT(in) ::   Kmm ! time level indices
165      INTEGER :: jn
166      !!----------------------------------------------------------------------
167      !
168      ! Pass sn_tracer fields to specialized arrays
169      DO jn = 1, jp_bgc
170         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
171         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
172         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
173         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
174         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
175         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
176         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
177      END DO
178      !
179      IF( .NOT.ln_trcbc ) THEN
180         DO jn = 1, jp_bgc
181            ln_trc_sbc(jn) = .FALSE.
182            ln_trc_cbc(jn) = .FALSE.
183            ln_trc_obc(jn) = .FALSE.
184         END DO
185      ENDIF
186     
187      lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 
188      !   
189      IF( ln_pisces      )   CALL trc_ini_pisces( Kmm )     !  PISCES model
190      IF( ln_my_trc      )   CALL trc_ini_my_trc( Kmm )     !  MY_TRC model
191      IF( ll_cfc         )   CALL trc_ini_cfc   ( Kmm )     !  CFC's
192      IF( ln_c14         )   CALL trc_ini_c14   ( Kmm )     !  C14 model
193      IF( ln_age         )   CALL trc_ini_age   ( Kmm )     !  AGE
194      !
195      IF(lwp) THEN                   ! control print
196         WRITE(numout,*)
197         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
198         WRITE(numout,*) '~~~~~~~~~~~~'
199         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC'
200         DO jn = 1, jptra
201            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
202         END DO
203      ENDIF
204      IF( lwp .AND. ln_trcbc .AND. lltrcbc ) THEN
205         WRITE(numout,*)
206         WRITE(numout,*) ' Applying tracer boundary conditions '
207      ENDIF
208     
2099001  FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
210      !
211   END SUBROUTINE trc_ini_sms
212
213
214   SUBROUTINE trc_ini_trp
215      !!----------------------------------------------------------------------
216      !!                     ***  ROUTINE trc_ini_trp  ***
217      !!
218      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
219      !!----------------------------------------------------------------------
220      USE trcdmp , ONLY:  trc_dmp_ini
221      USE trcadv , ONLY:  trc_adv_ini
222      USE trcldf , ONLY:  trc_ldf_ini
223      USE trcrad , ONLY:  trc_rad_ini
224      USE trcsink, ONLY:  trc_sink_ini
225      !
226      INTEGER :: ierr
227      !!----------------------------------------------------------------------
228      !
229      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
230                       CALL  trc_adv_ini          ! advection
231                       CALL  trc_ldf_ini          ! lateral diffusion
232                       !                          ! vertical diffusion: always implicit time stepping scheme
233                       CALL  trc_rad_ini          ! positivity of passive tracers
234                       CALL  trc_sink_ini         ! Vertical sedimentation of particles
235      !
236   END SUBROUTINE trc_ini_trp
237
238
239   SUBROUTINE trc_ini_state( Kbb, Kmm, Kaa )
240      !!----------------------------------------------------------------------
241      !!                     ***  ROUTINE trc_ini_state ***
242      !! ** Purpose :          Initialisation of passive tracer concentration
243      !!----------------------------------------------------------------------
244      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
245      USE trcrst          ! passive tracers restart
246      USE trcdta          ! initialisation from files
247      !
248      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa   ! time level index
249      INTEGER             :: jn, jl          ! dummy loop indices
250      !!----------------------------------------------------------------------
251      !
252      IF( ln_trcdta )   CALL trc_dta_ini( jptra )           ! set initial tracers values
253      !
254      IF( ln_trcbc .AND. lltrcbc )  THEN
255        CALL trc_bc_ini ( jptra, Kmm  )            ! set tracers Boundary Conditions
256        CALL trc_bc     ( nit000, Kmm, tr, Kaa )   ! tracers: surface and lateral Boundary Conditions
257      ENDIF
258      !
259      !
260      IF( ln_rsttr ) THEN              ! restart from a file
261        !
262        CALL trc_rst_read( Kbb, Kmm )
263        !
264      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
265!!gm BUG ?   if damping and restart, what's happening ?
266        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
267            ! update passive tracers arrays with input data read from file
268            DO jn = 1, jptra
269               IF( ln_trc_ini(jn) ) THEN
270                  jl = n_trc_index(jn) 
271                  CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) )
272                  !
273                  ! deallocate data structure if data are not used for damping
274                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
275                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
276                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
277                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
278                     !
279                  ENDIF
280               ENDIF
281            END DO
282            !
283        ENDIF
284        !
285        tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm)
286        !
287      ENDIF
288      !
289      tr(:,:,:,:,Kaa) = 0._wp
290      !                                                         ! Partial top/bottom cell: GRADh(tr(Kmm))
291   END SUBROUTINE trc_ini_state
292
293
294   SUBROUTINE top_alloc
295      !!----------------------------------------------------------------------
296      !!                     ***  ROUTINE top_alloc  ***
297      !!
298      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
299      !!----------------------------------------------------------------------
300      USE trc           , ONLY:   trc_alloc
301      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
302#if defined key_trdmxl_trc 
303      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
304#endif
305      !
306      INTEGER ::   ierr   ! local integer
307      !!----------------------------------------------------------------------
308      !
309      ierr =        trc_alloc()
310      ierr = ierr + trd_trc_oce_alloc()
311#if defined key_trdmxl_trc 
312      ierr = ierr + trd_mxl_trc_alloc()
313#endif
314      !
315      CALL mpp_sum( 'trcini', ierr )
316      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
317      !
318   END SUBROUTINE top_alloc
319
320#else
321   !!----------------------------------------------------------------------
322   !!  Empty module :                                     No passive tracer
323   !!----------------------------------------------------------------------
324CONTAINS
325   SUBROUTINE trc_init                      ! Dummy routine   
326   END SUBROUTINE trc_init
327#endif
328
329   !!======================================================================
330END MODULE trcini
Note: See TracBrowser for help on using the repository browser.