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

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

bug correction

  • Property svn:keywords set to Id
File size: 10.1 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 
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      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 4D  workspace
65      !!---------------------------------------------------------------------
66      !
67      IF( nn_timing == 1 )   CALL timing_start('trc_init')
68      !
69      IF(lwp) WRITE(numout,*)
70      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
71      IF(lwp) WRITE(numout,*) '~~~~~~~'
72
73      CALL top_alloc()              ! allocate TOP arrays
74
75#if defined key_offline
76      ltrcdm2dc = .FALSE.
77#endif
78
79      IF( ltrcdm2dc )CALL ctl_warn( ' Diurnal cycle on physics but not in PISCES or LOBSTER ' )
80
81      IF( nn_cla == 1 )   &
82         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
83
84      CALL trc_nam      ! read passive tracers namelists
85      !
86      IF(lwp) WRITE(numout,*)
87      !
88      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
89      !
90      IF(lwp) WRITE(numout,*)
91                                                              ! masked grid volume
92      !                                                              ! masked grid volume
93      DO jk = 1, jpk
94         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
95      END DO
96      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
97      !                                                              ! total volume of the ocean
98      areatot = glob_sum( cvol(:,:,:) )
99
100      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
101      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
102      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
103      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
104
105      IF( lwp ) THEN
106         !
107         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
108         !
109      ENDIF
110
111      IF( ln_trcdta )      CALL trc_dta_init(jptra)
112
113
114      IF( ln_rsttr ) THEN
115        !
116        CALL trc_rst_read              ! restart from a file
117        !
118      ELSE
119        !
120        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
121            !
122            CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )    ! Memory allocation
123            !
124            DO jn = 1, jptra
125               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
126                  jl = n_trc_index(jn) 
127                  CALL trc_dta( nit000, sf_trcdta(jl),rf_trfac(jl) )   ! read tracer data at nit000
128                  ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:)
129                  trn(:,:,:,jn) = ztrcdta(:,:,:) * tmask(:,:,:) 
130                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
131                     !                                                    (data used only for initialisation)
132                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
133                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
134                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
135                     !
136                  ENDIF
137               ENDIF
138            ENDDO
139            CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
140        ENDIF
141        !
142        trb(:,:,:,:) = trn(:,:,:,:)
143        !
144      ENDIF
145 
146      tra(:,:,:,:) = 0._wp
147      IF( ln_zps .AND. .NOT. lk_c1d )THEN              ! Partial steps: before horizontal gradient of passive
148         IF( ln_crs )  THEN
149            CALL zps_hde_crs( nit000, jptra, trn, gtru, gtrv )
150         ELSE
151            CALL zps_hde( nit000, jptra, trn, pgtu=gtru, pgtv=gtrv, sgtu=gtrui, sgtv=gtrvi )! tracers at the bottom ocean level
152         ENDIF
153      ENDIF
154      !
155      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
156      !
157
158      trai(:) = 0._wp                                                   ! initial content of all tracers
159      DO jn = 1, jptra
160         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
161      END DO
162
163      IF(lwp) THEN               ! control print
164         WRITE(numout,*)
165         WRITE(numout,*)
166         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
167         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
168         WRITE(numout,*) '          *** Total inital content of all tracers '
169         WRITE(numout,*)
170         DO jn = 1, jptra
171            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
172         ENDDO
173         WRITE(numout,*)
174      ENDIF
175      IF(lwp) WRITE(numout,*)
176      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
177         CALL prt_ctl_trc_init
178         WRITE(charout, FMT="('ini ')")
179         CALL prt_ctl_trc_info( charout )
180         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
181      ENDIF
1829000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
183      !
184      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
185      !
186   END SUBROUTINE trc_init
187
188
189   SUBROUTINE top_alloc
190      !!----------------------------------------------------------------------
191      !!                     ***  ROUTINE top_alloc  ***
192      !!
193      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
194      !!----------------------------------------------------------------------
195      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
196      USE trcadv_crs    , ONLY:   trc_adv_alloc_crs      ! TOP-related alloc routines..
197      USE trc           , ONLY:   trc_alloc
198      USE trcnxt        , ONLY:   trc_nxt_alloc
199      USE trczdf        , ONLY:   trc_zdf_alloc
200      USE trczdf_crs    , ONLY:   trc_zdf_alloc_crs
201      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
202#if defined key_trdmxl_trc 
203      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
204#endif
205      !
206      INTEGER :: ierr
207      !!----------------------------------------------------------------------
208      !
209      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
210      ierr = ierr + trc_adv_alloc_crs()
211      ierr = ierr + trc_alloc    ()
212      ierr = ierr + trc_nxt_alloc()
213      ierr = ierr + trc_zdf_alloc()
214      ierr = ierr + trc_zdf_alloc_crs()
215      ierr = ierr + trd_trc_oce_alloc()
216#if defined key_trdmxl_trc 
217      ierr = ierr + trd_mxl_trc_alloc()
218#endif
219      !
220      IF( lk_mpp    )   CALL mpp_sum( ierr )
221      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
222      !
223   END SUBROUTINE top_alloc
224
225#else
226   !!----------------------------------------------------------------------
227   !!  Empty module :                                     No passive tracer
228   !!----------------------------------------------------------------------
229CONTAINS
230   SUBROUTINE trc_init                      ! Dummy routine   
231   END SUBROUTINE trc_init
232#endif
233
234   !!======================================================================
235END MODULE trcini
Note: See TracBrowser for help on using the repository browser.