source: LMDZ5/trunk/libf/dyn3d/gcm.F @ 1720

Last change on this file since 1720 was 1697, checked in by lguez, 12 years ago

Created new variable vert_prof_dissip to choose the vertical profile
of horizontal dissipation. vert_prof_dissip is an integer, allowed
values are 0 and 1. Did not make it a logical variable because we
expect to have the choice between more than 2 profiles later, when we
converge with extra-terrestrial versions of LMDZ. Replaced test on
ok_strato and llm in inidissip by test on vert_prof_dissip.

Merged some lines of dyn3d/conf_gcm.F and dyn3dpar/conf_gcm.F (we want
as little difference as possible between dyn3d and dyn3dpar).

Checked that the sequential configuration does not change results for
the bench of "install.sh".

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.1 KB
Line 
1!
2! $Id: gcm.F 1697 2012-12-19 16:57:23Z emillour $
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      USE control_mod
18
19!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
21! A nettoyer. On ne veut qu'une ou deux routines d'interface
22! dynamique -> physique pour l'initialisation
23#ifdef CPP_PHYS
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#ifdef INCA
78! Only INCA needs these informations (from the Earth's physics)
79#include "indicesol.h"
80#endif
81      INTEGER         longcles
82      PARAMETER     ( longcles = 20 )
83      REAL  clesphy0( longcles )
84      SAVE  clesphy0
85
86
87
88      REAL zdtvr
89
90c   variables dynamiques
91      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
92      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
93      REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes
94      REAL ps(ip1jmp1)                       ! pression  au sol
95      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
96      REAL pks(ip1jmp1)                      ! exner au  sol
97      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
98      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
99      REAL masse(ip1jmp1,llm)                ! masse d'air
100      REAL phis(ip1jmp1)                     ! geopotentiel au sol
101      REAL phi(ip1jmp1,llm)                  ! geopotentiel
102      REAL w(ip1jmp1,llm)                    ! vitesse verticale
103
104c variables dynamiques intermediaire pour le transport
105
106c   variables pour le fichier histoire
107      REAL dtav      ! intervalle de temps elementaire
108
109      REAL time_0
110
111      LOGICAL lafin
112      INTEGER ij,iq,l,i,j
113
114
115      real time_step, t_wrt, t_ops
116
117      LOGICAL first
118
119      LOGICAL call_iniphys
120      data call_iniphys/.true./
121
122      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
123c+jld variables test conservation energie
124c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
125C     Tendance de la temp. potentiel d (theta)/ d t due a la
126C     tansformation d'energie cinetique en energie thermique
127C     cree par la dissipation
128      REAL dhecdt(ip1jmp1,llm)
129c      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
130c      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
131      CHARACTER (len=15) :: ztit
132c-jld
133
134
135      character (len=80) :: dynhist_file, dynhistave_file
136      character (len=20) :: modname
137      character (len=80) :: abort_message
138! locales pour gestion du temps
139      INTEGER :: an, mois, jour
140      REAL :: heure
141
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
153c-----------------------------------------------------------------------
154c   Initialisations:
155c   ----------------
156
157      abort_message = 'last timestep reached'
158      modname = 'gcm'
159      descript = 'Run GCM LMDZ'
160      lafin    = .FALSE.
161      dynhist_file = 'dyn_hist.nc'
162      dynhistave_file = 'dyn_hist_ave.nc'
163
164
165
166c----------------------------------------------------------------------
167c  lecture des fichiers gcm.def ou run.def
168c  ---------------------------------------
169c
170! Ehouarn: dump possibility of using defrun
171!#ifdef CPP_IOIPSL
172      CALL conf_gcm( 99, .TRUE. , clesphy0 )
173!#else
174!      CALL defrun( 99, .TRUE. , clesphy0 )
175!#endif
176
177!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
178! FH 2008/05/02
179! A nettoyer. On ne veut qu'une ou deux routines d'interface
180! dynamique -> physique pour l'initialisation
181#ifdef CPP_PHYS
182      CALL Init_Phys_lmdz(iim,jjp1,llm,1,(/(jjm-1)*iim+2/))
183      call InitComgeomphy
184#endif
185!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
186c-----------------------------------------------------------------------
187c   Choix du calendrier
188c   -------------------
189
190c      calend = 'earth_365d'
191
192#ifdef CPP_IOIPSL
193      if (calend == 'earth_360d') then
194        call ioconf_calendar('360d')
195        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
196      else if (calend == 'earth_365d') then
197        call ioconf_calendar('noleap')
198        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
199      else if (calend == 'earth_366d') then
200        call ioconf_calendar('gregorian')
201        write(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
202      else
203        abort_message = 'Mauvais choix de calendrier'
204        call abort_gcm(modname,abort_message,1)
205      endif
206#endif
207c-----------------------------------------------------------------------
208
209      IF (type_trac == 'inca') THEN
210#ifdef INCA
211      call init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday,
212     $        nbsrf, is_oce,is_sic,is_ter,is_lic)
213      call init_inca_para(iim,jjm+1,klon,1,klon_mpi_para_nb,0)
214#endif
215      END IF
216c
217c
218c------------------------------------
219c   Initialisation partie parallele
220c------------------------------------
221
222c
223c
224c-----------------------------------------------------------------------
225c   Initialisation des traceurs
226c   ---------------------------
227c  Choix du nombre de traceurs et du schema pour l'advection
228c  dans fichier traceur.def, par default ou via INCA
229      call infotrac_init
230
231c Allocation de la tableau q : champs advectes   
232      allocate(q(ip1jmp1,llm,nqtot))
233
234c-----------------------------------------------------------------------
235c   Lecture de l'etat initial :
236c   ---------------------------
237
238c  lecture du fichier start.nc
239      if (read_start) then
240      ! we still need to run iniacademic to initialize some
241      ! constants & fields, if we run the 'newtonian' or 'SW' cases:
242        if (iflag_phys.ne.1) then
243          CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
244        endif
245
246!        if (planet_type.eq."earth") then
247! Load an Earth-format start file
248         CALL dynetat0("start.nc",vcov,ucov,
249     &              teta,q,masse,ps,phis, time_0)
250!        endif ! of if (planet_type.eq."earth")
251       
252c       write(73,*) 'ucov',ucov
253c       write(74,*) 'vcov',vcov
254c       write(75,*) 'teta',teta
255c       write(76,*) 'ps',ps
256c       write(77,*) 'q',q
257
258      endif ! of if (read_start)
259
260      IF (type_trac == 'inca') THEN
261#ifdef INCA
262         call init_inca_dim(klon,llm,iim,jjm,
263     $        rlonu,rlatu,rlonv,rlatv)
264#endif
265      END IF
266
267
268c le cas echeant, creation d un etat initial
269      IF (prt_level > 9) WRITE(lunout,*)
270     .              'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
271      if (.not.read_start) then
272         CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
273      endif
274
275
276c-----------------------------------------------------------------------
277c   Lecture des parametres de controle pour la simulation :
278c   -------------------------------------------------------
279c  on recalcule eventuellement le pas de temps
280
281      IF(MOD(day_step,iperiod).NE.0) THEN
282        abort_message =
283     .  'Il faut choisir un nb de pas par jour multiple de iperiod'
284        call abort_gcm(modname,abort_message,1)
285      ENDIF
286
287      IF(MOD(day_step,iphysiq).NE.0) THEN
288        abort_message =
289     * 'Il faut choisir un nb de pas par jour multiple de iphysiq'
290        call abort_gcm(modname,abort_message,1)
291      ENDIF
292
293      zdtvr    = daysec/REAL(day_step)
294        IF(dtvr.NE.zdtvr) THEN
295         WRITE(lunout,*)
296     .    'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
297        ENDIF
298
299C
300C on remet le calendrier à zero si demande
301c
302      IF (start_time /= starttime) then
303        WRITE(lunout,*)' GCM: Attention l''heure de depart lue dans le'
304     &,' fichier restart ne correspond pas à celle lue dans le run.def'
305        IF (raz_date == 1) then
306          WRITE(lunout,*)'Je prends l''heure lue dans run.def'
307          start_time = starttime
308        ELSE
309          WRITE(lunout,*)'Je m''arrete'
310          CALL abort
311        ENDIF
312      ENDIF
313      IF (raz_date == 1) THEN
314        annee_ref = anneeref
315        day_ref = dayref
316        day_ini = dayref
317        itau_dyn = 0
318        itau_phy = 0
319        time_0 = 0.
320        write(lunout,*)
321     .   'GCM: On reinitialise a la date lue dans gcm.def'
322      ELSE IF (annee_ref .ne. anneeref .or. day_ref .ne. dayref) THEN
323        write(lunout,*)
324     .  'GCM: Attention les dates initiales lues dans le fichier'
325        write(lunout,*)
326     .  ' restart ne correspondent pas a celles lues dans '
327        write(lunout,*)' gcm.def'
328        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
329        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
330        write(lunout,*)' Pas de remise a zero'
331      ENDIF
332
333c      if (annee_ref .ne. anneeref .or. day_ref .ne. dayref) then
334c        write(lunout,*)
335c     .  'GCM: Attention les dates initiales lues dans le fichier'
336c        write(lunout,*)
337c     .  ' restart ne correspondent pas a celles lues dans '
338c        write(lunout,*)' gcm.def'
339c        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
340c        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
341c        if (raz_date .ne. 1) then
342c          write(lunout,*)
343c     .    'GCM: On garde les dates du fichier restart'
344c        else
345c          annee_ref = anneeref
346c          day_ref = dayref
347c          day_ini = dayref
348c          itau_dyn = 0
349c          itau_phy = 0
350c          time_0 = 0.
351c          write(lunout,*)
352c     .   'GCM: On reinitialise a la date lue dans gcm.def'
353c        endif
354c      ELSE
355c        raz_date = 0
356c      endif
357
358#ifdef CPP_IOIPSL
359      mois = 1
360      heure = 0.
361      call ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
362      jH_ref = jD_ref - int(jD_ref)
363      jD_ref = int(jD_ref)
364
365      call ioconf_startdate(INT(jD_ref), jH_ref)
366
367      write(lunout,*)'DEBUG'
368      write(lunout,*)'annee_ref, mois, day_ref, heure, jD_ref'
369      write(lunout,*)annee_ref, mois, day_ref, heure, jD_ref
370      call ju2ymds(jD_ref+jH_ref,an, mois, jour, heure)
371      write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
372      write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
373#else
374! Ehouarn: we still need to define JD_ref and JH_ref
375! and since we don't know how many days there are in a year
376! we set JD_ref to 0 (this should be improved ...)
377      jD_ref=0
378      jH_ref=0
379#endif
380
381
382      if (iflag_phys.eq.1) then
383      ! these initialisations have already been done (via iniacademic)
384      ! if running in SW or Newtonian mode
385c-----------------------------------------------------------------------
386c   Initialisation des constantes dynamiques :
387c   ------------------------------------------
388        dtvr = zdtvr
389        CALL iniconst
390
391c-----------------------------------------------------------------------
392c   Initialisation de la geometrie :
393c   --------------------------------
394        CALL inigeom
395
396c-----------------------------------------------------------------------
397c   Initialisation du filtre :
398c   --------------------------
399        CALL inifilr
400      endif ! of if (iflag_phys.eq.1)
401c
402c-----------------------------------------------------------------------
403c   Initialisation de la dissipation :
404c   ----------------------------------
405
406      CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   ,
407     *                tetagdiv, tetagrot , tetatemp, vert_prof_dissip)
408
409c-----------------------------------------------------------------------
410c   Initialisation de la physique :
411c   -------------------------------
412
413      IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN
414         latfi(1)=rlatu(1)
415         lonfi(1)=0.
416         zcufi(1) = cu(1)
417         zcvfi(1) = cv(1)
418         DO j=2,jjm
419            DO i=1,iim
420               latfi((j-2)*iim+1+i)= rlatu(j)
421               lonfi((j-2)*iim+1+i)= rlonv(i)
422               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
423               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
424            ENDDO
425         ENDDO
426         latfi(ngridmx)= rlatu(jjp1)
427         lonfi(ngridmx)= 0.
428         zcufi(ngridmx) = cu(ip1jm+1)
429         zcvfi(ngridmx) = cv(ip1jm-iim)
430         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
431         WRITE(lunout,*)
432     .       'GCM: WARNING!!! vitesse verticale nulle dans la physique'
433! Physics:
434#ifdef CPP_PHYS
435         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys,
436     &                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp,
437     &                iflag_phys)
438#endif
439         call_iniphys=.false.
440      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
441
442c  numero de stockage pour les fichiers de redemarrage:
443
444c-----------------------------------------------------------------------
445c   Initialisation des I/O :
446c   ------------------------
447
448
449      day_end = day_ini + nday
450      WRITE(lunout,300)day_ini,day_end
451 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
452
453#ifdef CPP_IOIPSL
454      call ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
455      write (lunout,301)jour, mois, an
456      call ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
457      write (lunout,302)jour, mois, an
458 301  FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
459 302  FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
460#endif
461
462!      if (planet_type.eq."earth") then
463! Write an Earth-format restart file
464
465        CALL dynredem0("restart.nc", day_end, phis)
466!      endif
467
468      ecripar = .TRUE.
469
470#ifdef CPP_IOIPSL
471      time_step = zdtvr
472      if (ok_dyn_ins) then
473        ! initialize output file for instantaneous outputs
474        ! t_ops = iecri * daysec ! do operations every t_ops
475        t_ops =((1.0*iecri)/day_step) * daysec 
476        t_wrt = daysec ! iecri * daysec ! write output every t_wrt
477        CALL inithist(day_ref,annee_ref,time_step,
478     &              t_ops,t_wrt)
479      endif
480
481      IF (ok_dyn_ave) THEN
482        ! initialize output file for averaged outputs
483        t_ops = iperiod * time_step ! do operations every t_ops
484        t_wrt = periodav * daysec   ! write output every t_wrt
485        CALL initdynav(day_ref,annee_ref,time_step,
486     &       t_ops,t_wrt)
487      END IF
488      dtav = iperiod*dtvr/daysec
489#endif
490! #endif of #ifdef CPP_IOIPSL
491
492c  Choix des frequences de stokage pour le offline
493c      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
494c      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
495      istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
496      istphy=istdyn/iphysiq     
497
498
499c
500c-----------------------------------------------------------------------
501c   Integration temporelle du modele :
502c   ----------------------------------
503
504c       write(78,*) 'ucov',ucov
505c       write(78,*) 'vcov',vcov
506c       write(78,*) 'teta',teta
507c       write(78,*) 'ps',ps
508c       write(78,*) 'q',q
509
510
511      CALL leapfrog(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
512     .              time_0)
513
514      END
515
Note: See TracBrowser for help on using the repository browser.