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.
trcnxt.F90 in trunk/NEMOGCM/NEMO/TOP_SRC/TRP – NEMO

source: trunk/NEMOGCM/NEMO/TOP_SRC/TRP/trcnxt.F90 @ 7702

Last change on this file since 7702 was 7698, checked in by mocavero, 7 years ago

update trunk with OpenMP parallelization

  • Property svn:keywords set to Id
File size: 7.5 KB
RevLine 
[941]1MODULE trcnxt
2   !!======================================================================
3   !!                       ***  MODULE  trcnxt  ***
4   !! Ocean passive tracers:  time stepping on passives tracers
5   !!======================================================================
[2528]6   !! History :  7.0  !  1991-11  (G. Madec)  Original code
7   !!                 !  1993-03  (M. Guyon)  symetrical conditions
8   !!                 !  1995-02  (M. Levy)   passive tracers
9   !!                 !  1996-02  (G. Madec & M. Imbard)  opa release 8.0
10   !!            8.0  !  1996-04  (A. Weaver)  Euler forward step
11   !!            8.2  !  1999-02  (G. Madec, N. Grima)  semi-implicit pressure grad.
12   !!  NEMO      1.0  !  2002-08  (G. Madec)  F90: Free form and module
13   !!                 !  2002-08  (G. Madec)  F90: Free form and module
14   !!                 !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
15   !!                 !  2004-03  (C. Ethe) passive tracers
16   !!                 !  2007-02  (C. Deltel) Diagnose ML trends for passive tracers
17   !!            2.0  !  2006-02  (L. Debreu, C. Mazauric) Agrif implementation
18   !!            3.0  !  2008-06  (G. Madec)  time stepping always done in trazdf
19   !!            3.1  !  2009-02  (G. Madec, R. Benshila)  re-introduce the vvl option
20   !!            3.3  !  2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
[1175]21   !!----------------------------------------------------------------------
[941]22#if defined key_top
23   !!----------------------------------------------------------------------
24   !!   'key_top'                                                TOP models
25   !!----------------------------------------------------------------------
26   !!   trc_nxt     : time stepping on passive tracers
27   !!----------------------------------------------------------------------
28   USE oce_trc         ! ocean dynamics and tracers variables
[2528]29   USE trc             ! ocean passive tracers variables
[941]30   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
31   USE prtctl_trc      ! Print control for debbuging
[4990]32   USE trd_oce
[2528]33   USE trdtra
34   USE tranxt
[7646]35   USE bdy_oce   , ONLY: ln_bdy
[6140]36   USE trcbdy          ! BDY open boundaries
[2528]37# if defined key_agrif
[941]38   USE agrif_top_interp
[2528]39# endif
[941]40
41   IMPLICIT NONE
42   PRIVATE
43
[2715]44   PUBLIC   trc_nxt          ! routine called by step.F90
[2528]45
[941]46   !!----------------------------------------------------------------------
[2528]47   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
[7698]48   !! $Id$
[2715]49   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
[941]50   !!----------------------------------------------------------------------
51CONTAINS
52
53   SUBROUTINE trc_nxt( kt )
54      !!----------------------------------------------------------------------
55      !!                   ***  ROUTINE trcnxt  ***
56      !!
57      !! ** Purpose :   Compute the passive tracers fields at the
58      !!      next time-step from their temporal trends and swap the fields.
59      !!
60      !! ** Method  :   Apply lateral boundary conditions on (ua,va) through
61      !!      call to lbc_lnk routine
62      !!   default:
63      !!      arrays swap
64      !!         (trn) = (tra) ; (tra) = (0,0)
65      !!         (trb) = (trn)
66      !!
67      !!   For Arakawa or TVD Scheme :
68      !!      A Asselin time filter applied on now tracers (trn) to avoid
69      !!      the divergence of two consecutive time-steps and tr arrays
70      !!      to prepare the next time_step:
71      !!         (trb) = (trn) + atfp [ (trb) + (tra) - 2 (trn) ]
72      !!         (trn) = (tra) ; (tra) = (0,0)
73      !!
74      !!
75      !! ** Action  : - update trb, trn
76      !!----------------------------------------------------------------------
[1271]77      INTEGER, INTENT( in ) ::   kt     ! ocean time-step index
[2715]78      !
[7698]79      INTEGER  ::   jk, jn, jj, ji   ! dummy loop indices
[941]80      REAL(wp) ::   zfact            ! temporary scalar
81      CHARACTER (len=22) :: charout
[3294]82      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  ztrdt 
[941]83      !!----------------------------------------------------------------------
[3294]84      !
85      IF( nn_timing == 1 )  CALL timing_start('trc_nxt')
86      !
87      IF( kt == nittrc000 .AND. lwp ) THEN
[941]88         WRITE(numout,*)
89         WRITE(numout,*) 'trc_nxt : time stepping on passive tracers'
90      ENDIF
[6140]91      !
[5656]92#if defined key_agrif
93      CALL Agrif_trc                   ! AGRIF zoom boundaries
94#endif
[6140]95      DO jn = 1, jptra                 ! Update after tracer on domain lateral boundaries
[941]96         CALL lbc_lnk( tra(:,:,:,jn), 'T', 1. )   
[2528]97      END DO
[941]98
[7646]99      IF( ln_bdy )  CALL trc_bdy( kt )
[941]100
[6140]101      IF( l_trdtrc )  THEN             ! trends: store now fields before the Asselin filter application
102         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrdt )
[7698]103!$OMP PARALLEL DO schedule(static) private(jn,jk,jj,ji)
104         DO jn = 1, jptra
105            DO jk = 1, jpk
106               DO jj = 1, jpj
107                  DO ji = 1, jpi
108                     ztrdt(ji,jj,jk,jn)  = trn(ji,jj,jk,jn)
109                  END DO
110               END DO
111            END DO
112         END DO
[2528]113      ENDIF
[6140]114      !                                ! Leap-Frog + Asselin filter time stepping
115      IF( neuler == 0 .AND. kt == nittrc000 ) THEN    ! Euler time-stepping at first time-step (only swap)
[7698]116!$OMP PARALLEL DO schedule(static) private(jn,jk,jj,ji)
[2528]117         DO jn = 1, jptra
118            DO jk = 1, jpkm1
[7698]119               DO jj = 1, jpj
120                  DO ji = 1, jpi
121                     trn(ji,jj,jk,jn) = tra(ji,jj,jk,jn)
122                  END DO
123               END DO
[2528]124            END DO
125         END DO
[6140]126      ELSE                                            ! Asselin filter + swap
127         IF( ln_linssh ) THEN   ;   CALL tra_nxt_fix( kt, nittrc000,         'TRC', trb, trn, tra, jptra )  !     linear ssh
128         ELSE                   ;   CALL tra_nxt_vvl( kt, nittrc000, rdttrc, 'TRC', trb, trn, tra,      &
129           &                                                                   sbc_trc, sbc_trc_b, jptra )  ! non-linear ssh
[2528]130         ENDIF
[6140]131         !
132         DO jn = 1, jptra
133            CALL lbc_lnk( trb(:,:,:,jn), 'T', 1._wp ) 
134            CALL lbc_lnk( trn(:,:,:,jn), 'T', 1._wp )
135            CALL lbc_lnk( tra(:,:,:,jn), 'T', 1._wp )
136         END DO
[2528]137      ENDIF
[6140]138      !
139      IF( l_trdtrc ) THEN              ! trends: send Asselin filter trends to trdtra manager for further diagnostics
[2528]140         DO jn = 1, jptra
141            DO jk = 1, jpkm1
[6140]142               zfact = 1._wp / r2dttrc 
[7698]143!$OMP PARALLEL DO schedule(static) private(jj,ji)
144               DO jj = 1, jpj
145                  DO ji = 1, jpi
146                     ztrdt(ji,jj,jk,jn) = ( trb(ji,jj,jk,jn) - ztrdt(ji,jj,jk,jn) ) * zfact
147                  END DO
148               END DO
[4990]149               CALL trd_tra( kt, 'TRC', jn, jptra_atf, ztrdt )
[1175]150            END DO
[2528]151         END DO
[3294]152         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrdt ) 
[2528]153      END IF
154      !
[941]155      IF(ln_ctl)   THEN  ! print mean trends (used for debugging)
156         WRITE(charout, FMT="('nxt')")
157         CALL prt_ctl_trc_info(charout)
158         CALL prt_ctl_trc(tab4d=trn, mask=tmask, clinfo=ctrcnm)
159      ENDIF
[2528]160      !
[3294]161      IF( nn_timing == 1 )  CALL timing_stop('trc_nxt')
162      !
[941]163   END SUBROUTINE trc_nxt
164
165#else
166   !!----------------------------------------------------------------------
167   !!   Default option                                         Empty module
168   !!----------------------------------------------------------------------
169CONTAINS
170   SUBROUTINE trc_nxt( kt ) 
171      INTEGER, INTENT(in) :: kt
172      WRITE(*,*) 'trc_nxt: You should not have seen this print! error?', kt
173   END SUBROUTINE trc_nxt
174#endif
175   !!======================================================================
176END MODULE trcnxt
Note: See TracBrowser for help on using the repository browser.