source: trunk/LMDZ.VENUS/libf/phyvenus/ballon.F @ 1453

Last change on this file since 1453 was 1442, checked in by slebonnois, 10 years ago

SL: update of the Venus GCM, + corrections on routines used for newstart/start2archive for Titan and Venus, + some modifications on tools

File size: 12.3 KB
Line 
1      subroutine ballon (iam,dtphys,rjour,rsec,plat,plon,
2     i                   temp, p, u, v, geop)
3
4      use dimphy
5      implicit none
6
7c======================================================================
8c Auteur: S. Lebonnois (LMD/CNRS) date: 20091201
9c Object: Compute balloon trajectories.
10C No outputs, every quantities are written on the iam+ Files.
11c
12c Called by physiq.F if flag ballons activated:
13c
14c      integer ballons
15c (...)
16c      ballons  = 1         ! (in initialisations)
17c (...)
18C  OUVERTURE DES FICHIERS FORMATTES CONTENANT LES POSITIONS ET VITESSES
19C  DES BALLONS
20c      if (ballons.eq.1) then
21c      open(30,file='ballons-lat.out',form='formatted')
22c      open(31,file='ballons-lon.out',form='formatted')
23c      open(32,file='ballons-u.out',form='formatted')
24c      open(33,file='ballons-v.out',form='formatted')
25c      open(34,file='ballons-alt.out',form='formatted')
26c      write(*,*)'Ouverture des ballons*.out'
27c      endif !ballons
28c (...)
29C        CALL ballon(30,pdtphys,rjourvrai,gmtime,rlatd,rlond,
30CC    C               t,pplay,u,v,pphi)   ! alt above surface (smoothed for GCM)
31C     C               t,pplay,u,v,zphi)   ! alt above planet average radius
32c (...)
33C  FERMETURE DES FICHIERS FORMATTES CONTENANT LES POSITIONS ET VITESSES
34C  DES BALLONS
35c      if (ballons.eq.1) then
36c        write(*,*)'Fermeture des ballons*.out'
37c        close(30)                                     
38c        close(31)                                     
39c        close(32)                                     
40c        close(33)                                     
41c        close(34)                                     
42c      endif !ballons
43c
44C======================================================================
45c Explicit Arguments:
46c ==================
47c iam-----input-I-File number where latitudes are written
48c                 It is a formatted file that has been opened
49c                 in physiq.F
50c   other files: iam+1=longitudes
51c                iam+2=zonal speeds
52c                iam+3=meridional speeds
53c                iam+4=altitudes
54c dtphys--input-R-pas de temps physique
55c rjour---input-R-Jour compte depuis le debut de la simu (run.def)
56c rsec----input-R-Seconde de la journee
57c plat ---input-R-Latitude en degres
58c plon ---input-R-Longitude en degres
59c temp----input-R-Temperature (K) at model levels
60c p-------input-R-Pressure (Pa) at model levels
61c u-------input-R-Horizontal wind (m/s)
62c v-------input-R-Meridional wind (m/s)
63c geop----input-R-Geopotential !! above surface OR average radius
64c
65c
66c Implicit Arguments:
67c ===================
68c
69c iim--common-I: Number of longitude intervals
70c jjm--common-I: Number of latitude intervals
71c klon-common-I: Number of points seen by the physics
72c                iim*(jjm-1)+2 for instance
73c klev-common-I: Number of vertical layers
74c RPI,RKBOL--common-R: Pi, KBoltzman
75c RDAY,RA,RG-common-R: day length in s, planet radius, gravity
76c======================================================================
77c Local Variables:
78c ================
79c
80c nb    ---I: number of balloons (parameter)
81c phib  ---R: Latitude of balloon in radians
82c lamb  ---R: Longitude of balloon in radians
83c lognb ---R: log(density) of balloon
84c ub    ---R: zonal speed of balloon
85c vb    ---R: meridional speed of balloon
86c altb  ---R: altitude of balloon
87c zlat  ---R: Latitude in radians
88c zlon  ---R: Longitude in radians
89c logn  ---R: log(density)
90c alt   ---R: altitude !! above surface OR average radius
91c ull   ---R: zonal wind for one balloon on the lognb surface
92c vll   ---R: meridional wind for one balloon on the lognb surface
93c aal   ---R: altitude for one balloon on the lognb surface
94c======================================================================
95
96#include "dimensions.h"
97#include "YOMCST.h"
98c
99c ARGUMENTS
100c
101      INTEGER iam
102      REAL dtphys,rjour,rsec,plat(klon),plon(klon)
103      REAL temp(klon,klev),p(klon,klev)
104      REAL u(klon,klev),v(klon,klev),geop(klon,klev)
105c
106c Variables locales:
107c
108      INTEGER i,j,k,l,nb,n
109      parameter (nb=20)  !! Adjust the format on line 100 !!
110      INTEGER jj,ii,ll
111
112      REAL zlon(iim+1),zlat(jjm+1)
113      save zlon,zlat
114
115      REAL time
116      REAL logn(klon,klev),ull(klon),vll(klon)
117      REAL alt(klon,klev),aal(klon)
118      real ub(nb),vb(nb),phib(nb),lamb(nb),lognb(nb),altb(nb)
119      save phib,lamb,lognb
120
121      REAL factalt
122
123c RungeKutta order - If not RK, Nrk=1
124      integer Nrk,irk
125      parameter (Nrk=1)
126      real    dtrk
127
128      logical first
129      save first
130      data first/.true./
131
132      time = rjour*RDAY+rsec
133      logn(:,:) = log10(p(:,:)/(RKBOL*temp(:,:)))
134      alt(:,:)  = geop(:,:)/RG
135
136c---------------------------------------------
137C INITIALIZATIONS
138c---------------------------------------------
139      if (first) then
140
141      print*,"BALLOONS ACTIVATED"
142
143C Latitudes:
144      zlat(1)=plat(1)*RPI/180.
145      do j = 2,jjm
146         k=(j-2)*iim+2
147         zlat(j)=plat(k)*RPI/180.
148      enddo
149      zlat(jjm+1)=plat(klon)*RPI/180.
150
151C Longitudes:
152      do i = 1,iim
153         k=i+1
154         zlon(i)=plon(k)*RPI/180.
155      enddo
156      zlon(iim+1)=zlon(1)+2.*RPI
157
158c verif init     lat de 90 à -90, lon de -180 à 180
159c     print*,"Latitudes:",zlat*180./RPI
160c     print*,"Longitudes:",zlon*180./RPI
161c     stop
162
163c initial positions of balloons (in degrees for lat/lon)
164      do j=1,5
165      do i=1,4
166        k=(j-1)*4+i
167      phib(k)= (j-1)*20.*RPI/180.
168      lamb(k)= (i-3)*90.*RPI/180.   ! de -180 à 90
169c     lognb(k)= log10(5.e4/(RKBOL*300.)) ! ~55km in VIRA model
170      lognb(k)= log10(5.e5/(RKBOL*300.)) ! 5 bars (for Blamont, mai2015)
171      enddo
172      enddo
173      print*,"Balloon density (m^-3)=",10.**(lognb(1))
174
175c     print*,"log(density) profile:"
176c     do l=1,klev
177c        print*,logn(klon/2,l)
178c     enddo
179c     stop !verif init
180
181      first=.false.
182      endif ! first
183c---------------------------------------------
184
185c-------------------------------------------------
186c loop over the balloons
187c-------------------------------------------------
188      do n=1,nb
189
190c Interpolation in altitudes
191c-------------------------------------------------
192        do k=1,klon
193         ll=1 ! en bas
194         do l=2,klev
195          if (lognb(n).lt.logn(k,l)) ll=l
196         enddo
197         factalt= (lognb(n)-logn(k,ll))/(logn(k,ll+1)-logn(k,ll))
198         ull(k) =   u(k,ll+1)*factalt +   u(k,ll)*(1-factalt)
199         vll(k) =   v(k,ll+1)*factalt +   v(k,ll)*(1-factalt)
200         aal(k) = alt(k,ll+1)*factalt + alt(k,ll)*(1-factalt)
201        enddo
202
203c Interpolation in latitudes and longitudes
204c-------------------------------------------
205        call wind_interp(ull,vll,aal,zlat,zlon,
206     .                   phib(n),lamb(n),ub(n),vb(n),altb(n))
207       
208      enddo ! over balloons
209c-------------------------------------------------
210
211c-------------------------------------------------
212c Output of positions and speed at time
213c-------------------------------------------------
214
215c Venus regardee a l'envers: lon et lat inversees
216      write(iam,  100) time, (-1)*phib*180./RPI
217      write(iam+1,100) time, (-1)*lamb*180./RPI
218      write(iam+2,100) time, ub
219c Venus regardee a l'envers: v inversee
220      write(iam+3,100) time, (-1)*vb
221      write(iam+4,100) time, altb
222c     stop !verif init
223
224c !!!!!!!!!!!!!!!! nb !!!!!!!!!!!!!!!!!
225100   format(E14.7,20(1x,E12.5))
226
227c-------------------------------------------------
228c Implementation: positions at time+dt
229c RK order Nrk
230c-------------------------------------------------
231
232      dtrk = dtphys/Nrk
233      time=time+dtrk
234
235      do n=1,nb
236        call pos_implem(phib(n),lamb(n),ub(n),vb(n),dtrk)
237      enddo
238
239      if (Nrk.gt.1) then
240       do irk=2,Nrk
241        do n=1,nb
242          time=time+dtrk
243          call wind_interp(ull,vll,aal,zlat,zlon,
244     .                   phib(n),lamb(n),ub(n),vb(n),altb(n))
245          call pos_implem(phib(n),lamb(n),ub(n),vb(n),dtrk)
246        enddo
247       enddo
248      endif
249
250      end
251
252c======================================================================
253c======================================================================
254c======================================================================
255
256      subroutine wind_interp(map_u,map_v,map_a,latit,longit,
257     .                       phi,lam,ubal,vbal,abal)
258
259      use dimphy
260      implicit none
261
262c======================================================================
263c Auteur: S. Lebonnois (LMD/CNRS) date: 20091201
264c Object: interpolate balloon speed from its position.
265C======================================================================
266c Explicit Arguments:
267c ==================
268c map_u ---R: zonal wind on the lognb surface
269c map_v ---R: meridional wind on the lognb surface
270c map_a ---R: altitude on the lognb surface
271c latit ---R: Latitude in radians
272c longit---R: Longitude in radians
273c phi   ---R: Latitude of balloon in radians
274c lam   ---R: Longitude of balloon in radians
275c ubal  ---R: zonal speed of balloon
276c vbal  ---R: meridional speed of balloon
277c abal  ---R: altitude of balloon
278c======================================================================
279c Local Variables:
280c ================
281c
282c ujj   ---R: zonal wind interpolated in latitude
283c vjj   ---R: meridional wind interpolated in latitude
284c ajj   ---R: altitude interpolated in latitude
285c======================================================================
286
287#include "dimensions.h"
288#include "YOMCST.h"
289c
290c ARGUMENTS
291c
292      real map_u(klon),map_v(klon),map_a(klon)
293      real latit(jjm+1),longit(iim)
294      real phi,lam,ubal,vbal,abal
295c
296c Variables locales:
297c
298      INTEGER i,j,k
299      INTEGER jj,ii
300      REAL    ujj(iim+1),vjj(iim+1),ajj(iim+1)
301      REAL    factlat,factlon
302
303c Interpolation in latitudes
304c-------------------------------------------------
305        jj=1  ! POLE NORD
306        do j=2,jjm
307          if (phi.lt.latit(j)) jj=j
308        enddo
309        factlat  = (phi-latit(jj))/(latit(jj+1)-latit(jj))
310
311c pole nord
312        if (jj.eq.1) then
313         do i=1,iim
314          ujj(i) = map_u(i+1)*factlat + map_u(1)*(1-factlat)
315          vjj(i) = map_v(i+1)*factlat + map_v(1)*(1-factlat)
316          ajj(i) = map_a(i+1)*factlat + map_a(1)*(1-factlat)
317         enddo
318c pole sud
319        elseif (jj.eq.jjm) then
320         do i=1,iim
321          k = (jj-2)*iim+1+i
322          ujj(i) = map_u(klon)*factlat + map_u(k)*(1-factlat)
323          vjj(i) = map_v(klon)*factlat + map_v(k)*(1-factlat)
324          ajj(i) = map_a(klon)*factlat + map_a(k)*(1-factlat)
325         enddo
326c autres latitudes
327        else
328         do i=1,iim
329          k = (jj-2)*iim+1+i
330          ujj(i) = map_u(k+iim)*factlat + map_u(k)*(1-factlat)
331          vjj(i) = map_v(k+iim)*factlat + map_v(k)*(1-factlat)
332          ajj(i) = map_a(k+iim)*factlat + map_a(k)*(1-factlat)
333         enddo
334        endif
335        ujj(iim+1)=ujj(1)
336        vjj(iim+1)=vjj(1)
337        ajj(iim+1)=ajj(1)
338
339c Interpolation in longitudes
340c-------------------------------------------------
341        ii=1  ! lon=-180
342        do i=2,iim
343          if (lam.gt.longit(i)) ii=i
344        enddo
345        factlon = (lam-longit(ii))/(longit(ii+1)-longit(ii))
346        ubal    = ujj(ii+1)*factlon + ujj(ii)*(1-factlon)
347        vbal    = vjj(ii+1)*factlon + vjj(ii)*(1-factlon)
348        abal    = ajj(ii+1)*factlon + ajj(ii)*(1-factlon)
349
350      end
351
352c======================================================================
353c======================================================================
354c======================================================================
355
356      subroutine pos_implem(phi,lam,ubal,vbal,dt)
357
358      use dimphy
359      implicit none
360
361c======================================================================
362c Auteur: S. Lebonnois (LMD/CNRS) date: 20091201
363c Object: implementation of balloon position.
364C======================================================================
365c Explicit Arguments:
366c ==================
367c phi   ---R: Latitude of balloon in radians
368c lam   ---R: Longitude of balloon in radians
369c ubal  ---R: zonal speed of balloon
370c vbal  ---R: meridional speed of balloon
371c dt    ---R: time step
372c======================================================================
373
374#include "dimensions.h"
375#include "YOMCST.h"
376c
377c ARGUMENTS
378c
379      real phi,lam,ubal,vbal,abal,dt
380
381c incrementation longitude
382        lam = lam + ubal*dt/(RA*cos(phi))
383c maintenue entre -PI et PI:
384        do while (lam.ge.RPI)     
385              lam=lam-2*RPI
386        enddo
387        do while (lam.lt.(-1.*RPI)) 
388              lam=lam+2*RPI
389        enddo
390c incrementation latitude
391        phi = phi + vbal*dt/RA
392c maintenue entre -PI/2 et PI/2:
393        if (phi.ge.( 0.5*RPI)) phi=    RPI-phi
394        if (phi.le.(-0.5*RPI)) phi=-1.*RPI-phi
395
396      end
Note: See TracBrowser for help on using the repository browser.