46 |
PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" |
PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" |
47 |
if test -r $PKG_GROUPS ; then |
if test -r $PKG_GROUPS ; then |
48 |
cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp |
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 |
cat ./p1.tmp | $AWK '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp |
50 |
matched=0 |
matched=0 |
51 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
52 |
line=`grep "^ *$i" ./p2.tmp` |
line=`grep "^ *$i" ./p2.tmp` |
53 |
RETVAL=$? |
RETVAL=$? |
54 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
55 |
matched=1 |
matched=1 |
56 |
replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'` |
replace=`echo $line | $AWK '{ $1=""; $2=""; print $0 }'` |
57 |
echo " replacing \"$i\" with: $replace" |
echo " replacing \"$i\" with: $replace" |
58 |
new_packages="$new_packages $replace" |
new_packages="$new_packages $replace" |
59 |
else |
else |
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" |
79 |
# if test "x$OFLIST" = x ; then |
# if test "x$OFLIST" = x ; then |
105 |
fi |
fi |
106 |
|
|
107 |
# look for possible fortran compilers |
# look for possible fortran compilers |
108 |
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" |
109 |
p_FC= |
p_FC= |
110 |
for c in $tmp ; do |
for c in $tmp ; do |
111 |
rm -f ./hello.f ./hello |
rm -f ./hello.f ./hello |
122 |
p_FC="$p_FC $c" |
p_FC="$p_FC $c" |
123 |
fi |
fi |
124 |
done |
done |
125 |
|
rm -f ./hello.f ./hello |
126 |
if test "x${p_FC}" = x ; then |
if test "x${p_FC}" = x ; then |
127 |
cat 1>&2 <<EOF |
cat 1>&2 <<EOF |
128 |
|
|
138 |
echo " The possible FORTRAN compilers found in your path are:" |
echo " The possible FORTRAN compilers found in your path are:" |
139 |
echo " "$p_FC |
echo " "$p_FC |
140 |
if test "x$FC" = x ; then |
if test "x$FC" = x ; then |
141 |
FC=`echo $p_FC | awk '{print $1}'` |
FC=`echo $p_FC | $AWK '{print $1}'` |
142 |
fi |
fi |
143 |
fi |
fi |
144 |
|
|
204 |
# strip the comments and then convert the dependency file into |
# strip the comments and then convert the dependency file into |
205 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
206 |
cat $1 | sed -e 's/#.*$//g' \ |
cat $1 | sed -e 's/#.*$//g' \ |
207 |
| 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} }' \ |
208 |
> ./.pd_tmp |
> ./.pd_tmp |
209 |
source ./.pd_tmp |
source ./.pd_tmp |
210 |
rm -f ./.pd_tmp |
rm -f ./.pd_tmp |
313 |
NOOPTFILES= |
NOOPTFILES= |
314 |
NOOPTFLAGS= |
NOOPTFLAGS= |
315 |
|
|
316 |
|
# DEFINES checked by test compilation |
317 |
|
HAVE_SYSTEM= |
318 |
|
HAVE_FDATE= |
319 |
|
FC_NAMEMANGLE= |
320 |
|
|
321 |
MODS= |
MODS= |
322 |
TOOLSDIR= |
TOOLSDIR= |
323 |
SOURCEDIRS= |
SOURCEDIRS= |
326 |
|
|
327 |
PWD=`pwd` |
PWD=`pwd` |
328 |
MAKE=make |
MAKE=make |
329 |
|
AWK=awk |
330 |
THISHOSTNAME=`hostname` |
THISHOSTNAME=`hostname` |
331 |
THISCWD=`pwd` |
THISCWD=`pwd` |
332 |
THISDATE=`date` |
THISDATE=`date` |
340 |
IEEE=$MITGCM_IEEE |
IEEE=$MITGCM_IEEE |
341 |
fi |
fi |
342 |
|
|
343 |
|
AUTODIFF_PKG_USED=f |
344 |
|
AD_OPTFILE= |
345 |
|
TAF= |
346 |
|
AD_TAF_FLAGS= |
347 |
|
FTL_TAF_FLAGS= |
348 |
|
SVD_TAF_FLAGS= |
349 |
|
TAF_EXTRA= |
350 |
|
TAMC= |
351 |
|
AD_TAMC_FLAGS= |
352 |
|
FTL_TAF_FLAGS= |
353 |
|
SVD_TAMC_FLAGS= |
354 |
|
TAMC_EXTRA= |
355 |
|
|
356 |
|
|
357 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
358 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" |
359 |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
gm_s2="FC IEEE MPI JAM DUMPSTATE STANDARDDIRS" |
363 |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
364 |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" |
365 |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
366 |
|
gm_s7="HAVE_SYSTEM HAVE_FDATE FC_NAMEMANGLE" |
367 |
|
|
368 |
|
# The following are all related to adjoint/tangent-linear stuff |
369 |
|
gm_s10="AUTODIFF_PKG_USED AD_OPTFILE TAMC TAF AD_TAMC_FLAGS AD_TAF_FLAGS" |
370 |
|
gm_s11="FTL_TAMC_FLAGS FTL_TAF_FLAGS SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
371 |
|
gm_s12="TAF_EXTRA TAMC_EXTRA" |
372 |
|
|
373 |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6" |
gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6 $gm_s7" |
374 |
|
gm_state="$gm_state $gm_s10 $gm_s11 $gm_s12" |
375 |
|
|
376 |
|
|
377 |
echo |
echo |
404 |
# n=$(( $n + 1 )) |
# n=$(( $n + 1 )) |
405 |
#done |
#done |
406 |
#parse_options |
#parse_options |
|
|
|
407 |
ac_prev= |
ac_prev= |
408 |
for ac_option ; do |
for ac_option ; do |
409 |
|
|
428 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
429 |
OPTFILE=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
430 |
|
|
431 |
|
-adoptfile | --adoptfile | -ad | --ad) |
432 |
|
ac_prev=AD_OPTFILE ;; |
433 |
|
-adoptfile=* | --adoptfile=* | -adof=* | --adof=*) |
434 |
|
AD_OPTFILE=$ac_optarg ;; |
435 |
|
|
436 |
-pdepend | --pdepend) |
-pdepend | --pdepend) |
437 |
ac_prev=PDEPEND ;; |
ac_prev=PDEPEND ;; |
438 |
-pdepend=* | --pdepend=*) |
-pdepend=* | --pdepend=*) |
516 |
-ds | --ds) |
-ds | --ds) |
517 |
DUMPSTATE=t ;; |
DUMPSTATE=t ;; |
518 |
|
|
519 |
|
-taf_extra | --taf_extra) |
520 |
|
ac_prev=TAF_EXTRA ;; |
521 |
|
-taf_extra=* | --taf_extra=*) |
522 |
|
TAF_EXTRA=$ac_optarg ;; |
523 |
|
|
524 |
|
-tamc_extra | --tamc_extra) |
525 |
|
ac_prev=TAMC_EXTRA ;; |
526 |
|
-tamc_extra=* | --tamc_extra=*) |
527 |
|
TAMC_EXTRA=$ac_optarg ;; |
528 |
|
|
529 |
-*) |
-*) |
530 |
echo "Error: unrecognized option: "$ac_option |
echo "Error: unrecognized option: "$ac_option |
531 |
usage |
usage |
606 |
fi |
fi |
607 |
fi |
fi |
608 |
|
|
609 |
|
echo " getting AD_OPTFILE information: " |
610 |
|
if test "x${AD_OPTFILE}" = x ; then |
611 |
|
if test "x$MITGCM_AD_OF" = x ; then |
612 |
|
AD_OPTFILE=$ROOTDIR/tools/adjoint_options/adjoint_default |
613 |
|
else |
614 |
|
AD_OPTFILE=$MITGCM_AD_OF |
615 |
|
fi |
616 |
|
fi |
617 |
|
if test "x${AD_OPTFILE}" != xNONE ; then |
618 |
|
if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then |
619 |
|
echo " using AD_OPTFILE=\"$AD_OPTFILE\"" |
620 |
|
source "$AD_OPTFILE" |
621 |
|
RETVAL=$? |
622 |
|
if test "x$RETVAL" != x0 ; then |
623 |
|
echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" |
624 |
|
echo "--please check that variable syntax is bash-compatible" |
625 |
|
exit 1 |
626 |
|
fi |
627 |
|
if test "x$DUMPSTATE" != xf ; then |
628 |
|
cp -f $AD_OPTFILE "genmake_ad_optfile" |
629 |
|
fi |
630 |
|
else |
631 |
|
echo "Error: can't read AD_OPTFILE=\"$AD_OPTFILE\"" |
632 |
|
exit 1 |
633 |
|
fi |
634 |
|
fi |
635 |
|
|
636 |
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
# Check that FC, LINK, CPP, and S64 are defined. If not, complain |
637 |
# and abort! |
# and abort! |
638 |
if test "x$FC" = x ; then |
if test "x$FC" = x ; then |
651 |
if test "x$CPP" = x ; then |
if test "x$CPP" = x ; then |
652 |
CPP="cpp" |
CPP="cpp" |
653 |
fi |
fi |
654 |
echo "#define A a" | cpp > test_cpp 2>&1 |
echo "#define A a" | $CPP > test_cpp 2>&1 |
655 |
RETVAL=$? |
RETVAL=$? |
656 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
657 |
cat <<EOF 1>&2 |
cat <<EOF 1>&2 |
670 |
MAKEDEPEND=makedepend |
MAKEDEPEND=makedepend |
671 |
fi |
fi |
672 |
|
|
673 |
|
|
674 |
|
printf "\n=== Checking system libraries ===\n" |
675 |
|
echo -n " Do we have the system() command using $FC... " |
676 |
|
cat > genmake_tcomp.f <<EOF |
677 |
|
program hello |
678 |
|
call system('echo hi') |
679 |
|
end |
680 |
|
EOF |
681 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
682 |
|
RETVAL=$? |
683 |
|
if test "x$RETVAL" = x0 ; then |
684 |
|
HAVE_SYSTEM=t |
685 |
|
DEFINES="$DEFINES -DHAVE_SYSTEM" |
686 |
|
echo "yes" |
687 |
|
else |
688 |
|
HAVE_SYSTEM= |
689 |
|
echo "no" |
690 |
|
fi |
691 |
|
rm -f genmake_tcomp* |
692 |
|
|
693 |
|
echo -n " Do we have the fdate() command using $FC... " |
694 |
|
cat > genmake_tcomp.f <<EOF |
695 |
|
program hello |
696 |
|
CHARACTER(128) string |
697 |
|
string = ' ' |
698 |
|
call fdate( string ) |
699 |
|
print *, string |
700 |
|
end |
701 |
|
EOF |
702 |
|
$FC $FFLAGS $DEFINES -o genmake_tcomp genmake_tcomp.f > genmake_tcomp.log 2>&1 |
703 |
|
RETVAL=$? |
704 |
|
if test "x$RETVAL" = x0 ; then |
705 |
|
HAVE_FDATE=t |
706 |
|
DEFINES="$DEFINES -DHAVE_FDATE" |
707 |
|
echo "yes" |
708 |
|
else |
709 |
|
HAVE_FDATE= |
710 |
|
echo "no" |
711 |
|
fi |
712 |
|
rm -f genmake_tcomp* |
713 |
|
|
714 |
|
echo -n " The name mangling convention for $FC is... " |
715 |
|
if test "x$FC_NAMEMANGLE" = x ; then |
716 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) X ## _" |
717 |
|
fi |
718 |
|
cat > genmake_tcomp.f <<EOF |
719 |
|
subroutine tcall( string ) |
720 |
|
character*(*) string |
721 |
|
call tsub( string ) |
722 |
|
end |
723 |
|
EOF |
724 |
|
$FC $FFLAGS $DEFINES -c genmake_tcomp.f > genmake_tcomp.log 2>&1 |
725 |
|
RETVAL=$? |
726 |
|
if test "x$RETVAL" != x0 ; then |
727 |
|
cat genmake_tcomp.log >> genmake_errors |
728 |
|
echo |
729 |
|
echo "WARNING: test compile fails -- please see \"genmake_errors\"" |
730 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
731 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
732 |
|
else |
733 |
|
tcall=`nm genmake_tcomp.o | grep tcall | cut -d ' ' -f 3` |
734 |
|
RETVAL=$? |
735 |
|
if test "x$RETVAL" != x0 ; then |
736 |
|
echo |
737 |
|
echo "WARNING: The \"nm\" command failed." |
738 |
|
echo "WARNING: We'll try to use: FC_NAMEMANGLE='$FC_NAMEMANGLE'" |
739 |
|
echo "WARNING: Please contact <MITgcm-support@mitgcm.org> if you need help here." |
740 |
|
else |
741 |
|
t0=`echo $tcall | sed -e 's|_tcall|_ ## X|g'` |
742 |
|
nmres=`echo $t0 | sed -e 's|tcall_|X ## _|g'` |
743 |
|
FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmres" |
744 |
|
echo "'$FC_NAMEMANGLE'" |
745 |
|
fi |
746 |
|
fi |
747 |
|
echo "$FC_NAMEMANGLE" > FC_NAMEMANGLE.h.template |
748 |
|
cmp FC_NAMEMANGLE.h FC_NAMEMANGLE.h.template > /dev/null 2>&1 |
749 |
|
RETVAL=$? |
750 |
|
if test "x$RETVAL" != x0 ; then |
751 |
|
mv -f FC_NAMEMANGLE.h.template FC_NAMEMANGLE.h |
752 |
|
fi |
753 |
|
rm -f genmake_tcomp* |
754 |
|
|
755 |
|
|
756 |
printf "\n=== Setting defaults ===\n" |
printf "\n=== Setting defaults ===\n" |
757 |
echo -n " Adding MODS directories: " |
echo -n " Adding MODS directories: " |
758 |
for d in $MODS ; do |
for d in $MODS ; do |
835 |
# Strip the comments and then convert the dependency file into |
# Strip the comments and then convert the dependency file into |
836 |
# two arrays: PNAME, DNAME |
# two arrays: PNAME, DNAME |
837 |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
cat $PDEPEND | sed -e 's/#.*$//g' \ |
838 |
| 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}' \ |
839 |
> ./.pd_tmp |
> ./.pd_tmp |
840 |
RETVAL=$? |
RETVAL=$? |
841 |
if test ! "x${RETVAL}" = x0 ; then |
if test ! "x${RETVAL}" = x0 ; then |
869 |
else |
else |
870 |
echo " using PDEFAULT=\"$PDEFAULT\"" |
echo " using PDEFAULT=\"$PDEFAULT\"" |
871 |
# Strip the comments and add all the names |
# Strip the comments and add all the names |
872 |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | awk '(NF>0){print $0}'` |
def=`cat $PDEFAULT | sed -e 's/#.*$//g' | $AWK '(NF>0){print $0}'` |
873 |
RETVAL=$? |
RETVAL=$? |
874 |
if test "x${RETVAL}" != x0 ; then |
if test "x${RETVAL}" != x0 ; then |
875 |
echo -n "Error: can't parse default package list " |
echo -n "Error: can't parse default package list " |
991 |
if test -d $adr ; then |
if test -d $adr ; then |
992 |
SOURCEDIRS="$SOURCEDIRS $adr" |
SOURCEDIRS="$SOURCEDIRS $adr" |
993 |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
INCLUDEDIRS="$INCLUDEDIRS $adr" |
994 |
|
if test "x$i" = xautodiff ; then |
995 |
|
AUTODIFF_PKG_USED=t |
996 |
|
fi |
997 |
else |
else |
998 |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
echo "Error: the directory \"$adr\" for package $i doesn't exist" |
999 |
exit 1 |
exit 1 |
1000 |
fi |
fi |
1001 |
done |
done |
1002 |
|
|
|
# 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 |
|
1003 |
|
|
1004 |
# Create a list of #define and #undef to enable/disable packages |
# Create a list of #define and #undef to enable/disable packages |
1005 |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
PACKAGES_DOT_H=PACKAGES_CONFIG.h |
1031 |
fi |
fi |
1032 |
done |
done |
1033 |
if test "x$has_pack" = xf ; then |
if test "x$has_pack" = xf ; then |
1034 |
undef=`echo "ALLOW_$n" | awk '{print toupper($0)}'` |
undef=`echo "ALLOW_$n" | $AWK '{print toupper($0)}'` |
1035 |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
echo "#undef $undef" >> $PACKAGES_DOT_H".tmp" |
|
# 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!!! |
|
|
|
|
1036 |
fi |
fi |
1037 |
fi |
fi |
1038 |
done |
done |
1041 |
C Packages enabled by genmake: |
C Packages enabled by genmake: |
1042 |
EOF |
EOF |
1043 |
for i in $PACKAGES ; do |
for i in $PACKAGES ; do |
1044 |
def=`echo "ALLOW_$i" | awk '{print toupper($0)}'` |
def=`echo "ALLOW_$i" | $AWK '{print toupper($0)}'` |
1045 |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
echo "#define $def" >> $PACKAGES_DOT_H".tmp" |
1046 |
#eh3 DEFINES="$DEFINES -D$def" |
#eh3 DEFINES="$DEFINES -D$def" |
1047 |
|
|
1098 |
fi |
fi |
1099 |
done |
done |
1100 |
|
|
1101 |
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" |
1102 |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
echo " of \"#define ALLOW_PKGNAME\"-type statements:" |
1103 |
CPP_OPTIONS= |
CPP_OPTIONS= |
1104 |
spaths=". $INCLUDEDIRS" |
spaths=". $INCLUDEDIRS" |
1105 |
for i in $spaths ; do |
for i in $spaths ; do |
1122 |
done |
done |
1123 |
|
|
1124 |
|
|
1125 |
|
# Here, we build the list of files to be "run through" the adjoint |
1126 |
|
# compiler. |
1127 |
|
if test -f ./ad_files ; then |
1128 |
|
rm -f ./ad_files |
1129 |
|
fi |
1130 |
|
echo " Creating the list of files for the adjoint compiler." |
1131 |
|
for i in $SOURCEDIRS ; do |
1132 |
|
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
1133 |
|
for j in $list_files ; do |
1134 |
|
cat $i/$j >> ad_files |
1135 |
|
done |
1136 |
|
done |
1137 |
|
|
1138 |
|
cat <<EOF > adjoint_sed |
1139 |
|
s/call adopen(/call adopen ( mythid,\\ |
1140 |
|
\& /g |
1141 |
|
s/call adclose(/call adclose( mythid,\\ |
1142 |
|
\& /g |
1143 |
|
s/call adread(/call adread ( mythid,\\ |
1144 |
|
\& /g |
1145 |
|
s/call adwrite(/call adwrite( mythid,\\ |
1146 |
|
\& /g |
1147 |
|
|
1148 |
|
EOF |
1149 |
|
|
1150 |
echo |
echo |
1151 |
echo "=== Creating the Makefile ===" |
echo "=== Creating the Makefile ===" |
1152 |
echo " setting INCLUDES" |
echo " setting INCLUDES" |
1167 |
echo -n 'CSRCFILES = ' > csrclist.inc |
echo -n 'CSRCFILES = ' > csrclist.inc |
1168 |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
echo -n 'F90SRCFILES = ' > f90srclist.inc |
1169 |
echo -n 'HEADERFILES = ' > hlist.inc |
echo -n 'HEADERFILES = ' > hlist.inc |
1170 |
|
echo -n 'AD_FLOW_FILES = ' > ad_flow_files.inc |
1171 |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
1172 |
for d in $alldirs ; do |
for d in $alldirs ; do |
1173 |
deplist= |
deplist= |
1174 |
sfiles=`( cd $d; echo *.[h,c,F] )` |
sfiles=`( cd $d; echo *.[h,c,F] *.flow )` |
1175 |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
1176 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
1177 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
1178 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
1179 |
extn=`echo $sf | awk -F '.' '{print $NF}'` |
extn=`echo $sf | $AWK -F '.' '{print $NF}'` |
1180 |
touch .links.tmp/$sf |
touch .links.tmp/$sf |
1181 |
deplist="$deplist $sf" |
deplist="$deplist $sf" |
1182 |
case $extn in |
case $extn in |
1196 |
echo " \\" >> hlist.inc |
echo " \\" >> hlist.inc |
1197 |
echo -n " $sf" >> hlist.inc |
echo -n " $sf" >> hlist.inc |
1198 |
;; |
;; |
1199 |
|
flow) |
1200 |
|
echo " \\" >> ad_flow_files.inc |
1201 |
|
echo -n " $sf" >> ad_flow_files.inc |
1202 |
|
;; |
1203 |
esac |
esac |
1204 |
fi |
fi |
1205 |
fi |
fi |
1216 |
echo "" >> csrclist.inc |
echo "" >> csrclist.inc |
1217 |
echo "" >> f90srclist.inc |
echo "" >> f90srclist.inc |
1218 |
echo "" >> hlist.inc |
echo "" >> hlist.inc |
1219 |
|
echo "" >> ad_flow_files.inc |
1220 |
|
|
1221 |
if test -e $MAKEFILE ; then |
if test -e $MAKEFILE ; then |
1222 |
mv -f $MAKEFILE "$MAKEFILE.bak" |
mv -f $MAKEFILE "$MAKEFILE.bak" |
1230 |
echo "# $0 $@" >> $MAKEFILE |
echo "# $0 $@" >> $MAKEFILE |
1231 |
echo "# executed by:" >> $MAKEFILE |
echo "# executed by:" >> $MAKEFILE |
1232 |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
echo "# $USER@${THISHOSTNAME}:${THISCWD}" >> $MAKEFILE |
1233 |
|
|
1234 |
|
EXE_AD=$EXECUTABLE"_ad" |
1235 |
|
EXE_FTL=$EXECUTABLE"_ftl" |
1236 |
|
EXE_SVD=$EXECUTABLE"_svd" |
1237 |
|
|
1238 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1239 |
# |
# |
1240 |
# BUILDDIR : Directory where object files are written |
# BUILDDIR : Directory where object files are written |
1263 |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
EXECUTABLE = \$(EXEDIR)/${EXECUTABLE} |
1264 |
TOOLSDIR = ${TOOLSDIR} |
TOOLSDIR = ${TOOLSDIR} |
1265 |
|
|
1266 |
|
#eh3 new defines for the adjoint work |
1267 |
|
AUTODIFF = ${ROOTDIR}/pkg/autodiff |
1268 |
|
EXE_AD = ${EXE_AD} |
1269 |
|
EXE_FTL = ${EXE_FTL} |
1270 |
|
EXE_SVD = ${EXE_SVD} |
1271 |
|
|
1272 |
EOF |
EOF |
1273 |
|
|
1274 |
# Note: figure out some way to add Hyades JAM libraries here |
# Note: figure out some way to add Hyades JAM libraries here |
1314 |
|
|
1315 |
EOF |
EOF |
1316 |
|
|
1317 |
cat srclist.inc >> $MAKEFILE |
cat srclist.inc >> $MAKEFILE |
1318 |
cat csrclist.inc >> $MAKEFILE |
cat csrclist.inc >> $MAKEFILE |
1319 |
cat f90srclist.inc >> $MAKEFILE |
cat f90srclist.inc >> $MAKEFILE |
1320 |
cat hlist.inc >> $MAKEFILE |
cat hlist.inc >> $MAKEFILE |
1321 |
|
cat ad_flow_files.inc >> $MAKEFILE |
1322 |
|
echo >> $MAKEFILE |
1323 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
1324 |
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
1325 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1326 |
|
|
1327 |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
1328 |
|
rm -f ad_flow_files.inc |
1329 |
|
|
1330 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1331 |
|
|
1349 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1350 |
|
|
1351 |
clean: |
clean: |
1352 |
|
-cat AD_CONFIG.template > AD_CONFIG.h |
1353 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} |
1354 |
Clean: |
Clean: |
1355 |
@make clean |
@make clean |
1356 |
@make cleanlinks |
@make cleanlinks |
1357 |
-rm -f Makefile.bak genmake_state genmake_optfile make.log |
-rm -f Makefile.bak genmake_state genmake_*optfile make.log |
1358 |
CLEAN: |
CLEAN: |
1359 |
@make Clean |
@make Clean |
1360 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
1362 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
1363 |
-rm -f \$(EXECUTABLE) output.txt |
-rm -f \$(EXECUTABLE) output.txt |
1364 |
|
|
1365 |
|
#eh3 Makefile: makefile |
1366 |
makefile: |
makefile: |
1367 |
${0} $@ |
${0} $@ |
1368 |
cleanlinks: |
cleanlinks: |
1386 |
.p.f: |
.p.f: |
1387 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
1388 |
|
|
1389 |
|
#========================================= |
1390 |
|
#=== Automatic Differentiation Rules === |
1391 |
|
|
1392 |
|
TAMC = ${TAMC} |
1393 |
|
TAF = ${TAF} |
1394 |
|
|
1395 |
|
TAF_EXTRA = ${TAF_EXTRA} |
1396 |
|
TAMC_EXTRA = ${TAMC_EXTRA} |
1397 |
|
|
1398 |
|
EOF |
1399 |
|
|
1400 |
|
ad_vars="AD_TAMC_FLAGS AD_TAF_FLAGS" |
1401 |
|
ad_vars="$ad_vars FTL_TAMC_FLAGS FTL_TAF_FLAGS" |
1402 |
|
ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
1403 |
|
for i in $ad_vars ; do |
1404 |
|
name=$i |
1405 |
|
t1="t2=\$"`echo $i` |
1406 |
|
eval $t1 |
1407 |
|
printf "%-20s = " $name >> $MAKEFILE |
1408 |
|
echo $t2 >> $MAKEFILE |
1409 |
|
done |
1410 |
|
|
1411 |
|
echo " Add the source list for AD code generation" |
1412 |
|
echo >> $MAKEFILE |
1413 |
|
echo -n "AD_FILES = " >> $MAKEFILE |
1414 |
|
AD_FILES=`cat ad_files` |
1415 |
|
for i in $AD_FILES ; do |
1416 |
|
echo " \\" >> $MAKEFILE |
1417 |
|
echo -n " $i" >> $MAKEFILE |
1418 |
|
done |
1419 |
|
echo >> $MAKEFILE |
1420 |
|
rm -f ad_files |
1421 |
|
|
1422 |
|
cat >>$MAKEFILE <<EOF |
1423 |
|
|
1424 |
|
# ... AD ... |
1425 |
|
adall: ad_taf |
1426 |
|
adtaf: ad_taf_output.f |
1427 |
|
adtamc: ad_tamc_output.f |
1428 |
|
|
1429 |
|
ad_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1430 |
|
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
1431 |
|
@make \$(F77FILES) |
1432 |
|
@make \$(AD_FLOW_FILES) |
1433 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.f |
1434 |
|
|
1435 |
|
ad_taf_output.f: ad_input_code.f |
1436 |
|
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.f |
1437 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_taf_output.f |
1438 |
|
|
1439 |
|
ad_taf: ad_taf_output.o \$(OBJFILES) |
1440 |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
1441 |
|
|
1442 |
|
ad_tamc_output.f: ad_input_code.f |
1443 |
|
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.f |
1444 |
|
cat ad_input_code_ad.f | sed -f adjoint_sed > ad_tamc_output.f |
1445 |
|
|
1446 |
|
ad_tamc: ad_tamc_output.o \$(OBJFILES) |
1447 |
|
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_tamc_output.o \$(LIBS) |
1448 |
|
|
1449 |
|
|
1450 |
|
# ... FTL ... |
1451 |
|
ftlall: ftl_taf |
1452 |
|
ftltaf: ftl_taf_output.f |
1453 |
|
ftltamc: ftl_tamc_output.f |
1454 |
|
|
1455 |
|
ftl_input_code.f: \$(AD_FILES) \$(HEADERFILES) |
1456 |
|
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
1457 |
|
@make \$(F77FILES) |
1458 |
|
@make \$(AD_FLOW_FILES) |
1459 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.f |
1460 |
|
|
1461 |
|
ftl_taf_output.f: ftl_input_code.f |
1462 |
|
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.f |
1463 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_taf_output.f |
1464 |
|
|
1465 |
|
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
1466 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_taf_output.o \$(LIBS) |
1467 |
|
|
1468 |
|
ftl_tamc_output.f: ftl_input_code.f |
1469 |
|
\$(TAMC) \$(FTL_TAMC_FLAGS) \$(TAMC_EXTRA) ftl_input_code.f |
1470 |
|
cat ftl_input_code_ftl.f | sed -f adjoint_sed > ftl_tamc_output.f |
1471 |
|
|
1472 |
|
ftl_tamc: ftl_tamc_output.o \$(OBJFILES) |
1473 |
|
\$(LINK) -o ${EXE_FTL} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ftl_tamc_output.o \$(LIBS) |
1474 |
|
|
1475 |
|
|
1476 |
|
# ... SVD ... |
1477 |
|
svd: svd_taf |
1478 |
|
svd_taf_f: svd_taf_output.f |
1479 |
|
|
1480 |
|
svd_input_code.f: \$(SRCFILES) |
1481 |
|
cmp svd_config.template AD_CONFIG.h || cat svd_config.template > AD_CONFIG.h |
1482 |
|
@make \$(F77FILES) |
1483 |
|
@make \$(AD_FLOW_FILES) |
1484 |
|
cat \$(AD_FLOW_FILES) \$(AD_FILES) > svd_input_code.f |
1485 |
|
|
1486 |
|
svd_taf_output.f: svd_input_code.f |
1487 |
|
\$(TAF) \$(SVD_TAF_FLAGS) \$(TAF_EXTRA) svd_input_code.f |
1488 |
|
cat svd_input_code_ad.f | sed -f adjoint_sed > svd_taf_output.f |
1489 |
|
|
1490 |
|
svd_taf: svd_taf_output.o \$(OBJFILES) |
1491 |
|
\$(LINK) -o ${EXE_SVD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) svd_taf_output.o \$(LIBS) |
1492 |
|
|
1493 |
|
|
1494 |
|
#========================================= |
1495 |
|
|
1496 |
EOF |
EOF |
1497 |
|
|
1498 |
if test "x$EXEHOOK" != x ; then |
if test "x$EXEHOOK" != x ; then |
1529 |
|
|
1530 |
printf "\n=== Done ===\n" |
printf "\n=== Done ===\n" |
1531 |
|
|
1532 |
|
# Write the "template" files for the adjoint builds |
1533 |
|
cat >AD_CONFIG.template <<EOF |
1534 |
|
C WARNING: This file is automatically generated by genmake2 and |
1535 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1536 |
|
C unless you are CERTAIN that you know what you are doing. |
1537 |
|
|
1538 |
|
#undef ALLOW_ADJOINT_RUN |
1539 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1540 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1541 |
|
EOF |
1542 |
|
cat >ad_config.template <<EOF |
1543 |
|
C WARNING: This file is automatically generated by genmake2 and |
1544 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1545 |
|
C unless you are CERTAIN that you know what you are doing. |
1546 |
|
|
1547 |
|
#define ALLOW_ADJOINT_RUN |
1548 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1549 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1550 |
|
EOF |
1551 |
|
cat >ftl_config.template <<EOF |
1552 |
|
C WARNING: This file is automatically generated by genmake2 and |
1553 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1554 |
|
C unless you are CERTAIN that you know what you are doing. |
1555 |
|
|
1556 |
|
#undef ALLOW_ADJOINT_RUN |
1557 |
|
#define ALLOW_TANGENTLINEAR_RUN |
1558 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1559 |
|
EOF |
1560 |
|
cat >svd_config.template <<EOF |
1561 |
|
C WARNING: This file is automatically generated by genmake2 and |
1562 |
|
C used by the Makefile rules. Please DO NOT EDIT this file |
1563 |
|
C unless you are CERTAIN that you know what you are doing. |
1564 |
|
|
1565 |
|
#undef ALLOW_ADJOINT_RUN |
1566 |
|
#undef ALLOW_TANGENTLINEAR_RUN |
1567 |
|
#undef ALLOW_ECCO_OPTIMIZATION |
1568 |
|
EOF |
1569 |
|
cp AD_CONFIG.template AD_CONFIG.h |
1570 |
|
|
1571 |
|
|
1572 |
# Write the "state" for future records |
# Write the "state" for future records |
1573 |
if test "x$DUMPSTATE" != xf ; then |
if test "x$DUMPSTATE" != xf ; then |