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 branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/OPA_SRC/TRD – NEMO

source: branches/2012/dev_r3309_LOCEAN12_Ediag/NEMOGCM/NEMO/OPA_SRC/TRD/trdvor.F90 @ 3316

Last change on this file since 3316 was 3316, checked in by gm, 12 years ago

Ediag branche: #927 add 3D output for dyn & tracer trends

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