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 @ 5602

Last change on this file since 5602 was 5602, checked in by cbricaud, 9 years ago

merge change from trunk rev 5003 to 5519 ( rev where branche 3.6_stable were created )

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