#!/bin/csh -f
#+
# fcs_logfile -- return name of the most recently-updated FCS logfile
#
# Purpose:
#	Return the name of the most-recently updated logfile in the
#	current FCS output directory.
#
# Usage:
#	fcs_logfile
# 
# Arguments:
#	none
# 
# Output:
#	Full disk name of the logfile is written to STDOUT.
# 
# Restrictions:
#	None
# 
# Exit values:
#	 0 = normal completion
#	 1 = wrong number of arguments
#
# Example:
#
#-
# Modification history:
#	2003-Feb-05	GDW	Original version
#-----------------------------------------------------------------------

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

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

# get FCS outdir...
set outdir = `show -s deifcs -terse outdir`

# check for no logfiles in outdir...
ls -1t $outdir/fcs*.log >& /dev/null
if ( $status ) then
    exit 1
endif

# determine the most recent logfile in the directory...
set logfiles = `ls -1t $outdir/fcs*.log`
if ( $#logfiles < 1 ) then
    exit 1
endif
echo $logfiles[1]
