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/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP – NEMO

source: NEMO/branches/2018/dev_r10164_HPC09_ESIWACE_PREP_MERGE/src/TOP/trcini.F90 @ 10345

Last change on this file since 10345 was 10345, checked in by smasson, 5 years ago

dev_r10164_HPC09_ESIWACE_PREP_MERGE: merge with trunk@10344, see #2133

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