#!/bin/csh
#
# make double precision version of mul22 source code
# 95-08-17  Mats Carlsson
# 
cd ../source_dp
#
# delete previous files
#
echo -n "Will delete all old source files in directory source_dp, is that OK (y/n)? "
if ($< != "y") then 
  exit
endif

\rm ../source_dp/*.f
\rm ../source_dp/C*
\rm ../source_dp/PREC
\rm ../source_dp/makefile
#
# copy over include files and change REAL to REAL*8
#
echo "Copying over include files and changing REAL to REAL*8"
cp ../source/C* .
if (! -e PARAM) then
  cp ../source/PARAM .
endif
if (! -e PARAMW) then
  cp ../source/PARAMW .
endif
cp ../source/PREC.dp PREC

foreach f (C*)
cat $f | sed -e '/REAL /s/REAL /REAL*8 /' >! a.jou
\mv a.jou $f
end
#
# copy over source files
#
echo "Linking over source files that are identical in sp and dp"
ln -s ../source/mul22_g.f .
ln -s ../source/mul22_l.f .
ln -s ../source/mul22_subg.f .
ln -s ../source/mul22_subl.f .
ln -s ../source/mul22_sub.f .
#ln -s ../source/mul22_opaco.f .
#ln -s ../source/mul22_write.f .
ln -s ../source/makefile .
#
echo "Copying and changing source files that differ between sp and dp"
echo "(mul22_opacu.f mul22_writeidl.f)"
#
# use mul22_writeidldbl.f as mul22_writeidl.f
# 
ln -s ../source/mul22_writeidldbl.f mul22_writeidl.f
#
# change REAL to REAL*8 in mul22_opacu.f (should be the only
# source file with non-include-file-variables that do not
# conform to the FORTRAN implicit typing)
#
cat ../source/mul22_opacu.f | sed -e '/REAL /s/REAL /REAL*8 /' >! mul22_opacu.f
#
# change record length specification in bconst
#
cat ../source/mul22_bconst.f | sed -e '/DATA NEWSTA,IRC/s/,1/,2/' >! a.tmp
cat a.tmp | sed -e '/DATA NEWSTA,IRC/s/,4/,8/' >! mul22_bconst.f
\rm a.tmp
cd ../source



