source: trunk/LMDZ.COMMON/libf/dyn3d/gcm.F @ 1021

Last change on this file since 1021 was 1019, checked in by emillour, 13 years ago

Common dynamics; keep up with updates (seq and ) in LMDZ5 (up tio rev 1845):

  • General stuff:
  • makelmdz_fcm: add options -j # (compile using # threads) and -full, and to keep up

with Earth model, possibility to compile with various versions of orchidee

  • bld.cfg: adaptations to enable compiling using multiple threads
  • build_gcm: adaptations to enable compiling using multiple threads
  • makelmdz: keep up with Earth model: possibility to compile with various versions of orchidee + cosmetic changes + library directory name change
  • bibio:
  • wxios.F90 : Added for possible future use of XIOS library
  • filtrez:
  • mkl_dft_type.f90 & mkl_dfti.f90 : MKL (for MKL FFT) interface definitions
  • filtreg_mod : limit use of FFT to parallel mode
  • mod_filtre_fft.F90 & mod_filtre_fft_lov.F90 : swich to use parallel_lmdz
  • dyn3d:
  • abort_gcm.F : add things for xios
  • advtrac.F90 : minor change in CFL outputs
  • ce0l.F90 : indicesol.h is now module indice_sol_mod
  • comvert.h : cosmetic change on comments
  • gcm.F : add xios and use module indice_sol_mod (for INCA)
  • inigeom.F : move two computations outside loop
  • dyn3dpar:
  • parallel.F90 => parallel_lmdz.F90 : and change all the "use parallel" into "use parallel_lmdz" in all files in dyn3dpar
  • comvert.h : cosmetic change on comments
  • gcm.F : add xios and use module indice_sol_mod (for INCA)
  • leapfrog_p.F : add xios + correction for times in Newtonian case
  • ce0l.F90 : indicesol.h is now module indice_sol_mod
  • inigeom.F : move two computations outside loop

EM

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