source: LMDZ4/branches/LMDZ4V5.0-dev/libf/dyn3d/gcm.F @ 1299

Last change on this file since 1299 was 1299, checked in by Laurent Fairhead, 14 years ago

Nettoyage general pour se rapprocher des normes et éviter des erreurs a la
compilation:

  • tous les FLOAT() sont remplacés par des REAL()
  • tous les STOP dans phylmd sont remplacés par des appels à abort_gcm
  • le common control défini dans le fichier control.h est remplacé par le module control_mod pour éviter des messages sur l'alignement des variables dans les déclarations
  • des $Header$ remplacés par des $Id$ pour svn

Quelques remplacements à faire ont pu m'échapper


General cleanup of the code to try and adhere to norms and to prevent some
compilation errors:

  • all FLOAT() instructions have been replaced by REAL() instructions
  • all STOP instructions in phylmd have been replaced by calls to abort_gcm
  • the common block control defined in the control.h file has been replaced by the control_mod to prevent compilation warnings on the alignement of declared variables
  • $Header$ replaced by $Id$ for svn

Some changes which should have been made might have escaped me

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