source: LMDZ4/trunk/libf/dyn3d/gcm.F @ 1244

Last change on this file since 1244 was 1147, checked in by Laurent Fairhead, 15 years ago

Inclusion des routines ioipsl

  • ioconf_startdate positionnant la date de départ de la simulation pour IOIPSL
  • getin_dump pour avoir les valeurs des paramètres effectivement utilisées par le programme

LF

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.1 KB
RevLine 
[524]1c
2c
3      PROGRAM gcm
4
5#ifdef CPP_IOIPSL
6      USE IOIPSL
[1146]7#else
8! if not using IOIPSL, we still need to use (a local version of) getin
9      USE ioipsl_getincom
[524]10#endif
[956]11
[1146]12      USE filtreg_mod
13      USE infotrac
14
[956]15!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique
17! A nettoyer. On ne veut qu'une ou deux routines d'interface
18! dynamique -> physique pour l'initialisation
[1146]19! Ehouarn: for now these only apply to Earth:
20#ifdef CPP_EARTH
[762]21      USE dimphy
22      USE comgeomphy
[863]23      USE mod_phys_lmdz_para, ONLY : klon_mpi_para_nb
[956]24#endif
25!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26
[524]27      IMPLICIT NONE
28
29c      ......   Version  du 10/01/98    ..........
30
31c             avec  coordonnees  verticales hybrides
32c   avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 )
33
34c=======================================================================
35c
36c   Auteur:  P. Le Van /L. Fairhead/F.Hourdin
37c   -------
38c
39c   Objet:
40c   ------
41c
42c   GCM LMD nouvelle grille
43c
44c=======================================================================
45c
46c  ... Dans inigeom , nouveaux calculs pour les elongations  cu , cv
47c      et possibilite d'appeler une fonction f(y)  a derivee tangente
48c      hyperbolique a la  place de la fonction a derivee sinusoidale.
49c  ... Possibilite de choisir le schema pour l'advection de
50c        q  , en modifiant iadv dans traceur.def  (MAF,10/02) .
51c
52c      Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99)
53c      Pour Van-Leer iadv=10
54c
55c-----------------------------------------------------------------------
56c   Declarations:
57c   -------------
58
59#include "dimensions.h"
60#include "paramet.h"
61#include "comconst.h"
62#include "comdissnew.h"
63#include "comvert.h"
64#include "comgeom.h"
65#include "logic.h"
66#include "temps.h"
67#include "control.h"
68#include "ener.h"
69#include "description.h"
70#include "serre.h"
71#include "com_io_dyn.h"
72#include "iniprint.h"
[541]73#include "tracstoke.h"
[524]74
75      INTEGER         longcles
76      PARAMETER     ( longcles = 20 )
77      REAL  clesphy0( longcles )
78      SAVE  clesphy0
79
80
81
82      REAL zdtvr
83      INTEGER nbetatmoy, nbetatdem,nbetat
84
85c   variables dynamiques
86      REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants
87      REAL teta(ip1jmp1,llm)                 ! temperature potentielle
[1146]88      REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes
[524]89      REAL ps(ip1jmp1)                       ! pression  au sol
90      REAL p (ip1jmp1,llmp1  )               ! pression aux interfac.des couches
91      REAL pks(ip1jmp1)                      ! exner au  sol
92      REAL pk(ip1jmp1,llm)                   ! exner au milieu des couches
93      REAL pkf(ip1jmp1,llm)                  ! exner filt.au milieu des couches
94      REAL masse(ip1jmp1,llm)                ! masse d'air
95      REAL phis(ip1jmp1)                     ! geopotentiel au sol
96      REAL phi(ip1jmp1,llm)                  ! geopotentiel
97      REAL w(ip1jmp1,llm)                    ! vitesse verticale
98
99c variables dynamiques intermediaire pour le transport
100
101c   variables pour le fichier histoire
102      REAL dtav      ! intervalle de temps elementaire
103
104      REAL time_0
105
106      LOGICAL lafin
107      INTEGER ij,iq,l,i,j
108
109
110      real time_step, t_wrt, t_ops
111
112      REAL rdayvrai,rdaym_ini,rday_ecri
113      LOGICAL first
114
115      LOGICAL call_iniphys
116      data call_iniphys/.true./
117
118      REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm)
119c+jld variables test conservation energie
[962]120c      REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm)
[524]121C     Tendance de la temp. potentiel d (theta)/ d t due a la
122C     tansformation d'energie cinetique en energie thermique
123C     cree par la dissipation
124      REAL dhecdt(ip1jmp1,llm)
[962]125c      REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm)
126c      REAL      d_h_vcol, d_qt, d_qw, d_ql, d_ec
127      CHARACTER (len=15) :: ztit
[524]128c-jld
129
130
[962]131      character (len=80) :: dynhist_file, dynhistave_file
132      character (len=20) :: modname
133      character (len=80) :: abort_message
[524]134
135C Calendrier
136      LOGICAL true_calendar
137      PARAMETER (true_calendar = .false.)
138
139c-----------------------------------------------------------------------
140c    variables pour l'initialisation de la physique :
141c    ------------------------------------------------
[1146]142      INTEGER ngridmx
[524]143      PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm   )
144      REAL zcufi(ngridmx),zcvfi(ngridmx)
145      REAL latfi(ngridmx),lonfi(ngridmx)
146      REAL airefi(ngridmx)
147      SAVE latfi, lonfi, airefi
148
149c-----------------------------------------------------------------------
150c   Initialisations:
151c   ----------------
152
153      abort_message = 'last timestep reached'
154      modname = 'gcm'
155      descript = 'Run GCM LMDZ'
156      lafin    = .FALSE.
157      dynhist_file = 'dyn_hist.nc'
158      dynhistave_file = 'dyn_hist_ave.nc'
159
[762]160
161
[524]162c-----------------------------------------------------------------------
163c   Choix du calendrier
164c   -------------------
165
166#ifdef CPP_IOIPSL
167      if (true_calendar) then
168        call ioconf_calendar('gregorian')
169      else
170        call ioconf_calendar('360d')
171      endif
172#endif
173c----------------------------------------------------------------------
174c  lecture des fichiers gcm.def ou run.def
175c  ---------------------------------------
176c
[1146]177! Ehouarn: dump possibility of using defrun
178!#ifdef CPP_IOIPSL
[524]179      CALL conf_gcm( 99, .TRUE. , clesphy0 )
[1146]180!#else
181!      CALL defrun( 99, .TRUE. , clesphy0 )
182!#endif
[762]183
[956]184!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
185! FH 2008/05/02
186! A nettoyer. On ne veut qu'une ou deux routines d'interface
187! dynamique -> physique pour l'initialisation
[1146]188! Ehouarn : temporarily (?) keep this only for Earth
189      if (planet_type.eq."earth") then
190#ifdef CPP_EARTH
191      CALL Init_Phys_lmdz(iim,jjp1,llm,1,(jjm-1)*iim+2)
[762]192      call InitComgeomphy
[956]193#endif
[1146]194      endif
[956]195!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[762]196
[960]197      IF (config_inca /= 'none') THEN
[762]198#ifdef INCA
[1146]199      call init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday)
[863]200      call init_inca_para(iim,jjm+1,klon,1,klon_mpi_para_nb,0)
[762]201#endif
[960]202      END IF
[524]203c
204c
[762]205c------------------------------------
206c   Initialisation partie parallele
207c------------------------------------
208
209c
210c
[524]211c-----------------------------------------------------------------------
212c   Initialisation des traceurs
213c   ---------------------------
[1146]214c  Choix du nombre de traceurs et du schema pour l'advection
215c  dans fichier traceur.def, par default ou via INCA
216      call infotrac_init
[524]217
[1146]218c Allocation de la tableau q : champs advectes   
219      allocate(q(ip1jmp1,llm,nqtot))
220
[524]221c-----------------------------------------------------------------------
222c   Lecture de l'etat initial :
223c   ---------------------------
224
225c  lecture du fichier start.nc
226      if (read_start) then
[1146]227      ! we still need to run iniacademic to initialize some
228      ! constants & fields, if we run the 'newtonian' case:
229        if (iflag_phys.eq.2) then
230          CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
231        endif
232!#ifdef CPP_IOIPSL
233        if (planet_type.eq."earth") then
234#ifdef CPP_EARTH
235! Load an Earth-format start file
236         CALL dynetat0("start.nc",vcov,ucov,
[524]237     .              teta,q,masse,ps,phis, time_0)
[1146]238#endif
239        endif ! of if (planet_type.eq."earth")
[524]240c       write(73,*) 'ucov',ucov
241c       write(74,*) 'vcov',vcov
242c       write(75,*) 'teta',teta
243c       write(76,*) 'ps',ps
244c       write(77,*) 'q',q
245
[1146]246      endif ! of if (read_start)
[524]247
[960]248      IF (config_inca /= 'none') THEN
[762]249#ifdef INCA
[960]250         call init_inca_dim(klon,llm,iim,jjm,
251     $        rlonu,rlatu,rlonv,rlatv)
[762]252#endif
[960]253      END IF
[524]254
255
256c le cas echeant, creation d un etat initial
257      IF (prt_level > 9) WRITE(lunout,*)
[1146]258     .              'GCM: AVANT iniacademic AVANT AVANT AVANT AVANT'
[524]259      if (.not.read_start) then
[1146]260         CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0)
[524]261      endif
262
263
264c-----------------------------------------------------------------------
265c   Lecture des parametres de controle pour la simulation :
266c   -------------------------------------------------------
267c  on recalcule eventuellement le pas de temps
268
269      IF(MOD(day_step,iperiod).NE.0) THEN
270        abort_message =
271     .  'Il faut choisir un nb de pas par jour multiple de iperiod'
272        call abort_gcm(modname,abort_message,1)
273      ENDIF
274
275      IF(MOD(day_step,iphysiq).NE.0) THEN
276        abort_message =
277     * 'Il faut choisir un nb de pas par jour multiple de iphysiq'
278        call abort_gcm(modname,abort_message,1)
279      ENDIF
280
281      zdtvr    = daysec/FLOAT(day_step)
282        IF(dtvr.NE.zdtvr) THEN
283         WRITE(lunout,*)
284     .    'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr
285        ENDIF
286
287C
288C on remet le calendrier à zero si demande
289c
290      if (annee_ref .ne. anneeref .or. day_ref .ne. dayref) then
291        write(lunout,*)
[1146]292     .  'GCM: Attention les dates initiales lues dans le fichier'
[524]293        write(lunout,*)
294     .  ' restart ne correspondent pas a celles lues dans '
295        write(lunout,*)' gcm.def'
296        if (raz_date .ne. 1) then
297          write(lunout,*)
[1146]298     .    'GCM: On garde les dates du fichier restart'
[524]299        else
300          annee_ref = anneeref
301          day_ref = dayref
302          day_ini = dayref
303          itau_dyn = 0
304          itau_phy = 0
305          time_0 = 0.
306          write(lunout,*)
[1146]307     .   'GCM: On reinitialise a la date lue dans gcm.def'
[524]308        endif
309      ELSE
310        raz_date = 0
311      endif
[1147]312#ifdef CPP_IOIPSL
313      call ioconf_startdate(annee_ref,0,day_ref, 0.)
314#endif
[524]315
316
317c  nombre d'etats dans les fichiers demarrage et histoire
318      nbetatdem = nday / iecri
319      nbetatmoy = nday / periodav + 1
320
321c-----------------------------------------------------------------------
322c   Initialisation des constantes dynamiques :
323c   ------------------------------------------
324      dtvr = zdtvr
325      CALL iniconst
326
327c-----------------------------------------------------------------------
328c   Initialisation de la geometrie :
329c   --------------------------------
330      CALL inigeom
331
332c-----------------------------------------------------------------------
333c   Initialisation du filtre :
334c   --------------------------
335      CALL inifilr
336c
337c-----------------------------------------------------------------------
338c   Initialisation de la dissipation :
339c   ----------------------------------
340
341      CALL inidissip( lstardis, nitergdiv, nitergrot, niterh   ,
342     *                tetagdiv, tetagrot , tetatemp              )
343
344c-----------------------------------------------------------------------
345c   Initialisation de la physique :
346c   -------------------------------
[1146]347
348      IF (call_iniphys.and.(iflag_phys.eq.1)) THEN
[524]349         latfi(1)=rlatu(1)
350         lonfi(1)=0.
351         zcufi(1) = cu(1)
352         zcvfi(1) = cv(1)
353         DO j=2,jjm
354            DO i=1,iim
355               latfi((j-2)*iim+1+i)= rlatu(j)
356               lonfi((j-2)*iim+1+i)= rlonv(i)
357               zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i)
358               zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i)
359            ENDDO
360         ENDDO
361         latfi(ngridmx)= rlatu(jjp1)
362         lonfi(ngridmx)= 0.
363         zcufi(ngridmx) = cu(ip1jm+1)
364         zcvfi(ngridmx) = cv(ip1jm-iim)
365         CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi)
366         WRITE(lunout,*)
[1146]367     .       'GCM: WARNING!!! vitesse verticale nulle dans la physique'
368! Earth:
369         if (planet_type.eq."earth") then
370#ifdef CPP_EARTH
[524]371         CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys ,
372     ,                latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp     )
[1146]373#endif
374         endif ! of if (planet_type.eq."earth")
[524]375         call_iniphys=.false.
[1146]376      ENDIF ! of IF (call_iniphys.and.(iflag_phys.eq.1))
377!#endif
[524]378
379c  numero de stockage pour les fichiers de redemarrage:
380
381c-----------------------------------------------------------------------
382c   Initialisation des I/O :
383c   ------------------------
384
385
386      day_end = day_ini + nday
387      WRITE(lunout,300)day_ini,day_end
[1146]388 300  FORMAT('1'/,15x,'run du jour',i7,2x,'au jour',i7//)
[524]389
[1146]390      if (planet_type.eq."earth") then
391#ifdef CPP_EARTH
392      CALL dynredem0("restart.nc", day_end, phis)
393#endif
394      endif
[524]395
396      ecripar = .TRUE.
397
[1146]398#ifdef CPP_IOIPSL
[524]399      if ( 1.eq.1) then
400      time_step = zdtvr
401      t_ops = iecri * daysec
402      t_wrt = iecri * daysec
403      CALL inithist(dynhist_file,day_ref,annee_ref,time_step,
[1146]404     .              t_ops, t_wrt, histid, histvid)
[524]405
[1146]406      IF (ok_dynzon) THEN
407         t_ops = iperiod * time_step
408         t_wrt = periodav * daysec
409         CALL initdynav(dynhistave_file,day_ref,annee_ref,time_step,
410     .        t_ops, t_wrt, histaveid)
411      END IF
[524]412      dtav = iperiod*dtvr/daysec
413      endif
414
415
416#endif
[1146]417! #endif of #ifdef CPP_IOIPSL
[524]418
[541]419c  Choix des frequences de stokage pour le offline
420c      istdyn=day_step/4     ! stockage toutes les 6h=1jour/4
421c      istdyn=day_step/12     ! stockage toutes les 2h=1jour/12
422      istdyn=day_step/4     ! stockage toutes les 6h=1jour/12
423      istphy=istdyn/iphysiq     
424
425
[524]426c
427c-----------------------------------------------------------------------
428c   Integration temporelle du modele :
429c   ----------------------------------
430
431c       write(78,*) 'ucov',ucov
432c       write(78,*) 'vcov',vcov
433c       write(78,*) 'teta',teta
434c       write(78,*) 'ps',ps
435c       write(78,*) 'q',q
436
437
[1146]438      CALL leapfrog(ucov,vcov,teta,ps,masse,phis,q,clesphy0,
[550]439     .              time_0)
[524]440
441      END
442
Note: See TracBrowser for help on using the repository browser.