1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# |
# |
72 |
|
|
73 |
tmp1=`uname`"_"`uname -m` |
tmp1=`uname`"_"`uname -m` |
74 |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` |
75 |
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/'` |
76 |
|
PLATFORM=`echo $tmp3 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` |
77 |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` |
78 |
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 |
|
79 |
|
|
80 |
echo "test" > test |
echo "test" > test |
81 |
ln -s ./test link |
ln -s ./test link |
93 |
CPP="cpp -traditional -P" |
CPP="cpp -traditional -P" |
94 |
fi |
fi |
95 |
|
|
96 |
|
# makedepend is not always available |
97 |
|
if test "x${MAKEDEPEND}" = x ; then |
98 |
|
which makedepend >& /dev/null |
99 |
|
RETVAL=$? |
100 |
|
if test "x${RETVAL}" = x1 ; then |
101 |
|
echo " makedepend was not found. Using xmakedpend instead." |
102 |
|
MAKEDEPEND='$(TOOLSDIR)/xmakedepend' |
103 |
|
fi |
104 |
|
fi |
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" |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" |
108 |
p_FC= |
p_FC= |
109 |
for c in $tmp ; do |
for c in $tmp ; do |
110 |
rm -f ./hello.f ./hello |
rm -f ./hello.f ./hello |
121 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
122 |
fi |
fi |
123 |
done |
done |
124 |
|
rm -f ./hello.f ./hello |
125 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
126 |
cat 1>&2 <<EOF |
cat 1>&2 <<EOF |
127 |
|
|
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 |
. ./.pd_tmp |
209 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
210 |
|
|
211 |
echo -n "PNAME = "${} |
echo -n "PNAME = "${} |
214 |
|
|
215 |
# Explain usage |
# Explain usage |
216 |
usage() { |
usage() { |
217 |
echo |
cat <<EOF |
218 |
echo "Usage: "$0" [OPTIONS]" |
|
219 |
echo " where [OPTIONS] can be:" |
Usage: "$0" [OPTIONS] |
220 |
echo |
where [OPTIONS] can be: |
221 |
echo " -help | --help | -h | --h" |
|
222 |
echo " -nooptfile | --nooptfile" |
-help | --help | -h | --h |
223 |
echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME" |
Print this help message and exit. |
224 |
echo " -optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME" |
|
225 |
echo " -pdepend NAME | --pdepend NAME" |
-nooptfile | --nooptfile |
226 |
echo " -pdepend=NAME | --pdepend=NAME" |
-optfile NAME | --optfile NAME | -of NAME | --of NAME |
227 |
echo " -pdefault NAME | --pdefault NAME" |
-optfile=NAME | --optfile=NAME | -of=NAME | --of=NAME |
228 |
echo " -pdefault=NAME | --pdefault=NAME" |
Use "NAME" as the optfile. By default, an attempt will be |
229 |
echo " -make NAME | -m NAME" |
made to find an appropriate "standard" optfile in the |
230 |
echo " --make=NAME | -m=NAME" |
tools/build_options/ directory. |
231 |
echo " -makefile NAME | -mf NAME" |
|
232 |
echo " --makefile=NAME | -mf=NAME" |
-pdepend NAME | --pdepend NAME |
233 |
echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" |
-pdepend=NAME | --pdepend=NAME |
234 |
echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" |
Get package dependency information from "NAME". |
235 |
echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" |
|
236 |
echo " -rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME" |
-pdefault NAME | --pdefault NAME |
237 |
echo " -mods NAME | --mods NAME | -mo NAME | --mo NAME" |
-pdefault=NAME | --pdefault=NAME |
238 |
echo " -mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME" |
Get the default package list from "NAME". |
239 |
echo " -disable NAME | --disable NAME" |
|
240 |
echo " -disable=NAME | --disable=NAME" |
-make NAME | -m NAME |
241 |
echo " -enable NAME | --enable NAME" |
--make=NAME | -m=NAME |
242 |
echo " -enable=NAME | --enable=NAME" |
Use "NAME" for the MAKE program. The default is "make" but |
243 |
echo " -standarddirs NAME | --standarddirs NAME" |
many platforms, "gmake" is the preferred choice. |
244 |
echo " -standarddirs=NAME | --standarddirs=NAME" |
|
245 |
echo " -noopt NAME | --noopt NAME" |
-makefile NAME | -mf NAME |
246 |
echo " -noopt=NAME | --noopt=NAME" |
--makefile=NAME | -mf=NAME |
247 |
# echo " -cpp NAME | --cpp NAME" |
Call the makefile "NAME". The default is "Makefile". |
248 |
# echo " -cpp=NAME | --cpp=NAME" |
|
249 |
echo " -fortran NAME | --fortran NAME | -fc NAME | --fc NAME" |
-rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME |
250 |
echo " -fc=NAME | --fc=NAME" |
-rootdir=NAME | --rootdir=NAME | -rd=NAME | --rd=NAME |
251 |
echo " -[no]ieee | --[no]ieee" |
Specify the location of the MITgcm ROOTDIR as "NAME". |
252 |
echo " -[no]mpi | --[no]mpi" |
By default, genamke will try to find the location by |
253 |
echo " -[no]jam | --[no]jam" |
looking in parent directories (up to the 5th parent). |
254 |
echo |
|
255 |
echo " and NAME is a string such as:" |
-mods NAME | --mods NAME | -mo NAME | --mo NAME |
256 |
echo |
-mods=NAME | --mods=NAME | -mo=NAME | --mo=NAME |
257 |
echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'" |
Here, "NAME" specifies a list of directories that are |
258 |
echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'" |
used for additional source code. Files found in the |
259 |
echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'" |
"mods list" are given preference over files of the same |
260 |
echo |
name found elsewhere. |
261 |
echo " which, depending upon your shell, may need to be single-quoted" |
|
262 |
echo " if it contains spaces, dashes, or other special characters." |
-disable NAME | --disable NAME |
263 |
|
-disable=NAME | --disable=NAME |
264 |
|
Here "NAME" specifies a list of packages that we don't |
265 |
|
want to use. If this violates package dependencies, |
266 |
|
genamke will exit with an error message. |
267 |
|
|
268 |
|
-enable NAME | --enable NAME |
269 |
|
-enable=NAME | --enable=NAME |
270 |
|
Here "NAME" specifies a list of packages that we wish |
271 |
|
to specifically enable. If this violates package |
272 |
|
dependencies, genamke will exit with an error message. |
273 |
|
|
274 |
|
-standarddirs NAME | --standarddirs NAME |
275 |
|
-standarddirs=NAME | --standarddirs=NAME |
276 |
|
Here, "NAME" specifies a list of directories to be |
277 |
|
used as the "standard" code. |
278 |
|
|
279 |
|
-fortran NAME | --fortran NAME | -fc NAME | --fc NAME |
280 |
|
-fc=NAME | --fc=NAME |
281 |
|
Use "NAME" as the fortran compiler. By default, genmake |
282 |
|
will search for a working compiler by trying a list of |
283 |
|
"usual suspects" such as g77, f77, etc. |
284 |
|
|
285 |
|
-[no]ieee | --[no]ieee |
286 |
|
Do or don't use IEEE numerics. Note that this option |
287 |
|
*only* works if it is supported by the OPTFILE that |
288 |
|
is being used. |
289 |
|
|
290 |
|
While it is most often a single word, the "NAME" variables specified |
291 |
|
above can in many cases be a space-delimited string such as: |
292 |
|
|
293 |
|
--enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3' |
294 |
|
-mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3' |
295 |
|
-foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32' |
296 |
|
|
297 |
|
which, depending upon your shell, may need to be single-quoted. |
298 |
|
|
299 |
|
For more detailed genmake documentation, please see: |
300 |
|
|
301 |
|
http://mitgcm.org/devel_HOWTO/ |
302 |
|
|
303 |
|
EOF |
304 |
|
|
305 |
exit 1 |
exit 1 |
306 |
} |
} |
307 |
|
|
308 |
#eh3 # This is the generic configuration. |
# Build a CPP macro to automate calling C routines from FORTRAN |
309 |
#eh3 set LN = ( 'ln -s' ) |
get_fortran_c_namemangling() { |
310 |
#eh3 set CPP = ( '/lib/cpp -P' ) |
default_nm="#define FC_NAMEMANGLE(X) X ## _" |
311 |
#eh3 set S64 = ( '$(TOOLSDIR)/set64bitConst.sh' ) |
|
312 |
#eh3 set KPP = ( ) |
cat > genmake_test.c <<EOF |
313 |
#eh3 set FC = ( 'f77' ) |
void tcall( char * string ) { tsub( string ); } |
314 |
#eh3 set LINK = $FC |
EOF |
315 |
#eh3 set MAKEDEPEND = ( 'makedepend' ) |
$MAKE genmake_test.o >> genmake_warnings 2>&1 |
316 |
#eh3 set INCLUDES = ( -I. ) |
RETVAL=$? |
317 |
#eh3 set FFLAGS = ( ) |
if test "x$RETVAL" != x0 ; then |
318 |
#eh3 set FOPTIM = ( ) |
FC_NAMEMANGLE=$default_nm |
319 |
#eh3 set CFLAGS = ( ) |
cat <<EOF>> genmake_errors |
320 |
#eh3 set KFLAGS1 = ( ) |
|
321 |
#eh3 set KFLAGS2 = ( ) |
WARNING: C test compile fails |
322 |
#eh3 set LIBS = ( ) |
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
323 |
#eh3 set KPPFILES = ( ) |
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
324 |
#eh3 if (! $?NOOPTFILES ) set NOOPTFILES = ( ) |
EOF |
325 |
#eh3 if (! $?NOOPTFLAGS ) set NOOPTFLAGS = ( ) |
return 1 |
326 |
|
fi |
327 |
|
c_tcall=`nm genmake_test.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` |
328 |
|
RETVAL=$? |
329 |
|
if test "x$RETVAL" != x0 ; then |
330 |
|
FC_NAMEMANGLE=$default_nm |
331 |
|
cat <<EOF>> genmake_warnings |
332 |
|
|
333 |
|
WARNING: The "nm" command failed. |
334 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
335 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here |
336 |
|
EOF |
337 |
|
return 1 |
338 |
|
fi |
339 |
|
cat > genmake_tcomp.f <<EOF |
340 |
|
subroutine tcall( string ) |
341 |
|
character*(*) string |
342 |
|
call tsub( string ) |
343 |
|
end |
344 |
|
EOF |
345 |
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f >> genmake_warnings 2>&1 |
346 |
|
RETVAL=$? |
347 |
|
if test "x$RETVAL" != x0 ; then |
348 |
|
FC_NAMEMANGLE=$default_nm |
349 |
|
cat <<EOF>> genmake_warnings |
350 |
|
|
351 |
|
WARNING: FORTRAN test compile fails -- please see "genmake_errors" |
352 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
353 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
354 |
|
EOF |
355 |
|
return 1 |
356 |
|
fi |
357 |
|
f_tcall=`nm genmake_tcomp.o | grep 'T ' | grep tcall | cut -d ' ' -f 3` |
358 |
|
RETVAL=$? |
359 |
|
if test "x$RETVAL" != x0 ; then |
360 |
|
FC_NAMEMANGLE=$default_nm |
361 |
|
cat <<EOF>> genmake_warnings |
362 |
|
|
363 |
|
WARNING: The "nm" command failed. |
364 |
|
WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE' |
365 |
|
WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here. |
366 |
|
EOF |
367 |
|
return 1 |
368 |
|
fi |
369 |
|
|
370 |
|
c_a=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
371 |
|
f_a=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 1 | sed -e 's|Y||'` |
372 |
|
c_b=`echo $c_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
373 |
|
f_b=`echo $f_tcall | sed -e 's|tcall|Y Y|' | cut -d ' ' -f 2 | sed -e 's|Y||'` |
374 |
|
|
375 |
|
nmangle="X" |
376 |
|
if test "x$c_a" != "x$f_a" ; then |
377 |
|
comm="echo x$f_a | sed -e 's|x$c_a||'" |
378 |
|
a=`eval $comm` |
379 |
|
nmangle="$a ## $nmangle" |
380 |
|
fi |
381 |
|
if test "x$c_b" != "x$f_b" ; then |
382 |
|
comm="echo x$f_b | sed -e 's|x$c_b||'" |
383 |
|
b=`eval $comm` |
384 |
|
nmangle="$nmangle ## $b" |
385 |
|
fi |
386 |
|
|
387 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle" |
388 |
|
|
389 |
|
# cleanup the testing files |
390 |
|
rm -f genmake_tcomp.* genmake_test.* |
391 |
|
} |
392 |
|
|
393 |
|
|
394 |
|
check_HAVE_CLOC() { |
395 |
|
get_fortran_c_namemangling |
396 |
|
cat <<EOF > genmake_tc_1.c |
397 |
|
$FC_NAMEMANGLE |
398 |
|
#include <stdio.h> |
399 |
|
#include <stdlib.h> |
400 |
|
#include <unistd.h> |
401 |
|
#include <assert.h> |
402 |
|
#include <sys/time.h> |
403 |
|
void FC_NAMEMANGLE(cloc) ( double *curtim ) |
404 |
|
{ |
405 |
|
struct timeval tv1; |
406 |
|
gettimeofday(&tv1 , (void *)NULL ); |
407 |
|
*curtim = (double)((tv1.tv_usec)+(tv1.tv_sec)*1.E6); |
408 |
|
*curtim = *curtim/1.E6; |
409 |
|
} |
410 |
|
EOF |
411 |
|
make genmake_tc_1.o >> genmake_tc.log 2>&1 |
412 |
|
RET_C=$? |
413 |
|
cat <<EOF > genmake_tc_2.f |
414 |
|
program hello |
415 |
|
Real*8 wtime |
416 |
|
external cloc |
417 |
|
call cloc(wtime) |
418 |
|
print *," HELLO WORLD", wtime |
419 |
|
end program hello |
420 |
|
EOF |
421 |
|
$FC $FFLAGS -o genmake_tc genmake_tc_2.f genmake_tc_1.o >> genmake_tc.log 2>&1 |
422 |
|
RET_F=$? |
423 |
|
test -x ./genmake_tc && ./genmake_tc >> genmake_tc.log 2>&1 |
424 |
|
RETVAL=$? |
425 |
|
if test "x$RETVAL" = x0 ; then |
426 |
|
HAVE_CLOC=t |
427 |
|
DEFINES="$DEFINES -DHAVE_CLOC" |
428 |
|
fi |
429 |
|
rm -f genmake_tc* |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
# Set defaults here |
# Set defaults here |
434 |
COMMANDL="$0 $@" |
COMMANDL="$0 $@" |
439 |
KPP= |
KPP= |
440 |
FC= |
FC= |
441 |
LINK= |
LINK= |
442 |
DEFINES="-DWORDLENGTH=4" |
# DEFINES="-DWORDLENGTH=4" |
443 |
|
DEFINES= |
444 |
PACKAGES= |
PACKAGES= |
445 |
ENABLE= |
ENABLE= |
446 |
DISABLE= |
DISABLE= |
461 |
NOOPTFILES= |
NOOPTFILES= |
462 |
NOOPTFLAGS= |
NOOPTFLAGS= |
463 |
|
|
464 |
|
# DEFINES checked by test compilation |
465 |
|
HAVE_SYSTEM= |
466 |
|
HAVE_FDATE= |
467 |
|
FC_NAMEMANGLE= |
468 |
|
HAVE_CLOC= |
469 |
|
|
470 |
MODS= |
MODS= |
471 |
TOOLSDIR= |
TOOLSDIR= |
472 |
SOURCEDIRS= |
SOURCEDIRS= |
504 |
|
|
505 |
|
|
506 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
507 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" |
508 |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
509 |
|
|
510 |
# The following state is not directly set by command-line switches |
# The following state is not directly set by command-line switches |
512 |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
513 |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
514 |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
515 |
|
gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE" |
516 |
|
|
517 |
# The following are all related to adjoint/tangent-linear stuff |
# The following are all related to adjoint/tangent-linear stuff |
518 |
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" |
519 |
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" |
520 |
gm_s9="TAF_EXTRA TAMC_EXTRA" |
gm_s12="TAF_EXTRA TAMC_EXTRA" |
521 |
|
|
522 |
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" |
523 |
|
gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12" |
524 |
|
|
525 |
|
cat <<EOF |
526 |
|
|
527 |
|
GENMAKE : |
528 |
|
|
529 |
|
A program for GENerating MAKEfiles for the MITgcm project. For a |
530 |
|
quick list of options, use "genmake -h" or for more detail see: |
531 |
|
|
532 |
|
http://mitgcm.org/devel_HOWTO/ |
533 |
|
|
534 |
|
EOF |
535 |
|
|
|
echo |
|
536 |
echo "=== Processing options files and arguments ===" |
echo "=== Processing options files and arguments ===" |
537 |
gm_local="genmake_local" |
gm_local="genmake_local" |
538 |
for i in . $MODS ; do |
for i in . $MODS ; do |
539 |
if test -r $i/$gm_local ; then |
if test -r $i/$gm_local ; then |
540 |
source $i/$gm_local |
. $i/$gm_local |
541 |
break |
break |
542 |
fi |
fi |
543 |
done |
done |
544 |
echo -n " getting local config information: " |
echo -n " getting local config information: " |
545 |
if test -e $gm_local ; then |
if test -e $gm_local ; then |
546 |
echo "using $gm_local" |
echo "using $gm_local" |
547 |
source $gm_local |
. $gm_local |
548 |
# echo "DISABLE=$DISABLE" |
# echo "DISABLE=$DISABLE" |
549 |
# echo "ENABLE=$ENABLE" |
# echo "ENABLE=$ENABLE" |
550 |
else |
else |
586 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
587 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
588 |
|
|
589 |
-adoptfile | --adoptfile | -ad | --ad) |
-adoptfile | --adoptfile | -adof | --adof) |
590 |
ac_prev=AD_OPTFILE ;; |
ac_prev=AD_OPTFILE ;; |
591 |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
592 |
AD_OPTFILE=$ac_optarg ;; |
AD_OPTFILE=$ac_optarg ;; |
611 |
-makefile=* | --makefile=* | -ma=* | --ma=*) |
-makefile=* | --makefile=* | -ma=* | --ma=*) |
612 |
MAKEFILE=$ac_optarg ;; |
MAKEFILE=$ac_optarg ;; |
613 |
|
|
614 |
-platform | --platform | -pl | --pl) |
-platform | --platform | -pl | --pl | -platform=* | --platform=* | -pl=* | --pl=*) |
615 |
ac_prev=PLATFORM ;; |
echo "ERROR: The platform option has been removed. Please specify" |
616 |
-platform=* | --platform=* | -pl=* | --pl=*) |
echo " the build options using the \"optfile\" mechanism." |
617 |
PLATFORM=$ac_optarg ;; |
echo |
618 |
|
usage |
619 |
|
;; |
620 |
|
|
621 |
-rootdir | --rootdir | -rd | --rd) |
-rootdir | --rootdir | -rd | --rd) |
622 |
ac_prev=ROOTDIR ;; |
ac_prev=ROOTDIR ;; |
643 |
-standarddirs=* | --standarddirs=*) |
-standarddirs=* | --standarddirs=*) |
644 |
STANDARDDIRS=$ac_optarg ;; |
STANDARDDIRS=$ac_optarg ;; |
645 |
|
|
|
-noopt | --noopt) |
|
|
ac_prev=NOOPT ;; |
|
|
-noopt=* | --noopt=*) |
|
|
NOOPT=$ac_optarg ;; |
|
|
|
|
646 |
# -cpp | --cpp) |
# -cpp | --cpp) |
647 |
# ac_prev=cpp ;; |
# ac_prev=cpp ;; |
648 |
# -cpp=* | --cpp=*) |
# -cpp=* | --cpp=*) |
658 |
-noieee | --noieee) |
-noieee | --noieee) |
659 |
IEEE= ;; |
IEEE= ;; |
660 |
|
|
661 |
-mpi | --mpi) |
# -jam | --jam) |
662 |
MPI=true ;; |
# JAM=1 ;; |
663 |
-nompi | --nompi) |
# -nojam | --nojam) |
664 |
MPI= ;; |
# JAM=0 ;; |
|
|
|
|
-jam | --jam) |
|
|
JAM=1 ;; |
|
|
-nojam | --nojam) |
|
|
JAM=0 ;; |
|
665 |
|
|
666 |
-ds | --ds) |
-ds | --ds) |
667 |
DUMPSTATE=t ;; |
DUMPSTATE=t ;; |
740 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
741 |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
if test -f "$OPTFILE" -a -r "$OPTFILE" ; then |
742 |
echo " using OPTFILE=\"$OPTFILE\"" |
echo " using OPTFILE=\"$OPTFILE\"" |
743 |
source "$OPTFILE" |
. "$OPTFILE" |
744 |
RETVAL=$? |
RETVAL=$? |
745 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
746 |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" |
767 |
if test "x${AD_OPTFILE}" != xNONE ; then |
if test "x${AD_OPTFILE}" != xNONE ; then |
768 |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
769 |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
770 |
source "$AD_OPTFILE" |
. "$AD_OPTFILE" |
771 |
RETVAL=$? |
RETVAL=$? |
772 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
773 |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
783 |
fi |
fi |
784 |
fi |
fi |
785 |
|
|
786 |
# 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, |
787 |
# and abort! |
# either set defaults or complain and abort! |
788 |
if test "x$FC" = x ; then |
if test "x$FC" = x ; then |
789 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |
790 |
|
|
801 |
if test "x$CPP" = x ; then |
if test "x$CPP" = x ; then |
802 |
CPP="cpp" |
CPP="cpp" |
803 |
fi |
fi |
804 |
|
if test "x$MAKE" = x ; then |
805 |
|
MAKE="make" |
806 |
|
fi |
807 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
808 |
RETVAL=$? |
RETVAL=$? |
809 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
813 |
|
|
814 |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
1) within the options file ("CPP=...") as specified by "-of=OPTFILE" |
815 |
2) the "./genmake_local" file |
2) the "./genmake_local" file |
816 |
|
3) with the CPP environment variable |
817 |
|
|
818 |
EOF |
EOF |
819 |
exit 1 |
exit 1 |
823 |
if test "x$MAKEDEPEND" = x ; then |
if test "x$MAKEDEPEND" = x ; then |
824 |
MAKEDEPEND=makedepend |
MAKEDEPEND=makedepend |
825 |
fi |
fi |
826 |
|
if test "x$LN" = x ; then |
827 |
|
LN="ln -s" |
828 |
|
fi |
829 |
|
echo "test" > genmake_test_ln |
830 |
|
$LN genmake_test_ln genmake_tlink |
831 |
|
RETVAL=$? |
832 |
|
if test "x$RETVAL" != x0 ; then |
833 |
|
cat <<EOF 1>&2 |
834 |
|
|
835 |
|
Error: The command "ln -s" failed -- please specify a working soft-link |
836 |
|
command in the optfile. |
837 |
|
|
838 |
|
EOF |
839 |
|
exit 1 |
840 |
|
fi |
841 |
|
rm -f genmake_test_ln genmake_tlink |
842 |
|
|
843 |
|
|
844 |
|
printf "\n=== Checking system libraries ===\n" |
845 |
|
echo -n " Do we have the system() command using $FC... " |
846 |
|
cat > genmake_tcomp.f <<EOF |
847 |
|
program hello |
848 |
|
call system('echo hi') |
849 |
|
end |
850 |
|
EOF |
851 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
852 |
|
RETVAL=$? |
853 |
|
if test "x$RETVAL" = x0 ; then |
854 |
|
HAVE_SYSTEM=t |
855 |
|
DEFINES="$DEFINES -DHAVE_SYSTEM" |
856 |
|
echo "yes" |
857 |
|
else |
858 |
|
HAVE_SYSTEM= |
859 |
|
echo "no" |
860 |
|
fi |
861 |
|
rm -f genmake_tcomp* |
862 |
|
|
863 |
|
echo -n " Do we have the fdate() command using $FC... " |
864 |
|
cat > genmake_tcomp.f <<EOF |
865 |
|
program hello |
866 |
|
CHARACTER(128) string |
867 |
|
string = ' ' |
868 |
|
call fdate( string ) |
869 |
|
print *, string |
870 |
|
end |
871 |
|
EOF |
872 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
873 |
|
RETVAL=$? |
874 |
|
if test "x$RETVAL" = x0 ; then |
875 |
|
HAVE_FDATE=t |
876 |
|
DEFINES="$DEFINES -DHAVE_FDATE" |
877 |
|
echo "yes" |
878 |
|
else |
879 |
|
HAVE_FDATE= |
880 |
|
echo "no" |
881 |
|
fi |
882 |
|
rm -f genmake_tcomp* |
883 |
|
|
884 |
|
echo -n " Can we call simple C routines (here, \"cloc()\") using $FC... " |
885 |
|
check_HAVE_CLOC |
886 |
|
if test "x$HAVE_CLOC" != x ; then |
887 |
|
echo "yes" |
888 |
|
else |
889 |
|
echo "no" |
890 |
|
fi |
891 |
|
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
892 |
|
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
893 |
|
RETVAL=$? |
894 |
|
if test "x$RETVAL" != x0 ; then |
895 |
|
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
896 |
|
fi |
897 |
|
rm -f genmake_t* |
898 |
|
|
899 |
|
|
900 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
901 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
941 |
if test "x$S64" = x ; then |
if test "x$S64" = x ; then |
942 |
S64='$(TOOLSDIR)/set64bitConst.sh' |
S64='$(TOOLSDIR)/set64bitConst.sh' |
943 |
fi |
fi |
944 |
|
THIS_SCRIPT=`echo ${0} | sed 's:'$TOOLSDIR':\$(TOOLSDIR):'` |
945 |
|
|
946 |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
EXECUTABLE=${EXECUTABLE:-mitgcmuv} |
947 |
|
|
950 |
# they appear as regular source code |
# they appear as regular source code |
951 |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
if test -r $ROOTDIR"/eesupp/src/Makefile" ; then |
952 |
echo " Making source files in eesupp from templates" |
echo " Making source files in eesupp from templates" |
953 |
$MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 |
( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1 |
954 |
RETVAL=$? |
RETVAL=$? |
955 |
if test "x${RETVAL}" = x0 ; then |
if test "x${RETVAL}" = x0 ; then |
956 |
rm -f make_eesupp.errors |
rm -f make_eesupp.errors |
987 |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" |
988 |
exit 1 |
exit 1 |
989 |
fi |
fi |
990 |
source ./.pd_tmp |
. ./.pd_tmp |
991 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
992 |
|
|
993 |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" |
994 |
# file should eventually be added so that, for convenience, one can |
# file should eventually be added so that, for convenience, one can |
995 |
# specify groups of packages using names like "ocean" and "atmosphere". |
# specify groups of packages using names like "ocean" and "atmosphere". |
996 |
echo -n " checking default package list: " |
echo " checking default package list: " |
997 |
if test "x${PDEFAULT}" = x ; then |
if test "x${PDEFAULT}" = x ; then |
998 |
for i in "." $MODS ; do |
for i in "." $MODS ; do |
999 |
if test -r $i"/packages.conf" ; then |
if test -r $i"/packages.conf" ; then |
1006 |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
PDEFAULT="$ROOTDIR/pkg/pkg_default" |
1007 |
fi |
fi |
1008 |
if test "x${PDEFAULT}" = xNONE ; then |
if test "x${PDEFAULT}" = xNONE ; then |
1009 |
echo "default packages file disabled" |
echo " default packages file disabled" |
1010 |
else |
else |
1011 |
if test ! -r $PDEFAULT ; then |
if test ! -r $PDEFAULT ; then |
|
echo "" |
|
1012 |
echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\"" |
echo "Warning: can't read default packages from PDEFAULT=\"$PDEFAULT\"" |
1013 |
else |
else |
1014 |
echo " using PDEFAULT=\"$PDEFAULT\"" |
echo " using PDEFAULT=\"$PDEFAULT\"" |
1015 |
# Strip the comments and add all the names |
# Strip the comments and add all the names |
1016 |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
1017 |
RETVAL=$? |
RETVAL=$? |
1144 |
fi |
fi |
1145 |
done |
done |
1146 |
|
|
|
# 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 |
|
1147 |
|
|
1148 |
# Create a list of #define and #undef to enable/disable packages |
# Create a list of #define and #undef to enable/disable packages |
1149 |
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 |
|
1150 |
# 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 |
1151 |
# 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 |
1152 |
# file would eventually be split up so that all package-related #define |
# file would eventually be split up so that all package-related #define |
1153 |
# statements could be separated and handled only by genmake. |
# statements could be separated and handled only by genmake. |
1154 |
names=`ls -1 "$ROOTDIR/pkg"` |
names=`ls -1 "$ROOTDIR/pkg"` |
1155 |
all_pack= |
all_pack= |
1156 |
|
DISABLED_PACKAGES= |
1157 |
for n in $names ; do |
for n in $names ; do |
1158 |
if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then |
if test -d "$ROOTDIR/pkg/$n" -a "x$n" != xCVS ; then |
1159 |
has_pack="f" |
has_pack="f" |
1165 |
done |
done |
1166 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
1167 |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
1168 |
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!!! |
|
|
|
|
1169 |
fi |
fi |
1170 |
fi |
fi |
1171 |
done |
done |
1172 |
cat <<EOF >>$PACKAGES_DOT_H".tmp" |
ENABLED_PACKAGES= |
|
|
|
|
C Packages enabled by genmake: |
|
|
EOF |
|
1173 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
1174 |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
1175 |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
ENABLED_PACKAGES="$ENABLED_PACKAGES -D$def" |
1176 |
#eh3 DEFINES="$DEFINES -D$def" |
#eh3 DEFINES="$DEFINES -D$def" |
1177 |
|
|
1178 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1179 |
case $i in |
case $i in |
1180 |
aim_v23) |
aim_v23) |
|
echo "#define ALLOW_AIM" >> $PACKAGES_DOT_H".tmp" |
|
1181 |
DEFINES="$DEFINES -DALLOW_AIM" |
DEFINES="$DEFINES -DALLOW_AIM" |
1182 |
|
ENABLED_PACKAGES="$ENABLED_PACKAGES -DALLOW_AIM" |
1183 |
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 :-)" |
1184 |
;; |
;; |
1185 |
esac |
esac |
1186 |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
#EH3 WARNING : This is an UGLY HACK that needs to be removed!!! |
1187 |
|
|
1188 |
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 |
|
1189 |
|
|
1190 |
echo " Adding STANDARDDIRS" |
echo " Adding STANDARDDIRS" |
1191 |
BUILDDIR=${BUILDDIR:-.} |
BUILDDIR=${BUILDDIR:-.} |
1211 |
fi |
fi |
1212 |
done |
done |
1213 |
|
|
1214 |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
echo " Searching for CPP_OPTIONS.h in order to warn about the presence" |
1215 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1216 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1217 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1218 |
for i in $spaths ; do |
for i in $spaths ; do |
1248 |
done |
done |
1249 |
done |
done |
1250 |
|
|
|
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 |
|
|
|
|
1251 |
echo |
echo |
1252 |
echo "=== Creating the Makefile ===" |
echo "=== Creating the Makefile ===" |
1253 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
1277 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
1278 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
1279 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1280 |
|
case $d/$sf in |
1281 |
|
./$PACKAGES_DOT_H) |
1282 |
|
;; |
1283 |
|
./AD_CONFIG.h) |
1284 |
|
;; |
1285 |
|
./FC_NAMEMANGLE.h) |
1286 |
|
;; |
1287 |
|
*) |
1288 |
|
touch .links.tmp/$sf |
1289 |
|
deplist="$deplist $sf" |
1290 |
|
;; |
1291 |
|
esac |
1292 |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
|
touch .links.tmp/$sf |
|
|
deplist="$deplist $sf" |
|
1293 |
case $extn in |
case $extn in |
1294 |
F) |
F) |
1295 |
echo " \\" >> srclist.inc |
echo " \\" >> srclist.inc |
1341 |
echo "# $0 $@" >> $MAKEFILE |
echo "# $0 $@" >> $MAKEFILE |
1342 |
echo "# executed by:" >> $MAKEFILE |
echo "# executed by:" >> $MAKEFILE |
1343 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
1344 |
|
|
1345 |
|
EXE_AD=$EXECUTABLE"_ad" |
1346 |
|
EXE_FTL=$EXECUTABLE"_ftl" |
1347 |
|
EXE_SVD=$EXECUTABLE"_svd" |
1348 |
|
|
1349 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1350 |
# |
# |
1351 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1376 |
|
|
1377 |
#eh3 new defines for the adjoint work |
#eh3 new defines for the adjoint work |
1378 |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1379 |
|
EXE_AD = ${EXE_AD} |
1380 |
|
EXE_FTL = ${EXE_FTL} |
1381 |
|
EXE_SVD = ${EXE_SVD} |
1382 |
|
|
1383 |
|
ENABLED_PACKAGES = ${ENABLED_PACKAGES} |
1384 |
|
DISABLED_PACKAGES = ${DISABLED_PACKAGES} |
1385 |
|
|
1386 |
EOF |
EOF |
1387 |
|
|
1447 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
1448 |
|
|
1449 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1450 |
\$(EXECUTABLE): \$(OBJFILES) |
\$(EXECUTABLE): ${PACKAGES_DOT_H} AD_CONFIG.h \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) |
1451 |
|
@echo Creating \$@ ... |
1452 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
1453 |
depend: |
depend: |
1454 |
@make links |
@make links |
1455 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1456 |
${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
1457 |
|
|
1458 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) ${PACKAGES_DOT_H} AD_CONFIG.h |
1459 |
|
|
1460 |
small_f: \$(F77FILES) \$(F90FILES) |
small_f: \$(F77FILES) \$(F90FILES) |
1461 |
|
|
1464 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1465 |
|
|
1466 |
clean: |
clean: |
1467 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template |
1468 |
Clean: |
Clean: |
1469 |
@make clean |
@make clean |
1470 |
@make cleanlinks |
@make cleanlinks |
1471 |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
-rm -f ${PACKAGES_DOT_H} AD_CONFIG.h |
1472 |
|
-rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak |
1473 |
CLEAN: |
CLEAN: |
1474 |
@make Clean |
@make Clean |
1475 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1477 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1478 |
-rm -f \$(EXECUTABLE) output.txt |
-rm -f \$(EXECUTABLE) output.txt |
1479 |
|
|
1480 |
Makefile: makefile |
#eh3 Makefile: makefile |
1481 |
makefile: |
makefile: |
1482 |
${0} $@ |
$THIS_SCRIPT $@ |
1483 |
cleanlinks: |
cleanlinks: |
1484 |
-find . -type l -exec rm {} \; |
-find . -type l -exec rm {} \; |
1485 |
|
|
1486 |
|
# Special targets |
1487 |
|
${PACKAGES_DOT_H}: |
1488 |
|
@echo Creating \$@ ... |
1489 |
|
@\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
1490 |
|
AD_CONFIG.h: |
1491 |
|
@echo Creating \$@ ... |
1492 |
|
@\$(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 > \$@ |
1493 |
|
|
1494 |
# The normal chain of rules is ( .F - .f - .o ) |
# The normal chain of rules is ( .F - .f - .o ) |
1495 |
.F.f: |
.F.f: |
1496 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1540 |
echo -n " $i" >> $MAKEFILE |
echo -n " $i" >> $MAKEFILE |
1541 |
done |
done |
1542 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
1543 |
|
rm -f ad_files |
1544 |
|
|
1545 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1546 |
|
|
1547 |
ad_input_code.f: \$(F77FILES) |
# ... AD ... |
1548 |
|
adall: ad_taf |
1549 |
|
adtaf: ad_taf_output.f |
1550 |
|
adtamc: ad_tamc_output.f |
1551 |
|
|
1552 |
|
ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1553 |
|
@\$(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 |
1554 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
1555 |
|
-rm -f ad_config.template |
1556 |
|
@make \$(F77FILES) |
1557 |
@make \$(AD_FLOW_FILES) |
@make \$(AD_FLOW_FILES) |
1558 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1559 |
|
|
|
# ... AD ... |
|
1560 |
ad_taf_output.f: ad_input_code.f |
ad_taf_output.f: ad_input_code.f |
1561 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1562 |
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 |
1563 |
|
|
1564 |
|
adtafonly: |
1565 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1566 |
|
cat ad_input_code_ad.f | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.f |
1567 |
|
|
1568 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
ad_taf: ad_taf_output.o \$(OBJFILES) |
1569 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1570 |
|
|
1571 |
ad_tamc_output.f: ad_input_code.f |
ad_tamc_output.f: ad_input_code.f |
1572 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1573 |
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 |
1574 |
|
|
1575 |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1576 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1577 |
|
|
1578 |
|
|
1579 |
|
# ... FTL ... |
1580 |
|
ftlall: ftl_taf |
1581 |
|
ftltaf: ftl_taf_output.f |
1582 |
|
ftltamc: ftl_tamc_output.f |
1583 |
|
|
1584 |
|
ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1585 |
|
@\$(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 |
1586 |
|
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
1587 |
|
-rm -f ftl_config.template |
1588 |
|
@make \$(F77FILES) |
1589 |
|
@make \$(AD_FLOW_FILES) |
1590 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1591 |
|
|
1592 |
|
ftl_taf_output.f: ftl_input_code.f |
1593 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1594 |
|
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f |
1595 |
|
|
1596 |
# ... FLT ... |
ftltafonly: |
1597 |
flt_taf_output.f: ad_input_code.f |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1598 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.f |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_taf_output.f |
|
1599 |
|
|
1600 |
flt_taf: flt_taf_output.o \$(OBJFILES) |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1601 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_taf_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1602 |
|
|
1603 |
flt_tamc_output.f: ad_input_code.f |
ftl_tamc_output.f: ftl_input_code.f |
1604 |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1605 |
cat ad_input_code_ad.f | sed -f adjoint_sed > flt_tamc_output.f |
cat ftl_input_code_ftl.f | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_tamc_output.f |
1606 |
|
|
1607 |
flt_tamc: flt_tamc_output.o \$(OBJFILES) |
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1608 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) flt_tamc_output.o \$(LIBS) |
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1609 |
|
|
1610 |
|
|
1611 |
# ... SVD ... |
# ... SVD ... |
1612 |
svd_taf_output.f: ad_input_code.f |
svdtaf: ad_taf_output.f ftl_taf_output.f |
1613 |
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
svdall: svd_taf |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
|
1614 |
|
|
1615 |
svd_taf: svd_taf_output.o \$(OBJFILES) |
svd_taf: ad_taf_output.o ftl_taf_output.o \$(OBJFILES) |
1616 |
\$(LINK) -o ${EXECUTABLE} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
\$(LINK) -o mitgcmuv_svd \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o ftl_taf_output.o \$(LIBS) |
1617 |
|
|
1618 |
|
|
1619 |
#========================================= |
#========================================= |
1654 |
|
|
1655 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1656 |
|
|
1657 |
|
# Create special header files |
1658 |
|
$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" |
1659 |
|
if test ! -f $PACKAGES_DOT_H ; then |
1660 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1661 |
|
else |
1662 |
|
cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1663 |
|
RETVAL=$? |
1664 |
|
if test "x$RETVAL" = x0 ; then |
1665 |
|
rm -f $PACKAGES_DOT_H".tmp" |
1666 |
|
else |
1667 |
|
mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" |
1668 |
|
mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H |
1669 |
|
fi |
1670 |
|
fi |
1671 |
|
if test ! -f AD_CONFIG.h ; then |
1672 |
|
$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 |
1673 |
|
fi |
1674 |
|
|
1675 |
|
|
1676 |
# Write the "state" for future records |
# Write the "state" for future records |
1677 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |