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

source: branches/2015/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 7256

Last change on this file since 7256 was 7256, checked in by cbricaud, 7 years ago

phaze NEMO routines in CRS branch with nemo_v3_6_STABLE branch at rev 7213 (09-09-2016) (merge -r 5519:7213 )

  • Property svn:keywords set to Id
File size: 9.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 trcrst          ! passive tracers restart
21   USE trcnam          ! Namelist read
22   USE trcini_cfc      ! CFC      initialisation
23   USE trcini_pisces   ! PISCES   initialisation
24   USE trcini_c14b     ! C14 bomb initialisation
25   USE trcini_my_trc   ! MY_TRC   initialisation
26   USE trcdta          ! initialisation from files
27   USE daymod          ! calendar manager
28   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
29   USE trcsub          ! variables to substep passive tracers
30   USE lib_mpp         ! distribued memory computing library
31   USE crs    , ONLY : ln_crs_top
32   USE dom_oce, ONLY : nn_cla, ln_isfcav
33   USE trcice          ! tracers in sea ice
34   USE sbc_oce
35 
36   IMPLICIT NONE
37   PRIVATE
38   
39   PUBLIC   trc_init   ! called by opa
40
41    !! * Substitutions
42#  include "domzgr_substitute.h90"
43   !!----------------------------------------------------------------------
44   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
45   !! $Id$
46   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
47   !!----------------------------------------------------------------------
48CONTAINS
49   
50   SUBROUTINE trc_init
51      !!---------------------------------------------------------------------
52      !!                     ***  ROUTINE trc_init  ***
53      !!
54      !! ** Purpose :   Initialization of the passive tracer fields
55      !!
56      !! ** Method  : - read namelist
57      !!              - control the consistancy
58      !!              - compute specific initialisations
59      !!              - set initial tracer fields (either read restart
60      !!                or read data or analytical formulation
61      !!---------------------------------------------------------------------
62      INTEGER ::   jk, jn, jl    ! dummy loop indices
63      CHARACTER (len=25) :: charout
64      !!---------------------------------------------------------------------
65      !
66      IF( nn_timing == 1 )   CALL timing_start('trc_init')
67      !
68      IF(lwp) WRITE(numout,*)
69      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
70      IF(lwp) WRITE(numout,*) '~~~~~~~'
71
72      CALL top_alloc()              ! allocate TOP arrays
73
74      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
75      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. lk_offline
76      IF( l_trcdm2dc .AND. lwp ) &
77         &   CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. &
78         & Computation of a daily mean shortwave for some biogeochemical models) ')
79
80      IF( nn_cla == 1 )   &
81         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
82
83      CALL trc_nam      ! read passive tracers namelists
84      !
85      IF(lwp) WRITE(numout,*)
86      !
87      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
88      !
89      IF(lwp) WRITE(numout,*)
90                                                              ! masked grid volume
91      !                                                              ! masked grid volume
92      DO jk = 1, jpk
93         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
94      END DO
95      !cbr IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
96      !                                                              ! total volume of the ocean
97      areatot = glob_sum( cvol(:,:,:) )
98
99      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
100      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
101      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
102      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
103
104      CALL trc_ice_ini                                 ! Tracers in sea ice
105
106      IF( lwp ) THEN
107         !
108         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
109         !
110      ENDIF
111
112      IF( ln_trcdta )      CALL trc_dta_init(jptra)
113
114
115      IF( ln_rsttr ) THEN
116        !
117        CALL trc_rst_read              ! restart from a file
118        !
119      ELSE
120        !
121        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
122            !
123            DO jn = 1, jptra
124               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
125                  jl = n_trc_index(jn) 
126                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl) )   ! read tracer data at nit000
127                  trn(:,:,:,jn) = sf_trcdta(jl)%fnow(:,:,:) 
128                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
129                     !                                                    (data used only for initialisation)
130                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
131                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
132                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
133                     !
134                  ENDIF
135               ENDIF
136            ENDDO
137            !
138        ENDIF
139        !
140        trb(:,:,:,:) = trn(:,:,:,:)
141        !
142      ENDIF
143 
144      tra(:,:,:,:) = 0._wp
145      !
146      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
147      !
148
149      trai(:) = 0._wp                                                   ! initial content of all tracers
150      DO jn = 1, jptra
151         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
152      END DO
153
154      IF(lwp) THEN               ! control print
155         WRITE(numout,*)
156         WRITE(numout,*)
157         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
158         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
159         WRITE(numout,*) '          *** Total inital content of all tracers '
160         WRITE(numout,*)
161         DO jn = 1, jptra
162            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
163         ENDDO
164         WRITE(numout,*)
165      ENDIF
166      IF(lwp) WRITE(numout,*)
167      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
168         CALL prt_ctl_trc_init
169         WRITE(charout, FMT="('ini ')")
170         CALL prt_ctl_trc_info( charout )
171         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
172      ENDIF
1739000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
174      !
175      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
176      !
177   END SUBROUTINE trc_init
178
179
180   SUBROUTINE top_alloc
181      !!----------------------------------------------------------------------
182      !!                     ***  ROUTINE top_alloc  ***
183      !!
184      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
185      !!----------------------------------------------------------------------
186      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
187      USE trcadv_crs    , ONLY:   trc_adv_alloc_crs      ! TOP-related alloc routines..
188      USE trc           , ONLY:   trc_alloc
189      USE trcnxt        , ONLY:   trc_nxt_alloc
190      USE trczdf        , ONLY:   trc_zdf_alloc
191      USE trczdf_crs    , ONLY:   trc_zdf_alloc_crs
192      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
193#if defined key_trdmxl_trc 
194      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
195#endif
196      !
197      INTEGER :: ierr
198      !!----------------------------------------------------------------------
199      !
200      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
201      ierr = ierr + trc_adv_alloc_crs()
202      ierr = ierr + trc_alloc    ()
203      ierr = ierr + trc_nxt_alloc()
204      ierr = ierr + trc_zdf_alloc()
205      ierr = ierr + trc_zdf_alloc_crs()
206      ierr = ierr + trd_trc_oce_alloc()
207#if defined key_trdmxl_trc 
208      ierr = ierr + trd_mxl_trc_alloc()
209#endif
210      !
211      IF( lk_mpp    )   CALL mpp_sum( ierr )
212      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
213      !
214   END SUBROUTINE top_alloc
215
216#else
217   !!----------------------------------------------------------------------
218   !!  Empty module :                                     No passive tracer
219   !!----------------------------------------------------------------------
220CONTAINS
221   SUBROUTINE trc_init                      ! Dummy routine   
222   END SUBROUTINE trc_init
223#endif
224
225   !!======================================================================
226END MODULE trcini
Note: See TracBrowser for help on using the repository browser.