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/2016/dev_r7012_ROBUST5_CNRS/NEMOGCM/NEMO/TOP_SRC – NEMO

source: branches/2016/dev_r7012_ROBUST5_CNRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 7068

Last change on this file since 7068 was 7068, checked in by cetlod, 8 years ago

ROBUST5_CNRS : implementation of part I of new TOP interface - 1st step -, see ticket #1782

  • Property svn:keywords set to Id
File size: 12.0 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   USE trcbc,   only : trc_bc_init ! generalized Boundary Conditions
29 
30   IMPLICIT NONE
31   PRIVATE
32   
33   PUBLIC   trc_init   ! called by opa
34
35   !!----------------------------------------------------------------------
36   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
37   !! $Id$
38   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
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( nn_timing == 1 )   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      !
62      !
63      CALL trc_ini_ctl   ! control
64      CALL trc_nam       ! read passive tracers namelists
65      CALL top_alloc()   ! allocate TOP arrays
66      !
67      !
68      IF(lwp) WRITE(numout,*)
69      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
70      IF(lwp) WRITE(numout,*)
71      !
72      CALL trc_ini_sms   ! SMS
73      CALL trc_ini_trp   ! passive tracers transport
74      CALL trc_ice_ini   ! Tracers in sea ice
75      !
76      IF(lwp) CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
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      CALL trc_ini_inv   ! Inventories
82      !
83      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
84      !
85   END SUBROUTINE trc_init
86
87
88   SUBROUTINE trc_ini_ctl
89      !!----------------------------------------------------------------------
90      !!                     ***  ROUTINE trc_ini_ctl  ***
91      !! ** Purpose :        Control  + ocean volume
92      !!----------------------------------------------------------------------
93      INTEGER ::   jk    ! dummy loop indices
94      !
95      ! Define logical parameter ton control dirunal cycle in TOP
96      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
97      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. lk_offline
98      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
99         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
100      !
101   END SUBROUTINE trc_ini_ctl
102
103
104   SUBROUTINE trc_ini_inv
105      !!----------------------------------------------------------------------
106      !!                     ***  ROUTINE trc_ini_stat  ***
107      !! ** Purpose :      passive tracers inventories at initialsation phase
108      !!----------------------------------------------------------------------
109      INTEGER ::  jk, jn    ! dummy loop indices
110      CHARACTER (len=25) :: charout
111      !!----------------------------------------------------------------------
112      !                                                              ! masked grid volume
113      DO jk = 1, jpk
114         cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk)
115      END DO
116      !                                                              ! total volume of the ocean
117      areatot = glob_sum( cvol(:,:,:) )
118      !
119      trai(:) = 0._wp                                                   ! initial content of all tracers
120      DO jn = 1, jptra
121         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
122      END DO
123
124      IF(lwp) THEN               ! control print
125         WRITE(numout,*)
126         WRITE(numout,*)
127         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
128         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
129         WRITE(numout,*) '          *** Total inital content of all tracers '
130         WRITE(numout,*)
131         DO jn = 1, jptra
132            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
133         ENDDO
134         WRITE(numout,*)
135      ENDIF
136      IF(lwp) WRITE(numout,*)
137      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
138         CALL prt_ctl_trc_init
139         WRITE(charout, FMT="('ini ')")
140         CALL prt_ctl_trc_info( charout )
141         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
142      ENDIF
1439000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
144      !
145   END SUBROUTINE trc_ini_inv
146
147
148   SUBROUTINE trc_ini_sms
149      !!----------------------------------------------------------------------
150      !!                     ***  ROUTINE trc_ini_sms  ***
151      !! ** Purpose :   SMS initialisation
152      !!----------------------------------------------------------------------
153      USE trcini_pisces  ! PISCES   initialisation
154      USE trcini_cfc     ! CFC      initialisation
155      USE trcini_c14     ! C14  initialisation
156      USE trcini_age     ! age initialisation
157      USE trcini_my_trc  ! MY_TRC   initialisation
158      !!----------------------------------------------------------------------
159      !   
160      IF( ln_pisces  )   CALL trc_ini_pisces     !  PISCES model
161      IF( ln_my_trc  )   CALL trc_ini_my_trc     !  MY_TRC model
162      IF( ll_cfc     )   CALL trc_ini_cfc        !  CFC's
163      IF( ln_c14     )   CALL trc_ini_c14        !  C14 model
164      IF( ln_age     )   CALL trc_ini_age        !  AGE
165      !
166   END SUBROUTINE trc_ini_sms
167
168   SUBROUTINE trc_ini_trp
169      !!----------------------------------------------------------------------
170      !!                     ***  ROUTINE trc_ini_trp  ***
171      !!
172      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
173      !!----------------------------------------------------------------------
174      USE trcdmp , ONLY:  trc_dmp_ini
175      USE trcadv , ONLY:  trc_adv_ini
176      USE trcldf , ONLY:  trc_ldf_ini
177      USE trczdf , ONLY:  trc_zdf_ini
178      USE trcrad , ONLY:  trc_rad_ini
179      !
180      INTEGER :: ierr
181      !!----------------------------------------------------------------------
182      !
183      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
184                       CALL  trc_adv_ini          ! advection
185                       CALL  trc_ldf_ini          ! lateral diffusion
186                       CALL  trc_zdf_ini          ! vertical diffusion
187                       CALL  trc_rad_ini          ! positivity of passive tracers
188      !
189   END SUBROUTINE trc_ini_trp
190
191
192   SUBROUTINE trc_ini_state
193      !!----------------------------------------------------------------------
194      !!                     ***  ROUTINE trc_ini_state ***
195      !! ** Purpose :          Initialisation of passive tracer concentration
196      !!----------------------------------------------------------------------
197      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
198      USE trcrst          ! passive tracers restart
199      USE trcdta          ! initialisation from files
200      !
201      INTEGER :: jn, jl   ! dummy loop indices
202      !!----------------------------------------------------------------------
203      !
204      ! Initialisation of tracers Initial Conditions
205      IF( ln_trcdta )      CALL trc_dta_init(jptra)
206
207      ! Initialisation of tracers Boundary Conditions
208      IF( ln_my_trc )     CALL trc_bc_init(jptra)
209
210      IF( ln_rsttr ) THEN
211        !
212        CALL trc_rst_read              ! restart from a file
213        !
214      ELSE
215        !
216        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
217            !
218            DO jn = 1, jptra
219               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
220                  jl = n_trc_index(jn) 
221                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) )   ! read tracer data at nit000
222                  trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) 
223                  !
224                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
225                     !                                                    (data used only for initialisation)
226                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
227                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
228                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
229                     !
230                  ENDIF
231               ENDIF
232            ENDDO
233            !
234        ENDIF
235        !
236        trb(:,:,:,:) = trn(:,:,:,:)
237        !
238      ENDIF
239 
240      tra(:,:,:,:) = 0._wp
241      !                                                         ! Partial top/bottom cell: GRADh(trn)
242   END SUBROUTINE trc_ini_state
243
244   SUBROUTINE top_alloc
245      !!----------------------------------------------------------------------
246      !!                     ***  ROUTINE top_alloc  ***
247      !!
248      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
249      !!----------------------------------------------------------------------
250      USE trc           , ONLY:   trc_alloc
251      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
252#if defined key_trdmxl_trc 
253      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
254#endif
255      !
256      INTEGER :: ierr
257      !!----------------------------------------------------------------------
258      !
259      ierr =        trc_alloc()
260      ierr = ierr + trd_trc_oce_alloc()
261#if defined key_trdmxl_trc 
262      ierr = ierr + trd_mxl_trc_alloc()
263#endif
264      !
265      IF( lk_mpp    )   CALL mpp_sum( ierr )
266      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
267      !
268   END SUBROUTINE top_alloc
269
270#else
271   !!----------------------------------------------------------------------
272   !!  Empty module :                                     No passive tracer
273   !!----------------------------------------------------------------------
274CONTAINS
275   SUBROUTINE trc_init                      ! Dummy routine   
276   END SUBROUTINE trc_init
277#endif
278
279   !!======================================================================
280END MODULE trcini
Note: See TracBrowser for help on using the repository browser.