NADCON5-ng  0.0.1
NADCON5 Next Generation
mymedian5.f File Reference

Go to the source code of this file.

Functions/Subroutines

program mymedian5
 Program to filter Map Data for GMT Plotting. More...
 
subroutine getmedian (zs, max, inumlo, inumhi, indx, maxppcell, dist, iiival)
 

Function/Subroutine Documentation

subroutine getmedian ( real*8, dimension(max)  zs,
  max,
integer*4  inumlo,
integer*4  inumhi,
integer*4, dimension(max)  indx,
  maxppcell,
real*8, dimension(max)  dist,
  iiival 
)

Definition at line 1330 of file mymedian5.f.

References indexxd().

Referenced by mymedian5().

1330  real*8 zs(max),dist(max)
1331  integer*4 indx(max),indx2(maxppcell)
1332  integer*4 inumlo,inumhi
1333 
1334  real*8 zz(maxppcell)
1335 
1336 
1337 c write(6,1)inumlo,inumhi
1338 c 1 format('Inside getmedian',/,
1339 c *'inumlo,inumhi = ',i8,1x,i8)
1340 
1341 c - When the whole set of "zs" data is sorted by
1342 c - "whichcell", then the "indx" values are our
1343 c - key to that sort. The "zs" data remains
1344 c - in "read order" (1-nkt), but the indx values
1345 c - (also in "read order" point to the sorted
1346 c - order.
1347 
1348 c write(6,*) ' UNSORTED data: '
1349 
1350  nval = inumhi-inumlo+1
1351  iq = 0
1352  do 2 i=inumlo,inumhi
1353  iq = iq + 1
1354  zz(iq) = zs(indx(i))
1355 c write(6,3)i,iq,zz(iq)
1356  2 continue
1357  3 format(i10,1x,i10,1x,f20.10)
1358 
1359 c - Sort this mini vector
1360 c call hpsort(nval,maxppcell,zz)
1361 
1362  call indexxd(nval,maxppcell,zz,indx2)
1363 
1364 c write(6,*) ' SORTED data: '
1365 
1366 c do 4 i=1,nval
1367 c write(6,3)i,indx2(i),zz(indx2(i))
1368 c 4 continue
1369  5 format(i10,1x,f20.10)
1370 
1371 c - True median comes from an odd number of values. If
1372 c - it is even, take the one which sits closest to the
1373 c - center of the cell.
1374  if(mod(nval,2).eq.1)then
1375  ival = (nval+1)/2
1376  else
1377  ival1 = nval/2
1378  ival2 = ival1 + 1
1379 c write(6,*) ' MedianLo = ',zz(indx2(ival1))
1380 c write(6,*) ' MedianHi = ',zz(indx2(ival2))
1381 c write(6,*) ' Dist Lo = ',dist(indx2(ival1))
1382 c write(6,*) ' Dist Hi = ',dist(indx2(ival2))
1383  if(dist(indx2(ival1)).lt.dist(indx2(ival2)))then
1384 c write(6,*) ' Median Set to LO = ',zz(indx2(ival1))
1385  ival = ival1
1386  else
1387 c write(6,*) ' Median Set to HI = ',zz(indx2(ival2))
1388  ival = ival2
1389  endif
1390  endif
1391 
1392 c - Note that "iiival" is the read-order number of the
1393 c - point chosen as median for the cell we're analyzing
1394 c - in this subroutine.
1395 c write(6,*) ' Median = ',zz(indx2(ival))
1396  igood1 = indx2(ival)
1397 c write(6,*) ' ival = ',ival
1398 c write(6,*) ' indx2(ival) = ',indx2(ival)
1399  iival = inumlo + indx2(ival) - 1
1400 c write(6,*) ' iival = ',iival
1401  iiival = indx(iival)
1402 c write(6,*) ' indx(iival) = ',indx(iival)
1403 
1404 
1405  return
subroutine indexxd(n, nd, arr, indx)
Subroutine to perform ?? indexing on floating point data (double precision)
Definition: indexxd.for:20

+ Here is the call graph for this function:

+ Here is the caller graph for this function: