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

source: branches/UKMO/AMM15_v3_6_STABLE_package_FABM/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 10156

Last change on this file since 10156 was 10156, checked in by dford, 6 years ago

Apply patch fabm_patch_e3284ca_889163b.diff from Jim Clark.

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