#!/bin/csh -f
#+
# fname -- Build full DEIMOS file name from frame number
#
# Purpose:
#	This script takes as input a frame number and outputs the full
#	disk name of the corresponding DEIMOS science image.
#
# Usage:
#	fname n
# 
# Arguments:
#	n = number of the image
# 
# Exit values:
#	 0 = normal completion
#	 1 = wrong number of arguments
#
# Example:
#	To obtain the disk name for the 99th DEIMOS image, type:
#		fname 99
#	Result:
#		/dsk/iraid1/kics/2002jun06/d0606_0099.fits
#-
# Modification history:
#	1997-Sep-09	ARC	Original version
#	2000-Jul-03	GDW	Changed from using 'pformat' to 'awk'
#	2001-May-07	GDW	Changed from using 'awk' to 'printf'
#       2002-Jun-06     GDW     Adapted for DEIMOS
#-----------------------------------------------------------------------

set buf = $0
set cmd = $buf:t
set usage = "Usage: $cmd n"

# verify args...
if ( $#argv != 1 ) then
  printf "$usage\n"
  exit 1
endif

# get frameno from command line...
@ frameno = $1

# Determine the output directory and filename prefix...
set dir = `show -s deiccd -terse outdir`
set filename = `show -s deiccd -terse outfile`
set suffix = ".fits"

# Form the complete filename...
printf "%s/%s%04d%s\n" $dir $filename $frameno $suffix
