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

source: branches/UKMO/AMM15_v3_6_STABLE_package_collate_utils366_fabmv1/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 13241

Last change on this file since 13241 was 13241, checked in by dford, 4 years ago

Update NEMO-FABM coupler for compatability with FABM v1.0.

File size: 11.0 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   ! +++>>> FABM
27   USE trcsms_fabm     ! FABM initialisation
28   USE trcini_fabm     ! FABM initialisation
29   ! FABM <<<FABM
30   USE trcdta          ! initialisation from files
31   USE daymod          ! calendar manager
32   USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
33   USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
34   USE trcsub          ! variables to substep passive tracers
35   USE lib_mpp         ! distribued memory computing library
36   USE sbc_oce
37   USE trcice          ! tracers in sea ice
38   USE trcbc,   only : trc_bc_init ! generalized Boundary Conditions
39 
40   IMPLICIT NONE
41   PRIVATE
42   
43   PUBLIC   trc_init   ! called by opa
44
45    !! * Substitutions
46#  include "domzgr_substitute.h90"
47   !!----------------------------------------------------------------------
48   !! NEMO/TOP 4.0 , NEMO Consortium (2011)
49   !! $Id$
50   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
51   !!----------------------------------------------------------------------
52CONTAINS
53   
54   SUBROUTINE trc_init
55      !!---------------------------------------------------------------------
56      !!                     ***  ROUTINE trc_init  ***
57      !!
58      !! ** Purpose :   Initialization of the passive tracer fields
59      !!
60      !! ** Method  : - read namelist
61      !!              - control the consistancy
62      !!              - compute specific initialisations
63      !!              - set initial tracer fields (either read restart
64      !!                or read data or analytical formulation
65      !!---------------------------------------------------------------------
66      INTEGER ::   jk, jn, jl    ! dummy loop indices
67      CHARACTER (len=25) :: charout
68      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 4D  workspace
69      !!---------------------------------------------------------------------
70      !
71      IF( nn_timing == 1 )   CALL timing_start('trc_init')
72      !
73      IF(lwp) WRITE(numout,*)
74      IF(lwp) WRITE(numout,*) 'trc_init : initial set up of the passive tracers'
75      IF(lwp) WRITE(numout,*) '~~~~~~~'
76      ! +++>>> FABM
77      ! Allow FABM to update numbers of biogeochemical tracers, diagnostics (jptra etc.)
78      IF( lk_fabm ) CALL nemo_fabm_configure
79      ! FABM <<<+++
80
81      CALL top_alloc()              ! allocate TOP arrays
82
83      l_trcdm2dc = ln_dm2dc  .AND. .NOT. lk_offline
84      IF( l_trcdm2dc .AND. lwp ) &
85         &   CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. &
86         & Computation of a daily mean shortwave for some biogeochemical models) ')
87
88      IF( nn_cla == 1 )   &
89         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
90
91      CALL trc_nam      ! read passive tracers namelists
92      !
93      IF(lwp) WRITE(numout,*)
94      !
95      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
96      !
97      IF(lwp) WRITE(numout,*)
98                                                              ! masked grid volume
99      !                                                              ! masked grid volume
100      DO jk = 1, jpk
101         cvol(:,:,jk) = e1e2t(:,:) * fse3t(:,:,jk) * tmask(:,:,jk)
102      END DO
103      IF( lk_degrad ) cvol(:,:,:) = cvol(:,:,:) * facvol(:,:,:)      ! degrad option: reduction by facvol
104      !                                                              ! total volume of the ocean
105      areatot = glob_sum( cvol(:,:,:) )
106
107      IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
108      IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
109      IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
110      IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
111      ! +++>>> FABM
112      IF( lk_fabm    )       CALL trc_ini_fabm         ! FABM    tracers
113      ! FABM <<<+++
114
115      CALL trc_ice_ini                                 ! Tracers in sea ice
116
117      IF( lwp ) THEN
118         !
119         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
120         !
121      ENDIF
122
123      ! Initialisation of tracers Initial Conditions
124      IF( ln_trcdta )      CALL trc_dta_init(jptra)
125
126      IF( ln_rsttr ) THEN
127        !
128        CALL trc_rst_read              ! restart from a file
129        !
130      ELSE
131        !
132        IF( ln_trcdta .AND. nb_trcdta > 0 ) THEN  ! Initialisation of tracer from a file that may also be used for damping
133            !
134            CALL wrk_alloc( jpi, jpj, jpk, ztrcdta )    ! Memory allocation
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                  CALL trc_dta( nit000, sf_trcdta(jl),rf_trfac(jl) )   ! read tracer data at nit000
140                  ztrcdta(:,:,:) = sf_trcdta(jl)%fnow(:,:,:)
141                  trn(:,:,:,jn) = ztrcdta(:,:,:) * tmask(:,:,:) 
142                  IF( .NOT.ln_trcdmp .AND. .NOT.ln_trcdmp_clo ) THEN      !== deallocate data structure   ==!
143                     !                                                    (data used only for initialisation)
144                     IF(lwp) WRITE(numout,*) 'trc_dta: deallocate data arrays as they are only used to initialize the run'
145                                                  DEALLOCATE( sf_trcdta(jl)%fnow )     !  arrays in the structure
146                     IF( sf_trcdta(jl)%ln_tint )  DEALLOCATE( sf_trcdta(jl)%fdta )
147                     !
148                  ENDIF
149               ENDIF
150            ENDDO
151            CALL wrk_dealloc( jpi, jpj, jpk, ztrcdta )
152        ENDIF
153        !
154        trb(:,:,:,:) = trn(:,:,:,:)
155        !
156      ENDIF
157      ! --->>> FABM
158! Initialisation of tracers Boundary Conditions  - here so that you can use initial condition as boundary
159      !IF( lk_my_trc )     CALL trc_bc_init(jptra)
160      ! FABM <<<---
161      ! FABM +++>>>
162! Initialisation of FABM diagnostics and tracer boundary conditions (so that you can use initial condition as boundary)
163      IF( lk_fabm )     CALL trc_bc_init(jptra) 
164      ! FABM <<<+++
165
166      tra(:,:,:,:) = 0._wp
167      IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav )   &              ! Partial steps: before horizontal gradient of passive
168        &    CALL zps_hde    ( nit000, jptra, trn, gtru, gtrv  )  ! Partial steps: before horizontal gradient
169      IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav )   &
170        &    CALL zps_hde_isf( nit000, jptra, trn, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )       ! tracers at the bottom ocean level
171
172
173      !
174      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
175      !
176
177      trai(:) = 0._wp                                                   ! initial content of all tracers
178      DO jn = 1, jptra
179         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
180      END DO
181
182      IF(lwp) THEN               ! control print
183         WRITE(numout,*)
184         WRITE(numout,*)
185         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
186         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
187         WRITE(numout,*) '          *** Total inital content of all tracers '
188         WRITE(numout,*)
189         DO jn = 1, jptra
190            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
191         ENDDO
192         WRITE(numout,*)
193      ENDIF
194      IF(lwp) WRITE(numout,*)
195      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
196         CALL prt_ctl_trc_init
197         WRITE(charout, FMT="('ini ')")
198         CALL prt_ctl_trc_info( charout )
199         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
200      ENDIF
2019000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
202      !
203      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
204      !
205   END SUBROUTINE trc_init
206
207
208   SUBROUTINE top_alloc
209      !!----------------------------------------------------------------------
210      !!                     ***  ROUTINE top_alloc  ***
211      !!
212      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
213      !!----------------------------------------------------------------------
214      USE trcadv        , ONLY:   trc_adv_alloc          ! TOP-related alloc routines...
215      USE trc           , ONLY:   trc_alloc
216      USE trcnxt        , ONLY:   trc_nxt_alloc
217      USE trczdf        , ONLY:   trc_zdf_alloc
218      USE trdtrc_oce    , ONLY:   trd_trc_oce_alloc
219#if defined key_trdmxl_trc 
220      USE trdmxl_trc    , ONLY:   trd_mxl_trc_alloc
221#endif
222      !
223      INTEGER :: ierr
224      !!----------------------------------------------------------------------
225      !
226      ierr =        trc_adv_alloc()          ! Start of TOP-related alloc routines...
227      ierr = ierr + trc_alloc    ()
228      ierr = ierr + trc_nxt_alloc()
229      ierr = ierr + trc_zdf_alloc()
230      ierr = ierr + trd_trc_oce_alloc()
231#if defined key_trdmxl_trc 
232      ierr = ierr + trd_mxl_trc_alloc()
233#endif
234      !
235      IF( lk_mpp    )   CALL mpp_sum( ierr )
236      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'top_alloc : unable to allocate standard ocean arrays' )
237      !
238   END SUBROUTINE top_alloc
239
240#else
241   !!----------------------------------------------------------------------
242   !!  Empty module :                                     No passive tracer
243   !!----------------------------------------------------------------------
244CONTAINS
245   SUBROUTINE trc_init                      ! Dummy routine   
246   END SUBROUTINE trc_init
247#endif
248
249   !!======================================================================
250END MODULE trcini
Note: See TracBrowser for help on using the repository browser.