source: trunk/LMDZ.MARS/libf/dyn3d/gcm.F @ 1594

Last change on this file since 1594 was 1594, checked in by emillour, 8 years ago

Mars and Generic "old" dynamics: to further harmonize with LMDZ.COMMON, replace "idissip" with "dissip_period".
EM

File size: 22.3 KB
Line 
1      PROGRAM gcm
2
3      use ioipsl_getincom, only: getin
4      use infotrac, only: iniadvtrac, nqtot, iadv
5      use control_mod, only: day_step, iperiod, iphysiq, ndynstep,
6     &                       nday_r, dissip_period, iconser, ecritstart
7      use filtreg_mod, only: inifilr
8!      use comgeomphy, only: initcomgeomphy
9      USE mod_const_mpi, ONLY: COMM_LMDZ
10      USE comvert_mod, ONLY: ap,bp
11      use sponge_mod, only: callsponge,mode_sponge,sponge
12      USE comconst_mod, ONLY: daysec,dtvr,dtphys,dtdiss,rad,g,r,cpp
13      USE logic_mod, ONLY: ecripar,forward,leapf,apphys,statcl,conser,
14     .                apdiss,purmats,iflag_phys,apphys
15      USE temps_mod, ONLY: day_ini,day_end,dt,itaufin
16      USE iniphysiq_mod, ONLY: iniphysiq
17      IMPLICIT NONE
18
19c      ......   Version  du 10/01/98    ..........
20
21c             avec  coordonnees  verticales hybrides
22c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
23
24c=======================================================================
25c
26c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
27c   -------
28c
29c   Objet:
30c   ------
31c
32c   GCM LMD nouvelle grille
33c
34c=======================================================================
35c
36c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
37c      et possibilite d'appeler une fonction f(y)  a derivee tangente
38c      hyperbolique a la  place de la fonction a derivee sinusoidale.
39
40c  ... Possibilite de choisir le shema de Van-leer pour l'advection de
41c        q  , en faisant iadv = 3  dans   traceur  (29/04/97) .
42c
43c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
44c
45c-----------------------------------------------------------------------
46c   Declarations:
47c   -------------
48
49#include "dimensions.h"
50#include "paramet.h"
51#include "comdissnew.h"
52#include "comgeom.h"
53!#include "control.h"
54#include "netcdf.inc"
55#include "tracstoke.h"
56!#include"advtrac.h"
57
58      INTEGER*4  iday ! jour julien
59      REAL       time ! Heure de la journee en fraction d''1 jour
60      REAL zdtvr
61
62c   variables dynamiques
63      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
64      real, dimension(ip1jmp1,llm) :: teta   ! temperature potentielle
65      REAL,allocatable :: q(:,:,:)           ! champs advectes
66      REAL ps(ip1jmp1)                       ! pression  au sol
67!      REAL pext(ip1jmp1)                     ! pression  extensive
68      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
69      REAL pks(ip1jmp1)                      ! exner au  sol
70      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
71      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
72      REAL masse(ip1jmp1,llm)                ! masse d''air
73      REAL phis(ip1jmp1)                     ! geopotentiel au sol
74      REAL phi(ip1jmp1,llm)                  ! geopotentiel
75      REAL w(ip1jmp1,llm)                    ! vitesse verticale
76
77c variables dynamiques intermediaire pour le transport
78      REAL pbaru(ip1jmp1,llm),pbarv(ip1jm,llm) !flux de masse
79
80c   variables dynamiques au pas -1
81      REAL vcovm1(ip1jm,llm),ucovm1(ip1jmp1,llm)
82
83      REAL tetam1(ip1jmp1,llm),psm1(ip1jmp1)
84      REAL massem1(ip1jmp1,llm)
85
86c   tendances dynamiques
87      REAL dv(ip1jm,llm),du(ip1jmp1,llm)
88      REAL dteta(ip1jmp1,llm),dp(ip1jmp1)
89      REAL,ALLOCATABLE :: dq(:,:,:)
90
91c   tendances de la dissipation
92      REAL dvdis(ip1jm,llm),dudis(ip1jmp1,llm)
93      REAL dhdis(ip1jmp1,llm)
94
95c   tendances physiques
96      REAL dvfi(ip1jm,llm),dufi(ip1jmp1,llm)
97      REAL dhfi(ip1jmp1,llm),dpfi(ip1jmp1)
98      REAL,ALLOCATABLE :: dqfi(:,:,:)
99
100c   variables pour le fichier histoire
101      REAL dtav      ! intervalle de temps elementaire
102
103      REAL tppn(iim),tpps(iim),tpn,tps
104c
105
106      INTEGER itau,itaufinp1,iav
107
108
109      EXTERNAL caldyn, traceur
110      EXTERNAL dissip,geopot,iniconst
111      EXTERNAL integrd,SCOPY
112      EXTERNAL inigeom
113      EXTERNAL exner_hyb,addit
114      EXTERNAL defrun_new, test_period
115      REAL  SSUM
116      REAL time_0 , finvmaold(ip1jmp1,llm)
117
118      LOGICAL lafin
119      INTEGER ij,iq,l,ierr,numvanle,iapp_tracvl
120
121      REAL rdayvrai,rdaym_ini,rday_ecri
122!      LOGICAL first
123      REAL beta(ip1jmp1,llm)
124
125      LOGICAL offline  ! Controle du stockage ds "fluxmass"
126      PARAMETER (offline=.false.)
127
128      character*20 modname
129      character*80 abort_message
130
131! flag to run with or without tracer transport (read from run.def)
132      logical tracer
133     
134C Calendrier
135      LOGICAL true_calendar
136      PARAMETER (true_calendar = .false.)
137
138! flag to set/remove calls to groupeun
139      logical callgroupeun
140      parameter (callgroupeun = .false.)
141
142c-----------------------------------------------------------------------
143c    variables pour l'initialisation de la physique :
144c    ------------------------------------------------
145!      INTEGER ngridmx
146!      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
147!      REAL zcufi(ngridmx),zcvfi(ngridmx)
148!      REAL latfi(ngridmx),lonfi(ngridmx)
149!      REAL airefi(ngridmx)
150!      SAVE latfi, lonfi, airefi
151!      INTEGER i,j
152
153c-----------------------------------------------------------------------
154c   Initialisations:
155c   ----------------
156
157      modname = 'gcm'
158      lafin    = .FALSE.
159
160c-----------------------------------------------------------------------
161      CALL defrun_new( 99, .TRUE. )
162      WRITE(*,*) ""
163      WRITE(*,*) "Run with or without tracer transport ?"
164      tracer=.true. ! default value
165      call getin("tracer",tracer)
166      WRITE(*,*)" tracer = ",tracer
167
168! Initialize tracers
169      call iniadvtrac(nqtot,numvanle)
170! Allocation de la tableau q : champs advectes   
171      allocate(q(ip1jmp1,llm,nqtot))
172      allocate(dq(ip1jmp1,llm,nqtot))
173      allocate(dqfi(ip1jmp1,llm,nqtot))
174
175      CALL dynetat0("start.nc",vcov,ucov,
176     .              teta,q,masse,ps,phis,time_0)
177
178      ! in case time_0 (because of roundoffs) is close to zero,
179      ! set it to zero to avoid roundoff propagation issues
180      if ((time_0.gt.0.).and.(time_0.lt.(1./day_step))) then
181        write(*,*)"GCM: In start.nc, time=",time_0
182        write(*,*)"     but day_step=",day_step
183        write(*,*)"     and 1./day_step=",1./day_step
184        write(*,*)"     fix this drift by setting time=0"
185        time_0=0.
186      endif
187
188
189c  on recalcule eventuellement le pas de temps
190
191      IF(MOD(day_step,iperiod).NE.0)
192     * STOP'Il faut choisir un nb de pas par jour multiple de iperiod'
193
194      IF(MOD(day_step,iphysiq).NE.0)
195     * STOP'Il faut choisir un nb de pas par jour multiple de iphysiq'
196
197      zdtvr    = daysec/REAL(day_step)
198        IF(dtvr.NE.zdtvr) THEN
199         PRINT*,'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
200        ENDIF
201
202c  nombre d'etats dans les fichiers demarrage et histoire
203
204      dtvr = zdtvr
205      CALL iniconst
206      CALL inigeom
207
208      CALL inifilr
209
210c
211c   ......    P.Le Van    ( modif  le 29/04/97 )   ......... 
212c
213
214      CALL inidissip ( lstardis, nitergdiv, nitergrot, niterh   ,
215     *                tetagdiv, tetagrot , tetatemp              )
216c
217
218c-----------------------------------------------------------------------
219c   Initialisation de la physique :
220c   -------------------------------
221
222!      IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN
223!         latfi(1)=rlatu(1)
224!         lonfi(1)=0.
225!         zcufi(1) = cu(1)
226!         zcvfi(1) = cv(1)
227!         DO j=2,jjm
228!            DO i=1,iim
229!               latfi((j-2)*iim+1+i)= rlatu(j)
230!               lonfi((j-2)*iim+1+i)= rlonv(i)
231!               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
232!               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
233!            ENDDO
234!         ENDDO
235!         latfi(ngridmx)= rlatu(jjp1)
236!         lonfi(ngridmx)= 0.
237!         zcufi(ngridmx) = cu(ip1jm+1)
238!         zcvfi(ngridmx) = cv(ip1jm-iim)
239!
240!         ! build airefi(), mesh area on physics grid
241!         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
242!         ! Poles are single points on physics grid
243!         airefi(1)=airefi(1)*iim
244!         airefi(ngridmx)=airefi(ngridmx)*iim
245
246! Initialisation de la physique: pose probleme quand on tourne
247! SANS physique, car iniphysiq.F est dans le repertoire phy[]...
248! Il faut une cle CPP_PHYS
249!#ifdef CPP_PHYS
250!         CALL iniphysiq(iim,jjm,llm,daysec,day_ini,dtphys/nsplit_phys,
251         CALL iniphysiq(iim,jjm,llm,
252     &                  (jjm-1)*iim+2,comm_lmdz,
253     &                  daysec,day_ini,dtphys,
254     &                  rlatu,rlatv,rlonu,rlonv,
255     &                  aire,cu,cv,rad,g,r,cpp,
256     &                iflag_phys)
257!#endif
258!         call_iniphys=.false.
259!      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
260!        call inifis(ngridmx,llm,nqtot,day_ini,daysec,dtphys,
261!     .                latfi,lonfi,airefi,rad,g,r,cpp)
262
263      call dump2d(iip1,jjp1,ps,'PRESSION SURFACE')
264
265c
266c  numero de stockage pour les fichiers de redemarrage:
267
268c-----------------------------------------------------------------------
269c   temps de depart et de fin:
270c   --------------------------
271
272      itau = 0
273      iday = day_ini+itau/day_step
274      time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
275         IF(time.GT.1.) THEN
276          time = time-1.
277          iday = iday+1
278         ENDIF
279      if (ndynstep .gt. 0) then
280         itaufin = ndynstep
281      else
282         itaufin=nint(nday_r*day_step) ! nint() to avoid problematic roundoffs
283      endif
284      ! check that this is compatible with call sequence dyn/phys/dissip
285      ! i.e. that itaufin is a multiple of iphysiq and dissip_period
286      if ((modulo(itaufin,iphysiq).ne.0).or.
287     &    (modulo(itaufin,dissip_period).ne.0)) then
288        if (ndynstep .gt. 0) then
289       write(*,'(A,I5)')
290     &  "gcm: Problem: incompatibility between ndynstep=",ndynstep
291        else
292       write(*,'((A,F9.2),2(A,I5))')
293     &  "gcm: Problem: incompatibility between nday=",nday_r,
294     &  " day_step=",day_step," which imply itaufin=",itaufin
295        endif
296        write(*,'(2(A,I5))')
297     &   "  whereas iphysiq=",iphysiq," and dissip_period=",
298     &  dissip_period
299        stop
300      endif
301!      write(*,*)"gcm: itaufin=",itaufin
302c ********************************
303c      itaufin = 120   ! temporaire !!
304c ********************************
305      itaufinp1 = itaufin +1
306
307      if (ndynstep .gt. 0) then
308        day_end = day_ini
309     &          + floor(float(ndynstep)/float(day_step)+time_0)
310      else
311        day_end = day_ini + floor(nday_r+time_0)
312      endif
313      PRINT 300, itau,itaufin,day_ini,day_end
314 300  FORMAT('1'/,15x,'run du pas',i7,2x,'au pas',i7,2x, 
315     . 'c''est a dire du jour',i7,3x,'au jour',i7//)
316
317      CALL dynredem0("restart.nc",day_ini,phis)
318
319      ecripar = .TRUE.
320
321      dtav = iperiod*dtvr/daysec
322
323
324c   Quelques initialisations pour les traceurs
325      dq(:,:,:)=0
326c     istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
327c     istphy=istdyn/iphysiq
328
329      write(*,*) "gcm: callgroupeun set to:",callgroupeun
330c-----------------------------------------------------------------------
331c   Debut de l'integration temporelle:
332c   ----------------------------------
333
334   1  CONTINUE
335c
336c TN 09/2012. To ensure "1+1=2" in dynamical core :
337c update atmospheric pressure IN the main loop
338      CALL pression ( ip1jmp1, ap, bp, ps, p       )
339      CALL exner_hyb( ip1jmp1, ps, p,beta, pks, pk, pkf )
340
341      IF( MOD( itau, 10* day_step ).EQ.0 )  THEN
342        CALL test_period ( ucov,vcov,teta,q,p,phis )
343        write(*,*)' GCM ---- Test_period apres continue   OK ! -----',
344     &            ' itau: ',itau
345      ENDIF
346
347      if (callgroupeun) then
348        call groupeun(jjp1,llm,ucov,.true.)
349        call groupeun(jjm,llm,vcov,.true.)
350        call groupeun(jjp1,llm,teta,.true.)
351        call groupeun(jjp1,llm,masse,.true.)
352        call groupeun(jjp1,1,ps,.false.)
353      endif
354
355      CALL SCOPY( ijmllm ,vcov , 1, vcovm1 , 1 )
356      CALL SCOPY( ijp1llm,ucov , 1, ucovm1 , 1 )
357      CALL SCOPY( ijp1llm,teta , 1, tetam1 , 1 )
358      CALL SCOPY( ijp1llm,masse, 1, massem1, 1 )
359      CALL SCOPY( ip1jmp1, ps  , 1,   psm1 , 1 )
360
361      forward = .TRUE.
362      leapf   = .FALSE.
363      dt      =  dtvr
364
365c   ...    P.Le Van .26/04/94  ....
366
367      CALL SCOPY   ( ijp1llm,   masse, 1, finvmaold,     1 )
368      CALL filtreg ( finvmaold ,jjp1, llm, -2,2, .TRUE., 1 )
369
370
371   2  CONTINUE
372
373c-----------------------------------------------------------------------
374
375c   date:
376c   -----
377
378!      write(*,*) 'GCM: itau=',itau
379
380c   gestion des appels de la physique et des dissipations:
381c   ------------------------------------------------------
382c
383c   ...    P.Le Van  ( 6/02/95 )  ....
384
385      apphys = .FALSE.
386      statcl = .FALSE.
387      conser = .FALSE.
388      apdiss = .FALSE.
389
390      IF( purmats ) THEN
391         IF( MOD(itau,iconser) .EQ.0.AND.  forward    ) conser = .TRUE.
392         IF( MOD(itau,dissip_period ).EQ.0
393     &                              .AND..NOT.forward ) apdiss = .TRUE.
394         IF( MOD(itau,iphysiq ).EQ.0.AND..NOT.forward
395     $                   .AND.   (iflag_phys.eq.1)    ) apphys = .TRUE.
396      ELSE
397         IF( MOD(itau   ,iconser) .EQ. 0              ) conser = .TRUE.
398         IF( MOD(itau+1,dissip_period)  .EQ. 0        ) apdiss = .TRUE.
399         IF( MOD(itau+1,iphysiq).EQ.0 
400     &                     .AND. (iflag_phys.eq.1)    ) apphys = .TRUE.
401      END IF
402
403c-----------------------------------------------------------------------
404c   calcul des tendances dynamiques:
405c   --------------------------------
406
407      CALL geopot  ( ip1jmp1, teta  , pk , pks,  phis  , phi   )
408c
409c
410      CALL caldyn
411     $  ( itau,ucov,vcov,teta,ps,masse,pk,pkf,phis ,
412     $    phi,conser,du,dv,dteta,dp,w, pbaru,pbarv, time+iday-day_ini )
413
414
415c-----------------------------------------------------------------------
416c   calcul des tendances advection des traceurs (dont l'humidite)
417c   -------------------------------------------------------------
418
419      if (tracer) then
420       IF( forward. OR . leapf )  THEN
421
422        DO iq = 1, nqtot
423c
424         IF ( iadv(iq).EQ.1.OR.iadv(iq).EQ.2 )  THEN
425            CALL traceur( iq,iadv,q,teta,pk,w, pbaru, pbarv, dq )
426
427         ELSE IF( iq.EQ. nqtot )   THEN
428c
429            iapp_tracvl = 5
430c
431cccc     iapp_tracvl est la frequence en pas du groupement des flux
432cccc      de masse pour  Van-Leer dans la routine  tracvl  .
433c
434
435            CALL vanleer(numvanle,iapp_tracvl,nqtot,q,pbaru,pbarv,
436     *                      p, masse, dq,  iadv(1), teta, pk     )
437
438c
439c                   ...  Modif  F.Codron  ....
440c
441         ENDIF
442c
443        ENDDO
444C
445c        IF (offline) THEN
446C maf stokage du flux de masse pour traceurs OFF-LINE
447
448c           CALL fluxstokenc(pbaru,pbarv,masse,teta,phi,phis,
449c    .   time_step, itau)
450
451c        ENDIF
452c
453      ENDIF
454          END IF   ! tracer
455
456
457c-----------------------------------------------------------------------
458c   integrations dynamique et traceurs:
459c   ----------------------------------
460
461       CALL integrd ( 2,vcovm1,ucovm1,tetam1,psm1,massem1 ,
462     $         dv,du,dteta,dq,dp,vcov,ucov,teta,q,ps,masse,phis ,
463     $              finvmaold )
464
465c .P.Le Van (26/04/94  ajout de  finvpold dans l'appel d'integrd)
466c
467c-----------------------------------------------------------------------
468c   calcul des tendances physiques:
469c   -------------------------------
470c    ########   P.Le Van ( Modif le  6/02/95 )   ###########
471c
472       IF( purmats )  THEN
473          IF( itau.EQ.itaufin.AND..NOT.forward ) lafin = .TRUE.
474       ELSE
475          IF( itau+1. EQ. itaufin )              lafin = .TRUE.
476       ENDIF
477c
478c
479       IF( apphys )  THEN
480c
481c     .......   Ajout   P.Le Van ( 17/04/96 )   ...........
482c
483
484         CALL pression (  ip1jmp1, ap, bp, ps,  p      )
485         CALL exner_hyb(  ip1jmp1, ps, p,beta,pks, pk, pkf )
486
487           rdaym_ini  = itau * dtvr / daysec + time_0
488           rdayvrai   = rdaym_ini  + day_ini
489
490! Ehouarn: what was this for ??
491!           IF ( ecritphy.LT.1. )  THEN
492!             rday_ecri = rdaym_ini
493!           ELSE
494             rday_ecri = INT( rdayvrai )
495!           ENDIF
496c
497        CALL calfis( nqtot, lafin ,rdayvrai,rday_ecri,time  ,
498     $                 ucov,vcov,teta,q,masse,ps,p,pk,phis,phi ,
499     $     du,dv,dteta,dq,w, dufi,dvfi,dhfi,dqfi,dpfi)
500
501
502c      ajout des tendances physiques:
503c      ------------------------------
504          CALL addfi( nqtot, dtphys, leapf, forward   ,
505     $                  ucov, vcov, teta , q   ,ps , masse,
506     $                 dufi, dvfi, dhfi , dqfi ,dpfi  )
507c
508       ENDIF
509
510       CALL pression ( ip1jmp1, ap, bp, ps, p                  )
511
512       CALL exner_hyb( ip1jmp1, ps, p,beta, pks, pk, pkf )
513c   ----------------------------------------------------------
514
515c
516c
517c   dissipation horizontale et verticale  des petites echelles:
518c   ----------------------------------------------------------
519
520
521      IF(apdiss) THEN
522
523c        Sponge layer
524c        ~~~~~~~~~~~~
525         IF (callsponge) THEN
526            CALL sponge(ucov,vcov,teta,ps,dtdiss,mode_sponge)
527         ENDIF
528
529c        Dissipation horizontale
530c        ~~~~~~~~~~~~~~~~~~~~~~~
531         CALL dissip(vcov,ucov,teta,p,dvdis,dudis,dhdis)
532
533         CALL addit( ijp1llm,ucov ,dudis,ucov )
534         CALL addit( ijmllm ,vcov ,dvdis,vcov )
535         CALL addit( ijp1llm,teta ,dhdis,teta )
536
537
538c    .......        P. Le Van (  ajout  le 17/04/96  )   ...........
539c   ...      Calcul de la valeur moyenne, unique de h aux poles  .....
540c
541
542        DO l  =  1, llm
543          DO ij =  1,iim
544           tppn(ij)  = aire(  ij    ) * teta(  ij    ,l)
545           tpps(ij)  = aire(ij+ip1jm) * teta(ij+ip1jm,l)
546          ENDDO
547
548           tpn  = SSUM(iim,tppn,1)/apoln
549           tps  = SSUM(iim,tpps,1)/apols
550
551          DO ij = 1, iip1
552           teta(  ij    ,l) = tpn
553           teta(ij+ip1jm,l) = tps
554          ENDDO
555        ENDDO
556
557        DO ij =  1,iim
558          tppn(ij)  = aire(  ij    ) * ps (  ij    )
559          tpps(ij)  = aire(ij+ip1jm) * ps (ij+ip1jm)
560        ENDDO
561          tpn  = SSUM(iim,tppn,1)/apoln
562
563          tps  = SSUM(iim,tpps,1)/apols
564
565        DO ij = 1, iip1
566          ps(  ij    ) = tpn
567          ps(ij+ip1jm) = tps
568        ENDDO
569
570
571      END IF
572       
573c   ********************************************************************
574c   ********************************************************************
575c   .... fin de l'integration dynamique  et physique pour le pas itau ..
576c   ********************************************************************
577c   ********************************************************************
578
579c   preparation du pas d'integration suivant  ......
580
581      IF ( .NOT.purmats ) THEN
582c       ........................................................
583c       ..............  schema matsuno + leapfrog  ..............
584c       ........................................................
585
586            IF(forward. OR. leapf) THEN
587              itau= itau + 1
588              iday= day_ini+itau/day_step
589              time= REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
590                !IF(time.GT.1.) THEN
591                IF(time.GE.1.) THEN
592                  time = time-1.
593                  iday = iday+1
594                ENDIF
595            ENDIF
596
597
598            IF( itau. EQ. itaufinp1 ) then 
599              abort_message = 'Simulation finished'
600              call abort_gcm(modname,abort_message,0)
601            ENDIF
602c-----------------------------------------------------------------------
603c   ecriture du fichier histoire moyenne:
604c   -------------------------------------
605
606c           IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
607c              IF(itau.EQ.itaufin) THEN
608c                 iav=1
609c              ELSE
610c                 iav=0
611c              ENDIF
612c              CALL writedynav(histaveid, nqtot, itau,vcov ,
613c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
614c           ENDIF
615
616c-----------------------------------------------------------------------
617
618            IF( (ecritstart.GT.0) .and. (MOD(itau,ecritstart).EQ.0)
619     .        .or. (itau.EQ.itaufin) ) THEN
620           
621       !write(*,*)' GCM: Appel test_period avant redem ; itau=',itau
622       CALL test_period ( ucov,vcov,teta,q,p,phis )
623       
624       write(*,'(A,I7,A,F12.5)')
625     .  'GCM:    Ecriture du fichier restart   ; itau=  ',itau,
626     .  ' date=',REAL(itau)/REAL(day_step)
627       CALL dynredem1("restart.nc",REAL(itau)/REAL(day_step),
628     .                vcov,ucov,teta,q,masse,ps)
629     
630      CLOSE(99)
631     
632            ENDIF
633
634
635c-----------------------------------------------------------------------
636c   gestion de l'integration temporelle:
637c   ------------------------------------
638
639            IF( MOD(itau,iperiod).EQ.0 )    THEN
640                    GO TO 1
641            ELSE IF ( MOD(itau-1,iperiod). EQ. 0 ) THEN
642
643                   IF( forward )  THEN
644c      fin du pas forward et debut du pas backward
645
646                      forward = .FALSE.
647                        leapf = .FALSE.
648                           GO TO 2
649
650                   ELSE
651c      fin du pas backward et debut du premier pas leapfrog
652
653                        leapf =  .TRUE.
654                        dt  =  2.*dtvr
655                        GO TO 2
656                   END IF
657            ELSE
658
659c      ......   pas leapfrog  .....
660
661                 leapf = .TRUE.
662                 dt  = 2.*dtvr
663                 GO TO 2
664            END IF
665
666      ELSE
667
668c       ........................................................
669c       ..............       schema  matsuno        ...............
670c       ........................................................
671            IF( forward )  THEN
672
673             itau =  itau + 1
674             iday = day_ini+itau/day_step
675             time = REAL(itau-(iday-day_ini)*day_step)/day_step+time_0
676
677                  IF(time.GE.1.) THEN
678                   time = time-1.
679                   iday = iday+1
680                  ENDIF
681
682               forward =  .FALSE.
683               IF( itau. EQ. itaufinp1 ) then 
684                 abort_message = 'Simulation finished'
685                 call abort_gcm(modname,abort_message,0)
686               ENDIF
687               GO TO 2
688
689            ELSE
690
691            IF(MOD(itau,iperiod).EQ.0 .OR. itau.EQ.itaufin) THEN
692               IF(itau.EQ.itaufin) THEN
693                  iav=1
694               ELSE
695                  iav=0
696               ENDIF
697c              CALL writedynav(histaveid, nqtot, itau,vcov ,
698c    ,                          ucov,teta,pk,phi,q,masse,ps,phis)
699
700            ENDIF
701
702
703            IF( (ecritstart.GT.0) .and. (MOD(itau,ecritstart).EQ.0)
704     .      .or. (itau.EQ.itaufin) ) THEN
705           
706              CALL dynredem1("restart.nc",
707     .                REAL(itau)/REAL(day_step),
708     .                vcov,ucov,teta,q,masse,ps)
709     
710              forward = .TRUE.
711              GO TO  1
712             
713            ENDIF
714
715
716            ENDIF
717
718      END IF
719
720      STOP
721      END
Note: See TracBrowser for help on using the repository browser.