[1677] | 1 | #! /bin/ksh |
---|
| 2 | ################################################################################ |
---|
| 3 | # |
---|
| 4 | # File : ~/util/compile/frames/Create_COMP_libs.frm |
---|
| 5 | # |
---|
| 6 | # Script to generate the library compile script |
---|
| 7 | # |
---|
| 8 | # Stephanie Legutke, MPI-HH, M&D Dec 14, 2004 |
---|
| 9 | # |
---|
| 10 | # This script is used to generate a compile script for the PRISM libraries. |
---|
| 11 | # The script is specifically created for the target platform. |
---|
| 12 | # Depending on the node name it selects site and OS specifics. |
---|
| 13 | # The node name is either detected with `uname -n` or, if the script is not |
---|
| 14 | # created on the target machine, it must be specifieid by the user. |
---|
| 15 | # The generated compile script is moved to ~/src/mod/'model name' |
---|
| 16 | # after successful generation. |
---|
| 17 | # The script uses m4 for preprocessing. It has been tested with |
---|
| 18 | # GNU m4 version 1.4. Other, older or non-GNU versions of m4 may fail! |
---|
| 19 | # |
---|
| 20 | # This script is called interactively only. |
---|
| 21 | # |
---|
| 22 | # 5 positional parameters are possible: |
---|
| 23 | # |
---|
| 24 | # Usage : COMP_libs [- [- [node [MPI1]]]] |
---|
| 25 | # |
---|
| 26 | # $1=""/"-": directing std output to a file / the screen |
---|
| 27 | # $2=""/"-"/"+": directing err output to a file / the screen / stdout |
---|
| 28 | # $3=""/"'node'": node name for header files with OS/site specs |
---|
| 29 | # $4=""/"MPI1": message passing |
---|
| 30 | # |
---|
| 31 | # If not called with all parameters, the defaults are: |
---|
| 32 | # $1 the gmake of the generated script directs stdout to a file |
---|
| 33 | # $2 the gmake of the generated script directs errout to a file |
---|
| 34 | # $3 node name of the machine where this scripts is run; |
---|
| 35 | # (if it is not the node name appearing in the header file |
---|
| 36 | # names with the site/OS specifications, it must be given) |
---|
| 37 | # $4 MPI2 |
---|
| 38 | # |
---|
| 39 | ################################################################################ |
---|
| 40 | # |
---|
| 41 | echo |
---|
| 42 | echo '-----------------------------------------------------------------' |
---|
| 43 | echo ' ' |
---|
| 44 | echo ' This script may fail if you do not use the right version of m4!' |
---|
| 45 | if [ "$3" = "rhodes" ] ; then |
---|
| 46 | echo ' The version you use is :' `/usr/freeware/bin/m4 --version` |
---|
| 47 | elif [ "$3" = "zahir" ] ; then |
---|
| 48 | echo ' The version you use is :' `/usr/local/bin/m4 --version` |
---|
| 49 | elif [ "$3" = "vargas" ] ; then |
---|
| 50 | echo ' The version you use is :' `/usr/local/pub/M4/m4-1.4.11/bin/m4 --version` |
---|
| 51 | else |
---|
| 52 | echo ' The version you use is :' `m4 --version` |
---|
| 53 | fi |
---|
| 54 | echo ' Make sure this is GNU m4 younger than version 1.4!' |
---|
| 55 | echo ' ' |
---|
| 56 | echo '-----------------------------------------------------------------' |
---|
| 57 | |
---|
| 58 | set +x |
---|
| 59 | |
---|
| 60 | if [ "$1" = "--" ] || [ "$1" = "help" ] || [ "$1" = "--help" ] ; then |
---|
| 61 | echo |
---|
| 62 | echo '----------- Usage --------------------------------------------------------' |
---|
| 63 | echo ' $1=""/"-": directing std output to a file / the screen' |
---|
| 64 | echo ' $2=""/"-"/"+": directing err output to a file / the screen / stdout' |
---|
| 65 | echo ' $3=""/"node": node name for header files with OS/site specs' |
---|
| 66 | echo ' $4=""/"MPI1": message passing' |
---|
| 67 | echo '--------------------------------------------------------------------------' |
---|
| 68 | echo ' ' |
---|
| 69 | exit |
---|
| 70 | fi |
---|
| 71 | echo |
---|
| 72 | |
---|
| 73 | # |
---|
| 74 | # Redirecting standard output and error output |
---|
| 75 | # |
---|
| 76 | |
---|
| 77 | outout='stdout=$SCRIPTDIR/COMP_libs.log' |
---|
| 78 | if [ "$1" != "" ]; then |
---|
| 79 | if [ "$1" = "-" ]; then |
---|
| 80 | outout='stdout=`tty`' |
---|
| 81 | echo '* (g)make standard output will directed to screen.' |
---|
| 82 | else |
---|
| 83 | echo 'This values is not allowed for parameter 1 (std out)' |
---|
| 84 | exit |
---|
| 85 | fi |
---|
| 86 | else |
---|
| 87 | echo '* (g)make standard output will be directed to a file.' |
---|
| 88 | fi |
---|
| 89 | |
---|
| 90 | errout='stderr=$SCRIPTDIR/COMP_libs.err' |
---|
| 91 | if [ "$2" != "" ]; then |
---|
| 92 | if [ "$2" = "-" ]; then |
---|
| 93 | echo '* (g)make standard error will directed to screen.' |
---|
| 94 | errout='stderr=`tty`' |
---|
| 95 | elif [ "$2" = "+" ]; then |
---|
| 96 | echo '* (g)make standard error will directed to stdout.' |
---|
| 97 | errout='stderr="$stdout"' |
---|
| 98 | else |
---|
| 99 | echo 'This values is not allowed for parameter 2 (std err)' |
---|
| 100 | exit |
---|
| 101 | fi |
---|
| 102 | else |
---|
| 103 | echo '* (g)make standard error will be directed to a file.' |
---|
| 104 | fi |
---|
| 105 | |
---|
| 106 | # |
---|
| 107 | # HOST, OS, node name for header file directory selection |
---|
| 108 | # |
---|
| 109 | |
---|
| 110 | node=`uname -n` |
---|
| 111 | node1_7=`echo ${node} | cut -c1-7` |
---|
| 112 | if [ ${node1_7} = platine ]; then node=${node1_7}; fi |
---|
| 113 | if [ ${node1_7} = mercure ]; then node=${node1_7}; fi |
---|
| 114 | node1_5=`echo ${node} | cut -c1-5` |
---|
| 115 | if [ ${node1_5} = zahir ]; then node=${node1_5}; fi |
---|
| 116 | if [ ${node1_5} = curie ]; then node=${node1_5}; fi |
---|
| 117 | node1_6=`echo ${node} | cut -c1-6` |
---|
| 118 | if [ ${node1_6} = vargas ] || [ ${node1_6} = titane ]; then node=${node1_6}; fi |
---|
| 119 | |
---|
| 120 | build=`uname -s` |
---|
| 121 | if [ "$3" != "" ]; then |
---|
| 122 | if [ "$3" != $node ]; then |
---|
| 123 | echo ' ' |
---|
| 124 | echo 'Warning: the node name specified is not the node name of this machine' |
---|
| 125 | echo 'Ensure that the site/OS specific header files exist.' |
---|
| 126 | node=$3 |
---|
| 127 | fi |
---|
| 128 | fi |
---|
| 129 | |
---|
| 130 | echo ' ' |
---|
| 131 | echo '* Creating library compile script' |
---|
| 132 | echo ' on/for a '$build ' platform with node name ' $node'.' |
---|
| 133 | echo ' ' |
---|
| 134 | |
---|
| 135 | node1_4=`echo ${node} | cut -c1-4` |
---|
| 136 | if [ ${node1_4} = xbar ]; then node=${node1_4}; fi |
---|
| 137 | if [ ${node1_4} = hpca ]; then node=${node1_4}; fi |
---|
| 138 | |
---|
| 139 | node1_2=`echo ${node} | cut -c1-2` |
---|
| 140 | if [ ${node1_2} = ds ]; then node=${node1_2}; fi |
---|
| 141 | |
---|
| 142 | node1_6=`echo ${node} | cut -c1-6` |
---|
| 143 | if [ ${node1_6} = total1 ]; then node=${node1_6}; fi |
---|
| 144 | |
---|
| 145 | echo ' ' |
---|
| 146 | echo '* Abbreviated node name is ' $node'.' |
---|
| 147 | echo ' ' |
---|
| 148 | |
---|
| 149 | mespas=irgendwas |
---|
| 150 | messpass=MPI2 |
---|
| 151 | if [ "$4" != "" ]; then |
---|
| 152 | if [ "$4" = MPI1 ] || [ "$4" = NONE ] ; then |
---|
| 153 | messpass=$4 |
---|
| 154 | mespas=MPI2 |
---|
| 155 | else |
---|
| 156 | echo 'This may not be specified:'$4 |
---|
| 157 | exit 1 |
---|
| 158 | fi |
---|
| 159 | echo '* The message passing will be '$4'.' |
---|
| 160 | else |
---|
| 161 | echo '* The message passing will be MPI2.' |
---|
| 162 | fi |
---|
| 163 | |
---|
| 164 | # |
---|
| 165 | # Change to directory of script |
---|
| 166 | # |
---|
| 167 | |
---|
| 168 | scriptdir=`dirname $0` |
---|
| 169 | cd $scriptdir |
---|
| 170 | |
---|
| 171 | # /u/fj/mfuj/mfuj004/bin/m4" ; xbar |
---|
| 172 | |
---|
| 173 | cat > infile.m4 <<EOF |
---|
| 174 | #! /bin/ksh |
---|
| 175 | changequote([{,}])dnl |
---|
| 176 | changecom |
---|
| 177 | dnl |
---|
| 178 | dnl Embedding as batch (not needed on all nodes) |
---|
| 179 | dnl |
---|
| 180 | define(comp_Model,comp_libs)dnl |
---|
| 181 | sinclude(include/Qsub_start_${node}.h)dnl |
---|
| 182 | undefine([{comp_Model}])dnl |
---|
| 183 | |
---|
| 184 | dnl |
---|
| 185 | dnl Comments, usage, history |
---|
| 186 | dnl |
---|
| 187 | include(include/Comments_libs.h)dnl |
---|
| 188 | include(include/Comments_libs_frm.h)dnl |
---|
| 189 | |
---|
| 190 | dnl |
---|
| 191 | dnl GUI input for all compile scripts |
---|
| 192 | dnl |
---|
| 193 | define(${mespas},${messpass})dnl |
---|
| 194 | include(include/Guispecif_all.h)dnl |
---|
| 195 | undefine([{${mespas}}])dnl |
---|
| 196 | |
---|
| 197 | dnl |
---|
| 198 | dnl GUI input depending on model |
---|
| 199 | dnl |
---|
| 200 | include(include/Guispecif_libs.h)dnl |
---|
| 201 | |
---|
| 202 | dnl |
---|
| 203 | dnl Command parameter input (scripting only) |
---|
| 204 | dnl |
---|
| 205 | include(include/Command_par_libs_frm.h)dnl |
---|
| 206 | include(include/Input_check_all_frm.h)dnl |
---|
| 207 | include(include/Input_check_libs_frm.h)dnl |
---|
| 208 | |
---|
| 209 | dnl |
---|
| 210 | dnl Parameter renaming and printing |
---|
| 211 | dnl |
---|
| 212 | include(include/Print_par_all.h)dnl |
---|
| 213 | include(include/Print_par_libs.h)dnl |
---|
| 214 | |
---|
| 215 | scriptdir=\`dirname \$0\` |
---|
| 216 | cd \$scriptdir |
---|
| 217 | export SCRIPTDIR=\`pwd\` |
---|
| 218 | node=\`uname -n\` |
---|
| 219 | node1_7=\`echo \${node} | cut -c1-7\` |
---|
| 220 | if [ \${node1_7} = platine ]; then node=\${node1_7}; fi |
---|
| 221 | if [ \${node1_7} = mercure ]; then node=\${node1_7}; fi |
---|
| 222 | node1_5=\`echo \${node} | cut -c1-5\` |
---|
| 223 | if [ \${node1_5} = zahir ]; then node=\${node1_5}; fi |
---|
| 224 | if [ \${node1_5} = curie ]; then node=\${node1_5}; fi |
---|
| 225 | node1_6=\`echo \${node} | cut -c1-6\` |
---|
| 226 | if [ \${node1_6} = vargas ] || [ \${node1_6} = titane ]; then node=\${node1_6}; fi |
---|
| 227 | dnl |
---|
| 228 | dnl HOST, OS, node name |
---|
| 229 | dnl |
---|
| 230 | include(include/Prolog_all.h)dnl |
---|
| 231 | include(include/Prolog_libs.h)dnl |
---|
| 232 | export TARFILE=libs_\`date +%y%m%d\`.tar |
---|
| 233 | |
---|
| 234 | dnl |
---|
| 235 | dnl Site and OS specifics |
---|
| 236 | dnl |
---|
| 237 | include(include_${node}/Sitespecific_${node}.h)dnl |
---|
| 238 | include(include_${node}/Compile_mode_libs_${node}.h)dnl |
---|
| 239 | include(include_${node}/OSspecific_${node}.h)dnl |
---|
| 240 | |
---|
| 241 | dnl |
---|
| 242 | dnl Non Site and OS dependent cpp flags |
---|
| 243 | dnl |
---|
| 244 | include(include/Cppflags_libs.h)dnl |
---|
| 245 | include(include/Cppflags_edit.h)dnl |
---|
| 246 | |
---|
| 247 | dnl |
---|
| 248 | dnl Build the build |
---|
| 249 | dnl |
---|
| 250 | include(include/Build_dirs_libs.h)dnl |
---|
| 251 | |
---|
| 252 | dnl |
---|
| 253 | dnl Create top level Makefile |
---|
| 254 | dnl |
---|
| 255 | include(include/Top_makefile_all.h)dnl |
---|
| 256 | define(NodeName,$node)dnl |
---|
| 257 | include(include/Top_makefile_libs.h)dnl |
---|
| 258 | undefine(NodeName)dnl |
---|
| 259 | |
---|
| 260 | define(outdev,${outout})dnl |
---|
| 261 | outdev |
---|
| 262 | undefine([{outdev}])dnl |
---|
| 263 | define(errdev,${errout})dnl |
---|
| 264 | errdev |
---|
| 265 | undefine([{errdev}])dnl |
---|
| 266 | |
---|
| 267 | if [ -f \$BLDROOT/lib.status ]; then rm \$BLDROOT/lib.status; fi |
---|
| 268 | |
---|
| 269 | dnl |
---|
| 270 | dnl Make libaries |
---|
| 271 | dnl |
---|
| 272 | include(include/Make_libs.h)dnl |
---|
| 273 | |
---|
| 274 | dnl |
---|
| 275 | dnl Print update status : scripting only |
---|
| 276 | dnl |
---|
| 277 | include(include/Status_libs_frm.h)dnl |
---|
| 278 | |
---|
| 279 | dnl |
---|
| 280 | dnl Embedding as batch (not needed on all nodes) |
---|
| 281 | dnl |
---|
| 282 | sinclude(include/Qsub_end_${node}.h)dnl |
---|
| 283 | |
---|
| 284 | exit |
---|
| 285 | |
---|
| 286 | m4exit |
---|
| 287 | |
---|
| 288 | EOF |
---|
| 289 | # |
---|
| 290 | # Run preprocessor: note the blank behind -D / -U |
---|
| 291 | # |
---|
| 292 | if [ "$3" = "rhodes" ] ; then |
---|
| 293 | /usr/freeware/bin/m4 infile.m4 > COMP_libs |
---|
| 294 | elif [ "$3" = "zahir" ] ; then |
---|
| 295 | /usr/local/bin/m4 infile.m4 > COMP_libs |
---|
| 296 | elif [ "$3" = "vargas" ] ; then |
---|
| 297 | /usr/local/pub/M4/m4-1.4.11/bin/m4 infile.m4 > COMP_libs |
---|
| 298 | else |
---|
| 299 | m4 infile.m4 > COMP_libs |
---|
| 300 | fi |
---|
| 301 | |
---|
| 302 | status=$? |
---|
| 303 | if [ $status -eq 0 ]; then |
---|
| 304 | mv COMP_libs ../../COMP_libs.${node} |
---|
| 305 | chmod 755 ../../COMP_libs.${node} |
---|
| 306 | olddir=`pwd` |
---|
| 307 | cd ../.. |
---|
| 308 | moddir=`pwd` |
---|
| 309 | echo "* The compile script name is "$moddir/COMP_libs.${node} |
---|
| 310 | echo ' ' |
---|
| 311 | else |
---|
| 312 | echo "An error occurred! Status="$status |
---|
| 313 | echo ' ' |
---|
| 314 | fi |
---|
| 315 | |
---|
| 316 | cd $olddir |
---|
| 317 | rm infile.m4 |
---|
| 318 | exit |
---|