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

source: branches/2015/nemo_v3_6_STABLE/NEMOGCM/NEMO/TOP_SRC/trcini.F90 @ 6967

Last change on this file since 6967 was 6941, checked in by cetlod, 8 years ago

v3.6stable: bugfix on TOP restartability with vvl and/or with diurnal cycle, see ticket #1773

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