/[lmdze]/trunk/dyn3d/gcm.f
ViewVC logotype

Diff of /trunk/dyn3d/gcm.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/libf/dyn3d/gcm.f90 revision 5 by guez, Mon Mar 3 16:32:04 2008 UTC trunk/dyn3d/gcm.f revision 128 by guez, Thu Feb 12 16:23:33 2015 UTC
# Line 1  Line 1 
1  PROGRAM gcm  PROGRAM gcm
2    
   ! General circulation model of LMD  
   
   ! From "gcm.F", version 1.4, 2006/04/04 15:05:16  
   
   ! Avec coordonnées verticales hybrides, avec nouveaux opérateurs de  
   ! dissipation * (gradiv2, divgrad2, nxgraro2)  
   
3    ! Authors: P. Le Van, L. Fairhead, F. Hourdin    ! Authors: P. Le Van, L. Fairhead, F. Hourdin
4      ! From "gcm.F", version 1.4, 2006/04/04 15:05:16
5    
6    ! Possibilité de choisir le schéma pour l'advection de "q", en    ! General circulation model of LMD. Avec coordonnée verticale
7    ! modifiant "iadv" dans "traceur.def".    ! hybride, avec nouveaux opérateurs de dissipation "*" ("gradiv2",
8      ! "divgrad2", "nxgraro2"). Possibilité de choisir le schéma pour
9    ! Pour Van-Leer plus vapeur d'eau saturée : iadv(1)=4    ! l'advection de "q", en modifiant "iadv" dans "traceur.def".
10    ! Pour Van-Leer : iadv=10  
11      use comconst, only: daysec, dtvr, iniconst
12    USE IOIPSL, only: ioconf_calendar    use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv, inigeom
13      use comgeomphy, only: airephy, cuphy, cvphy, rlatd, rlond
14      use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, &
15           nday, raz_date, periodav, conf_gcm, iflag_phys
16      use conf_guide_m, only: conf_guide
17    use dimens_m, only: iim, jjm, llm, nqmx    use dimens_m, only: iim, jjm, llm, nqmx
18    use dimphy, only: klon    use dimphy, only: klon
19    use paramet_m, only: ip1jm, ip1jmp1    USE disvert_m, ONLY : disvert
20    use comconst, only: daysec, cpp, dtvr, dtphys, g, rad, r, initialize    use dynetat0_m, only: dynetat0, day_ini
21      use dynredem0_m, only: dynredem0
   use comdissnew, only: lstardis, nitergdiv, nitergrot, niterh, tetagdiv, &  
        tetagrot, tetatemp  
   
   use conf_gcm_m, only: day_step, iperiod, anneeref, dayref, iecri, iphysiq, &  
        nday, raz_date, periodav, conf_gcm  
   
   use logic, only: iflag_phys  
   use comgeom, only: rlatu, aire_2d, cu_2d, cv_2d, rlonv  
   use temps, only: day_ref, annee_ref, day_ini, day_end, itau_phy, itau_dyn  
   use com_io_dyn, only: histid, histvid, histaveid  
   use tracstoke, only: istdyn, istphy  
   use abort_gcm_m, only: abort_gcm  
   use inithist_m, only: inithist  
   use initdynav_m, only: initdynav  
   use dynetat0_m, only: dynetat0  
22    use grid_change, only: dyn_phy, init_dyn_phy    use grid_change, only: dyn_phy, init_dyn_phy
23    use advtrac_m, only: iniadvtrac    use histclo_m, only: histclo
24      use iniadvtrac_m, only: iniadvtrac
25      use inidissip_m, only: inidissip
26      use inifilr_m, only: inifilr
27      use initdynav_m, only: initdynav
28      use inithist_m, only: inithist
29      use init_dynzon_m, only: init_dynzon
30      USE ioconf_calendar_m, only: ioconf_calendar
31      use jumble, only: new_unit
32    use leapfrog_m, only: leapfrog    use leapfrog_m, only: leapfrog
33      use netcdf95, only: nf95_close
34      use suphec_m, only: suphec
35      use temps, only: day_ref, annee_ref, day_end, itau_dyn
36      use tracstoke, only: istdyn, istphy
37      use unit_nml_m, only: unit_nml
38      use yoethf_m, only: yoethf
39      use createnewfield_m, only: NbField, Ncid
40    
41    IMPLICIT NONE    IMPLICIT NONE
42    
   REAL clesphy0(20)  
   REAL zdtvr ! time step for dynamics, in s  
   
43    ! Variables dynamiques :    ! Variables dynamiques :
44    REAL vcov(ip1jm, llm), ucov(ip1jmp1, llm) ! vents covariants    REAL ucov(iim + 1, jjm + 1, llm), vcov(iim + 1, jjm, llm)  ! vent covariant
45    REAL teta(ip1jmp1, llm) ! température potentielle    REAL teta(iim + 1, jjm + 1, llm) ! température potentielle
46    REAL q(ip1jmp1, llm, nqmx) ! champs advectés    REAL q(iim + 1, jjm + 1, llm, nqmx) ! champs advectés
47    REAL ps(ip1jmp1) ! pression au sol (Pa)    REAL ps(iim + 1, jjm + 1) ! pression au sol (Pa)
48      REAL masse(iim + 1, jjm + 1, llm) ! masse d'air
49    REAL masse(ip1jmp1, llm) ! masse d'air    REAL phis(iim + 1, jjm + 1) ! géopotentiel au sol
   REAL phis(ip1jmp1) ! géopotentiel au sol  
50    
51    ! Variables pour le fichier histoire :    ! Variables pour le fichier histoire :
52    REAL time_0    REAL time_0 ! time in day, as a fraction of day, in [0, 1[
   
   !!INTEGER i  
53    
54    ! Calendrier :    ! Calendrier :
55    LOGICAL:: true_calendar = .false. ! default value    LOGICAL:: true_calendar = .false. ! default value
56    
   ! Variables pour l'initialisation de la physique :  
   integer nq  
   REAL zcufi(klon), zcvfi(klon) ! "cu" and "cv" values on the scalar grid  
   REAL latfi(klon), lonfi(klon)  
   REAL airefi(klon)  
   
57    logical mask_v(iim + 1, jjm)    logical mask_v(iim + 1, jjm)
58    ! (mask for points in the "v" grid, first index is for longitude,    ! (mask for points in the "v" grid, first index is for longitude,
59    ! second index is for latitude)    ! second index is for latitude)
60    
61      integer i
62    
63    namelist /main_nml/true_calendar    namelist /main_nml/true_calendar
64    
65    !------------------------------------------------------------    !------------------------------------------------------------
66    
67      call new_unit(unit_nml)
68      open(unit_nml, file="used_namelists.txt", status="replace", action="write")
69    
70      CALL conf_gcm
71    
72    print *, "Enter namelist 'main_nml'."    print *, "Enter namelist 'main_nml'."
73    read (unit=*, nml=main_nml)    read (unit=*, nml=main_nml)
74    write(unit=*, nml=main_nml)    write(unit_nml, nml=main_nml)
   
   ! Initialisations:  
   call initialize  
75    
76    ! Choix du calendrier :    ! Choix du calendrier :
77    if (true_calendar) then    if (true_calendar) then
# Line 90  PROGRAM gcm Line 80  PROGRAM gcm
80       call ioconf_calendar('360d')       call ioconf_calendar('360d')
81    endif    endif
82    
   ! Lecture des fichiers "gcm.def" ou "run.def" :  
   CALL conf_gcm(clesphy0)  
   
83    ! Initialisation des traceurs    ! Initialisation des traceurs
84    ! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA    ! Choix du schéma pour l'advection dans le fichier "traceur.def" ou via INCA
85    call iniadvtrac(nq)    call iniadvtrac
86    
   ! Lecture du fichier "start.nc" :  
   CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis, time_0)  
   ! Begin special experiment  
 !!$     print *, "This is a special experiment."  
 !!$     print *, "We are setting:"  
 !!$     print *, "ucov = vcov = 0, q = 0, ps = 101325"  
 !!$     print *, "We are averaging 'teta' horizontally."  
 !!$     ucov = 0.  
 !!$     vcov = 0.  
 !!$     q = 0.  
 !!$     ps = 101325.  
   ! Average teta over all longitudes and latitudes:  
 !!$     forall(i = 1:llm) teta(:,i) = sum(teta(:,i)) / ip1jmp1  
   ! (it would be better to weight each element with an associated  
   ! surface area)  
   ! End special experiment  
   
   ! Lecture des paramètres de contrôle pour la simulation :  
   ! on recalcule éventuellement le pas de temps  
   IF (MOD(day_step, iperiod) /= 0) THEN  
      call abort_gcm(modname = "gcm", message = &  
           'Il faut choisir un nombre de pas par jour multiple de "iperiod".', &  
           ierr = 1)  
   ENDIF  
   
   IF (MOD(day_step,iphysiq)/=0) THEN  
      call abort_gcm(modname = "gcm", message = &  
           'Il faut choisir un nombre de pas par jour multiple de "iphysiq".', &  
           ierr = 1)  
   ENDIF  
   
   ! On remet le calendrier à zero si demandé:  
   if (annee_ref /= anneeref .or. day_ref /= dayref) then  
      print *, 'Attention : les dates initiales lues dans le fichier ' // &  
           '"start" ne correspondent pas à celles lues dans "gcm.def".'  
      if (raz_date /= 1) then  
         print *, 'On garde les dates du fichier "start".'  
      else  
         print *, 'On réinitialise à la date lue dans "gcm.def".'  
         annee_ref = anneeref  
         day_ref = dayref  
         day_ini = dayref  
         itau_dyn = 0  
         itau_phy = 0  
         time_0 = 0.  
      endif  
   ELSE  
      raz_date = 0  
   endif  
   
   ! Initialisation des constantes dynamiques :  
   zdtvr = daysec / REAL(day_step)  
   IF (dtvr /= zdtvr) THEN  
      print *, 'Warning: the time steps in the ".def" file and in ' // &  
           '"start.nc" are different'  
      print *, 'dtvr (from "start.nc") = ', dtvr  
      print *, 'zdtvr (from ".def") = ', zdtvr  
      print *, 'Using the value from the ".def" file.'  
      dtvr = zdtvr  
   ENDIF  
87    CALL iniconst    CALL iniconst
88    
89    ! Initialisation de la géometrie :    ! Lecture du fichier "start.nc" :
90    CALL inigeom    CALL dynetat0(vcov, ucov, teta, q, masse, ps, phis)
   
   ! Initialisation du filtre :  
   CALL inifilr  
91    
92    ! Initialisation de la dissipation :    ! On remet le calendrier à zéro si demandé :
93    CALL inidissip(lstardis, nitergdiv, nitergrot, niterh, tetagdiv, tetagrot, &    if (raz_date) then
94         tetatemp)       print *, 'On réinitialise à la date lue dans la namelist.'
95         annee_ref = anneeref
96         day_ref = dayref
97         day_ini = dayref
98         itau_dyn = 0
99      else
100         print *, 'On garde les dates du fichier "start".'
101      endif
102    
103      CALL disvert
104      CALL inigeom ! initialisation de la géometrie
105      CALL inifilr ! initialisation du filtre
106      CALL inidissip
107    call init_dyn_phy    call init_dyn_phy
108    
109    ! Initialisation de la physique :    ! Initialisation de la physique :
110    IF (iflag_phys == 1) THEN    IF (iflag_phys == 1) THEN
111       latfi(1)=rlatu(1)       rlatd(1)=rlatu(1)
112       latfi(2:klon-1) = pack(spread(rlatu(2:jjm), 1, iim), .true.)       rlatd(2:klon-1) = pack(spread(rlatu(2:jjm), 1, iim), .true.)
113       latfi(klon)= rlatu(jjm + 1)       rlatd(klon)= rlatu(jjm + 1)
114    
115       lonfi(1)=0.       rlond(1)=0.
116       lonfi(2:klon-1) = pack(spread(rlonv(:iim), 2, jjm - 1), .true.)       rlond(2:klon-1) = pack(spread(rlonv(:iim), 2, jjm - 1), .true.)
117       lonfi(klon)= 0.       rlond(klon)= 0.
118    
119       zcufi = pack(cu_2d, dyn_phy)       cuphy = pack(cu_2d, dyn_phy)
120    
121       ! Construct a mask for points in the "v" grid:       ! Construct a mask for points in the "v" grid:
122       mask_v = .true.       mask_v = .true.
123       mask_v(2:, 1) = .false.       mask_v(2:, 1) = .false.
124       mask_v(iim + 1, 2:) = .false.       mask_v(iim + 1, 2:) = .false.
125    
126       zcvfi(:klon - 1) = pack(cv_2d, mask_v)       cvphy(:klon - 1) = pack(cv_2d, mask_v)
127       zcvfi(klon) = cv_2d(1, jjm)       cvphy(klon) = cv_2d(1, jjm)
128       ! (that value of "cv_2d" is used twice in "zcvfi")       ! (that value of "cv_2d" is used twice in "cvphy")
129    
130       airefi = pack(aire_2d, dyn_phy)       airephy = pack(aire_2d, dyn_phy)
131       print *, 'Attention : vitesse verticale nulle dans la physique.'       CALL suphec
132       CALL iniphysiq(klon, llm, daysec, day_ini, dtphys, latfi, lonfi, airefi, &       call yoethf
           zcufi, zcvfi, rad, g, r, cpp)  
133    ENDIF    ENDIF
134    
   ! Numéro de stockage pour les fichiers de redémarrage :  
135    ! Initialisation des entrées-sorties :    ! Initialisation des entrées-sorties :
136    day_end = day_ini + nday    day_end = day_ini + nday
137    print *, "day_ini = ", day_ini    print *, "day_ini = ", day_ini
138    print *, "day_end = ", day_end    print *, "day_end = ", day_end
139    
140    CALL dynredem0("restart.nc", day_end, phis)    CALL dynredem0("restart.nc", day_end, phis)
141    CALL inithist(day_ref, annee_ref, zdtvr, nqmx, histid, histvid, &    CALL inithist(day_ref, annee_ref, dtvr, nqmx, t_ops = iecri * daysec, &
142         infile="dyn_hist.nc", t_ops = iecri * daysec, t_wrt = iecri * daysec)         t_wrt = iecri * daysec)
143    CALL initdynav(day_ref, annee_ref, zdtvr, nqmx, histaveid, &    CALL initdynav(day_ref, annee_ref, dtvr, nqmx, t_ops = iperiod * dtvr, &
        infile='dyn_hist_ave.nc', t_ops = iperiod * zdtvr, &  
144         t_wrt = periodav * daysec)         t_wrt = periodav * daysec)
145      call init_dynzon(dt_app = dtvr * iperiod)
146    
147    ! Choix des fréquences de stockage pour le hors-ligne :    ! Choix des fréquences de stockage pour le hors-ligne :
148    istdyn = day_step / 4     ! stockage toutes les 6 h = 1 jour / 4    istdyn = day_step / 4 ! stockage toutes les 6 h = 1 jour / 4
149    istphy = istdyn / iphysiq        istphy = istdyn / iphysiq    
150    
151      CALL conf_guide
152    
153    ! Intégration temporelle du modèle :    ! Intégration temporelle du modèle :
154    CALL leapfrog(ucov, vcov, teta, ps, masse, phis, nq, q, clesphy0, time_0)    CALL leapfrog(ucov, vcov, teta, ps, masse, phis, q)
155    
156      close(unit_nml)
157      call histclo
158    
159      do i = 1, nbfield
160         call nf95_close(Ncid(i))
161      end do
162    
163      print *, 'Simulation finished'
164      print *, 'Everything is cool'
165    
166  END PROGRAM gcm  END PROGRAM gcm

Legend:
Removed from v.5  
changed lines
  Added in v.128

  ViewVC Help
Powered by ViewVC 1.1.21