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_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP – NEMO

source: NEMO/branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps/src/TOP/trcini.F90 @ 10880

Last change on this file since 10880 was 10880, checked in by davestorkey, 5 years ago

branches/2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps:

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