12 |
# Guess possible config options for this host |
# Guess possible config options for this host |
13 |
find_possible_configs() { |
find_possible_configs() { |
14 |
|
|
15 |
p_PLATFORM=`uname`"-"`uname -m` |
tmp1=`uname`"_"`uname -m` |
16 |
echo "The platform appears to be:" |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
17 |
echo " "$p_PLATFORM |
PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'` |
18 |
|
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
19 |
p_LN= |
echo " The platform appears to be: $PLATFORM" |
20 |
|
# if test "x$OFLIST" = x ; then |
21 |
|
# echo " No pre-defined options files were found matching this platform" |
22 |
|
# echo " but examples for other platforms can be found in:" |
23 |
|
# echo " $ROOTDIR/tools/build_options" |
24 |
|
# else |
25 |
|
# echo " Options files (located in $ROOTDIR/tools/build_options) that" |
26 |
|
# echo " may work with this machine are:" |
27 |
|
# for i in $OFLIST ; do |
28 |
|
# echo " $i" |
29 |
|
# done |
30 |
|
# fi |
31 |
|
|
32 |
echo "test" > test |
echo "test" > test |
33 |
ln -s ./test link |
ln -s ./test link |
34 |
RETVAL=$? |
RETVAL=$? |
35 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
36 |
p_LN="ln -s" |
LN="ln -s" |
37 |
|
else |
38 |
|
echo "Error: \"ln -s\" does not appear to work on this system!" |
39 |
|
echo " For help, please contact <MITgcm-support@mitgcm.org>." |
40 |
|
exit 1 |
41 |
fi |
fi |
42 |
rm -f test link |
rm -f test link |
43 |
|
|
44 |
p_CPP=`which cpp` |
if test "x$CPP" = x ; then |
45 |
|
CPP="cpp -traditional -P" |
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
p_LN="ln -s" |
|
46 |
fi |
fi |
|
rm -f test link |
|
47 |
|
|
48 |
# look for possible fortran compilers |
# look for possible fortran compilers |
49 |
|
tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
50 |
p_FC= |
p_FC= |
51 |
for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do |
for c in $tmp ; do |
52 |
which $c > /dev/null 2>&1 |
rm -f ./hello.f ./hello |
53 |
|
cat >> hello.f <<EOF |
54 |
|
program hello |
55 |
|
do i=1,3 |
56 |
|
print *, 'hello world : ', i |
57 |
|
enddo |
58 |
|
end |
59 |
|
EOF |
60 |
|
$c -o hello hello.f > /dev/null 2>&1 |
61 |
RETVAL=$? |
RETVAL=$? |
62 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
63 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
64 |
fi |
fi |
65 |
done |
done |
|
echo "Possible FORTRAN compilers appear to be: " |
|
66 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
67 |
echo " None found!!!" |
cat 1>&2 <<EOF |
68 |
|
|
69 |
|
Error: No Fortran compilers were found in your path. Please specify one using: |
70 |
|
|
71 |
|
1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"), |
72 |
|
2) a command-line option (eg. "-fc NAME"), or |
73 |
|
3) the MITGCM_FC environment variable. |
74 |
|
|
75 |
|
EOF |
76 |
|
exit 1 |
77 |
else |
else |
78 |
echo " "$p_FC |
echo " The possible FORTRAN compilers found in your path are:" |
79 |
|
echo " "$p_FC |
80 |
|
if test "x$FC" = x ; then |
81 |
|
FC=`echo $p_FC | awk '{print $1}'` |
82 |
|
fi |
83 |
fi |
fi |
84 |
|
|
85 |
# look for possible MPI libraries |
for i in $p_FC ; do |
86 |
mpi_libs= |
p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i |
87 |
mpi_fort=`which mpif77 2>/dev/null` |
if test -r $p_OF ; then |
88 |
RETVAL=$? |
OPTFILE=$p_OF |
89 |
if test "x${RETVAL}" = x0 ; then |
echo " The options file: $p_OF" |
90 |
cat >>test.f <<EOF |
echo " appears to match so we'll use it." |
91 |
PROGRAM HELLO |
break |
|
DO 10, I=1,10 |
|
|
PRINT *,'Hello World' |
|
|
10 CONTINUE |
|
|
STOP |
|
|
END |
|
|
EOF |
|
|
eval "$mpi_fort -showme test.f > out" |
|
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
a=`cat out` |
|
|
for i in $a ; do |
|
|
case $i in |
|
|
-*) |
|
|
mpi_libs="$mpi_libs $i" ;; |
|
|
esac |
|
|
done |
|
|
echo "The MPI libs appear to be:" |
|
|
echo " "$mpi_libs |
|
92 |
fi |
fi |
93 |
rm -f test.f out |
done |
94 |
|
if test "x$OPTFILE" = x ; then |
95 |
|
cat 1>&2 <<EOF |
96 |
|
|
97 |
|
Error: No options file was found in: $ROOTDIR/tools/build_options/ |
98 |
|
that matches this platform ("$PLATFORM") and the compilers found in |
99 |
|
your path. Please specify an "optfile" using: |
100 |
|
|
101 |
|
1) the command line (eg. "-optfile=path/to/OPTFILE"), or |
102 |
|
2) the MITGCM_OF environment variable. |
103 |
|
|
104 |
|
If you need help, please contact the developers at <MITgcm-support@mitgcm.org>. |
105 |
|
|
106 |
|
EOF |
107 |
|
exit 1 |
108 |
fi |
fi |
109 |
|
|
110 |
|
# # look for possible MPI libraries |
111 |
|
# mpi_libs= |
112 |
|
# mpi_fort=`which mpif77 2>/dev/null` |
113 |
|
# RETVAL=$? |
114 |
|
# if test "x${RETVAL}" = x0 ; then |
115 |
|
# cat >>test.f <<EOF |
116 |
|
# PROGRAM HELLO |
117 |
|
# DO 10, I=1,10 |
118 |
|
# PRINT *,'Hello World' |
119 |
|
# 10 CONTINUE |
120 |
|
# STOP |
121 |
|
# END |
122 |
|
# EOF |
123 |
|
# eval "$mpi_fort -showme test.f > out" |
124 |
|
# RETVAL=$? |
125 |
|
# if test "x${RETVAL}" = x0 ; then |
126 |
|
# a=`cat out` |
127 |
|
# for i in $a ; do |
128 |
|
# case $i in |
129 |
|
# -*) |
130 |
|
# mpi_libs="$mpi_libs $i" ;; |
131 |
|
# esac |
132 |
|
# done |
133 |
|
# echo "The MPI libs appear to be:" |
134 |
|
# echo " "$mpi_libs |
135 |
|
# fi |
136 |
|
# rm -f test.f out |
137 |
|
# fi |
138 |
|
|
139 |
} |
} |
140 |
|
|
230 |
KPP= |
KPP= |
231 |
FC= |
FC= |
232 |
LINK= |
LINK= |
233 |
|
DEFINES="-DWORDLENGTH=4" |
234 |
PACKAGES= |
PACKAGES= |
235 |
ENABLE= |
ENABLE= |
236 |
DISABLE= |
DISABLE= |
237 |
MAKEFILE= |
MAKEFILE= |
238 |
MAKEDEPEND= |
MAKEDEPEND= |
239 |
PDEPEND= |
PDEPEND= |
240 |
DUMPSTATE=f |
DUMPSTATE=t |
241 |
PDEFAULT= |
PDEFAULT= |
242 |
OPTFILE= |
OPTFILE= |
243 |
INCLUDES="-I." |
INCLUDES="-I." |
420 |
|
|
421 |
done |
done |
422 |
|
|
423 |
echo " getting OPTFILE information: " |
if test "x${ROOTDIR}" = x ; then |
424 |
if test "x${OPTFILE}" = x ; then |
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
425 |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
ROOTDIR=".." |
|
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
|
|
find_possible_configs |
|
|
else |
|
|
if test "x$OPTFILE" = xNONE ; then |
|
|
echo " OPTFILE=NONE so we'll try to use default settings" |
|
426 |
else |
else |
427 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
428 |
echo " using OPTFILE=\"$OPTFILE\"" |
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
429 |
source "$OPTFILE" |
ROOTDIR=$d |
430 |
RETVAL=$? |
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
431 |
if test "x$RETVAL" != x0 ; then |
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
432 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
break |
|
echo "--please check that variable syntax is bash-compatible" |
|
|
exit 1 |
|
|
fi |
|
|
if test "x$DUMPSTATE" != xf ; then |
|
|
cp -f $OPTFILE "gm_optfile" |
|
433 |
fi |
fi |
434 |
else |
done |
435 |
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
fi |
436 |
|
fi |
437 |
|
if test "x${ROOTDIR}" = x ; then |
438 |
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
439 |
|
echo " Please specify a ROOTDIR using either an options " |
440 |
|
echo " file or a command-line option." |
441 |
|
exit 1 |
442 |
|
fi |
443 |
|
if test ! -d ${ROOTDIR} ; then |
444 |
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
445 |
|
exit 1 |
446 |
|
fi |
447 |
|
|
448 |
|
echo " getting OPTFILE information: " |
449 |
|
if test "x${OPTFILE}" = x ; then |
450 |
|
if test "x$MITGCM_OF" = x ; then |
451 |
|
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
452 |
|
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
453 |
|
find_possible_configs |
454 |
|
else |
455 |
|
OPTFILE=$MITGCM_OF |
456 |
|
fi |
457 |
|
fi |
458 |
|
if test "x$OPTFILE" != xNONE ; then |
459 |
|
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
460 |
|
echo " using OPTFILE=\"$OPTFILE\"" |
461 |
|
source "$OPTFILE" |
462 |
|
RETVAL=$? |
463 |
|
if test "x$RETVAL" != x0 ; then |
464 |
|
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
465 |
|
echo "--please check that variable syntax is bash-compatible" |
466 |
exit 1 |
exit 1 |
467 |
fi |
fi |
468 |
|
if test "x$DUMPSTATE" != xf ; then |
469 |
|
cp -f $OPTFILE "gm_optfile" |
470 |
|
fi |
471 |
|
else |
472 |
|
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
473 |
|
exit 1 |
474 |
fi |
fi |
475 |
fi |
fi |
476 |
|
|
490 |
LINK=$FC |
LINK=$FC |
491 |
fi |
fi |
492 |
if test "x$CPP" = x ; then |
if test "x$CPP" = x ; then |
493 |
|
CPP="cpp" |
494 |
|
fi |
495 |
|
echo "#define A a" | cpp > test_cpp 2>&1 |
496 |
|
RETVAL=$? |
497 |
|
if test "x$RETVAL" != x0 ; then |
498 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |
499 |
|
|
500 |
Error: no C pre-processor: please specify using one of the following: |
Error: C pre-processor "$CPP" failed the test case: please specify using: |
501 |
|
|
502 |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
503 |
2) the "./gm_local" file |
2) the "./gm_local" file |
|
EOF |
|
|
exit 1 |
|
|
fi |
|
|
if test "x$S64" = x ; then |
|
|
cat <<EOF 1>&2 |
|
504 |
|
|
|
Error: no C pre-processor: please specify using one of the following: |
|
|
1) within the options file ("S64=...") as specified by "-of=OPTFILE" |
|
|
2) the "./gm_local" file |
|
505 |
EOF |
EOF |
506 |
exit 1 |
exit 1 |
507 |
|
else |
508 |
|
rm -f test_cpp |
509 |
|
fi |
510 |
|
if test "x$MAKEDEPEND" = x ; then |
511 |
|
MAKEDEPEND=makedepend |
512 |
fi |
fi |
|
|
|
513 |
|
|
514 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
515 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
533 |
PLATFORM=$p_PLATFORM |
PLATFORM=$p_PLATFORM |
534 |
fi |
fi |
535 |
|
|
|
if test "x${ROOTDIR}" = x ; then |
|
|
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
|
|
ROOTDIR=".." |
|
|
else |
|
|
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
|
|
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
|
|
ROOTDIR=$d |
|
|
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
|
|
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
|
|
break |
|
|
fi |
|
|
done |
|
|
fi |
|
|
fi |
|
|
if test "x${ROOTDIR}" = x ; then |
|
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
|
|
echo " Please specify a ROOTDIR using either an options " |
|
|
echo " file or a command-line option." |
|
|
exit 1 |
|
|
fi |
|
|
if test ! -d ${ROOTDIR} ; then |
|
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
|
|
exit 1 |
|
|
fi |
|
|
|
|
536 |
if test "x${EXEDIR}" = x ; then |
if test "x${EXEDIR}" = x ; then |
537 |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
538 |
EXEDIR=../exe |
EXEDIR=../exe |
552 |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
553 |
exit 1 |
exit 1 |
554 |
fi |
fi |
555 |
|
if test "x$S64" = x ; then |
556 |
|
S64='$(TOOLSDIR)/set64bitConst.sh' |
557 |
|
fi |
558 |
|
|
559 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
560 |
|
|
761 |
# done |
# done |
762 |
# echo |
# echo |
763 |
|
|
764 |
echo " Setting package-specific CPP flags in CPP_OPTIONS.h:" |
echo " Searching for CPP_OPTIONS.h (macros and flags for configuring the model):" |
765 |
CPP_OPTIONS= |
CPP_OPTIONS= |
766 |
spaths="$SOURCEDIRS" |
spaths=". $SOURCEDIRS" |
767 |
for i in $spaths ; do |
for i in $spaths ; do |
768 |
try="$i/CPP_OPTIONS.h" |
try="$i/CPP_OPTIONS.h" |
769 |
# echo -n " trying $try : " |
# echo -n " trying $try : " |
790 |
fi |
fi |
791 |
cat <<EOF >>CPP_OPTIONS.h.tmp |
cat <<EOF >>CPP_OPTIONS.h.tmp |
792 |
C=== GENMAKE v2 === |
C=== GENMAKE v2 === |
793 |
C The following defines have been set by GENMAKE, so please edit |
C The following defines have been set by GENMAKE, so please do not |
794 |
C them only if you know what you're doing. In general, you should |
C edit anything below these comments. In general, you should |
795 |
C add or remove packages by re-running genmake with different |
C add or remove packages by re-running genmake with different |
796 |
C "-enable" and/or "-disable" options. |
C "-enable" and/or "-disable" options. |
797 |
|
|
898 |
echo -n 'CSRCFILES = ' > csrclist.inc |
echo -n 'CSRCFILES = ' > csrclist.inc |
899 |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
900 |
echo -n 'HEADERFILES = ' > hlist.inc |
echo -n 'HEADERFILES = ' > hlist.inc |
901 |
alldirs=". $SOURCEDIRS $INCLUDEDIRS" |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
902 |
for d in $alldirs ; do |
for d in $alldirs ; do |
903 |
deplist= |
deplist= |
904 |
sfiles=`( cd $d; echo *.[h,c,F] )` |
sfiles=`( cd $d; echo *.[h,c,F] )` |