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

Last change on this file since 1410 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

EM

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