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

Last change on this file since 914 was 841, checked in by emillour, 13 years ago

Common dynamics:

  • updates to keep up with LMDZ5 Earth (rev 1678) changes
  • fixed bug in leapfrog_p.F: parallel dynamics now work fine.
  • see file "DOC/chantiers/commit_importants.log" for details.

EM

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