source: LMDZ4/trunk/libf/dyn3dpar/gcm.F @ 1147

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