#!/bin/csh -f

if($#argv != 1) then
  echo "USAGE: getnframes stem "
  echo '$Id'
  exit 1;
endif

set stem = $argv[1];
set firstslice = `getfirstsliceno $stem`
set st = $status;
if($st) then
  echo "ERROR: cannot find any files with $stem";
  exit 1;
endif

set hdr = `printf "%s_%03d.hdr" $stem $firstslice`
if(! -e $hdr) then
  echo "ERROR: cannot find $hdr"
  exit 1;
endif

set tmp = `cat $hdr`;
set nframes = $tmp[3];

echo $nframes;

exit 0;
##########################################
