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 NEMO/trunk/src/TOP – NEMO

source: NEMO/trunk/src/TOP/trcini.F90 @ 12136

Last change on this file since 12136 was 12136, checked in by cetlod, 4 years ago

TOP updates

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