source: trunk/libf/dyn3dpar/gcm.F @ 52

Last change on this file since 52 was 52, checked in by aslmd, 14 years ago

chantier principal du commit
--- version LMDZ5 qui fonctionne pour tests geantes
--- prochaine etape, tests sur GNOME

M libf/dyn3dpar/comconst.h
M libf/dyn3dpar/conf_planete.F90
ajout du flux de chaleur intrinseque: ihf
[par defaut il est nul]

M libf/dyn3dpar/gcm.F
changements cosmetiques
[pour diff plus efficace avec version non par]

M libf/dyn3dpar/iniacademic.F
possibilites de variations latitudinales
de temperature plus originales
[seulement pour planet_type.eq."giant"]

M libf/dyn3dpar/leapfrog_p.F

  1. ajout d'une tendance causee par le flux de chaleur intrinseque

(seulement prise en compte si planet_type.eq."giant")

  1. correction bugs problematiques a la compilation et au run

--> probleme dans les boucles (l'indice etait llm et non l)
--> ajout de SAVE pour les variables paralleles
--> correction des declarations de variables manquantes

M libf/dyn3dpar/calfis_p.F
correction d'une deuxieme parenthese manquante sur ALLOCATE(zteta(klon,llm))

M libf/phylmd/regr_lat_time_climoz_m.F90
erreur a la compilation avec FCM... il s'agit d'une routine terrestre
il y a visiblement un probleme avec o3_in
en attendant, les lignes sont commentees avec !AS

A deftanks/giant 8 fichiers
ajout de fichiers de configuration typiques pour les geantes gazeuses
[experimental pour le moment... on est loin de jupiter]

--> comparaisons entre un run ancien [avec LMDZ5-dev sur SVN ipsl sans cp var]
et run avec version sur ce SVN planeto donne des resultats similaires

pratique

A ioipsl
A ioipsl/compile_ioipsl.bash
A ioipsl/util 16 fichiers
script et utilitaire pour compiler IOIPSL de facon independante
il suffit d'executer ./compile_ioipsl.bash

M arch/arch-AMD64_CICLAD.path
si IOIPSL a ete compile avec la methode precedente, les bons
PATH sont definis dans ce fichier [le NETCDF est aussi OK]

M 000-README-svn
mise a jour options "svn status"

M mars/libf/phymars/meso_callkeys.h
mise a jour mineure du fichier
[ecri_phys etait defini mais pas dans la liste]

File size: 17.3 KB
Line 
1!
2! $Id: gcm.F 1446 2010-10-22 09:27:25Z emillour $
3!
4c
5c
6      PROGRAM gcm
7
8#ifdef CPP_IOIPSL
9      USE IOIPSL
10#endif
11
12      USE mod_const_mpi, ONLY: init_const_mpi
13      USE parallel
14      USE infotrac
15      USE mod_interface_dyn_phys
16      USE mod_hallo
17      USE Bands
18      USE getparam
19      USE filtreg_mod
20      USE control_mod
21
22! Ehouarn: for now these only apply to Earth:
23#ifdef CPP_EARTH
24      USE mod_grid_phy_lmdz
25      USE mod_phys_lmdz_para, ONLY : klon_mpi_para_nb
26      USE mod_phys_lmdz_omp_data, ONLY: klon_omp
27      USE dimphy
28      USE comgeomphy
29#endif
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
89c      INTEGER nbetatmoy, nbetatdem,nbetat
90      INTEGER nbetatmoy, nbetatdem
91
92c   variables dynamiques
93      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
94      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
95      REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes
96      REAL ps(ip1jmp1)                       ! pression  au sol
97c      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
98c      REAL pks(ip1jmp1)                      ! exner au  sol
99c      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
100c      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
101      REAL masse(ip1jmp1,llm)                ! masse d'air
102      REAL phis(ip1jmp1)                     ! geopotentiel au sol
103c      REAL phi(ip1jmp1,llm)                  ! geopotentiel
104c      REAL w(ip1jmp1,llm)                    ! vitesse verticale
105
106c variables dynamiques intermediaire pour le transport
107
108c   variables pour le fichier histoire
109      REAL dtav      ! intervalle de temps elementaire
110
111      REAL time_0
112
113      LOGICAL lafin
114c      INTEGER ij,iq,l,i,j
115      INTEGER i,j
116
117
118      real time_step, t_wrt, t_ops
119
120
121      LOGICAL call_iniphys
122      data call_iniphys/.true./
123
124c      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
125c+jld variables test conservation energie
126c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
127C     Tendance de la temp. potentiel d (theta)/ d t due a la
128C     tansformation d'energie cinetique en energie thermique
129C     cree par la dissipation
130c      REAL dhecdt(ip1jmp1,llm)
131c      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
132c      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
133c      CHARACTER (len=15) :: ztit
134c-jld
135
136
137      character (len=80) :: dynhist_file, dynhistave_file
138      character (len=20) :: modname
139      character (len=80) :: abort_message
140! locales pour gestion du temps
141      INTEGER :: an, mois, jour
142      REAL :: heure
143
144
145c-----------------------------------------------------------------------
146c    variables pour l'initialisation de la physique :
147c    ------------------------------------------------
148      INTEGER ngridmx
149      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
150      REAL zcufi(ngridmx),zcvfi(ngridmx)
151      REAL latfi(ngridmx),lonfi(ngridmx)
152      REAL airefi(ngridmx)
153      SAVE latfi, lonfi, airefi
154     
155      INTEGER :: ierr
156
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'
167      dynhistave_file = 'dyn_hist_ave'
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
181c
182c
183c------------------------------------
184c   Initialisation partie parallele
185c------------------------------------
186      CALL init_const_mpi
187
188      call init_parallel
189      call ini_getparam("out.def")
190      call Read_Distrib
191! Ehouarn : temporarily (?) keep this only for Earth
192!      if (planet_type.eq."earth") then
193!#ifdef CPP_EARTH
194#ifdef CPP_PHYS
195        CALL Init_Phys_lmdz(iim,jjp1,llm,mpi_size,distrib_phys)
196#endif
197!      endif ! of if (planet_type.eq."earth")
198      CALL set_bands
199#ifdef CPP_PHYS
200! Ehouarn: NB: For now only Earth physics is parallel
201      CALL Init_interface_dyn_phys
202#endif
203      CALL barrier
204
205      if (mpi_rank==0) call WriteBands
206      call SetDistrib(jj_Nb_Caldyn)
207
208c$OMP PARALLEL
209      call Init_Mod_hallo
210c$OMP END PARALLEL
211
212! Ehouarn : temporarily (?) keep this only for Earth
213!      if (planet_type.eq."earth") then
214!#ifdef CPP_EARTH
215#ifdef CPP_PHYS
216c$OMP PARALLEL
217      call InitComgeomphy
218c$OMP END PARALLEL
219#endif
220!      endif ! of if (planet_type.eq."earth")
221!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
222c
223c Initialisations pour Cp(T) Venus
224      call ini_cpdet
225c
226c-----------------------------------------------------------------------
227c   Choix du calendrier
228c   -------------------
229
230c      calend = 'earth_365d'
231
232#ifdef CPP_IOIPSL
233      if (calend == 'earth_360d') then
234        call ioconf_calendar('360d')
235        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
236      else if (calend == 'earth_365d') then
237        call ioconf_calendar('noleap')
238        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
239      else if (calend == 'earth_366d') then
240        call ioconf_calendar('gregorian')
241        write(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
242      else
243        abort_message = 'Mauvais choix de calendrier'
244        call abort_gcm(modname,abort_message,1)
245      endif
246#endif
247c-----------------------------------------------------------------------
248
249      IF (config_inca /= 'none') THEN
250#ifdef INCA
251         call init_const_lmdz(
252     $        nbtr,anneeref,dayref,
253     $        iphysiq,day_step,nday,
254     $        nbsrf, is_oce,is_sic,
255     $        is_ter,is_lic)
256
257         call init_inca_para(
258     $        iim,jjm+1,llm,klon_glo,mpi_size,
259     $        distrib_phys,COMM_LMDZ)
260#endif
261      END IF
262
263c-----------------------------------------------------------------------
264c   Initialisation des traceurs
265c   ---------------------------
266c  Choix du nombre de traceurs et du schema pour l'advection
267c  dans fichier traceur.def, par default ou via INCA
268      call infotrac_init
269
270c Allocation de la tableau q : champs advectes   
271      ALLOCATE(q(ip1jmp1,llm,nqtot))
272
273c-----------------------------------------------------------------------
274c   Lecture de l'etat initial :
275c   ---------------------------
276
277c  lecture du fichier start.nc
278      if (read_start) then
279      ! we still need to run iniacademic to initialize some
280      ! constants & fields, if we run the 'newtonian' or 'SW' cases:
281        if (iflag_phys.ne.1) then
282          CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
283        endif
284
285        if (planet_type.eq."mars") then
286! POUR MARS, METTRE UNE FONCTION A PART, genre dynetat0_mars
287         abort_message = 'dynetat0_mars A FAIRE'
288         call abort_gcm(modname,abort_message,0)
289        else
290         CALL dynetat0("start.nc",vcov,ucov,
291     &              teta,q,masse,ps,phis, time_0)
292        endif ! of if (planet_type.eq."mars")
293       
294c       write(73,*) 'ucov',ucov
295c       write(74,*) 'vcov',vcov
296c       write(75,*) 'teta',teta
297c       write(76,*) 'ps',ps
298c       write(77,*) 'q',q
299
300      endif ! of if (read_start)
301
302c le cas echeant, creation d un etat initial
303      IF (prt_level > 9) WRITE(lunout,*)
304     .              'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
305      if (.not.read_start) then
306         CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
307      endif
308
309
310c-----------------------------------------------------------------------
311c   Lecture des parametres de controle pour la simulation :
312c   -------------------------------------------------------
313c  on recalcule eventuellement le pas de temps
314
315      IF(MOD(day_step,iperiod).NE.0) THEN
316        abort_message =
317     .  'Il faut choisir un nb de pas par jour multiple de iperiod'
318        call abort_gcm(modname,abort_message,1)
319      ENDIF
320
321      IF(MOD(day_step,iphysiq).NE.0) THEN
322        abort_message =
323     * 'Il faut choisir un nb de pas par jour multiple de iphysiq'
324        call abort_gcm(modname,abort_message,1)
325      ENDIF
326
327      zdtvr    = daysec/REAL(day_step)
328        IF(dtvr.NE.zdtvr) THEN
329         WRITE(lunout,*)
330     .    'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
331        ENDIF
332
333C
334C on remet le calendrier à zero si demande
335c
336      IF (raz_date == 1) THEN
337        annee_ref = anneeref
338        day_ref = dayref
339        day_ini = dayref
340        itau_dyn = 0
341        itau_phy = 0
342        time_0 = 0.
343        write(lunout,*)
344     .   'GCM: On reinitialise a la date lue dans gcm.def'
345      ELSE IF (annee_ref .ne. anneeref .or. day_ref .ne. dayref) THEN
346        write(lunout,*)
347     .  'GCM: Attention les dates initiales lues dans le fichier'
348        write(lunout,*)
349     .  ' restart ne correspondent pas a celles lues dans '
350        write(lunout,*)' gcm.def'
351        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
352        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
353        write(lunout,*)' Pas de remise a zero'
354      ENDIF
355
356c      if (annee_ref .ne. anneeref .or. day_ref .ne. dayref) then
357c        write(lunout,*)
358c     .  'GCM: Attention les dates initiales lues dans le fichier'
359c        write(lunout,*)
360c     .  ' restart ne correspondent pas a celles lues dans '
361c        write(lunout,*)' gcm.def'
362c        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
363c        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
364c        if (raz_date .ne. 1) then
365c          write(lunout,*)
366c     .    'GCM: On garde les dates du fichier restart'
367c        else
368c          annee_ref = anneeref
369c          day_ref = dayref
370c          day_ini = dayref
371c          itau_dyn = 0
372c          itau_phy = 0
373c          time_0 = 0.
374c          write(lunout,*)
375c     .   'GCM: On reinitialise a la date lue dans gcm.def'
376c        endif
377c      ELSE
378c        raz_date = 0
379c      endif
380
381#ifdef CPP_IOIPSL
382      mois = 1
383      heure = 0.
384      call ymds2ju(annee_ref, mois, day_ref, heure, jD_ref)
385      jH_ref = jD_ref - int(jD_ref)
386      jD_ref = int(jD_ref)
387
388      call ioconf_startdate(INT(jD_ref), jH_ref)
389
390      write(lunout,*)'DEBUG'
391      write(lunout,*)'annee_ref, mois, day_ref, heure, jD_ref'
392      write(lunout,*)annee_ref, mois, day_ref, heure, jD_ref
393      call ju2ymds(jD_ref+jH_ref,an, mois, jour, heure)
394      write(lunout,*)'jD_ref+jH_ref,an, mois, jour, heure'
395      write(lunout,*)jD_ref+jH_ref,an, mois, jour, heure
396#else
397! Ehouarn: we still need to define JD_ref and JH_ref
398! and since we don't know how many days there are in a year
399! we set JD_ref to 0 (this should be improved ...)
400      jD_ref=0
401      jH_ref=0
402#endif
403
404c  nombre d'etats dans les fichiers demarrage et histoire
405      nbetatdem = nday / iecri
406      nbetatmoy = nday / periodav + 1
407
408      if (iflag_phys.eq.1) then
409      ! these initialisations have already been done (via iniacademic)
410      ! if running in SW or Newtonian mode
411c-----------------------------------------------------------------------
412c   Initialisation des constantes dynamiques :
413c   ------------------------------------------
414        dtvr = zdtvr
415        CALL iniconst
416
417c-----------------------------------------------------------------------
418c   Initialisation de la geometrie :
419c   --------------------------------
420        CALL inigeom
421
422c-----------------------------------------------------------------------
423c   Initialisation du filtre :
424c   --------------------------
425        CALL inifilr
426      endif ! of if (iflag_phys.eq.1)
427c
428c-----------------------------------------------------------------------
429c   Initialisation de la dissipation :
430c   ----------------------------------
431
432      CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   ,
433     *                tetagdiv, tetagrot , tetatemp              )
434
435c-----------------------------------------------------------------------
436c   Initialisation de la physique :
437c   -------------------------------
438
439      IF (call_iniphys.and.(iflag_phys.eq.1)) THEN
440         latfi(1)=rlatu(1)
441         lonfi(1)=0.
442         zcufi(1) = cu(1)
443         zcvfi(1) = cv(1)
444         DO j=2,jjm
445            DO i=1,iim
446               latfi((j-2)*iim+1+i)= rlatu(j)
447               lonfi((j-2)*iim+1+i)= rlonv(i)
448               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
449               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
450            ENDDO
451         ENDDO
452         latfi(ngridmx)= rlatu(jjp1)
453         lonfi(ngridmx)= 0.
454         zcufi(ngridmx) = cu(ip1jm+1)
455         zcvfi(ngridmx) = cv(ip1jm-iim)
456         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
457         WRITE(lunout,*)
458     .       'GCM: WARNING!!! vitesse verticale nulle dans la physique'
459
460! Initialisation de la physique: pose probleme quand on tourne
461! SANS physique, car iniphysiq.F est dans le repertoire phy[]...
462! Il faut une cle CPP_PHYS
463#ifdef CPP_PHYS
464         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys ,
465     ,                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp     )
466#endif ! CPP_PHYS
467         call_iniphys=.false.
468      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
469!#endif
470
471c-----------------------------------------------------------------------
472c   Initialisation des dimensions d'INCA :
473c   --------------------------------------
474      IF (config_inca /= 'none') THEN
475!$OMP PARALLEL
476#ifdef INCA
477         CALL init_inca_dim(klon_omp,llm,iim,jjm,
478     $        rlonu,rlatu,rlonv,rlatv)
479#endif
480!$OMP END PARALLEL
481      END IF
482
483c-----------------------------------------------------------------------
484c   Initialisation des I/O :
485c   ------------------------
486
487
488      day_end = day_ini + nday
489      WRITE(lunout,300)day_ini,day_end
490 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
491
492#ifdef CPP_IOIPSL
493      call ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
494      write (lunout,301)jour, mois, an
495      call ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
496      write (lunout,302)jour, mois, an
497 301  FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
498 302  FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
499#endif
500
501      if (planet_type.eq."mars") then
502! POUR MARS, METTRE UNE FONCTION A PART, genre dynredem0_mars
503         abort_message = 'dynredem0_mars A FAIRE'
504         call abort_gcm(modname,abort_message,0)
505      else
506        CALL dynredem0_p("restart.nc", day_end, phis)
507      endif ! of if (planet_type.eq."mars")
508
509      ecripar = .TRUE.
510
511#ifdef CPP_IOIPSL
512      time_step = zdtvr
513      IF (mpi_rank==0) then
514        if (ok_dyn_ins) then
515        ! initialize output file for instantaneous outputs
516        ! t_ops = iecri * daysec ! do operations every t_ops
517        t_ops =((1.0*iecri)/day_step) * daysec 
518        t_wrt = daysec ! iecri * daysec ! write output every t_wrt
519        CALL inithist(day_ref,annee_ref,time_step,
520     &                  t_ops,t_wrt)
521        endif
522
523        IF (ok_dyn_ave) THEN
524          ! initialize output file for averaged outputs
525          t_ops = iperiod * time_step ! do operations every t_ops
526          t_wrt = periodav * daysec   ! write output every t_wrt
527          CALL initdynav(day_ref,annee_ref,time_step,
528     &                   t_ops,t_wrt)
529!         CALL initdynav_p(dynhistave_file,day_ref,annee_ref,time_step,
530!     .        t_ops, t_wrt, histaveid)
531        END IF
532      ENDIF
533      dtav = iperiod*dtvr/daysec
534#endif
535! #endif of #ifdef CPP_IOIPSL
536
537c  Choix des frequences de stokage pour le offline
538c      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
539c      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
540      istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
541      istphy=istdyn/iphysiq     
542
543
544c
545c-----------------------------------------------------------------------
546c   Integration temporelle du modele :
547c   ----------------------------------
548
549c       write(78,*) 'ucov',ucov
550c       write(78,*) 'vcov',vcov
551c       write(78,*) 'teta',teta
552c       write(78,*) 'ps',ps
553c       write(78,*) 'q',q
554
555c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logic/)
556      CALL leapfrog_p(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
557     .              time_0)
558c$OMP END PARALLEL
559
560
561      END
562
Note: See TracBrowser for help on using the repository browser.