source: trunk/LMDZ.COMMON/libf/dyn3d/leapfrog.F @ 638

Last change on this file since 638 was 500, checked in by slebonnois, 14 years ago

Sorry, correction of some bugs from recent Titan commit...

File size: 27.9 KB
RevLine 
[1]1!
[7]2! $Id: leapfrog.F 1446 2010-10-22 09:27:25Z emillour $
[1]3!
4c
5c
[97]6      SUBROUTINE leapfrog(ucov,vcov,teta,ps,masse,phis,q,
[1]7     &                    time_0)
8
9
10cIM : pour sortir les param. du modele dans un fis. netcdf 110106
11#ifdef CPP_IOIPSL
12      use IOIPSL
13#endif
14      USE infotrac
15      USE guide_mod, ONLY : guide_main
16      USE write_field
17      USE control_mod
18      IMPLICIT NONE
19
20c      ......   Version  du 10/01/98    ..........
21
22c             avec  coordonnees  verticales hybrides
23c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
24
25c=======================================================================
26c
27c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
28c   -------
29c
30c   Objet:
31c   ------
32c
33c   GCM LMD nouvelle grille
34c
35c=======================================================================
36c
37c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
38c      et possibilite d'appeler une fonction f(y)  a derivee tangente
39c      hyperbolique a la  place de la fonction a derivee sinusoidale.
40
41c  ... Possibilite de choisir le shema pour l'advection de
42c        q  , en modifiant iadv dans traceur.def  (10/02) .
43c
44c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
45c      Pour Van-Leer iadv=10
46c
47c-----------------------------------------------------------------------
48c   Declarations:
49c   -------------
50
51#include "dimensions.h"
52#include "paramet.h"
53#include "comconst.h"
54#include "comdissnew.h"
55#include "comvert.h"
56#include "comgeom.h"
57#include "logic.h"
58#include "temps.h"
59#include "ener.h"
60#include "description.h"
61#include "serre.h"
62!#include "com_io_dyn.h"
63#include "iniprint.h"
64#include "academic.h"
65
66! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
67! #include "clesphys.h"
68
69      real zqmin,zqmax
70
71c   variables dynamiques
72      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
73      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
74      REAL q(ip1jmp1,llm,nqtot)               ! champs advectes
75      REAL ps(ip1jmp1)                       ! pression  au sol
76      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
77      REAL pks(ip1jmp1)                      ! exner au  sol
78      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
79      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
80      REAL masse(ip1jmp1,llm)                ! masse d'air
81      REAL phis(ip1jmp1)                     ! geopotentiel au sol
82      REAL phi(ip1jmp1,llm)                  ! geopotentiel
83      REAL w(ip1jmp1,llm)                    ! vitesse verticale
[5]84! ADAPTATION GCM POUR CP(T)
85      REAL temp(ip1jmp1,llm)                 ! temperature 
86      REAL tsurpk(ip1jmp1,llm)               ! cpp*T/pk 
[1]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
[6]96c   tendances dynamiques en */s
[1]97      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
98      REAL dteta(ip1jmp1,llm),dq(ip1jmp1,llm,nqtot),dp(ip1jmp1)
99
[6]100c   tendances de la dissipation en */s
[1]101      REAL dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
102      REAL dtetadis(ip1jmp1,llm)
103
[6]104c   tendances de la couche superieure */s
105      REAL dvtop(ip1jm,llm),dutop(ip1jmp1,llm)
106      REAL dtetatop(ip1jmp1,llm)
107      REAL dqtop(ip1jmp1,llm,nqtot),dptop(ip1jmp1)
108
[495]109c   TITAN : tendances due au forces de marees */s
110      REAL dvtidal(ip1jm,llm),dutidal(ip1jmp1,llm)
111
[6]112c   tendances physiques */s
[1]113      REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
114      REAL dtetafi(ip1jmp1,llm),dqfi(ip1jmp1,llm,nqtot),dpfi(ip1jmp1)
115
116c   variables pour le fichier histoire
117      REAL dtav      ! intervalle de temps elementaire
118
119      REAL tppn(iim),tpps(iim),tpn,tps
120c
121      INTEGER itau,itaufinp1,iav
122!      INTEGER  iday ! jour julien
123      REAL       time
124
125      REAL  SSUM
126      REAL time_0 , finvmaold(ip1jmp1,llm)
127
128cym      LOGICAL  lafin
129      LOGICAL :: lafin=.false.
130      INTEGER ij,iq,l
131      INTEGER ik
132
133      real time_step, t_wrt, t_ops
134
[497]135      REAL rdaym_ini
[1]136! jD_cur: jour julien courant
137! jH_cur: heure julienne courante
138      REAL :: jD_cur, jH_cur
139      INTEGER :: an, mois, jour
140      REAL :: secondes
141
142      LOGICAL first,callinigrads
143cIM : pour sortir les param. du modele dans un fis. netcdf 110106
144      save first
145      data first/.true./
146      real dt_cum
147      character*10 infile
148      integer zan, tau0, thoriid
149      integer nid_ctesGCM
150      save nid_ctesGCM
151      real degres
152      real rlong(iip1), rlatg(jjp1)
153      real zx_tmp_2d(iip1,jjp1)
154      integer ndex2d(iip1*jjp1)
155      logical ok_sync
156      parameter (ok_sync = .true.)
[270]157      logical physic
[1]158
159      data callinigrads/.true./
160      character*10 string10
161
162      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
163      REAL :: flxw(ip1jmp1,llm)  ! flux de masse verticale
164
165c+jld variables test conservation energie
166      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
167C     Tendance de la temp. potentiel d (theta)/ d t due a la
168C     tansformation d'energie cinetique en energie thermique
169C     cree par la dissipation
170      REAL dtetaecdt(ip1jmp1,llm)
171      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
172      REAL vnat(ip1jm,llm),unat(ip1jmp1,llm)
173      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
174      CHARACTER*15 ztit
175!IM   INTEGER   ip_ebil_dyn  ! PRINT level for energy conserv. diag.
176!IM   SAVE      ip_ebil_dyn
177!IM   DATA      ip_ebil_dyn/0/
178c-jld
179
[37]180      integer :: itau_w ! for write_paramLMDZ_dyn.h
181
[1]182      character*80 dynhist_file, dynhistave_file
[127]183      character(len=*),parameter :: modname="leapfrog"
[1]184      character*80 abort_message
185
186      logical dissip_conservative
187      save dissip_conservative
188      data dissip_conservative/.true./
189
190      INTEGER testita
191      PARAMETER (testita = 9)
192
193      logical , parameter :: flag_verif = .false.
194     
[37]195      ! for CP(T)
196      real :: dtec
197      real,external :: cpdet
198      real :: ztetaec(ip1jmp1,llm)
[1]199
[101]200c dummy: sinon cette routine n'est jamais compilee...
201      if(1.eq.0) then
202        CALL init_phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
203      endif
204
[1]205      itaufin   = nday*day_step
[97]206      if (less1day) then
207c MODIF VENUS: to run less than one day:
208        itaufin   = int(fractday*day_step)
209      endif
[1]210      itaufinp1 = itaufin +1
211     
[6]212c INITIALISATIONS
213        dudis(:,:)   =0.
214        dvdis(:,:)   =0.
215        dtetadis(:,:)=0.
216        dutop(:,:)   =0.
217        dvtop(:,:)   =0.
218        dtetatop(:,:)=0.
219        dqtop(:,:,:) =0.
220        dptop(:)     =0.
221        dufi(:,:)   =0.
222        dvfi(:,:)   =0.
223        dtetafi(:,:)=0.
224        dqfi(:,:,:) =0.
225        dpfi(:)     =0.
[1]226
227      itau = 0
[270]228      physic=.true.
229      if (iflag_phys==0.or.iflag_phys==2) physic=.false.
230
[1]231c      iday = day_ini+itau/day_step
232c      time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
233c         IF(time.GT.1.) THEN
234c          time = time-1.
235c          iday = iday+1
236c         ENDIF
237
238
239c-----------------------------------------------------------------------
240c   On initialise la pression et la fonction d'Exner :
241c   --------------------------------------------------
242
[7]243      dq(:,:,:)=0.
[1]244      CALL pression ( ip1jmp1, ap, bp, ps, p       )
[127]245      if (disvert_type==1) then
[109]246        CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
[127]247      else ! we assume that we are in the disvert_type==2 case
[109]248        CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
249      endif
250
[97]251c------------------
252c TEST PK MONOTONE
253c------------------
254      write(*,*) "Test PK"
255      do ij=1,ip1jmp1
256        do l=2,llm
257          if(pk(ij,l).gt.pk(ij,l-1)) then
258c           write(*,*) ij,l,pk(ij,l)
259            abort_message = 'PK non strictement decroissante'
260            call abort_gcm(modname,abort_message,1)
261c           write(*,*) "ATTENTION, Test PK deconnecté..."
262          endif
263        enddo
264      enddo
265      write(*,*) "Fin Test PK"
266c     stop
267c------------------
[1]268
269c-----------------------------------------------------------------------
270c   Debut de l'integration temporelle:
271c   ----------------------------------
272
273   1  CONTINUE
274
[492]275      jD_cur = jD_ref + day_ini - day_ref +                             &
276     &          int (itau * dtvr / daysec)
277      jH_cur = jH_ref + start_time +                                    &
[1]278     &          (itau * dtvr / daysec - int(itau * dtvr / daysec))
[492]279      jD_cur = jD_cur + int(jH_cur)
280      jH_cur = jH_cur - int(jH_cur)
[1]281
282
283#ifdef CPP_IOIPSL
284      if (ok_guide) then
285        call guide_main(itau,ucov,vcov,teta,q,masse,ps)
286      endif
287#endif
288
289
290c
291c     IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
292c       CALL  test_period ( ucov,vcov,teta,q,p,phis )
293c       PRINT *,' ----   Test_period apres continue   OK ! -----', itau
294c     ENDIF
295c
296
297! Save fields obtained at previous time step as '...m1'
298      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
299      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
300      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
301      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
302      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
303
304      forward = .TRUE.
305      leapf   = .FALSE.
306      dt      =  dtvr
307
308c   ...    P.Le Van .26/04/94  ....
309
310      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
311      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
312
313   2  CONTINUE
314
315c-----------------------------------------------------------------------
316
317c   date:
318c   -----
319
320
321c   gestion des appels de la physique et des dissipations:
322c   ------------------------------------------------------
323c
324c   ...    P.Le Van  ( 6/02/95 )  ....
325
326      apphys = .FALSE.
327      statcl = .FALSE.
328      conser = .FALSE.
329      apdiss = .FALSE.
330
331      IF( purmats ) THEN
332      ! Purely Matsuno time stepping
333         IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
[270]334         IF( MOD(itau,dissip_period ).EQ.0.AND..NOT.forward )
335     s        apdiss = .TRUE.
[1]336         IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward
[270]337     s          .and. physic                        ) apphys = .TRUE.
[1]338      ELSE
339      ! Leapfrog/Matsuno time stepping
340         IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
[270]341         IF( MOD(itau+1,dissip_period).EQ.0 .AND. .NOT. forward )
342     s        apdiss = .TRUE.
343         IF( MOD(itau+1,iphysiq).EQ.0.AND.physic       ) apphys=.TRUE.
[1]344      END IF
345
346! Ehouarn: for Shallow Water case (ie: 1 vertical layer),
347!          supress dissipation step
348      if (llm.eq.1) then
349        apdiss=.false.
350      endif
351
352c-----------------------------------------------------------------------
353c   calcul des tendances dynamiques:
354c   --------------------------------
355
[5]356! ADAPTATION GCM POUR CP(T)
357      call tpot2t(ijp1llm,teta,temp,pk)
358      tsurpk = cpp*temp/pk
359      CALL geopot  ( ip1jmp1, tsurpk  , pk , pks,  phis  , phi   )
[1]360
[497]361           rdaym_ini  = itau * dtvr / daysec
362
[1]363      time = jD_cur + jH_cur
364      CALL caldyn
[5]365     $  ( itau,ucov,vcov,teta,ps,masse,pk,pkf,tsurpk,phis ,
[1]366     $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time )
367
368
369c-----------------------------------------------------------------------
370c   calcul des tendances advection des traceurs (dont l'humidite)
371c   -------------------------------------------------------------
372
[270]373!      IF( forward. OR . leapf )  THEN
374      IF((.not.forward).OR. leapf )  THEN
375        ! Ehouarn: gather mass fluxes during backward Matsuno or LF step
[1]376         CALL caladvtrac(q,pbaru,pbarv,
377     *        p, masse, dq,  teta,
378     .        flxw, pk)
379         
380         IF (offline) THEN
381Cmaf stokage du flux de masse pour traceurs OFF-LINE
382
383#ifdef CPP_IOIPSL
384           CALL fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
385     .   dtvr, itau)
386#endif
387
388
389         ENDIF ! of IF (offline)
390c
391      ENDIF ! of IF( forward. OR . leapf )
392
393
394c-----------------------------------------------------------------------
395c   integrations dynamique et traceurs:
396c   ----------------------------------
397
398
399       CALL integrd ( 2,vcovm1,ucovm1,tetam1,psm1,massem1 ,
400     $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis ,
401     $              finvmaold                                    )
402
[500]403       IF ((planet_type.eq."titan").and.(tidal)) then
[495]404c-----------------------------------------------------------------------
405c   Marées gravitationnelles causées par Saturne
406c   B. Charnay (28/10/2010)
407c   ----------------------------------------------------------
408            CALL tidal_forces(rdaym_ini, dutidal, dvtidal)
409            ucov=ucov+dutidal*dt
410            vcov=vcov+dvtidal*dt
411       ENDIF
[1]412
413c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
414c
415c-----------------------------------------------------------------------
416c   calcul des tendances physiques:
417c   -------------------------------
418c    ########   P.Le Van ( Modif le  6/02/95 )   ###########
419c
420       IF( purmats )  THEN
421          IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
422       ELSE
423          IF( itau+1. EQ. itaufin )              lafin = .TRUE.
424       ENDIF
425c
426c
427       IF( apphys )  THEN
428c
429c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
430c
431
432         CALL pression (  ip1jmp1, ap, bp, ps,  p      )
[127]433         if (disvert_type==1) then
434           CALL exner_hyb(  ip1jmp1, ps, p,alpha,beta,pks, pk, pkf )
435         else ! we assume that we are in the disvert_type==2 case
[109]436           CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
437         endif
[1]438
[492]439           jD_cur = jD_ref + day_ini - day_ref +                        &
440     &          int (itau * dtvr / daysec)
441           jH_cur = jH_ref + start_time +                               &
442     &          (itau * dtvr / daysec - int(itau * dtvr / daysec))
443           jD_cur = jD_cur + int(jH_cur)
444           jH_cur = jH_cur - int(jH_cur)
[1]445!         write(lunout,*)'itau, jD_cur = ', itau, jD_cur, jH_cur
446!         call ju2ymds(jD_cur+jH_cur, an, mois, jour, secondes)
447!         write(lunout,*)'current date = ',an, mois, jour, secondes
448
449c rajout debug
450c       lafin = .true.
451
452
[6]453c   Interface avec les routines de phylmd (phymars ... )
[1]454c   -----------------------------------------------------
455
456c+jld
457
458c  Diagnostique de conservation de l'énergie : initialisation
459         IF (ip_ebil_dyn.ge.1 ) THEN
460          ztit='bil dyn'
461! Ehouarn: be careful, diagedyn is Earth-specific (includes ../phylmd/..)!
462           IF (planet_type.eq."earth") THEN
463            CALL diagedyn(ztit,2,1,1,dtphys
464     &    , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
465           ENDIF
466         ENDIF ! of IF (ip_ebil_dyn.ge.1 )
467c-jld
468#ifdef CPP_IOIPSL
469cIM : pour sortir les param. du modele dans un fis. netcdf 110106
470         IF (first) THEN
471#include "ini_paramLMDZ_dyn.h"
[119]472          first=.false.
[1]473         ENDIF
474c
475#include "write_paramLMDZ_dyn.h"
476c
477#endif
478! #endif of #ifdef CPP_IOIPSL
[6]479
[1]480         CALL calfis( lafin , jD_cur, jH_cur,
481     $               ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
482     $               du,dv,dteta,dq,
483     $               flxw,
[97]484     $               dufi,dvfi,dtetafi,dqfi,dpfi  )
[1]485
[6]486c      ajout des tendances physiques:
487c      ------------------------------
488          CALL addfi( dtphys, leapf, forward   ,
489     $                  ucov, vcov, teta , q   ,ps ,
490     $                 dufi, dvfi, dtetafi , dqfi ,dpfi  )
491
492c      Couche superieure :
493c      -------------------
[1]494         IF (ok_strato) THEN
[110]495           CALL top_bound( vcov,ucov,teta,phi,masse,
496     $                     dutop,dvtop,dtetatop)
[6]497c dqtop=0, dptop=0
[108]498           CALL addfi( dtphys, leapf, forward   ,
[1]499     $                  ucov, vcov, teta , q   ,ps ,
[108]500     $                 dutop, dvtop, dtetatop , dqtop ,dptop  )
501         ENDIF
502
[1]503c  Diagnostique de conservation de l'énergie : difference
504         IF (ip_ebil_dyn.ge.1 ) THEN
505          ztit='bil phys'
506          IF (planet_type.eq."earth") THEN
507           CALL diagedyn(ztit,2,1,1,dtphys
508     &     , ucov    , vcov , ps, p ,pk , teta , q(:,:,1), q(:,:,2))
509          ENDIF
510         ENDIF ! of IF (ip_ebil_dyn.ge.1 )
511
512       ENDIF ! of IF( apphys )
513
514      IF(iflag_phys.EQ.2) THEN ! "Newtonian" case
515!   Academic case : Simple friction and Newtonan relaxation
516!   -------------------------------------------------------
517        DO l=1,llm   
518          DO ij=1,ip1jmp1
519           teta(ij,l)=teta(ij,l)-dtvr*
520     &      (teta(ij,l)-tetarappel(ij,l))*(knewt_g+knewt_t(l)*clat4(ij))
521          ENDDO
522        ENDDO ! of DO l=1,llm
[53]523   
[270]524        if (planet_type.eq."giant") then
525          ! add an intrinsic heat flux at the base of the atmosphere
526          teta(:,1)=teta(:,1)+dtvr*aire(:)*ihf/cpp/masse(:,1)
527        endif
[53]528
[270]529        call friction(ucov,vcov,dtvr)
530
[53]531   
[1]532        ! Sponge layer (if any)
533        IF (ok_strato) THEN
[110]534          CALL top_bound(vcov,ucov,teta,phi,
535     $                   masse,dutop,dvtop,dtetatop)
[108]536c dqtop=0, dptop=0
[1]537          CALL addfi( dtvr, leapf, forward   ,
538     $                  ucov, vcov, teta , q   ,ps ,
[6]539     $                 dutop, dvtop, dtetatop , dqtop ,dptop  )
[1]540        ENDIF ! of IF (ok_strato)
541      ENDIF ! of IF (iflag_phys.EQ.2)
542
543
544c-jld
545
546        CALL pression ( ip1jmp1, ap, bp, ps, p                  )
[127]547        if (disvert_type==1) then
[109]548          CALL exner_hyb( ip1jmp1, ps, p,alpha,beta, pks, pk, pkf )
[127]549        else ! we assume that we are in the disvert_type==2 case
[109]550          CALL exner_milieu( ip1jmp1, ps, p, beta, pks, pk, pkf )
551        endif
[1]552
553
554c-----------------------------------------------------------------------
555c   dissipation horizontale et verticale  des petites echelles:
556c   ----------------------------------------------------------
557
558      IF(apdiss) THEN
559
560
561c   calcul de l'energie cinetique avant dissipation
562        call covcont(llm,ucov,vcov,ucont,vcont)
563        call enercin(vcov,ucov,vcont,ucont,ecin0)
564
565c   dissipation
[5]566! ADAPTATION GCM POUR CP(T)
567        call tpot2t(ijp1llm,teta,temp,pk)
568
[1]569        CALL dissip(vcov,ucov,teta,p,dvdis,dudis,dtetadis)
570        ucov=ucov+dudis
571        vcov=vcov+dvdis
[6]572        dudis=dudis/dtdiss   ! passage en (m/s)/s
573        dvdis=dvdis/dtdiss   ! passage en (m/s)/s
[1]574
575c------------------------------------------------------------------------
576        if (dissip_conservative) then
577C       On rajoute la tendance due a la transform. Ec -> E therm. cree
578C       lors de la dissipation
579            call covcont(llm,ucov,vcov,ucont,vcont)
580            call enercin(vcov,ucov,vcont,ucont,ecin)
[5]581! ADAPTATION GCM POUR CP(T)
582            do ij=1,ip1jmp1
583              do l=1,llm
584                dtec = (ecin0(ij,l)-ecin(ij,l))/cpdet(temp(ij,l))
585                temp(ij,l) = temp(ij,l) + dtec
586              enddo
587            enddo
588            call t2tpot(ijp1llm,temp,ztetaec,pk)
589            dtetaecdt=ztetaec-teta
[1]590            dtetadis=dtetadis+dtetaecdt
591        endif
592        teta=teta+dtetadis
[6]593        dtetadis=dtetadis/dtdiss   ! passage en K/s
[1]594c------------------------------------------------------------------------
595
596
597c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
598c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
599c
600
601        DO l  =  1, llm
602          DO ij =  1,iim
603           tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
604           tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
605          ENDDO
606           tpn  = SSUM(iim,tppn,1)/apoln
607           tps  = SSUM(iim,tpps,1)/apols
608
609          DO ij = 1, iip1
610           teta(  ij    ,l) = tpn
611           teta(ij+ip1jm,l) = tps
612          ENDDO
613        ENDDO
614
615        DO ij =  1,iim
616          tppn(ij)  = aire(  ij    ) * ps (  ij    )
617          tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
618        ENDDO
619          tpn  = SSUM(iim,tppn,1)/apoln
620          tps  = SSUM(iim,tpps,1)/apols
621
622        DO ij = 1, iip1
623          ps(  ij    ) = tpn
624          ps(ij+ip1jm) = tps
625        ENDDO
626
627
628      END IF ! of IF(apdiss)
629
630c ajout debug
631c              IF( lafin ) then 
632c                abort_message = 'Simulation finished'
633c                call abort_gcm(modname,abort_message,0)
634c              ENDIF
635       
636c   ********************************************************************
637c   ********************************************************************
638c   .... fin de l'integration dynamique  et physique pour le pas itau ..
639c   ********************************************************************
640c   ********************************************************************
641
642c   preparation du pas d'integration suivant  ......
643
644      IF ( .NOT.purmats ) THEN
645c       ........................................................
646c       ..............  schema matsuno + leapfrog  ..............
647c       ........................................................
648
649            IF(forward. OR. leapf) THEN
650              itau= itau + 1
651c              iday= day_ini+itau/day_step
652c              time= REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
653c                IF(time.GT.1.) THEN
654c                  time = time-1.
655c                  iday = iday+1
656c                ENDIF
657            ENDIF
658
659
660            IF( itau. EQ. itaufinp1 ) then 
661              if (flag_verif) then
662                write(79,*) 'ucov',ucov
663                write(80,*) 'vcov',vcov
664                write(81,*) 'teta',teta
665                write(82,*) 'ps',ps
666                write(83,*) 'q',q
667                WRITE(85,*) 'q1 = ',q(:,:,1)
668                WRITE(86,*) 'q3 = ',q(:,:,3)
669              endif
670
671              abort_message = 'Simulation finished'
672
673              call abort_gcm(modname,abort_message,0)
674            ENDIF
675c-----------------------------------------------------------------------
676c   ecriture du fichier histoire moyenne:
677c   -------------------------------------
678
679            IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
680               IF(itau.EQ.itaufin) THEN
681                  iav=1
682               ELSE
683                  iav=0
684               ENDIF
685               
686               IF (ok_dynzon) THEN
687#ifdef CPP_IOIPSL
[6]688c les traceurs ne sont pas sortis, trop lourd.
689c Peut changer eventuellement si besoin.
690                 CALL bilan_dyn(dtvr*iperiod,dtvr*day_step*periodav,
691     &                 ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,
[108]692     &                 du,dudis,dutop,dufi)
[1]693#endif
694               END IF
695               IF (ok_dyn_ave) THEN
696#ifdef CPP_IOIPSL
697                 CALL writedynav(itau,vcov,
698     &                 ucov,teta,pk,phi,q,masse,ps,phis)
699#endif
700               ENDIF
701
702            ENDIF ! of IF((MOD(itau,iperiod).EQ.0).OR.(itau.EQ.itaufin))
703
704c-----------------------------------------------------------------------
705c   ecriture de la bande histoire:
706c   ------------------------------
707
708            IF( MOD(itau,iecri).EQ.0) THEN
709             ! Ehouarn: output only during LF or Backward Matsuno
710             if (leapf.or.(.not.leapf.and.(.not.forward))) then
[5]711! ADAPTATION GCM POUR CP(T)
712              call tpot2t(ijp1llm,teta,temp,pk)
713              tsurpk = cpp*temp/pk
714              CALL geopot(ip1jmp1,tsurpk,pk,pks,phis,phi)
[1]715              unat=0.
716              do l=1,llm
717                unat(iip2:ip1jm,l)=ucov(iip2:ip1jm,l)/cu(iip2:ip1jm)
718                vnat(:,l)=vcov(:,l)/cv(:)
719              enddo
720#ifdef CPP_IOIPSL
721              if (ok_dyn_ins) then
722!               write(lunout,*) "leapfrog: call writehist, itau=",itau
723               CALL writehist(itau,vcov,ucov,teta,phi,q,masse,ps,phis)
724!               call WriteField('ucov',reshape(ucov,(/iip1,jmp1,llm/)))
725!               call WriteField('vcov',reshape(vcov,(/iip1,jjm,llm/)))
726!              call WriteField('teta',reshape(teta,(/iip1,jmp1,llm/)))
727!               call WriteField('ps',reshape(ps,(/iip1,jmp1/)))
728!               call WriteField('masse',reshape(masse,(/iip1,jmp1,llm/)))
729              endif ! of if (ok_dyn_ins)
730#endif
731! For some Grads outputs of fields
732              if (output_grads_dyn) then
733#include "write_grads_dyn.h"
734              endif
735             endif ! of if (leapf.or.(.not.leapf.and.(.not.forward)))
736            ENDIF ! of IF(MOD(itau,iecri).EQ.0)
737
738            IF(itau.EQ.itaufin) THEN
739
740
[6]741              if (planet_type.eq."mars") then
742! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem1_mars
743                abort_message = 'dynredem1_mars A FAIRE'
744                call abort_gcm(modname,abort_message,0)
745              else
[492]746                CALL dynredem1("restart.nc",start_time,
[1]747     &                         vcov,ucov,teta,q,masse,ps)
[6]748              endif ! of if (planet_type.eq."mars")
[1]749
750              CLOSE(99)
751            ENDIF ! of IF (itau.EQ.itaufin)
752
753c-----------------------------------------------------------------------
754c   gestion de l'integration temporelle:
755c   ------------------------------------
756
757            IF( MOD(itau,iperiod).EQ.0 )    THEN
758                    GO TO 1
759            ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
760
761                   IF( forward )  THEN
762c      fin du pas forward et debut du pas backward
763
764                      forward = .FALSE.
765                        leapf = .FALSE.
766                           GO TO 2
767
768                   ELSE
769c      fin du pas backward et debut du premier pas leapfrog
770
771                        leapf =  .TRUE.
772                        dt  =  2.*dtvr
773                        GO TO 2
774                   END IF ! of IF (forward)
775            ELSE
776
777c      ......   pas leapfrog  .....
778
779                 leapf = .TRUE.
780                 dt  = 2.*dtvr
781                 GO TO 2
782            END IF ! of IF (MOD(itau,iperiod).EQ.0)
783                   !    ELSEIF (MOD(itau-1,iperiod).EQ.0)
784
785      ELSE ! of IF (.not.purmats)
786
787c       ........................................................
788c       ..............       schema  matsuno        ...............
789c       ........................................................
790            IF( forward )  THEN
791
792             itau =  itau + 1
793c             iday = day_ini+itau/day_step
794c             time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
795c
796c                  IF(time.GT.1.) THEN
797c                   time = time-1.
798c                   iday = iday+1
799c                  ENDIF
800
801               forward =  .FALSE.
802               IF( itau. EQ. itaufinp1 ) then 
803                 abort_message = 'Simulation finished'
804                 call abort_gcm(modname,abort_message,0)
805               ENDIF
806               GO TO 2
807
808            ELSE ! of IF(forward) i.e. backward step
809
810              IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
811               IF(itau.EQ.itaufin) THEN
812                  iav=1
813               ELSE
814                  iav=0
815               ENDIF
816
817               IF (ok_dynzon) THEN
818#ifdef CPP_IOIPSL
[6]819c les traceurs ne sont pas sortis, trop lourd.
820c Peut changer eventuellement si besoin.
821                 CALL bilan_dyn(dtvr*iperiod,dtvr*day_step*periodav,
822     &                 ps,masse,pk,pbaru,pbarv,teta,phi,ucov,vcov,
[108]823     &                 du,dudis,dutop,dufi)
[1]824#endif
825               ENDIF
826               IF (ok_dyn_ave) THEN
827#ifdef CPP_IOIPSL
828                 CALL writedynav(itau,vcov,
829     &                 ucov,teta,pk,phi,q,masse,ps,phis)
830#endif
831               ENDIF
832
833              ENDIF ! of IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin)
834
835              IF(MOD(itau,iecri         ).EQ.0) THEN
836c              IF(MOD(itau,iecri*day_step).EQ.0) THEN
[5]837! ADAPTATION GCM POUR CP(T)
838                call tpot2t(ijp1llm,teta,temp,pk)
839                tsurpk = cpp*temp/pk
840                CALL geopot(ip1jmp1,tsurpk,pk,pks,phis,phi)
[1]841                unat=0.
842                do l=1,llm
843                  unat(iip2:ip1jm,l)=ucov(iip2:ip1jm,l)/cu(iip2:ip1jm)
844                  vnat(:,l)=vcov(:,l)/cv(:)
845                enddo
846#ifdef CPP_IOIPSL
847              if (ok_dyn_ins) then
848!                write(lunout,*) "leapfrog: call writehist (b)",
849!     &                        itau,iecri
850                CALL writehist(itau,vcov,ucov,teta,phi,q,masse,ps,phis)
851              endif ! of if (ok_dyn_ins)
852#endif
853! For some Grads outputs
854                if (output_grads_dyn) then
855#include "write_grads_dyn.h"
856                endif
857
858              ENDIF ! of IF(MOD(itau,iecri         ).EQ.0)
859
860              IF(itau.EQ.itaufin) THEN
[6]861                if (planet_type.eq."mars") then
862! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem1_mars
863                  abort_message = 'dynredem1_mars A FAIRE'
864                  call abort_gcm(modname,abort_message,0)
865                else
[492]866                  CALL dynredem1("restart.nc",start_time,
[6]867     &                         vcov,ucov,teta,q,masse,ps)
868                endif ! of if (planet_type.eq."mars")
[1]869              ENDIF ! of IF(itau.EQ.itaufin)
870
871              forward = .TRUE.
872              GO TO  1
873
874            ENDIF ! of IF (forward)
875
876      END IF ! of IF(.not.purmats)
877
878      STOP
879      END
Note: See TracBrowser for help on using the repository browser.