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

Last change on this file since 1677 was 1677, checked in by aclsce, 10 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 8.7 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
119
120build=`uname -s`
121if [ "$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
128fi
129
130echo ' '
131echo '* Creating library compile script'
132echo '         on/for a '$build ' platform with node name ' $node'.'
133echo ' '
134
135node1_4=`echo ${node} | cut -c1-4`
136if [ ${node1_4} = xbar ]; then node=${node1_4}; fi
137if [ ${node1_4} = hpca ]; then node=${node1_4}; fi
138
139node1_2=`echo ${node} | cut -c1-2`
140if [ ${node1_2} = ds ]; then node=${node1_2}; fi
141
142node1_6=`echo ${node} | cut -c1-6`
143if [ ${node1_6} = total1 ]; then node=${node1_6}; fi
144
145echo ' '
146echo '* Abbreviated node name is  ' $node'.'
147echo ' '
148
149mespas=irgendwas
150messpass=MPI2
151if [ "$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'.'
160else
161  echo '* The message passing will be MPI2.'
162fi
163
164#
165#  Change to directory of script
166#
167
168scriptdir=`dirname $0`
169cd $scriptdir
170
171# /u/fj/mfuj/mfuj004/bin/m4" ; xbar
172
173cat > infile.m4 <<EOF
174#! /bin/ksh
175changequote([{,}])dnl
176changecom
177dnl
178dnl  Embedding as batch  (not needed on all nodes)
179dnl
180define(comp_Model,comp_libs)dnl
181sinclude(include/Qsub_start_${node}.h)dnl
182undefine([{comp_Model}])dnl
183
184dnl
185dnl  Comments, usage, history
186dnl
187include(include/Comments_libs.h)dnl
188include(include/Comments_libs_frm.h)dnl
189
190dnl
191dnl  GUI input for all compile scripts
192dnl
193define(${mespas},${messpass})dnl
194include(include/Guispecif_all.h)dnl
195undefine([{${mespas}}])dnl
196
197dnl
198dnl  GUI input depending on model
199dnl
200include(include/Guispecif_libs.h)dnl
201
202dnl
203dnl  Command parameter input (scripting only)
204dnl
205include(include/Command_par_libs_frm.h)dnl
206include(include/Input_check_all_frm.h)dnl
207include(include/Input_check_libs_frm.h)dnl
208
209dnl
210dnl  Parameter renaming and printing
211dnl
212include(include/Print_par_all.h)dnl
213include(include/Print_par_libs.h)dnl
214
215scriptdir=\`dirname \$0\`
216cd \$scriptdir
217export SCRIPTDIR=\`pwd\`
218node=\`uname -n\`
219node1_7=\`echo \${node} | cut -c1-7\`
220if [ \${node1_7} = platine ]; then node=\${node1_7}; fi
221if [ \${node1_7} = mercure ]; then node=\${node1_7}; fi
222node1_5=\`echo \${node} | cut -c1-5\`
223if [ \${node1_5} = zahir ]; then node=\${node1_5}; fi
224if [ \${node1_5} = curie ]; then node=\${node1_5}; fi
225node1_6=\`echo \${node} | cut -c1-6\`
226if [ \${node1_6} = vargas ] || [ \${node1_6} = titane ]; then node=\${node1_6}; fi
227dnl
228dnl  HOST, OS, node name
229dnl
230include(include/Prolog_all.h)dnl
231include(include/Prolog_libs.h)dnl
232export TARFILE=libs_\`date +%y%m%d\`.tar
233
234dnl
235dnl  Site and OS specifics
236dnl
237include(include_${node}/Sitespecific_${node}.h)dnl
238include(include_${node}/Compile_mode_libs_${node}.h)dnl
239include(include_${node}/OSspecific_${node}.h)dnl
240
241dnl
242dnl  Non Site and OS dependent cpp flags
243dnl
244include(include/Cppflags_libs.h)dnl
245include(include/Cppflags_edit.h)dnl
246
247dnl
248dnl  Build the build
249dnl
250include(include/Build_dirs_libs.h)dnl
251
252dnl
253dnl  Create top level Makefile
254dnl
255include(include/Top_makefile_all.h)dnl
256define(NodeName,$node)dnl
257include(include/Top_makefile_libs.h)dnl
258undefine(NodeName)dnl
259
260define(outdev,${outout})dnl
261outdev
262undefine([{outdev}])dnl
263define(errdev,${errout})dnl
264errdev
265undefine([{errdev}])dnl
266
267if [ -f \$BLDROOT/lib.status ]; then rm \$BLDROOT/lib.status; fi
268
269dnl
270dnl  Make libaries
271dnl
272include(include/Make_libs.h)dnl
273
274dnl
275dnl  Print update status : scripting only
276dnl
277include(include/Status_libs_frm.h)dnl
278
279dnl
280dnl  Embedding as batch  (not needed on all nodes)
281dnl
282sinclude(include/Qsub_end_${node}.h)dnl
283
284exit
285
286m4exit
287
288EOF
289#
290# Run preprocessor: note the blank behind -D / -U
291#
292if [ "$3" = "rhodes" ] ; then
293  /usr/freeware/bin/m4 infile.m4 > COMP_libs
294elif [ "$3" = "zahir" ] ; then
295  /usr/local/bin/m4 infile.m4 > COMP_libs
296elif [ "$3" = "vargas" ] ; then
297  /usr/local/pub/M4/m4-1.4.11/bin/m4 infile.m4 > COMP_libs
298else
299  m4 infile.m4 > COMP_libs
300fi 
301
302status=$?
303if [ $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 ' '
311else
312  echo "An error occurred! Status="$status
313  echo ' '
314fi
315
316cd $olddir
317rm infile.m4
318exit
Note: See TracBrowser for help on using the repository browser.