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

source: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 8356

Last change on this file since 8356 was 8356, checked in by davestorkey, 7 years ago

UKMO/dev_r5518_GO6_package branch: merge in changes from rev 6917 to 6959 of the 3.6_stable branch.

File size: 13.3 KB
RevLine 
[268]1MODULE trcini
[945]2   !!======================================================================
3   !!                         ***  MODULE trcini  ***
4   !! TOP :   Manage the passive tracer initialization
5   !!======================================================================
[2715]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
[8280]10   !!             -   ! 2014-06 (A. Yool, J. Palmieri) adding MEDUSA-2
[274]11   !!----------------------------------------------------------------------
[1011]12#if defined key_top
13   !!----------------------------------------------------------------------
14   !!   'key_top'                                                TOP models
15   !!----------------------------------------------------------------------
[2715]16   !!   trc_init  :   Initialization for passive tracer
17   !!   top_alloc :   allocate the TOP arrays
[1011]18   !!----------------------------------------------------------------------
[3294]19   USE oce_trc         ! shared variables between ocean and passive tracers
20   USE trc             ! passive tracers common variables
21   USE trcrst          ! passive tracers restart
[2528]22   USE trcnam          ! Namelist read
[1254]23   USE trcini_cfc      ! CFC      initialisation
24   USE trcini_pisces   ! PISCES   initialisation
25   USE trcini_c14b     ! C14 bomb initialisation
26   USE trcini_my_trc   ! MY_TRC   initialisation
[8280]27   USE trcini_medusa   ! MEDUSA   initialisation
28   USE trcini_idtra    ! idealize tracer initialisation
29   USE trcini_age      ! AGE      initialisation
[4230]30   USE trcdta          ! initialisation from files
[3294]31   USE daymod          ! calendar manager
[1011]32   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
[4306]33   USE trcsub          ! variables to substep passive tracers
34   USE lib_mpp         ! distribued memory computing library
35   USE sbc_oce
[5385]36   USE trcice          ! tracers in sea ice
[4306]37 
[335]38   IMPLICIT NONE
39   PRIVATE
[1011]40   
[2528]41   PUBLIC   trc_init   ! called by opa
[268]42
[1011]43    !! * Substitutions
44#  include "domzgr_substitute.h90"
[2715]45   !!----------------------------------------------------------------------
46   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
[6486]47   !! $Id$
[2715]48   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
49   !!----------------------------------------------------------------------
[335]50CONTAINS
[1011]51   
[2528]52   SUBROUTINE trc_init
[1011]53      !!---------------------------------------------------------------------
[2528]54      !!                     ***  ROUTINE trc_init  ***
[335]55      !!
[1011]56      !! ** Purpose :   Initialization of the passive tracer fields
57      !!
58      !! ** Method  : - read namelist
59      !!              - control the consistancy
60      !!              - compute specific initialisations
61      !!              - set initial tracer fields (either read restart
62      !!                or read data or analytical formulation
63      !!---------------------------------------------------------------------
[3294]64      INTEGER ::   jk, jn, jl    ! dummy loop indices
[1011]65      CHARACTER (len=25) :: charout
66      !!---------------------------------------------------------------------
[3294]67      !
68      IF( nn_timing == 1 )   CALL timing_start('trc_init')
69      !
[945]70      IF(lwp) WRITE(numout,*)
[2528]71      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
[945]72      IF(lwp) WRITE(numout,*) '~~~~~~~'
[1011]73
[2715]74      CALL top_alloc()              ! allocate TOP arrays
75
[5407]76      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
[5385]77      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. lk_offline
78      IF( l_trcdm2dc .AND. lwp ) &
79         &   CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. &
80         & Computation of a daily mean shortwave for some biogeochemical models) ')
[8280]81          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
82          !!!!! CHECK For MEDUSA
83          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[3294]84      IF( nn_cla == 1 )   &
85         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
[1011]86
[4152]87      CALL trc_nam      ! read passive tracers namelists
[3294]88      !
89      IF(lwp) WRITE(numout,*)
[4152]90      !
91      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
92      !
[3294]93      IF(lwp) WRITE(numout,*)
94                                                              ! masked grid volume
95      !                                                              ! masked grid volume
96      DO jk = 1, jpk
97         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
98      END DO
99      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
100      !                                                              ! total volume of the ocean
101      areatot = glob_sum( cvol(:,:,:) )
[1011]102
[3294]103      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
[8280]104      IF( lk_medusa  )       CALL trc_ini_medusa       ! MEDUSA  tracers
105      IF( lk_idtra   )       CALL trc_ini_idtra        ! Idealize tracers
[3294]106      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
107      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
[8280]108      IF( lk_age     )       CALL trc_ini_age          ! AGE       tracer
[7203]109      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
[2528]110
[5385]111      CALL trc_ice_ini                                 ! Tracers in sea ice
112
[8280]113# if defined key_debug_medusa
114         IF (lwp) write (numout,*) '------------------------------'
115         IF (lwp) write (numout,*) 'Jpalm - debug'
116         IF (lwp) write (numout,*) ' in trc_init'
117         IF (lwp) write (numout,*) ' sms init OK'
118         IF (lwp) write (numout,*) ' next: open tracer.stat'
119         IF (lwp) write (numout,*) ' '
120         CALL flush(numout)
121# endif
122
123      IF( ln_ctl ) THEN
[3294]124         !
[8280]125         IF (narea == 1) THEN 
126            ! The tracer.stat file only contains global tracer sum values, if
127            ! it contains anything at all. Hence it only needs to be opened
128            ! and written to on the master PE, not on all PEs. 
129            CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE','FORMATTED',  & 
130                          'SEQUENTIAL', -1, numout, lwp , narea ) 
131         ENDIF 
[3294]132         !
[945]133      ENDIF
[1254]134
[8280]135# if defined key_debug_medusa
136         IF (lwp) write (numout,*) '------------------------------'
137         IF (lwp) write (numout,*) 'Jpalm - debug'
138         IF (lwp) write (numout,*) ' in trc_init'
139         IF (lwp) write (numout,*) 'open tracer.stat -- OK'
140         IF (lwp) write (numout,*) ' '
141         CALL flush(numout)
142# endif
[1011]143
[3294]144
[8280]145      IF( ln_trcdta ) THEN
146#if defined key_medusa
147         IF(lwp) WRITE(numout,*) 'AXY: calling trc_dta_init'
148         IF(lwp) CALL flush(numout)
149#endif
150         CALL trc_dta_init(jptra)
151      ENDIF
152
[2528]153      IF( ln_rsttr ) THEN
154        !
[8280]155#if defined key_medusa
156        IF(lwp) WRITE(numout,*) 'AXY: calling trc_rst_read'
157        IF(lwp) CALL flush(numout)
158#endif
[2528]159        CALL trc_rst_read              ! restart from a file
160        !
[1011]161      ELSE
[3294]162        !
[8280]163# if defined key_debug_medusa
164         IF (lwp) write (numout,*) '------------------------------'
165         IF (lwp) write (numout,*) 'Jpalm - debug'
166         IF (lwp) write (numout,*) ' Init from file -- will call trc_dta'
167         IF (lwp) write (numout,*) ' '
168         CALL flush(numout)
169# endif
170        !
[3294]171        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
172            !
173            DO jn = 1, jptra
174               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
175                  jl = n_trc_index(jn) 
[6793]176                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) )   ! read tracer data at nit000
177                  trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) 
[4230]178                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
179                     !                                                    (data used only for initialisation)
180                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
181                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
182                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
183                     !
184                  ENDIF
[3294]185               ENDIF
186            ENDDO
[6498]187            !
[2528]188        ENDIF
[3294]189        !
[8280]190# if defined key_debug_medusa
191         IF (lwp) write (numout,*) '------------------------------'
192         IF (lwp) write (numout,*) 'Jpalm - debug'
193         IF (lwp) write (numout,*) ' in trc_init'
194         IF (lwp) write (numout,*) ' before trb = trn'
195         IF (lwp) write (numout,*) ' '
196         CALL flush(numout)
197# endif
198        !
[2528]199        trb(:,:,:,:) = trn(:,:,:,:)
200        !
[8280]201# if defined key_debug_medusa
202         IF (lwp) write (numout,*) '------------------------------'
203         IF (lwp) write (numout,*) 'Jpalm - debug'
204         IF (lwp) write (numout,*) ' in trc_init'
205         IF (lwp) write (numout,*) ' trb = trn -- OK'
206         IF (lwp) write (numout,*) ' '
207         CALL flush(numout)
208# endif
209        !
[1011]210      ENDIF
[2528]211 
[2715]212      tra(:,:,:,:) = 0._wp
[3294]213      !
[8280]214# if defined key_debug_medusa
215         IF (lwp) write (numout,*) '------------------------------'
216         IF (lwp) write (numout,*) 'Jpalm - debug'
217         IF (lwp) write (numout,*) ' in trc_init'
218         IF (lwp) write (numout,*) ' partial step -- OK'
219         IF (lwp) write (numout,*) ' '
220         CALL flush(numout)
221# endif
222      !
[3294]223      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
224      !
[8280]225# if defined key_debug_medusa
226         IF (lwp) write (numout,*) '------------------------------'
227         IF (lwp) write (numout,*) 'Jpalm - debug'
228         IF (lwp) write (numout,*) ' in trc_init'
229         IF (lwp) write (numout,*) ' before initiate tracer contents'
230         IF (lwp) write (numout,*) ' '
231         CALL flush(numout)
232# endif
233      !
[3294]234      trai(:) = 0._wp                                                   ! initial content of all tracers
[1011]235      DO jn = 1, jptra
[3294]236         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
237      END DO
[1011]238
[2715]239      IF(lwp) THEN               ! control print
240         WRITE(numout,*)
241         WRITE(numout,*)
242         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
243         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
[3294]244         WRITE(numout,*) '          *** Total inital content of all tracers '
[2715]245         WRITE(numout,*)
[8280]246# if defined key_debug_medusa
247         CALL flush(numout)
248# endif
249         !
250# if defined key_debug_medusa
251         WRITE(numout,*) ' litle check :  ', ctrcnm(1)
252         CALL flush(numout)
253# endif
[3294]254         DO jn = 1, jptra
255            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
256         ENDDO
257         WRITE(numout,*)
[2715]258      ENDIF
[3294]259      IF(lwp) WRITE(numout,*)
[2715]260      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
261         CALL prt_ctl_trc_init
[1011]262         WRITE(charout, FMT="('ini ')")
263         CALL prt_ctl_trc_info( charout )
264         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
265      ENDIF
[8280]266
267      IF(lwp) WRITE(numout,*)
268      IF(lwp) WRITE(numout,*) 'trc_init : passive tracer set up completed'
269      IF(lwp) WRITE(numout,*) '~~~~~~~'
270      IF(lwp) CALL flush(numout)
271# if defined key_debug_medusa
272         CALL trc_rst_stat
273         CALL flush(numout)
274# endif
275
[3294]2769000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
[2715]277      !
[3294]278      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
279      !
[2528]280   END SUBROUTINE trc_init
[268]281
[2715]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 trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
290      USE trc           , ONLY:   trc_alloc
291      USE trcnxt        , ONLY:   trc_nxt_alloc
292      USE trczdf        , ONLY:   trc_zdf_alloc
[4990]293      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
294#if defined key_trdmxl_trc 
295      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
[2715]296#endif
297      !
298      INTEGER :: ierr
299      !!----------------------------------------------------------------------
300      !
301      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
302      ierr = ierr + trc_alloc    ()
303      ierr = ierr + trc_nxt_alloc()
304      ierr = ierr + trc_zdf_alloc()
[4990]305      ierr = ierr + trd_trc_oce_alloc()
306#if defined key_trdmxl_trc 
307      ierr = ierr + trd_mxl_trc_alloc()
[2715]308#endif
309      !
310      IF( lk_mpp    )   CALL mpp_sum( ierr )
311      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
312      !
313   END SUBROUTINE top_alloc
314
[1011]315#else
316   !!----------------------------------------------------------------------
317   !!  Empty module :                                     No passive tracer
318   !!----------------------------------------------------------------------
319CONTAINS
[2528]320   SUBROUTINE trc_init                      ! Dummy routine   
321   END SUBROUTINE trc_init
[1011]322#endif
323
[335]324   !!======================================================================
[268]325END MODULE trcini
Note: See TracBrowser for help on using the repository browser.