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.
trdvor.F90 in NEMO/trunk/src/OCE/TRD – NEMO

source: NEMO/trunk/src/OCE/TRD/trdvor.F90

Last change on this file was 15033, checked in by smasson, 3 years ago

trunk: suppress jpim1 et jpjm1, #2699

  • Property svn:keywords set to Id
File size: 25.2 KB
RevLine 
[109]1MODULE trdvor
2   !!======================================================================
3   !!                       ***  MODULE  trdvor  ***
4   !! Ocean diagnostics:  momentum trends
5   !!=====================================================================
[4990]6   !! History :  1.0  !  2006-01  (L. Brunier, A-M. Treguier) Original code
7   !!            2.0  !  2008-04  (C. Talandier) New trends organization
8   !!            3.5  !  2012-02  (G. Madec) regroup beta.V computation with pvo trend
[503]9   !!----------------------------------------------------------------------
[4990]10
[109]11   !!----------------------------------------------------------------------
12   !!   trd_vor      : momentum trends averaged over the depth
[216]13   !!   trd_vor_zint : vorticity vertical integration
14   !!   trd_vor_init : initialization step
[109]15   !!----------------------------------------------------------------------
[129]16   USE oce             ! ocean dynamics and tracers variables
[109]17   USE dom_oce         ! ocean space and time domain variables
[4990]18   USE trd_oce         ! trends: ocean variables
[109]19   USE zdf_oce         ! ocean vertical physics
[4990]20   USE sbc_oce         ! surface boundary condition: ocean
[109]21   USE phycst          ! Define parameters for the routines
[5836]22   USE ldfdyn          ! ocean active tracers: lateral physics
[109]23   USE dianam          ! build the name of file (routine)
[216]24   USE zdfmxl          ! mixed layer depth
[5836]25   !
[4990]26   USE in_out_manager  ! I/O manager
[216]27   USE ioipsl          ! NetCDF library
[5836]28   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
[2715]29   USE lib_mpp         ! MPP library
[109]30
31   IMPLICIT NONE
32   PRIVATE
[129]33
[216]34   INTERFACE trd_vor_zint
35      MODULE PROCEDURE trd_vor_zint_2d, trd_vor_zint_3d
36   END INTERFACE
[129]37
[4990]38   PUBLIC   trd_vor        ! routine called by trddyn.F90
[503]39   PUBLIC   trd_vor_init   ! routine called by opa.F90
[2715]40   PUBLIC   trd_vor_alloc  ! routine called by nemogcm.F90
[109]41
[2715]42   INTEGER ::   nh_t, nmoydpvor, nidvor, nhoridvor, ndimvor1, icount   ! needs for IOIPSL output
43   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) ::   ndexvor1   ! needed for IOIPSL output
[2528]44   INTEGER ::   ndebug     ! (0/1) set it to 1 in case of problem to have more print
[109]45
[2715]46   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avr      ! average
47   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrb     ! before vorticity (kt-1)
[11536]48   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrbb    ! vorticity at begining of the nn_write-1 timestep averaging period
[2715]49   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrbn    ! after vorticity at time step after the
[11536]50   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   rotot        ! begining of the NN_WRITE-1 timesteps
[2715]51   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrtot   !
52   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:)   ::   vor_avrres   !
53   REAL(wp), SAVE, ALLOCATABLE, DIMENSION(:,:,:) ::   vortrd       ! curl of trends
[503]54         
[216]55   CHARACTER(len=12) ::   cvort
56
[109]57   !! * Substitutions
[12377]58#  include "do_loop_substitute.h90"
[13237]59#  include "domzgr_substitute.h90"
[109]60   !!----------------------------------------------------------------------
[9598]61   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
[1152]62   !! $Id$
[10068]63   !! Software governed by the CeCILL license (see ./LICENSE)
[109]64   !!----------------------------------------------------------------------
65CONTAINS
66
[2715]67   INTEGER FUNCTION trd_vor_alloc()
68      !!----------------------------------------------------------------------------
69      !!                  ***  ROUTINE trd_vor_alloc  ***
70      !!----------------------------------------------------------------------------
71      ALLOCATE( vor_avr   (jpi,jpj) , vor_avrb(jpi,jpj) , vor_avrbb (jpi,jpj) ,   &
72         &      vor_avrbn (jpi,jpj) , rotot   (jpi,jpj) , vor_avrtot(jpi,jpj) ,   &
73         &      vor_avrres(jpi,jpj) , vortrd  (jpi,jpj,jpltot_vor) ,              &
74         &      ndexvor1  (jpi*jpj)                                ,   STAT= trd_vor_alloc )
75         !
[10425]76      CALL mpp_sum ( 'trdvor', trd_vor_alloc )
77      IF( trd_vor_alloc /= 0 )   CALL ctl_stop( 'STOP', 'trd_vor_alloc: failed to allocate arrays' )
[2715]78   END FUNCTION trd_vor_alloc
79
80
[12377]81   SUBROUTINE trd_vor( putrd, pvtrd, ktrd, kt, Kmm )
[4990]82      !!----------------------------------------------------------------------
83      !!                  ***  ROUTINE trd_vor  ***
84      !!
85      !! ** Purpose :  computation of cumulated trends over analysis period
[6140]86      !!               and make outputs (NetCDF format)
[4990]87      !!----------------------------------------------------------------------
88      REAL(wp), DIMENSION(:,:,:), INTENT(inout) ::   putrd, pvtrd   ! U and V trends
89      INTEGER                   , INTENT(in   ) ::   ktrd           ! trend index
90      INTEGER                   , INTENT(in   ) ::   kt             ! time step
[12377]91      INTEGER                   , INTENT(in   ) ::   Kmm            ! time level index
[4990]92      !
93      INTEGER ::   ji, jj   ! dummy loop indices
[9125]94      REAL(wp), DIMENSION(jpi,jpj) ::   ztswu, ztswv    ! 2D workspace
[4990]95      !!----------------------------------------------------------------------
96
[15033]97      CALL lbc_lnk( 'trdvor', putrd, 'U', -1.0_wp , pvtrd, 'V', -1.0_wp )      ! lateral boundary condition
98
[4990]99      SELECT CASE( ktrd ) 
[12377]100      CASE( jpdyn_hpg )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_prg, Kmm )   ! Hydrostatique Pressure Gradient
101      CASE( jpdyn_keg )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_keg, Kmm )   ! KE Gradient
102      CASE( jpdyn_rvo )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_rvo, Kmm )   ! Relative Vorticity
103      CASE( jpdyn_pvo )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_pvo, Kmm )   ! Planetary Vorticity Term
104      CASE( jpdyn_ldf )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_ldf, Kmm )   ! Horizontal Diffusion
105      CASE( jpdyn_zad )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_zad, Kmm )   ! Vertical Advection
106      CASE( jpdyn_spg )   ;   CALL trd_vor_zint( putrd, pvtrd, jpvor_spg, Kmm )   ! Surface Pressure Grad.
[13497]107      CASE( jpdyn_zdf )                                                           ! Vertical Diffusion
[15033]108         DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )                                                               ! wind stress trends
[12489]109            ztswu(ji,jj) = 0.5 * ( utau_b(ji,jj) + utau(ji,jj) ) / ( e3u(ji,jj,1,Kmm) * rho0 )
110            ztswv(ji,jj) = 0.5 * ( vtau_b(ji,jj) + vtau(ji,jj) ) / ( e3v(ji,jj,1,Kmm) * rho0 )
[12377]111         END_2D
112         CALL trd_vor_zint( putrd, pvtrd, jpvor_zdf, Kmm )                             ! zdf trend including surf./bot. stresses
113         CALL trd_vor_zint( ztswu, ztswv, jpvor_swf, Kmm )                             ! surface wind stress
[4990]114      CASE( jpdyn_bfr )
[12377]115         CALL trd_vor_zint( putrd, pvtrd, jpvor_bfr, Kmm )                             ! Bottom stress
[4990]116         !
117      CASE( jpdyn_atf )       ! last trends: perform the output of 2D vorticity trends
[12377]118         CALL trd_vor_iom( kt, Kmm )
[4990]119      END SELECT
120      !
121   END SUBROUTINE trd_vor
122
123
[12377]124   SUBROUTINE trd_vor_zint_2d( putrdvor, pvtrdvor, ktrd, Kmm )
[129]125      !!----------------------------------------------------------------------------
[216]126      !!                  ***  ROUTINE trd_vor_zint  ***
[109]127      !!
128      !! ** Purpose :   computation of vertically integrated vorticity budgets
[2528]129      !!              from ocean surface down to control surface (NetCDF output)
[109]130      !!
[11536]131      !! ** Method/usage :   integration done over nn_write-1 time steps
[109]132      !!
[2528]133      !! ** Action :   trends :
[503]134      !!                  vortrd (,, 1) = Pressure Gradient Trend
135      !!                  vortrd (,, 2) = KE Gradient Trend
136      !!                  vortrd (,, 3) = Relative Vorticity Trend
137      !!                  vortrd (,, 4) = Coriolis Term Trend
138      !!                  vortrd (,, 5) = Horizontal Diffusion Trend
139      !!                  vortrd (,, 6) = Vertical Advection Trend
140      !!                  vortrd (,, 7) = Vertical Diffusion Trend
141      !!                  vortrd (,, 8) = Surface Pressure Grad. Trend
142      !!                  vortrd (,, 9) = Beta V
[109]143      !!                  vortrd (,,10) = forcing term
[15033]144      !!      vortrd (,,11) = bottom friction term
[11536]145      !!                  rotot(,) : total cumulative trends over nn_write-1 time steps
[109]146      !!                  vor_avrtot(,) : first membre of vrticity equation
147      !!                  vor_avrres(,) : residual = dh/dt entrainment
148      !!
149      !!      trends output in netCDF format using ioipsl
150      !!----------------------------------------------------------------------
[15033]151      INTEGER                     , INTENT(in) ::   ktrd       ! ocean trend index
152      INTEGER                     , INTENT(in) ::   Kmm        ! time level index
153      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   putrdvor   ! u vorticity trend
154      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   pvtrdvor   ! v vorticity trend
[2715]155      !
[2528]156      INTEGER ::   ji, jj       ! dummy loop indices
157      INTEGER ::   ikbu, ikbv   ! local integers
[9125]158      REAL(wp), DIMENSION(jpi,jpj) :: zudpvor, zvdpvor  ! total cmulative trends
[216]159      !!----------------------------------------------------------------------
[109]160
[216]161      !  =====================================
162      !  I vertical integration of 2D trends
163      !  =====================================
164
[4990]165      SELECT CASE( ktrd ) 
[2528]166      !
[4990]167      CASE( jpvor_bfr )        ! bottom friction
[15033]168         DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
[12377]169            ikbu = mbkv(ji,jj)
170            ikbv = mbkv(ji,jj)           
171            zudpvor(ji,jj) = putrdvor(ji,jj) * e3u(ji,jj,ikbu,Kmm) * e1u(ji,jj) * umask(ji,jj,ikbu)
172            zvdpvor(ji,jj) = pvtrdvor(ji,jj) * e3v(ji,jj,ikbv,Kmm) * e2v(ji,jj) * vmask(ji,jj,ikbv)
173         END_2D
[2528]174         !
[4990]175      CASE( jpvor_swf )        ! wind stress
[12377]176         zudpvor(:,:) = putrdvor(:,:) * e3u(:,:,1,Kmm) * e1u(:,:) * umask(:,:,1)
177         zvdpvor(:,:) = pvtrdvor(:,:) * e3v(:,:,1,Kmm) * e2v(:,:) * vmask(:,:,1)
[2528]178         !
[216]179      END SELECT
180
181      ! Average except for Beta.V
[12377]182      zudpvor(:,:) = zudpvor(:,:) * r1_hu(:,:,Kmm)
183      zvdpvor(:,:) = zvdpvor(:,:) * r1_hv(:,:,Kmm)
[216]184   
185      ! Curl
[15033]186      DO_2D( 0, 0, 0, 0 )
187         vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)       &
188            &                  - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) )   ) &
189            &                  / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
190      END_2D
[216]191
[2528]192      IF( ndebug /= 0 ) THEN
[216]193         IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
194         CALL FLUSH(numout)
195      ENDIF
[503]196      !
[216]197   END SUBROUTINE trd_vor_zint_2d
198
199
[12377]200   SUBROUTINE trd_vor_zint_3d( putrdvor, pvtrdvor, ktrd , Kmm )
[216]201      !!----------------------------------------------------------------------------
202      !!                  ***  ROUTINE trd_vor_zint  ***
203      !!
204      !! ** Purpose :   computation of vertically integrated vorticity budgets
[2528]205      !!              from ocean surface down to control surface (NetCDF output)
[216]206      !!
[11536]207      !! ** Method/usage :   integration done over nn_write-1 time steps
[216]208      !!
[2528]209      !! ** Action :     trends :
[216]210      !!                  vortrd (,,1) = Pressure Gradient Trend
211      !!                  vortrd (,,2) = KE Gradient Trend
212      !!                  vortrd (,,3) = Relative Vorticity Trend
213      !!                  vortrd (,,4) = Coriolis Term Trend
214      !!                  vortrd (,,5) = Horizontal Diffusion Trend
215      !!                  vortrd (,,6) = Vertical Advection Trend
216      !!                  vortrd (,,7) = Vertical Diffusion Trend
217      !!                  vortrd (,,8) = Surface Pressure Grad. Trend
218      !!                  vortrd (,,9) = Beta V
219      !!                  vortrd (,,10) = forcing term
220      !!      vortrd (,,11) = bottom friction term
[11536]221      !!                  rotot(,) : total cumulative trends over nn_write-1 time steps
[216]222      !!                  vor_avrtot(,) : first membre of vrticity equation
223      !!                  vor_avrres(,) : residual = dh/dt entrainment
224      !!
225      !!      trends output in netCDF format using ioipsl
[109]226      !!----------------------------------------------------------------------
[2715]227      !
[15033]228      INTEGER                         , INTENT(in) ::   ktrd       ! ocean trend index
229      INTEGER                         , INTENT(in) ::   Kmm        ! time level index
230      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   putrdvor   ! u vorticity trend
231      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   pvtrdvor   ! v vorticity trend
[2715]232      !
233      INTEGER ::   ji, jj, jk   ! dummy loop indices
[9125]234      REAL(wp), DIMENSION(jpi,jpj) :: zudpvor, zvdpvor  ! total cmulative trends
[216]235      !!----------------------------------------------------------------------
[109]236
[216]237      !  =====================================
238      !  I vertical integration of 3D trends
239      !  =====================================
240      ! putrdvor and pvtrdvor terms
241      DO jk = 1,jpk
[12377]242        zudpvor(:,:) = zudpvor(:,:) + putrdvor(:,:,jk) * e3u(:,:,jk,Kmm) * e1u(:,:) * umask(:,:,jk)
243        zvdpvor(:,:) = zvdpvor(:,:) + pvtrdvor(:,:,jk) * e3v(:,:,jk,Kmm) * e2v(:,:) * vmask(:,:,jk)
[216]244      END DO
[109]245
[4990]246      ! Planetary vorticity: 2nd computation (Beta.V term) store the vertical sum
247      ! as Beta.V term need intergration, not average
248      IF( ktrd == jpvor_pvo ) THEN
[15033]249         DO_2D( 0, 0, 0, 0 )
250            vortrd(ji,jj,jpvor_bev) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)     &
251               &                       - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
252               &                           / ( e1f(ji,jj) * e2f(ji,jj) ) * r1_hu(ji,jj,Kmm) * fmask(ji,jj,1)
253         END_2D
[216]254      ENDIF
[4990]255      !
256      ! Average
[12377]257      zudpvor(:,:) = zudpvor(:,:) * r1_hu(:,:,Kmm)
258      zvdpvor(:,:) = zvdpvor(:,:) * r1_hv(:,:,Kmm)
[4990]259      !
[216]260      ! Curl
[15033]261      DO_2D( 0, 0, 0, 0 )
262         vortrd(ji,jj,ktrd) = (    zvdpvor(ji+1,jj) - zvdpvor(ji,jj)     &
263            &                  - ( zudpvor(ji,jj+1) - zudpvor(ji,jj) ) ) &
264            &                         / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
265      END_2D
[216]266   
[2528]267      IF( ndebug /= 0 ) THEN
[216]268         IF(lwp) WRITE(numout,*) ' debuging trd_vor_zint: I done'
269         CALL FLUSH(numout)
270      ENDIF
[503]271      !
[216]272   END SUBROUTINE trd_vor_zint_3d
[109]273
[216]274
[12377]275   SUBROUTINE trd_vor_iom( kt , Kmm )
[216]276      !!----------------------------------------------------------------------
277      !!                  ***  ROUTINE trd_vor  ***
278      !!
279      !! ** Purpose :  computation of cumulated trends over analysis period
[6140]280      !!               and make outputs (NetCDF format)
[216]281      !!----------------------------------------------------------------------
[4990]282      INTEGER                   , INTENT(in   ) ::   kt             ! time step
[12377]283      INTEGER                   , INTENT(in   ) ::   Kmm            ! time level index
[2715]284      !
[2528]285      INTEGER  ::   ji, jj, jk, jl   ! dummy loop indices
286      INTEGER  ::   it, itmod        ! local integers
287      REAL(wp) ::   zmean            ! local scalars
[12377]288      REAL(wp), DIMENSION(jpi,jpj) :: zuu, zvv
[216]289      !!----------------------------------------------------------------------
290
291      !  =================
292      !  I. Initialization
293      !  =================
294     
295     
296      ! I.1 set before values of vertically average u and v
297      ! ---------------------------------------------------
298
[2528]299      IF( kt > nit000 )   vor_avrb(:,:) = vor_avr(:,:)
[109]300
[216]301      ! I.2 vertically integrated vorticity
302      !  ----------------------------------
[109]303
[2528]304      vor_avr   (:,:) = 0._wp
[12377]305      zuu       (:,:) = 0._wp
306      zvv       (:,:) = 0._wp
[2528]307      vor_avrtot(:,:) = 0._wp
308      vor_avrres(:,:) = 0._wp
[109]309     
[216]310      ! Vertically averaged velocity
[109]311      DO jk = 1, jpk - 1
[12377]312         zuu(:,:) = zuu(:,:) + e1u(:,:) * uu(:,:,jk,Kmm) * e3u(:,:,jk,Kmm)
313         zvv(:,:) = zvv(:,:) + e2v(:,:) * vv(:,:,jk,Kmm) * e3v(:,:,jk,Kmm)
[109]314      END DO
315 
[12377]316      zuu(:,:) = zuu(:,:) * r1_hu(:,:,Kmm)
317      zvv(:,:) = zvv(:,:) * r1_hv(:,:,Kmm)
[109]318
[216]319      ! Curl
[15033]320      DO_2D( 0, 0, 0, 0 )
321         vor_avr(ji,jj) = (  ( zvv(ji+1,jj) - zvv(ji,jj) )    &
322            &              - ( zuu(ji,jj+1) - zuu(ji,jj) ) )  &
323            &             / ( e1f(ji,jj) * e2f(ji,jj) ) * fmask(ji,jj,1)
324      END_2D
[109]325     
326      !  =================================
[216]327      !   II. Cumulated trends
[109]328      !  =================================
329
[216]330      ! II.1 set `before' mixed layer values for kt = nit000+1
331      ! ------------------------------------------------------
[109]332      IF( kt == nit000+1 ) THEN
333         vor_avrbb(:,:) = vor_avrb(:,:)
334         vor_avrbn(:,:) = vor_avr (:,:)
335      ENDIF
336
[11536]337      ! II.2 cumulated trends over analysis period (kt=2 to nn_write)
[109]338      ! ----------------------
[11536]339      ! trends cumulated over nn_write-2 time steps
[109]340
341      IF( kt >= nit000+2 ) THEN
342         nmoydpvor = nmoydpvor + 1
[503]343         DO jl = 1, jpltot_vor
[129]344            IF( jl /= 9 ) THEN
345               rotot(:,:) = rotot(:,:) + vortrd(:,:,jl)
346            ENDIF
[109]347         END DO
348      ENDIF
349
350      !  =============================================
[216]351      !   III. Output in netCDF + residual computation
[109]352      !  =============================================
[11536]353     
[1317]354      ! define time axis
[2528]355      it    = kt
[1334]356      itmod = kt - nit000 + 1
[109]357
[1601]358      IF( MOD( it, nn_trd ) == 0 ) THEN
[1317]359
[216]360         ! III.1 compute total trend
[109]361         ! ------------------------
[12489]362         zmean = 1._wp / (  REAL( nmoydpvor, wp ) * 2._wp * rn_Dt  )
[2528]363         vor_avrtot(:,:) = (  vor_avr(:,:) - vor_avrbn(:,:) + vor_avrb(:,:) - vor_avrbb(:,:) ) * zmean
[109]364
365
[216]366         ! III.2 compute residual
[109]367         ! ---------------------
[2528]368         zmean = 1._wp / REAL( nmoydpvor, wp )
[109]369         vor_avrres(:,:) = vor_avrtot(:,:) - rotot(:,:) / zmean
370
[129]371         ! Boundary conditions
[14433]372         CALL lbc_lnk( 'trdvor', vor_avrtot, 'F', 1.0_wp , vor_avrres, 'F', 1.0_wp )
[109]373
374
[216]375         ! III.3 time evolution array swap
[109]376         ! ------------------------------
377         vor_avrbb(:,:) = vor_avrb(:,:)
[2528]378         vor_avrbn(:,:) = vor_avr (:,:)
379         !
380         nmoydpvor = 0
381         !
[109]382      ENDIF
383
[216]384      ! III.4 write trends to output
[109]385      ! ---------------------------
[216]386
[109]387      IF( kt >=  nit000+1 ) THEN
388
[1601]389         IF( lwp .AND. MOD( itmod, nn_trd ) == 0 ) THEN
[503]390            WRITE(numout,*) ''
391            WRITE(numout,*) 'trd_vor : write trends in the NetCDF file at kt = ', kt
392            WRITE(numout,*) '~~~~~~~  '
[216]393         ENDIF
394 
[503]395         CALL histwrite( nidvor,"sovortPh",it,vortrd(:,:,jpvor_prg),ndimvor1,ndexvor1)  ! grad Ph
396         CALL histwrite( nidvor,"sovortEk",it,vortrd(:,:,jpvor_keg),ndimvor1,ndexvor1)  ! Energy
397         CALL histwrite( nidvor,"sovozeta",it,vortrd(:,:,jpvor_rvo),ndimvor1,ndexvor1)  ! rel vorticity
398         CALL histwrite( nidvor,"sovortif",it,vortrd(:,:,jpvor_pvo),ndimvor1,ndexvor1)  ! coriolis
399         CALL histwrite( nidvor,"sovodifl",it,vortrd(:,:,jpvor_ldf),ndimvor1,ndexvor1)  ! lat diff
400         CALL histwrite( nidvor,"sovoadvv",it,vortrd(:,:,jpvor_zad),ndimvor1,ndexvor1)  ! vert adv
401         CALL histwrite( nidvor,"sovodifv",it,vortrd(:,:,jpvor_zdf),ndimvor1,ndexvor1)  ! vert diff
402         CALL histwrite( nidvor,"sovortPs",it,vortrd(:,:,jpvor_spg),ndimvor1,ndexvor1)  ! grad Ps
403         CALL histwrite( nidvor,"sovortbv",it,vortrd(:,:,jpvor_bev),ndimvor1,ndexvor1)  ! beta.V
404         CALL histwrite( nidvor,"sovowind",it,vortrd(:,:,jpvor_swf),ndimvor1,ndexvor1) ! wind stress
405         CALL histwrite( nidvor,"sovobfri",it,vortrd(:,:,jpvor_bfr),ndimvor1,ndexvor1) ! bottom friction
[216]406         CALL histwrite( nidvor,"1st_mbre",it,vor_avrtot    ,ndimvor1,ndexvor1) ! First membre
407         CALL histwrite( nidvor,"sovorgap",it,vor_avrres    ,ndimvor1,ndexvor1) ! gap between 1st and 2 nd mbre
[503]408         !
[2528]409         IF( ndebug /= 0 ) THEN
[216]410            WRITE(numout,*) ' debuging trd_vor: III.4 done'
[109]411            CALL FLUSH(numout)
412         ENDIF
[503]413         !
[109]414      ENDIF
[503]415      !
[1601]416      IF( MOD( it, nn_trd ) == 0 ) rotot(:,:)=0
[503]417      !
[216]418      IF( kt == nitend )   CALL histclo( nidvor )
[503]419      !
[4990]420   END SUBROUTINE trd_vor_iom
[216]421
422
423   SUBROUTINE trd_vor_init
424      !!----------------------------------------------------------------------
425      !!                  ***  ROUTINE trd_vor_init  ***
426      !!
427      !! ** Purpose :   computation of vertically integrated T and S budgets
428      !!      from ocean surface down to control surface (NetCDF output)
429      !!----------------------------------------------------------------------
[503]430      REAL(wp) ::   zjulian, zsto, zout
[216]431      CHARACTER (len=40) ::   clhstnam
432      CHARACTER (len=40) ::   clop
433      !!----------------------------------------------------------------------
434
435      !  ===================
436      !   I. initialization
437      !  ===================
438
439      cvort='averaged-vor'
440
441      ! Open specifier
[2528]442      ndebug = 0      ! set it to 1 in case of problem to have more Print
[216]443
444      IF(lwp) THEN
445         WRITE(numout,*) ' '
[503]446         WRITE(numout,*) ' trd_vor_init: vorticity trends'
447         WRITE(numout,*) ' ~~~~~~~~~~~~'
[216]448         WRITE(numout,*) ' '
[503]449         WRITE(numout,*) '               ##########################################################################'
450         WRITE(numout,*) '                CAUTION: The interpretation of the vorticity trends is'
451         WRITE(numout,*) '                not obvious, please contact Anne-Marie TREGUIER at: treguier@ifremer.fr '
452         WRITE(numout,*) '               ##########################################################################'
[216]453         WRITE(numout,*) ' '
[129]454      ENDIF
[109]455
[2715]456      IF( trd_vor_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trd_vor_init : unable to allocate trdvor arrays' )
457
458
[216]459      ! cumulated trends array init
460      nmoydpvor = 0
461      rotot(:,:)=0
462      vor_avrtot(:,:)=0
463      vor_avrres(:,:)=0
464
[2528]465      IF( ndebug /= 0 ) THEN
[216]466         WRITE(numout,*) ' debuging trd_vor_init: I. done'
467         CALL FLUSH(numout)
[129]468      ENDIF
[109]469
[216]470      !  =================================
471      !   II. netCDF output initialization
472      !  =================================
[109]473
[216]474      !-----------------------------------------
475      ! II.1 Define frequency of output and means
476      ! -----------------------------------------
[1312]477      IF( ln_mskland )   THEN   ;   clop = "only(x)"   ! put 1.e+20 on land (very expensive!!)
478      ELSE                      ;   clop = "x"         ! no use of the mask value (require less cpu time)
479      ENDIF
[216]480#if defined key_diainstant
[12489]481      zsto = nn_write*rn_Dt
[1312]482      clop = "inst("//TRIM(clop)//")"
[109]483#else
[12489]484      zsto = rn_Dt
[1312]485      clop = "ave("//TRIM(clop)//")"
[216]486#endif
[12489]487      zout = nn_trd*rn_Dt
[216]488
[503]489      IF(lwp) WRITE(numout,*) '               netCDF initialization'
[216]490
491      ! II.2 Compute julian date from starting date of the run
492      ! ------------------------
[12489]493      CALL ymds2ju( nyear, nmonth, nday, rn_Dt, zjulian )
[1310]494      zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
[503]495      IF(lwp) WRITE(numout,*)' ' 
496      IF(lwp) WRITE(numout,*)'               Date 0 used :',nit000,    &
497         &                   ' YEAR ', nyear,' MONTH '      , nmonth,   &
498         &                   ' DAY ' , nday, 'Julian day : ', zjulian
[216]499
500      ! II.3 Define the T grid trend file (nidvor)
501      ! ---------------------------------
[1601]502      CALL dia_nam( clhstnam, nn_trd, 'vort' )                  ! filename
[216]503      IF(lwp) WRITE(numout,*) ' Name of NETCDF file ', clhstnam
504      CALL histbeg( clhstnam, jpi, glamf, jpj, gphif,1, jpi,   &  ! Horizontal grid : glamt and gphit
[12489]505         &          1, jpj, nit000-1, zjulian, rn_Dt, nh_t, nidvor, domain_id=nidom, snc4chunks=snc4set )
[216]506      CALL wheneq( jpi*jpj, fmask, 1, 1., ndexvor1, ndimvor1 )    ! surface
507
508      ! Declare output fields as netCDF variables
509      CALL histdef( nidvor, "sovortPh", cvort//"grad Ph" , "s-2",        & ! grad Ph
510         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
511      CALL histdef( nidvor, "sovortEk", cvort//"Energy", "s-2",          & ! Energy
512         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
513      CALL histdef( nidvor, "sovozeta", cvort//"rel vorticity", "s-2",   & ! rel vorticity
514         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
515      CALL histdef( nidvor, "sovortif", cvort//"coriolis", "s-2",        & ! coriolis
516         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
517      CALL histdef( nidvor, "sovodifl", cvort//"lat diff ", "s-2",       & ! lat diff
518         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
519      CALL histdef( nidvor, "sovoadvv", cvort//"vert adv", "s-2",        & ! vert adv
520         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
521      CALL histdef( nidvor, "sovodifv", cvort//"vert diff" , "s-2",      & ! vert diff
522         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
523      CALL histdef( nidvor, "sovortPs", cvort//"grad Ps", "s-2",         & ! grad Ps
524         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
525      CALL histdef( nidvor, "sovortbv", cvort//"Beta V", "s-2",          & ! beta.V
526         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
527      CALL histdef( nidvor, "sovowind", cvort//"wind stress", "s-2",     & ! wind stress
528         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
529      CALL histdef( nidvor, "sovobfri", cvort//"bottom friction", "s-2", & ! bottom friction
530         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
531      CALL histdef( nidvor, "1st_mbre", cvort//"1st mbre", "s-2",        & ! First membre
532         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
533      CALL histdef( nidvor, "sovorgap", cvort//"gap", "s-2",             & ! gap between 1st and 2 nd mbre
534         &          jpi,jpj,nh_t,1,1,1,-99,32,clop,zsto,zout)
[2528]535      CALL histend( nidvor, snc4set )
[216]536
[2528]537      IF( ndebug /= 0 ) THEN
[216]538         WRITE(numout,*) ' debuging trd_vor_init: II. done'
539         CALL FLUSH(numout)
540      ENDIF
[503]541      !
[216]542   END SUBROUTINE trd_vor_init
543
[109]544   !!======================================================================
545END MODULE trdvor
Note: See TracBrowser for help on using the repository browser.