

! Benchmark for sort and sample external Functions
! ACM 5/99

use coads_climatology
set region/x=141/y=39/z=0/l=1:6

list sst
list samplel(sst, {1,3,5})

let tsorted_indices = sortl(sst)
let tsorted_sst = samplel(sst, tsorted_indices)

list tsorted_indices, tsorted_sst


! test sortt with data containing bad/missing data.

can region 

! use  "/home/ja4/kobrien/FERRET/bench/coads_vwnd.cdf"
use  coads_vwnd.cdf
set region/i=90/j=65
plot vwnd

let tsorted_indices = sortl(vwnd)
let tsorted_wnd = samplel(vwnd, tsorted_indices)
list tsorted_indices, tsorted_wnd

let len = tsorted_wnd[l=@ngd]
list len

!  This illustrates a problem with BAIL OUT of the function with
!  out-of-range indices:

 let tsorted_indices = sortl(vwnd) + 90
 let tsorted_wnd = samplel(vwnd, tsorted_indices)
 list tsorted_indices, tsorted_wnd

