#!/bin/sh # # Commandfile which compiles the sources and installs the executables # This version is written for Linux # Both g77 and f77 or fort77(Red Hat) (compilation via f2c and cc) are supported # echon () { echo $1 | tr -d '\012' } opt=-O # # The directory where Crunch is going to be installed # $cwd in this script # mkdir crunch_1.0 cd crunch_1.0 cwd=`pwd` clear echo "Automatic installation of Crunch and aditional utilities, version 1.0" echo " " echo "Please provide the information requested as the installation proceeds" echo " " prodir="$cwd/programs" dridir="$cwd/drivers" soudir="$cwd/source" mkdir $prodir # # The user is required to give the amount of memory available # Crunch will use a maximum of 256 Mb # echo " " echo "You are required to specify the maximum amount of memory you would" echo "like to make available to the program." echo "Crunch will use a maximum of 256 Mb." echo "In general, more available memory will result in better performance" echon "Please give the amount of available ram now (in megabytes): " read p1 echo " " p1=` expr $p1 / 4 ` if [ "$p1" -lt 2 ]; then echo "Your computer should have at least 8 Mb available for Crunch," echo "Otherwise the program cannot run properly." echo "The installation is stopped." exit else if [ "$p1" -gt 64 ]; then p1=` expr 64 ` fi fi echo "Unpacking crunch.tar.gz now" gzip -c -d ../crunch.tar.gz | tar -xf - # # Building crunch.uni # cat $dridir/script1 > crunch.uni echo ' dcru="'$dridir'"' >> crunch.uni echo ' dpro="'$prodir'"' >> crunch.uni cat $dridir/script2 >> crunch.uni chmod +x crunch.uni mv crunch.uni $dridir/crunch.uni echo " " echo "Both autofour and deter will use a maximum of "$p1" million words" p3=`expr $p1 \* 10` p2=`expr $p3 / 2` p5=`expr $p2 / 10` p2=`expr $p2 - $p5` echo " PROGRAM AUTOFOUR" > main000.f echo " REAL*8 COM" >> main000.f echo " COMMON COM("$p5"00000),R("$p2"00000),I("$p2"00000)" >> main000.f echo " CHARACTER*8 NAME(1000)" >> main000.f echo " DATA NR/"$p2"00000/,NC/"$p5"00000/,NI/"$p2"00000/,NM/1000/" >> main000.f echo " CALL MAINS(COM,R,I,NC,NR,NI,NAME,NM)" >> main000.f echo " END" >> main000.f mv main000.f $soudir/autofour/autofour.f p1=`expr $p1 - 1` echo " PROGRAM DETER" > main000.f echo " INTEGER CI" >> main000.f echo " COMMON CR("$p1"000000),CI(1000000)" >> main000.f echo " DATA NR/"$p1"000000/,NI/1000000/" >> main000.f echo " CALL MAINS(CI,NI,CR,NR)" >> main000.f echo " END" >> main000.f mv main000.f $soudir/deter/deter.f echo " " echo "g77 will be used to compile the sources. However, if g77 is not " echo "available on your system, f2c and cc and the script f77 will be" echo "tried. On Red Hat systems fort77, Red Hat's pseudo compiler will" echo "be used instead. If non of these is present installation will stop" echo " " p3="" if [ -x /usr/bin/f77 ]; then # Slackware f77 or Red Hat with g77 installed p3="f77" fi if [ -x /usr/bin/fort77 ]; then #RED HAT distribution, no g77 installed ln -s /usr/bin/fort77 $soudir/f77 chmod +x $soudir/f77 p3="$soudir/f77" fi if [ -x /usr/bin/g77 ]; then #g77 installed, this is the preferred option, which is why it is #checked last. p3="g77" fi if [ $p3 = "" ]; then echo "No suitable fortran compiler has been found. Installation stops" echo "We have looked for compilers in /usr/bin only. If you have a " echo "Fortran compiler or an equivalent somewhere else, make a link in" echo "/usr/bin. If it is a script such as f77 which calls f2c and cc" echo "use this name. Is it g77, use that." exit fi echo "COMPILE ALL CRUNCH PROGRAMS" echo " " echo "Standard optimization is "$opt echo " " echo "Programs directory is: "$prodir echo "Sources directory is: "$soudir echo " " # # Auxiliary programs # echo "Compile Utility Programs" echo " " # echo "Compile CONREF80" # $p3 $opt -o $prodir/conref80 $soudir/conref80.f # echo "Compile FERNOC80" # $p3 $opt -o $prodir/fernoc80 $soudir/fernoc80.f # echo "Compile REDNOR80" # $p3 $opt -o $prodir/rednor80 $soudir/rednor80.f # echo "Compile NORRED80" # $p3 $opt -o $prodir/norred80 $soudir/norred80.f # echo "Compile NORMAL80" # $p3 $opt -o $prodir/normal80 $soudir/normal80.f # echo "Compile Conhkl" # $p3 $opt -o $prodir/conhkl $soudir/conhkl.f # echo "Compile Contents" # $p3 $opt -o $prodir/contents $soudir/contents.f # echo "Compile Mat" $p3 $opt -o $prodir/mat $soudir/mat.f # echo "Compile Crys" $p3 $opt -o $prodir/crys $soudir/crys.f # echo "Compile Avrg" $p3 $opt -o $prodir/avrg $soudir/avrg.f # echo "Compile Symt" $p3 $opt -o $prodir/symt $soudir/symt.f # # Crunch programs # echo " " echo "Compile CRUNCH proper" echo " " echo "Compile INIT" # $p3 $opt -o $prodir/init $soudir/init.f # echo "Compile THINKC" # $p3 $opt -o $prodir/thinkc $soudir/thinkc.f # # Deter echo "Compile DETER" # cd $soudir/deter case "$p3" in $soudir/f77 ) cp $soudir/f77 . make rm -f *.o rm f77 ;; f77 ) make -f makefilef2c rm -f *.o rm -f *.c ;; g77 ) make -f makefileg77 rm -f *.o ;; esac cd $cwd # echo "Compile VEXFFT" # $p3 $opt -o $prodir/vexfft $soudir/vexfft.f # echo "Compile EXFFT80" # $p3 $opt -o $prodir/exfft80 $soudir/exfft80.f # echo "Compile SEARCH80" # $p3 $opt -o $prodir/search80 $soudir/search80.f # echo "Compile FRAGMENT" # $p3 $opt -o $prodir/fragment $soudir/fragment.f # # Autofour # echo "Compile AUTOFOUR" # cd $soudir/autofour case $p3 in $soudir/f77 ) cp $soudir/f77 . make rm -f *.o rm f77 ;; f77 ) make -f makefilef2c rm -f *.o rm -f *.c ;; g77 ) make -f makefileg77 rm -f *.o ;; esac cd $cwd rm -f temp rm -f *.c rm -f *.o ln -s $cwd/drivers/crunch.uni crunch rm -f $soudir/f77 echo " " echo "The installation is complete. The file crunch.tar.gz" echo "may be removed " exit