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/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP – NEMO

source: NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcini.F90 @ 14644

Last change on this file since 14644 was 14644, checked in by sparonuz, 3 years ago

Merge trunk -r14642:HEAD

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