1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# |
# |
13 |
test_for_package_in_cpp_options() { |
test_for_package_in_cpp_options() { |
14 |
cpp_options=$1 |
cpp_options=$1 |
15 |
pkg=$2 |
pkg=$2 |
16 |
grep -i "#define.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_$pkg" || exit 99 |
17 |
RETVAL=$? |
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_$pkg" || exit 99 |
18 |
if test "x${RETVAL}" = x0 ; then |
test_for_string_in_file $cpp_options "^[ ]*#define.*DISABLE_$pkg" || exit 99 |
19 |
echo "Error: In $cpp_options there is an illegal line: #define ALLOW_$pkg" |
test_for_string_in_file $cpp_options "^[ ]*#undef.*DISABLE_$pkg" || exit 99 |
20 |
exit 99 |
} |
21 |
fi |
|
22 |
grep -i "#undef.*ALLOW_$pkg" $cpp_options > /dev/null 2>&1 |
# Search for particular CPP #cmds associated with MPI |
23 |
RETVAL=$? |
# usage: test_for_mpi_in_cpp_eeoptions CPP_file |
24 |
if test "x${RETVAL}" = x0 ; then |
test_for_mpi_in_cpp_eeoptions() { |
25 |
echo "Error: In $cpp_options there is an illegal line: #undef ALLOW_$pkg" |
cpp_options=$1 |
26 |
exit 99 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALLOW_USE_MPI" || exit 99 |
27 |
fi |
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALLOW_USE_MPI" || exit 99 |
28 |
grep -i "#define.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
test_for_string_in_file $cpp_options "^[ ]*#define.*ALWAYS_USE_MPI" || exit 99 |
29 |
|
test_for_string_in_file $cpp_options "^[ ]*#undef.*ALWAYS_USE_MPI" || exit 99 |
30 |
|
} |
31 |
|
|
32 |
|
# Search for particular string in a file. Return 1 if detected, 0 if not |
33 |
|
# usage: test_for_string_in_file file string |
34 |
|
test_for_string_in_file() { |
35 |
|
file=$1 |
36 |
|
strng=$2 |
37 |
|
grep -i "$strng" $file > /dev/null 2>&1 |
38 |
RETVAL=$? |
RETVAL=$? |
39 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
40 |
echo "Error: In $cpp_options there is an illegal line: #define DISABLE_$pkg" |
echo -n "Error: In $file there is an illegal line: " |
41 |
exit 99 |
grep -i "$strng" $file |
42 |
|
return 1 |
43 |
fi |
fi |
44 |
grep -i "#undef.*DISABLE_$pkg" $cpp_options > /dev/null 2>&1 |
return 0 |
|
RETVAL=$? |
|
|
if test "x${RETVAL}" = x0 ; then |
|
|
echo "Error: In $cpp_options there is an illegal line: #undef DISABLE_$pkg" |
|
|
exit 99 |
|
|
fi |
|
45 |
} |
} |
46 |
|
|
47 |
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to |
77 |
|
|
78 |
tmp1=`uname`"_"`uname -m` |
tmp1=`uname`"_"`uname -m` |
79 |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
80 |
PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
tmp3=`echo $tmp2 | sed -e 's/power macintosh/ppc/'` |
81 |
|
PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
82 |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
83 |
echo " The platform appears to be: $PLATFORM" |
echo " The platform appears to be: $PLATFORM" |
|
# if test "x$OFLIST" = x ; then |
|
|
# echo " No pre-defined options files were found matching this platform" |
|
|
# echo " but examples for other platforms can be found in:" |
|
|
# echo " $ROOTDIR/tools/build_options" |
|
|
# else |
|
|
# echo " Options files (located in $ROOTDIR/tools/build_options) that" |
|
|
# echo " may work with this machine are:" |
|
|
# for i in $OFLIST ; do |
|
|
# echo " $i" |
|
|
# done |
|
|
# fi |
|
84 |
|
|
85 |
echo "test" > test |
echo "test" > test |
86 |
ln -s ./test link |
ln -s ./test link |
98 |
CPP="cpp -traditional -P" |
CPP="cpp -traditional -P" |
99 |
fi |
fi |
100 |
|
|
101 |
|
# makedepend is not always available |
102 |
|
if test "x${MAKEDEPEND}" = x ; then |
103 |
|
which makedepend >& /dev/null |
104 |
|
RETVAL=$? |
105 |
|
if test "x${RETVAL}" = x1 ; then |
106 |
|
echo " makedepend was not found. Using xmakedpend instead." |
107 |
|
MAKEDEPEND='$(TOOLSDIR)/xmakedepend' |
108 |
|
fi |
109 |
|
fi |
110 |
|
|
111 |
# look for possible fortran compilers |
# look for possible fortran compilers |
112 |
tmp="$MITGCM_FC $FC g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
113 |
p_FC= |
p_FC= |
114 |
for c in $tmp ; do |
for c in $tmp ; do |
115 |
rm -f ./hello.f ./hello |
rm -f ./hello.f ./hello |
210 |
cat $1 | sed -e 's/#.*$//g' \ |
cat $1 | sed -e 's/#.*$//g' \ |
211 |
| $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} }' \ |
212 |
> ./.pd_tmp |
> ./.pd_tmp |
213 |
source ./.pd_tmp |
. ./.pd_tmp |
214 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
215 |
|
|
216 |
echo -n "PNAME = "${} |
echo -n "PNAME = "${} |
219 |
|
|
220 |
# Explain usage |
# Explain usage |
221 |
usage() { |
usage() { |
222 |
echo |
cat <<EOF |
223 |
echo "Usage: "$0" [OPTIONS]" |
|
224 |
echo " where [OPTIONS] can be:" |
Usage: "$0" [OPTIONS] |
225 |
echo |
where [OPTIONS] can be: |
226 |
echo " -help | --help | -h | --h" |
|
227 |
echo " -nooptfile | --nooptfile" |
-help | --help | -h | --h |
228 |
echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME" |
Print this help message and exit. |
229 |
echo " -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME" |
|
230 |
echo " -pdepend NAME | --pdepend NAME" |
-nooptfile | --nooptfile |
231 |
echo " -pdepend=NAME | --pdepend=NAME" |
-optfile NAME | --optfile NAME | -of NAME | --of NAME |
232 |
echo " -pdefault NAME | --pdefault NAME" |
-optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME |
233 |
echo " -pdefault=NAME | --pdefault=NAME" |
Use "NAME" as the optfile. By default, an attempt will be |
234 |
echo " -make NAME | -m NAME" |
made to find an appropriate "standard" optfile in the |
235 |
echo " --make=NAME | -m=NAME" |
tools/build_options/ directory. |
236 |
echo " -makefile NAME | -mf NAME" |
|
237 |
echo " --makefile=NAME | -mf=NAME" |
-pdepend NAME | --pdepend NAME |
238 |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
-pdepend=NAME | --pdepend=NAME |
239 |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
Get package dependency information from "NAME". |
240 |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
|
241 |
echo " -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME" |
-pdefault NAME | --pdefault NAME |
242 |
echo " -mods NAME | --mods NAME | -mo NAME | --mo NAME" |
-pdefault=NAME | --pdefault=NAME |
243 |
echo " -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME" |
Get the default package list from "NAME". |
244 |
echo " -disable NAME | --disable NAME" |
|
245 |
echo " -disable=NAME | --disable=NAME" |
-make NAME | -m NAME |
246 |
echo " -enable NAME | --enable NAME" |
--make=NAME | -m=NAME |
247 |
echo " -enable=NAME | --enable=NAME" |
Use "NAME" for the MAKE program. The default is "make" but |
248 |
echo " -standarddirs NAME | --standarddirs NAME" |
many platforms, "gmake" is the preferred choice. |
249 |
echo " -standarddirs=NAME | --standarddirs=NAME" |
|
250 |
echo " -noopt NAME | --noopt NAME" |
-makefile NAME | -mf NAME |
251 |
echo " -noopt=NAME | --noopt=NAME" |
--makefile=NAME | -mf=NAME |
252 |
# echo " -cpp NAME | --cpp NAME" |
Call the makefile "NAME". The default is "Makefile". |
253 |
# echo " -cpp=NAME | --cpp=NAME" |
|
254 |
echo " -fortran NAME | --fortran NAME | -fc NAME | --fc NAME" |
-rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME |
255 |
echo " -fc=NAME | --fc=NAME" |
-rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME |
256 |
echo " -[no]ieee | --[no]ieee" |
Specify the location of the MITgcm ROOTDIR as "NAME". |
257 |
echo " -[no]mpi | --[no]mpi" |
By default, genamke will try to find the location by |
258 |
echo " -[no]jam | --[no]jam" |
looking in parent directories (up to the 5th parent). |
259 |
echo |
|
260 |
echo " and NAME is a string such as:" |
-mods NAME | --mods NAME | -mo NAME | --mo NAME |
261 |
echo |
-mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME |
262 |
echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'" |
Here, "NAME" specifies a list of directories that are |
263 |
echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'" |
used for additional source code. Files found in the |
264 |
echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'" |
"mods list" are given preference over files of the same |
265 |
echo |
name found elsewhere. |
266 |
echo " which, depending upon your shell, may need to be single-quoted" |
|
267 |
echo " if it contains spaces, dashes, or other special characters." |
-disable NAME | --disable NAME |
268 |
|
-disable=NAME | --disable=NAME |
269 |
|
Here "NAME" specifies a list of packages that we don't |
270 |
|
want to use. If this violates package dependencies, |
271 |
|
genamke will exit with an error message. |
272 |
|
|
273 |
|
-enable NAME | --enable NAME |
274 |
|
-enable=NAME | --enable=NAME |
275 |
|
Here "NAME" specifies a list of packages that we wish |
276 |
|
to specifically enable. If this violates package |
277 |
|
dependencies, genamke will exit with an error message. |
278 |
|
|
279 |
|
-standarddirs NAME | --standarddirs NAME |
280 |
|
-standarddirs=NAME | --standarddirs=NAME |
281 |
|
Here, "NAME" specifies a list of directories to be |
282 |
|
used as the "standard" code. |
283 |
|
|
284 |
|
-fortran NAME | --fortran NAME | -fc NAME | --fc NAME |
285 |
|
-fc=NAME | --fc=NAME |
286 |
|
Use "NAME" as the fortran compiler. By default, genmake |
287 |
|
will search for a working compiler by trying a list of |
288 |
|
"usual suspects" such as g77, f77, etc. |
289 |
|
|
290 |
|
-[no]ieee | --[no]ieee |
291 |
|
Do or don't use IEEE numerics. Note that this option |
292 |
|
*only* works if it is supported by the OPTFILE that |
293 |
|
is being used. |
294 |
|
|
295 |
|
While it is most often a single word, the "NAME" variables specified |
296 |
|
above can in many cases be a space-delimited string such as: |
297 |
|
|
298 |
|
--enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3' |
299 |
|
-mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3' |
300 |
|
-foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32' |
301 |
|
|
302 |
|
which, depending upon your shell, may need to be single-quoted. |
303 |
|
|
304 |
|
For more detailed genmake documentation, please see: |
305 |
|
|
306 |
|
http://mitgcm.org/devel_HOWTO/ |
307 |
|
|
308 |
|
EOF |
309 |
|
|
310 |
exit 1 |
exit 1 |
311 |
} |
} |
312 |
|
|
313 |
#eh3 # This is the generic configuration. |
# Build a CPP macro to automate calling C routines from FORTRAN |
314 |
#eh3 set LN = ( 'ln -s' ) |
get_fortran_c_namemangling() { |
315 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
default_nm="#define FC_NAMEMANGLE(X) X ## _" |
316 |
#eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' ) |
|
317 |
#eh3 set KPP = ( ) |
cat > genmake_test.c <<EOF |
318 |
#eh3 set FC = ( 'f77' ) |
void tcall( char * string ) { tsub( string ); } |
319 |
#eh3 set LINK = $FC |
EOF |
320 |
#eh3 set MAKEDEPEND = ( 'makedepend' ) |
$MAKE genmake_test.o >> genmake_warnings 2>&1 |
321 |
#eh3 set INCLUDES = ( -I. ) |
RETVAL=$? |
322 |
#eh3 set FFLAGS = ( ) |
if test "x$RETVAL" != x0 ; then |
323 |
#eh3 set FOPTIM = ( ) |
FC_NAMEMANGLE=$default_nm |
324 |
#eh3 set CFLAGS = ( ) |
cat <<EOF>> genmake_errors |
325 |
#eh3 set KFLAGS1 = ( ) |
|
326 |
#eh3 set KFLAGS2 = ( ) |
WARNING: C test compile fails |
327 |
#eh3 set LIBS = ( ) |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
328 |
#eh3 set KPPFILES = ( ) |
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
329 |
#eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( ) |
EOF |
330 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
return 1 |
331 |
|
fi |
332 |
|
c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` |
333 |
|
RETVAL=$? |
334 |
|
if test "x$RETVAL" != x0 ; then |
335 |
|
FC_NAMEMANGLE=$default_nm |
336 |
|
cat <<EOF>> genmake_warnings |
337 |
|
|
338 |
|
WARNING: The "nm" command failed. |
339 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
340 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
341 |
|
EOF |
342 |
|
return 1 |
343 |
|
fi |
344 |
|
cat > genmake_tcomp.f <<EOF |
345 |
|
subroutine tcall( string ) |
346 |
|
character*(*) string |
347 |
|
call tsub( string ) |
348 |
|
end |
349 |
|
EOF |
350 |
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1 |
351 |
|
RETVAL=$? |
352 |
|
if test "x$RETVAL" != x0 ; then |
353 |
|
FC_NAMEMANGLE=$default_nm |
354 |
|
cat <<EOF>> genmake_warnings |
355 |
|
|
356 |
|
WARNING: FORTRAN test compile fails -- please see "genmake_errors" |
357 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
358 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
359 |
|
EOF |
360 |
|
return 1 |
361 |
|
fi |
362 |
|
f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` |
363 |
|
RETVAL=$? |
364 |
|
if test "x$RETVAL" != x0 ; then |
365 |
|
FC_NAMEMANGLE=$default_nm |
366 |
|
cat <<EOF>> genmake_warnings |
367 |
|
|
368 |
|
WARNING: The "nm" command failed. |
369 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
370 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
371 |
|
EOF |
372 |
|
return 1 |
373 |
|
fi |
374 |
|
|
375 |
|
c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
376 |
|
f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
377 |
|
c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
378 |
|
f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
379 |
|
|
380 |
|
nmangle="X" |
381 |
|
if test "x$c_a" != "x$f_a" ; then |
382 |
|
comm="echo x$f_a | sed -e 's|x$c_a||'" |
383 |
|
a=`eval $comm` |
384 |
|
nmangle="$a ## $nmangle" |
385 |
|
fi |
386 |
|
if test "x$c_b" != "x$f_b" ; then |
387 |
|
comm="echo x$f_b | sed -e 's|x$c_b||'" |
388 |
|
b=`eval $comm` |
389 |
|
nmangle="$nmangle ## $b" |
390 |
|
fi |
391 |
|
|
392 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle" |
393 |
|
|
394 |
|
# cleanup the testing files |
395 |
|
rm -f genmake_tcomp.* genmake_test.* |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
|
check_HAVE_CLOC() { |
400 |
|
get_fortran_c_namemangling |
401 |
|
cat <<EOF > genmake_tc_1.c |
402 |
|
$FC_NAMEMANGLE |
403 |
|
#include <stdio.h> |
404 |
|
#include <stdlib.h> |
405 |
|
#include <unistd.h> |
406 |
|
#include <assert.h> |
407 |
|
#include <sys/time.h> |
408 |
|
void FC_NAMEMANGLE(cloc) ( double *curtim ) |
409 |
|
{ |
410 |
|
struct timeval tv1; |
411 |
|
gettimeofday(&tv1 , (void *)NULL ); |
412 |
|
*curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6); |
413 |
|
*curtim = *curtim/1.E6; |
414 |
|
} |
415 |
|
EOF |
416 |
|
make genmake_tc_1.o >> genmake_tc.log 2>&1 |
417 |
|
RET_C=$? |
418 |
|
cat <<EOF > genmake_tc_2.f |
419 |
|
program hello |
420 |
|
Real*8 wtime |
421 |
|
external cloc |
422 |
|
call cloc(wtime) |
423 |
|
print *," HELLO WORLD", wtime |
424 |
|
end program hello |
425 |
|
EOF |
426 |
|
$FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1 |
427 |
|
RET_F=$? |
428 |
|
test -x ./genmake_tc && ./genmake_tc >> genmake_tc.log 2>&1 |
429 |
|
RETVAL=$? |
430 |
|
if test "x$RETVAL" = x0 ; then |
431 |
|
HAVE_CLOC=t |
432 |
|
DEFINES="$DEFINES -DHAVE_CLOC" |
433 |
|
fi |
434 |
|
rm -f genmake_tc* |
435 |
|
} |
436 |
|
|
437 |
|
|
438 |
# Set defaults here |
# Set defaults here |
439 |
COMMANDL="$0 $@" |
COMMANDL="$0 $@" |
444 |
KPP= |
KPP= |
445 |
FC= |
FC= |
446 |
LINK= |
LINK= |
447 |
DEFINES="-DWORDLENGTH=4" |
# DEFINES="-DWORDLENGTH=4" |
448 |
|
DEFINES= |
449 |
PACKAGES= |
PACKAGES= |
450 |
ENABLE= |
ENABLE= |
451 |
DISABLE= |
DISABLE= |
466 |
NOOPTFILES= |
NOOPTFILES= |
467 |
NOOPTFLAGS= |
NOOPTFLAGS= |
468 |
|
|
469 |
|
# DEFINES checked by test compilation |
470 |
|
HAVE_SYSTEM= |
471 |
|
HAVE_FDATE= |
472 |
|
FC_NAMEMANGLE= |
473 |
|
HAVE_CLOC= |
474 |
|
|
475 |
MODS= |
MODS= |
476 |
TOOLSDIR= |
TOOLSDIR= |
477 |
SOURCEDIRS= |
SOURCEDIRS= |
509 |
|
|
510 |
|
|
511 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
512 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" |
513 |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
514 |
|
|
515 |
# The following state is not directly set by command-line switches |
# The following state is not directly set by command-line switches |
517 |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
518 |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
519 |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
520 |
|
gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE" |
521 |
|
|
522 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
523 |
gm_s7="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
524 |
gm_s8="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
525 |
gm_s9="TAF_EXTRA TAMC_EXTRA" |
gm_s12="TAF_EXTRA TAMC_EXTRA" |
526 |
|
|
527 |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7 $gm_s8 $gm_s9" |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7" |
528 |
|
gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12" |
529 |
|
|
530 |
|
cat <<EOF |
531 |
|
|
532 |
|
GENMAKE : |
533 |
|
|
534 |
|
A program for GENerating MAKEfiles for the MITgcm project. For a |
535 |
|
quick list of options, use "genmake -h" or for more detail see: |
536 |
|
|
537 |
|
http://mitgcm.org/devel_HOWTO/ |
538 |
|
|
539 |
|
EOF |
540 |
|
|
|
echo |
|
541 |
echo "=== Processing options files and arguments ===" |
echo "=== Processing options files and arguments ===" |
542 |
gm_local="genmake_local" |
gm_local="genmake_local" |
543 |
for i in . $MODS ; do |
for i in . $MODS ; do |
544 |
if test -r $i/$gm_local ; then |
if test -r $i/$gm_local ; then |
545 |
source $i/$gm_local |
. $i/$gm_local |
546 |
break |
break |
547 |
fi |
fi |
548 |
done |
done |
549 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
550 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
551 |
echo "using $gm_local" |
echo "using $gm_local" |
552 |
source $gm_local |
. $gm_local |
553 |
# echo "DISABLE=$DISABLE" |
# echo "DISABLE=$DISABLE" |
554 |
# echo "ENABLE=$ENABLE" |
# echo "ENABLE=$ENABLE" |
555 |
else |
else |
591 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
592 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
593 |
|
|
594 |
-adoptfile | --adoptfile | -ad | --ad) |
-adoptfile | --adoptfile | -adof | --adof) |
595 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
596 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
597 |
AD_OPTFILE=$ac_optarg ;; |
AD_OPTFILE=$ac_optarg ;; |
616 |
-makefile=* | --makefile=* | -ma=* | --ma=*) |
-makefile=* | --makefile=* | -ma=* | --ma=*) |
617 |
MAKEFILE=$ac_optarg ;; |
MAKEFILE=$ac_optarg ;; |
618 |
|
|
619 |
-platform | --platform | -pl | --pl) |
-platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*) |
620 |
ac_prev=PLATFORM ;; |
echo "ERROR: The platform option has been removed. Please specify" |
621 |
-platform=* | --platform=* | -pl=* | --pl=*) |
echo " the build options using the \"optfile\" mechanism." |
622 |
PLATFORM=$ac_optarg ;; |
echo |
623 |
|
usage |
624 |
|
;; |
625 |
|
|
626 |
-rootdir | --rootdir | -rd | --rd) |
-rootdir | --rootdir | -rd | --rd) |
627 |
ac_prev=ROOTDIR ;; |
ac_prev=ROOTDIR ;; |
648 |
-standarddirs=* | --standarddirs=*) |
-standarddirs=* | --standarddirs=*) |
649 |
STANDARDDIRS=$ac_optarg ;; |
STANDARDDIRS=$ac_optarg ;; |
650 |
|
|
|
-noopt | --noopt) |
|
|
ac_prev=NOOPT ;; |
|
|
-noopt=* | --noopt=*) |
|
|
NOOPT=$ac_optarg ;; |
|
|
|
|
651 |
# -cpp | --cpp) |
# -cpp | --cpp) |
652 |
# ac_prev=cpp ;; |
# ac_prev=cpp ;; |
653 |
# -cpp=* | --cpp=*) |
# -cpp=* | --cpp=*) |
663 |
-noieee | --noieee) |
-noieee | --noieee) |
664 |
IEEE= ;; |
IEEE= ;; |
665 |
|
|
666 |
-mpi | --mpi) |
# -jam | --jam) |
667 |
MPI=true ;; |
# JAM=1 ;; |
668 |
-nompi | --nompi) |
# -nojam | --nojam) |
669 |
MPI= ;; |
# JAM=0 ;; |
|
|
|
|
-jam | --jam) |
|
|
JAM=1 ;; |
|
|
-nojam | --nojam) |
|
|
JAM=0 ;; |
|
670 |
|
|
671 |
-ds | --ds) |
-ds | --ds) |
672 |
DUMPSTATE=t ;; |
DUMPSTATE=t ;; |
745 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
746 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
747 |
echo " using OPTFILE=\"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
748 |
source "$OPTFILE" |
. "$OPTFILE" |
749 |
RETVAL=$? |
RETVAL=$? |
750 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
751 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
772 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
773 |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
774 |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
775 |
source "$AD_OPTFILE" |
. "$AD_OPTFILE" |
776 |
RETVAL=$? |
RETVAL=$? |
777 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
778 |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
788 |
fi |
fi |
789 |
fi |
fi |
790 |
|
|
791 |
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
# Check that FC, LINK, CPP, S64, LN, and MAKE are defined. If not, |
792 |
# and abort! |
# either set defaults or complain and abort! |
793 |
if test "x$FC" = x ; then |
if test "x$FC" = x ; then |
794 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |
795 |
|
|
806 |
if test "x$CPP" = x ; then |
if test "x$CPP" = x ; then |
807 |
CPP="cpp" |
CPP="cpp" |
808 |
fi |
fi |
809 |
|
if test "x$MAKE" = x ; then |
810 |
|
MAKE="make" |
811 |
|
fi |
812 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
813 |
RETVAL=$? |
RETVAL=$? |
814 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
818 |
|
|
819 |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
820 |
2) the "./genmake_local" file |
2) the "./genmake_local" file |
821 |
|
3) with the CPP environment variable |
822 |
|
|
823 |
EOF |
EOF |
824 |
exit 1 |
exit 1 |
828 |
if test "x$MAKEDEPEND" = x ; then |
if test "x$MAKEDEPEND" = x ; then |
829 |
MAKEDEPEND=makedepend |
MAKEDEPEND=makedepend |
830 |
fi |
fi |
831 |
|
if test "x$LN" = x ; then |
832 |
|
LN="ln -s" |
833 |
|
fi |
834 |
|
echo "test" > genmake_test_ln |
835 |
|
$LN genmake_test_ln genmake_tlink |
836 |
|
RETVAL=$? |
837 |
|
if test "x$RETVAL" != x0 ; then |
838 |
|
cat <<EOF 1>&2 |
839 |
|
|
840 |
|
Error: The command "ln -s" failed -- please specify a working soft-link |
841 |
|
command in the optfile. |
842 |
|
|
843 |
|
EOF |
844 |
|
exit 1 |
845 |
|
fi |
846 |
|
rm -f genmake_test_ln genmake_tlink |
847 |
|
|
848 |
|
|
849 |
|
printf "\n=== Checking system libraries ===\n" |
850 |
|
echo -n " Do we have the system() command using $FC... " |
851 |
|
cat > genmake_tcomp.f <<EOF |
852 |
|
program hello |
853 |
|
call system('echo hi') |
854 |
|
end |
855 |
|
EOF |
856 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
857 |
|
RETVAL=$? |
858 |
|
if test "x$RETVAL" = x0 ; then |
859 |
|
HAVE_SYSTEM=t |
860 |
|
DEFINES="$DEFINES -DHAVE_SYSTEM" |
861 |
|
echo "yes" |
862 |
|
else |
863 |
|
HAVE_SYSTEM= |
864 |
|
echo "no" |
865 |
|
fi |
866 |
|
rm -f genmake_tcomp* |
867 |
|
|
868 |
|
echo -n " Do we have the fdate() command using $FC... " |
869 |
|
cat > genmake_tcomp.f <<EOF |
870 |
|
program hello |
871 |
|
CHARACTER(128) string |
872 |
|
string = ' ' |
873 |
|
call fdate( string ) |
874 |
|
print *, string |
875 |
|
end |
876 |
|
EOF |
877 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
878 |
|
RETVAL=$? |
879 |
|
if test "x$RETVAL" = x0 ; then |
880 |
|
HAVE_FDATE=t |
881 |
|
DEFINES="$DEFINES -DHAVE_FDATE" |
882 |
|
echo "yes" |
883 |
|
else |
884 |
|
HAVE_FDATE= |
885 |
|
echo "no" |
886 |
|
fi |
887 |
|
rm -f genmake_tcomp* |
888 |
|
|
889 |
|
echo -n " Can we call simple C routines (here, \"cloc()\") using $FC... " |
890 |
|
check_HAVE_CLOC |
891 |
|
if test "x$HAVE_CLOC" != x ; then |
892 |
|
echo "yes" |
893 |
|
else |
894 |
|
echo "no" |
895 |
|
fi |
896 |
|
rm -f genmake_t* |
897 |
|
|
898 |
|
|
899 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
900 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
940 |
if test "x$S64" = x ; then |
if test "x$S64" = x ; then |
941 |
S64='$(TOOLSDIR)/set64bitConst.sh' |
S64='$(TOOLSDIR)/set64bitConst.sh' |
942 |
fi |
fi |
943 |
|
THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'` |
944 |
|
|
945 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
946 |
|
|
949 |
# they appear as regular source code |
# they appear as regular source code |
950 |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
951 |
echo " Making source files in eesupp from templates" |
echo " Making source files in eesupp from templates" |
952 |
$MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 |
( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1 |
953 |
RETVAL=$? |
RETVAL=$? |
954 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
955 |
rm -f make_eesupp.errors |
rm -f make_eesupp.errors |
986 |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
987 |
exit 1 |
exit 1 |
988 |
fi |
fi |
989 |
source ./.pd_tmp |
. ./.pd_tmp |
990 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
991 |
|
|
992 |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
993 |
# file should eventually be added so that, for convenience, one can |
# file should eventually be added so that, for convenience, one can |
994 |
# specify groups of packages using names like "ocean" and "atmosphere". |
# specify groups of packages using names like "ocean" and "atmosphere". |
995 |
echo -n " checking default package list: " |
echo " checking default package list: " |
996 |
if test "x${PDEFAULT}" = x ; then |
if test "x${PDEFAULT}" = x ; then |
997 |
for i in "." $MODS ; do |
for i in "." $MODS ; do |
998 |
if test -r $i"/packages.conf" ; then |
if test -r $i"/packages.conf" ; then |
1005 |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
1006 |
fi |
fi |
1007 |
if test "x${PDEFAULT}" = xNONE ; then |
if test "x${PDEFAULT}" = xNONE ; then |
1008 |
echo "default packages file disabled" |
echo " default packages file disabled" |
1009 |
else |
else |
1010 |
if test ! -r $PDEFAULT ; then |
if test ! -r $PDEFAULT ; then |
|
echo "" |
|
1011 |
echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\"" |
echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\"" |
1012 |
else |
else |
1013 |
echo " using PDEFAULT=\"$PDEFAULT\"" |
echo " using PDEFAULT=\"$PDEFAULT\"" |
1014 |
# Strip the comments and add all the names |
# Strip the comments and add all the names |
1015 |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
1016 |
RETVAL=$? |
RETVAL=$? |
1143 |
fi |
fi |
1144 |
done |
done |
1145 |
|
|
|
# This is compatible with the old genmake. The "DISABLE_*" flags |
|
|
# need to be replaced by the "ALLOW_*" flags set below. |
|
|
# |
|
|
# echo -n " Setting package-specific CPP flags: " |
|
|
# pkrm=( mom_fluxform mom_vecinv generic_advdiff ) |
|
|
# pkrmdef=( -DDISABLE_MOM_FLUXFORM -DDISABLE_MOM_VECINV -DDISABLE_GENERIC_ADVDIFF -DDISABLE_DEBUGMODE ) |
|
|
# echo -n " " |
|
|
# i=0 |
|
|
# while test $i -lt "${#pkrm[@]}" ; do |
|
|
# echo "$PACKAGES" | grep "${pk[$i]}" > /dev/null 2>&1 |
|
|
# RETVAL=$? |
|
|
# if test "x$RETVAL" = x1 ; then |
|
|
# DEFINES="$DEFINES ${pkdef[$i]}" |
|
|
# echo -n " ${pkdef[$i]}" |
|
|
# fi |
|
|
# i=$(( $i + 1 )) |
|
|
# done |
|
|
# echo |
|
1146 |
|
|
1147 |
# Create a list of #define and #undef to enable/disable packages |
# Create a list of #define and #undef to enable/disable packages |
1148 |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
|
cat <<EOF >$PACKAGES_DOT_H".tmp" |
|
|
C=== GENMAKE v2 === |
|
|
C The following defines have been set by GENMAKE, so please do not |
|
|
C edit anything below these comments. In general, you should |
|
|
C add or remove packages by re-running genmake with different |
|
|
C "-enable" and/or "-disable" options. |
|
|
|
|
|
#ifndef PACKAGES_H |
|
|
#define PACKAGES_H |
|
|
|
|
|
C Packages disabled by genmake: |
|
|
EOF |
|
1149 |
# 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 |
1150 |
# away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h |
# away. On 2003-08-12, CNH, JMC, and EH3 agreed that the CPP_OPTIONS.h |
1151 |
# file would eventually be split up so that all package-related #define |
# file would eventually be split up so that all package-related #define |
1152 |
# statements could be separated and handled only by genmake. |
# statements could be separated and handled only by genmake. |
1153 |
names=`ls -1 "$ROOTDIR/pkg"` |
names=`ls -1 "$ROOTDIR/pkg"` |
1154 |
all_pack= |
all_pack= |
1155 |
|
DISABLED_PACKAGES= |
1156 |
for n in $names ; do |
for n in $names ; do |
1157 |
if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then |
if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then |
1158 |
has_pack="f" |
has_pack="f" |
1164 |
done |
done |
1165 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
1166 |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
1167 |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
DISABLED_PACKAGES="$DISABLED_PACKAGES -U$undef" |
|
# DEFINES="$DEFINES -U$undef" |
|
|
|
|
|
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
|
|
case $n in |
|
|
mom_fluxform) |
|
|
DEFINES="$DEFINES -DDISABLE_MOM_FLUXFORM" |
|
|
;; |
|
|
mom_vecinv) |
|
|
DEFINES="$DEFINES -DDISABLE_MOM_VECINV" |
|
|
;; |
|
|
debug) |
|
|
DEFINES="$DEFINES -DDISABLE_DEBUGMODE" |
|
|
;; |
|
|
esac |
|
|
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
|
|
|
|
1168 |
fi |
fi |
1169 |
fi |
fi |
1170 |
done |
done |
1171 |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
ENABLED_PACKAGES= |
|
|
|
|
C Packages enabled by genmake: |
|
|
EOF |
|
1172 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
1173 |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
1174 |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def" |
1175 |
#eh3 DEFINES="$DEFINES -D$def" |
#eh3 DEFINES="$DEFINES -D$def" |
1176 |
|
|
1177 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1178 |
case $i in |
case $i in |
1179 |
aim_v23) |
aim_v23) |
|
echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp" |
|
1180 |
DEFINES="$DEFINES -DALLOW_AIM" |
DEFINES="$DEFINES -DALLOW_AIM" |
1181 |
|
ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" |
1182 |
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
echo "Warning: ALLOW_AIM is set to enable aim_v23. This is REALLY ugly Jean-Michel :-)" |
1183 |
;; |
;; |
1184 |
esac |
esac |
1185 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1186 |
|
|
1187 |
done |
done |
|
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
|
|
|
|
|
#endif /* PACKAGES_H */ |
|
|
EOF |
|
|
|
|
|
if test ! -f $PACKAGES_DOT_H ; then |
|
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
|
|
else |
|
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" = x0 ; then |
|
|
rm -f $PACKAGES_DOT_H".tmp" |
|
|
else |
|
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
|
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
|
|
fi |
|
|
fi |
|
1188 |
|
|
1189 |
echo " Adding STANDARDDIRS" |
echo " Adding STANDARDDIRS" |
1190 |
BUILDDIR=${BUILDDIR:-.} |
BUILDDIR=${BUILDDIR:-.} |
1210 |
fi |
fi |
1211 |
done |
done |
1212 |
|
|
1213 |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
echo " Searching for *OPTIONS.h files in order to warn about the presence" |
1214 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define \"-type statements that are no longer allowed:" |
1215 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1216 |
|
CPP_EEOPTIONS= |
1217 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1218 |
|
names=`ls -1 "$ROOTDIR/pkg"` |
1219 |
for i in $spaths ; do |
for i in $spaths ; do |
1220 |
try="$i/CPP_OPTIONS.h" |
try="$i/CPP_OPTIONS.h" |
1221 |
# echo -n " trying $try : " |
if test -f $try -a -r $try -a "x$CPP_OPTIONS" == x ; then |
|
if test -f $try -a -r $try ; then |
|
1222 |
echo " found CPP_OPTIONS=\"$try\"" |
echo " found CPP_OPTIONS=\"$try\"" |
1223 |
CPP_OPTIONS="$try" |
CPP_OPTIONS="$try" |
1224 |
break |
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
1225 |
|
for n in $names ; do |
1226 |
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
1227 |
|
done |
1228 |
|
fi |
1229 |
|
try="$i/CPP_EEOPTIONS.h" |
1230 |
|
if test -f $try -a -r $try -a "x$CPP_EEOPTIONS" == x ; then |
1231 |
|
echo " found CPP_EEOPTIONS=\"$try\"" |
1232 |
|
# New safety test: make sure MPI is not determined by CPP_EEOPTIONS.h |
1233 |
|
#**** not yet enabled **** |
1234 |
|
# test_for_mpi_in_cpp_eeoptions $try |
1235 |
|
#**** not yet enabled **** |
1236 |
|
CPP_EEOPTIONS="$try" |
1237 |
fi |
fi |
1238 |
done |
done |
1239 |
if test "x$CPP_OPTIONS" = x ; then |
if test "x$CPP_OPTIONS" = x ; then |
1240 |
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
echo "Error: can't find \"CPP_OPTIONS.h\" in the path list: $spaths" |
1241 |
exit 1 |
exit 1 |
1242 |
fi |
fi |
|
# New safety test: make sure packages are not mentioned in CPP_OPTIONS.h |
|
|
names=`ls -1 "$ROOTDIR/pkg"` |
|
|
for n in $names ; do |
|
|
test_for_package_in_cpp_options $CPP_OPTIONS $n |
|
|
done |
|
|
|
|
1243 |
|
|
1244 |
# Here, we build the list of files to be "run through" the adjoint |
# Here, we build the list of files to be "run through" the adjoint |
1245 |
# compiler. |
# compiler. |
1254 |
done |
done |
1255 |
done |
done |
1256 |
|
|
|
cat <<EOF > adjoint_sed |
|
|
s/call adopen(/call adopen ( mythid,\\ |
|
|
\& /g |
|
|
s/call adclose(/call adclose( mythid,\\ |
|
|
\& /g |
|
|
s/call adread(/call adread ( mythid,\\ |
|
|
\& /g |
|
|
s/call adwrite(/call adwrite( mythid,\\ |
|
|
\& /g |
|
|
|
|
|
EOF |
|
|
|
|
1257 |
echo |
echo |
1258 |
echo "=== Creating the Makefile ===" |
echo "=== Creating the Makefile ===" |
1259 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
1283 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
1284 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
1285 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1286 |
|
case $d/$sf in |
1287 |
|
./$PACKAGES_DOT_H) |
1288 |
|
;; |
1289 |
|
./AD_CONFIG.h) |
1290 |
|
;; |
1291 |
|
./FC_NAMEMANGLE.h) |
1292 |
|
;; |
1293 |
|
*) |
1294 |
|
touch .links.tmp/$sf |
1295 |
|
deplist="$deplist $sf" |
1296 |
|
;; |
1297 |
|
esac |
1298 |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
|
touch .links.tmp/$sf |
|
|
deplist="$deplist $sf" |
|
1299 |
case $extn in |
case $extn in |
1300 |
F) |
F) |
1301 |
echo " \\" >> srclist.inc |
echo " \\" >> srclist.inc |
1386 |
EXE_FTL = ${EXE_FTL} |
EXE_FTL = ${EXE_FTL} |
1387 |
EXE_SVD = ${EXE_SVD} |
EXE_SVD = ${EXE_SVD} |
1388 |
|
|
1389 |
|
ENABLED_PACKAGES = ${ENABLED_PACKAGES} |
1390 |
|
DISABLED_PACKAGES = ${DISABLED_PACKAGES} |
1391 |
|
|
1392 |
|
# These files are created by Makefile |
1393 |
|
SPECIAL_FILES = ${PACKAGES_DOT_H} AD_CONFIG.h FC_NAMEMANGLE.h |
1394 |
|
|
1395 |
EOF |
EOF |
1396 |
|
|
1397 |
# Note: figure out some way to add Hyades JAM libraries here |
# Note: figure out some way to add Hyades JAM libraries here |
1456 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
1457 |
|
|
1458 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1459 |
\$(EXECUTABLE): \$(OBJFILES) |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) |
1460 |
|
@echo Creating \$@ ... |
1461 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
1462 |
depend: |
depend: |
1463 |
@make links |
@make links |
1464 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1465 |
${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
1466 |
|
|
1467 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES) |
1468 |
|
|
1469 |
small_f: \$(F77FILES) \$(F90FILES) |
small_f: \$(F77FILES) \$(F90FILES) |
1470 |
|
|
1473 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1474 |
|
|
1475 |
clean: |
clean: |
1476 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template |
1477 |
Clean: |
Clean: |
1478 |
@make clean |
@make clean |
1479 |
@make cleanlinks |
@make cleanlinks |
1480 |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
-rm -f \$(SPECIAL_FILES) |
1481 |
|
-rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak |
1482 |
CLEAN: |
CLEAN: |
1483 |
@make Clean |
@make Clean |
1484 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1488 |
|
|
1489 |
#eh3 Makefile: makefile |
#eh3 Makefile: makefile |
1490 |
makefile: |
makefile: |
1491 |
${0} $@ |
$THIS_SCRIPT $@ |
1492 |
cleanlinks: |
cleanlinks: |
1493 |
-find . -type l -exec rm {} \; |
-find . -type l -exec rm {} \; |
1494 |
|
|
1495 |
|
# Special targets ($SPECIAL_FILES) which are create by make |
1496 |
|
${PACKAGES_DOT_H}: |
1497 |
|
@echo Creating \$@ ... |
1498 |
|
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
1499 |
|
AD_CONFIG.h: |
1500 |
|
@echo Creating \$@ ... |
1501 |
|
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ |
1502 |
|
FC_NAMEMANGLE.h: |
1503 |
|
@echo Creating \$@ ... |
1504 |
|
echo "$FC_NAMEMANGLE" > \$@ |
1505 |
|
|
1506 |
# The normal chain of rules is ( .F - .f - .o ) |
# The normal chain of rules is ( .F - .f - .o ) |
1507 |
.F.f: |
.F.f: |
1508 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1556 |
|
|
1557 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1558 |
|
|
1559 |
ad_input_code.f: \$(F77FILES) |
# ... AD ... |
1560 |
|
adall: ad_taf |
1561 |
|
adtaf: ad_taf_output.f |
1562 |
|
adtamc: ad_tamc_output.f |
1563 |
|
|
1564 |
|
ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1565 |
|
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template |
1566 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
1567 |
|
-rm -f ad_config.template |
1568 |
|
@make \$(F77FILES) |
1569 |
@make \$(AD_FLOW_FILES) |
@make \$(AD_FLOW_FILES) |
1570 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1571 |
|
|
|
# ... AD ... |
|
|
ad: ad_taf |
|
|
ad_taf_f: ad_taf_output.f |
|
|
ad_tamc_f: ad_tamc_output.f |
|
|
|
|
1572 |
ad_taf_output.f: ad_input_code.f |
ad_taf_output.f: ad_input_code.f |
1573 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1574 |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f |
1575 |
|
|
1576 |
|
adtafonly: |
1577 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1578 |
|
cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f |
1579 |
|
|
1580 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
ad_taf: ad_taf_output.o \$(OBJFILES) |
1581 |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1582 |
|
|
1583 |
ad_tamc_output.f: ad_input_code.f |
ad_tamc_output.f: ad_input_code.f |
1584 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1585 |
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_tamc_output.f |
1586 |
|
|
1587 |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1588 |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1589 |
|
|
1590 |
|
|
1591 |
# ... FTL ... |
# ... FTL ... |
1592 |
ftl: ftl_taf |
ftlall: ftl_taf |
1593 |
ftl_taf_f: ftl_taf_output.f |
ftltaf: ftl_taf_output.f |
1594 |
ftl_tamc_f: ftl_tamc_output.f |
ftltamc: ftl_tamc_output.f |
1595 |
|
|
1596 |
ftl_taf_output.f: ad_input_code.f |
ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1597 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template |
1598 |
cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
1599 |
|
-rm -f ftl_config.template |
1600 |
|
@make \$(F77FILES) |
1601 |
|
@make \$(AD_FLOW_FILES) |
1602 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1603 |
|
|
1604 |
|
ftl_taf_output.f: ftl_input_code.f |
1605 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1606 |
|
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f |
1607 |
|
|
1608 |
|
ftltafonly: |
1609 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1610 |
|
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f |
1611 |
|
|
1612 |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1613 |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1614 |
|
|
1615 |
ftl_tamc_output.f: ad_input_code.f |
ftl_tamc_output.f: ftl_input_code.f |
1616 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1617 |
cat ad_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f |
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f |
1618 |
|
|
1619 |
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1620 |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1621 |
|
|
1622 |
|
|
1623 |
# ... SVD ... |
# ... SVD ... |
1624 |
svd: svd_taf |
svdtaf: ad_taf_output.f ftl_taf_output.f |
1625 |
svd_taf_f: svd_taf_output.f |
svdall: svd_taf |
|
|
|
|
svd_taf_output.f: ad_input_code.f |
|
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
|
|
cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
|
1626 |
|
|
1627 |
svd_taf: svd_taf_output.o \$(OBJFILES) |
svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES) |
1628 |
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
\$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS) |
1629 |
|
|
1630 |
|
|
1631 |
#========================================= |
#========================================= |
1666 |
|
|
1667 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1668 |
|
|
1669 |
|
# Create special header files |
1670 |
|
$TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" $DISABLED_PACKAGES " " "Enabled packages:" $ENABLED_PACKAGES > $PACKAGES_DOT_H".tmp" |
1671 |
|
if test ! -f $PACKAGES_DOT_H ; then |
1672 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1673 |
|
else |
1674 |
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1675 |
|
RETVAL=$? |
1676 |
|
if test "x$RETVAL" = x0 ; then |
1677 |
|
rm -f $PACKAGES_DOT_H".tmp" |
1678 |
|
else |
1679 |
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
1680 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1681 |
|
fi |
1682 |
|
fi |
1683 |
|
if test ! -f AD_CONFIG.h ; then |
1684 |
|
$TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h |
1685 |
|
fi |
1686 |
|
|
1687 |
|
|
1688 |
# Write the "state" for future records |
# Write the "state" for future records |
1689 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |