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

Last change on this file since 1785 was 1785, checked in by Ehouarn Millour, 11 years ago

Transformation de l'include indicesol.h en un module indice_sol_mod et modification des appels dans tous les fichiers concernés.
Aucun changement des résultats ni des sorties du modèle vs 1784.
UG

...................................................

Replacement of the indicesol.h include by a module named indice_sol_mod. Modification of the calls in every affected files.
Results and outputs of simulations are unchanged in comparison with rev 1784.
UG

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