source: LMDZ4/branches/LMDZ4-dev/libf/dyn3d/leapfrog.F @ 1190

Last change on this file since 1190 was 1190, checked in by yann meurdesoif, 15 years ago

Correction de FH sur la sponge layer de top_bound + parallelisation des corrections.

YM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.3 KB
Line 
1!
2c
3c
4      SUBROUTINE leapfrog(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
5     &                    time_0)
6
7
8cIM : pour sortir les param. du modele dans un fis. netcdf 110106
9#ifdef CPP_IOIPSL
10      use IOIPSL
11#endif
12      USE infotrac
13      USE guide_mod, ONLY : guide_main
14      USE write_field
15      IMPLICIT NONE
16
17c      ......   Version  du 10/01/98    ..........
18
19c             avec  coordonnees  verticales hybrides
20c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
21
22c=======================================================================
23c
24c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
25c   -------
26c
27c   Objet:
28c   ------
29c
30c   GCM LMD nouvelle grille
31c
32c=======================================================================
33c
34c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
35c      et possibilite d'appeler une fonction f(y)  a derivee tangente
36c      hyperbolique a la  place de la fonction a derivee sinusoidale.
37
38c  ... Possibilite de choisir le shema pour l'advection de
39c        q  , en modifiant iadv dans traceur.def  (10/02) .
40c
41c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
42c      Pour Van-Leer iadv=10
43c
44c-----------------------------------------------------------------------
45c   Declarations:
46c   -------------
47
48#include "dimensions.h"
49#include "paramet.h"
50#include "comconst.h"
51#include "comdissnew.h"
52#include "comvert.h"
53#include "comgeom.h"
54#include "logic.h"
55#include "temps.h"
56#include "control.h"
57#include "ener.h"
58#include "description.h"
59#include "serre.h"
60#include "com_io_dyn.h"
61#include "iniprint.h"
62#include "academic.h"
63
64! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
65! #include "clesphys.h"
66
67      INTEGER         longcles
68      PARAMETER     ( longcles = 20 )
69      REAL  clesphy0( longcles )
70
71      real zqmin,zqmax
72      INTEGER nbetatmoy, nbetatdem,nbetat
73
74c   variables dynamiques
75      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
76      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
77      REAL q(ip1jmp1,llm,nqtot)               ! champs advectes
78      REAL ps(ip1jmp1)                       ! pression  au sol
79      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
80      REAL pks(ip1jmp1)                      ! exner au  sol
81      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
82      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
83      REAL masse(ip1jmp1,llm)                ! masse d'air
84      REAL phis(ip1jmp1)                     ! geopotentiel au sol
85      REAL phi(ip1jmp1,llm)                  ! geopotentiel
86      REAL w(ip1jmp1,llm)                    ! vitesse verticale
87
88c variables dynamiques intermediaire pour le transport
89      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm) !flux de masse
90
91c   variables dynamiques au pas -1
92      REAL vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
93      REAL tetam1(ip1jmp1,llm),psm1(ip1jmp1)
94      REAL massem1(ip1jmp1,llm)
95
96c   tendances dynamiques
97      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
98      REAL dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqtot),dp(ip1jmp1)
99
100c   tendances de la dissipation
101      REAL dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
102      REAL dtetadis(ip1jmp1,llm)
103
104c   tendances physiques
105      REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
106      REAL dtetafi(ip1jmp1,llm),dqfi(ip1jmp1,llm,nqtot),dpfi(ip1jmp1)
107
108c   variables pour le fichier histoire
109      REAL dtav      ! intervalle de temps elementaire
110
111      REAL tppn(iim),tpps(iim),tpn,tps
112c
113      INTEGER itau,itaufinp1,iav
114      INTEGER*4  iday ! jour julien
115      REAL       time ! Heure de la journee en fraction d'1 jour
116
117      REAL  SSUM
118      REAL time_0 , finvmaold(ip1jmp1,llm)
119
120cym      LOGICAL  lafin
121      LOGICAL :: lafin=.false.
122      INTEGER ij,iq,l
123      INTEGER ik
124
125      real time_step, t_wrt, t_ops
126
127      REAL rdayvrai,rdaym_ini
128      LOGICAL first,callinigrads
129cIM : pour sortir les param. du modele dans un fis. netcdf 110106
130      save first
131      data first/.true./
132      real dt_cum, zjulian
133      character*10 infile
134      integer zan, tau0, thoriid
135      integer nid_ctesGCM
136      save nid_ctesGCM
137      real degres
138      real rlong(iip1), rlatg(jjp1)
139      real zx_tmp_2d(iip1,jjp1)
140      integer ndex2d(iip1*jjp1)
141      logical ok_sync
142      parameter (ok_sync = .true.)
143
144      data callinigrads/.true./
145      character*10 string10
146
147      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
148      REAL :: flxw(ip1jmp1,llm)  ! flux de masse verticale
149
150c+jld variables test conservation energie
151      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
152C     Tendance de la temp. potentiel d (theta)/ d t due a la
153C     tansformation d'energie cinetique en energie thermique
154C     cree par la dissipation
155      REAL dtetaecdt(ip1jmp1,llm)
156      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
157      REAL vnat(ip1jm,llm),unat(ip1jmp1,llm)
158      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
159      CHARACTER*15 ztit
160!IM   INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
161!IM   SAVE      ip_ebil_dyn
162!IM   DATA      ip_ebil_dyn/0/
163c-jld
164
165      character*80 dynhist_file, dynhistave_file
166      character(len=20) :: modname
167      character*80 abort_message
168
169C Calendrier
170      LOGICAL true_calendar
171      PARAMETER (true_calendar = .false.)
172
173      logical dissip_conservative
174      save dissip_conservative
175      data dissip_conservative/.true./
176
177      LOGICAL prem
178      save prem
179      DATA prem/.true./
180      INTEGER testita
181      PARAMETER (testita = 9)
182
183      logical , parameter :: flag_verif = .false.
184     
185
186      integer itau_w   ! pas de temps ecriture = itap + itau_phy
187
188
189      itaufin   = nday*day_step
190      itaufinp1 = itaufin +1
191      modname="leapfrog"
192     
193
194      itau = 0
195      iday = day_ini+itau/day_step
196      time = FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
197         IF(time.GT.1.) THEN
198          time = time-1.
199          iday = iday+1
200         ENDIF
201
202
203c-----------------------------------------------------------------------
204c   On initialise la pression et la fonction d'Exner :
205c   --------------------------------------------------
206
207      dq=0.
208      CALL pression ( ip1jmp1, ap, bp, ps, p       )
209      CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
210
211c-----------------------------------------------------------------------
212c   Debut de l'integration temporelle:
213c   ----------------------------------
214
215   1  CONTINUE
216
217
218#ifdef CPP_IOIPSL
219      if (ok_guide) then
220        call guide_main(itau,ucov,vcov,teta,q,masse,ps)
221      endif
222#endif
223
224
225c
226c     IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
227c       CALL  test_period ( ucov,vcov,teta,q,p,phis )
228c       PRINT *,' ----   Test_period apres continue   OK ! -----', itau
229c     ENDIF
230c
231
232! Save fields obtained at previous time step as '...m1'
233      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
234      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
235      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
236      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
237      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
238
239      forward = .TRUE.
240      leapf   = .FALSE.
241      dt      =  dtvr
242
243c   ...    P.Le Van .26/04/94  ....
244
245      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
246      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
247
248! Ehouarn: what is this for? zqmin & zqmax are not used anyway ...
249!      call minmax(ijp1llm,q(:,:,3),zqmin,zqmax)
250
251   2  CONTINUE
252
253c-----------------------------------------------------------------------
254
255c   date:
256c   -----
257
258
259c   gestion des appels de la physique et des dissipations:
260c   ------------------------------------------------------
261c
262c   ...    P.Le Van  ( 6/02/95 )  ....
263
264      apphys = .FALSE.
265      statcl = .FALSE.
266      conser = .FALSE.
267      apdiss = .FALSE.
268
269      IF( purmats ) THEN
270         IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
271         IF( MOD(itau,idissip ).EQ.0.AND..NOT.forward ) apdiss = .TRUE.
272         IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward
273     s          .and. iflag_phys.EQ.1                 ) apphys = .TRUE.
274      ELSE
275         IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
276         IF( MOD(itau+1,idissip)  .EQ. 0              ) apdiss = .TRUE.
277         IF( MOD(itau+1,iphysiq).EQ.0.AND.iflag_phys.EQ.1) apphys=.TRUE.
278      END IF
279
280c-----------------------------------------------------------------------
281c   calcul des tendances dynamiques:
282c   --------------------------------
283
284      CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
285
286      CALL caldyn
287     $  ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
288     $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time+iday-day_ini )
289
290
291c-----------------------------------------------------------------------
292c   calcul des tendances advection des traceurs (dont l'humidite)
293c   -------------------------------------------------------------
294
295      IF( forward. OR . leapf )  THEN
296
297         CALL caladvtrac(q,pbaru,pbarv,
298     *        p, masse, dq,  teta,
299     .        flxw, pk)
300         
301         IF (offline) THEN
302Cmaf stokage du flux de masse pour traceurs OFF-LINE
303
304#ifdef CPP_IOIPSL
305           CALL fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
306     .   dtvr, itau)
307#endif
308
309
310         ENDIF ! of IF (offline)
311c
312      ENDIF ! of IF( forward. OR . leapf )
313
314
315c-----------------------------------------------------------------------
316c   integrations dynamique et traceurs:
317c   ----------------------------------
318
319
320       CALL integrd ( 2,vcovm1,ucovm1,tetam1,psm1,massem1 ,
321     $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis ,
322     $              finvmaold                                    )
323
324
325c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
326c
327c-----------------------------------------------------------------------
328c   calcul des tendances physiques:
329c   -------------------------------
330c    ########   P.Le Van ( Modif le  6/02/95 )   ###########
331c
332       IF( purmats )  THEN
333          IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
334       ELSE
335          IF( itau+1. EQ. itaufin )              lafin = .TRUE.
336       ENDIF
337c
338c
339       IF( apphys )  THEN
340c
341c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
342c
343
344         CALL pression (  ip1jmp1, ap, bp, ps,  p      )
345         CALL exner_hyb(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
346
347           rdaym_ini  = itau * dtvr / daysec
348           rdayvrai   = rdaym_ini  + day_ini
349
350
351c rajout debug
352c       lafin = .true.
353
354
355c   Inbterface avec les routines de phylmd (phymars ... )
356c   -----------------------------------------------------
357
358c+jld
359
360c  Diagnostique de conservation de l'énergie : initialisation
361         IF (ip_ebil_dyn.ge.1 ) THEN
362          ztit='bil dyn'
363! Ehouarn: be careful, diagedyn is Earth-specific (includes ../phylmd/..)!
364           IF (planet_type.eq."earth") THEN
365            CALL diagedyn(ztit,2,1,1,dtphys
366     &    , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
367           ENDIF
368         ENDIF ! of IF (ip_ebil_dyn.ge.1 )
369c-jld
370#ifdef CPP_IOIPSL
371cIM : pour sortir les param. du modele dans un fis. netcdf 110106
372         IF (first) THEN
373          first=.false.
374#include "ini_paramLMDZ_dyn.h"
375         ENDIF
376c
377#include "write_paramLMDZ_dyn.h"
378c
379#endif
380! #endif of #ifdef CPP_IOIPSL
381         CALL calfis( lafin ,rdayvrai,time  ,
382     $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
383     $               du,dv,dteta,dq,
384     $               flxw,
385     $               clesphy0, dufi,dvfi,dtetafi,dqfi,dpfi  )
386
387         IF (ok_strato) THEN
388           CALL top_bound( vcov,ucov,teta,masse,dufi,dvfi,dtetafi)
389         ENDIF
390       
391c      ajout des tendances physiques:
392c      ------------------------------
393          CALL addfi( dtphys, leapf, forward   ,
394     $                  ucov, vcov, teta , q   ,ps ,
395     $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
396c
397c  Diagnostique de conservation de l'énergie : difference
398         IF (ip_ebil_dyn.ge.1 ) THEN
399          ztit='bil phys'
400          IF (planet_type.eq."earth") THEN
401           CALL diagedyn(ztit,2,1,1,dtphys
402     &     , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
403          ENDIF
404         ENDIF ! of IF (ip_ebil_dyn.ge.1 )
405
406       ENDIF ! of IF( apphys )
407
408      IF(iflag_phys.EQ.2) THEN ! "Newtonian" case
409c   Calcul academique de la physique = Rappel Newtonien + friction
410c   --------------------------------------------------------------
411       teta(:,:)=teta(:,:)
412     s  -iphysiq*dtvr*(teta(:,:)-tetarappel(:,:))/taurappel
413       call friction(ucov,vcov,iphysiq*dtvr)
414      ENDIF
415
416
417c-jld
418
419        CALL pression ( ip1jmp1, ap, bp, ps, p                  )
420        CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
421
422
423c-----------------------------------------------------------------------
424c   dissipation horizontale et verticale  des petites echelles:
425c   ----------------------------------------------------------
426
427      IF(apdiss) THEN
428
429
430c   calcul de l'energie cinetique avant dissipation
431        call covcont(llm,ucov,vcov,ucont,vcont)
432        call enercin(vcov,ucov,vcont,ucont,ecin0)
433
434c   dissipation
435        CALL dissip(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
436        ucov=ucov+dudis
437        vcov=vcov+dvdis
438c       teta=teta+dtetadis
439
440
441c------------------------------------------------------------------------
442        if (dissip_conservative) then
443C       On rajoute la tendance due a la transform. Ec -> E therm. cree
444C       lors de la dissipation
445            call covcont(llm,ucov,vcov,ucont,vcont)
446            call enercin(vcov,ucov,vcont,ucont,ecin)
447            dtetaecdt= (ecin0-ecin)/ pk
448c           teta=teta+dtetaecdt
449            dtetadis=dtetadis+dtetaecdt
450        endif
451        teta=teta+dtetadis
452c------------------------------------------------------------------------
453
454
455c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
456c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
457c
458
459        DO l  =  1, llm
460          DO ij =  1,iim
461           tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
462           tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
463          ENDDO
464           tpn  = SSUM(iim,tppn,1)/apoln
465           tps  = SSUM(iim,tpps,1)/apols
466
467          DO ij = 1, iip1
468           teta(  ij    ,l) = tpn
469           teta(ij+ip1jm,l) = tps
470          ENDDO
471        ENDDO
472
473        DO ij =  1,iim
474          tppn(ij)  = aire(  ij    ) * ps (  ij    )
475          tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
476        ENDDO
477          tpn  = SSUM(iim,tppn,1)/apoln
478          tps  = SSUM(iim,tpps,1)/apols
479
480        DO ij = 1, iip1
481          ps(  ij    ) = tpn
482          ps(ij+ip1jm) = tps
483        ENDDO
484
485
486      END IF ! of IF(apdiss)
487
488c ajout debug
489c              IF( lafin ) then 
490c                abort_message = 'Simulation finished'
491c                call abort_gcm(modname,abort_message,0)
492c              ENDIF
493       
494c   ********************************************************************
495c   ********************************************************************
496c   .... fin de l'integration dynamique  et physique pour le pas itau ..
497c   ********************************************************************
498c   ********************************************************************
499
500c   preparation du pas d'integration suivant  ......
501
502      IF ( .NOT.purmats ) THEN
503c       ........................................................
504c       ..............  schema matsuno + leapfrog  ..............
505c       ........................................................
506
507            IF(forward. OR. leapf) THEN
508              itau= itau + 1
509              iday= day_ini+itau/day_step
510              time= FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
511                IF(time.GT.1.) THEN
512                  time = time-1.
513                  iday = iday+1
514                ENDIF
515            ENDIF
516
517
518            IF( itau. EQ. itaufinp1 ) then 
519              if (flag_verif) then
520                write(79,*) 'ucov',ucov
521                write(80,*) 'vcov',vcov
522                write(81,*) 'teta',teta
523                write(82,*) 'ps',ps
524                write(83,*) 'q',q
525                WRITE(85,*) 'q1 = ',q(:,:,1)
526                WRITE(86,*) 'q3 = ',q(:,:,3)
527              endif
528
529              abort_message = 'Simulation finished'
530
531              call abort_gcm(modname,abort_message,0)
532            ENDIF
533c-----------------------------------------------------------------------
534c   ecriture du fichier histoire moyenne:
535c   -------------------------------------
536
537            IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
538               IF(itau.EQ.itaufin) THEN
539                  iav=1
540               ELSE
541                  iav=0
542               ENDIF
543               
544               IF (ok_dynzon) THEN
545#ifdef CPP_IOIPSL
546                  CALL writedynav(histaveid, itau,vcov ,
547     ,                 ucov,teta,pk,phi,q,masse,ps,phis)
548                  CALL bilan_dyn (2,dtvr*iperiod,dtvr*day_step*periodav,
549     ,                 ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
550#endif
551               END IF
552
553            ENDIF
554
555c-----------------------------------------------------------------------
556c   ecriture de la bande histoire:
557c   ------------------------------
558
559            IF( MOD(itau,iecri         ).EQ.0) THEN
560c           IF( MOD(itau,iecri*day_step).EQ.0) THEN
561
562              nbetat = nbetatdem
563              CALL geopot(ip1jmp1,teta,pk,pks,phis,phi)
564              unat=0.
565              do l=1,llm
566                unat(iip2:ip1jm,l)=ucov(iip2:ip1jm,l)/cu(iip2:ip1jm)
567                vnat(:,l)=vcov(:,l)/cv(:)
568              enddo
569#ifdef CPP_IOIPSL
570c             CALL writehist(histid,histvid,itau,vcov,
571c     &                      ucov,teta,phi,q,masse,ps,phis)
572#endif
573! For some Grads outputs of fields
574             if (output_grads_dyn) then
575#include "write_grads_dyn.h"
576             endif
577
578            ENDIF ! of IF(MOD(itau,iecri).EQ.0)
579
580            IF(itau.EQ.itaufin) THEN
581
582
583              if (planet_type.eq."earth") then
584#ifdef CPP_EARTH
585! Write an Earth-format restart file
586                CALL dynredem1("restart.nc",0.0,
587     &                         vcov,ucov,teta,q,masse,ps)
588#endif
589              endif ! of if (planet_type.eq."earth")
590
591              CLOSE(99)
592            ENDIF ! of IF (itau.EQ.itaufin)
593
594c-----------------------------------------------------------------------
595c   gestion de l'integration temporelle:
596c   ------------------------------------
597
598            IF( MOD(itau,iperiod).EQ.0 )    THEN
599                    GO TO 1
600            ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
601
602                   IF( forward )  THEN
603c      fin du pas forward et debut du pas backward
604
605                      forward = .FALSE.
606                        leapf = .FALSE.
607                           GO TO 2
608
609                   ELSE
610c      fin du pas backward et debut du premier pas leapfrog
611
612                        leapf =  .TRUE.
613                        dt  =  2.*dtvr
614                        GO TO 2
615                   END IF ! of IF (forward)
616            ELSE
617
618c      ......   pas leapfrog  .....
619
620                 leapf = .TRUE.
621                 dt  = 2.*dtvr
622                 GO TO 2
623            END IF ! of IF (MOD(itau,iperiod).EQ.0)
624                   !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
625
626      ELSE ! of IF (.not.purmats)
627
628c       ........................................................
629c       ..............       schema  matsuno        ...............
630c       ........................................................
631            IF( forward )  THEN
632
633             itau =  itau + 1
634             iday = day_ini+itau/day_step
635             time = FLOAT(itau-(iday-day_ini)*day_step)/day_step+time_0
636
637                  IF(time.GT.1.) THEN
638                   time = time-1.
639                   iday = iday+1
640                  ENDIF
641
642               forward =  .FALSE.
643               IF( itau. EQ. itaufinp1 ) then 
644                 abort_message = 'Simulation finished'
645                 call abort_gcm(modname,abort_message,0)
646               ENDIF
647               GO TO 2
648
649            ELSE ! of IF(forward)
650
651              IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
652               IF(itau.EQ.itaufin) THEN
653                  iav=1
654               ELSE
655                  iav=0
656               ENDIF
657
658               IF (ok_dynzon) THEN
659#ifdef CPP_IOIPSL
660                  CALL writedynav(histaveid, itau,vcov ,
661     ,                 ucov,teta,pk,phi,q,masse,ps,phis)
662                  CALL bilan_dyn (2,dtvr*iperiod,dtvr*day_step*periodav,
663     ,                 ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,q)
664#endif
665               END IF
666
667              ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
668
669              IF(MOD(itau,iecri         ).EQ.0) THEN
670c              IF(MOD(itau,iecri*day_step).EQ.0) THEN
671                nbetat = nbetatdem
672                CALL geopot(ip1jmp1,teta,pk,pks,phis,phi)
673                unat=0.
674                do l=1,llm
675                  unat(iip2:ip1jm,l)=ucov(iip2:ip1jm,l)/cu(iip2:ip1jm)
676                  vnat(:,l)=vcov(:,l)/cv(:)
677                enddo
678#ifdef CPP_IOIPSL
679c               CALL writehist( histid, histvid, itau,vcov ,
680c    &                           ucov,teta,phi,q,masse,ps,phis)
681#endif
682! For some Grads outputs
683                if (output_grads_dyn) then
684#include "write_grads_dyn.h"
685                endif
686
687              ENDIF ! of IF(MOD(itau,iecri         ).EQ.0)
688
689              IF(itau.EQ.itaufin) THEN
690                if (planet_type.eq."earth") then
691#ifdef CPP_EARTH
692                  CALL dynredem1("restart.nc",0.0,
693     &                           vcov,ucov,teta,q,masse,ps)
694#endif
695                endif ! of if (planet_type.eq."earth")
696              ENDIF ! of IF(itau.EQ.itaufin)
697
698              forward = .TRUE.
699              GO TO  1
700
701            ENDIF ! of IF (forward)
702
703      END IF ! of IF(.not.purmats)
704
705      STOP
706      END
Note: See TracBrowser for help on using the repository browser.