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

source: branches/2015/dev_merge_2015/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 6069

Last change on this file since 6069 was 6069, checked in by timgraham, 8 years ago

Merge of dev_MetOffice_merge_2015 into branch (only NEMO directory for now).

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