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 |
124 |
echo "Possible FORTRAN compilers appear to be: " |
rm -f ./hello.f ./hello |
125 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
126 |
echo " None found!!!" |
cat 1>&2 <<EOF |
127 |
else |
|
128 |
echo " "$p_FC |
Error: No Fortran compilers were found in your path. Please specify one using: |
129 |
fi |
|
130 |
|
1) an "optfile" on (eg. "-optfile=path/to/OPTFILE"), |
131 |
|
2) a command-line option (eg. "-fc NAME"), or |
132 |
|
3) the MITGCM_FC environment variable. |
133 |
|
|
|
# look for possible MPI libraries |
|
|
mpi_libs= |
|
|
mpi_fort=`which mpif77 2>/dev/null` |
|
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
cat >>test.f <<EOF |
|
|
PROGRAM HELLO |
|
|
DO 10, I=1,10 |
|
|
PRINT *,'Hello World' |
|
|
10 CONTINUE |
|
|
STOP |
|
|
END |
|
134 |
EOF |
EOF |
135 |
eval "$mpi_fort -showme test.f > out" |
exit 1 |
136 |
RETVAL=$? |
else |
137 |
if test "x${RETVAL}" = x0 ; then |
echo " The possible FORTRAN compilers found in your path are:" |
138 |
a=`cat out` |
echo " "$p_FC |
139 |
for i in $a ; do |
if test "x$FC" = x ; then |
140 |
case $i in |
FC=`echo $p_FC | $AWK '{print $1}'` |
|
-*) |
|
|
mpi_libs="$mpi_libs $i" ;; |
|
|
esac |
|
|
done |
|
|
echo "The MPI libs appear to be:" |
|
|
echo " "$mpi_libs |
|
141 |
fi |
fi |
|
rm -f test.f out |
|
142 |
fi |
fi |
143 |
|
|
144 |
} |
for i in $p_FC ; do |
145 |
|
p_OF=$ROOTDIR"/tools/build_options/"$PLATFORM"_"$i |
146 |
|
if test -r $p_OF ; then |
147 |
|
OPTFILE=$p_OF |
148 |
|
echo " The options file: $p_OF" |
149 |
|
echo " appears to match so we'll use it." |
150 |
|
break |
151 |
|
fi |
152 |
|
done |
153 |
|
if test "x$OPTFILE" = x ; then |
154 |
|
cat 1>&2 <<EOF |
155 |
|
|
156 |
parse_options() { |
Error: No options file was found in: $ROOTDIR/tools/build_options/ |
157 |
|
that matches this platform ("$PLATFORM") and the compilers found in |
158 |
|
your path. Please specify an "optfile" using: |
159 |
|
|
160 |
ac_prev= |
1) the command line (eg. "-optfile=path/to/OPTFILE"), or |
161 |
for ac_option in "${OPTIONS[@]}" ; do |
2) the MITGCM_OF environment variable. |
162 |
|
|
163 |
|
If you need help, please contact the developers at <MITgcm-support@mitgcm.org>. |
164 |
|
|
165 |
|
EOF |
166 |
|
exit 1 |
167 |
|
fi |
168 |
|
|
169 |
|
# # look for possible MPI libraries |
170 |
|
# mpi_libs= |
171 |
|
# mpi_fort=`which mpif77 2>/dev/null` |
172 |
|
# RETVAL=$? |
173 |
|
# if test "x${RETVAL}" = x0 ; then |
174 |
|
# cat >>test.f <<EOF |
175 |
|
# PROGRAM HELLO |
176 |
|
# DO 10, I=1,10 |
177 |
|
# PRINT *,'Hello World' |
178 |
|
# 10 CONTINUE |
179 |
|
# STOP |
180 |
|
# END |
181 |
|
# EOF |
182 |
|
# eval "$mpi_fort -showme test.f > out" |
183 |
|
# RETVAL=$? |
184 |
|
# if test "x${RETVAL}" = x0 ; then |
185 |
|
# a=`cat out` |
186 |
|
# for i in $a ; do |
187 |
|
# case $i in |
188 |
|
# -*) |
189 |
|
# mpi_libs="$mpi_libs $i" ;; |
190 |
|
# esac |
191 |
|
# done |
192 |
|
# echo "The MPI libs appear to be:" |
193 |
|
# echo " "$mpi_libs |
194 |
|
# fi |
195 |
|
# rm -f test.f out |
196 |
|
# fi |
197 |
|
|
|
# echo "ac_option = :$ac_option:" |
|
|
|
|
|
# If the previous option needs an argument, assign it. |
|
|
if test -n "$ac_prev"; then |
|
|
eval "$ac_prev=\$ac_option" |
|
|
ac_prev= |
|
|
continue |
|
|
fi |
|
|
|
|
|
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
|
|
|
|
|
case $ac_option in |
|
|
|
|
|
-help | --help | -h | --h) |
|
|
usage ;; |
|
|
|
|
|
-nooptfile | --nooptfile) |
|
|
OPTFILE="NONE" ;; |
|
|
-optfile | --optfile | -of | --of) |
|
|
ac_prev=optfile ;; |
|
|
-optfile=* | --optfile=* | -of=* | --of=*) |
|
|
OPTFILE=$ac_optarg ;; |
|
|
|
|
|
-pdepend | --pdepend) |
|
|
ac_prev=pdepend ;; |
|
|
-pdepend=* | --pdepend=*) |
|
|
PDEPEND=$ac_optarg ;; |
|
|
|
|
|
-pdefault | --pdefault) |
|
|
ac_prev=pdefault ;; |
|
|
-pdefault=* | --pdefault=*) |
|
|
PDEFAULT=$ac_optarg ;; |
|
|
|
|
|
-makefile | -ma) |
|
|
ac_prev=makefile ;; |
|
|
--makefile=* | -ma=*) |
|
|
MAKEFILE=$ac_optarg ;; |
|
|
|
|
|
-platform | --platform | -pl | --pl) |
|
|
ac_prev=platform ;; |
|
|
-platform=* | --platform=* | -pl=* | --pl=*) |
|
|
PLATFORM=$ac_optarg ;; |
|
|
|
|
|
-rootdir | --rootdir | -rd | --rd) |
|
|
ac_prev=rootdir ;; |
|
|
-rootdir=* | --rootdir=* | -rd=* | --rd=*) |
|
|
ROOTDIR=$ac_optarg ;; |
|
|
|
|
|
-mods | --mods | -mo | --mo) |
|
|
ac_prev=mods ;; |
|
|
-mods=* | --mods=* | -mo=* | --mo=*) |
|
|
MODS=$ac_optarg ;; |
|
|
|
|
|
-disable | --disable) |
|
|
ac_prev=disable ;; |
|
|
-disable=* | --disable=*) |
|
|
DISABLE=$ac_optarg ;; |
|
|
|
|
|
-enable | --enable) |
|
|
ac_prev=enable ;; |
|
|
-enable=* | --enable=*) |
|
|
ENABLE=$ac_optarg ;; |
|
|
|
|
|
-noopt | --noopt) |
|
|
ac_prev=noopt ;; |
|
|
-noopt=* | --noopt=*) |
|
|
NOOPT=$ac_optarg ;; |
|
|
|
|
|
# -cpp | --cpp) |
|
|
# ac_prev=cpp ;; |
|
|
# -cpp=* | --cpp=*) |
|
|
# CPP=$ac_optarg ;; |
|
|
|
|
|
-fortran | --fortran | -fc | --fc) |
|
|
ac_prev=fc ;; |
|
|
-fc=* | --fc=*) |
|
|
FC=$ac_optarg ;; |
|
|
|
|
|
-ieee | --ieee) |
|
|
IEEE=1 ;; |
|
|
-noieee | --noieee) |
|
|
IEEE=0 ;; |
|
|
|
|
|
-mpi | --mpi) |
|
|
MPI=1 ;; |
|
|
-nompi | --nompi) |
|
|
MPI=0 ;; |
|
|
|
|
|
-jam | --jam) |
|
|
JAM=1 ;; |
|
|
-nojam | --nojam) |
|
|
JAM=0 ;; |
|
|
|
|
|
-*) |
|
|
echo "Error: unrecognized option: "$ac_option |
|
|
usage |
|
|
;; |
|
|
|
|
|
*) |
|
|
echo "Error: unrecognized argument: "$ac_option |
|
|
usage |
|
|
;; |
|
|
|
|
|
esac |
|
|
|
|
|
done |
|
198 |
} |
} |
199 |
|
|
200 |
# Parse the package dependency information |
# Parse the package dependency information |
203 |
# strip the comments and then convert the dependency file into |
# strip the comments and then convert the dependency file into |
204 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
205 |
cat $1 | sed -e 's/#.*$//g' \ |
cat $1 | sed -e 's/#.*$//g' \ |
206 |
| 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} }' \ |
207 |
> ./.pd_tmp |
> ./.pd_tmp |
208 |
source ./.pd_tmp |
source ./.pd_tmp |
209 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
226 |
echo " -pdepend=NAME | --pdepend=NAME" |
echo " -pdepend=NAME | --pdepend=NAME" |
227 |
echo " -pdefault NAME | --pdefault NAME" |
echo " -pdefault NAME | --pdefault NAME" |
228 |
echo " -pdefault=NAME | --pdefault=NAME" |
echo " -pdefault=NAME | --pdefault=NAME" |
229 |
echo " -makefile NAME | -ma NAME" |
echo " -make NAME | -m NAME" |
230 |
echo " --makefile=NAME | -ma=NAME" |
echo " --make=NAME | -m=NAME" |
231 |
|
echo " -makefile NAME | -mf NAME" |
232 |
|
echo " --makefile=NAME | -mf=NAME" |
233 |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
234 |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
235 |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
240 |
echo " -disable=NAME | --disable=NAME" |
echo " -disable=NAME | --disable=NAME" |
241 |
echo " -enable NAME | --enable NAME" |
echo " -enable NAME | --enable NAME" |
242 |
echo " -enable=NAME | --enable=NAME" |
echo " -enable=NAME | --enable=NAME" |
243 |
|
echo " -standarddirs NAME | --standarddirs NAME" |
244 |
|
echo " -standarddirs=NAME | --standarddirs=NAME" |
245 |
echo " -noopt NAME | --noopt NAME" |
echo " -noopt NAME | --noopt NAME" |
246 |
echo " -noopt=NAME | --noopt=NAME" |
echo " -noopt=NAME | --noopt=NAME" |
247 |
# echo " -cpp NAME | --cpp NAME" |
# echo " -cpp NAME | --cpp NAME" |
263 |
exit 1 |
exit 1 |
264 |
} |
} |
265 |
|
|
|
# Dump all important state |
|
|
dump_state() { |
|
|
fname=$1 |
|
|
echo " " > $fname |
|
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x ; then |
|
|
echo "Error: cannot write to $fname" |
|
|
exit 1 |
|
|
fi |
|
|
echo "makefile "$makefile > $fname |
|
|
} |
|
|
|
|
|
|
|
266 |
#eh3 # This is the generic configuration. |
#eh3 # This is the generic configuration. |
267 |
#eh3 set LN = ( 'ln -s' ) |
#eh3 set LN = ( 'ln -s' ) |
268 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
#eh3 set CPP = ( '/lib/cpp -P' ) |
283 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
284 |
|
|
285 |
# Set defaults here |
# Set defaults here |
286 |
|
COMMANDL="$0 $@" |
287 |
|
|
288 |
PLATFORM= |
PLATFORM= |
289 |
LN= |
LN= |
290 |
S64= |
S64= |
291 |
KPP= |
KPP= |
292 |
FC= |
FC= |
293 |
LINK= |
LINK= |
294 |
|
DEFINES="-DWORDLENGTH=4" |
295 |
PACKAGES= |
PACKAGES= |
296 |
ENABLE= |
ENABLE= |
297 |
DISABLE= |
DISABLE= |
298 |
MAKEFILE= |
MAKEFILE= |
299 |
MAKEDEPEND= |
MAKEDEPEND= |
300 |
PDEPEND= |
PDEPEND= |
301 |
|
DUMPSTATE=t |
302 |
PDEFAULT= |
PDEFAULT= |
303 |
OPTFILE= |
OPTFILE= |
304 |
INCLUDES="-I." |
INCLUDES="-I." |
316 |
TOOLSDIR= |
TOOLSDIR= |
317 |
SOURCEDIRS= |
SOURCEDIRS= |
318 |
INCLUDEDIRS= |
INCLUDEDIRS= |
319 |
|
STANDARDDIRS= |
320 |
|
|
321 |
PWD=`pwd` |
PWD=`pwd` |
322 |
MAKE=make |
MAKE=make |
323 |
|
AWK=awk |
324 |
THISHOSTNAME=`hostname` |
THISHOSTNAME=`hostname` |
325 |
THISCWD=`pwd` |
THISCWD=`pwd` |
326 |
THISDATE=`date` |
THISDATE=`date` |
327 |
MACHINE=`uname -a` |
MACHINE=`uname -a` |
328 |
|
EXECUTABLE= |
329 |
|
EXEHOOK= |
330 |
|
EXEDIR= |
331 |
|
PACKAGES_CONF= |
332 |
|
IEEE= |
333 |
|
if test "x$MITGCM_IEEE" != x ; then |
334 |
|
IEEE=$MITGCM_IEEE |
335 |
|
fi |
336 |
|
|
337 |
|
AUTODIFF_PKG_USED=f |
338 |
|
AD_OPTFILE= |
339 |
|
TAF= |
340 |
|
AD_TAF_FLAGS= |
341 |
|
FTL_TAF_FLAGS= |
342 |
|
SVD_TAF_FLAGS= |
343 |
|
TAF_EXTRA= |
344 |
|
TAMC= |
345 |
|
AD_TAMC_FLAGS= |
346 |
|
FTL_TAF_FLAGS= |
347 |
|
SVD_TAMC_FLAGS= |
348 |
|
TAMC_EXTRA= |
349 |
|
|
350 |
|
|
351 |
|
# The following state can be set directly by command-line switches |
352 |
|
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
353 |
|
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
354 |
|
|
355 |
|
# The following state is not directly set by command-line switches |
356 |
|
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " |
357 |
|
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
358 |
|
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
359 |
|
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
360 |
|
|
361 |
|
# The following are all related to adjoint/tangent-linear stuff |
362 |
|
gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
363 |
|
gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
364 |
|
gm_s9="TAF_EXTRA TAMC_EXTRA" |
365 |
|
|
366 |
|
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9" |
367 |
|
|
368 |
|
|
369 |
echo |
echo |
370 |
echo "=== Processing options files and arguments ===" |
echo "=== Processing options files and arguments ===" |
371 |
gm_local="./gm_local" |
gm_local="genmake_local" |
372 |
|
for i in . $MODS ; do |
373 |
|
if test -r $i/$gm_local ; then |
374 |
|
source $i/$gm_local |
375 |
|
break |
376 |
|
fi |
377 |
|
done |
378 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
379 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
380 |
echo "using $gm_local" |
echo "using $gm_local" |
396 |
# n=$(( $n + 1 )) |
# n=$(( $n + 1 )) |
397 |
#done |
#done |
398 |
#parse_options |
#parse_options |
|
|
|
399 |
ac_prev= |
ac_prev= |
400 |
for ac_option ; do |
for ac_option ; do |
401 |
|
|
416 |
-nooptfile | --nooptfile) |
-nooptfile | --nooptfile) |
417 |
OPTFILE="NONE" ;; |
OPTFILE="NONE" ;; |
418 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
419 |
ac_prev=optfile ;; |
ac_prev=OPTFILE ;; |
420 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
421 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
422 |
|
|
423 |
|
-adoptfile | --adoptfile | -ad | --ad) |
424 |
|
ac_prev=AD_OPTFILE ;; |
425 |
|
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
426 |
|
AD_OPTFILE=$ac_optarg ;; |
427 |
|
|
428 |
-pdepend | --pdepend) |
-pdepend | --pdepend) |
429 |
ac_prev=pdepend ;; |
ac_prev=PDEPEND ;; |
430 |
-pdepend=* | --pdepend=*) |
-pdepend=* | --pdepend=*) |
431 |
PDEPEND=$ac_optarg ;; |
PDEPEND=$ac_optarg ;; |
432 |
|
|
433 |
-pdefault | --pdefault) |
-pdefault | --pdefault) |
434 |
ac_prev=pdefault ;; |
ac_prev=PDEFAULT ;; |
435 |
-pdefault=* | --pdefault=*) |
-pdefault=* | --pdefault=*) |
436 |
PDEFAULT=$ac_optarg ;; |
PDEFAULT=$ac_optarg ;; |
437 |
|
|
438 |
-makefile | -ma) |
-make | --make | -m | --m) |
439 |
ac_prev=makefile ;; |
ac_prev=MAKE ;; |
440 |
--makefile=* | -ma=*) |
-make=* | --make=* | -m=* | --m=*) |
441 |
|
MAKE=$ac_optarg ;; |
442 |
|
|
443 |
|
-makefile | --makefile | -ma | --ma) |
444 |
|
ac_prev=MAKEFILE ;; |
445 |
|
-makefile=* | --makefile=* | -ma=* | --ma=*) |
446 |
MAKEFILE=$ac_optarg ;; |
MAKEFILE=$ac_optarg ;; |
447 |
|
|
448 |
-platform | --platform | -pl | --pl) |
-platform | --platform | -pl | --pl) |
449 |
ac_prev=platform ;; |
ac_prev=PLATFORM ;; |
450 |
-platform=* | --platform=* | -pl=* | --pl=*) |
-platform=* | --platform=* | -pl=* | --pl=*) |
451 |
PLATFORM=$ac_optarg ;; |
PLATFORM=$ac_optarg ;; |
452 |
|
|
453 |
-rootdir | --rootdir | -rd | --rd) |
-rootdir | --rootdir | -rd | --rd) |
454 |
ac_prev=rootdir ;; |
ac_prev=ROOTDIR ;; |
455 |
-rootdir=* | --rootdir=* | -rd=* | --rd=*) |
-rootdir=* | --rootdir=* | -rd=* | --rd=*) |
456 |
ROOTDIR=$ac_optarg ;; |
ROOTDIR=$ac_optarg ;; |
457 |
|
|
458 |
-mods | --mods | -mo | --mo) |
-mods | --mods | -mo | --mo) |
459 |
ac_prev=mods ;; |
ac_prev=MODS ;; |
460 |
-mods=* | --mods=* | -mo=* | --mo=*) |
-mods=* | --mods=* | -mo=* | --mo=*) |
461 |
MODS=$ac_optarg ;; |
MODS=$ac_optarg ;; |
462 |
|
|
463 |
-disable | --disable) |
-disable | --disable) |
464 |
ac_prev=disable ;; |
ac_prev=DISABLE ;; |
465 |
-disable=* | --disable=*) |
-disable=* | --disable=*) |
466 |
DISABLE=$ac_optarg ;; |
DISABLE=$ac_optarg ;; |
467 |
|
|
468 |
-enable | --enable) |
-enable | --enable) |
469 |
ac_prev=enable ;; |
ac_prev=ENABLE ;; |
470 |
-enable=* | --enable=*) |
-enable=* | --enable=*) |
471 |
ENABLE=$ac_optarg ;; |
ENABLE=$ac_optarg ;; |
472 |
|
|
473 |
|
-standarddirs | --standarddirs) |
474 |
|
ac_prev=STANDARDDIRS ;; |
475 |
|
-standarddirs=* | --standarddirs=*) |
476 |
|
STANDARDDIRS=$ac_optarg ;; |
477 |
|
|
478 |
-noopt | --noopt) |
-noopt | --noopt) |
479 |
ac_prev=noopt ;; |
ac_prev=NOOPT ;; |
480 |
-noopt=* | --noopt=*) |
-noopt=* | --noopt=*) |
481 |
NOOPT=$ac_optarg ;; |
NOOPT=$ac_optarg ;; |
482 |
|
|
486 |
# CPP=$ac_optarg ;; |
# CPP=$ac_optarg ;; |
487 |
|
|
488 |
-fortran | --fortran | -fc | --fc) |
-fortran | --fortran | -fc | --fc) |
489 |
ac_prev=fc ;; |
ac_prev=FC ;; |
490 |
-fc=* | --fc=*) |
-fc=* | --fc=*) |
491 |
FC=$ac_optarg ;; |
FC=$ac_optarg ;; |
492 |
|
|
493 |
-ieee | --ieee) |
-ieee | --ieee) |
494 |
IEEE=1 ;; |
IEEE=true ;; |
495 |
-noieee | --noieee) |
-noieee | --noieee) |
496 |
IEEE=0 ;; |
IEEE= ;; |
497 |
|
|
498 |
-mpi | --mpi) |
-mpi | --mpi) |
499 |
MPI=1 ;; |
MPI=true ;; |
500 |
-nompi | --nompi) |
-nompi | --nompi) |
501 |
MPI=0 ;; |
MPI= ;; |
502 |
|
|
503 |
-jam | --jam) |
-jam | --jam) |
504 |
JAM=1 ;; |
JAM=1 ;; |
505 |
-nojam | --nojam) |
-nojam | --nojam) |
506 |
JAM=0 ;; |
JAM=0 ;; |
507 |
|
|
508 |
|
-ds | --ds) |
509 |
|
DUMPSTATE=t ;; |
510 |
|
|
511 |
|
-taf_extra | --taf_extra) |
512 |
|
ac_prev=TAF_EXTRA ;; |
513 |
|
-taf_extra=* | --taf_extra=*) |
514 |
|
TAF_EXTRA=$ac_optarg ;; |
515 |
|
|
516 |
|
-tamc_extra | --tamc_extra) |
517 |
|
ac_prev=TAMC_EXTRA ;; |
518 |
|
-tamc_extra=* | --tamc_extra=*) |
519 |
|
TAMC_EXTRA=$ac_optarg ;; |
520 |
|
|
521 |
-*) |
-*) |
522 |
echo "Error: unrecognized option: "$ac_option |
echo "Error: unrecognized option: "$ac_option |
523 |
usage |
usage |
532 |
|
|
533 |
done |
done |
534 |
|
|
535 |
|
if test -f ./.genmakerc ; then |
536 |
|
echo |
537 |
|
echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" |
538 |
|
echo " file. This file format is no longer supported. Please see:" |
539 |
|
echo |
540 |
|
echo " http://mitgcm.org/devel_HOWTO/" |
541 |
|
echo |
542 |
|
echo " for directions on how to setup and use the new \"genmake2\" input" |
543 |
|
echo " files and send an email to MITgcm-support@mitgcm.org if you want help." |
544 |
|
echo |
545 |
|
fi |
546 |
|
|
547 |
|
if test "x${ROOTDIR}" = x ; then |
548 |
|
if test "${PWD##/*/}" = "bin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
549 |
|
ROOTDIR=".." |
550 |
|
else |
551 |
|
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
552 |
|
if [ -d "$d/model" -a -d "$d/eesupp" -a -d "$d/pkg" ]; then |
553 |
|
ROOTDIR=$d |
554 |
|
echo -n "Warning: ROOTDIR was not specified but there appears to be" |
555 |
|
echo " a copy of MITgcm at \"$ROOTDIR\" so we'll try it." |
556 |
|
break |
557 |
|
fi |
558 |
|
done |
559 |
|
fi |
560 |
|
fi |
561 |
|
if test "x${ROOTDIR}" = x ; then |
562 |
|
echo "Error: Cannot determine ROOTDIR for MITgcm code." |
563 |
|
echo " Please specify a ROOTDIR using either an options " |
564 |
|
echo " file or a command-line option." |
565 |
|
exit 1 |
566 |
|
fi |
567 |
|
if test ! -d ${ROOTDIR} ; then |
568 |
|
echo "Error: the specified ROOTDIR (\"$ROOTDIR\") does not exist!" |
569 |
|
exit 1 |
570 |
|
fi |
571 |
|
|
572 |
echo " getting OPTFILE information: " |
echo " getting OPTFILE information: " |
573 |
if test "x${OPTFILE}" = x ; then |
if test "x${OPTFILE}" = x ; then |
574 |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
if test "x$MITGCM_OF" = x ; then |
575 |
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
echo "Warning: no OPTFILE specified so we'll look for possible settings" |
576 |
find_possible_configs |
printf "\n=== Searching for possible settings for OPTFILE ===\n" |
577 |
else |
find_possible_configs |
|
if test "x$OPTFILE" = xNONE ; then |
|
|
echo " OPTFILE=NONE so we'll try to use default settings" |
|
578 |
else |
else |
579 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
OPTFILE=$MITGCM_OF |
580 |
echo " using OPTFILE=\"$OPTFILE\"" |
fi |
581 |
source "$OPTFILE" |
fi |
582 |
RETVAL=$? |
if test "x$OPTFILE" != xNONE ; then |
583 |
if test "x$RETVAL" != x0 ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
584 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
585 |
echo "--please check that variable syntax is bash-compatible" |
source "$OPTFILE" |
586 |
exit 1 |
RETVAL=$? |
587 |
fi |
if test "x$RETVAL" != x0 ; then |
588 |
else |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
589 |
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
echo "--please check that variable syntax is bash-compatible" |
590 |
exit 1 |
exit 1 |
591 |
fi |
fi |
592 |
|
if test "x$DUMPSTATE" != xf ; then |
593 |
|
cp -f $OPTFILE "genmake_optfile" |
594 |
|
fi |
595 |
|
else |
596 |
|
echo "Error: can't read OPTFILE=\"$OPTFILE\"" |
597 |
|
exit 1 |
598 |
fi |
fi |
599 |
fi |
fi |
600 |
|
|
601 |
|
echo " getting AD_OPTFILE information: " |
602 |
|
if test "x${AD_OPTFILE}" = x ; then |
603 |
|
if test "x$MITGCM_AD_OF" = x ; then |
604 |
|
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
605 |
|
else |
606 |
|
AD_OPTFILE=$MITGCM_AD_OF |
607 |
|
fi |
608 |
|
fi |
609 |
|
if test "x${AD_OPTFILE}" != xNONE ; then |
610 |
|
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
611 |
|
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
612 |
|
source "$AD_OPTFILE" |
613 |
|
RETVAL=$? |
614 |
|
if test "x$RETVAL" != x0 ; then |
615 |
|
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
616 |
|
echo "--please check that variable syntax is bash-compatible" |
617 |
|
exit 1 |
618 |
|
fi |
619 |
|
if test "x$DUMPSTATE" != xf ; then |
620 |
|
cp -f $AD_OPTFILE "genmake_ad_optfile" |
621 |
|
fi |
622 |
|
else |
623 |
|
echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\"" |
624 |
|
exit 1 |
625 |
|
fi |
626 |
|
fi |
627 |
|
|
628 |
|
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
629 |
|
# and abort! |
630 |
|
if test "x$FC" = x ; then |
631 |
|
cat <<EOF 1>&2 |
632 |
|
|
633 |
|
Error: no Fortran compiler: please specify using one of the following: |
634 |
|
1) within the options file ("FC=...") as specified by "-of=OPTFILE" |
635 |
|
2) the "-fc=XXX" command-line option |
636 |
|
3) the "./genmake_local" file |
637 |
|
EOF |
638 |
|
exit 1 |
639 |
|
fi |
640 |
|
if test "x$LINK" = x ; then |
641 |
|
LINK=$FC |
642 |
|
fi |
643 |
|
if test "x$CPP" = x ; then |
644 |
|
CPP="cpp" |
645 |
|
fi |
646 |
|
echo "#define A a" | $CPP > test_cpp 2>&1 |
647 |
|
RETVAL=$? |
648 |
|
if test "x$RETVAL" != x0 ; then |
649 |
|
cat <<EOF 1>&2 |
650 |
|
|
651 |
|
Error: C pre-processor "$CPP" failed the test case: please specify using: |
652 |
|
|
653 |
|
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
654 |
|
2) the "./genmake_local" file |
655 |
|
|
656 |
|
EOF |
657 |
|
exit 1 |
658 |
|
else |
659 |
|
rm -f test_cpp |
660 |
|
fi |
661 |
|
if test "x$MAKEDEPEND" = x ; then |
662 |
|
MAKEDEPEND=makedepend |
663 |
|
fi |
664 |
|
|
665 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
666 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
667 |
for d in $MODS ; do |
for d in $MODS ; do |
684 |
PLATFORM=$p_PLATFORM |
PLATFORM=$p_PLATFORM |
685 |
fi |
fi |
686 |
|
|
|
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 |
|
|
|
|
687 |
if test "x${EXEDIR}" = x ; then |
if test "x${EXEDIR}" = x ; then |
688 |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
if test "${PWD##/*/}" = "bin" -a -d ../exe -a $ROOTDIR = .. ; then |
689 |
EXEDIR=../exe |
EXEDIR=../exe |
703 |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
echo "Error: the specified $TOOLSDIR (\"$TOOLSDIR\") does not exist!" |
704 |
exit 1 |
exit 1 |
705 |
fi |
fi |
706 |
|
if test "x$S64" = x ; then |
707 |
|
S64='$(TOOLSDIR)/set64bitConst.sh' |
708 |
|
fi |
709 |
|
|
710 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
711 |
|
|
744 |
# Strip the comments and then convert the dependency file into |
# Strip the comments and then convert the dependency file into |
745 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
746 |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
747 |
| 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}' \ |
748 |
> ./.pd_tmp |
> ./.pd_tmp |
749 |
RETVAL=$? |
RETVAL=$? |
750 |
if test ! "x${RETVAL}" = x0 ; then |
if test ! "x${RETVAL}" = x0 ; then |
754 |
source ./.pd_tmp |
source ./.pd_tmp |
755 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
756 |
|
|
757 |
|
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
758 |
|
# file should eventually be added so that, for convenience, one can |
759 |
|
# specify groups of packages using names like "ocean" and "atmosphere". |
760 |
echo -n " checking default package list: " |
echo -n " checking default package list: " |
761 |
if test "x${PDEFAULT}" = x ; then |
if test "x${PDEFAULT}" = x ; then |
762 |
|
for i in "." $MODS ; do |
763 |
|
if test -r $i"/packages.conf" ; then |
764 |
|
PDEFAULT=$i"/packages.conf" |
765 |
|
break |
766 |
|
fi |
767 |
|
done |
768 |
|
fi |
769 |
|
if test "x${PDEFAULT}" = x ; then |
770 |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
771 |
fi |
fi |
772 |
if test "x${PDEFAULT}" = xNONE ; then |
if test "x${PDEFAULT}" = xNONE ; then |
778 |
else |
else |
779 |
echo " using PDEFAULT=\"$PDEFAULT\"" |
echo " using PDEFAULT=\"$PDEFAULT\"" |
780 |
# Strip the comments and add all the names |
# Strip the comments and add all the names |
781 |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'` |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
782 |
RETVAL=$? |
RETVAL=$? |
783 |
if test "x${RETVAL}" != x0 ; then |
if test "x${RETVAL}" != x0 ; then |
784 |
echo -n "Error: can't parse default package list " |
echo -n "Error: can't parse default package list " |
788 |
for i in $def ; do |
for i in $def ; do |
789 |
PACKAGES="$PACKAGES $i" |
PACKAGES="$PACKAGES $i" |
790 |
done |
done |
791 |
echo " packages are: $PACKAGES" |
echo " before group expansion packages are: $PACKAGES" |
792 |
|
expand_pkg_groups |
793 |
|
echo " after group expansion packages are: $PACKAGES" |
794 |
fi |
fi |
795 |
fi |
fi |
796 |
|
|
809 |
done |
done |
810 |
PACKAGES="$pack" |
PACKAGES="$pack" |
811 |
echo " applying ENABLE settings" |
echo " applying ENABLE settings" |
812 |
rm -f ./.tmp_pack |
echo "" > ./.tmp_pack |
813 |
PACKAGES="$PACKAGES $ENABLE" |
PACKAGES="$PACKAGES $ENABLE" |
814 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
815 |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
if test ! -d "$ROOTDIR/pkg/$i" ; then |
900 |
if test -d $adr ; then |
if test -d $adr ; then |
901 |
SOURCEDIRS="$SOURCEDIRS $adr" |
SOURCEDIRS="$SOURCEDIRS $adr" |
902 |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
903 |
|
if test "x$i" = xautodiff ; then |
904 |
|
AUTODIFF_PKG_USED=t |
905 |
|
fi |
906 |
else |
else |
907 |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
908 |
exit 1 |
exit 1 |
928 |
# done |
# done |
929 |
# echo |
# echo |
930 |
|
|
931 |
echo " Setting package-specific CPP flags in CPP_OPTIONS.h:" |
# Create a list of #define and #undef to enable/disable packages |
932 |
CPP_OPTIONS= |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
933 |
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 |
|
934 |
C=== GENMAKE v2 === |
C=== GENMAKE v2 === |
935 |
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 |
936 |
C them only if you know what you're doing. In general, you should |
C edit anything below these comments. In general, you should |
937 |
C add or remove packages by re-running genmake with different |
C add or remove packages by re-running genmake with different |
938 |
C "-enable" and/or "-disable" options. |
C "-enable" and/or "-disable" options. |
939 |
|
|
940 |
|
#ifndef PACKAGES_H |
941 |
|
#define PACKAGES_H |
942 |
|
|
943 |
C Packages disabled by genmake: |
C Packages disabled by genmake: |
944 |
EOF |
EOF |
945 |
# 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 |
958 |
fi |
fi |
959 |
done |
done |
960 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
961 |
undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
962 |
echo "#undef $undef" >> CPP_OPTIONS.h.tmp |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
963 |
|
# DEFINES="$DEFINES -U$undef" |
964 |
|
|
965 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
966 |
case $n in |
case $n in |
970 |
mom_vecinv) |
mom_vecinv) |
971 |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
972 |
;; |
;; |
|
generic_advdiff) |
|
|
DEFINES="$DEFINES -DDISABLE_GENERIC_ADVDIFF" |
|
|
;; |
|
973 |
debug) |
debug) |
974 |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
975 |
;; |
;; |
979 |
fi |
fi |
980 |
fi |
fi |
981 |
done |
done |
982 |
cat <<EOF >>CPP_OPTIONS.h.tmp |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
983 |
|
|
984 |
C Packages enabled by genmake: |
C Packages enabled by genmake: |
985 |
EOF |
EOF |
986 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
987 |
def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
988 |
echo "#define $def" >> CPP_OPTIONS.h.tmp |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
989 |
|
#eh3 DEFINES="$DEFINES -D$def" |
990 |
|
|
991 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
992 |
case $i in |
case $i in |
993 |
aim_v23) |
aim_v23) |
994 |
echo "#define ALLOW_AIM" >> CPP_OPTIONS.h.tmp |
echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp" |
995 |
|
DEFINES="$DEFINES -DALLOW_AIM" |
996 |
|
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
997 |
;; |
;; |
998 |
esac |
esac |
999 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1000 |
|
|
1001 |
done |
done |
1002 |
mv -f CPP_OPTIONS.h.tmp CPP_OPTIONS.h |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
1003 |
|
|
1004 |
|
#endif /* PACKAGES_H */ |
1005 |
|
EOF |
1006 |
|
|
1007 |
|
if test ! -f $PACKAGES_DOT_H ; then |
1008 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1009 |
|
else |
1010 |
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1011 |
|
RETVAL=$? |
1012 |
|
if test "x$RETVAL" = x0 ; then |
1013 |
|
rm -f $PACKAGES_DOT_H".tmp" |
1014 |
|
else |
1015 |
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
1016 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1017 |
|
fi |
1018 |
|
fi |
1019 |
|
|
1020 |
echo " Adding STANDARDDIRS" |
echo " Adding STANDARDDIRS" |
1021 |
BUILDDIR=${BUILDDIR:-.} |
BUILDDIR=${BUILDDIR:-.} |
1022 |
STANDARDDIRS=${STANDARDDIRS:-"eesupp model"} |
if test "x$STANDARDDIRS" = x ; then |
1023 |
|
STANDARDDIRS="eesupp model" |
1024 |
|
fi |
1025 |
for d in $STANDARDDIRS ; do |
for d in $STANDARDDIRS ; do |
1026 |
adr="$ROOTDIR/$d/src" |
adr="$ROOTDIR/$d/src" |
1027 |
if test ! -d $adr ; then |
if test ! -d $adr ; then |
1041 |
fi |
fi |
1042 |
done |
done |
1043 |
|
|
1044 |
|
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
1045 |
|
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1046 |
|
CPP_OPTIONS= |
1047 |
|
spaths=". $INCLUDEDIRS" |
1048 |
|
for i in $spaths ; do |
1049 |
|
try="$i/CPP_OPTIONS.h" |
1050 |
|
# echo -n " trying $try : " |
1051 |
|
if test -f $try -a -r $try ; then |
1052 |
|
echo " found CPP_OPTIONS=\"$try\"" |
1053 |
|
CPP_OPTIONS="$try" |
1054 |
|
break |
1055 |
|
fi |
1056 |
|
done |
1057 |
|
if test "x$CPP_OPTIONS" = x ; then |
1058 |
|
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
1059 |
|
exit 1 |
1060 |
|
fi |
1061 |
|
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
1062 |
|
names=`ls -1 "$ROOTDIR/pkg"` |
1063 |
|
for n in $names ; do |
1064 |
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
1065 |
|
done |
1066 |
|
|
1067 |
|
|
1068 |
|
# Here, we build the list of files to be "run through" the adjoint |
1069 |
|
# compiler. |
1070 |
|
if test -f ./ad_files ; then |
1071 |
|
rm -f ./ad_files |
1072 |
|
fi |
1073 |
|
echo " Creating the list of files for the adjoint compiler." |
1074 |
|
for i in $SOURCEDIRS ; do |
1075 |
|
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
1076 |
|
for j in $list_files ; do |
1077 |
|
cat $i/$j >> ad_files |
1078 |
|
done |
1079 |
|
done |
1080 |
|
|
1081 |
|
cat <<EOF > adjoint_sed |
1082 |
|
s/call adopen(/call adopen ( mythid,\\ |
1083 |
|
\& /g |
1084 |
|
s/call adclose(/call adclose( mythid,\\ |
1085 |
|
\& /g |
1086 |
|
s/call adread(/call adread ( mythid,\\ |
1087 |
|
\& /g |
1088 |
|
s/call adwrite(/call adwrite( mythid,\\ |
1089 |
|
\& /g |
1090 |
|
|
1091 |
|
EOF |
1092 |
|
|
1093 |
echo |
echo |
1094 |
echo "=== Creating the Makefile ===" |
echo "=== Creating the Makefile ===" |
1095 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
1096 |
for i in $INCLUDEDIRS ; do |
for i in $INCLUDEDIRS ; do |
1097 |
if test -d $i ; then |
if ! test -d $i ; then |
1098 |
INCLUDES="$INCLUDES -I$i" |
# INCLUDES="$INCLUDES -I$i" |
1099 |
else |
# else |
1100 |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
echo "Warning: can't find INCLUDEDIRS=\"$i\"" |
1101 |
fi |
fi |
1102 |
done |
done |
1106 |
mkdir .links.tmp |
mkdir .links.tmp |
1107 |
echo "# This section creates symbolic links" > srclinks.tmp |
echo "# This section creates symbolic links" > srclinks.tmp |
1108 |
echo "" >> srclinks.tmp |
echo "" >> srclinks.tmp |
1109 |
echo -n 'SRCFILES = ' > srclist.inc |
echo -n 'SRCFILES = ' > srclist.inc |
1110 |
echo -n 'CSRCFILES = ' > csrclist.inc |
echo -n 'CSRCFILES = ' > csrclist.inc |
1111 |
|
echo -n 'F90SRCFILES = ' > f90srclist.inc |
1112 |
echo -n 'HEADERFILES = ' > hlist.inc |
echo -n 'HEADERFILES = ' > hlist.inc |
1113 |
alldirs=". $SOURCEDIRS $INCLUDEDIRS" |
echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc |
1114 |
|
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
1115 |
for d in $alldirs ; do |
for d in $alldirs ; do |
1116 |
deplist= |
deplist= |
1117 |
sfiles=`( cd $d; echo *.[h,c,F] )` |
sfiles=`( cd $d; echo *.[h,c,F] *.flow )` |
1118 |
|
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
1119 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
1120 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
1121 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1122 |
extn=`echo $sf | awk -F '.' '{print $NF}'` |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
1123 |
touch .links.tmp/$sf |
touch .links.tmp/$sf |
1124 |
deplist="$deplist $sf" |
deplist="$deplist $sf" |
1125 |
case $extn in |
case $extn in |
1127 |
echo " \\" >> srclist.inc |
echo " \\" >> srclist.inc |
1128 |
echo -n " $sf" >> srclist.inc |
echo -n " $sf" >> srclist.inc |
1129 |
;; |
;; |
1130 |
|
F90) |
1131 |
|
echo " \\" >> f90srclist.inc |
1132 |
|
echo -n " $sf" >> f90srclist.inc |
1133 |
|
;; |
1134 |
c) |
c) |
1135 |
echo " \\" >> csrclist.inc |
echo " \\" >> csrclist.inc |
1136 |
echo -n " $sf" >> csrclist.inc |
echo -n " $sf" >> csrclist.inc |
1139 |
echo " \\" >> hlist.inc |
echo " \\" >> hlist.inc |
1140 |
echo -n " $sf" >> hlist.inc |
echo -n " $sf" >> hlist.inc |
1141 |
;; |
;; |
1142 |
|
flow) |
1143 |
|
echo " \\" >> ad_flow_files.inc |
1144 |
|
echo -n " $sf" >> ad_flow_files.inc |
1145 |
|
;; |
1146 |
esac |
esac |
1147 |
fi |
fi |
1148 |
fi |
fi |
1157 |
rm -rf .links.tmp |
rm -rf .links.tmp |
1158 |
echo "" >> srclist.inc |
echo "" >> srclist.inc |
1159 |
echo "" >> csrclist.inc |
echo "" >> csrclist.inc |
1160 |
|
echo "" >> f90srclist.inc |
1161 |
echo "" >> hlist.inc |
echo "" >> hlist.inc |
1162 |
|
echo "" >> ad_flow_files.inc |
1163 |
|
|
1164 |
if test -e $MAKEFILE ; then |
if test -e $MAKEFILE ; then |
1165 |
mv -f $MAKEFILE "$MAKEFILE.bak" |
mv -f $MAKEFILE "$MAKEFILE.bak" |
1173 |
echo "# $0 $@" >> $MAKEFILE |
echo "# $0 $@" >> $MAKEFILE |
1174 |
echo "# executed by:" >> $MAKEFILE |
echo "# executed by:" >> $MAKEFILE |
1175 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
1176 |
|
|
1177 |
|
EXE_AD=$EXECUTABLE"_ad" |
1178 |
|
EXE_FTL=$EXECUTABLE"_ftl" |
1179 |
|
EXE_SVD=$EXECUTABLE"_svd" |
1180 |
|
|
1181 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1182 |
# |
# |
1183 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1206 |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
1207 |
TOOLSDIR = ${TOOLSDIR} |
TOOLSDIR = ${TOOLSDIR} |
1208 |
|
|
1209 |
|
#eh3 new defines for the adjoint work |
1210 |
|
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1211 |
|
EXE_AD = ${EXE_AD} |
1212 |
|
EXE_FTL = ${EXE_FTL} |
1213 |
|
EXE_SVD = ${EXE_SVD} |
1214 |
|
|
1215 |
EOF |
EOF |
1216 |
|
|
1217 |
# Note: figure out some way to add Hyades JAM libraries here |
# Note: figure out some way to add Hyades JAM libraries here |
1227 |
KPP = ${KPP} |
KPP = ${KPP} |
1228 |
# Fortran compiler |
# Fortran compiler |
1229 |
FC = ${FC} |
FC = ${FC} |
1230 |
|
# Fortran compiler |
1231 |
|
F90C = ${F90C} |
1232 |
# Link editor |
# Link editor |
1233 |
LINK = ${LINK} |
LINK = ${LINK} |
1234 |
|
|
1242 |
# Optim./debug for FC |
# Optim./debug for FC |
1243 |
FFLAGS = ${FFLAGS} |
FFLAGS = ${FFLAGS} |
1244 |
FOPTIM = ${FOPTIM} |
FOPTIM = ${FOPTIM} |
1245 |
|
# Optim./debug for FC |
1246 |
|
F90FLAGS = ${F90FLAGS} |
1247 |
|
F90OPTIM = ${F90OPTIM} |
1248 |
# Flags for CC |
# Flags for CC |
1249 |
CFLAGS = ${CFLAGS} |
CFLAGS = ${CFLAGS} |
1250 |
# Files that should not be optimized |
# Files that should not be optimized |
1252 |
NOOPTFLAGS = ${NOOPTFLAGS} |
NOOPTFLAGS = ${NOOPTFLAGS} |
1253 |
# Flags and libraries needed for linking |
# Flags and libraries needed for linking |
1254 |
LIBS = ${LIBS} \$(XLIBS) |
LIBS = ${LIBS} \$(XLIBS) |
1255 |
|
# Name of the Mekfile |
1256 |
|
MAKEFILE=${MAKEFILE} |
1257 |
|
|
1258 |
EOF |
EOF |
1259 |
|
|
1260 |
cat srclist.inc >> $MAKEFILE |
cat srclist.inc >> $MAKEFILE |
1261 |
cat csrclist.inc >> $MAKEFILE |
cat csrclist.inc >> $MAKEFILE |
1262 |
cat hlist.inc >> $MAKEFILE |
cat f90srclist.inc >> $MAKEFILE |
1263 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
cat hlist.inc >> $MAKEFILE |
1264 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o)' >> $MAKEFILE |
cat ad_flow_files.inc >> $MAKEFILE |
1265 |
|
echo >> $MAKEFILE |
1266 |
|
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
1267 |
|
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
1268 |
|
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1269 |
|
|
1270 |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
1271 |
|
rm -f ad_flow_files.inc |
1272 |
|
|
1273 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1274 |
|
|
1275 |
.SUFFIXES: |
.SUFFIXES: |
1276 |
.SUFFIXES: .o .f .p .F .c |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
1277 |
|
|
1278 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1279 |
\$(EXECUTABLE): \$(OBJFILES) |
\$(EXECUTABLE): \$(OBJFILES) |
1281 |
depend: |
depend: |
1282 |
@make links |
@make links |
1283 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1284 |
|
${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) |
1285 |
|
|
1286 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
1287 |
|
|
1288 |
small_f: \$(F77FILES) |
small_f: \$(F77FILES) \$(F90FILES) |
1289 |
|
|
1290 |
output.txt: \$(EXECUTABLE) |
output.txt: \$(EXECUTABLE) |
1291 |
@printf 'running ... ' |
@printf 'running ... ' |
1292 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1293 |
|
|
1294 |
clean: |
clean: |
1295 |
-rm -rf *.o *.f *.p ${RMFILES} work.{pc,pcl} |
-cat AD_CONFIG.template > AD_CONFIG.h |
1296 |
|
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
1297 |
Clean: |
Clean: |
1298 |
@make clean |
@make clean |
1299 |
@make cleanlinks |
@make cleanlinks |
1300 |
-rm -f Makefile.bak |
-rm -f Makefile.bak genmake_state genmake_*optfile make.log |
1301 |
CLEAN: |
CLEAN: |
1302 |
@make Clean |
@make Clean |
1303 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1304 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
1305 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1306 |
-rm -f \$(EXECUTABLE) |
-rm -f \$(EXECUTABLE) output.txt |
1307 |
|
|
1308 |
|
#eh3 Makefile: makefile |
1309 |
makefile: |
makefile: |
1310 |
${0} $@ |
${0} $@ |
1311 |
cleanlinks: |
cleanlinks: |
1316 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1317 |
.f.o: |
.f.o: |
1318 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
1319 |
|
.F90.f90: |
1320 |
|
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1321 |
|
.f90.o: |
1322 |
|
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
1323 |
.c.o: |
.c.o: |
1324 |
\$(CC) \$(CFLAGS) -c \$< |
\$(CC) \$(CFLAGS) -c \$< |
1325 |
|
|
1329 |
.p.f: |
.p.f: |
1330 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
1331 |
|
|
1332 |
|
#========================================= |
1333 |
|
#=== Automatic Differentiation Rules === |
1334 |
|
|
1335 |
|
TAMC = ${TAMC} |
1336 |
|
TAF = ${TAF} |
1337 |
|
|
1338 |
|
TAF_EXTRA = ${TAF_EXTRA} |
1339 |
|
TAMC_EXTRA = ${TAMC_EXTRA} |
1340 |
|
|
1341 |
EOF |
EOF |
1342 |
|
|
1343 |
|
ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" |
1344 |
|
ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS" |
1345 |
|
ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
1346 |
|
for i in $ad_vars ; do |
1347 |
|
name=$i |
1348 |
|
t1="t2=\$"`echo $i` |
1349 |
|
eval $t1 |
1350 |
|
printf "%-20s = " $name >> $MAKEFILE |
1351 |
|
echo $t2 >> $MAKEFILE |
1352 |
|
done |
1353 |
|
|
1354 |
|
echo " Add the source list for AD code generation" |
1355 |
|
echo >> $MAKEFILE |
1356 |
|
echo -n "AD_FILES = " >> $MAKEFILE |
1357 |
|
AD_FILES=`cat ad_files` |
1358 |
|
for i in $AD_FILES ; do |
1359 |
|
echo " \\" >> $MAKEFILE |
1360 |
|
echo -n " $i" >> $MAKEFILE |
1361 |
|
done |
1362 |
|
echo >> $MAKEFILE |
1363 |
|
rm -f ad_files |
1364 |
|
|
1365 |
|
cat >>$MAKEFILE <<EOF |
1366 |
|
|
1367 |
|
AD_CONFIG.h: |
1368 |
|
cat AD_CONFIG.template > AD_CONFIG.h |
1369 |
|
|
1370 |
|
# ... AD ... |
1371 |
|
ad: ad_taf |
1372 |
|
ad_taf_f: ad_taf_output.f |
1373 |
|
ad_tamc_f: ad_tamc_output.f |
1374 |
|
|
1375 |
|
ad_input_code.f: \$(SRCFILES) |
1376 |
|
cat ad_config.template > AD_CONFIG.h |
1377 |
|
@make \$(F77FILES) |
1378 |
|
@make \$(AD_FLOW_FILES) |
1379 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1380 |
|
|
1381 |
|
ad_taf_output.f: ad_input_code.f |
1382 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1383 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
1384 |
|
|
1385 |
|
ad_taf: ad_taf_output.o \$(OBJFILES) |
1386 |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1387 |
|
|
1388 |
|
ad_tamc_output.f: ad_input_code.f |
1389 |
|
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1390 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
1391 |
|
|
1392 |
|
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1393 |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1394 |
|
|
1395 |
|
|
1396 |
|
# ... FTL ... |
1397 |
|
ftl: ftl_taf |
1398 |
|
ftl_taf_f: ftl_taf_output.f |
1399 |
|
ftl_tamc_f: ftl_tamc_output.f |
1400 |
|
|
1401 |
|
ftl_input_code.f: \$(SRCFILES) |
1402 |
|
cat ftl_config.template > AD_CONFIG.h |
1403 |
|
@make \$(AD_FLOW_FILES) |
1404 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1405 |
|
|
1406 |
|
ftl_taf_output.f: ftl_input_code.f |
1407 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1408 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1409 |
|
|
1410 |
|
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1411 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1412 |
|
|
1413 |
|
ftl_tamc_output.f: ftl_input_code.f |
1414 |
|
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1415 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f |
1416 |
|
|
1417 |
|
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1418 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1419 |
|
|
1420 |
|
|
1421 |
|
# ... SVD ... |
1422 |
|
svd: svd_taf |
1423 |
|
svd_taf_f: svd_taf_output.f |
1424 |
|
|
1425 |
|
svd_input_code.f: \$(SRCFILES) |
1426 |
|
cat svd_config.template > AD_CONFIG.h |
1427 |
|
@make \$(AD_FLOW_FILES) |
1428 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f |
1429 |
|
|
1430 |
|
svd_taf_output.f: svd_input_code.f |
1431 |
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f |
1432 |
|
cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
1433 |
|
|
1434 |
|
svd_taf: svd_taf_output.o \$(OBJFILES) |
1435 |
|
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
1436 |
|
|
1437 |
|
|
1438 |
|
#========================================= |
1439 |
|
|
1440 |
|
EOF |
1441 |
|
|
1442 |
|
if test "x$EXEHOOK" != x ; then |
1443 |
|
printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE |
1444 |
|
fi |
1445 |
|
|
1446 |
echo " Making list of \"exceptions\" that need \".p\" files" |
echo " Making list of \"exceptions\" that need \".p\" files" |
1447 |
for i in $KPPFILES ; do |
for i in $KPPFILES ; do |
1448 |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'` |
1472 |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |
printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE |
1473 |
|
|
1474 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1475 |
|
|
1476 |
|
# Write the "template" files for the adjoint builds |
1477 |
|
cat >>AD_CONFIG.template <<EOF |
1478 |
|
C WARNING: This file is automatically generated by genmake2 and |
1479 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1480 |
|
C unless you are CERTAIN that you know what you're doing. |
1481 |
|
|
1482 |
|
#undef ALLOW_ADJOINT_RUN |
1483 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1484 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1485 |
|
EOF |
1486 |
|
cat >>ad_config.template <<EOF |
1487 |
|
C WARNING: This file is automatically generated by genmake2 and |
1488 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1489 |
|
C unless you are CERTAIN that you know what you're doing. |
1490 |
|
|
1491 |
|
#undef ALLOW_ADJOINT_RUN |
1492 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1493 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1494 |
|
EOF |
1495 |
|
cat >>ftl_config.template <<EOF |
1496 |
|
C WARNING: This file is automatically generated by genmake2 and |
1497 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1498 |
|
C unless you are CERTAIN that you know what you're doing. |
1499 |
|
|
1500 |
|
#undef ALLOW_ADJOINT_RUN |
1501 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1502 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1503 |
|
EOF |
1504 |
|
cat >>svd_config.template <<EOF |
1505 |
|
C WARNING: This file is automatically generated by genmake2 and |
1506 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1507 |
|
C unless you are CERTAIN that you know what you're doing. |
1508 |
|
|
1509 |
|
#undef ALLOW_ADJOINT_RUN |
1510 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1511 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1512 |
|
EOF |
1513 |
|
cp AD_CONFIG.template AD_CONFIG.h |
1514 |
|
|
1515 |
|
|
1516 |
|
# Write the "state" for future records |
1517 |
|
if test "x$DUMPSTATE" != xf ; then |
1518 |
|
echo -n "" > genmake_state |
1519 |
|
for i in $gm_state ; do |
1520 |
|
t1="t2=\$$i" |
1521 |
|
eval $t1 |
1522 |
|
echo "$i='$t2'" >> genmake_state |
1523 |
|
done |
1524 |
|
fi |