#! /bin/csh
#++++++++++++++++
#.IDENTIFICATION show_model
#.LANGUAGE       C-shell
#.AUTHOR         CDS Catalogues Service
#.ENVIRONMENT    
#.KEYWORDS       
#.VERSION  1.0   03-Jan-2001
#.PURPOSE        Show a model file as a table
#.COMMENTS       Arg1 = file name, arg2=T arg3=logg arg4=He/H
#		"fcat" is a program which executes cat, zcat or gzcat
#			depending on the compression status of the file
#----------------
set xqt = /tmp/A+A.363.1051.exe		# Program to execute
if (! -x $xqt) then
    if (-x /opt/SUNWspro/bin/) then
	setenv PATH ${PATH}:/opt/SUNWspro/bin
    endif
    fcat mod_cds.f > /tmp/$$.f
    ( cd /tmp && f77 $$.f -o $xqt )
endif

if ("$5" == "gif") then
    #echo "Contents-type: text/plain" ; echo ""
    echo "Content-type: image/gif"; echo ""
    fcat models/$1 | $xqt | gawk '/T-p diagram/{p=1;next}{if(p>0)print}' \
    | tee /tmp/XXXgif \
    | graph -f 0.0325 -h 0.75 -w 0.75 -u 0.125 -r 0.15 --title-font-size 0.05 \
    -T gif -C -L "T\sbeff\eb=$2 log(g)=$3 He/H=$4" -X 'log(T)' -Y 'log(p)'
    exit 0
endif

# The program uses a WMM argument, 2.173e-24
#setenv WMM "2.173e-24"
if (! $?QUERY_STRING) setenv QUERY_STRING ""

echo "{\bf Model for T_{eff}=$2\d K, log(g)=$3, He/H=$4}" ; 
echo "\quad ({\em file } {\tt models/$1})" ; 
echo "\thickrule\begin{alltty}"; 
fcat models/$1 | $xqt | gawk -v q="$QUERY_STRING" '/T-p diagram/{\
    if (q != "") printf("\\tag{IMG ALIGN=right SRC=\"%s?%s\\&gif\"}\n", \
       "/viz-bin/nph-Plot/show_model", q) }{print}'
echo "\end{alltty}\thickrule" 
