#!/bin/csh
#
#
#
if($#argv < 2) then
        echo "  "
        echo "    This command requires two arguments:"
        echo "      1 - GSLIB PostScript plot file, and"
        echo "      2 - output file"
        echo "  "
        exit
endif
set OUTFILE=$argv[$#argv]
set thedate = `date`


#                    Header and Footer

cat<<END>$OUTFILE
%!

% Created by: `whoami` 
% Date      : $thedate
% Directory : `pwd`

% To import this file into other PostScript documents:
%     1. delete "Header and Footer"
%     2. delete final "showpage" (last line of this file)
%     3. uncomment the EOF (last line in file), i.e., remove leading %_
%     4. uncomment the line below "Uncomment the following for EPS"
%     5. uncomment the EPS Header, i.e., remove leading %_
%     6. delete all lines above "%!PS-Adobe-3.0 EPSF-3.0"
%     7. the result will be 6.0" wide by 4.5" high

%                       EPS Header

%Uncomment the following seven lines for EPS
% %!PS-Adobe-3.0 EPSF-3.0
% %%BoundingBox: 0 0 432 324
% %%Creator: GSLIB
% %%Title:   Combined with plot1 
% %%CreationDate: 
% %%EndComments
% -1.25 72 mul -3.0 72 mul translate

%                    Header and Footer

/rtext{ dup stringwidth pop -1 div 0 rmoveto show } def
/ctext{ dup stringwidth pop -2 div 0 rmoveto show } def
/ltext{show} def
/Times-Bold findfont 24 scalefont setfont
4.25 72 mul 10.2 72 mul moveto ( ) ctext          % Upper centered title
/Times findfont 9 scalefont setfont
0.50 72 mul  0.5 72 mul moveto ($OUTFILE ) ltext
4.25 72 mul  0.5 72 mul moveto ( ) ctext          % Lower centered label
8.00 72 mul  0.5 72 mul moveto ($thedate ) rtext
END

cat<<END>>$OUTFILE

%                     First Plot File

gsave 1.25 72 mul 3.0 72 mul translate 1.5 1.5 scale
END
sed -e "1,11 d" -e "s/\%\%EOF//g" -e "$ d" < $1 >> $OUTFILE
cat<<END>>$OUTFILE
grestore
% %%EOF
showpage
END
