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

source: branches/2013/dev_r3940_CNRS4_IOCRS/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 4064

Last change on this file since 4064 was 4064, checked in by cetlod, 11 years ago

branch dev_r3940_CNRS4_IOCRS: some improvments+ minor bug corrections

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