3 |
michaesp |
1 |
program getmima
|
|
|
2 |
C ===============
|
|
|
3 |
|
|
|
4 |
C Get the minimum and maximum of a variable either
|
|
|
5 |
C in the whole 3d data domain, or an a specified pressure or
|
|
|
6 |
C theta level.
|
|
|
7 |
C The program is invoked by the shell-script getmima.
|
|
|
8 |
C
|
|
|
9 |
C August 96 H. Wernli
|
|
|
10 |
|
|
|
11 |
implicit none
|
|
|
12 |
|
|
|
13 |
integer nzmax,ntmax
|
|
|
14 |
parameter(nzmax=100,ntmax=200)
|
|
|
15 |
|
|
|
16 |
real,allocatable, dimension (:) :: sp,varf,field,varl,tt
|
|
|
17 |
integer stat
|
|
|
18 |
|
|
|
19 |
real time(ntmax),level
|
|
|
20 |
character*80 cdfnam,cstnam,varnam,tvar,clev
|
|
|
21 |
character*20 vnam(100)
|
|
|
22 |
character*1 mode
|
|
|
23 |
integer cdfid,cstid,ierr,ndim,vardim(4)
|
|
|
24 |
real dx,dy,mdv,varmin(4),varmax(4),stag(4)
|
|
|
25 |
real aklev(nzmax),bklev(nzmax),aklay(nzmax),bklay(nzmax),
|
|
|
26 |
> ak(nzmax),bk(nzmax)
|
|
|
27 |
logical prelev
|
|
|
28 |
integer nx,ny,nz,ntimes,ipom,nvars
|
|
|
29 |
real pollon,pollat,xphys,yphys
|
|
|
30 |
integer i,n
|
|
|
31 |
integer imin,jmin,imax,jmax,minind,maxind,kmin,kmax,hmin,hmax
|
|
|
32 |
real min,max,lonmin,latmin,lonmax,latmax,pmin,pmax,tmin,tmax
|
|
|
33 |
|
|
|
34 |
real lmstolm,phstoph
|
|
|
35 |
|
|
|
36 |
integer iargc
|
|
|
37 |
character*(80) arg
|
|
|
38 |
integer flag
|
|
|
39 |
|
|
|
40 |
c check for sufficient requested arguments
|
|
|
41 |
if (iargc().lt.2) then
|
|
|
42 |
print*,'USAGE: getmima filename var ',
|
|
|
43 |
> '[lev in the form Pval or Tval]'
|
|
|
44 |
call exit(1)
|
|
|
45 |
endif
|
|
|
46 |
|
|
|
47 |
c read and transform input
|
|
|
48 |
call getarg(1,arg)
|
|
|
49 |
cdfnam=trim(arg)
|
|
|
50 |
|
|
|
51 |
call getarg(2,arg)
|
|
|
52 |
varnam=trim(arg)
|
|
|
53 |
|
|
|
54 |
if (iargc().eq.3) then
|
|
|
55 |
call getarg(3,arg)
|
|
|
56 |
mode=arg(1:1)
|
|
|
57 |
clev=arg(2:len(arg))
|
|
|
58 |
call checkchar(clev,".",flag)
|
|
|
59 |
if (flag.eq.0) clev=trim(clev)//"."
|
|
|
60 |
read(clev,'(f10.2)') level
|
|
|
61 |
else
|
|
|
62 |
mode='X'
|
|
|
63 |
level=0.
|
|
|
64 |
endif
|
|
|
65 |
|
|
|
66 |
prelev=.true.
|
|
|
67 |
|
|
|
68 |
min= 1.e19
|
|
|
69 |
max=-1.e19
|
|
|
70 |
|
|
|
71 |
C Open files and get infos about data domain
|
|
|
72 |
|
|
|
73 |
call cdfopn(trim(cdfnam),cdfid,ierr)
|
|
|
74 |
call getcfn(cdfid,cstnam,ierr)
|
|
|
75 |
call cdfopn(trim(cstnam),cstid,ierr)
|
|
|
76 |
call getdef(cdfid,trim(varnam),ndim,mdv,vardim,
|
|
|
77 |
> varmin,varmax,stag,ierr)
|
|
|
78 |
if (ierr.ne.0) goto 920
|
|
|
79 |
|
|
|
80 |
C Get the data array and the levels
|
|
|
81 |
|
|
|
82 |
nx=vardim(1)
|
|
|
83 |
ny=vardim(2)
|
|
|
84 |
nz=vardim(3)
|
|
|
85 |
call gettimes(cdfid,time,ntimes,ierr)
|
|
|
86 |
|
|
|
87 |
call getgrid(cstid,dx,dy,ierr)
|
|
|
88 |
call getlevs(cstid,nz,aklev,bklev,aklay,bklay,ierr)
|
|
|
89 |
call getpole(cstid,pollon,pollat,ierr)
|
|
|
90 |
|
|
|
91 |
C Get memory for dynamic arrays
|
|
|
92 |
|
|
|
93 |
allocate(sp(nx*ny),stat=stat)
|
|
|
94 |
if (stat.ne.0) print*,'*** error allocating array sp ***'
|
|
|
95 |
allocate(varf(nx*ny),stat=stat)
|
|
|
96 |
if (stat.ne.0) print*,'*** error allocating array varf ***'
|
|
|
97 |
allocate(varl(nx*ny*nz),stat=stat)
|
|
|
98 |
if (stat.ne.0) print*,'*** error allocating array varl ***'
|
|
|
99 |
allocate(tt(nx*ny*nz),stat=stat)
|
|
|
100 |
if (stat.ne.0) print*,'*** error allocating array tt ***'
|
|
|
101 |
allocate(field(nx*ny*nz),stat=stat)
|
|
|
102 |
if (stat.ne.0) print*,'*** error allocating array field ***'
|
|
|
103 |
|
|
|
104 |
do n=1,ntimes
|
|
|
105 |
|
|
|
106 |
call getdat(cdfid,trim(varnam),time(n),0,field,ierr)
|
|
|
107 |
|
|
|
108 |
C Define the appropriate ak and bk-arrays
|
|
|
109 |
|
|
|
110 |
if (stag(3).eq.0.) then
|
|
|
111 |
do i=1,nz
|
|
|
112 |
ak(i)=aklev(i)
|
|
|
113 |
bk(i)=bklev(i)
|
|
|
114 |
enddo
|
|
|
115 |
else
|
|
|
116 |
do i=1,nz
|
|
|
117 |
ak(i)=aklay(i)
|
|
|
118 |
bk(i)=bklay(i)
|
|
|
119 |
enddo
|
|
|
120 |
endif
|
|
|
121 |
|
|
|
122 |
do i=1,nz
|
|
|
123 |
if (bk(i).ne.0.) prelev=.false.
|
|
|
124 |
enddo
|
|
|
125 |
|
|
|
126 |
if (.not.prelev) call getdat(cdfid,'PS',time(n),0,sp,ierr)
|
|
|
127 |
|
|
|
128 |
C Determine name of "temperature variable"
|
|
|
129 |
|
|
|
130 |
call getvars(cdfid,nvars,vnam,ierr)
|
|
|
131 |
tvar="T"
|
|
|
132 |
do i=1,nvars
|
|
|
133 |
if (vnam(i).eq."THETA") tvar="THETA"
|
|
|
134 |
if (vnam(i).eq."TH") tvar="TH"
|
|
|
135 |
enddo
|
|
|
136 |
|
|
|
137 |
C If required do interpolation on pressure or theta level
|
|
|
138 |
|
|
|
139 |
if (mode.eq.'P') then
|
|
|
140 |
call pres(varl,sp,nx,ny,nz,ak,bk)
|
|
|
141 |
call vipo(field,varl,level,varf,nx,ny,nz,mdv,ipom)
|
|
|
142 |
else if (mode.eq.'T') then
|
|
|
143 |
if (tvar.eq.'T') then
|
|
|
144 |
call getdat(cdfid,'T',time(n),0,tt,ierr)
|
|
|
145 |
call pottemp(varl,tt,sp,nx,ny,nz,ak,bk)
|
|
|
146 |
call thipo(field,varl,level,varf,nx,ny,nz,mdv,ipom)
|
|
|
147 |
else
|
|
|
148 |
call getdat(cdfid,tvar,time(n),0,varl,ierr)
|
|
|
149 |
call thipo(field,varl,level,varf,nx,ny,nz,mdv,ipom)
|
|
|
150 |
endif
|
|
|
151 |
endif
|
|
|
152 |
|
|
|
153 |
C Determine minimum and maximum and calculate their location
|
|
|
154 |
|
|
|
155 |
if (mode.ne.'X') then
|
|
|
156 |
do i=1,nx*ny
|
|
|
157 |
if ((varf(i).ne.mdv).and.(varf(i).lt.min)) then
|
|
|
158 |
min=varf(i)
|
|
|
159 |
minind=i
|
|
|
160 |
tmin=time(n)
|
|
|
161 |
else if ((varf(i).ne.mdv).and.(varf(i).gt.max)) then
|
|
|
162 |
max=varf(i)
|
|
|
163 |
maxind=i
|
|
|
164 |
tmax=time(n)
|
|
|
165 |
endif
|
|
|
166 |
enddo
|
|
|
167 |
imin=mod(minind-1,nx)+1
|
|
|
168 |
jmin=int((minind-1)/nx)+1
|
|
|
169 |
imax=mod(maxind-1,nx)+1
|
|
|
170 |
jmax=int((maxind-1)/nx)+1
|
|
|
171 |
lonmin=varmin(1)+(imin-1)*dx
|
|
|
172 |
latmin=varmin(2)+(jmin-1)*dy
|
|
|
173 |
pmin=level
|
|
|
174 |
lonmax=varmin(1)+(imax-1)*dx
|
|
|
175 |
latmax=varmin(2)+(jmax-1)*dy
|
|
|
176 |
pmax=level
|
|
|
177 |
else
|
|
|
178 |
do i=1,nx*ny*nz
|
|
|
179 |
if ((field(i).ne.mdv).and.(field(i).lt.min)) then
|
|
|
180 |
min=field(i)
|
|
|
181 |
minind=i
|
|
|
182 |
tmin=time(n)
|
|
|
183 |
else if ((field(i).ne.mdv).and.(field(i).gt.max)) then
|
|
|
184 |
max=field(i)
|
|
|
185 |
maxind=i
|
|
|
186 |
tmax=time(n)
|
|
|
187 |
endif
|
|
|
188 |
enddo
|
|
|
189 |
imin=mod(mod(minind-1,nx*ny),nx)+1
|
|
|
190 |
jmin=int(mod(minind-1,nx*ny)/nx)+1
|
|
|
191 |
imax=mod(mod(maxind-1,nx*ny),nx)+1
|
|
|
192 |
jmax=int(mod(maxind-1,nx*ny)/nx)+1
|
|
|
193 |
kmin=int((minind-1)/(nx*ny))+1
|
|
|
194 |
kmax=int((maxind-1)/(nx*ny))+1
|
|
|
195 |
hmin=imin+(jmin-1)*nx
|
|
|
196 |
hmax=imax+(jmax-1)*ny
|
|
|
197 |
lonmin=varmin(1)+(imin-1)*dx
|
|
|
198 |
latmin=varmin(2)+(jmin-1)*dy
|
|
|
199 |
pmin=ak(kmin)+bk(kmin)*sp(hmin)
|
|
|
200 |
lonmax=varmin(1)+(imax-1)*dx
|
|
|
201 |
latmax=varmin(2)+(jmax-1)*dy
|
|
|
202 |
pmax=ak(kmax)+bk(kmax)*sp(hmax)
|
|
|
203 |
endif
|
|
|
204 |
|
|
|
205 |
if ((pollon.ne.0.).or.(pollat.ne.90.)) then
|
|
|
206 |
xphys=lmstolm(latmin,lonmin,pollat,pollon)
|
|
|
207 |
yphys=phstoph(latmin,lonmin,pollat,pollon)
|
|
|
208 |
lonmin=xphys
|
|
|
209 |
latmin=yphys
|
|
|
210 |
xphys=lmstolm(latmax,lonmax,pollat,pollon)
|
|
|
211 |
yphys=phstoph(latmax,lonmax,pollat,pollon)
|
|
|
212 |
lonmax=xphys
|
|
|
213 |
latmax=yphys
|
|
|
214 |
endif
|
|
|
215 |
|
|
|
216 |
enddo
|
|
|
217 |
|
|
|
218 |
write(*,101)min,max,lonmin,latmin,nint(pmin),tmin,
|
|
|
219 |
> lonmax,latmax,nint(pmax),tmax
|
|
|
220 |
101 format(2f10.3,2f8.2,i6,f6.1,2f8.2,i6,f6.1)
|
|
|
221 |
|
|
|
222 |
call clscdf(cdfid,ierr)
|
|
|
223 |
call clscdf(cstid,ierr)
|
|
|
224 |
|
|
|
225 |
goto 999
|
|
|
226 |
|
|
|
227 |
920 stop '*** error: variable not found on file ***'
|
|
|
228 |
999 continue
|
|
|
229 |
end
|
|
|
230 |
|
|
|
231 |
subroutine vipo(var3d,varl,lev,var,nx,ny,nz,mdv,ipom)
|
|
|
232 |
C =====================================================
|
|
|
233 |
|
|
|
234 |
C Interpolates the 3d variable var3d on the surface defined
|
|
|
235 |
C by lev of the variable varl. The interpolated field is
|
|
|
236 |
C returned as var.
|
|
|
237 |
C ipom determines the way of vertical interpolation:
|
|
|
238 |
C ipom=0 is for linear interpolation
|
|
|
239 |
C ipom=1 is for logarithmic interpolation
|
|
|
240 |
|
|
|
241 |
integer nx,ny,nz,ipom
|
|
|
242 |
real lev,mdv
|
|
|
243 |
real var3d(nx,ny,nz),varl(nx,ny,nz),var(nx,ny)
|
|
|
244 |
|
|
|
245 |
integer i,j,k
|
|
|
246 |
real kind
|
|
|
247 |
real int3dm
|
|
|
248 |
|
|
|
249 |
do i=1,nx
|
|
|
250 |
do j=1,ny
|
|
|
251 |
|
|
|
252 |
do k=1,nz-1
|
|
|
253 |
if ((varl(i,j,k).ge.lev).and.(varl(i,j,k+1).le.lev)) then
|
|
|
254 |
kind=float(k)+(varl(i,j,k)-lev)/
|
|
|
255 |
> (varl(i,j,k)-varl(i,j,k+1))
|
|
|
256 |
goto 100
|
|
|
257 |
endif
|
|
|
258 |
enddo
|
|
|
259 |
100 continue
|
|
|
260 |
|
|
|
261 |
var(i,j)=int3dm(var3d,nx,ny,nz,float(i),float(j),kind,mdv)
|
|
|
262 |
|
|
|
263 |
enddo
|
|
|
264 |
enddo
|
|
|
265 |
|
|
|
266 |
return
|
|
|
267 |
end
|
|
|
268 |
|
|
|
269 |
subroutine thipo(var3d,th3d,lev,var,nx,ny,nz,mdv,mode)
|
|
|
270 |
C ======================================================
|
|
|
271 |
|
|
|
272 |
C Interpolates the 3d variable var3d on the isentropic surface
|
|
|
273 |
C defined by lev. The interpolated field is returned as var.
|
|
|
274 |
C th3d denotes the 3d theta array.
|
|
|
275 |
C mode determines the way of vertical interpolation:
|
|
|
276 |
C mode=0 is for linear interpolation
|
|
|
277 |
C mode=1 is for logarithmic interpolation
|
|
|
278 |
|
|
|
279 |
integer nx,ny,nz,mode
|
|
|
280 |
real lev,mdv
|
|
|
281 |
real var3d(nx,ny,nz),th3d(nx,ny,nz),var(nx,ny)
|
|
|
282 |
|
|
|
283 |
integer i,j,k
|
|
|
284 |
real kind
|
|
|
285 |
real int3dm
|
|
|
286 |
|
|
|
287 |
do i=1,nx
|
|
|
288 |
do j=1,ny
|
|
|
289 |
|
|
|
290 |
do k=1,nz-1
|
|
|
291 |
if ((th3d(i,j,k).le.lev).and.(th3d(i,j,k+1).ge.lev)) then
|
|
|
292 |
kind=float(k)+(th3d(i,j,k)-lev)/
|
|
|
293 |
> (th3d(i,j,k)-th3d(i,j,k+1))
|
|
|
294 |
goto 100
|
|
|
295 |
endif
|
|
|
296 |
enddo
|
|
|
297 |
100 continue
|
|
|
298 |
|
|
|
299 |
var(i,j)=int3dm(var3d,nx,ny,nz,float(i),float(j),kind,mdv)
|
|
|
300 |
|
|
|
301 |
enddo
|
|
|
302 |
enddo
|
|
|
303 |
|
|
|
304 |
return
|
|
|
305 |
end
|
|
|
306 |
|
|
|
307 |
subroutine checkchar(string,char,flag)
|
|
|
308 |
C ======================================
|
|
|
309 |
|
|
|
310 |
character*(*) string
|
|
|
311 |
character*(1) char
|
|
|
312 |
integer n,flag
|
|
|
313 |
|
|
|
314 |
flag=0
|
|
|
315 |
do n=1,len(string)
|
|
|
316 |
if (string(n:n).eq.char) then
|
|
|
317 |
flag=n
|
|
|
318 |
return
|
|
|
319 |
endif
|
|
|
320 |
enddo
|
|
|
321 |
end
|
|
|
322 |
|
|
|
323 |
real function int3d(ar,n1,n2,n3,rid,rjd,rkd)
|
|
|
324 |
c-----------------------------------------------------------------------
|
|
|
325 |
c Purpose:
|
|
|
326 |
c This subroutine interpolates a 3d-array to an arbitrary
|
|
|
327 |
c location within the grid.
|
|
|
328 |
c Arguments:
|
|
|
329 |
c ar real input surface pressure, define as ar(n1,n2,n3)
|
|
|
330 |
c n1,n2,n3 int input dimensions of ar
|
|
|
331 |
c ri,rj,rk real input grid location to be interpolated to
|
|
|
332 |
c History:
|
|
|
333 |
c-----------------------------------------------------------------------
|
|
|
334 |
|
|
|
335 |
c argument declarations
|
|
|
336 |
integer n1,n2,n3
|
|
|
337 |
real ar(n1,n2,n3), rid,rjd,rkd
|
|
|
338 |
|
|
|
339 |
c local declarations
|
|
|
340 |
integer i,j,k,ip1,jp1,kp1,ih,jh,kh
|
|
|
341 |
real frac0i,frac0j,frac0k,frac1i,frac1j,frac1k,ri,rj,rk
|
|
|
342 |
|
|
|
343 |
c do linear interpolation
|
|
|
344 |
ri=amax1(1.,amin1(float(n1),rid))
|
|
|
345 |
rj=amax1(1.,amin1(float(n2),rjd))
|
|
|
346 |
rk=amax1(1.,amin1(float(n3),rkd))
|
|
|
347 |
ih=nint(ri)
|
|
|
348 |
jh=nint(rj)
|
|
|
349 |
kh=nint(rk)
|
|
|
350 |
|
|
|
351 |
c Check for interpolation in i
|
|
|
352 |
* if (abs(float(ih)-ri).lt.1.e-3) then
|
|
|
353 |
* i =ih
|
|
|
354 |
* ip1=ih
|
|
|
355 |
* else
|
|
|
356 |
i =min0(int(ri),n1-1)
|
|
|
357 |
ip1=i+1
|
|
|
358 |
* endif
|
|
|
359 |
|
|
|
360 |
c Check for interpolation in j
|
|
|
361 |
if (abs(float(jh)-rj).lt.1.e-3) then
|
|
|
362 |
j =jh
|
|
|
363 |
jp1=jh
|
|
|
364 |
else
|
|
|
365 |
j =min0(int(rj),n2-1)
|
|
|
366 |
jp1=j+1
|
|
|
367 |
endif
|
|
|
368 |
|
|
|
369 |
c Check for interpolation in k
|
|
|
370 |
* if (abs(float(kh)-rk).lt.1.e-3) then
|
|
|
371 |
* k =kh
|
|
|
372 |
* kp1=kh
|
|
|
373 |
* else
|
|
|
374 |
k =min0(int(rk),n3-1)
|
|
|
375 |
kp1=k+1
|
|
|
376 |
* endif
|
|
|
377 |
|
|
|
378 |
if (k.eq.kp1) then
|
|
|
379 |
c no interpolation in k
|
|
|
380 |
if ((i.eq.ip1).and.(j.eq.jp1)) then
|
|
|
381 |
c no interpolation at all
|
|
|
382 |
int3d=ar(i,j,k)
|
|
|
383 |
c print *,'int3d 00: ',rid,rjd,rkd,int3d
|
|
|
384 |
else
|
|
|
385 |
c horizontal interpolation only
|
|
|
386 |
frac0i=ri-float(i)
|
|
|
387 |
frac0j=rj-float(j)
|
|
|
388 |
frac1i=1.-frac0i
|
|
|
389 |
frac1j=1.-frac0j
|
|
|
390 |
int3d = ar(i ,j ,k ) * frac1i * frac1j
|
|
|
391 |
& + ar(i ,jp1,k ) * frac1i * frac0j
|
|
|
392 |
& + ar(ip1,j ,k ) * frac0i * frac1j
|
|
|
393 |
& + ar(ip1,jp1,k ) * frac0i * frac0j
|
|
|
394 |
c print *,'int3d 10: ',rid,rjd,rkd,int3d
|
|
|
395 |
endif
|
|
|
396 |
else
|
|
|
397 |
frac0k=rk-float(k)
|
|
|
398 |
frac1k=1.-frac0k
|
|
|
399 |
if ((i.eq.ip1).and.(j.eq.jp1)) then
|
|
|
400 |
c vertical interpolation only
|
|
|
401 |
int3d = ar(i ,j ,k ) * frac1k
|
|
|
402 |
& + ar(i ,j ,kp1) * frac0k
|
|
|
403 |
c print *,'int3d 01: ',rid,rjd,rkd,int3d
|
|
|
404 |
else
|
|
|
405 |
c full 3d interpolation
|
|
|
406 |
frac0i=ri-float(i)
|
|
|
407 |
frac0j=rj-float(j)
|
|
|
408 |
frac1i=1.-frac0i
|
|
|
409 |
frac1j=1.-frac0j
|
|
|
410 |
int3d = ar(i ,j ,k ) * frac1i * frac1j * frac1k
|
|
|
411 |
& + ar(i ,jp1,k ) * frac1i * frac0j * frac1k
|
|
|
412 |
& + ar(ip1,j ,k ) * frac0i * frac1j * frac1k
|
|
|
413 |
& + ar(ip1,jp1,k ) * frac0i * frac0j * frac1k
|
|
|
414 |
& + ar(i ,j ,kp1) * frac1i * frac1j * frac0k
|
|
|
415 |
& + ar(i ,jp1,kp1) * frac1i * frac0j * frac0k
|
|
|
416 |
& + ar(ip1,j ,kp1) * frac0i * frac1j * frac0k
|
|
|
417 |
& + ar(ip1,jp1,kp1) * frac0i * frac0j * frac0k
|
|
|
418 |
c print *,'int3d 11: ',rid,rjd,rkd,int3d
|
|
|
419 |
endif
|
|
|
420 |
endif
|
|
|
421 |
end
|
|
|
422 |
real function int3dm(ar,n1,n2,n3,rid,rjd,rkd,misdat)
|
|
|
423 |
c-----------------------------------------------------------------------
|
|
|
424 |
c Purpose:
|
|
|
425 |
c This subroutine interpolates a 3d-array to an arbitrary
|
|
|
426 |
c location within the grid. The interpolation includes the
|
|
|
427 |
c testing of the missing data flag 'misdat'.
|
|
|
428 |
c Arguments:
|
|
|
429 |
c ar real input surface pressure, define as ar(n1,n2,n3)
|
|
|
430 |
c n1,n2,n3 int input dimensions of ar
|
|
|
431 |
c ri,rj,rk real input grid location to be interpolated to
|
|
|
432 |
c misdat real input missing data flag (on if misdat<>0)
|
|
|
433 |
c Warning:
|
|
|
434 |
c This routine has not yet been seriously tested
|
|
|
435 |
c History:
|
|
|
436 |
c-----------------------------------------------------------------------
|
|
|
437 |
|
|
|
438 |
c argument declarations
|
|
|
439 |
integer n1,n2,n3
|
|
|
440 |
real ar(n1,n2,n3), rid,rjd,rkd, misdat
|
|
|
441 |
|
|
|
442 |
c local declarations
|
|
|
443 |
integer i,j,k,ip1,jp1,kp1,ih,jh,kh
|
|
|
444 |
real frac0i,frac0j,frac0k,frac1i,frac1j,frac1k,ri,rj,rk,int3d
|
|
|
445 |
|
|
|
446 |
c check if routine without missing data checking can be called instead
|
|
|
447 |
if (misdat.eq.0.) then
|
|
|
448 |
int3dm=int3d(ar,n1,n2,n3,rid,rjd,rkd)
|
|
|
449 |
return
|
|
|
450 |
endif
|
|
|
451 |
|
|
|
452 |
c do linear interpolation
|
|
|
453 |
ri=amax1(1.,amin1(float(n1),rid))
|
|
|
454 |
rj=amax1(1.,amin1(float(n2),rjd))
|
|
|
455 |
rk=amax1(1.,amin1(float(n3),rkd))
|
|
|
456 |
ih=nint(ri)
|
|
|
457 |
jh=nint(rj)
|
|
|
458 |
kh=nint(rk)
|
|
|
459 |
|
|
|
460 |
c Check for interpolation in i
|
|
|
461 |
* if (abs(float(ih)-ri).lt.1.e-3) then
|
|
|
462 |
* i =ih
|
|
|
463 |
* ip1=ih
|
|
|
464 |
* else
|
|
|
465 |
i =min0(int(ri),n1-1)
|
|
|
466 |
ip1=i+1
|
|
|
467 |
* endif
|
|
|
468 |
|
|
|
469 |
c Check for interpolation in j
|
|
|
470 |
* if (abs(float(jh)-rj).lt.1.e-3) then
|
|
|
471 |
* j =jh
|
|
|
472 |
* jp1=jh
|
|
|
473 |
* else
|
|
|
474 |
j =min0(int(rj),n2-1)
|
|
|
475 |
jp1=j+1
|
|
|
476 |
* endif
|
|
|
477 |
|
|
|
478 |
c Check for interpolation in k
|
|
|
479 |
* if (abs(float(kh)-rk).lt.1.e-3) then
|
|
|
480 |
* k =kh
|
|
|
481 |
* kp1=kh
|
|
|
482 |
* else
|
|
|
483 |
k =min0(int(rk),n3-1)
|
|
|
484 |
kp1=k+1
|
|
|
485 |
* endif
|
|
|
486 |
|
|
|
487 |
if (k.eq.kp1) then
|
|
|
488 |
c no interpolation in k
|
|
|
489 |
if ((i.eq.ip1).and.(j.eq.jp1)) then
|
|
|
490 |
c no interpolation at all
|
|
|
491 |
if (misdat.eq.ar(i,j,k)) then
|
|
|
492 |
int3dm=misdat
|
|
|
493 |
else
|
|
|
494 |
int3dm=ar(i,j,k)
|
|
|
495 |
endif
|
|
|
496 |
c print *,'int3dm 00: ',rid,rjd,rkd,int3dm
|
|
|
497 |
else
|
|
|
498 |
c horizontal interpolation only
|
|
|
499 |
if ((misdat.eq.ar(i ,j ,k )).or.
|
|
|
500 |
& (misdat.eq.ar(i ,jp1,k )).or.
|
|
|
501 |
& (misdat.eq.ar(ip1,j ,k )).or.
|
|
|
502 |
& (misdat.eq.ar(ip1,jp1,k ))) then
|
|
|
503 |
int3dm=misdat
|
|
|
504 |
else
|
|
|
505 |
frac0i=ri-float(i)
|
|
|
506 |
frac0j=rj-float(j)
|
|
|
507 |
frac1i=1.-frac0i
|
|
|
508 |
frac1j=1.-frac0j
|
|
|
509 |
int3dm = ar(i ,j ,k ) * frac1i * frac1j
|
|
|
510 |
& + ar(i ,jp1,k ) * frac1i * frac0j
|
|
|
511 |
& + ar(ip1,j ,k ) * frac0i * frac1j
|
|
|
512 |
& + ar(ip1,jp1,k ) * frac0i * frac0j
|
|
|
513 |
c print *,'int3dm 10: ',rid,rjd,rkd,int3dm
|
|
|
514 |
endif
|
|
|
515 |
endif
|
|
|
516 |
else
|
|
|
517 |
frac0k=rk-float(k)
|
|
|
518 |
frac1k=1.-frac0k
|
|
|
519 |
if ((i.eq.ip1).and.(j.eq.jp1)) then
|
|
|
520 |
c vertical interpolation only
|
|
|
521 |
if ((misdat.eq.ar(i ,j ,k )).or.
|
|
|
522 |
& (misdat.eq.ar(i ,j ,kp1))) then
|
|
|
523 |
int3dm=misdat
|
|
|
524 |
else
|
|
|
525 |
int3dm = ar(i ,j ,k ) * frac1k
|
|
|
526 |
& + ar(i ,j ,kp1) * frac0k
|
|
|
527 |
c print *,'int3dm 01: ',rid,rjd,rkd,int3dm
|
|
|
528 |
endif
|
|
|
529 |
else
|
|
|
530 |
c full 3d interpolation
|
|
|
531 |
if ((misdat.eq.ar(i ,j ,k )).or.
|
|
|
532 |
& (misdat.eq.ar(i ,jp1,k )).or.
|
|
|
533 |
& (misdat.eq.ar(ip1,j ,k )).or.
|
|
|
534 |
& (misdat.eq.ar(ip1,jp1,k )).or.
|
|
|
535 |
& (misdat.eq.ar(i ,j ,kp1)).or.
|
|
|
536 |
& (misdat.eq.ar(i ,jp1,kp1)).or.
|
|
|
537 |
& (misdat.eq.ar(ip1,j ,kp1)).or.
|
|
|
538 |
& (misdat.eq.ar(ip1,jp1,kp1))) then
|
|
|
539 |
int3dm=misdat
|
|
|
540 |
else
|
|
|
541 |
frac0i=ri-float(i)
|
|
|
542 |
frac0j=rj-float(j)
|
|
|
543 |
frac1i=1.-frac0i
|
|
|
544 |
frac1j=1.-frac0j
|
|
|
545 |
int3dm = ar(i ,j ,k ) * frac1i * frac1j * frac1k
|
|
|
546 |
& + ar(i ,jp1,k ) * frac1i * frac0j * frac1k
|
|
|
547 |
& + ar(ip1,j ,k ) * frac0i * frac1j * frac1k
|
|
|
548 |
& + ar(ip1,jp1,k ) * frac0i * frac0j * frac1k
|
|
|
549 |
& + ar(i ,j ,kp1) * frac1i * frac1j * frac0k
|
|
|
550 |
& + ar(i ,jp1,kp1) * frac1i * frac0j * frac0k
|
|
|
551 |
& + ar(ip1,j ,kp1) * frac0i * frac1j * frac0k
|
|
|
552 |
& + ar(ip1,jp1,kp1) * frac0i * frac0j * frac0k
|
|
|
553 |
c print *,'int3dm 11: ',rid,rjd,rkd,int3dm
|
|
|
554 |
endif
|
|
|
555 |
endif
|
|
|
556 |
endif
|
|
|
557 |
end
|
|
|
558 |
|
|
|
559 |
|
|
|
560 |
subroutine pottemp(pt,t,sp,ie,je,ke,ak,bk)
|
|
|
561 |
c ==========================================
|
|
|
562 |
|
|
|
563 |
c argument declaration
|
|
|
564 |
integer ie,je,ke
|
|
|
565 |
real pt(ie,je,ke),t(ie,je,ke),sp(ie,je),
|
|
|
566 |
> ak(ke),bk(ke)
|
|
|
567 |
|
|
|
568 |
c variable declaration
|
|
|
569 |
integer i,j,k
|
|
|
570 |
real rdcp,tzero
|
|
|
571 |
data rdcp,tzero /0.286,273.15/
|
|
|
572 |
|
|
|
573 |
c statement-functions for the computation of pressure
|
|
|
574 |
real pp,psrf
|
|
|
575 |
integer is
|
|
|
576 |
pp(is)=ak(is)+bk(is)*psrf
|
|
|
577 |
|
|
|
578 |
c computation of potential temperature
|
|
|
579 |
do i=1,ie
|
|
|
580 |
do j=1,je
|
|
|
581 |
psrf=sp(i,j)
|
|
|
582 |
do k=1,ke
|
|
|
583 |
c distinction of temperature in K and deg C
|
|
|
584 |
if (t(i,j,k).lt.100.) then
|
|
|
585 |
pt(i,j,k)=(t(i,j,k)+tzero)*( (1000./pp(k))**rdcp )
|
|
|
586 |
else
|
|
|
587 |
pt(i,j,k)=t(i,j,k)*( (1000./pp(k))**rdcp )
|
|
|
588 |
endif
|
|
|
589 |
enddo
|
|
|
590 |
enddo
|
|
|
591 |
enddo
|
|
|
592 |
end
|
|
|
593 |
|
|
|
594 |
subroutine pres(pr,sp,ie,je,ke,ak,bk)
|
|
|
595 |
c =====================================
|
|
|
596 |
c argument declaration
|
|
|
597 |
integer ie,je,ke
|
|
|
598 |
real,intent(OUT) :: pr(ie,je,ke)
|
|
|
599 |
real,intent(IN) :: sp(ie,je)
|
|
|
600 |
real,intent(IN) :: ak(ke),bk(ke)
|
|
|
601 |
|
|
|
602 |
c variable declaration
|
|
|
603 |
integer i,j,k
|
|
|
604 |
|
|
|
605 |
c computation pressure
|
|
|
606 |
do i=1,ie
|
|
|
607 |
do j=1,je
|
|
|
608 |
do k=1,ke
|
|
|
609 |
pr(i,j,k)=ak(k)+bk(k)*sp(i,j)
|
|
|
610 |
enddo
|
|
|
611 |
enddo
|
|
|
612 |
enddo
|
|
|
613 |
end
|
|
|
614 |
REAL FUNCTION PHTOPHS (PHI, LAM, POLPHI, POLLAM)
|
|
|
615 |
C
|
|
|
616 |
C%Z% Modul %M%, V%I% vom %G%, extrahiert am %H%
|
|
|
617 |
C
|
|
|
618 |
C**** PHTOPHS - FC:UMRECHNUNG DER WAHREN GEOGRAPHISCHEN BREITE PHI
|
|
|
619 |
C**** AUF EINEM PUNKT MIT DEN KOORDINATEN (PHIS, LAMS)
|
|
|
620 |
C**** IM ROTIERTEN SYSTEM. DER NORDPOL DES SYSTEMS HAT
|
|
|
621 |
C**** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
622 |
C** AUFRUF : PHI = PHTOPHS (PHI, LAM, POLPHI, POLLAM)
|
|
|
623 |
C** ENTRIES : KEINE
|
|
|
624 |
C** ZWECK : UMRECHNUNG DER WAHREN GEOGRAPHISCHEN BREITE PHI AUF
|
|
|
625 |
C** EINEM PUNKT MIT DEN KOORDINATEN (PHIS, LAMS) IM
|
|
|
626 |
C** ROTIERTEN SYSTEM. DER NORDPOL DIESES SYSTEMS HAT
|
|
|
627 |
C** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
628 |
C** VERSIONS-
|
|
|
629 |
C** DATUM : 03.05.90
|
|
|
630 |
C**
|
|
|
631 |
C** EXTERNALS: KEINE
|
|
|
632 |
C** EINGABE-
|
|
|
633 |
C** PARAMETER: PHI REAL BREITE DES PUNKTES IM GEOGR. SYSTEM
|
|
|
634 |
C** LAM REAL LAENGE DES PUNKTES IM GEOGR. SYSTEM
|
|
|
635 |
C** POLPHI REAL GEOGR.BREITE DES N-POLS DES ROT. SYSTEMS
|
|
|
636 |
C** POLLAM REAL GEOGR.LAENGE DES N-POLS DES ROT. SYSTEMS
|
|
|
637 |
C** AUSGABE-
|
|
|
638 |
C** PARAMETER: ROTIERTE BREITE PHIS ALS WERT DER FUNKTION
|
|
|
639 |
C** ALLE WINKEL IN GRAD (NORDEN>0, OSTEN>0)
|
|
|
640 |
C**
|
|
|
641 |
C** COMMON-
|
|
|
642 |
C** BLOECKE : KEINE
|
|
|
643 |
C**
|
|
|
644 |
C** FEHLERBE-
|
|
|
645 |
C** HANDLUNG : KEINE
|
|
|
646 |
C** VERFASSER: G. DE MORSIER
|
|
|
647 |
|
|
|
648 |
REAL LAM,PHI,POLPHI,POLLAM
|
|
|
649 |
|
|
|
650 |
DATA ZRPI18 , ZPIR18 / 57.2957795 , 0.0174532925 /
|
|
|
651 |
|
|
|
652 |
ZSINPOL = SIN(ZPIR18*POLPHI)
|
|
|
653 |
ZCOSPOL = COS(ZPIR18*POLPHI)
|
|
|
654 |
ZLAMPOL = ZPIR18*POLLAM
|
|
|
655 |
ZPHI = ZPIR18*PHI
|
|
|
656 |
ZLAM = LAM
|
|
|
657 |
IF(ZLAM.GT.180.0) ZLAM = ZLAM - 360.0
|
|
|
658 |
ZLAM = ZPIR18*ZLAM
|
|
|
659 |
ZARG = ZCOSPOL*COS(ZPHI)*COS(ZLAM-ZLAMPOL) + ZSINPOL*SIN(ZPHI)
|
|
|
660 |
|
|
|
661 |
PHTOPHS = ZRPI18*ASIN(ZARG)
|
|
|
662 |
|
|
|
663 |
RETURN
|
|
|
664 |
END
|
|
|
665 |
REAL FUNCTION PHSTOPH (PHIS, LAMS, POLPHI, POLLAM)
|
|
|
666 |
C
|
|
|
667 |
C%Z% Modul %M%, V%I% vom %G%, extrahiert am %H%
|
|
|
668 |
C
|
|
|
669 |
C**** PHSTOPH - FC:BERECHNUNG DER WAHREN GEOGRAPHISCHEN BREITE FUER
|
|
|
670 |
C**** EINEN PUNKT MIT DEN KOORDINATEN (PHIS, LAMS) IM
|
|
|
671 |
C**** ROTIERTEN SYSTEM. DER NORDPOL DIESES SYSTEMS HAT
|
|
|
672 |
C**** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
673 |
C** AUFRUF : PHI = PHSTOPH (PHIS, LAMS, POLPHI, POLLAM)
|
|
|
674 |
C** ENTRIES : KEINE
|
|
|
675 |
C** ZWECK : BERECHNUNG DER WAHREN GEOGRAPHISCHEN BREITE FUER
|
|
|
676 |
C** EINEN PUNKT MIT DEN KOORDINATEN (PHIS, LAMS) IM
|
|
|
677 |
C** ROTIERTEN SYSTEM. DER NORDPOL DIESES SYSTEMS HAT
|
|
|
678 |
C** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
679 |
C** VERSIONS-
|
|
|
680 |
C** DATUM : 03.05.90
|
|
|
681 |
C**
|
|
|
682 |
C** EXTERNALS: KEINE
|
|
|
683 |
C** EINGABE-
|
|
|
684 |
C** PARAMETER: PHIS REAL GEOGR. BREITE DES PUNKTES IM ROT.SYS.
|
|
|
685 |
C** LAMS REAL GEOGR. LAENGE DES PUNKTES IM ROT.SYS.
|
|
|
686 |
C** POLPHI REAL WAHRE GEOGR. BREITE DES NORDPOLS
|
|
|
687 |
C** POLLAM REAL WAHRE GEOGR. LAENGE DES NORDPOLS
|
|
|
688 |
C** AUSGABE-
|
|
|
689 |
C** PARAMETER: WAHRE GEOGRAPHISCHE BREITE ALS WERT DER FUNKTION
|
|
|
690 |
C** ALLE WINKEL IN GRAD (NORDEN>0, OSTEN>0)
|
|
|
691 |
C**
|
|
|
692 |
C** COMMON-
|
|
|
693 |
C** BLOECKE : KEINE
|
|
|
694 |
C**
|
|
|
695 |
C** FEHLERBE-
|
|
|
696 |
C** HANDLUNG : KEINE
|
|
|
697 |
C** VERFASSER: D.MAJEWSKI
|
|
|
698 |
|
|
|
699 |
REAL LAMS,PHIS,POLPHI,POLLAM
|
|
|
700 |
|
|
|
701 |
DATA ZRPI18 , ZPIR18 / 57.2957795 , 0.0174532925 /
|
|
|
702 |
|
|
|
703 |
SINPOL = SIN(ZPIR18*POLPHI)
|
|
|
704 |
COSPOL = COS(ZPIR18*POLPHI)
|
|
|
705 |
ZPHIS = ZPIR18*PHIS
|
|
|
706 |
ZLAMS = LAMS
|
|
|
707 |
IF(ZLAMS.GT.180.0) ZLAMS = ZLAMS - 360.0
|
|
|
708 |
ZLAMS = ZPIR18*ZLAMS
|
|
|
709 |
ARG = COSPOL*COS(ZPHIS)*COS(ZLAMS) + SINPOL*SIN(ZPHIS)
|
|
|
710 |
|
|
|
711 |
PHSTOPH = ZRPI18*ASIN(ARG)
|
|
|
712 |
|
|
|
713 |
RETURN
|
|
|
714 |
END
|
|
|
715 |
REAL FUNCTION LMTOLMS (PHI, LAM, POLPHI, POLLAM)
|
|
|
716 |
C
|
|
|
717 |
C%Z% Modul %M%, V%I% vom %G%, extrahiert am %H%
|
|
|
718 |
C
|
|
|
719 |
C**** LMTOLMS - FC:UMRECHNUNG DER WAHREN GEOGRAPHISCHEN LAENGE LAM
|
|
|
720 |
C**** AUF EINEM PUNKT MIT DEN KOORDINATEN (PHIS, LAMS)
|
|
|
721 |
C**** IM ROTIERTEN SYSTEM. DER NORDPOL DES SYSTEMS HAT
|
|
|
722 |
C**** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
723 |
C** AUFRUF : LAM = LMTOLMS (PHI, LAM, POLPHI, POLLAM)
|
|
|
724 |
C** ENTRIES : KEINE
|
|
|
725 |
C** ZWECK : UMRECHNUNG DER WAHREN GEOGRAPHISCHEN LAENGE LAM AUF
|
|
|
726 |
C** EINEM PUNKT MIT DEN KOORDINATEN (PHIS, LAMS) IM
|
|
|
727 |
C** ROTIERTEN SYSTEM. DER NORDPOL DIESES SYSTEMS HAT
|
|
|
728 |
C** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
729 |
C** VERSIONS-
|
|
|
730 |
C** DATUM : 03.05.90
|
|
|
731 |
C**
|
|
|
732 |
C** EXTERNALS: KEINE
|
|
|
733 |
C** EINGABE-
|
|
|
734 |
C** PARAMETER: PHI REAL BREITE DES PUNKTES IM GEOGR. SYSTEM
|
|
|
735 |
C** LAM REAL LAENGE DES PUNKTES IM GEOGR. SYSTEM
|
|
|
736 |
C** POLPHI REAL GEOGR.BREITE DES N-POLS DES ROT. SYSTEMS
|
|
|
737 |
C** POLLAM REAL GEOGR.LAENGE DES N-POLS DES ROT. SYSTEMS
|
|
|
738 |
C** AUSGABE-
|
|
|
739 |
C** PARAMETER: WAHRE GEOGRAPHISCHE LAENGE ALS WERT DER FUNKTION
|
|
|
740 |
C** ALLE WINKEL IN GRAD (NORDEN>0, OSTEN>0)
|
|
|
741 |
C**
|
|
|
742 |
C** COMMON-
|
|
|
743 |
C** BLOECKE : KEINE
|
|
|
744 |
C**
|
|
|
745 |
C** FEHLERBE-
|
|
|
746 |
C** HANDLUNG : KEINE
|
|
|
747 |
C** VERFASSER: G. DE MORSIER
|
|
|
748 |
|
|
|
749 |
REAL LAM,PHI,POLPHI,POLLAM
|
|
|
750 |
|
|
|
751 |
DATA ZRPI18 , ZPIR18 / 57.2957795 , 0.0174532925 /
|
|
|
752 |
|
|
|
753 |
ZSINPOL = SIN(ZPIR18*POLPHI)
|
|
|
754 |
ZCOSPOL = COS(ZPIR18*POLPHI)
|
|
|
755 |
ZLAMPOL = ZPIR18*POLLAM
|
|
|
756 |
ZPHI = ZPIR18*PHI
|
|
|
757 |
ZLAM = LAM
|
|
|
758 |
IF(ZLAM.GT.180.0) ZLAM = ZLAM - 360.0
|
|
|
759 |
ZLAM = ZPIR18*ZLAM
|
|
|
760 |
|
|
|
761 |
ZARG1 = - SIN(ZLAM-ZLAMPOL)*COS(ZPHI)
|
|
|
762 |
ZARG2 = - ZSINPOL*COS(ZPHI)*COS(ZLAM-ZLAMPOL)+ZCOSPOL*SIN(ZPHI)
|
|
|
763 |
IF (ABS(ZARG2).LT.1.E-30) THEN
|
|
|
764 |
IF (ABS(ZARG1).LT.1.E-30) THEN
|
|
|
765 |
LMTOLMS = 0.0
|
|
|
766 |
ELSEIF (ZARG1.GT.0.) THEN
|
|
|
767 |
LMTOLMS = 90.0
|
|
|
768 |
ELSE
|
|
|
769 |
LMTOLMS = -90.0
|
|
|
770 |
ENDIF
|
|
|
771 |
ELSE
|
|
|
772 |
LMTOLMS = ZRPI18*ATAN2(ZARG1,ZARG2)
|
|
|
773 |
ENDIF
|
|
|
774 |
|
|
|
775 |
RETURN
|
|
|
776 |
END
|
|
|
777 |
REAL FUNCTION LMSTOLM (PHIS, LAMS, POLPHI, POLLAM)
|
|
|
778 |
C
|
|
|
779 |
C%Z% Modul %M%, V%I% vom %G%, extrahiert am %H%
|
|
|
780 |
C
|
|
|
781 |
C**** LMSTOLM - FC:BERECHNUNG DER WAHREN GEOGRAPHISCHEN LAENGE FUER
|
|
|
782 |
C**** EINEN PUNKT MIT DEN KOORDINATEN (PHIS, LAMS)
|
|
|
783 |
C**** IM ROTIERTEN SYSTEM. DER NORDPOL DES SYSTEMS HAT
|
|
|
784 |
C**** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
785 |
C** AUFRUF : LAM = LMSTOLM (PHIS, LAMS, POLPHI, POLLAM)
|
|
|
786 |
C** ENTRIES : KEINE
|
|
|
787 |
C** ZWECK : BERECHNUNG DER WAHREN GEOGRAPHISCHEN LAENGE FUER
|
|
|
788 |
C** EINEN PUNKT MIT DEN KOORDINATEN (PHIS, LAMS)
|
|
|
789 |
C** IM ROTIERTEN SYSTEM. DER NORDPOL DIESES SYSTEMS HAT
|
|
|
790 |
C** DIE WAHREN KOORDINATEN (POLPHI, POLLAM)
|
|
|
791 |
C** VERSIONS-
|
|
|
792 |
C** DATUM : 03.05.90
|
|
|
793 |
C**
|
|
|
794 |
C** EXTERNALS: KEINE
|
|
|
795 |
C** EINGABE-
|
|
|
796 |
C** PARAMETER: PHIS REAL GEOGR. BREITE DES PUNKTES IM ROT.SYS.
|
|
|
797 |
C** LAMS REAL GEOGR. LAENGE DES PUNKTES IM ROT.SYS.
|
|
|
798 |
C** POLPHI REAL WAHRE GEOGR. BREITE DES NORDPOLS
|
|
|
799 |
C** POLLAM REAL WAHRE GEOGR. LAENGE DES NORDPOLS
|
|
|
800 |
C** AUSGABE-
|
|
|
801 |
C** PARAMETER: WAHRE GEOGRAPHISCHE LAENGE ALS WERT DER FUNKTION
|
|
|
802 |
C** ALLE WINKEL IN GRAD (NORDEN>0, OSTEN>0)
|
|
|
803 |
C**
|
|
|
804 |
C** COMMON-
|
|
|
805 |
C** BLOECKE : KEINE
|
|
|
806 |
C**
|
|
|
807 |
C** FEHLERBE-
|
|
|
808 |
C** HANDLUNG : KEINE
|
|
|
809 |
C** VERFASSER: D.MAJEWSKI
|
|
|
810 |
|
|
|
811 |
REAL LAMS,PHIS,POLPHI,POLLAM
|
|
|
812 |
|
|
|
813 |
DATA ZRPI18 , ZPIR18 / 57.2957795 , 0.0174532925 /
|
|
|
814 |
|
|
|
815 |
ZSINPOL = SIN(ZPIR18*POLPHI)
|
|
|
816 |
ZCOSPOL = COS(ZPIR18*POLPHI)
|
|
|
817 |
ZLAMPOL = ZPIR18*POLLAM
|
|
|
818 |
ZPHIS = ZPIR18*PHIS
|
|
|
819 |
ZLAMS = LAMS
|
|
|
820 |
IF(ZLAMS.GT.180.0) ZLAMS = ZLAMS - 360.0
|
|
|
821 |
ZLAMS = ZPIR18*ZLAMS
|
|
|
822 |
|
|
|
823 |
ZARG1 = SIN(ZLAMPOL)*(- ZSINPOL*COS(ZLAMS)*COS(ZPHIS) +
|
|
|
824 |
1 ZCOSPOL* SIN(ZPHIS)) -
|
|
|
825 |
2 COS(ZLAMPOL)* SIN(ZLAMS)*COS(ZPHIS)
|
|
|
826 |
ZARG2 = COS(ZLAMPOL)*(- ZSINPOL*COS(ZLAMS)*COS(ZPHIS) +
|
|
|
827 |
1 ZCOSPOL* SIN(ZPHIS)) +
|
|
|
828 |
2 SIN(ZLAMPOL)* SIN(ZLAMS)*COS(ZPHIS)
|
|
|
829 |
IF (ABS(ZARG2).LT.1.E-30) THEN
|
|
|
830 |
IF (ABS(ZARG1).LT.1.E-30) THEN
|
|
|
831 |
LMSTOLM = 0.0
|
|
|
832 |
ELSEIF (ZARG1.GT.0.) THEN
|
|
|
833 |
LMSTOLAM = 90.0
|
|
|
834 |
ELSE
|
|
|
835 |
LMSTOLAM = -90.0
|
|
|
836 |
ENDIF
|
|
|
837 |
ELSE
|
|
|
838 |
LMSTOLM = ZRPI18*ATAN2(ZARG1,ZARG2)
|
|
|
839 |
ENDIF
|
|
|
840 |
|
|
|
841 |
RETURN
|
|
|
842 |
END
|