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

source: branches/UKMO/dev_r8864_restart_date/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 9235

Last change on this file since 9235 was 9235, checked in by davestorkey, 6 years ago

UKMO/dev_r8864_restart_date : clear SVN keywords.

File size: 12.8 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 trcnam          ! Namelist read
21   USE daymod          ! calendar manager
22   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
23   USE trcsub          ! variables to substep passive tracers
24   USE trcrst
25   USE lib_mpp         ! distribued memory computing library
26   USE trcice          ! tracers in sea ice
27   USE trcbc,   only : trc_bc_ini ! generalized Boundary Conditions
28 
29   IMPLICIT NONE
30   PRIVATE
31   
32   PUBLIC   trc_init   ! called by opa
33
34   !!----------------------------------------------------------------------
35   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
36   !! $Id$
37   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
38   !!----------------------------------------------------------------------
39CONTAINS
40   
41   SUBROUTINE trc_init
42      !!---------------------------------------------------------------------
43      !!                     ***  ROUTINE trc_init  ***
44      !!
45      !! ** Purpose :   Initialization of the passive tracer fields
46      !!
47      !! ** Method  : - read namelist
48      !!              - control the consistancy
49      !!              - compute specific initialisations
50      !!              - set initial tracer fields (either read restart
51      !!                or read data or analytical formulation
52      !!---------------------------------------------------------------------
53      !
54      IF( nn_timing == 1 )   CALL timing_start('trc_init')
55      !
56      IF(lwp) WRITE(numout,*)
57      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
58      IF(lwp) WRITE(numout,*) '~~~~~~~'
59      !
60      CALL trc_ini_ctl   ! control
61      CALL trc_nam       ! read passive tracers namelists
62      CALL top_alloc()   ! allocate TOP arrays
63      !
64      IF(.NOT.ln_trcdta )   ln_trc_ini(:) = .FALSE.
65      !
66      IF(lwp) WRITE(numout,*)
67      IF( ln_rsttr .AND. .NOT. l_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
68      IF(lwp) WRITE(numout,*)
69      !
70      CALL trc_ini_sms   ! SMS
71      CALL trc_ini_trp   ! passive tracers transport
72      CALL trc_ice_ini   ! Tracers in sea ice
73      !
74      IF(lwp) CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
75      !
76      CALL trc_ini_state  !  passive tracers initialisation : from a restart or from clim
77      IF( nn_dttrc /= 1 ) &
78      CALL trc_sub_ini    ! Initialize variables for substepping passive tracers
79      !
80      CALL trc_ini_inv   ! Inventories
81      !
82      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
83      !
84   END SUBROUTINE trc_init
85
86
87   SUBROUTINE trc_ini_ctl
88      !!----------------------------------------------------------------------
89      !!                     ***  ROUTINE trc_ini_ctl  ***
90      !! ** Purpose :        Control  + ocean volume
91      !!----------------------------------------------------------------------
92      INTEGER ::   jk    ! dummy loop indices
93      !
94      ! Define logical parameter ton control dirunal cycle in TOP
95      l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
96      l_trcdm2dc = l_trcdm2dc  .AND. .NOT. l_offline
97      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
98         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
99      !
100   END SUBROUTINE trc_ini_ctl
101
102
103   SUBROUTINE trc_ini_inv
104      !!----------------------------------------------------------------------
105      !!                     ***  ROUTINE trc_ini_stat  ***
106      !! ** Purpose :      passive tracers inventories at initialsation phase
107      !!----------------------------------------------------------------------
108      INTEGER ::  jk, jn    ! dummy loop indices
109      CHARACTER (len=25) :: charout
110      !!----------------------------------------------------------------------
111      !                                                              ! masked grid volume
112      DO jk = 1, jpk
113         cvol(:,:,jk) = e1e2t(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk)
114      END DO
115      !                                                              ! total volume of the ocean
116      areatot = glob_sum( cvol(:,:,:) )
117      !
118      trai(:) = 0._wp                                                   ! initial content of all tracers
119      DO jn = 1, jptra
120         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
121      END DO
122
123      IF(lwp) THEN               ! control print
124         WRITE(numout,*)
125         WRITE(numout,*) '  *** Total number of passive tracer jptra = ', jptra
126         WRITE(numout,*) '  *** Total volume of ocean                = ', areatot
127         WRITE(numout,*) '  *** Total inital content of all tracers '
128         WRITE(numout,*)
129         DO jn = 1, jptra
130            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
131         ENDDO
132         WRITE(numout,*)
133      ENDIF
134      IF(lwp) WRITE(numout,*)
135      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
136         CALL prt_ctl_trc_init
137         WRITE(charout, FMT="('ini ')")
138         CALL prt_ctl_trc_info( charout )
139         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
140      ENDIF
1419000  FORMAT('  tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
142      !
143   END SUBROUTINE trc_ini_inv
144
145
146   SUBROUTINE trc_ini_sms
147      !!----------------------------------------------------------------------
148      !!                     ***  ROUTINE trc_ini_sms  ***
149      !! ** Purpose :   SMS initialisation
150      !!----------------------------------------------------------------------
151      USE trcini_pisces  ! PISCES   initialisation
152      USE trcini_cfc     ! CFC      initialisation
153      USE trcini_c14     ! C14  initialisation
154      USE trcini_age     ! age initialisation
155      USE trcini_my_trc  ! MY_TRC   initialisation
156      !
157      INTEGER :: jn
158      !!----------------------------------------------------------------------
159      !
160      ! Pass sn_tracer fields to specialized arrays
161      DO jn = 1, jp_bgc
162         ctrcnm    (jn) = TRIM( sn_tracer(jn)%clsname )
163         ctrcln    (jn) = TRIM( sn_tracer(jn)%cllname )
164         ctrcun    (jn) = TRIM( sn_tracer(jn)%clunit  )
165         ln_trc_ini(jn) =       sn_tracer(jn)%llinit
166         ln_trc_sbc(jn) =       sn_tracer(jn)%llsbc
167         ln_trc_cbc(jn) =       sn_tracer(jn)%llcbc
168         ln_trc_obc(jn) =       sn_tracer(jn)%llobc
169      END DO
170      !   
171      IF( ln_pisces  )   CALL trc_ini_pisces     !  PISCES model
172      IF( ln_my_trc  )   CALL trc_ini_my_trc     !  MY_TRC model
173      IF( ll_cfc     )   CALL trc_ini_cfc        !  CFC's
174      IF( ln_c14     )   CALL trc_ini_c14        !  C14 model
175      IF( ln_age     )   CALL trc_ini_age        !  AGE
176      !
177      IF(lwp) THEN                   ! control print
178         WRITE(numout,*)
179         WRITE(numout,*) ' trc_init: Summary for selected passive tracers'
180         WRITE(numout,*) ' ~~~~~~~~~~~~~~'
181         WRITE(numout,*) ' ID     NAME     INI  SBC  CBC  OBC'
182         DO jn = 1, jptra
183            WRITE(numout,9001) jn, TRIM(ctrcnm(jn)), ln_trc_ini(jn), ln_trc_sbc(jn),ln_trc_cbc(jn),ln_trc_obc(jn)
184         END DO
185      ENDIF
1869001  FORMAT(1x,i3,1x,a10,3x,l2,3x,l2,3x,l2,3x,l2)
187      !
188   END SUBROUTINE trc_ini_sms
189
190   SUBROUTINE trc_ini_trp
191      !!----------------------------------------------------------------------
192      !!                     ***  ROUTINE trc_ini_trp  ***
193      !!
194      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
195      !!----------------------------------------------------------------------
196      USE trcdmp , ONLY:  trc_dmp_ini
197      USE trcadv , ONLY:  trc_adv_ini
198      USE trcldf , ONLY:  trc_ldf_ini
199      USE trczdf , ONLY:  trc_zdf_ini
200      USE trcrad , ONLY:  trc_rad_ini
201      !
202      INTEGER :: ierr
203      !!----------------------------------------------------------------------
204      !
205      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
206                       CALL  trc_adv_ini          ! advection
207                       CALL  trc_ldf_ini          ! lateral diffusion
208                       CALL  trc_zdf_ini          ! vertical diffusion
209                       CALL  trc_rad_ini          ! positivity of passive tracers
210      !
211   END SUBROUTINE trc_ini_trp
212
213
214   SUBROUTINE trc_ini_state
215      !!----------------------------------------------------------------------
216      !!                     ***  ROUTINE trc_ini_state ***
217      !! ** Purpose :          Initialisation of passive tracer concentration
218      !!----------------------------------------------------------------------
219      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
220      USE trcrst          ! passive tracers restart
221      USE trcdta          ! initialisation from files
222      !
223      INTEGER :: jn, jl   ! dummy loop indices
224      !!----------------------------------------------------------------------
225      !
226      ! Initialisation of tracers Initial Conditions
227      IF( ln_trcdta )      CALL trc_dta_ini(jptra)
228
229      ! Initialisation of tracers Boundary Conditions
230      IF( ln_my_trc )     CALL trc_bc_ini(jptra)
231
232      IF( ln_rsttr ) THEN
233        !
234        CALL trc_rst_read              ! restart from a file
235        !
236      ELSE
237        ! Initialisation of tracer from a file that may also be used for damping
238        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN
239            ! update passive tracers arrays with input data read from file
240            DO jn = 1, jptra
241               IF( ln_trc_ini(jn) ) THEN
242                  jl = n_trc_index(jn) 
243                  CALL trc_dta( nit000, sf_trcdta(jl), rf_trfac(jl), trn(:,:,:,jn) )
244                  !
245                  ! deallocate data structure if data are not used for damping
246                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN
247                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
248                                                  DEALLOCATE( sf_trcdta(jl)%fnow )
249                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
250                     !
251                  ENDIF
252               ENDIF
253            ENDDO
254            !
255        ENDIF
256        !
257        trb(:,:,:,:) = trn(:,:,:,:)
258        !
259      ENDIF
260 
261      tra(:,:,:,:) = 0._wp
262      !                                                         ! Partial top/bottom cell: GRADh(trn)
263   END SUBROUTINE trc_ini_state
264
265   SUBROUTINE top_alloc
266      !!----------------------------------------------------------------------
267      !!                     ***  ROUTINE top_alloc  ***
268      !!
269      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
270      !!----------------------------------------------------------------------
271      USE trc           , ONLY:   trc_alloc
272      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
273#if defined key_trdmxl_trc 
274      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
275#endif
276      !
277      INTEGER :: ierr
278      !!----------------------------------------------------------------------
279      !
280      ierr =        trc_alloc()
281      ierr = ierr + trd_trc_oce_alloc()
282#if defined key_trdmxl_trc 
283      ierr = ierr + trd_mxl_trc_alloc()
284#endif
285      !
286      IF( lk_mpp    )   CALL mpp_sum( ierr )
287      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
288      !
289   END SUBROUTINE top_alloc
290
291#else
292   !!----------------------------------------------------------------------
293   !!  Empty module :                                     No passive tracer
294   !!----------------------------------------------------------------------
295CONTAINS
296   SUBROUTINE trc_init                      ! Dummy routine   
297   END SUBROUTINE trc_init
298#endif
299
300   !!======================================================================
301END MODULE trcini
Note: See TracBrowser for help on using the repository browser.