source: trunk/LMDZ.MARS/libf/dyn3d/disvert.F @ 1662

Last change on this file since 1662 was 1621, checked in by emillour, 8 years ago

Further work on full dynamics/physics separation.

LMDZ.COMMON:

  • added phy_common/vertical_layers_mod.F90 to store information on vertical grid. This is where routines in the physics should get the information.
  • The contents of vertical_layers_mod intialized via dynphy_lonlat/inigeomphy_mod.F90.

LMDZ.MARS:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • created an "ini_tracer_mod" routine in module "tracer_mod" for a cleaner initialization of the later.
  • removed some purely dynamics-related outputs (etot0, zoom parameters, etc.) from diagfi.nc and stats.nc outputs as these informations are not available in the physics.

LMDZ.GENERIC:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • added nqtot to tracer_h.F90.
  • removed some purely dynamics-related outputs (etot0, zoom parameters, etc.) from diagfi.nc and stats.nc outputs as these informations are not available in the physics.

LMDZ.VENUS:

  • physics now completely decoupled from dynamics; the physics package may now be compiled as a library (-libphy option of makelmdz_fcm).
  • added infotrac_phy.F90 to store information on tracers in the physics. Initialized via iniphysiq.
  • added cpdet_phy_mod.F90 to store t2tpot etc. functions to be used in the physics. Initialized via iniphysiq. IMPORTANT: there are some hard-coded constants! These should match what is in cpdet_mod.F90 in the dynamics.
  • got rid of references to moyzon_mod module within the physics. The required variables (tmoy, plevmoy) are passed to the physics as arguments to physiq.

LMDZ.TITAN:

  • added infotrac_phy.F90 to store information on tracers in the physics. Initialized via iniphysiq.
  • added cpdet_phy_mod.F90 to store t2tpot etc. functions to be used in the physics.
  • Extra work required to completely decouple physics and dynamics: moyzon_mod should be cleaned up and information passed from dynamics to physics as as arguments. Likewise moyzon_ch and moyzon_mu should not be queried from logic_mod (which is in the dynamics).

EM

File size: 8.7 KB
Line 
1      SUBROUTINE disvert
2
3c    Auteur :  F. Forget Y. Wanherdrick, P. Levan
4c    Nouvelle version 100% Mars !!
5
6      USE comvert_mod, ONLY: ap,bp,sig,nivsigs,nivsig,pa,preff,
7     .                  aps,bps,presnivs,pseudoalt,scaleheight
8      USE comconst_mod, ONLY: kappa,pi
9      USE logic_mod, ONLY: hybrid
10
11      IMPLICIT NONE
12
13#include "dimensions.h"
14#include "paramet.h"
15c
16c=======================================================================
17c    Discretisation verticale en coordonnée hybride OU sigma
18c
19c=======================================================================
20c
21c   declarations:
22c   -------------
23c
24c
25      INTEGER l,ll
26      REAL snorm
27      REAL alpha,beta,gama,delta,deltaz,quoi,quand
28      REAL zsig(llm)
29      INTEGER np,ierr
30      integer :: ierr1,ierr2,ierr3,ierr4
31      REAL x
32
33      REAL SSUM
34      EXTERNAL SSUM
35      real newsig
36      REAL dz0,dz1,nhaut,sig1,esig,csig,zz
37      real tt,rr,gg, prevz
38      real s(llm),dsig(llm)
39
40      integer iz
41      real z, ps,p
42
43c
44c-----------------------------------------------------------------------
45c
46      pi=2.*ASIN(1.)
47
48! Ouverture possible de fichiers typiquement E.T.
49
50         open(99,file="esasig.def",status='old',form='formatted',
51     s   iostat=ierr2)
52         if(ierr2.ne.0) then
53              close(99)
54              open(99,file="z2sig.def",status='old',form='formatted',
55     s        iostat=ierr4)
56         endif
57
58c-----------------------------------------------------------------------
59c   cas 1 on lit les options dans esasig.def:
60c   ----------------------------------------
61
62      IF(ierr2.eq.0) then
63
64c        Lecture de esasig.def :
65c        Systeme peu souple, mais qui respecte en theorie
66c        La conservation de l'energie (conversion Energie potentielle
67c        <-> energie cinetique, d'apres la note de Frederic Hourdin...
68
69         PRINT*,'*****************************'
70         PRINT*,'WARNING Lecture de esasig.def'
71         PRINT*,'*****************************'
72         READ(99,*) scaleheight
73         READ(99,*) dz0
74         READ(99,*) dz1
75         READ(99,*) nhaut
76         CLOSE(99)
77
78         dz0=dz0/scaleheight
79         dz1=dz1/scaleheight
80
81         sig1=(1.-dz1)/tanh(.5*(llm-1)/nhaut)
82
83         esig=1.
84
85         do l=1,20
86            esig=-log((1./sig1-1.)*exp(-dz0)/esig)/(llm-1.)
87         enddo
88         csig=(1./sig1-1.)/(exp(esig)-1.)
89
90         DO L = 2, llm
91            zz=csig*(exp(esig*(l-1.))-1.)
92            sig(l) =1./(1.+zz)
93     &      * tanh(.5*(llm+1-l)/nhaut)
94         ENDDO
95         sig(1)=1.
96         sig(llm+1)=0.
97         quoi      = 1. + 2.* kappa
98         s( llm )  = 1.
99         s(llm-1) = quoi
100         IF( llm.gt.2 )  THEN
101            DO  ll = 2, llm-1
102               l         = llm+1 - ll
103               quand     = sig(l+1)/ sig(l)
104               s(l-1)    = quoi * (1.-quand) * s(l)  + quand * s(l+1)
105            ENDDO
106         END IF
107c
108         snorm=(1.-.5*sig(2)+kappa*(1.-sig(2)))*s(1)+.5*sig(2)*s(2)
109         DO l = 1, llm
110            s(l)    = s(l)/ snorm
111         ENDDO
112
113c-----------------------------------------------------------------------
114c   cas 2 on lit les options dans z2sig.def:
115c   ----------------------------------------
116
117      ELSE IF(ierr4.eq.0) then
118         PRINT*,'****************************'
119         PRINT*,'Lecture de z2sig.def'
120         PRINT*,'****************************'
121
122         READ(99,*) scaleheight
123         do l=1,llm
124            read(99,*) zsig(l)
125         end do
126         CLOSE(99)
127
128         sig(1) =1
129         do l=2,llm
130           sig(l) = 0.5 * ( exp(-zsig(l)/scaleheight) +
131     &                      exp(-zsig(l-1)/scaleheight) )
132         end do
133         sig(llm+1) =0
134
135c-----------------------------------------------------------------------
136      ELSE
137         write(*,*) 'didn t you forget something ??? '
138         write(*,*) 'We need the file  z2sig.def ! (OR esasig.def) '
139         stop
140      ENDIF
141c-----------------------------------------------------------------------
142
143      DO l=1,llm
144        nivsigs(l) = REAL(l)
145      ENDDO
146
147      DO l=1,llmp1
148        nivsig(l)= REAL(l)
149      ENDDO
150
151 
152c-----------------------------------------------------------------------
153c    ....  Calculs  de ap(l) et de bp(l)  ....
154c    .........................................
155c
156c   .....  pa et preff sont lus  sur les fichiers start par dynetat0 .....
157c-----------------------------------------------------------------------
158c
159
160      if (hybrid) then
161         write(*,*) "*******************************"
162         write(*,*) "Systeme en coordonnees hybrides"
163         write(*,*)
164c        Coordonnees hybrides avec mod
165         DO l = 1, llm
166
167         call sig_hybrid(sig(l),pa,preff,newsig)
168            bp(l) = EXP( 1. - 1./(newsig**2)  )
169            ap(l) = pa * (newsig - bp(l) )
170         enddo
171         bp(llmp1) = 0.
172         ap(llmp1) = 0.
173      else
174         write(*,*) "****************************"
175         write(*,*) "Systeme en coordonnees sigma"
176         write(*,*)
177c        Pour ne pas passer en coordonnees hybrides
178         DO l = 1, llm
179            ap(l) = 0.
180            bp(l) = sig(l)
181         ENDDO
182         ap(llmp1) = 0.
183      endif
184
185      bp(llmp1) =   0.
186
187      PRINT *,' BP '
188      PRINT *,  bp
189      PRINT *,' AP '
190      PRINT *,  ap
191
192c     Calcul au milieu des couches :
193c     WARNING : le choix de placer le milieu des couches au niveau de
194c     pression intermédiaire est arbitraire et pourrait etre modifié.
195c     Le calcul du niveau pour la derniere couche
196c     (on met la meme distance (en log pression)  entre P(llm)
197c     et P(llm -1) qu'entre P(llm-1) et P(llm-2) ) est
198c     Specifique.  Ce choix est spécifié ici ET dans exner_hyb.F
199
200      DO l = 1, llm-1
201       aps(l) =  0.5 *( ap(l) +ap(l+1))
202       bps(l) =  0.5 *( bp(l) +bp(l+1))
203      ENDDO
204     
205      if (hybrid) then
206         aps(llm) = aps(llm-1)**2 / aps(llm-2)
207         bps(llm) = 0.5*(bp(llm) + bp(llm+1))
208      else
209         bps(llm) = bps(llm-1)**2 / bps(llm-2)
210         aps(llm) = 0.
211      end if
212
213      PRINT *,' BPs '
214      PRINT *,  bps
215      PRINT *,' APs'
216      PRINT *,  aps
217
218      DO l = 1, llm
219       presnivs(l) = aps(l)+bps(l)*preff
220       pseudoalt(l) = -10.*log(presnivs(l)/preff)
221      ENDDO
222
223      PRINT *,' PRESNIVS'
224      PRINT *,presnivs
225      PRINT *,'Pseudo altitude des Presnivs : '
226      PRINT *,pseudoalt
227
228c     --------------------------------------------------
229c     This can be used to plot the vertical discretization
230c     (> xmgrace -nxy testhybrid.tab       (z = H*log(p(l)/pref))
231c     --------------------------------------------------
232c     open (53,file='testhybrid.tab')
233c     do iz=0,60
234c       z = -10 + min(iz,60-iz)
235c       ps = preff*exp(-z/10)
236c       do l=1,llm
237c          zsig(l)= -10.*log((aps(l) + bps(l)*ps)/preff)
238c       end do
239c       write(53,*)iz, (zsig(l),l=1,llm,1)
240c      end do
241c      close(53)
242c     --------------------------------------------------
243
244
245      RETURN
246      END
247
248c ************************************************************
249      subroutine sig_hybrid(sig,pa,preff,newsig)
250c     ----------------------------------------------
251c     Subroutine utilisee pour calculer des valeurs de sigma modifie
252c     pour conserver les coordonnees verticales decrites dans
253c     esasig.def/z2sig.def lors du passage en coordonnees hybrides
254c     F. Forget 2002
255c     Connaissant sig (niveaux "sigma" ou on veut mettre les couches)
256c     L'objectif est de calculer newsig telle que
257c       (1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig = sig
258c     Cela ne se résoud pas analytiquement:
259c     => on résoud par iterration bourrine
260c     ----------------------------------------------
261c     Information  : where exp(1-1./x**2) become << x
262c           x      exp(1-1./x**2) /x
263c           1           1
264c           0.68       0.5
265c           0.5        1.E-1
266c           0.391      1.E-2
267c           0.333      1.E-3
268c           0.295      1.E-4
269c           0.269      1.E-5
270c           0.248      1.E-6
271c        => on peut utiliser newsig = sig*preff/pa si sig*preff/pa < 0.25
272
273
274      implicit none
275      real x1, x2, sig,pa,preff, newsig, F
276      integer j
277
278      newsig = sig
279      x1=0
280      x2=1
281          if (sig.ge.1) then
282               newsig= sig
283      else if (sig*preff/pa.ge.0.25) then
284        DO J=1,9999  ! nombre d''iteration max
285          F=((1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig)/sig
286c         write(0,*) J, ' newsig =', newsig, ' F= ', F
287          if (F.gt.1) then
288              X2 = newsig
289              newsig=(X1+newsig)*0.5
290          else
291              X1 = newsig
292              newsig=(X2+newsig)*0.5
293          end if
294c         Test : on arete lorsque on approxime sig à moins de 0.01 m près
295c         (en pseudo altiude) :
296          IF(abs(10.*log(F)).LT.1.E-5) goto 999
297        END DO
298       else   !    if (sig*preff/pa.le.0.25) then
299                newsig= sig*preff/pa
300       end if
301 999   continue
302       Return
303      END
Note: See TracBrowser for help on using the repository browser.