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 @ 11480

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

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Merge in changes from branch of branch.
Main changes:

  1. "nxt" modules renamed as "atf" and now just do Asselin time filtering. The time level swapping is achieved by swapping indices.
  2. Some additional prognostic grid variables changed to use a time dimension.

Notes:

  1. This merged branch passes SETTE tests but does not identical results to the SETTE tests with the trunk@10721 unless minor bugs to do with Euler timestepping and the OFF timestepping are fixed in the trunk (NEMO tickets #2310 and #2311).
  2. The nn_dttrc > 1 option for TOP (TOP has a different timestep to OCE) doesn't work. But it doesn't work in the trunk or NEMO 4.0 release either.
  • Property svn:keywords set to Id
File size: 13.8 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      ! Initialise time level indices
62      Nbb_trc = 1; Nnn_trc = 2; Naa_trc = 3; Nrhs_trc = Naa_trc
63      !
64      CALL trc_ini_ctl   ! control
65      CALL trc_nam       ! read passive tracers namelists
66      CALL top_alloc()   ! allocate TOP arrays
67
68      !
69      IF(.NOT.ln_trcdta )   ln_trc_ini(:) = .FALSE.
70      !
71      IF(lwp) WRITE(numout,*)
72      IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
73      IF(lwp) WRITE(numout,*)
74      !
75      CALL trc_ini_sms( Nnn_trc )   ! SMS
76      CALL trc_ini_trp          ! passive tracers transport
77      CALL trc_ice_ini          ! Tracers in sea ice
78      !
79      IF( lwm .AND. sn_cfctl%l_trcstat ) THEN
80         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
81      ENDIF
82      !
83      CALL trc_ini_state( Nbb_trc, Nnn_trc, Naa_trc )  !  passive tracers initialisation : from a restart or from clim
84      IF( nn_dttrc /= 1 ) &
85      CALL trc_sub_ini( Nnn_trc )    ! Initialize variables for substepping passive tracers
86      !
87      CALL trc_ini_inv( Nnn_trc )    ! Inventories
88      !
89      IF( ln_timing )   CALL timing_stop('trc_init')
90      !
91   END SUBROUTINE trc_init
92
93
94   SUBROUTINE trc_ini_ctl
95      !!----------------------------------------------------------------------
96      !!                     ***  ROUTINE trc_ini_ctl  ***
97      !! ** Purpose :        Control  + ocean volume
98      !!----------------------------------------------------------------------
99      INTEGER ::   jk    ! dummy loop indices
100      !
101      ! Define logical parameter ton control dirunal cycle in TOP
102      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
103      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
104      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
105         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
106      !
107   END SUBROUTINE trc_ini_ctl
108
109
110   SUBROUTINE trc_ini_inv( Kmm )
111      !!----------------------------------------------------------------------
112      !!                     ***  ROUTINE trc_ini_stat  ***
113      !! ** Purpose :      passive tracers inventories at initialsation phase
114      !!----------------------------------------------------------------------
115      INTEGER, INTENT(in) ::   Kmm    ! time level index
116      INTEGER             ::  jk, jn  ! dummy loop indices
117      CHARACTER (len=25) :: charout
118      !!----------------------------------------------------------------------
119      !
120      IF(lwp) WRITE(numout,*)
121      IF(lwp) WRITE(numout,*) 'trc_ini_inv : initial passive tracers inventories'
122      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
123      !
124      !                          ! masked grid volume
125      DO jk = 1, jpk
126         cvol(:,:,jk) = e1e2t(:,:) * e3t(:,:,jk,Kmm) * tmask(:,:,jk)
127      END DO
128      !                          ! total volume of the ocean
129      areatot = glob_sum( 'trcini', cvol(:,:,:) )
130      !
131      trai(:) = 0._wp            ! initial content of all tracers
132      DO jn = 1, jptra
133         trai(jn) = trai(jn) + glob_sum( 'trcini', tr(:,:,:,jn,Kmm) * cvol(:,:,:)   )
134      END DO
135
136      IF(lwp) THEN               ! control print
137         WRITE(numout,*)
138         WRITE(numout,*) '   ==>>>   Total number of passive tracer jptra = ', jptra
139         WRITE(numout,*) '           Total volume of ocean                = ', areatot
140         WRITE(numout,*) '           Total inital content of all tracers '
141         WRITE(numout,*)
142         DO jn = 1, jptra
143            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
144         ENDDO
145         WRITE(numout,*)
146      ENDIF
147      IF(lwp) WRITE(numout,*)
148      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
149         CALL prt_ctl_trc_init
150         WRITE(charout, FMT="('ini ')")
151         CALL prt_ctl_trc_info( charout )
152         CALL prt_ctl_trc( tab4d=tr(:,:,:,:,Kmm), mask=tmask, clinfo=ctrcnm )
153      ENDIF
1549000  FORMAT('      tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
155      !
156   END SUBROUTINE trc_ini_inv
157
158
159   SUBROUTINE trc_ini_sms( Kmm )
160      !!----------------------------------------------------------------------
161      !!                     ***  ROUTINE trc_ini_sms  ***
162      !! ** Purpose :   SMS initialisation
163      !!----------------------------------------------------------------------
164      USE trcini_pisces  ! PISCES   initialisation
165      USE trcini_cfc     ! CFC      initialisation
166      USE trcini_c14     ! C14  initialisation
167      USE trcini_age     ! age initialisation
168      USE trcini_my_trc  ! MY_TRC   initialisation
169      !
170      INTEGER, INTENT(in) ::   Kmm ! time level indices
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( Kmm )     !  PISCES model
186      IF( ln_my_trc      )   CALL trc_ini_my_trc( Kmm )     !  MY_TRC model
187      IF( ll_cfc         )   CALL trc_ini_cfc   ( Kmm )     !  CFC's
188      IF( ln_c14         )   CALL trc_ini_c14   ( Kmm )     !  C14 model
189      IF( ln_age         )   CALL trc_ini_age   ( Kmm )     !  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( Kbb, Kmm, Kaa )
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, INTENT(in) :: Kbb, Kmm, Kaa   ! time level index
241      INTEGER             :: jn, jl          ! dummy loop indices
242      !!----------------------------------------------------------------------
243      !
244      IF( ln_trcdta )   CALL trc_dta_ini( jptra )           ! set initial tracers values
245      !
246      IF( ln_my_trc )   CALL trc_bc_ini ( jptra, Kmm )      ! set tracers Boundary Conditions
247      !
248      !
249      IF( ln_rsttr ) THEN              ! restart from a file
250        !
251        CALL trc_rst_read( Kbb, Kmm )
252        !
253      ELSE                             ! Initialisation of tracer from a file that may also be used for damping
254!!gm BUG ?   if damping and restart, what's happening ?
255        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
256            ! update passive tracers arrays with input data read from file
257            DO jn = 1, jptra
258               IF( ln_trc_ini(jn) ) THEN
259                  jl = n_trc_index(jn) 
260                  CALL trc_dta( nit000, Kmm, sf_trcdta(jl), rf_trfac(jl), tr(:,:,:,jn,Kmm) )
261                  !
262                  ! deallocate data structure if data are not used for damping
263                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
264                     IF(lwp) WRITE(numout,*) 'trc_ini_state: deallocate data arrays as they are only used to initialize the run'
265                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
266                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
267                     !
268                  ENDIF
269               ENDIF
270            END DO
271            !
272        ENDIF
273        !
274        tr(:,:,:,:,Kbb) = tr(:,:,:,:,Kmm)
275        !
276      ENDIF
277      !
278      tr(:,:,:,:,Kaa) = 0._wp
279      !                                                         ! Partial top/bottom cell: GRADh(tr(Kmm))
280   END SUBROUTINE trc_ini_state
281
282
283   SUBROUTINE top_alloc
284      !!----------------------------------------------------------------------
285      !!                     ***  ROUTINE top_alloc  ***
286      !!
287      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
288      !!----------------------------------------------------------------------
289      USE trc           , ONLY:   trc_alloc
290      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
291#if defined key_trdmxl_trc 
292      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
293#endif
294      !
295      INTEGER ::   ierr   ! local integer
296      !!----------------------------------------------------------------------
297      !
298      ierr =        trc_alloc()
299      ierr = ierr + trd_trc_oce_alloc()
300#if defined key_trdmxl_trc 
301      ierr = ierr + trd_mxl_trc_alloc()
302#endif
303      !
304      CALL mpp_sum( 'trcini', ierr )
305      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
306      !
307   END SUBROUTINE top_alloc
308
309#else
310   !!----------------------------------------------------------------------
311   !!  Empty module :                                     No passive tracer
312   !!----------------------------------------------------------------------
313CONTAINS
314   SUBROUTINE trc_init                      ! Dummy routine   
315   END SUBROUTINE trc_init
316#endif
317
318   !!======================================================================
319END MODULE trcini
Note: See TracBrowser for help on using the repository browser.