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

source: branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 7179

Last change on this file since 7179 was 7179, checked in by timgraham, 7 years ago

Manually merge in changes from v3.6_extra_CMIP6_diagnostics branch.
This change also includes a change of the domain_def.xml file so XIOS2 must be used from this revision onwards

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