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 branches/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2015/dev_r5721_CNRS9_NOC3_LDF/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 5766

Last change on this file since 5766 was 5766, checked in by cetlod, 9 years ago

LDF: phasing the improvements/simplifications of TOP component

  • Property svn:keywords set to Id
File size: 12.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 sbc_oce
27   USE trcice          ! tracers in sea ice
28 
29   IMPLICIT NONE
30   PRIVATE
31   
32   PUBLIC   trc_init   ! called by opa
33
34    !! * Substitutions
35#  include "domzgr_substitute.h90"
36   !!----------------------------------------------------------------------
37   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
38   !! $Id$
39   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
40   !!----------------------------------------------------------------------
41CONTAINS
42   
43   SUBROUTINE trc_init
44      !!---------------------------------------------------------------------
45      !!                     ***  ROUTINE trc_init  ***
46      !!
47      !! ** Purpose :   Initialization of the passive tracer fields
48      !!
49      !! ** Method  : - read namelist
50      !!              - control the consistancy
51      !!              - compute specific initialisations
52      !!              - set initial tracer fields (either read restart
53      !!                or read data or analytical formulation
54      !!---------------------------------------------------------------------
55      !!---------------------------------------------------------------------
56      !
57      IF( nn_timing == 1 )   CALL timing_start('trc_init')
58      !
59      IF(lwp) WRITE(numout,*)
60      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
61      IF(lwp) WRITE(numout,*) '~~~~~~~'
62
63      !
64      CALL top_alloc()   ! allocate TOP arrays
65      !
66      CALL trc_ini_ctl   ! control
67      !
68      CALL trc_nam       ! read passive tracers namelists
69      !
70      IF(lwp) WRITE(numout,*)
71      !
72      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
73      !
74      IF(lwp) WRITE(numout,*)
75      !
76      CALL trc_ini_sms   ! SMS
77      !
78      CALL trc_ini_trp   ! passive tracers transport
79      !
80      CALL trc_ice_ini   ! Tracers in sea ice
81      !
82      IF( lwp )  &
83         &  CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
84      !
85      CALL trc_ini_state  !  passive tracers initialisation : from a restart or from clim
86      !
87      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
88      !
89      CALL trc_ini_inv   ! Inventories
90      !
91      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
92      !
93   END SUBROUTINE trc_init
94
95   SUBROUTINE trc_ini_ctl
96      !!----------------------------------------------------------------------
97      !!                     ***  ROUTINE trc_ini_ctl  ***
98      !! ** Purpose :        Control  + ocean volume
99      !!----------------------------------------------------------------------
100      INTEGER ::   jk    ! dummy loop indices
101      !
102      ! Define logical parameter ton control dirunal cycle in TOP
103      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
104      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. lk_offline
105      IF( l_trcdm2dc .AND. lwp ) &
106         &   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      !
110      IF( nn_cla == 1 )   &
111         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
112      !
113   END SUBROUTINE trc_ini_ctl
114
115   SUBROUTINE trc_ini_inv
116      !!----------------------------------------------------------------------
117      !!                     ***  ROUTINE trc_ini_stat  ***
118      !! ** Purpose :      passive tracers inventories at initialsation phase
119      !!----------------------------------------------------------------------
120      INTEGER ::  jk, jn    ! dummy loop indices
121      CHARACTER (len=25) :: charout
122      !!----------------------------------------------------------------------
123      !                                                              ! masked grid volume
124      DO jk = 1, jpk
125         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
126      END DO
127      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
128      !                                                              ! total volume of the ocean
129      areatot = glob_sum( cvol(:,:,:) )
130      !
131      trai(:) = 0._wp                                                   ! initial content of all tracers
132      DO jn = 1, jptra
133         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
134      END DO
135
136      IF(lwp) THEN               ! control print
137         WRITE(numout,*)
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   SUBROUTINE trc_ini_sms
160      !!----------------------------------------------------------------------
161      !!                     ***  ROUTINE trc_ini_sms  ***
162      !! ** Purpose :   SMS initialisation
163      !!----------------------------------------------------------------------
164      USE trcini_cfc      ! CFC      initialisation
165      USE trcini_pisces   ! PISCES   initialisation
166      USE trcini_c14b     ! C14 bomb initialisation
167      USE trcini_my_trc   ! MY_TRC   initialisation
168      !!----------------------------------------------------------------------
169      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
170      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
171      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
172      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
173      !
174   END SUBROUTINE trc_ini_sms
175
176   SUBROUTINE trc_ini_trp
177      !!----------------------------------------------------------------------
178      !!                     ***  ROUTINE trc_ini_trp  ***
179      !!
180      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
181      !!----------------------------------------------------------------------
182      USE trcdmp , ONLY:  trc_dmp_ini
183      USE trcadv , ONLY:  trc_adv_ini
184      USE trcldf , ONLY:  trc_ldf_ini
185      USE trczdf , ONLY:  trc_zdf_ini
186      USE trcrad , ONLY:  trc_rad_ini
187      !
188      INTEGER :: ierr
189      !!----------------------------------------------------------------------
190      !
191      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
192                       CALL  trc_adv_ini          ! advection
193                       CALL  trc_ldf_ini          ! lateral diffusion
194                       CALL  trc_zdf_ini          ! vertical diffusion
195                       CALL  trc_rad_ini          ! positivity of passive tracers
196      !
197   END SUBROUTINE trc_ini_trp
198
199   SUBROUTINE trc_ini_state
200      !!----------------------------------------------------------------------
201      !!                     ***  ROUTINE trc_ini_state ***
202      !! ** Purpose :          Initialisation of passive tracer concentration
203      !!----------------------------------------------------------------------
204      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
205      USE trcrst          ! passive tracers restart
206      USE trcdta          ! initialisation from files
207      !
208      INTEGER ::   jk, jn, jl    ! dummy loop indices
209      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 4D  workspace
210      !!----------------------------------------------------------------------
211      !
212      IF( ln_trcdta )      CALL trc_dta_init(jptra)
213
214      IF( ln_rsttr ) THEN
215        !
216        CALL trc_rst_read              ! restart from a file
217        !
218      ELSE
219        !
220        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
221            !
222            CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )    ! Memory allocation
223            !
224            DO jn = 1, jptra
225               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
226                  jl = n_trc_index(jn) 
227                  CALL trc_dta( nit000, sf_trcdta(jl),rf_trfac(jl) )   ! read tracer data at nit000
228                  ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:)
229                  trn(:,:,:,jn) = ztrcdta(:,:,:) * tmask(:,:,:) 
230                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
231                     !                                                    (data used only for initialisation)
232                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
233                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
234                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
235                     !
236                  ENDIF
237               ENDIF
238            ENDDO
239            CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
240        ENDIF
241        !
242        trb(:,:,:,:) = trn(:,:,:,:)
243        !
244      ENDIF
245 
246      tra(:,:,:,:) = 0._wp
247      !                                                         ! Partial top/bottom cell: GRADh(trn)
248   END SUBROUTINE trc_ini_state
249
250   SUBROUTINE top_alloc
251      !!----------------------------------------------------------------------
252      !!                     ***  ROUTINE top_alloc  ***
253      !!
254      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
255      !!----------------------------------------------------------------------
256      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
257      USE trc           , ONLY:   trc_alloc
258      USE trcnxt        , ONLY:   trc_nxt_alloc
259      USE trczdf        , ONLY:   trc_zdf_alloc
260      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
261#if defined key_trdmxl_trc 
262      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
263#endif
264      !
265      INTEGER :: ierr
266      !!----------------------------------------------------------------------
267      !
268      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
269      ierr = ierr + trc_alloc    ()
270      ierr = ierr + trc_nxt_alloc()
271      ierr = ierr + trc_zdf_alloc()
272      ierr = ierr + trd_trc_oce_alloc()
273#if defined key_trdmxl_trc 
274      ierr = ierr + trd_mxl_trc_alloc()
275#endif
276      !
277      IF( lk_mpp    )   CALL mpp_sum( ierr )
278      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
279      !
280   END SUBROUTINE top_alloc
281
282#else
283   !!----------------------------------------------------------------------
284   !!  Empty module :                                     No passive tracer
285   !!----------------------------------------------------------------------
286CONTAINS
287   SUBROUTINE trc_init                      ! Dummy routine   
288   END SUBROUTINE trc_init
289#endif
290
291   !!======================================================================
292END MODULE trcini
Note: See TracBrowser for help on using the repository browser.