source: CPL/oasis3/trunk/util/compile/frames/Create_COMP_libs.frm @ 1991

Last change on this file since 1991 was 1991, checked in by aclsce, 9 years ago

Added ada compilation options for Oasis3.
Added -xHost on Curie (without that crashes...I have to investigate)

File size: 8.8 KB
Line 
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!'
45if [ "$3" = "rhodes" ] ; then
46  echo ' The version you use is :' `/usr/freeware/bin/m4 --version`
47elif [ "$3" = "zahir" ] ; then
48  echo ' The version you use is :' `/usr/local/bin/m4 --version`
49elif [ "$3" = "vargas" ] ; then
50  echo ' The version you use is :' `/usr/local/pub/M4/m4-1.4.11/bin/m4 --version`
51else
52  echo ' The version you use is :' `m4 --version`
53fi
54  echo ' Make sure this is GNU m4 younger than version 1.4!'
55  echo ' '
56  echo '-----------------------------------------------------------------'
57
58set +x
59
60if [ "$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
70fi
71echo
72
73#
74# Redirecting standard output and error output
75#
76
77outout='stdout=$SCRIPTDIR/COMP_libs.log'
78if [ "$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
86else
87  echo '* (g)make standard output will be directed to a file.'
88fi
89
90errout='stderr=$SCRIPTDIR/COMP_libs.err'
91if [ "$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
102else
103  echo '* (g)make standard error will be directed to a file.'
104fi
105
106#
107#  HOST, OS, node name for header file directory selection
108#
109
110node=`uname -n`
111node1_7=`echo ${node} | cut -c1-7`
112if [ ${node1_7} = platine ]; then node=${node1_7}; fi
113if [ ${node1_7} = mercure ]; then node=${node1_7}; fi
114node1_5=`echo ${node} | cut -c1-5`
115if [ ${node1_5} = zahir ]; then node=${node1_5}; fi
116if [ ${node1_5} = curie ]; then node=${node1_5}; fi
117node1_6=`echo ${node} | cut -c1-6`
118if [ ${node1_6} = vargas ] || [ ${node1_6} = titane ]; then node=${node1_6}; fi
119node1_3=`echo ${node} | cut -c1-3`
120if [ ${node1_3} = ada ]; then node=${node1_3}; fi
121build=`uname -s`
122if [ "$3" != "" ]; then
123  if [ "$3" != $node ]; then
124    echo ' '
125    echo 'Warning: the node name specified is not the node name of this machine'
126    echo 'Ensure that the site/OS specific header files exist.'
127    node=$3
128  fi
129fi
130
131echo ' '
132echo '* Creating library compile script'
133echo '         on/for a '$build ' platform with node name ' $node'.'
134echo ' '
135
136node1_4=`echo ${node} | cut -c1-4`
137if [ ${node1_4} = xbar ]; then node=${node1_4}; fi
138if [ ${node1_4} = hpca ]; then node=${node1_4}; fi
139
140node1_2=`echo ${node} | cut -c1-2`
141if [ ${node1_2} = ds ]; then node=${node1_2}; fi
142
143node1_6=`echo ${node} | cut -c1-6`
144if [ ${node1_6} = total1 ]; then node=${node1_6}; fi
145
146echo ' '
147echo '* Abbreviated node name is  ' $node'.'
148echo ' '
149
150mespas=irgendwas
151messpass=MPI2
152if [ "$4" != "" ]; then
153  if [ "$4" = MPI1 ] || [ "$4" = NONE ]  ; then
154    messpass=$4
155    mespas=MPI2
156  else
157    echo 'This  may not be specified:'$4
158    exit 1
159  fi
160  echo '* The message passing will be '$4'.'
161else
162  echo '* The message passing will be MPI2.'
163fi
164
165#
166#  Change to directory of script
167#
168
169scriptdir=`dirname $0`
170cd $scriptdir
171
172# /u/fj/mfuj/mfuj004/bin/m4" ; xbar
173
174cat > infile.m4 <<EOF
175#! /bin/ksh
176changequote([{,}])dnl
177changecom
178dnl
179dnl  Embedding as batch  (not needed on all nodes)
180dnl
181define(comp_Model,comp_libs)dnl
182sinclude(include/Qsub_start_${node}.h)dnl
183undefine([{comp_Model}])dnl
184
185dnl
186dnl  Comments, usage, history
187dnl
188include(include/Comments_libs.h)dnl
189include(include/Comments_libs_frm.h)dnl
190
191dnl
192dnl  GUI input for all compile scripts
193dnl
194define(${mespas},${messpass})dnl
195include(include/Guispecif_all.h)dnl
196undefine([{${mespas}}])dnl
197
198dnl
199dnl  GUI input depending on model
200dnl
201include(include/Guispecif_libs.h)dnl
202
203dnl
204dnl  Command parameter input (scripting only)
205dnl
206include(include/Command_par_libs_frm.h)dnl
207include(include/Input_check_all_frm.h)dnl
208include(include/Input_check_libs_frm.h)dnl
209
210dnl
211dnl  Parameter renaming and printing
212dnl
213include(include/Print_par_all.h)dnl
214include(include/Print_par_libs.h)dnl
215
216scriptdir=\`dirname \$0\`
217cd \$scriptdir
218export SCRIPTDIR=\`pwd\`
219node=\`uname -n\`
220node1_7=\`echo \${node} | cut -c1-7\`
221if [ \${node1_7} = platine ]; then node=\${node1_7}; fi
222if [ \${node1_7} = mercure ]; then node=\${node1_7}; fi
223node1_5=\`echo \${node} | cut -c1-5\`
224if [ \${node1_5} = zahir ]; then node=\${node1_5}; fi
225if [ \${node1_5} = curie ]; then node=\${node1_5}; fi
226node1_6=\`echo \${node} | cut -c1-6\`
227if [ \${node1_6} = vargas ] || [ \${node1_6} = titane ]; then node=\${node1_6}; fi
228node1_3=\`echo \${node} | cut -c1-3\`
229if [ \${node1_3} = ada ]; then node=\${node1_3}; fi
230
231dnl
232dnl  HOST, OS, node name
233dnl
234include(include/Prolog_all.h)dnl
235include(include/Prolog_libs.h)dnl
236export TARFILE=libs_\`date +%y%m%d\`.tar
237
238dnl
239dnl  Site and OS specifics
240dnl
241include(include_${node}/Sitespecific_${node}.h)dnl
242include(include_${node}/Compile_mode_libs_${node}.h)dnl
243include(include_${node}/OSspecific_${node}.h)dnl
244
245dnl
246dnl  Non Site and OS dependent cpp flags
247dnl
248include(include/Cppflags_libs.h)dnl
249include(include/Cppflags_edit.h)dnl
250
251dnl
252dnl  Build the build
253dnl
254include(include/Build_dirs_libs.h)dnl
255
256dnl
257dnl  Create top level Makefile
258dnl
259include(include/Top_makefile_all.h)dnl
260define(NodeName,$node)dnl
261include(include/Top_makefile_libs.h)dnl
262undefine(NodeName)dnl
263
264define(outdev,${outout})dnl
265outdev
266undefine([{outdev}])dnl
267define(errdev,${errout})dnl
268errdev
269undefine([{errdev}])dnl
270
271if [ -f \$BLDROOT/lib.status ]; then rm \$BLDROOT/lib.status; fi
272
273dnl
274dnl  Make libaries
275dnl
276include(include/Make_libs.h)dnl
277
278dnl
279dnl  Print update status : scripting only
280dnl
281include(include/Status_libs_frm.h)dnl
282
283dnl
284dnl  Embedding as batch  (not needed on all nodes)
285dnl
286sinclude(include/Qsub_end_${node}.h)dnl
287
288exit
289
290m4exit
291
292EOF
293#
294# Run preprocessor: note the blank behind -D / -U
295#
296if [ "$3" = "rhodes" ] ; then
297  /usr/freeware/bin/m4 infile.m4 > COMP_libs
298elif [ "$3" = "zahir" ] ; then
299  /usr/local/bin/m4 infile.m4 > COMP_libs
300elif [ "$3" = "vargas" ] ; then
301  /usr/local/pub/M4/m4-1.4.11/bin/m4 infile.m4 > COMP_libs
302else
303  m4 infile.m4 > COMP_libs
304fi 
305
306status=$?
307if [ $status -eq 0 ]; then
308  mv COMP_libs ../../COMP_libs.${node}
309  chmod 755 ../../COMP_libs.${node}
310  olddir=`pwd`
311  cd ../..
312  moddir=`pwd`
313  echo "* The compile script name is "$moddir/COMP_libs.${node}
314  echo ' '
315else
316  echo "An error occurred! Status="$status
317  echo ' '
318fi
319
320cd $olddir
321rm infile.m4
322exit
Note: See TracBrowser for help on using the repository browser.