source: LMDZ4/trunk/libf/dyn3d/gcm.F @ 1315

Last change on this file since 1315 was 1315, checked in by acozic, 14 years ago

acozic: add argument in init_const_lmdz call for initialisation of INCA model

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.8 KB
Line 
1!
2! $Id: gcm.F 1315 2010-02-22 14:41:06Z acozic $
3!
4c
5c
6      PROGRAM gcm
7
8#ifdef CPP_IOIPSL
9      USE IOIPSL
10#else
11! if not using IOIPSL, we still need to use (a local version of) getin
12      USE ioipsl_getincom
13#endif
14
15      USE filtreg_mod
16      USE infotrac
17
18!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
20! A nettoyer. On ne veut qu'une ou deux routines d'interface
21! dynamique -> physique pour l'initialisation
22! Ehouarn: for now these only apply to Earth:
23#ifdef CPP_EARTH
24      USE dimphy
25      USE comgeomphy
26      USE mod_phys_lmdz_para, ONLY : klon_mpi_para_nb
27#endif
28!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29
30      IMPLICIT NONE
31
32c      ......   Version  du 10/01/98    ..........
33
34c             avec  coordonnees  verticales hybrides
35c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
36
37c=======================================================================
38c
39c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
40c   -------
41c
42c   Objet:
43c   ------
44c
45c   GCM LMD nouvelle grille
46c
47c=======================================================================
48c
49c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
50c      et possibilite d'appeler une fonction f(y)  a derivee tangente
51c      hyperbolique a la  place de la fonction a derivee sinusoidale.
52c  ... Possibilite de choisir le schema pour l'advection de
53c        q  , en modifiant iadv dans traceur.def  (MAF,10/02) .
54c
55c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
56c      Pour Van-Leer iadv=10
57c
58c-----------------------------------------------------------------------
59c   Declarations:
60c   -------------
61
62#include "dimensions.h"
63#include "paramet.h"
64#include "comconst.h"
65#include "comdissnew.h"
66#include "comvert.h"
67#include "comgeom.h"
68#include "logic.h"
69#include "temps.h"
70#include "control.h"
71#include "ener.h"
72#include "description.h"
73#include "serre.h"
74#include "com_io_dyn.h"
75#include "iniprint.h"
76#include "tracstoke.h"
77#include "indicesol.h"
78
79      INTEGER         longcles
80      PARAMETER     ( longcles = 20 )
81      REAL  clesphy0( longcles )
82      SAVE  clesphy0
83
84
85
86      REAL zdtvr
87      INTEGER nbetatmoy, nbetatdem,nbetat
88
89c   variables dynamiques
90      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
91      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
92      REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes
93      REAL ps(ip1jmp1)                       ! pression  au sol
94      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
95      REAL pks(ip1jmp1)                      ! exner au  sol
96      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
97      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
98      REAL masse(ip1jmp1,llm)                ! masse d'air
99      REAL phis(ip1jmp1)                     ! geopotentiel au sol
100      REAL phi(ip1jmp1,llm)                  ! geopotentiel
101      REAL w(ip1jmp1,llm)                    ! vitesse verticale
102
103c variables dynamiques intermediaire pour le transport
104
105c   variables pour le fichier histoire
106      REAL dtav      ! intervalle de temps elementaire
107
108      REAL time_0
109
110      LOGICAL lafin
111      INTEGER ij,iq,l,i,j
112
113
114      real time_step, t_wrt, t_ops
115
116      LOGICAL first
117
118      LOGICAL call_iniphys
119      data call_iniphys/.true./
120
121      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
122c+jld variables test conservation energie
123c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
124C     Tendance de la temp. potentiel d (theta)/ d t due a la
125C     tansformation d'energie cinetique en energie thermique
126C     cree par la dissipation
127      REAL dhecdt(ip1jmp1,llm)
128c      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
129c      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
130      CHARACTER (len=15) :: ztit
131c-jld
132
133
134      character (len=80) :: dynhist_file, dynhistave_file
135      character (len=20) :: modname
136      character (len=80) :: abort_message
137! locales pour gestion du temps
138      INTEGER :: an, mois, jour
139      REAL :: heure
140
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
152c-----------------------------------------------------------------------
153c   Initialisations:
154c   ----------------
155
156      abort_message = 'last timestep reached'
157      modname = 'gcm'
158      descript = 'Run GCM LMDZ'
159      lafin    = .FALSE.
160      dynhist_file = 'dyn_hist.nc'
161      dynhistave_file = 'dyn_hist_ave.nc'
162
163
164
165c----------------------------------------------------------------------
166c  lecture des fichiers gcm.def ou run.def
167c  ---------------------------------------
168c
169! Ehouarn: dump possibility of using defrun
170!#ifdef CPP_IOIPSL
171      CALL conf_gcm( 99, .TRUE. , clesphy0 )
172!#else
173!      CALL defrun( 99, .TRUE. , clesphy0 )
174!#endif
175
176!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
177! FH 2008/05/02
178! A nettoyer. On ne veut qu'une ou deux routines d'interface
179! dynamique -> physique pour l'initialisation
180! Ehouarn : temporarily (?) keep this only for Earth
181      if (planet_type.eq."earth") then
182#ifdef CPP_EARTH
183      CALL Init_Phys_lmdz(iim,jjp1,llm,1,(jjm-1)*iim+2)
184      call InitComgeomphy
185#endif
186      endif
187!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
188c-----------------------------------------------------------------------
189c   Choix du calendrier
190c   -------------------
191
192c      calend = 'earth_365d'
193
194#ifdef CPP_IOIPSL
195      if (calend == 'earth_360d') then
196        call ioconf_calendar('360d')
197        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
198      else if (calend == 'earth_365d') then
199        call ioconf_calendar('noleap')
200        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
201      else if (calend == 'earth_366d') then
202        call ioconf_calendar('gregorian')
203        write(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
204      else
205        abort_message = 'Mauvais choix de calendrier'
206        call abort_gcm(modname,abort_message,1)
207      endif
208#endif
209c-----------------------------------------------------------------------
210
211      IF (config_inca /= 'none') THEN
212#ifdef INCA
213      call init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday,
214     $        nbsrf, is_oce,is_sic,is_ter,is_lic)
215      call init_inca_para(iim,jjm+1,klon,1,klon_mpi_para_nb,0)
216#endif
217      END IF
218c
219c
220c------------------------------------
221c   Initialisation partie parallele
222c------------------------------------
223
224c
225c
226c-----------------------------------------------------------------------
227c   Initialisation des traceurs
228c   ---------------------------
229c  Choix du nombre de traceurs et du schema pour l'advection
230c  dans fichier traceur.def, par default ou via INCA
231      call infotrac_init
232
233c Allocation de la tableau q : champs advectes   
234      allocate(q(ip1jmp1,llm,nqtot))
235
236c-----------------------------------------------------------------------
237c   Lecture de l'etat initial :
238c   ---------------------------
239
240c  lecture du fichier start.nc
241      if (read_start) then
242      ! we still need to run iniacademic to initialize some
243      ! constants & fields, if we run the 'newtonian' case:
244        if (iflag_phys.eq.2) then
245          CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
246        endif
247!#ifdef CPP_IOIPSL
248        if (planet_type.eq."earth") then
249#ifdef CPP_EARTH
250! Load an Earth-format start file
251         CALL dynetat0("start.nc",vcov,ucov,
252     .              teta,q,masse,ps,phis, time_0)
253#endif
254        endif ! of if (planet_type.eq."earth")
255c       write(73,*) 'ucov',ucov
256c       write(74,*) 'vcov',vcov
257c       write(75,*) 'teta',teta
258c       write(76,*) 'ps',ps
259c       write(77,*) 'q',q
260
261      endif ! of if (read_start)
262
263      IF (config_inca /= 'none') THEN
264#ifdef INCA
265         call init_inca_dim(klon,llm,iim,jjm,
266     $        rlonu,rlatu,rlonv,rlatv)
267#endif
268      END IF
269
270
271c le cas echeant, creation d un etat initial
272      IF (prt_level > 9) WRITE(lunout,*)
273     .              'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
274      if (.not.read_start) then
275         CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
276      endif
277
278
279c-----------------------------------------------------------------------
280c   Lecture des parametres de controle pour la simulation :
281c   -------------------------------------------------------
282c  on recalcule eventuellement le pas de temps
283
284      IF(MOD(day_step,iperiod).NE.0) THEN
285        abort_message =
286     .  'Il faut choisir un nb de pas par jour multiple de iperiod'
287        call abort_gcm(modname,abort_message,1)
288      ENDIF
289
290      IF(MOD(day_step,iphysiq).NE.0) THEN
291        abort_message =
292     * 'Il faut choisir un nb de pas par jour multiple de iphysiq'
293        call abort_gcm(modname,abort_message,1)
294      ENDIF
295
296      zdtvr    = daysec/FLOAT(day_step)
297        IF(dtvr.NE.zdtvr) THEN
298         WRITE(lunout,*)
299     .    'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
300        ENDIF
301
302C
303C on remet le calendrier à zero si demande
304c
305      if (annee_ref .ne. anneeref .or. day_ref .ne. dayref) then
306        write(lunout,*)
307     .  'GCM: Attention les dates initiales lues dans le fichier'
308        write(lunout,*)
309     .  ' restart ne correspondent pas a celles lues dans '
310        write(lunout,*)' gcm.def'
311        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
312        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
313        if (raz_date .ne. 1) then
314          write(lunout,*)
315     .    'GCM: On garde les dates du fichier restart'
316        else
317          annee_ref = anneeref
318          day_ref = dayref
319          day_ini = dayref
320          itau_dyn = 0
321          itau_phy = 0
322          time_0 = 0.
323          write(lunout,*)
324     .   'GCM: On reinitialise a la date lue dans gcm.def'
325        endif
326      ELSE
327        raz_date = 0
328      endif
329
330#ifdef CPP_IOIPSL
331      mois = 1
332      heure = 0.
333      call ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
334      jH_ref = jD_ref - int(jD_ref)
335      jD_ref = int(jD_ref)
336
337      call ioconf_startdate(INT(jD_ref), jH_ref)
338
339      write(lunout,*)'DEBUG'
340      write(lunout,*)'annee_ref, mois, day_ref, heure, jD_ref'
341      write(lunout,*)annee_ref, mois, day_ref, heure, jD_ref
342      call ju2ymds(jD_ref+jH_ref,an, mois, jour, heure)
343      write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
344      write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
345#else
346! Ehouarn: we still need to define JD_ref and JH_ref
347! and since we don't know how many days there are in a year
348! we set JD_ref to 0 (this should be improved ...)
349      jD_ref=0
350      jH_ref=0
351#endif
352
353c  nombre d'etats dans les fichiers demarrage et histoire
354      nbetatdem = nday / iecri
355      nbetatmoy = nday / periodav + 1
356
357c-----------------------------------------------------------------------
358c   Initialisation des constantes dynamiques :
359c   ------------------------------------------
360      dtvr = zdtvr
361      CALL iniconst
362
363c-----------------------------------------------------------------------
364c   Initialisation de la geometrie :
365c   --------------------------------
366      CALL inigeom
367
368c-----------------------------------------------------------------------
369c   Initialisation du filtre :
370c   --------------------------
371      CALL inifilr
372c
373c-----------------------------------------------------------------------
374c   Initialisation de la dissipation :
375c   ----------------------------------
376
377      CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   ,
378     *                tetagdiv, tetagrot , tetatemp              )
379
380c-----------------------------------------------------------------------
381c   Initialisation de la physique :
382c   -------------------------------
383
384      IF (call_iniphys.and.(iflag_phys.eq.1)) THEN
385         latfi(1)=rlatu(1)
386         lonfi(1)=0.
387         zcufi(1) = cu(1)
388         zcvfi(1) = cv(1)
389         DO j=2,jjm
390            DO i=1,iim
391               latfi((j-2)*iim+1+i)= rlatu(j)
392               lonfi((j-2)*iim+1+i)= rlonv(i)
393               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
394               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
395            ENDDO
396         ENDDO
397         latfi(ngridmx)= rlatu(jjp1)
398         lonfi(ngridmx)= 0.
399         zcufi(ngridmx) = cu(ip1jm+1)
400         zcvfi(ngridmx) = cv(ip1jm-iim)
401         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
402         WRITE(lunout,*)
403     .       'GCM: WARNING!!! vitesse verticale nulle dans la physique'
404! Earth:
405         if (planet_type.eq."earth") then
406#ifdef CPP_EARTH
407         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys ,
408     ,                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp     )
409#endif
410         endif ! of if (planet_type.eq."earth")
411         call_iniphys=.false.
412      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
413!#endif
414
415c  numero de stockage pour les fichiers de redemarrage:
416
417c-----------------------------------------------------------------------
418c   Initialisation des I/O :
419c   ------------------------
420
421
422      day_end = day_ini + nday
423      WRITE(lunout,300)day_ini,day_end
424 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
425
426#ifdef CPP_IOIPSL
427      call ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
428      write (lunout,301)jour, mois, an
429      call ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
430      write (lunout,302)jour, mois, an
431 301  FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
432 302  FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
433#endif
434
435      if (planet_type.eq."earth") then
436        CALL dynredem0("restart.nc", day_end, phis)
437      endif
438
439      ecripar = .TRUE.
440
441#ifdef CPP_IOIPSL
442      if ( 1.eq.1) then
443      time_step = zdtvr
444      t_ops = iecri * daysec
445      t_wrt = iecri * daysec
446!      CALL inithist(dynhist_file,day_ref,annee_ref,time_step,
447!    .              t_ops, t_wrt, histid, histvid)
448
449!     IF (ok_dynzon) THEN
450!        t_ops = iperiod * time_step
451!        t_wrt = periodav * daysec
452!        CALL initdynav(dynhistave_file,day_ref,annee_ref,time_step,
453!    .        t_ops, t_wrt, histaveid)
454!     END IF
455      dtav = iperiod*dtvr/daysec
456      endif
457
458
459#endif
460! #endif of #ifdef CPP_IOIPSL
461
462c  Choix des frequences de stokage pour le offline
463c      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
464c      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
465      istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
466      istphy=istdyn/iphysiq     
467
468
469c
470c-----------------------------------------------------------------------
471c   Integration temporelle du modele :
472c   ----------------------------------
473
474c       write(78,*) 'ucov',ucov
475c       write(78,*) 'vcov',vcov
476c       write(78,*) 'teta',teta
477c       write(78,*) 'ps',ps
478c       write(78,*) 'q',q
479
480
481      CALL leapfrog(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
482     .              time_0)
483
484      END
485
Note: See TracBrowser for help on using the repository browser.