UPP (develop)
Loading...
Searching...
No Matches
POLEAVG.f
1 SUBROUTINE poleavg(IM,JM,JSTA,JEND,SMALL,COSL,SPVAL,VAR)
2! This program averages scalor fields at pole points
3! 13-05-06 Shrinivas Moorthi : Added protection from divide by zero for icount
4 implicit none
5
6! INCLUDE 'mpif.h'
7 INTEGER,intent(in) :: IM,JM,JSTA,JEND
8 REAL,intent(in) :: SMALL,SPVAL
9 REAL,intent(in) :: COSL(IM,JSTA:JEND)
10 REAL,intent(inout) :: VAR(IM,JSTA:JEND)
11 INTEGER I,JJ,ICOUNT
12 REAL WORK, tem
13!
14 jj = 1
15 IF(jj>=jsta .and. jj<=jend)then
16 IF(cosl(1,jj) < small)then
17 work = 0.
18 icount = 0
19 DO i=1,im
20 IF(var(i,jj) /= spval)THEN
21 work = var(i,jj) + work
22 icount = icount + 1
23 END IF
24 END DO
25 if (icount > 0) then
26 tem = work/icount
27 DO i=1,im
28 var(i,jj) = tem
29 END DO
30 endif
31 END IF
32 END IF
33 jj = jm
34 IF(jj>=jsta .and. jj<=jend)then
35 IF(cosl(1,jj) < small)then
36 work = 0.
37 icount = 0
38 DO i=1,im
39 IF(var(i,jj) /= spval)THEN
40 work = var(i,jj) + work
41 icount = icount + 1
42 END IF
43 END DO
44 if (icount > 0) then
45 tem = work/icount
46 DO i=1,im
47 var(i,jj) = tem
48 END DO
49 endif
50 END IF
51 END IF
52 RETURN
53 END