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

Last change on this file since 11027 was 11027, checked in by acc, 5 years ago

2019/dev_r10721_KERNEL-02_Storkey_Coward_IMMERSE_first_steps : Final renaming conversions and removal of temporary pointers. All non-AGRIF SETTE tests are passing (including test cases). AGRIF tests compile and link but segment on first call to Agrif_Regrid. NST changes are therefore a work in progress but nothing is broken that was not broken before

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