awips2/nativeLib/rary.meteorological/src/maxmin.f
root 06a8b51d6d Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 64fa9254b946eae7e61bbc3f513b7c3696c4f54f
2012-01-06 08:55:05 -06:00

43 lines
931 B
Fortran
Executable file

c
c
subroutine max_min(a,b,result,mni,ni,nj,mode)
c
c..... Routine to find the max or min of two fields. mode>0 means max,
c..... mode<0 means min.
c
c..... Original : 06-25-02 Borrowed from addaray
c
implicit none
integer mni, ni, nj, i, j
real flag, bad
parameter(flag = 1.e37)
real a(mni,nj), b(mni,nj), result(mni,nj)
integer mode
c
bad = 1.e36
if (mode.gt.0) Then
do 1 j=1,nj
do 1 i=1,ni
if (a(i,j).gt.bad) then
result(i,j) = b(i,j)
else if (b(i,j).gt.bad) then
result(i,j) = a(i,j)
else if (a(i,j).gt.b(i,j)) then
result(i,j) = a(i,j)
else
result(i,j) = b(i,j)
endif
1 continue
Else
do 2 j=1,nj
do 2 i=1,ni
if (a(i,j).lt.b(i,j)) then
result(i,j) = a(i,j)
else
result(i,j) = b(i,j)
endif
2 continue
Endif
Return
end