NADCON5-ng  0.0.2
NADCON5 Next Generation Documentation
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 1334 of file mymedian5.f.

References indexxd().

Referenced by mymedian5().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: