package Util::Ftool;
##############################################################################
#
# DESCRIPTION: This sub-class adds FTOOLS environment initialization
#
# HISTORY: 1.0 -> 1.1 2001-03-05
# HISTORY: Modified the way the PATH and LD_LIBRARY_PATH environment variables
# HISTORY: are set to make the more robust.
# HISTORY:
# HISTORY: 1.1 -> 2.0 2002-04-18
# HISTORY: Made this a subclass of ParfileTool to better handle FTOOLS
# HISTORY: and HEAdas, not to mention PseudoFtools.
# HISTORY:
# HISTORY: 2.0 -> 2.1 2004-02-11
# HISTORY: The environment method now returns a reference to a hash
# HISTORY:
# HISTORY: 2.1 -> 2.2 2004-10-01
# HISTORY: Now set the TCLRL_LIBDIR environment variable
#
# VERSION: 2.1
#
##############################################################################
use Util::ParfileTool;
@ISA=("Util::ParfileTool");
use strict;
my $INSTALL_DIR;
my @BINS=();
my @LIBS=();
my $SYSPFILES;
my %ENVIRONMENT=();
my $VERSION;
#########################################################################
#
#########################################################################
sub new {
my $self=shift;
my $tool=shift;
$self->SUPER::new($tool,$SYSPFILES, \@BINS, \@LIBS);
} # end of constructor
########################################################################
# Returns a hash of environment variables which must
# be set before running this tool
########################################################################
sub environment {
my $self=shift;
return {%{$self->SUPER::environment()}, %ENVIRONMENT};
} # end of environment method
####################################################################
# This method does all the initialization for this class, given
# the name of the FTOOLS machine-specific instalation directory
####################################################################
sub install_dir {
my $self=shift;
if(@_) {
my $ftools = shift;
$INSTALL_DIR=$ftools;
#####################################################
# set the executable directories, the libraries and
# the parfile directory
#####################################################
@BINS=("$ftools/bin", "$ftools/scripts");
@LIBS=("$ftools/lib");
$SYSPFILES = "$ftools/syspfiles";
##########################################
# parse the FTOOLS version name
##########################################
($VERSION) = $ftools =~ m|/[a-z]*\.([^/]*)/[^/]*$|;
#####################################################
# Set the FTOOLS environment variables
#####################################################
$ENVIRONMENT{FTOOLS}=$ftools;
$ENVIRONMENT{LHEASOFT}=$ftools;
$ENVIRONMENT{LHEA_DATA}="$ftools/../refdata";
$ENVIRONMENT{LHEA_HELP}="$ftools/../help";
$ENVIRONMENT{PGPLOT_FONT}="$ftools/lib/grfont.dat";
$ENVIRONMENT{LHEAPERL}=$^X; # <- perl version running this script
$ENVIRONMENT{FTOOLSINPUT }="stdin";
$ENVIRONMENT{FTOOLSOUTPUT}="stdout";
#####################################################################
# the following is to get rid of the
# readline: warning: rl_prep_terminal: cannot get terminal settings
# error from lcurve, but it is broken in the release version of
# FTOOLS 5.2 . Talk to Bryan Irby about this.
# 2004-10-01 setting this seems to break grppha in 5.3.1
#####################################################################
#$ENVIRONMENT{XPINOREADLINE} = 1;
$ENVIRONMENT{TCLRL_LIBDIR} = "$ftools/lib";
}
return $INSTALL_DIR;
}
##############################################################
# returns the version of the FTOOLS being used.
# Note this version name is derived by parsing the name
# of the FTOOLS instalation directory.
############################################################
sub version {
my $self=shift;
return $VERSION;
}
####################################################
# assemble the error message.
# Override the generic message to specify "FTOOL"
####################################################
sub error_message {
my $self=shift;
my $message="Error from FTOOL $self->{COMMAND} - ".
"exit status $self->{STATUS}";
return $message;
}
1;