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

source: branches/2011/dev_NEMO_MERGE_2011/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 3242

Last change on this file since 3242 was 3242, checked in by cetlod, 12 years ago

Minor bugfix related to OFFLINE

  • 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_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          ! initialisation form files
28   USE daymod          ! calendar manager
29   USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
30   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
31   USE trcsub       ! variables to substep passive tracers
32   
33   IMPLICIT NONE
34   PRIVATE
35   
36   PUBLIC   trc_init   ! called by opa
37
38    !! * Substitutions
39#  include "domzgr_substitute.h90"
40   !!----------------------------------------------------------------------
41   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
42   !! $Id$
43   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
44   !!----------------------------------------------------------------------
45CONTAINS
46   
47   SUBROUTINE trc_init
48      !!---------------------------------------------------------------------
49      !!                     ***  ROUTINE trc_init  ***
50      !!
51      !! ** Purpose :   Initialization of the passive tracer fields
52      !!
53      !! ** Method  : - read namelist
54      !!              - control the consistancy
55      !!              - compute specific initialisations
56      !!              - set initial tracer fields (either read restart
57      !!                or read data or analytical formulation
58      !!---------------------------------------------------------------------
59      INTEGER ::   jk, jn, jl    ! dummy loop indices
60      CHARACTER (len=25) :: charout
61      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrcdta   ! 4D  workspace
62      !!---------------------------------------------------------------------
63      !
64      IF( nn_timing == 1 )   CALL timing_start('trc_init')
65      !
66      IF(lwp) WRITE(numout,*)
67      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
68      IF(lwp) WRITE(numout,*) '~~~~~~~'
69
70      CALL top_alloc()              ! allocate TOP arrays
71
72      IF( ln_dm2dc .AND. ( lk_pisces .OR. lk_lobster ) )    &
73         &  CALL ctl_stop( ' The diurnal cycle is not compatible with PISCES or LOBSTER  ' )
74
75      IF( nn_cla == 1 )   &
76         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
77
78      CALL trc_nam                  ! read passive tracers namelists
79      !                                                              ! masked grid volume
80      IF( lk_offline )  THEN
81         IF( ln_rsttr ) THEN
82            neuler = 1   ! Set time-step indicator at nit000 (leap-frog)
83         ELSE
84            neuler = 0                  ! Set time-step indicator at nit000 (euler)
85            CALL day_init               ! set calendar
86        ENDIF
87      ENDIF
88      !                                                              ! masked grid volume
89      DO jk = 1, jpk
90         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
91      END DO
92      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
93      !                                                              ! total volume of the ocean
94      areatot = glob_sum( cvol(:,:,:) )
95
96      IF( lk_lobster ) THEN   ;   CALL trc_ini_lobster      ! LOBSTER bio-model
97      ELSE                    ;   IF(lwp) WRITE(numout,*) '          LOBSTER not used'
98      ENDIF
99     
100      IF( lk_pisces  ) THEN   ;   CALL trc_ini_pisces       ! PISCES  bio-model
101      ELSE                    ;   IF(lwp) WRITE(numout,*) '          PISCES not used'
102      ENDIF
103     
104      IF( lk_cfc     ) THEN   ;   CALL trc_ini_cfc          ! CFC     tracers
105      ELSE                    ;   IF(lwp) WRITE(numout,*) '          CFC not used'
106      ENDIF
107
108      IF( lk_c14b    ) THEN   ;   CALL trc_ini_c14b         ! C14 bomb  tracer
109      ELSE                    ;   IF(lwp) WRITE(numout,*) '          C14 not used'
110      ENDIF
111     
112      IF( lk_my_trc  ) THEN   ;   CALL trc_ini_my_trc       ! MY_TRC  tracers
113      ELSE                    ;   IF(lwp) WRITE(numout,*) '          MY_TRC not used'
114      ENDIF
115
116      IF( lwp ) THEN
117         !
118         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, 6, .FALSE., narea )
119         !
120      ENDIF
121
122      IF( ln_trcdta )             CALL trc_dta_init
123
124      IF( ln_rsttr ) THEN
125        !
126        CALL trc_rst_read              ! restart from a file
127        !
128      ELSE
129        !
130        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
131            !
132            CALL wrk_alloc( jpi, jpj, jpk, nb_trcdta, ztrcdta )    ! Memory allocation
133            !
134            CALL trc_dta( nit000, ztrcdta )   ! read tracer data at nit000
135            !
136            DO jn = 1, jptra
137               IF( ln_trc_ini(jn) ) THEN      ! update passive tracers arrays with input data read from file
138                  jl = n_trc_index(jn) 
139                  trn(:,:,:,jn) = ztrcdta(:,:,:,jl) * tmask(:,:,:) 
140               ENDIF
141            ENDDO
142            CALL wrk_dealloc( jpi, jpj, jpk, nb_trcdta, ztrcdta )
143        ENDIF
144        !
145        trb(:,:,:,:) = trn(:,:,:,:)
146        !
147      ENDIF
148 
149      tra(:,:,:,:) = 0._wp
150     
151      IF( ln_zps .AND. .NOT. lk_c1d )   &              ! Partial steps: before horizontal gradient of passive
152        &    CALL zps_hde( nit000, jptra, trn, gtru, gtrv )       ! tracers at the bottom ocean level
153
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      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 trc           , ONLY:   trc_alloc
197      USE trcnxt        , ONLY:   trc_nxt_alloc
198      USE trczdf        , ONLY:   trc_zdf_alloc
199      USE trdmod_trc_oce, ONLY:   trd_mod_trc_oce_alloc
200#if defined key_trdmld_trc 
201      USE trdmld_trc    , ONLY:   trd_mld_trc_alloc
202#endif
203      !
204      INTEGER :: ierr
205      !!----------------------------------------------------------------------
206      !
207      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
208      ierr = ierr + trc_alloc    ()
209      ierr = ierr + trc_nxt_alloc()
210      ierr = ierr + trc_zdf_alloc()
211      ierr = ierr + trd_mod_trc_oce_alloc()
212#if defined key_trdmld_trc 
213      ierr = ierr + trd_mld_trc_alloc()
214#endif
215      !
216      IF( lk_mpp    )   CALL mpp_sum( ierr )
217      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
218      !
219   END SUBROUTINE top_alloc
220
221#else
222   !!----------------------------------------------------------------------
223   !!  Empty module :                                     No passive tracer
224   !!----------------------------------------------------------------------
225CONTAINS
226   SUBROUTINE trc_init                      ! Dummy routine   
227   END SUBROUTINE trc_init
228#endif
229
230   !!======================================================================
231END MODULE trcini
Note: See TracBrowser for help on using the repository browser.