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_r11219_TOP-01_cethe_PISCES_LBC/src/TOP – NEMO

source: NEMO/branches/2019/dev_r11219_TOP-01_cethe_PISCES_LBC/src/TOP/trcini.F90 @ 11609

Last change on this file since 11609 was 11609, checked in by cetlod, 5 years ago

dev_PISCES_LBC : minor improvments

  • Property svn:keywords set to Id
File size: 13.7 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 trcsub          ! variables to substep passive tracers
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 
29   IMPLICIT NONE
30   PRIVATE
31   
32   PUBLIC   trc_init   ! called by opa
33
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
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      !
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      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   ! 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  !  passive tracers initialisation : from a restart or from clim
79      IF( nn_dttrc /= 1 ) &
80      CALL trc_sub_ini    ! Initialize variables for substepping passive tracers
81      !
82      CALL trc_ini_inv   ! Inventories
83      !
84      IF( ln_timing )   CALL timing_stop('trc_init')
85      !
86   END SUBROUTINE trc_init
87
88
89   SUBROUTINE trc_ini_ctl
90      !!----------------------------------------------------------------------
91      !!                     ***  ROUTINE trc_ini_ctl  ***
92      !! ** Purpose :        Control  + ocean volume
93      !!----------------------------------------------------------------------
94      INTEGER ::   jk    ! dummy loop indices
95      !
96      ! Define logical parameter ton control dirunal cycle in TOP
97      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
98      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
99      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
100         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
101      !
102   END SUBROUTINE trc_ini_ctl
103
104
105   SUBROUTINE trc_ini_inv
106      !!----------------------------------------------------------------------
107      !!                     ***  ROUTINE trc_ini_stat  ***
108      !! ** Purpose :      passive tracers inventories at initialsation phase
109      !!----------------------------------------------------------------------
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_n(:,:,jk) * 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', trn(:,:,:,jn) * 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=trn, 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
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 :: jn
165      !!----------------------------------------------------------------------
166      !
167      ! Pass sn_tracer fields to specialized arrays
168      DO jn = 1, jp_bgc
169         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
170         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
171         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
172         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
173         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
174         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
175         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
176      END DO
177      !
178      IF( .NOT.ln_trcbc ) THEN
179         DO jn = 1, jp_bgc
180            ln_trc_sbc(jn) = .FALSE.
181            ln_trc_cbc(jn) = .FALSE.
182            ln_trc_obc(jn) = .FALSE.
183         END DO
184      ENDIF
185     
186      lltrcbc = ( COUNT(ln_trc_sbc) + COUNT(ln_trc_obc) + COUNT(ln_trc_cbc) ) > 0 
187      !   
188      IF( ln_pisces      )   CALL trc_ini_pisces     !  PISCES model
189      IF( ln_my_trc      )   CALL trc_ini_my_trc     !  MY_TRC model
190      IF( ll_cfc         )   CALL trc_ini_cfc        !  CFC's
191      IF( ln_c14         )   CALL trc_ini_c14        !  C14 model
192      IF( ln_age         )   CALL trc_ini_age        !  AGE
193      !
194      IF(lwp) THEN                   ! control print
195         WRITE(numout,*)
196         WRITE(numout,*) 'trc_init_sms : Summary for selected passive tracers'
197         WRITE(numout,*) '~~~~~~~~~~~~'
198         WRITE(numout,*) '    ID     NAME     INI  SBC  CBC  OBC'
199         DO jn = 1, jptra
200            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
201         END DO
202      ENDIF
203      IF( lwp .AND. ln_trcbc .AND. lltrcbc ) THEN
204         WRITE(numout,*)
205         WRITE(numout,*) ' Applying tracer boundary conditions '
206      ENDIF
207     
2089001  FORMAT(3x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
209      !
210   END SUBROUTINE trc_ini_sms
211
212
213   SUBROUTINE trc_ini_trp
214      !!----------------------------------------------------------------------
215      !!                     ***  ROUTINE trc_ini_trp  ***
216      !!
217      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
218      !!----------------------------------------------------------------------
219      USE trcdmp , ONLY:  trc_dmp_ini
220      USE trcadv , ONLY:  trc_adv_ini
221      USE trcldf , ONLY:  trc_ldf_ini
222      USE trcrad , ONLY:  trc_rad_ini
223      USE trcsink, ONLY:  trc_sink_ini
224      !
225      INTEGER :: ierr
226      !!----------------------------------------------------------------------
227      !
228      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
229                       CALL  trc_adv_ini          ! advection
230                       CALL  trc_ldf_ini          ! lateral diffusion
231                       !                          ! vertical diffusion: always implicit time stepping scheme
232                       CALL  trc_rad_ini          ! positivity of passive tracers
233                       CALL  trc_sink_ini         ! Vertical sedimentation of particles
234      !
235   END SUBROUTINE trc_ini_trp
236
237
238   SUBROUTINE trc_ini_state
239      !!----------------------------------------------------------------------
240      !!                     ***  ROUTINE trc_ini_state ***
241      !! ** Purpose :          Initialisation of passive tracer concentration
242      !!----------------------------------------------------------------------
243      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
244      USE trcrst          ! passive tracers restart
245      USE trcdta          ! initialisation from files
246      !
247      INTEGER :: jn, jl   ! dummy loop indices
248      !!----------------------------------------------------------------------
249      !
250      IF( ln_trcdta )   CALL trc_dta_ini( jptra )      ! set initial tracers values
251      !
252      IF( ln_trcbc .AND. lltrcbc )  THEN
253        CALL trc_bc_ini ( jptra  )      ! set tracers Boundary Conditions
254        CALL trc_bc     ( nit000 )      ! tracers: surface and lateral Boundary Conditions
255      ENDIF
256      !
257      !
258      IF( ln_rsttr ) THEN              ! restart from a file
259        !
260        CALL trc_rst_read
261        !
262      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
263!!gm BUG ?   if damping and restart, what's happening ?
264        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
265            ! update passive tracers arrays with input data read from file
266            DO jn = 1, jptra
267               IF( ln_trc_ini(jn) ) THEN
268                  jl = n_trc_index(jn) 
269                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl), trn(:,:,:,jn) )
270                  !
271                  ! deallocate data structure if data are not used for damping
272                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
273                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
274                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
275                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
276                     !
277                  ENDIF
278               ENDIF
279            END DO
280            !
281        ENDIF
282        !
283        trb(:,:,:,:) = trn(:,:,:,:)
284        !
285      ENDIF
286      !
287      tra(:,:,:,:) = 0._wp
288      !                                                         ! Partial top/bottom cell: GRADh(trn)
289   END SUBROUTINE trc_ini_state
290
291
292   SUBROUTINE top_alloc
293      !!----------------------------------------------------------------------
294      !!                     ***  ROUTINE top_alloc  ***
295      !!
296      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
297      !!----------------------------------------------------------------------
298      USE trc           , ONLY:   trc_alloc
299      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
300#if defined key_trdmxl_trc 
301      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
302#endif
303      !
304      INTEGER ::   ierr   ! local integer
305      !!----------------------------------------------------------------------
306      !
307      ierr =        trc_alloc()
308      ierr = ierr + trd_trc_oce_alloc()
309#if defined key_trdmxl_trc 
310      ierr = ierr + trd_mxl_trc_alloc()
311#endif
312      !
313      CALL mpp_sum( 'trcini', ierr )
314      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
315      !
316   END SUBROUTINE top_alloc
317
318#else
319   !!----------------------------------------------------------------------
320   !!  Empty module :                                     No passive tracer
321   !!----------------------------------------------------------------------
322CONTAINS
323   SUBROUTINE trc_init                      ! Dummy routine   
324   END SUBROUTINE trc_init
325#endif
326
327   !!======================================================================
328END MODULE trcini
Note: See TracBrowser for help on using the repository browser.