#! /bin/ksh ################################################################################ # # File : ~/util/compile/frames/Create_COMP_libs.frm # # Script to generate the library compile script # # Stephanie Legutke, MPI-HH, M&D Dec 14, 2004 # # This script is used to generate a compile script for the PRISM libraries. # The script is specifically created for the target platform. # Depending on the node name it selects site and OS specifics. # The node name is either detected with `uname -n` or, if the script is not # created on the target machine, it must be specifieid by the user. # The generated compile script is moved to ~/src/mod/'model name' # after successful generation. # The script uses m4 for preprocessing. It has been tested with # GNU m4 version 1.4. Other, older or non-GNU versions of m4 may fail! # # This script is called interactively only. # # 5 positional parameters are possible: # # Usage : COMP_libs [- [- [node [MPI1]]]] # # $1=""/"-": directing std output to a file / the screen # $2=""/"-"/"+": directing err output to a file / the screen / stdout # $3=""/"'node'": node name for header files with OS/site specs # $4=""/"MPI1": message passing # # If not called with all parameters, the defaults are: # $1 the gmake of the generated script directs stdout to a file # $2 the gmake of the generated script directs errout to a file # $3 node name of the machine where this scripts is run; # (if it is not the node name appearing in the header file # names with the site/OS specifications, it must be given) # $4 MPI2 # ################################################################################ # echo echo '-----------------------------------------------------------------' echo ' ' echo ' This script may fail if you do not use the right version of m4!' if [ "$3" = "rhodes" ] ; then echo ' The version you use is :' `/usr/freeware/bin/m4 --version` elif [ "$3" = "zahir" ] ; then echo ' The version you use is :' `/usr/local/bin/m4 --version` elif [ "$3" = "vargas" ] ; then echo ' The version you use is :' `/usr/local/pub/M4/m4-1.4.11/bin/m4 --version` else echo ' The version you use is :' `m4 --version` fi echo ' Make sure this is GNU m4 younger than version 1.4!' echo ' ' echo '-----------------------------------------------------------------' set +x if [ "$1" = "--" ] || [ "$1" = "help" ] || [ "$1" = "--help" ] ; then echo echo '----------- Usage --------------------------------------------------------' echo ' $1=""/"-": directing std output to a file / the screen' echo ' $2=""/"-"/"+": directing err output to a file / the screen / stdout' echo ' $3=""/"node": node name for header files with OS/site specs' echo ' $4=""/"MPI1": message passing' echo '--------------------------------------------------------------------------' echo ' ' exit fi echo # # Redirecting standard output and error output # outout='stdout=$SCRIPTDIR/COMP_libs.log' if [ "$1" != "" ]; then if [ "$1" = "-" ]; then outout='stdout=`tty`' echo '* (g)make standard output will directed to screen.' else echo 'This values is not allowed for parameter 1 (std out)' exit fi else echo '* (g)make standard output will be directed to a file.' fi errout='stderr=$SCRIPTDIR/COMP_libs.err' if [ "$2" != "" ]; then if [ "$2" = "-" ]; then echo '* (g)make standard error will directed to screen.' errout='stderr=`tty`' elif [ "$2" = "+" ]; then echo '* (g)make standard error will directed to stdout.' errout='stderr="$stdout"' else echo 'This values is not allowed for parameter 2 (std err)' exit fi else echo '* (g)make standard error will be directed to a file.' fi # # HOST, OS, node name for header file directory selection # node=`uname -n` node1_7=`echo ${node} | cut -c1-7` if [ ${node1_7} = platine ]; then node=${node1_7}; fi if [ ${node1_7} = mercure ]; then node=${node1_7}; fi node1_5=`echo ${node} | cut -c1-5` if [ ${node1_5} = zahir ]; then node=${node1_5}; fi if [ ${node1_5} = curie ]; then node=${node1_5}; fi node1_6=`echo ${node} | cut -c1-6` if [ ${node1_6} = vargas ] || [ ${node1_6} = titane ]; then node=${node1_6}; fi build=`uname -s` if [ "$3" != "" ]; then if [ "$3" != $node ]; then echo ' ' echo 'Warning: the node name specified is not the node name of this machine' echo 'Ensure that the site/OS specific header files exist.' node=$3 fi fi echo ' ' echo '* Creating library compile script' echo ' on/for a '$build ' platform with node name ' $node'.' echo ' ' node1_4=`echo ${node} | cut -c1-4` if [ ${node1_4} = xbar ]; then node=${node1_4}; fi if [ ${node1_4} = hpca ]; then node=${node1_4}; fi node1_2=`echo ${node} | cut -c1-2` if [ ${node1_2} = ds ]; then node=${node1_2}; fi node1_6=`echo ${node} | cut -c1-6` if [ ${node1_6} = total1 ]; then node=${node1_6}; fi echo ' ' echo '* Abbreviated node name is ' $node'.' echo ' ' mespas=irgendwas messpass=MPI2 if [ "$4" != "" ]; then if [ "$4" = MPI1 ] || [ "$4" = NONE ] ; then messpass=$4 mespas=MPI2 else echo 'This may not be specified:'$4 exit 1 fi echo '* The message passing will be '$4'.' else echo '* The message passing will be MPI2.' fi # # Change to directory of script # scriptdir=`dirname $0` cd $scriptdir # /u/fj/mfuj/mfuj004/bin/m4" ; xbar cat > infile.m4 < COMP_libs elif [ "$3" = "zahir" ] ; then /usr/local/bin/m4 infile.m4 > COMP_libs elif [ "$3" = "vargas" ] ; then /usr/local/pub/M4/m4-1.4.11/bin/m4 infile.m4 > COMP_libs else m4 infile.m4 > COMP_libs fi status=$? if [ $status -eq 0 ]; then mv COMP_libs ../../COMP_libs.${node} chmod 755 ../../COMP_libs.${node} olddir=`pwd` cd ../.. moddir=`pwd` echo "* The compile script name is "$moddir/COMP_libs.${node} echo ' ' else echo "An error occurred! Status="$status echo ' ' fi cd $olddir rm infile.m4 exit