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 trunk/NEMOGCM/NEMO/OPA_SRC/TRD – NEMO

source: trunk/NEMOGCM/NEMO/OPA_SRC/TRD/trdvor.F90 @ 2528

Last change on this file since 2528 was 2528, checked in by rblod, 13 years ago

Update NEMOGCM from branch nemo_v3_3_beta

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