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

source: trunk/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 2715

Last change on this file since 2715 was 2715, checked in by rblod, 13 years ago

First attempt to put dynamic allocation on the trunk

  • Property svn:keywords set to Id
File size: 9.3 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
19   USE trc
20   USE trcrst
21   USE trcnam          ! Namelist read
22   USE trcini_cfc      ! CFC      initialisation
23   USE trcini_lobster  ! LOBSTER  initialisation
24   USE trcini_pisces   ! PISCES   initialisation
25   USE trcini_c14b     ! C14 bomb initialisation
26   USE trcini_my_trc   ! MY_TRC   initialisation
27   USE trcdta   
28   USE daymod
29   USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
30   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
31   
32   IMPLICIT NONE
33   PRIVATE
34   
35   PUBLIC   trc_init   ! called by opa
36
37    !! * Substitutions
38#  include "domzgr_substitute.h90"
39   !!----------------------------------------------------------------------
40   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
41   !! $Id$
42   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
43   !!----------------------------------------------------------------------
44CONTAINS
45   
46   SUBROUTINE trc_init
47      !!---------------------------------------------------------------------
48      !!                     ***  ROUTINE trc_init  ***
49      !!
50      !! ** Purpose :   Initialization of the passive tracer fields
51      !!
52      !! ** Method  : - read namelist
53      !!              - control the consistancy
54      !!              - compute specific initialisations
55      !!              - set initial tracer fields (either read restart
56      !!                or read data or analytical formulation
57      !!---------------------------------------------------------------------
58      INTEGER ::   jk, jn    ! dummy loop indices
59      CHARACTER (len=25) :: charout
60      !!---------------------------------------------------------------------
61
62      IF(lwp) WRITE(numout,*)
63      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
64      IF(lwp) WRITE(numout,*) '~~~~~~~'
65
66      CALL top_alloc()              ! allocate TOP arrays
67
68      !                             ! masked grid volume
69      DO jk = 1, jpk
70         cvol(:,:,jk) = e1t(:,:) * e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk) 
71      END DO
72
73      !                             ! total volume of the ocean
74#if ! defined key_degrad
75      areatot = glob_sum( cvol(:,:,:) )
76#else
77      areatot = glob_sum( cvol(:,:,:) * facvol(:,:,:) )  ! degrad option: reduction by facvol
78#endif
79
80      CALL trc_nam                  ! read passive tracers namelists
81
82      !                             ! restart for passive tracer (input)
83      IF( ln_rsttr ) THEN
84         IF(lwp) WRITE(numout,*) '       read a restart file for passive tracer : ', cn_trcrst_in
85         IF(lwp) WRITE(numout,*) ' '
86      ELSE
87         IF( lwp .AND. lk_dtatrc ) THEN
88            DO jn = 1, jptra
89               IF( lutini(jn) )  &                  ! open input FILE only IF lutini(jn) is true
90                  &  WRITE(numout,*) ' read an initial file for passive tracer number :', jn, ' traceur : ', ctrcnm(jn) 
91             END DO
92          ENDIF
93          IF( lwp ) WRITE(numout,*)
94      ENDIF
95
96      IF( ln_dm2dc .AND. ( lk_pisces .OR. lk_lobster ) )    &
97         &       CALL ctl_stop( ' The diurnal cycle is not compatible with PISCES or LOBSTER  ' )
98
99      IF( nn_cla == 1 )   &
100         &       CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
101
102      IF( lk_lobster ) THEN   ;   CALL trc_ini_lobster      ! LOBSTER bio-model
103      ELSE                    ;   IF(lwp) WRITE(numout,*) '          LOBSTER not used'
104      ENDIF
105     
106      IF( lk_pisces  ) THEN   ;   CALL trc_ini_pisces       ! PISCES  bio-model
107      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
108      ENDIF
109     
110      IF( lk_cfc     ) THEN   ;   CALL trc_ini_cfc          ! CFC     tracers
111      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
112      ENDIF
113
114      IF( lk_c14b    ) THEN   ;   CALL trc_ini_c14b         ! C14 bomb  tracer
115      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14 not used'
116      ENDIF
117     
118      IF( lk_my_trc  ) THEN   ;   CALL trc_ini_my_trc       ! MY_TRC  tracers
119      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
120      ENDIF
121
122      IF( ln_rsttr ) THEN
123        !
124        IF( lk_offline )  neuler = 1   ! Set time-step indicator at nit000 (leap-frog)
125        CALL trc_rst_read              ! restart from a file
126        !
127      ELSE
128        IF( lk_offline )  THEN
129           neuler = 0                  ! Set time-step indicator at nit000 (euler)
130           CALL day_init               ! set calendar
131        ENDIF
132#if defined key_dtatrc
133        CALL trc_dta( nit000 )      ! Initialization of tracer from a file that may also be used for damping
134        DO jn = 1, jptra
135           IF( lutini(jn) )   trn(:,:,:,jn) = trdta(:,:,:,jn) * tmask(:,:,:)   ! initialisation from file if required
136        END DO
137#endif
138        trb(:,:,:,:) = trn(:,:,:,:)
139        !
140      ENDIF
141 
142      tra(:,:,:,:) = 0._wp
143     
144      IF( ln_zps .AND. .NOT. lk_c1d )   &              ! Partial steps: before horizontal gradient of passive
145        &    CALL zps_hde( nit000, jptra, trn, gtru, gtrv )       ! tracers at the bottom ocean level
146
147
148      !           
149      trai = 0._wp         ! Computation content of all tracers
150      DO jn = 1, jptra
151#if ! defined key_degrad
152         trai = trai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) )
153#else
154         trai = trai + glob_sum( trn(:,:,:,jn) * cvol(:,:,:) * facvol(:,:,:) ) ! degrad option: reduction by facvol
155#endif
156      END DO     
157
158      IF(lwp) THEN               ! control print
159         WRITE(numout,*)
160         WRITE(numout,*)
161         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
162         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
163         WRITE(numout,*) '          *** Total inital content of all tracers  = ', trai
164         WRITE(numout,*)
165      ENDIF
166
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
173      !
174   END SUBROUTINE trc_init
175
176
177   SUBROUTINE top_alloc
178      !!----------------------------------------------------------------------
179      !!                     ***  ROUTINE top_alloc  ***
180      !!
181      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
182      !!----------------------------------------------------------------------
183      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
184      USE trc           , ONLY:   trc_alloc
185      USE trcnxt        , ONLY:   trc_nxt_alloc
186      USE trczdf        , ONLY:   trc_zdf_alloc
187      USE trdmod_trc_oce, ONLY:   trd_mod_trc_oce_alloc
188#if ! defined key_iomput
189      USE trcdia        , ONLY:   trc_dia_alloc
190#endif
191#if defined key_trcdmp 
192      USE trcdmp        , ONLY:   trc_dmp_alloc
193#endif
194#if defined key_dtatrc
195      USE trcdta        , ONLY:   trc_dta_alloc
196#endif
197#if defined key_trdmld_trc   ||   defined key_esopa
198      USE trdmld_trc    , ONLY:   trd_mld_trc_alloc
199#endif
200      !
201      INTEGER :: ierr
202      !!----------------------------------------------------------------------
203      !
204      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
205      ierr = ierr + trc_alloc    ()
206      ierr = ierr + trc_nxt_alloc()
207      ierr = ierr + trc_zdf_alloc()
208      ierr = ierr + trd_mod_trc_oce_alloc()
209#if ! defined key_iomput
210      ierr = ierr + trc_dia_alloc()
211#endif
212#if defined key_trcdmp 
213      ierr = ierr + trc_dmp_alloc()
214#endif
215#if defined key_dtatrc
216      ierr = ierr + trc_dta_alloc()
217#endif
218#if defined key_trdmld_trc   ||   defined key_esopa
219      ierr = ierr + trd_mld_trc_alloc()
220#endif
221      !
222      IF( lk_mpp    )   CALL mpp_sum( ierr )
223      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
224      !
225   END SUBROUTINE top_alloc
226
227#else
228   !!----------------------------------------------------------------------
229   !!  Empty module :                                     No passive tracer
230   !!----------------------------------------------------------------------
231CONTAINS
232   SUBROUTINE trc_init                      ! Dummy routine   
233   END SUBROUTINE trc_init
234#endif
235
236   !!======================================================================
237END MODULE trcini
Note: See TracBrowser for help on using the repository browser.