source: LMDZ5/trunk/libf/dyn3dpar/gcm.F @ 1997

Last change on this file since 1997 was 1939, checked in by lguez, 11 years ago

Same as revision 1930: replaced abort by abort_gcm.

Also replaced real*8 by real(kind=8) (was done way back in revision 1220 for
dyn3d/fxhyp.F but not dyn3dpar/fxhyp.F).

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.8 KB
RevLine 
[630]1!
[1279]2! $Id: gcm.F 1939 2014-01-21 14:23:17Z acaubel $
[630]3!
4c
5c
6      PROGRAM gcm
7
8#ifdef CPP_IOIPSL
9      USE IOIPSL
10#endif
[1146]11
[1825]12
[774]13      USE mod_const_mpi, ONLY: init_const_mpi
[1823]14      USE parallel_lmdz
[1146]15      USE infotrac
16      USE mod_interface_dyn_phys
17      USE mod_hallo
18      USE Bands
[1279]19      USE getparam
[1146]20      USE filtreg_mod
[1403]21      USE control_mod
[1146]22
[1785]23#ifdef INCA
24! Only INCA needs these informations (from the Earth's physics)
25      USE indice_sol_mod
26#endif
27
[1615]28#ifdef CPP_PHYS
[791]29      USE mod_grid_phy_lmdz
[1279]30      USE mod_phys_lmdz_para, ONLY : klon_mpi_para_nb
[1146]31      USE mod_phys_lmdz_omp_data, ONLY: klon_omp
[630]32      USE dimphy
33      USE comgeomphy
[1146]34#endif
[630]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#include "dimensions.h"
67#include "paramet.h"
68#include "comconst.h"
69#include "comdissnew.h"
70#include "comvert.h"
71#include "comgeom.h"
72#include "logic.h"
73#include "temps.h"
74#include "ener.h"
75#include "description.h"
76#include "serre.h"
[1403]77!#include "com_io_dyn.h"
[630]78#include "iniprint.h"
79#include "tracstoke.h"
[1403]80
81#ifdef INCA
82! Only INCA needs these informations (from the Earth's physics)
[1785]83!#include "indicesol.h"
[1403]84#endif
[630]85
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
[1146]98      REAL, ALLOCATABLE, DIMENSION(:,:,:) :: q ! champs advectes
[630]99      REAL ps(ip1jmp1)                       ! pression  au sol
[949]100c      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
101c      REAL pks(ip1jmp1)                      ! exner au  sol
102c      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
103c      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
[630]104      REAL masse(ip1jmp1,llm)                ! masse d'air
105      REAL phis(ip1jmp1)                     ! geopotentiel au sol
[949]106c      REAL phi(ip1jmp1,llm)                  ! geopotentiel
107c      REAL w(ip1jmp1,llm)                    ! vitesse verticale
[630]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
[949]117c      INTEGER ij,iq,l,i,j
118      INTEGER i,j
[630]119
120
121      real time_step, t_wrt, t_ops
122
123
124      LOGICAL call_iniphys
125      data call_iniphys/.true./
126
[949]127c      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
[630]128c+jld variables test conservation energie
[949]129c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
[630]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
[949]133c      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
136c      CHARACTER (len=15) :: ztit
[630]137c-jld
138
139
[949]140      character (len=80) :: dynhist_file, dynhistave_file
[1279]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
[630]146
147
148c-----------------------------------------------------------------------
149c    variables pour l'initialisation de la physique :
150c    ------------------------------------------------
[1146]151      INTEGER ngridmx
[630]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     
158      INTEGER :: ierr
159
160
161c-----------------------------------------------------------------------
162c   Initialisations:
163c   ----------------
164
165      abort_message = 'last timestep reached'
166      modname = 'gcm'
167      descript = 'Run GCM LMDZ'
168      lafin    = .FALSE.
169      dynhist_file = 'dyn_hist'
170      dynhistave_file = 'dyn_hist_ave'
171
[764]172
[630]173
174c----------------------------------------------------------------------
175c  lecture des fichiers gcm.def ou run.def
176c  ---------------------------------------
177c
[1146]178! Ehouarn: dump possibility of using defrun
179!#ifdef CPP_IOIPSL
[630]180      CALL conf_gcm( 99, .TRUE. , clesphy0 )
[1146]181!#else
182!      CALL defrun( 99, .TRUE. , clesphy0 )
183!#endif
[630]184c
185c
186c------------------------------------
187c   Initialisation partie parallele
188c------------------------------------
[1852]189
[807]190      CALL init_const_mpi
[630]191      call init_parallel
[1279]192      call ini_getparam("out.def")
[774]193      call Read_Distrib
[1615]194
195#ifdef CPP_PHYS
[1146]196        CALL Init_Phys_lmdz(iim,jjp1,llm,mpi_size,distrib_phys)
197#endif
[774]198      CALL set_bands
[1615]199#ifdef CPP_PHYS
[774]200      CALL Init_interface_dyn_phys
[1279]201#endif
[1000]202      CALL barrier
203
[630]204      if (mpi_rank==0) call WriteBands
205      call SetDistrib(jj_Nb_Caldyn)
[985]206
207c$OMP PARALLEL
[807]208      call Init_Mod_hallo
[985]209c$OMP END PARALLEL
[807]210
[1615]211#ifdef CPP_PHYS
[764]212c$OMP PARALLEL
[630]213      call InitComgeomphy
[764]214c$OMP END PARALLEL
[1146]215#endif
[960]216
[1825]217!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
218! Initialisation de XIOS
219!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
220
221
[1279]222c-----------------------------------------------------------------------
223c   Choix du calendrier
224c   -------------------
225
226c      calend = 'earth_365d'
227
228#ifdef CPP_IOIPSL
229      if (calend == 'earth_360d') then
230        call ioconf_calendar('360d')
231        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 360 jours/an'
232      else if (calend == 'earth_365d') then
233        call ioconf_calendar('noleap')
234        write(lunout,*)'CALENDRIER CHOISI: Terrestre a 365 jours/an'
235      else if (calend == 'earth_366d') then
236        call ioconf_calendar('gregorian')
237        write(lunout,*)'CALENDRIER CHOISI: Terrestre bissextile'
238      else
239        abort_message = 'Mauvais choix de calendrier'
240        call abort_gcm(modname,abort_message,1)
241      endif
242#endif
243
[1563]244      IF (type_trac == 'inca') THEN
[630]245#ifdef INCA
[1017]246         call init_const_lmdz(
[1146]247     $        nbtr,anneeref,dayref,
[1315]248     $        iphysiq,day_step,nday,
249     $        nbsrf, is_oce,is_sic,
250     $        is_ter,is_lic)
[1017]251
252         call init_inca_para(
[1077]253     $        iim,jjm+1,llm,klon_glo,mpi_size,
254     $        distrib_phys,COMM_LMDZ)
[630]255#endif
[960]256      END IF
[630]257
258c-----------------------------------------------------------------------
259c   Initialisation des traceurs
260c   ---------------------------
[1146]261c  Choix du nombre de traceurs et du schema pour l'advection
262c  dans fichier traceur.def, par default ou via INCA
263      call infotrac_init
[630]264
[1146]265c Allocation de la tableau q : champs advectes   
266      ALLOCATE(q(ip1jmp1,llm,nqtot))
267
[630]268c-----------------------------------------------------------------------
269c   Lecture de l'etat initial :
270c   ---------------------------
271
272c  lecture du fichier start.nc
273      if (read_start) then
[1146]274      ! we still need to run iniacademic to initialize some
[1403]275      ! constants & fields, if we run the 'newtonian' or 'SW' cases:
276        if (iflag_phys.ne.1) then
[1146]277          CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
278        endif
[1403]279
[1454]280!        if (planet_type.eq."earth") then
[1146]281! Load an Earth-format start file
282         CALL dynetat0("start.nc",vcov,ucov,
[1403]283     &              teta,q,masse,ps,phis, time_0)
[1454]284!        endif ! of if (planet_type.eq."earth")
285
[630]286c       write(73,*) 'ucov',ucov
287c       write(74,*) 'vcov',vcov
288c       write(75,*) 'teta',teta
289c       write(76,*) 'ps',ps
290c       write(77,*) 'q',q
291
[1146]292      endif ! of if (read_start)
[630]293
294c le cas echeant, creation d un etat initial
295      IF (prt_level > 9) WRITE(lunout,*)
[1146]296     .              'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
[630]297      if (.not.read_start) then
[1146]298         CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
[630]299      endif
300
301c-----------------------------------------------------------------------
302c   Lecture des parametres de controle pour la simulation :
303c   -------------------------------------------------------
304c  on recalcule eventuellement le pas de temps
305
306      IF(MOD(day_step,iperiod).NE.0) THEN
307        abort_message =
308     .  'Il faut choisir un nb de pas par jour multiple de iperiod'
309        call abort_gcm(modname,abort_message,1)
310      ENDIF
311
312      IF(MOD(day_step,iphysiq).NE.0) THEN
313        abort_message =
314     * 'Il faut choisir un nb de pas par jour multiple de iphysiq'
315        call abort_gcm(modname,abort_message,1)
316      ENDIF
317
[1403]318      zdtvr    = daysec/REAL(day_step)
[630]319        IF(dtvr.NE.zdtvr) THEN
320         WRITE(lunout,*)
321     .    'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
322        ENDIF
323
324C
325C on remet le calendrier à zero si demande
326c
[1577]327      IF (start_time /= starttime) then
328        WRITE(lunout,*)' GCM: Attention l''heure de depart lue dans le'
329     &,' fichier restart ne correspond pas à celle lue dans le run.def'
330        IF (raz_date == 1) then
331          WRITE(lunout,*)'Je prends l''heure lue dans run.def'
332          start_time = starttime
333        ELSE
[1939]334          call abort_gcm("gcm", "'Je m''arrete'", 1)
[1577]335        ENDIF
336      ENDIF
[1403]337      IF (raz_date == 1) THEN
338        annee_ref = anneeref
339        day_ref = dayref
340        day_ini = dayref
341        itau_dyn = 0
342        itau_phy = 0
343        time_0 = 0.
[630]344        write(lunout,*)
[1403]345     .   'GCM: On reinitialise a la date lue dans gcm.def'
346      ELSE IF (annee_ref .ne. anneeref .or. day_ref .ne. dayref) THEN
347        write(lunout,*)
[1279]348     .  'GCM: Attention les dates initiales lues dans le fichier'
[630]349        write(lunout,*)
350     .  ' restart ne correspondent pas a celles lues dans '
351        write(lunout,*)' gcm.def'
[1403]352        write(lunout,*)' annee_ref=',annee_ref," anneeref=",anneeref
353        write(lunout,*)' day_ref=',day_ref," dayref=",dayref
354        write(lunout,*)' Pas de remise a zero'
355      ENDIF
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
[1279]380
[1147]381#ifdef CPP_IOIPSL
[1279]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
[1147]402#endif
[630]403
404
[1403]405      if (iflag_phys.eq.1) then
406      ! these initialisations have already been done (via iniacademic)
407      ! if running in SW or Newtonian mode
[630]408c-----------------------------------------------------------------------
409c   Initialisation des constantes dynamiques :
410c   ------------------------------------------
[1403]411        dtvr = zdtvr
412        CALL iniconst
[630]413
414c-----------------------------------------------------------------------
415c   Initialisation de la geometrie :
416c   --------------------------------
[1403]417        CALL inigeom
[630]418
419c-----------------------------------------------------------------------
420c   Initialisation du filtre :
421c   --------------------------
[1403]422        CALL inifilr
423      endif ! of if (iflag_phys.eq.1)
[630]424c
425c-----------------------------------------------------------------------
426c   Initialisation de la dissipation :
427c   ----------------------------------
428
429      CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   ,
[1697]430     *                tetagdiv, tetagrot , tetatemp, vert_prof_dissip)
[630]431
432c-----------------------------------------------------------------------
433c   Initialisation de la physique :
434c   -------------------------------
[1671]435      IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100)) THEN
[630]436         latfi(1)=rlatu(1)
437         lonfi(1)=0.
438         zcufi(1) = cu(1)
439         zcvfi(1) = cv(1)
440         DO j=2,jjm
441            DO i=1,iim
442               latfi((j-2)*iim+1+i)= rlatu(j)
443               lonfi((j-2)*iim+1+i)= rlonv(i)
444               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
445               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
446            ENDDO
447         ENDDO
448         latfi(ngridmx)= rlatu(jjp1)
449         lonfi(ngridmx)= 0.
450         zcufi(ngridmx) = cu(ip1jm+1)
451         zcvfi(ngridmx) = cv(ip1jm-iim)
452         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
[807]453
[630]454         WRITE(lunout,*)
[1146]455     .       'GCM: WARNING!!! vitesse verticale nulle dans la physique'
[1615]456! Physics:
457#ifdef CPP_PHYS
[1671]458         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys/nsplit_phys,
459     &                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp,
460     &                iflag_phys)
[1146]461#endif
[630]462         call_iniphys=.false.
[1671]463      ENDIF ! of IF (call_iniphys.and.(iflag_phys==1.or.iflag_phys>=100))
[807]464
[1146]465
466c-----------------------------------------------------------------------
467c   Initialisation des dimensions d'INCA :
468c   --------------------------------------
[1563]469      IF (type_trac == 'inca') THEN
[1146]470!$OMP PARALLEL
471#ifdef INCA
472         CALL init_inca_dim(klon_omp,llm,iim,jjm,
473     $        rlonu,rlatu,rlonv,rlatv)
[630]474#endif
[1146]475!$OMP END PARALLEL
476      END IF
[630]477
478c-----------------------------------------------------------------------
479c   Initialisation des I/O :
480c   ------------------------
481
482
483      day_end = day_ini + nday
484      WRITE(lunout,300)day_ini,day_end
[1146]485 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
[630]486
[1279]487#ifdef CPP_IOIPSL
488      call ju2ymds(jD_ref + day_ini - day_ref, an, mois, jour, heure)
489      write (lunout,301)jour, mois, an
490      call ju2ymds(jD_ref + day_end - day_ref, an, mois, jour, heure)
491      write (lunout,302)jour, mois, an
492 301  FORMAT('1'/,15x,'run du ', i2,'/',i2,'/',i4)
493 302  FORMAT('1'/,15x,'    au ', i2,'/',i2,'/',i4)
494#endif
495
[1454]496!      if (planet_type.eq."earth") then
497! Write an Earth-format restart file
[1279]498        CALL dynredem0_p("restart.nc", day_end, phis)
[1454]499!      endif
[630]500
501      ecripar = .TRUE.
502
[1146]503#ifdef CPP_IOIPSL
[630]504      time_step = zdtvr
[1403]505      IF (mpi_rank==0) then
506        if (ok_dyn_ins) then
507          ! initialize output file for instantaneous outputs
508          ! t_ops = iecri * daysec ! do operations every t_ops
509          t_ops =((1.0*iecri)/day_step) * daysec 
510          t_wrt = daysec ! iecri * daysec ! write output every t_wrt
511          t_wrt = daysec ! iecri * daysec ! write output every t_wrt
512          CALL inithist(day_ref,annee_ref,time_step,
513     &                  t_ops,t_wrt)
514        endif
[630]515
[1403]516        IF (ok_dyn_ave) THEN
517          ! initialize output file for averaged outputs
518          t_ops = iperiod * time_step ! do operations every t_ops
519          t_wrt = periodav * daysec   ! write output every t_wrt
520          CALL initdynav(day_ref,annee_ref,time_step,
521     &                   t_ops,t_wrt)
[1279]522!         CALL initdynav_p(dynhistave_file,day_ref,annee_ref,time_step,
523!     .        t_ops, t_wrt, histaveid)
[1403]524        END IF
525      ENDIF
[630]526      dtav = iperiod*dtvr/daysec
527#endif
[1146]528! #endif of #ifdef CPP_IOIPSL
[630]529
530c  Choix des frequences de stokage pour le offline
531c      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
532c      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
533      istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
534      istphy=istdyn/iphysiq     
535
536
537c
538c-----------------------------------------------------------------------
539c   Integration temporelle du modele :
540c   ----------------------------------
541
542c       write(78,*) 'ucov',ucov
543c       write(78,*) 'vcov',vcov
544c       write(78,*) 'teta',teta
545c       write(78,*) 'ps',ps
546c       write(78,*) 'q',q
547
[1520]548c$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/,/logici/,/logicl/)
[1146]549      CALL leapfrog_p(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
[630]550     .              time_0)
[774]551c$OMP END PARALLEL
[630]552
553
554      END
555
Note: See TracBrowser for help on using the repository browser.