#! /bin/csh -f
# -----------------------------------------
# UNIX Script to run galaxy code
# -----------------------------------------
#
# Usage: 1) Edit six user-defined quantities found below
#        2) Run code with 'nice go_galaxy &' --> output in 'time_used'
# -----------------------------------------------------------------------
# Six user-defined quantities:
#           Directory where the run is made (=directory of this file):
#set    drun=/home/katkov/starburst99/output/
#           Name of input file:
set  ninput=$1
#           Name and extension number of output files:
#           --> files will be: noutput.colornext, noutput.quantnext etc.
set noutput=$2
set    next=$3
#           Directory where code is:
set   dcode=/db1/Data/starburst99/
#          Name of code: 
set   ncode=galaxy_ik
#           Directory where libraries are:
set   dlib=/db1/Data/starburst99/
#- - - - - - - DO NOT MODIFY below this line - - - - - - - - - - - - - -

#cd $drun
# A) Create links (assign) to directories with input files
	# Tracks + Spectral type calibration:
if (!(-e tracks)) ln -s $dlib/tracks/ tracks
	# Atmosphere models:
if (!(-e lejeune)) ln -s $dlib/lejeune/ lejeune
	# Spectral libraries:
if (!(-e auxil)) ln -s $dlib/auxil/ auxil

# B) Link input file, RUN code, and save output data
echo "Job on `hostname` started at `date`" >time_used_$2$3
echo " ">>time_used_$2$3

if (-f fort.1) then
    rm fort.1
endif
if (-e $ninput) ln -s $ninput fort.1
(/usr/bin/time $dcode/$ncode) >>& time_used_$2$3
echo " ">>time_used_$2$3

$dcode/save_output $noutput $next >>time_used_$2$3
echo "Done at `date`" >>time_used_$2$3
