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

Last change on this file since 1563 was 1543, checked in by emillour, 10 years ago

All models: Further adaptations to keep up with changes in LMDZ5 concerning
physics/dynamics separation:

  • dyn3d:
  • adapted gcm.F so that all physics initializations are now done in iniphysiq.
  • dyn3dpar:
  • adapted gcm.F so that all physics initializations are now done in iniphysiq.
  • updated calfis_p.F to follow up with changes.
  • copied over updated "bands.F90" from LMDZ5.
  • dynphy_lonlat:
  • calfis_p.F90, mod_interface_dyn_phys.F90, follow up of changes in phy_common/mod_* routines
  • phy_common:
  • added "geometry_mod.F90" to store information about the grid (replaces phy*/comgeomphy.F90) and give variables friendlier names: rlond => longitude , rlatd => latitude, airephy => cell_area, cuphy => dx , cvphy => dy
  • added "physics_distribution_mod.F90"
  • updated "mod_grid_phy_lmdz.F90", "mod_phys_lmdz_mpi_data.F90", "mod_phys_lmdz_para.F90", "mod_phys_lmdz_mpi_transfert.F90", "mod_grid_phy_lmdz.F90", "mod_phys_lmdz_omp_data.F90", "mod_phys_lmdz_omp_transfert.F90", "write_field_phy.F90" and "ioipsl_getin_p_mod.F90" to LMDZ5 versions.
  • phy[venus/titan/mars/std]:
  • removed "init_phys_lmdz.F90", "comgeomphy.F90"; adapted routines to use geometry_mod (longitude, latitude, cell_area, etc.)

EM

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