8 |
# modified by aja 01/00 |
# modified by aja 01/00 |
9 |
# rewritten in bash by eh3 08/03 |
# rewritten in bash by eh3 08/03 |
10 |
|
|
11 |
|
# Search for particular CPP #cmds associated with packages |
12 |
|
# usage: test_for_package_in_cpp_options CPP_file package_name |
13 |
|
test_for_package_in_cpp_options() { |
14 |
|
cpp_options=$1 |
15 |
|
pkg=$2 |
16 |
|
grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
17 |
|
RETVAL=$? |
18 |
|
if test "x${RETVAL}" = x0 ; then |
19 |
|
echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg" |
20 |
|
exit 99 |
21 |
|
fi |
22 |
|
grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
23 |
|
RETVAL=$? |
24 |
|
if test "x${RETVAL}" = x0 ; then |
25 |
|
echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg" |
26 |
|
exit 99 |
27 |
|
fi |
28 |
|
grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
29 |
|
RETVAL=$? |
30 |
|
if test "x${RETVAL}" = x0 ; then |
31 |
|
echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg" |
32 |
|
exit 99 |
33 |
|
fi |
34 |
|
grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
35 |
|
RETVAL=$? |
36 |
|
if test "x${RETVAL}" = x0 ; then |
37 |
|
echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg" |
38 |
|
exit 99 |
39 |
|
fi |
40 |
|
} |
41 |
|
|
42 |
|
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
43 |
|
# the package list. |
44 |
|
expand_pkg_groups() { |
45 |
|
new_packages= |
46 |
|
PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" |
47 |
|
if test -r $PKG_GROUPS ; then |
48 |
|
cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp |
49 |
|
cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp |
50 |
|
matched=0 |
51 |
|
for i in $PACKAGES ; do |
52 |
|
line=`grep "^ *$i" ./p2.tmp` |
53 |
|
RETVAL=$? |
54 |
|
if test "x$RETVAL" = x0 ; then |
55 |
|
matched=1 |
56 |
|
replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'` |
57 |
|
echo " replacing \"$i\" with: $replace" |
58 |
|
new_packages="$new_packages $replace" |
59 |
|
else |
60 |
|
new_packages="$new_packages $i" |
61 |
|
fi |
62 |
|
done |
63 |
|
PACKAGES=$new_packages |
64 |
|
rm -f ./p[1,2].tmp |
65 |
|
else |
66 |
|
echo "Warning: can't read package groups definition file: $PKG_GROUPS" |
67 |
|
fi |
68 |
|
} |
69 |
|
|
70 |
# Guess possible config options for this host |
# Guess possible config options for this host |
71 |
find_possible_configs() { |
find_possible_configs() { |
72 |
|
|
73 |
p_PLATFORM=`uname`"-"`uname -m` |
tmp1=`uname`"_"`uname -m` |
74 |
echo "The platform appears to be:" |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
75 |
echo " "$p_PLATFORM |
PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
76 |
|
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
77 |
p_LN= |
echo " The platform appears to be: $PLATFORM" |
78 |
|
# if test "x$OFLIST" = x ; then |
79 |
|
# echo " No pre-defined options files were found matching this platform" |
80 |
|
# echo " but examples for other platforms can be found in:" |
81 |
|
# echo " $ROOTDIR/tools/build_options" |
82 |
|
# else |
83 |
|
# echo " Options files (located in $ROOTDIR/tools/build_options) that" |
84 |
|
# echo " may work with this machine are:" |
85 |
|
# for i in $OFLIST ; do |
86 |
|
# echo " $i" |
87 |
|
# done |
88 |
|
# fi |
89 |
|
|
90 |
echo "test" > test |
echo "test" > test |
91 |
ln -s ./test link |
ln -s ./test link |
92 |
RETVAL=$? |
RETVAL=$? |
93 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
94 |
p_LN="ln -s" |
LN="ln -s" |
95 |
|
else |
96 |
|
echo "Error: \"ln -s\" does not appear to work on this system!" |
97 |
|
echo " For help, please contact <MITgcm-support@mitgcm.org>." |
98 |
|
exit 1 |
99 |
fi |
fi |
100 |
rm -f test link |
rm -f test link |
101 |
|
|
102 |
p_CPP=`which cpp` |
if test "x$CPP" = x ; then |
103 |
|
CPP="cpp -traditional -P" |
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
p_LN="ln -s" |
|
104 |
fi |
fi |
|
rm -f test link |
|
105 |
|
|
106 |
# look for possible fortran compilers |
# look for possible fortran compilers |
107 |
|
tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
108 |
p_FC= |
p_FC= |
109 |
for c in f77 g77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 ; do |
for c in $tmp ; do |
110 |
which $c > /dev/null 2>&1 |
rm -f ./hello.f ./hello |
111 |
|
cat >> hello.f <<EOF |
112 |
|
program hello |
113 |
|
do i=1,3 |
114 |
|
print *, 'hello world : ', i |
115 |
|
enddo |
116 |
|
end |
117 |
|
EOF |
118 |
|
$c -o hello hello.f > /dev/null 2>&1 |
119 |
RETVAL=$? |
RETVAL=$? |
120 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
121 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
122 |
fi |
fi |
123 |
done |
done |
|
echo "Possible FORTRAN compilers appear to be: " |
|
124 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
125 |
echo " None found!!!" |
cat 1>&2 <<EOF |
126 |
|
|
127 |
|
Error: No Fortran compilers were found in your path. Please specify one using: |
128 |
|
|
129 |
|
1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"), |
130 |
|
2) a command-line option (eg. "-fc NAME"), or |
131 |
|
3) the MITGCM_FC environment variable. |
132 |
|
|
133 |
|
EOF |
134 |
|
exit 1 |
135 |
else |
else |
136 |
echo " "$p_FC |
echo " The possible FORTRAN compilers found in your path are:" |
137 |
|
echo " "$p_FC |
138 |
|
if test "x$FC" = x ; then |
139 |
|
FC=`echo $p_FC | $AWK '{print $1}'` |
140 |
|
fi |
141 |
fi |
fi |
142 |
|
|
143 |
# look for possible MPI libraries |
for i in $p_FC ; do |
144 |
mpi_libs= |
p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i |
145 |
mpi_fort=`which mpif77 2>/dev/null` |
if test -r $p_OF ; then |
146 |
RETVAL=$? |
OPTFILE=$p_OF |
147 |
if test "x${RETVAL}" = x0 ; then |
echo " The options file: $p_OF" |
148 |
cat >>test.f <<EOF |
echo " appears to match so we'll use it." |
149 |
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 |
|
150 |
fi |
fi |
151 |
rm -f test.f out |
done |
152 |
|
if test "x$OPTFILE" = x ; then |
153 |
|
cat 1>&2 <<EOF |
154 |
|
|
155 |
|
Error: No options file was found in: $ROOTDIR/tools/build_options/ |
156 |
|
that matches this platform ("$PLATFORM") and the compilers found in |
157 |
|
your path. Please specify an "optfile" using: |
158 |
|
|
159 |
|
1) the command line (eg. "-optfile=path/to/OPTFILE"), or |
160 |
|
2) the MITGCM_OF environment variable. |
161 |
|
|
162 |
|
If you need help, please contact the developers at <MITgcm-support@mitgcm.org>. |
163 |
|
|
164 |
|
EOF |
165 |
|
exit 1 |
166 |
fi |
fi |
167 |
|
|
168 |
|
# # look for possible MPI libraries |
169 |
|
# mpi_libs= |
170 |
|
# mpi_fort=`which mpif77 2>/dev/null` |
171 |
|
# RETVAL=$? |
172 |
|
# if test "x${RETVAL}" = x0 ; then |
173 |
|
# cat >>test.f <<EOF |
174 |
|
# PROGRAM HELLO |
175 |
|
# DO 10, I=1,10 |
176 |
|
# PRINT *,'Hello World' |
177 |
|
# 10 CONTINUE |
178 |
|
# STOP |
179 |
|
# END |
180 |
|
# EOF |
181 |
|
# eval "$mpi_fort -showme test.f > out" |
182 |
|
# RETVAL=$? |
183 |
|
# if test "x${RETVAL}" = x0 ; then |
184 |
|
# a=`cat out` |
185 |
|
# for i in $a ; do |
186 |
|
# case $i in |
187 |
|
# -*) |
188 |
|
# mpi_libs="$mpi_libs $i" ;; |
189 |
|
# esac |
190 |
|
# done |
191 |
|
# echo "The MPI libs appear to be:" |
192 |
|
# echo " "$mpi_libs |
193 |
|
# fi |
194 |
|
# rm -f test.f out |
195 |
|
# fi |
196 |
|
|
197 |
} |
} |
198 |
|
|
202 |
# strip the comments and then convert the dependency file into |
# strip the comments and then convert the dependency file into |
203 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
204 |
cat $1 | sed -e 's/#.*$//g' \ |
cat $1 | sed -e 's/#.*$//g' \ |
205 |
| awk 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ |
| $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ |
206 |
> ./.pd_tmp |
> ./.pd_tmp |
207 |
source ./.pd_tmp |
source ./.pd_tmp |
208 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
239 |
echo " -disable=NAME | --disable=NAME" |
echo " -disable=NAME | --disable=NAME" |
240 |
echo " -enable NAME | --enable NAME" |
echo " -enable NAME | --enable NAME" |
241 |
echo " -enable=NAME | --enable=NAME" |
echo " -enable=NAME | --enable=NAME" |
242 |
|
echo " -standarddirs NAME | --standarddirs NAME" |
243 |
|
echo " -standarddirs=NAME | --standarddirs=NAME" |
244 |
echo " -noopt NAME | --noopt NAME" |
echo " -noopt NAME | --noopt NAME" |
245 |
echo " -noopt=NAME | --noopt=NAME" |
echo " -noopt=NAME | --noopt=NAME" |
246 |
# echo " -cpp NAME | --cpp NAME" |
# echo " -cpp NAME | --cpp NAME" |
290 |
KPP= |
KPP= |
291 |
FC= |
FC= |
292 |
LINK= |
LINK= |
293 |
|
DEFINES="-DWORDLENGTH=4" |
294 |
PACKAGES= |
PACKAGES= |
295 |
ENABLE= |
ENABLE= |
296 |
DISABLE= |
DISABLE= |
297 |
MAKEFILE= |
MAKEFILE= |
298 |
MAKEDEPEND= |
MAKEDEPEND= |
299 |
PDEPEND= |
PDEPEND= |
300 |
DUMPSTATE=f |
DUMPSTATE=t |
301 |
PDEFAULT= |
PDEFAULT= |
302 |
OPTFILE= |
OPTFILE= |
303 |
INCLUDES="-I." |
INCLUDES="-I." |
315 |
TOOLSDIR= |
TOOLSDIR= |
316 |
SOURCEDIRS= |
SOURCEDIRS= |
317 |
INCLUDEDIRS= |
INCLUDEDIRS= |
318 |
|
STANDARDDIRS= |
319 |
|
|
320 |
PWD=`pwd` |
PWD=`pwd` |
321 |
MAKE=make |
MAKE=make |
322 |
|
AWK=awk |
323 |
THISHOSTNAME=`hostname` |
THISHOSTNAME=`hostname` |
324 |
THISCWD=`pwd` |
THISCWD=`pwd` |
325 |
THISDATE=`date` |
THISDATE=`date` |
326 |
MACHINE=`uname -a` |
MACHINE=`uname -a` |
327 |
|
EXECUTABLE= |
328 |
|
EXEHOOK= |
329 |
|
EXEDIR= |
330 |
|
PACKAGES_CONF= |
331 |
|
IEEE= |
332 |
|
if test "x$MITGCM_IEEE" != x ; then |
333 |
|
IEEE=$MITGCM_IEEE |
334 |
|
fi |
335 |
|
|
336 |
|
AUTODIFF_PKG_USED=f |
337 |
|
AD_OPTFILE= |
338 |
|
|
339 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
340 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
341 |
gm_s2="FC IEEE MPI JAM DUMPSTATE" |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
342 |
|
|
343 |
# The following state is not directly set by command-line switches |
# The following state is not directly set by command-line switches |
344 |
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " |
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " |
345 |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
346 |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
347 |
|
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
348 |
|
|
349 |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5" |
# The following are all related to adjoint/tangent-linear stuff |
350 |
|
gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF DIFF_FLAGS AD_TAMC_FLAGS AD_TAF_FLAGS" |
351 |
|
gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
352 |
|
gm_s9="" |
353 |
|
|
354 |
|
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8" |
355 |
|
|
356 |
|
|
357 |
echo |
echo |
358 |
echo "=== Processing options files and arguments ===" |
echo "=== Processing options files and arguments ===" |
359 |
gm_local="./gm_local" |
gm_local="genmake_local" |
360 |
|
for i in . $MODS ; do |
361 |
|
if test -r $i/$gm_local ; then |
362 |
|
source $i/$gm_local |
363 |
|
break |
364 |
|
fi |
365 |
|
done |
366 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
367 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
368 |
echo "using $gm_local" |
echo "using $gm_local" |
384 |
# n=$(( $n + 1 )) |
# n=$(( $n + 1 )) |
385 |
#done |
#done |
386 |
#parse_options |
#parse_options |
|
|
|
387 |
ac_prev= |
ac_prev= |
388 |
for ac_option ; do |
for ac_option ; do |
389 |
|
|
408 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
409 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
410 |
|
|
411 |
|
-adoptfile | --adoptfile | -ad | --ad) |
412 |
|
ac_prev=AD_OPTFILE ;; |
413 |
|
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
414 |
|
AD_OPTFILE=$ac_optarg ;; |
415 |
|
|
416 |
-pdepend | --pdepend) |
-pdepend | --pdepend) |
417 |
ac_prev=PDEPEND ;; |
ac_prev=PDEPEND ;; |
418 |
-pdepend=* | --pdepend=*) |
-pdepend=* | --pdepend=*) |
458 |
-enable=* | --enable=*) |
-enable=* | --enable=*) |
459 |
ENABLE=$ac_optarg ;; |
ENABLE=$ac_optarg ;; |
460 |
|
|
461 |
|
-standarddirs | --standarddirs) |
462 |
|
ac_prev=STANDARDDIRS ;; |
463 |
|
-standarddirs=* | --standarddirs=*) |
464 |
|
STANDARDDIRS=$ac_optarg ;; |
465 |
|
|
466 |
-noopt | --noopt) |
-noopt | --noopt) |
467 |
ac_prev=NOOPT ;; |
ac_prev=NOOPT ;; |
468 |
-noopt=* | --noopt=*) |
-noopt=* | --noopt=*) |
479 |
FC=$ac_optarg ;; |
FC=$ac_optarg ;; |
480 |
|
|
481 |
-ieee | --ieee) |
-ieee | --ieee) |
482 |
IEEE=1 ;; |
IEEE=true ;; |
483 |
-noieee | --noieee) |
-noieee | --noieee) |
484 |
IEEE=0 ;; |
IEEE= ;; |
485 |
|
|
486 |
-mpi | --mpi) |
-mpi | --mpi) |
487 |
MPI=1 ;; |
MPI=true ;; |
488 |
-nompi | --nompi) |
-nompi | --nompi) |
489 |
MPI=0 ;; |
MPI= ;; |
490 |
|
|
491 |
-jam | --jam) |
-jam | --jam) |
492 |
JAM=1 ;; |
JAM=1 ;; |
510 |
|
|
511 |
done |
done |
512 |
|
|
513 |
|
if test -f ./.genmakerc ; then |
514 |
|
echo |
515 |
|
echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" |
516 |
|
echo " file. This file format is no longer supported. Please see:" |
517 |
|
echo |
518 |
|
echo " http://mitgcm.org/devel_HOWTO/" |
519 |
|
echo |
520 |
|
echo " for directions on how to setup and use the new \"genmake2\" input" |
521 |
|
echo " files and send an email to MITgcm-support@mitgcm.org if you want help." |
522 |
|
echo |
523 |
|
fi |
524 |
|
|
525 |
|
if test "x${ROOTDIR}" = x ; then |
526 |
|
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
527 |
|
ROOTDIR=".." |
528 |
|
else |
529 |
|
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
530 |
|
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
531 |
|
ROOTDIR=$d |
532 |
|
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
533 |
|
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
534 |
|
break |
535 |
|
fi |
536 |
|
done |
537 |
|
fi |
538 |
|
fi |
539 |
|
if test "x${ROOTDIR}" = x ; then |
540 |
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
541 |
|
echo " Please specify a ROOTDIR using either an options " |
542 |
|
echo " file or a command-line option." |
543 |
|
exit 1 |
544 |
|
fi |
545 |
|
if test ! -d ${ROOTDIR} ; then |
546 |
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
547 |
|
exit 1 |
548 |
|
fi |
549 |
|
|
550 |
echo " getting OPTFILE information: " |
echo " getting OPTFILE information: " |
551 |
if test "x${OPTFILE}" = x ; then |
if test "x${OPTFILE}" = x ; then |
552 |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
if test "x$MITGCM_OF" = x ; then |
553 |
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
554 |
find_possible_configs |
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
555 |
else |
find_possible_configs |
|
if test "x$OPTFILE" = xNONE ; then |
|
|
echo " OPTFILE=NONE so we'll try to use default settings" |
|
556 |
else |
else |
557 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
OPTFILE=$MITGCM_OF |
558 |
echo " using OPTFILE=\"$OPTFILE\"" |
fi |
559 |
source "$OPTFILE" |
fi |
560 |
RETVAL=$? |
if test "x$OPTFILE" != xNONE ; then |
561 |
if test "x$RETVAL" != x0 ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
562 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
563 |
echo "--please check that variable syntax is bash-compatible" |
source "$OPTFILE" |
564 |
exit 1 |
RETVAL=$? |
565 |
fi |
if test "x$RETVAL" != x0 ; then |
566 |
if test "x$DUMPSTATE" != xf ; then |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
567 |
cp -f $OPTFILE "gm_optfile" |
echo "--please check that variable syntax is bash-compatible" |
568 |
fi |
exit 1 |
569 |
else |
fi |
570 |
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
if test "x$DUMPSTATE" != xf ; then |
571 |
|
cp -f $OPTFILE "genmake_optfile" |
572 |
|
fi |
573 |
|
else |
574 |
|
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
575 |
|
exit 1 |
576 |
|
fi |
577 |
|
fi |
578 |
|
|
579 |
|
echo " getting AD_OPTFILE information: " |
580 |
|
if test "x${AD_OPTFILE}" = x ; then |
581 |
|
if test "x$MITGCM_AD_OF" = x ; then |
582 |
|
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
583 |
|
else |
584 |
|
AD_OPTFILE=$MITGCM_AD_OF |
585 |
|
fi |
586 |
|
fi |
587 |
|
if test "x${AD_OPTFILE}" != xNONE ; then |
588 |
|
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
589 |
|
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
590 |
|
source "$AD_OPTFILE" |
591 |
|
RETVAL=$? |
592 |
|
if test "x$RETVAL" != x0 ; then |
593 |
|
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
594 |
|
echo "--please check that variable syntax is bash-compatible" |
595 |
exit 1 |
exit 1 |
596 |
fi |
fi |
597 |
|
if test "x$DUMPSTATE" != xf ; then |
598 |
|
cp -f $AD_OPTFILE "genmake_ad_optfile" |
599 |
|
fi |
600 |
|
else |
601 |
|
echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\"" |
602 |
|
exit 1 |
603 |
fi |
fi |
604 |
fi |
fi |
605 |
|
|
606 |
|
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
607 |
|
# and abort! |
608 |
|
if test "x$FC" = x ; then |
609 |
|
cat <<EOF 1>&2 |
610 |
|
|
611 |
|
Error: no Fortran compiler: please specify using one of the following: |
612 |
|
1) within the options file ("FC=...") as specified by "-of=OPTFILE" |
613 |
|
2) the "-fc=XXX" command-line option |
614 |
|
3) the "./genmake_local" file |
615 |
|
EOF |
616 |
|
exit 1 |
617 |
|
fi |
618 |
|
if test "x$LINK" = x ; then |
619 |
|
LINK=$FC |
620 |
|
fi |
621 |
|
if test "x$CPP" = x ; then |
622 |
|
CPP="cpp" |
623 |
|
fi |
624 |
|
echo "#define A a" | $CPP > test_cpp 2>&1 |
625 |
|
RETVAL=$? |
626 |
|
if test "x$RETVAL" != x0 ; then |
627 |
|
cat <<EOF 1>&2 |
628 |
|
|
629 |
|
Error: C pre-processor "$CPP" failed the test case: please specify using: |
630 |
|
|
631 |
|
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
632 |
|
2) the "./genmake_local" file |
633 |
|
|
634 |
|
EOF |
635 |
|
exit 1 |
636 |
|
else |
637 |
|
rm -f test_cpp |
638 |
|
fi |
639 |
|
if test "x$MAKEDEPEND" = x ; then |
640 |
|
MAKEDEPEND=makedepend |
641 |
|
fi |
642 |
|
|
643 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
644 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
645 |
for d in $MODS ; do |
for d in $MODS ; do |
662 |
PLATFORM=$p_PLATFORM |
PLATFORM=$p_PLATFORM |
663 |
fi |
fi |
664 |
|
|
|
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 |
|
|
|
|
665 |
if test "x${EXEDIR}" = x ; then |
if test "x${EXEDIR}" = x ; then |
666 |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
667 |
EXEDIR=../exe |
EXEDIR=../exe |
681 |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
682 |
exit 1 |
exit 1 |
683 |
fi |
fi |
684 |
|
if test "x$S64" = x ; then |
685 |
|
S64='$(TOOLSDIR)/set64bitConst.sh' |
686 |
|
fi |
687 |
|
|
688 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
689 |
|
|
722 |
# Strip the comments and then convert the dependency file into |
# Strip the comments and then convert the dependency file into |
723 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
724 |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
725 |
| awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ |
| $AWK 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ |
726 |
> ./.pd_tmp |
> ./.pd_tmp |
727 |
RETVAL=$? |
RETVAL=$? |
728 |
if test ! "x${RETVAL}" = x0 ; then |
if test ! "x${RETVAL}" = x0 ; then |
732 |
source ./.pd_tmp |
source ./.pd_tmp |
733 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
734 |
|
|
735 |
|
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
736 |
|
# file should eventually be added so that, for convenience, one can |
737 |
|
# specify groups of packages using names like "ocean" and "atmosphere". |
738 |
echo -n " checking default package list: " |
echo -n " checking default package list: " |
739 |
if test "x${PDEFAULT}" = x ; then |
if test "x${PDEFAULT}" = x ; then |
740 |
|
for i in "." $MODS ; do |
741 |
|
if test -r $i"/packages.conf" ; then |
742 |
|
PDEFAULT=$i"/packages.conf" |
743 |
|
break |
744 |
|
fi |
745 |
|
done |
746 |
|
fi |
747 |
|
if test "x${PDEFAULT}" = x ; then |
748 |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
749 |
fi |
fi |
750 |
if test "x${PDEFAULT}" = xNONE ; then |
if test "x${PDEFAULT}" = xNONE ; then |
756 |
else |
else |
757 |
echo " using PDEFAULT=\"$PDEFAULT\"" |
echo " using PDEFAULT=\"$PDEFAULT\"" |
758 |
# Strip the comments and add all the names |
# Strip the comments and add all the names |
759 |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'` |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
760 |
RETVAL=$? |
RETVAL=$? |
761 |
if test "x${RETVAL}" != x0 ; then |
if test "x${RETVAL}" != x0 ; then |
762 |
echo -n "Error: can't parse default package list " |
echo -n "Error: can't parse default package list " |
766 |
for i in $def ; do |
for i in $def ; do |
767 |
PACKAGES="$PACKAGES $i" |
PACKAGES="$PACKAGES $i" |
768 |
done |
done |
769 |
echo " packages are: $PACKAGES" |
echo " before group expansion packages are: $PACKAGES" |
770 |
|
expand_pkg_groups |
771 |
|
echo " after group expansion packages are: $PACKAGES" |
772 |
fi |
fi |
773 |
fi |
fi |
774 |
|
|
787 |
done |
done |
788 |
PACKAGES="$pack" |
PACKAGES="$pack" |
789 |
echo " applying ENABLE settings" |
echo " applying ENABLE settings" |
790 |
rm -f ./.tmp_pack |
echo "" > ./.tmp_pack |
791 |
PACKAGES="$PACKAGES $ENABLE" |
PACKAGES="$PACKAGES $ENABLE" |
792 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
793 |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
878 |
if test -d $adr ; then |
if test -d $adr ; then |
879 |
SOURCEDIRS="$SOURCEDIRS $adr" |
SOURCEDIRS="$SOURCEDIRS $adr" |
880 |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
881 |
|
if test "x$i" = xautodiff ; then |
882 |
|
AUTODIFF_PKG_USED=t |
883 |
|
fi |
884 |
else |
else |
885 |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
886 |
exit 1 |
exit 1 |
906 |
# done |
# done |
907 |
# echo |
# echo |
908 |
|
|
909 |
echo " Setting package-specific CPP flags in CPP_OPTIONS.h:" |
# Create a list of #define and #undef to enable/disable packages |
910 |
CPP_OPTIONS= |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
911 |
spaths="$SOURCEDIRS" |
cat <<EOF >$PACKAGES_DOT_H".tmp" |
|
for i in $spaths ; do |
|
|
try="$i/CPP_OPTIONS.h" |
|
|
# echo -n " trying $try : " |
|
|
if test -f $try -a -r $try ; then |
|
|
echo " found CPP_OPTIONS=\"$try\"" |
|
|
CPP_OPTIONS="$try" |
|
|
if test "x$i" != "x." ; then |
|
|
cp -f $CPP_OPTIONS . |
|
|
fi |
|
|
break |
|
|
fi |
|
|
done |
|
|
if test "x$CPP_OPTIONS" = x ; then |
|
|
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
|
|
exit 1 |
|
|
fi |
|
|
if test -e CPP_OPTIONS.h ; then |
|
|
if test ! -e CPP_OPTIONS.h.bak ; then |
|
|
cp -f CPP_OPTIONS.h CPP_OPTIONS.h.bak |
|
|
fi |
|
|
cat CPP_OPTIONS.h \ |
|
|
| awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \ |
|
|
> CPP_OPTIONS.h.tmp |
|
|
fi |
|
|
cat <<EOF >>CPP_OPTIONS.h.tmp |
|
912 |
C=== GENMAKE v2 === |
C=== GENMAKE v2 === |
913 |
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 |
914 |
C them only if you know what you're doing. In general, you should |
C edit anything below these comments. In general, you should |
915 |
C add or remove packages by re-running genmake with different |
C add or remove packages by re-running genmake with different |
916 |
C "-enable" and/or "-disable" options. |
C "-enable" and/or "-disable" options. |
917 |
|
|
918 |
|
#ifndef PACKAGES_H |
919 |
|
#define PACKAGES_H |
920 |
|
|
921 |
C Packages disabled by genmake: |
C Packages disabled by genmake: |
922 |
EOF |
EOF |
923 |
# The following UGLY HACK sets multiple "#undef"s and it needs to go |
# The following UGLY HACK sets multiple "#undef"s and it needs to go |
936 |
fi |
fi |
937 |
done |
done |
938 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
939 |
undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
940 |
echo "#undef $undef" >> CPP_OPTIONS.h.tmp |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
941 |
|
# DEFINES="$DEFINES -U$undef" |
942 |
|
|
943 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
944 |
case $n in |
case $n in |
948 |
mom_vecinv) |
mom_vecinv) |
949 |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
950 |
;; |
;; |
|
generic_advdiff) |
|
|
DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF" |
|
|
;; |
|
951 |
debug) |
debug) |
952 |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
953 |
;; |
;; |
957 |
fi |
fi |
958 |
fi |
fi |
959 |
done |
done |
960 |
cat <<EOF >>CPP_OPTIONS.h.tmp |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
961 |
|
|
962 |
C Packages enabled by genmake: |
C Packages enabled by genmake: |
963 |
EOF |
EOF |
964 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
965 |
def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
966 |
echo "#define $def" >> CPP_OPTIONS.h.tmp |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
967 |
|
#eh3 DEFINES="$DEFINES -D$def" |
968 |
|
|
969 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
970 |
case $i in |
case $i in |
971 |
aim_v23) |
aim_v23) |
972 |
echo "#define ALLOW_AIM" >> CPP_OPTIONS.h.tmp |
echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp" |
973 |
|
DEFINES="$DEFINES -DALLOW_AIM" |
974 |
|
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
975 |
;; |
;; |
976 |
esac |
esac |
977 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
978 |
|
|
979 |
done |
done |
980 |
mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
981 |
|
|
982 |
|
#endif /* PACKAGES_H */ |
983 |
|
EOF |
984 |
|
|
985 |
|
if test ! -f $PACKAGES_DOT_H ; then |
986 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
987 |
|
else |
988 |
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
989 |
|
RETVAL=$? |
990 |
|
if test "x$RETVAL" = x0 ; then |
991 |
|
rm -f $PACKAGES_DOT_H".tmp" |
992 |
|
else |
993 |
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
994 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
995 |
|
fi |
996 |
|
fi |
997 |
|
|
998 |
echo " Adding STANDARDDIRS" |
echo " Adding STANDARDDIRS" |
999 |
BUILDDIR=${BUILDDIR:-.} |
BUILDDIR=${BUILDDIR:-.} |
1000 |
STANDARDDIRS=${STANDARDDIRS:-"eesupp model"} |
if test "x$STANDARDDIRS" = x ; then |
1001 |
|
STANDARDDIRS="eesupp model" |
1002 |
|
fi |
1003 |
for d in $STANDARDDIRS ; do |
for d in $STANDARDDIRS ; do |
1004 |
adr="$ROOTDIR/$d/src" |
adr="$ROOTDIR/$d/src" |
1005 |
if test ! -d $adr ; then |
if test ! -d $adr ; then |
1019 |
fi |
fi |
1020 |
done |
done |
1021 |
|
|
1022 |
|
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
1023 |
|
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1024 |
|
CPP_OPTIONS= |
1025 |
|
spaths=". $INCLUDEDIRS" |
1026 |
|
for i in $spaths ; do |
1027 |
|
try="$i/CPP_OPTIONS.h" |
1028 |
|
# echo -n " trying $try : " |
1029 |
|
if test -f $try -a -r $try ; then |
1030 |
|
echo " found CPP_OPTIONS=\"$try\"" |
1031 |
|
CPP_OPTIONS="$try" |
1032 |
|
break |
1033 |
|
fi |
1034 |
|
done |
1035 |
|
if test "x$CPP_OPTIONS" = x ; then |
1036 |
|
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
1037 |
|
exit 1 |
1038 |
|
fi |
1039 |
|
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
1040 |
|
names=`ls -1 "$ROOTDIR/pkg"` |
1041 |
|
for n in $names ; do |
1042 |
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
1043 |
|
done |
1044 |
|
|
1045 |
|
|
1046 |
|
# Here, we build the list of files to be "run through" the adjoint |
1047 |
|
# compiler. |
1048 |
|
if test -f ./ad_files ; then |
1049 |
|
rm -f ./ad_files |
1050 |
|
fi |
1051 |
|
echo " Creating the list of files for the adjoint compiler." |
1052 |
|
for i in $SOURCEDIRS ; do |
1053 |
|
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
1054 |
|
for j in $list_files ; do |
1055 |
|
cat $i/$j >> ad_files |
1056 |
|
done |
1057 |
|
done |
1058 |
|
|
1059 |
|
cat <<EOF > adjoint_sed |
1060 |
|
s/call adopen(/call adopen ( mythid,\\ |
1061 |
|
\& /g |
1062 |
|
s/call adclose(/call adclose( mythid,\\ |
1063 |
|
\& /g |
1064 |
|
s/call adread(/call adread ( mythid,\\ |
1065 |
|
\& /g |
1066 |
|
s/call adwrite(/call adwrite( mythid,\\ |
1067 |
|
\& /g |
1068 |
|
|
1069 |
|
EOF |
1070 |
|
|
1071 |
echo |
echo |
1072 |
echo "=== Creating the Makefile ===" |
echo "=== Creating the Makefile ===" |
1073 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
1074 |
for i in $INCLUDEDIRS ; do |
for i in $INCLUDEDIRS ; do |
1075 |
if test -d $i ; then |
if ! test -d $i ; then |
1076 |
INCLUDES="$INCLUDES -I$i" |
# INCLUDES="$INCLUDES -I$i" |
1077 |
else |
# else |
1078 |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
1079 |
fi |
fi |
1080 |
done |
done |
1088 |
echo -n 'CSRCFILES = ' > csrclist.inc |
echo -n 'CSRCFILES = ' > csrclist.inc |
1089 |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
1090 |
echo -n 'HEADERFILES = ' > hlist.inc |
echo -n 'HEADERFILES = ' > hlist.inc |
1091 |
alldirs=". $SOURCEDIRS $INCLUDEDIRS" |
echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc |
1092 |
|
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
1093 |
for d in $alldirs ; do |
for d in $alldirs ; do |
1094 |
deplist= |
deplist= |
1095 |
sfiles=`( cd $d; echo *.[h,c,F] )` |
sfiles=`( cd $d; echo *.[h,c,F] *.flow )` |
1096 |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
1097 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
1098 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
1099 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1100 |
extn=`echo $sf | awk -F '.' '{print $NF}'` |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
1101 |
touch .links.tmp/$sf |
touch .links.tmp/$sf |
1102 |
deplist="$deplist $sf" |
deplist="$deplist $sf" |
1103 |
case $extn in |
case $extn in |
1117 |
echo " \\" >> hlist.inc |
echo " \\" >> hlist.inc |
1118 |
echo -n " $sf" >> hlist.inc |
echo -n " $sf" >> hlist.inc |
1119 |
;; |
;; |
1120 |
|
flow) |
1121 |
|
echo " \\" >> ad_flow_files.inc |
1122 |
|
echo -n " $sf" >> ad_flow_files.inc |
1123 |
|
;; |
1124 |
esac |
esac |
1125 |
fi |
fi |
1126 |
fi |
fi |
1137 |
echo "" >> csrclist.inc |
echo "" >> csrclist.inc |
1138 |
echo "" >> f90srclist.inc |
echo "" >> f90srclist.inc |
1139 |
echo "" >> hlist.inc |
echo "" >> hlist.inc |
1140 |
|
echo "" >> ad_flow_files.inc |
1141 |
|
|
1142 |
if test -e $MAKEFILE ; then |
if test -e $MAKEFILE ; then |
1143 |
mv -f $MAKEFILE "$MAKEFILE.bak" |
mv -f $MAKEFILE "$MAKEFILE.bak" |
1179 |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
1180 |
TOOLSDIR = ${TOOLSDIR} |
TOOLSDIR = ${TOOLSDIR} |
1181 |
|
|
1182 |
|
#eh3 new defines for the adjoint work |
1183 |
|
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1184 |
|
|
1185 |
EOF |
EOF |
1186 |
|
|
1187 |
# Note: figure out some way to add Hyades JAM libraries here |
# Note: figure out some way to add Hyades JAM libraries here |
1227 |
|
|
1228 |
EOF |
EOF |
1229 |
|
|
1230 |
cat srclist.inc >> $MAKEFILE |
cat srclist.inc >> $MAKEFILE |
1231 |
cat csrclist.inc >> $MAKEFILE |
cat csrclist.inc >> $MAKEFILE |
1232 |
cat f90srclist.inc >> $MAKEFILE |
cat f90srclist.inc >> $MAKEFILE |
1233 |
cat hlist.inc >> $MAKEFILE |
cat hlist.inc >> $MAKEFILE |
1234 |
|
cat ad_flow_files.inc >> $MAKEFILE |
1235 |
|
echo >> $MAKEFILE |
1236 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
1237 |
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
1238 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1239 |
|
|
1240 |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
1241 |
|
rm -f ad_flow_files.inc |
1242 |
|
|
1243 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1244 |
|
|
1251 |
depend: |
depend: |
1252 |
@make links |
@make links |
1253 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1254 |
../../../tools/f90mkdepend >> \$(MAKEFILE) |
${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) |
1255 |
|
|
1256 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
1257 |
|
|
1266 |
Clean: |
Clean: |
1267 |
@make clean |
@make clean |
1268 |
@make cleanlinks |
@make cleanlinks |
1269 |
-rm -f Makefile.bak |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
1270 |
CLEAN: |
CLEAN: |
1271 |
@make Clean |
@make Clean |
1272 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1273 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
1274 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1275 |
-rm -f \$(EXECUTABLE) |
-rm -f \$(EXECUTABLE) output.txt |
1276 |
|
|
1277 |
|
Makefile: makefile |
1278 |
makefile: |
makefile: |
1279 |
${0} $@ |
${0} $@ |
1280 |
cleanlinks: |
cleanlinks: |
1298 |
.p.f: |
.p.f: |
1299 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
1300 |
|
|
1301 |
|
#========================================= |
1302 |
|
#=== Automatic Differentiation Rules === |
1303 |
|
|
1304 |
|
TAMC = ${TAMC} |
1305 |
|
TAF = ${TAF} |
1306 |
|
|
1307 |
|
EOF |
1308 |
|
|
1309 |
|
ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" |
1310 |
|
ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS" |
1311 |
|
ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
1312 |
|
for i in $ad_vars ; do |
1313 |
|
name=$i |
1314 |
|
t1="t2=\$"`echo $i` |
1315 |
|
eval $t1 |
1316 |
|
printf "%-20s = " $name >> $MAKEFILE |
1317 |
|
echo $t2 >> $MAKEFILE |
1318 |
|
done |
1319 |
|
|
1320 |
|
echo " Add the source list for AD code generation" |
1321 |
|
echo >> $MAKEFILE |
1322 |
|
echo -n "AD_FILES = " >> $MAKEFILE |
1323 |
|
AD_FILES=`cat ad_files` |
1324 |
|
for i in $AD_FILES ; do |
1325 |
|
echo " \\" >> $MAKEFILE |
1326 |
|
echo -n " $i" >> $MAKEFILE |
1327 |
|
done |
1328 |
|
echo >> $MAKEFILE |
1329 |
|
|
1330 |
|
cat >>$MAKEFILE <<EOF |
1331 |
|
|
1332 |
|
|
1333 |
|
ad_input_code.f: \$(F77FILES) |
1334 |
|
@make \$(AD_FLOW_FILES) |
1335 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1336 |
|
|
1337 |
|
# ... AD ... |
1338 |
|
ad_taf_output.f: ad_input_code.f |
1339 |
|
\$(TAF) \$(AD_TAF_FLAGS) ad_input_code.f |
1340 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
1341 |
|
|
1342 |
|
ad_taf: ad_taf_output.o \$(OBJFILES) |
1343 |
|
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1344 |
|
|
1345 |
|
ad_tamc_output.f: ad_input_code.f |
1346 |
|
\$(TAMC) \$(AD_TAMC_FLAGS) ad_input_code.f |
1347 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
1348 |
|
|
1349 |
|
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1350 |
|
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1351 |
|
|
1352 |
|
|
1353 |
|
# ... FLT ... |
1354 |
|
flt_taf_output.f: ad_input_code.f |
1355 |
|
\$(TAF) \$(FTL_TAF_FLAGS) ad_input_code.f |
1356 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f |
1357 |
|
|
1358 |
|
flt_taf: flt_taf_output.o \$(OBJFILES) |
1359 |
|
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) |
1360 |
|
|
1361 |
|
flt_tamc_output.f: ad_input_code.f |
1362 |
|
\$(TAMC) \$(FTL_TAF_FLAGS) ad_input_code.f |
1363 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f |
1364 |
|
|
1365 |
|
flt_tamc: flt_tamc_output.o \$(OBJFILES) |
1366 |
|
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS) |
1367 |
|
|
1368 |
|
|
1369 |
|
# ... SVD ... |
1370 |
|
svd_taf_output.f: ad_input_code.f |
1371 |
|
\$(TAF) \$(SVD_TAF_FLAGS) ad_input_code.f |
1372 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
1373 |
|
|
1374 |
|
svd_taf: svd_taf_output.o \$(OBJFILES) |
1375 |
|
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
1376 |
|
|
1377 |
|
|
1378 |
|
#========================================= |
1379 |
|
|
1380 |
EOF |
EOF |
1381 |
|
|
1382 |
|
if test "x$EXEHOOK" != x ; then |
1383 |
|
printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE |
1384 |
|
fi |
1385 |
|
|
1386 |
echo " Making list of \"exceptions\" that need \".p\" files" |
echo " Making list of \"exceptions\" that need \".p\" files" |
1387 |
for i in $KPPFILES ; do |
for i in $KPPFILES ; do |
1388 |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
1416 |
|
|
1417 |
# Write the "state" for future records |
# Write the "state" for future records |
1418 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |
1419 |
echo -n "" > gm_state |
echo -n "" > genmake_state |
1420 |
for i in $gm_state ; do |
for i in $gm_state ; do |
1421 |
t1="t2=\$$i" |
t1="t2=\$$i" |
1422 |
eval $t1 |
eval $t1 |
1423 |
echo "$i='$t2'" >> gm_state |
echo "$i='$t2'" >> genmake_state |
1424 |
done |
done |
1425 |
fi |
fi |