1 | #! /bin/ksh |
---|
2 | |
---|
3 | |
---|
4 | ######################################################################### |
---|
5 | # |
---|
6 | # C O M P I L E - script for component model 'oasis3'. |
---|
7 | # |
---|
8 | # File : ~/src/mod/oasis3/COMP_oasis3 |
---|
9 | # |
---|
10 | # 2 positional parameters are possible: |
---|
11 | # $1=Make target (optional:all,lib,clean,tar) |
---|
12 | # $2=message_passing (optional) |
---|
13 | # |
---|
14 | # message_passing "NONE" will cause the script NOT to update and load the |
---|
15 | # psmile/mpp_io libraries. It should therefore be used for creation of |
---|
16 | # executables w/o submodels which do not communicate through OASIS3. |
---|
17 | # For communication through OASIS3 use "MPI1" or "MPI2". |
---|
18 | # |
---|
19 | # If called with $1=clean, only the model's build directory |
---|
20 | # is cleaned, not the libraries. |
---|
21 | # |
---|
22 | # If called with $1=lib, only the model's library (archive with .o files) |
---|
23 | # is updated. |
---|
24 | # |
---|
25 | # If called with $1=tar, a tar file with the source code of the model |
---|
26 | # and all libraries it links to is created. The tar file is moved to |
---|
27 | # PRISM source-root directory. |
---|
28 | # |
---|
29 | # If called with $1=all, this script checks all libraries needed by |
---|
30 | # the model. If these are not up-to-date they will be made by calling |
---|
31 | # the library-compile script with "all" for the target |
---|
32 | # with the models libraries, |
---|
33 | # with the message passing used by the model, |
---|
34 | # with the model name |
---|
35 | # as positional parameters to that script. |
---|
36 | # If the libraries are ok the model will be made. |
---|
37 | # |
---|
38 | # The list of models being part of the coupled constellation (cpl_to) |
---|
39 | # is used to set the right cpp flags if needed. It is checked against |
---|
40 | # a list of models that may be specified. |
---|
41 | # For a standalone model specify " " (blank). |
---|
42 | # For main models: |
---|
43 | # If the list of models being part of the coupled constellation (cpl_to) |
---|
44 | # contains the name of a valid submodel the library with the source |
---|
45 | # code of that submodel is created first. |
---|
46 | # |
---|
47 | # Cleaning of libraries is not possible with this script. |
---|
48 | # |
---|
49 | # Usage : COMP_oasis3 \ |
---|
50 | # ["make_target" ["message_passing" ] ] |
---|
51 | # |
---|
52 | # If called with no parameters, the defaults given below |
---|
53 | # are used. If parameter n is specified; the parameter 1,...n-1 |
---|
54 | # must be specified as well. |
---|
55 | # |
---|
56 | ######################################################################### |
---|
57 | |
---|
58 | |
---|
59 | scriptdir=`dirname $0` |
---|
60 | cd $scriptdir |
---|
61 | export SCRIPTDIR=`pwd` |
---|
62 | node=`uname -n` |
---|
63 | node1_7=`echo ${node} | cut -c1-7` |
---|
64 | if [ ${node1_7} = platine ]; then node=${node1_7}; fi |
---|
65 | |
---|
66 | ################################# Prolog ####################################### |
---|
67 | # |
---|
68 | # 'Prolog' : Node name and operating system etc. |
---|
69 | # |
---|
70 | |
---|
71 | export NODE=$node |
---|
72 | |
---|
73 | echo ' ' |
---|
74 | echo 'This script runs on node ' $NODE'.' |
---|
75 | |
---|
76 | cd $SCRIPTDIR |
---|
77 | |
---|
78 | cd ../../.. |
---|
79 | export SRCROOT=`pwd` |
---|
80 | |
---|
81 | export MODHOME=$SCRIPTDIR |
---|
82 | export MODEL_DIR=`basename $MODHOME` |
---|
83 | |
---|
84 | echo ' ' |
---|
85 | echo 'Model directory is '$MODHOME |
---|
86 | export TARFILE=${MODEL_DIR}_`date +%y%m%d`.tar |
---|
87 | |
---|
88 | |
---|
89 | set -e |
---|
90 | |
---|
91 | ################### Start of user specifications (defaults) #################### |
---|
92 | # |
---|
93 | |
---|
94 | # message_passing : NONE / MPI 2/1 |
---|
95 | |
---|
96 | message_passing=MPI1 |
---|
97 | |
---|
98 | # coupler : oasis3 |
---|
99 | # use_key_noIO : whether mpp_io will be used for I/O |
---|
100 | # |
---|
101 | coupler=oasis3 |
---|
102 | use_key_noIO=no |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | # Gui input for all models |
---|
107 | |
---|
108 | target_mode=forced : "" / forced |
---|
109 | target_mode="" |
---|
110 | |
---|
111 | cpl_to=" " |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | # OASIS3 specific GUI input: |
---|
116 | |
---|
117 | #compile_mode=default |
---|
118 | compile_mode=debug |
---|
119 | |
---|
120 | model_version="" |
---|
121 | |
---|
122 | # make_target : clean/all/tar/lib |
---|
123 | make_target=all |
---|
124 | |
---|
125 | submodel_1="" |
---|
126 | |
---|
127 | # |
---|
128 | ################### End of user specifications (defaults) #################### |
---|
129 | |
---|
130 | poss_cpl_mods=" " |
---|
131 | |
---|
132 | |
---|
133 | ######################## Command line parameter ############################### |
---|
134 | # |
---|
135 | # Help function |
---|
136 | # |
---|
137 | if [ "$1" = "--" ] || [ "$1" = "help" ] || [ "$1" = "--help" ] ; then |
---|
138 | echo |
---|
139 | echo '----------- Usage -----------------------------------------------' |
---|
140 | echo ' $1=make_target (all/lib/tar/clean; optional)' |
---|
141 | echo ' $2=message_passing (MPI1/MPI2; optional)' |
---|
142 | echo ' ' |
---|
143 | echo ' Default active values are:' |
---|
144 | echo ' make_target : '${make_target} |
---|
145 | echo ' message_passing : '${message_passing} |
---|
146 | echo ' ' |
---|
147 | echo '-----------------------------------------------------------------' |
---|
148 | exit 1 |
---|
149 | fi |
---|
150 | |
---|
151 | # Overwrite with command line parameter if specified |
---|
152 | |
---|
153 | [ "$1" = "" ] || make_target=$1 |
---|
154 | [ "$2" = "" ] || message_passing=$2 |
---|
155 | |
---|
156 | set -u |
---|
157 | |
---|
158 | ######################## Input checks : all ######################## |
---|
159 | # |
---|
160 | # |
---|
161 | |
---|
162 | if [ "${make_target}" != "clean" ] && \ |
---|
163 | [ "${make_target}" != "all" ] && \ |
---|
164 | [ "${make_target}" != "lib" ] && \ |
---|
165 | [ "${make_target}" != "tar" ]; then |
---|
166 | echo " Invalid target : "${make_target} |
---|
167 | echo " The task is stopped!" |
---|
168 | exit 1 |
---|
169 | fi |
---|
170 | |
---|
171 | if [ "${message_passing}" != "MPI2" ] && \ |
---|
172 | [ "${message_passing}" != "MPI1" ] && \ |
---|
173 | [ "${message_passing}" != "NONE" ]; then |
---|
174 | echo " Invalid option for message passing : "${message_passing} |
---|
175 | echo " The task is stopped!" |
---|
176 | exit 1 |
---|
177 | fi |
---|
178 | |
---|
179 | |
---|
180 | ######################## Set and print input parameter: all ################### |
---|
181 | # |
---|
182 | |
---|
183 | export COUPLER=${coupler} |
---|
184 | |
---|
185 | export MAKETARGET=${make_target} |
---|
186 | echo " " |
---|
187 | echo "Make target : "$MAKETARGET |
---|
188 | |
---|
189 | export CHAN=${message_passing} |
---|
190 | |
---|
191 | |
---|
192 | export TARGETMODE=${target_mode} |
---|
193 | |
---|
194 | # echo ' ' |
---|
195 | if [ "$MAKETARGET" = all ]; then |
---|
196 | echo 'The model will be updated.' |
---|
197 | echo ' Target mode: '$TARGETMODE |
---|
198 | echo ' Message passing : '$CHAN |
---|
199 | elif [ "$MAKETARGET" = lib ]; then |
---|
200 | echo 'The model library will be created; no executable.' |
---|
201 | echo ' Target mode: '$TARGETMODE |
---|
202 | elif [ "$MAKETARGET" = clean ]; then |
---|
203 | echo 'The model build directory and model libraries will be cleaned.' |
---|
204 | elif [ "$MAKETARGET" = tar ]; then |
---|
205 | echo 'A tar-file of the model including all necessary ' |
---|
206 | echo 'libraries will be created.' |
---|
207 | fi |
---|
208 | echo ' ' |
---|
209 | |
---|
210 | if [ $CHAN = NONE ]; then |
---|
211 | export COUPLER=NONE |
---|
212 | fi |
---|
213 | |
---|
214 | export SUBMOD1="" |
---|
215 | export SUBMOD1LIB="" |
---|
216 | |
---|
217 | # |
---|
218 | # Version acronyms must start with "_" |
---|
219 | # |
---|
220 | |
---|
221 | vers_pref=` echo ${model_version} | cut -c1-1 ` |
---|
222 | if [ ! "${vers_pref}" = "_" ] && [ ! "${vers_pref}" = "" ]; then |
---|
223 | echo ERROR: The compile script does not have a valid model version. |
---|
224 | echo ' A model version acronym must start with an underscore.' |
---|
225 | echo ' The compilation is stopped!' |
---|
226 | exit 1 |
---|
227 | fi |
---|
228 | |
---|
229 | export MODVERS=${model_version} |
---|
230 | |
---|
231 | # |
---|
232 | # check against list of possible partner models: |
---|
233 | # |
---|
234 | |
---|
235 | for cpl_mod in ${cpl_to}; do |
---|
236 | cpl_to_ok=not_ok |
---|
237 | for poss_cpl_mod in ${poss_cpl_mods}; do |
---|
238 | if [ ${cpl_mod} = ${poss_cpl_mod} ] || [ ${cpl_mod} = ${MODEL_DIR} ];then |
---|
239 | cpl_to_ok=ok |
---|
240 | fi |
---|
241 | done |
---|
242 | if [ "${cpl_to_ok}" = "not_ok" ]; then |
---|
243 | echo ERROR: Model ${cpl_mod} specified in the list of partner models |
---|
244 | echo ' does not appear in the list of possible partner models.' |
---|
245 | echo ' Check the lists and try again.' |
---|
246 | echo 'The compilation is stopped.' |
---|
247 | exit 1 |
---|
248 | fi |
---|
249 | done |
---|
250 | |
---|
251 | echo '***********************************************************************' |
---|
252 | echo '*' |
---|
253 | if [ "${cpl_to}" = "" ] || [ "${cpl_to}" = " " ] || \ |
---|
254 | [ "${cpl_to}" = ${MODEL_DIR} ]; then |
---|
255 | echo '* The model is prepared for an uncoupled constellation.' |
---|
256 | else |
---|
257 | echo '* The model is prepared for a coupled model constellation with :' |
---|
258 | for cpl_mod in ${cpl_to}; do |
---|
259 | echo '* '${cpl_mod} |
---|
260 | done |
---|
261 | fi |
---|
262 | echo '*' |
---|
263 | echo '***********************************************************************' |
---|
264 | |
---|
265 | if [ ! $CHAN = NONE ] && [ ! $MODEL_DIR = "oasis3" ] && [ "${cpl_to}" = " " ]; then |
---|
266 | echo '***********************************************************************' |
---|
267 | echo '*' |
---|
268 | echo '* Message passing MPI1/2 without partner model is not possible!' |
---|
269 | echo '* The compilation is stopped!' |
---|
270 | echo '*' |
---|
271 | echo '***********************************************************************' |
---|
272 | exit 1 |
---|
273 | fi |
---|
274 | |
---|
275 | # |
---|
276 | # Special parameter check for OASIS3 |
---|
277 | # |
---|
278 | |
---|
279 | |
---|
280 | ############### Site and OS dependent specifications ########################### |
---|
281 | # |
---|
282 | # moon : part of name of header file |
---|
283 | # NODE : where the model is compiled |
---|
284 | |
---|
285 | if [ ${NODE} != moon ]; then |
---|
286 | if [ ${NODE} != moon2 ]; then |
---|
287 | echo ' The OS/Site dependent specifications are not for this machine.' |
---|
288 | echo ' Node name of this machine:' ${NODE} |
---|
289 | echo ' Script setup is for use on a moon node (cross compiling for ES)' |
---|
290 | if [ "$MAKETARGET" != "tar" ]; then |
---|
291 | echo ' The task is stopped!' |
---|
292 | exit 1 |
---|
293 | fi |
---|
294 | fi |
---|
295 | fi |
---|
296 | |
---|
297 | if [ "$MAKETARGET" = "lib" ]; then |
---|
298 | echo ' ' |
---|
299 | echo 'No executable will be created. ' |
---|
300 | fi |
---|
301 | export ARCH=ES |
---|
302 | export BLDROOT=$SRCROOT/$ARCH |
---|
303 | |
---|
304 | set +u |
---|
305 | if [[ -z "$LD_LIBRARY_PATH0" ]]; then |
---|
306 | LD_LIBRARY_PATH0="" |
---|
307 | fi |
---|
308 | set -u |
---|
309 | |
---|
310 | export MPI_INCLUDE=./ |
---|
311 | |
---|
312 | export NETCDFROOT=/S/home010/c0010/ES |
---|
313 | export NETCDF_LIB="-L${NETCDFROOT}/lib -lnetcdf" |
---|
314 | export NETCDF_INCLUDE=${NETCDFROOT}/include |
---|
315 | |
---|
316 | export LIB1=" -L/ES/opt/mathkeisan/inst/lib0 -llapack -lblas " |
---|
317 | |
---|
318 | export SYS_INCLUDE=./ |
---|
319 | |
---|
320 | if [ "$MAKETARGET" = "all" ] || [ "$MAKETARGET" = "lib" ]; then |
---|
321 | echo ' ' |
---|
322 | echo 'Compiler revision :' |
---|
323 | echo ` esf90 -V ` |
---|
324 | fi |
---|
325 | |
---|
326 | export F90com=esmpif90 |
---|
327 | export f90com=${F90com} |
---|
328 | export Fcom=${F90com} |
---|
329 | export fcom=${F90com} |
---|
330 | |
---|
331 | export cc=esmpic++ |
---|
332 | export ar=esar |
---|
333 | export as="esas" |
---|
334 | export cp=cp |
---|
335 | |
---|
336 | PATH=$SRCROOT/util:$PATH |
---|
337 | |
---|
338 | alias make="gmake" |
---|
339 | |
---|
340 | # Compile modes (specified by user) : oasis3 on mercure |
---|
341 | |
---|
342 | if [ $compile_mode = default ]; then |
---|
343 | optc=" " |
---|
344 | optf=" -Wf,-pvctl noassume loopcnt=5000000 " |
---|
345 | optf77=" -Wf,-pvctl noassume loopcnt=5000000 " |
---|
346 | optl=" " |
---|
347 | elif [ $compile_mode = debug ]; then |
---|
348 | optc=" " |
---|
349 | optf=" -Wf,-pvctl noassume loopcnt=5000000 -ftrace" |
---|
350 | optf77=" -Wf,-pvctl noassume loopcnt=5000000 -ftrace" |
---|
351 | optl=" -ftrace" |
---|
352 | elif [ $compile_mode = profile ]; then |
---|
353 | optc=" " |
---|
354 | optf="-Wf,-pvctl noassume loopcnt=5000000 " |
---|
355 | optf77="-Wf,-pvctl noassume loopcnt=5000000 " |
---|
356 | optl="-p" |
---|
357 | elif [ $compile_mode = opt ]; then |
---|
358 | optc="-Chopt" |
---|
359 | optf="-Chopt -Wf,-pvctl noassume loopcnt=5000000 " |
---|
360 | optf77="-Chopt -Wf,-pvctl noassume loopcnt=5000000 " |
---|
361 | optl=" -Wl,-Z 1000000 -pi line=1000" |
---|
362 | elif [ $compile_mode = ad_hoc ]; then |
---|
363 | echo "with this option the options are set through GUI input" |
---|
364 | exit 1 |
---|
365 | else |
---|
366 | echo "Invalid compile mode" |
---|
367 | exit 1 |
---|
368 | fi |
---|
369 | |
---|
370 | # Other compile options |
---|
371 | |
---|
372 | optdbl="-dw -Wf,-A idbl4" |
---|
373 | optnh="" |
---|
374 | lstflags="-Wf,-L fmtlist transform" |
---|
375 | |
---|
376 | # |
---|
377 | # All models should use cpp flag __SX for activation of platform dependent |
---|
378 | # source code on SUPER-SX machines ! |
---|
379 | # |
---|
380 | # `uname -n` : moon (cross compiling only) |
---|
381 | # `uname -s` : HP-UX |
---|
382 | # `uname -m` : |
---|
383 | # |
---|
384 | |
---|
385 | export CPPFLAG="-D__SX -DSX" |
---|
386 | |
---|
387 | export CPPFLAGF90start=" " |
---|
388 | export CPPFLAGSEP=" " |
---|
389 | |
---|
390 | export F90FLAG="-EP ${optf} ${optdbl} ${optnh} ${lstflags}" |
---|
391 | export FFLAG="-EP ${optf77} ${optdbl} ${optnh} ${lstflags}" |
---|
392 | export f90FLAG=${F90FLAG} |
---|
393 | export fFLAG=${FFLAG} |
---|
394 | |
---|
395 | export LDFLAG="-Pstack ${optl} ${optdbl} ${optnh}" |
---|
396 | |
---|
397 | export CCFLAG=${optc} |
---|
398 | |
---|
399 | export AFLAG="-h float0 -m" |
---|
400 | |
---|
401 | export ARFLAG="-rv" |
---|
402 | |
---|
403 | export MPPFLAG=" " |
---|
404 | |
---|
405 | export I4mods="I" |
---|
406 | |
---|
407 | |
---|
408 | |
---|
409 | ################################################################################ |
---|
410 | # |
---|
411 | # OASIS3 CPP flags not depending on site or OS |
---|
412 | # |
---|
413 | |
---|
414 | CPPFLAG=${CPPFLAG}" -Duse_comm_${CHAN}" |
---|
415 | |
---|
416 | export CPPFLAGCC=$CPPFLAG |
---|
417 | |
---|
418 | CPPFLAGF90="" |
---|
419 | for flag in $CPPFLAG ; do |
---|
420 | CPPFLAGF90=$CPPFLAGF90$CPPFLAGSEP$flag |
---|
421 | done |
---|
422 | if [ "$CPPFLAGF90" != "" ]; then |
---|
423 | CPPFLAGF90=$CPPFLAGF90start$CPPFLAGF90 |
---|
424 | fi |
---|
425 | export CPPFLAGF90 |
---|
426 | |
---|
427 | if [ "$MAKETARGET" = "all" ] || [ "$MAKETARGET" = "lib" ]; then |
---|
428 | echo ' ' |
---|
429 | echo "CPP flags used with the cc command: " |
---|
430 | echo $CPPFLAGCC |
---|
431 | echo ' ' |
---|
432 | echo "CPP flags used with the f90 command: " |
---|
433 | echo $CPPFLAGF90 |
---|
434 | fi |
---|
435 | |
---|
436 | |
---|
437 | # |
---|
438 | #-------------------------------------------------------------------------------- |
---|
439 | # Model executable name. |
---|
440 | # |
---|
441 | |
---|
442 | export EXEC=${MODEL_DIR} |
---|
443 | if [ "${SUBMOD1}" != "" ]; then |
---|
444 | EXEC=${EXEC}_${SUBMOD1} |
---|
445 | fi |
---|
446 | EXEC=${EXEC}${MODVERS} |
---|
447 | if [ "${CHAN}" != "NONE" ]; then |
---|
448 | export EXEC=${EXEC}.${CHAN} |
---|
449 | fi |
---|
450 | |
---|
451 | |
---|
452 | ################################################################################ |
---|
453 | # |
---|
454 | # Libraries for oasis3 |
---|
455 | # |
---|
456 | |
---|
457 | export SRCCOMP="src" |
---|
458 | |
---|
459 | export MODLIB=$EXEC |
---|
460 | |
---|
461 | srclibs="anaisg anaism scrip fscint psmile mpp_io" |
---|
462 | if [ "$CHAN" != "NONE" ]; then |
---|
463 | srclibs=${srclibs}" clim" |
---|
464 | fi |
---|
465 | |
---|
466 | export MAINPRG=couple |
---|
467 | # SRCCOMP : model-src directories in order they will be compiled |
---|
468 | # MODLIB : model library/ies (should be one only) |
---|
469 | # srclibs : other PRISM libraries ( $SRCROOT/src/lib...); must be " " if empty |
---|
470 | ################################################################################ |
---|
471 | # |
---|
472 | # Libraries needed by all models |
---|
473 | # |
---|
474 | |
---|
475 | if [ "$MAKETARGET" = "all" ]; then |
---|
476 | if [ "$CHAN" != "NONE" ] && [ "${MODEL_DIR}" != "oasis3" ]; then |
---|
477 | srclibs=${srclibs}" psmile " |
---|
478 | if [ $use_key_noIO != yes ]; then |
---|
479 | srclibs=${srclibs}" mpp_io" |
---|
480 | fi |
---|
481 | fi |
---|
482 | fi |
---|
483 | |
---|
484 | ################################################################################ |
---|
485 | # |
---|
486 | # Directories for tar file |
---|
487 | # |
---|
488 | |
---|
489 | TARFILE_DIRS="" |
---|
490 | for srclib in $srclibs; do |
---|
491 | TARFILE_DIRS=${TARFILE_DIRS}" src/lib/${srclib}" |
---|
492 | done |
---|
493 | TARFILE_DIRS=${TARFILE_DIRS}" src/lib/psmile src/lib/mpp_io " |
---|
494 | if [ "${SUBMOD1}" != "" ]; then |
---|
495 | TARFILE_DIRS=${TARFILE_DIRS}" src/mod/${SUBMOD1}" |
---|
496 | fi |
---|
497 | export TARFILE_DIRS |
---|
498 | |
---|
499 | ################################# Directories ################################ |
---|
500 | # |
---|
501 | # Make the 'build' directories if needed |
---|
502 | # |
---|
503 | |
---|
504 | echo " " |
---|
505 | if [ "$MAKETARGET" = "all" ] || [ "$MAKETARGET" = "lib" ]; then |
---|
506 | echo The model $MODEL_DIR will be updated |
---|
507 | if [ "${srclibs}" != " " ]; then |
---|
508 | echo together with its libraries |
---|
509 | echo $srclibs '.' |
---|
510 | else |
---|
511 | echo No libraries need to be updated. |
---|
512 | fi |
---|
513 | fi |
---|
514 | |
---|
515 | if [ ! -d ${BLDROOT}/lib/$MODEL_DIR ]; then |
---|
516 | echo ' ' |
---|
517 | echo 'Making model library build directory '${BLDROOT}/lib/$MODEL_DIR |
---|
518 | mkdir -p ${BLDROOT}/lib/$MODEL_DIR |
---|
519 | fi |
---|
520 | |
---|
521 | export MODBUILD=${BLDROOT}/build/mod/${MODEL_DIR}${MODVERS} |
---|
522 | if [ ${CHAN} != "NONE" ]; then |
---|
523 | MODBUILD=${MODBUILD}.${CHAN} |
---|
524 | fi |
---|
525 | if [ ! -d $MODBUILD ]; then |
---|
526 | echo ' ' |
---|
527 | echo 'Making build directory '$MODBUILD |
---|
528 | mkdir -p $MODBUILD |
---|
529 | fi |
---|
530 | |
---|
531 | export bin=${BLDROOT}/bin |
---|
532 | [ -d $bin ] || mkdir -p $bin |
---|
533 | |
---|
534 | export OTHLIBS=" " |
---|
535 | if [ "$srclibs" != " " ]; then |
---|
536 | for library in $srclibs ; do |
---|
537 | if [ $library = psmile ] || \ |
---|
538 | [ $library = clim ] ; then |
---|
539 | ldlib=${library}.${CHAN} |
---|
540 | else |
---|
541 | ldlib=${library} |
---|
542 | fi |
---|
543 | OTHLIBS=${OTHLIBS}" -l"$ldlib |
---|
544 | done |
---|
545 | OTHLIBS="-L${BLDROOT}/lib ${OTHLIBS}" |
---|
546 | fi |
---|
547 | |
---|
548 | export MODLIBS=" " |
---|
549 | for library in $MODLIB ; do |
---|
550 | MODLIBS=${MODLIBS}" -l"${library} |
---|
551 | done |
---|
552 | MODLIBS="-L${BLDROOT}/lib/${MODEL_DIR} ${MODLIBS}" |
---|
553 | |
---|
554 | if [ "${SUBMOD1}" != "" ]; then |
---|
555 | MODLIBS=${MODLIBS}" -L${BLDROOT}/lib/${SUBMOD1} -l${SUBMOD1LIB}" |
---|
556 | SUBMOD1LIB=lib${SUBMOD1LIB}.a |
---|
557 | fi |
---|
558 | |
---|
559 | # |
---|
560 | # Dont put paths here; they are included in VPATH |
---|
561 | # |
---|
562 | export DEPLIBS=" " |
---|
563 | for library in $MODLIB $srclibs ; do |
---|
564 | if [ $library = psmile ] || \ |
---|
565 | [ $library = clim ] ; then |
---|
566 | ldlib=${library}.${CHAN} |
---|
567 | else |
---|
568 | ldlib=${library} |
---|
569 | fi |
---|
570 | DEPLIBS=${DEPLIBS}" lib"${ldlib}.a |
---|
571 | done |
---|
572 | |
---|
573 | cd $MODBUILD |
---|
574 | if [ "$MAKETARGET" != "tar" ]; then |
---|
575 | echo ' ' |
---|
576 | echo 'Build directory is '$MODBUILD |
---|
577 | fi |
---|
578 | |
---|
579 | # |
---|
580 | # Update external libraries |
---|
581 | # |
---|
582 | if [ "$MAKETARGET" = "all" ] || [ "$MAKETARGET" = "lib" ]; then |
---|
583 | if [ "$srclibs" != " " ]; then |
---|
584 | echo ' ' |
---|
585 | echo 'Checking the libraries ...' |
---|
586 | if [ ! -f $SRCROOT/util/COMP_libs.${NODE} ]; then |
---|
587 | echo --- $SRCROOT/util/COMP_libs.${NODE} must be created first! --- |
---|
588 | echo --- Use $SRCROOT/util/compile/frames/Create_COMP_libs.frm. --- |
---|
589 | echo --- This script is stopped! |
---|
590 | exit 1 |
---|
591 | fi |
---|
592 | COMP_libs.${NODE} "all" "${srclibs}" "${CHAN}" "${MODEL_DIR}" |
---|
593 | echo 'Checking the libraries finished ' |
---|
594 | echo ' ' |
---|
595 | echo ' ' |
---|
596 | echo 'Library update exit status : ' |
---|
597 | cat $BLDROOT/lib.status |
---|
598 | set +e |
---|
599 | grep -v ': 0' $BLDROOT/lib.status |
---|
600 | if [ $? != 0 ]; then |
---|
601 | echo 'Libraries OK' |
---|
602 | echo ' ' |
---|
603 | else |
---|
604 | echo "ERROR in $SRCROOT/util : Libraries not updated!" |
---|
605 | echo "Check the log file for details!" |
---|
606 | echo ' ' |
---|
607 | exit 1 |
---|
608 | fi |
---|
609 | rm $BLDROOT/lib.status |
---|
610 | set -e |
---|
611 | fi |
---|
612 | fi |
---|
613 | |
---|
614 | # |
---|
615 | # Update submodel |
---|
616 | # |
---|
617 | if [ "$MAKETARGET" = "all" ] || [ "$MAKETARGET" = "clean" ]; then |
---|
618 | if [ "${SUBMOD1}" != "" ]; then |
---|
619 | echo ' ' |
---|
620 | echo 'Checking the submodel '${SUBMOD1} |
---|
621 | COMP_submodel=$SRCROOT/src/mod/${SUBMOD1}/COMP_${SUBMOD1}${MODVERS}.${NODE} |
---|
622 | if [ ! -f ${COMP_submodel} ]; then |
---|
623 | echo --- ${COMP_submodel} must be created first! --- |
---|
624 | echo --- Use $SRCROOT/util/compile/frames/Create_COMP_models.frm. --- |
---|
625 | echo --- This script is stopped! |
---|
626 | exit 1 |
---|
627 | fi |
---|
628 | cpl_to=${cpl_to}" "${MODEL_DIR} |
---|
629 | ${COMP_submodel} "${MAKETARGET}" "${CHAN}" |
---|
630 | echo 'Checking the submodel finished ' |
---|
631 | echo ' ' |
---|
632 | echo 'Submodel update exit status : ' |
---|
633 | cat $BLDROOT/${SUBMOD1}.status |
---|
634 | set +e |
---|
635 | grep -v ': 0' $BLDROOT/${SUBMOD1}.status |
---|
636 | if [ $? != 0 ]; then |
---|
637 | echo 'Submodel '${SUBMOD1}' OK' |
---|
638 | echo ' ' |
---|
639 | else |
---|
640 | echo "ERROR in $SRCROOT/src/mod/${SUBMOD1} : Submodel not updated!" |
---|
641 | echo "Check the log file for details!" |
---|
642 | echo ' ' |
---|
643 | exit 1 |
---|
644 | fi |
---|
645 | rm $BLDROOT/${SUBMOD1}.status |
---|
646 | set -e |
---|
647 | fi |
---|
648 | fi |
---|
649 | |
---|
650 | |
---|
651 | ################################################################################ |
---|
652 | # |
---|
653 | # Create the top level Makefile |
---|
654 | # |
---|
655 | |
---|
656 | cat > Top_Makefile_$$ <<'EOF1' |
---|
657 | |
---|
658 | export |
---|
659 | |
---|
660 | SHELL = /bin/ksh |
---|
661 | |
---|
662 | builddir = ./ |
---|
663 | |
---|
664 | prefix = ../../../.. |
---|
665 | |
---|
666 | includedir = ${prefix}/include |
---|
667 | |
---|
668 | configdir = ${prefix}/config |
---|
669 | |
---|
670 | exec_prefix = ../../.. |
---|
671 | |
---|
672 | top_builddir = $(exec_prefix)/build |
---|
673 | |
---|
674 | bindir = $(exec_prefix)/bin |
---|
675 | |
---|
676 | libdir = $(exec_prefix)/lib |
---|
677 | |
---|
678 | INCLUDES = -I$(NETCDF_INCLUDE) -I$(MPI_INCLUDE) -I$(SYS_INCLUDE) |
---|
679 | |
---|
680 | F90 = ${F90com} |
---|
681 | f90 = ${f90com} |
---|
682 | F = ${Fcom} |
---|
683 | f = ${fcom} |
---|
684 | CC = $(cc) |
---|
685 | CPP = ${cc} -E |
---|
686 | AR = ${ar} |
---|
687 | AS = ${as} |
---|
688 | |
---|
689 | AFLAGS = $(AFLAG) |
---|
690 | |
---|
691 | ARFLAGS = $(ARFLAG) |
---|
692 | |
---|
693 | CCFLAGS = -I$(configdir) -I$(SYS_INCLUDE) $(CCFLAG) $(CPPFLAGCC) |
---|
694 | |
---|
695 | F90FLAGS = $(F90FLAG) $(INCLUDES) $(CPPFLAGF90) |
---|
696 | |
---|
697 | FFLAGS = $(FFLAG) $(INCLUDES) $(CPPFLAGF90) |
---|
698 | |
---|
699 | f90FLAGS = $(f90FLAG) $(INCLUDES) $(CPPFLAGF90) |
---|
700 | |
---|
701 | fFLAGS = $(fFLAG) $(INCLUDES) $(CPPFLAGF90) |
---|
702 | |
---|
703 | top_srcdir = $(prefix)/src/mod/${MODEL_DIR} |
---|
704 | |
---|
705 | LIBS = $(MODLIBS) $(OTHLIBS) $(NETCDF_LIB) $(MPI_LIB) $(LIB1) $(LIB2) $(LIB3) |
---|
706 | |
---|
707 | LDFLAGS = $(LDFLAG) |
---|
708 | |
---|
709 | lib: all |
---|
710 | |
---|
711 | all: |
---|
712 | @for SRCDIR in $(SRCCOMP) ;\ |
---|
713 | do \ |
---|
714 | export SRC=$$SRCDIR;\ |
---|
715 | echo Now updating : $$SRCDIR ...;\ |
---|
716 | $(MAKE) -f $(top_srcdir)/$$SRCDIR/Makefile $(MAKETARGET); status=$$? ; \ |
---|
717 | echo $$SRCDIR ':' $$status >> $(BLDROOT)/$(MODEL_DIR).status ; \ |
---|
718 | if [ $$status != 0 ] ; then \ |
---|
719 | echo "Exit status from make was $$status" ; \ |
---|
720 | fi ; \ |
---|
721 | done |
---|
722 | |
---|
723 | clean: |
---|
724 | @for SRCDIR in $(SRCCOMP) ;\ |
---|
725 | do \ |
---|
726 | export SRC=$$SRCDIR;\ |
---|
727 | echo Now cleaning : $$SRCDIR ...;\ |
---|
728 | $(MAKE) -f $(top_srcdir)/$$SRCDIR/Makefile $(MAKETARGET); status=$$? ; \ |
---|
729 | echo $$SRCDIR ':' $$status >> $(BLDROOT)/$(MODEL_DIR).status ; \ |
---|
730 | if [ $$status != 0 ] ; then \ |
---|
731 | echo "Exit status from cleaning was $$status" ; \ |
---|
732 | fi ; \ |
---|
733 | done |
---|
734 | |
---|
735 | tar: |
---|
736 | cd $(prefix) ; \ |
---|
737 | tar -cvf $(TARFILE) \ |
---|
738 | src/mod/$(MODEL_DIR)/*/* \ |
---|
739 | $(TARFILE_DIRS) \ |
---|
740 | util/compile util/running |
---|
741 | |
---|
742 | EOF1 |
---|
743 | # src/mod/$(MODEL_DIR)/COMP_$(MODEL_DIR).moon util/COMP_libs.moon \ |
---|
744 | |
---|
745 | |
---|
746 | stdout=$SCRIPTDIR/COMP_${MODEL_DIR}.log |
---|
747 | stderr=$SCRIPTDIR/COMP_${MODEL_DIR}.err |
---|
748 | |
---|
749 | if [ -f $BLDROOT/oasis3.status ]; then rm $BLDROOT/oasis3.status; fi |
---|
750 | |
---|
751 | ################################################################################ |
---|
752 | # |
---|
753 | # Execute makefile : -p : listing of all default rules |
---|
754 | # -d : debug |
---|
755 | # -k : dont stop when error occurs |
---|
756 | # |
---|
757 | |
---|
758 | if [ -f ${stdout} ] ; then |
---|
759 | rm -f ${stdout} |
---|
760 | fi |
---|
761 | if [ -f ${stderr} ] ; then |
---|
762 | rm -f ${stderr} |
---|
763 | fi |
---|
764 | |
---|
765 | make -f Top_Makefile_$$ $MAKETARGET -k |
---|
766 | |
---|
767 | if [ ! "$MAKETARGET" = "clean" ]; then |
---|
768 | rm Top_Makefile_$$ |
---|
769 | fi |
---|
770 | |
---|
771 | |
---|
772 | # |
---|
773 | # Print compilation status |
---|
774 | # |
---|
775 | |
---|
776 | if [ $MAKETARGET != "tar" ] ; then |
---|
777 | echo ' ' |
---|
778 | cat $BLDROOT/${MODEL_DIR}.status |
---|
779 | set +e |
---|
780 | grep -v ': 0' $BLDROOT/${MODEL_DIR}.status |
---|
781 | if [ $? != 0 ]; then |
---|
782 | if [ $MAKETARGET = all ]; then echo ${MODEL_DIR}' ... is up-to-date!' ; fi |
---|
783 | if [ $MAKETARGET = clean ]; then echo ${MODEL_DIR}' ... is cleaned!' ; fi |
---|
784 | echo ' ' |
---|
785 | else |
---|
786 | if [ $MAKETARGET = all ]; then echo 'Updating '${MODEL_DIR}' failed!' ; fi |
---|
787 | if [ $MAKETARGET = clean ]; then echo 'Cleaning '${MODEL_DIR}' failed!' ; fi |
---|
788 | echo 'Compilation of '${MODEL_DIR}' is stopped!' |
---|
789 | exit 1 |
---|
790 | fi |
---|
791 | set -e |
---|
792 | fi |
---|
793 | echo ' ' |
---|
794 | |
---|
795 | # |
---|
796 | ################################################################################ |
---|
797 | |
---|
798 | |
---|
799 | # |
---|
800 | #-------------------------------------------------------------------------------- |
---|
801 | # Save executable |
---|
802 | # |
---|
803 | |
---|
804 | if [ "$MAKETARGET" = "all" ]; then |
---|
805 | |
---|
806 | cd $bin |
---|
807 | |
---|
808 | if [ -f ${EXEC}.x ]; then |
---|
809 | execname=${EXEC}.x |
---|
810 | if [ ${MODEL_DIR} = "mpi-om" ]; then |
---|
811 | if [ $newstart = yes ]; then |
---|
812 | execname=${EXEC}_newstart.x |
---|
813 | mv ${EXEC}.x ${execname} |
---|
814 | echo '-------------------------------------------------------------' |
---|
815 | echo ' You created the executable to start from initial conditions.' |
---|
816 | echo ' To create the executable for the following runs ' |
---|
817 | echo ' edit the compile script COMP_'${MODEL_DIR}'.'${NODE}'' |
---|
818 | echo ' and set newstart=no (instead of newstart=yes)' |
---|
819 | echo ' then run it again.' |
---|
820 | echo '------------------------------------------------------------' |
---|
821 | fi |
---|
822 | fi |
---|
823 | echo ' ' |
---|
824 | echo 'Executable : '$bin/$execname |
---|
825 | if [ ${MODEL_DIR} = "lmdz" ]; then |
---|
826 | if [ -f ${EXEC}_newstart.x ]; then |
---|
827 | echo 'Second Executable : '$bin/${EXEC}_newstart.x |
---|
828 | else |
---|
829 | echo 'ERROR creating second executable used for newstart' |
---|
830 | fi |
---|
831 | fi |
---|
832 | if [ ${MODEL_DIR} = "oasis3" ]; then |
---|
833 | cp -p ${EXEC}.x ../../../bin/oasis |
---|
834 | fi |
---|
835 | else |
---|
836 | echo ' ' |
---|
837 | echo 'No executable created.' |
---|
838 | echo ' ' |
---|
839 | fi |
---|
840 | |
---|
841 | fi |
---|
842 | |
---|
843 | exit |
---|