325 |
|
|
326 |
#================================================================ |
#================================================================ |
327 |
# look for possible C compilers |
# look for possible C compilers |
328 |
tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc" |
tmp="$MITGCM_CC $CC gcc c89 cc c99 mpicc icc" |
329 |
p_CC= |
p_CC= |
330 |
for c in $tmp ; do |
for c in $tmp ; do |
331 |
rm -f ./genmake_hello.c ./genmake_hello |
rm -f ./genmake_hello.c ./genmake_hello |
364 |
|
|
365 |
#================================================================ |
#================================================================ |
366 |
# look for possible FORTRAN compilers |
# look for possible FORTRAN compilers |
367 |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95 gfortran" |
tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc ifort f90 f95 mpif77 mpf77 mpxlf95 gfortran g95" |
368 |
p_FC= |
p_FC= |
369 |
for c in $tmp ; do |
for c in $tmp ; do |
370 |
rm -f ./hello.f ./hello |
rm -f ./hello.f ./hello |
587 |
-ts | --ts |
-ts | --ts |
588 |
Produce timing information per timestep |
Produce timing information per timestep |
589 |
-papis | --papis |
-papis | --papis |
590 |
Produce summary MFlop/s with PAPI per timestep |
Produce summary MFlop/s (and IPC) with PAPI per timestep |
591 |
|
-pcls | --pcls |
592 |
|
Produce summary MFlop/s etc. with PCL per timestep |
593 |
-foolad | --foolad |
-foolad | --foolad |
594 |
Fool the AD code generator |
Fool the AD code generator |
595 |
-papi | --papi |
-papi | --papi |
596 |
Performance analysis with PAPI |
Performance analysis with PAPI |
597 |
|
-pcl | --pcl |
598 |
|
Performance analysis with PCL |
599 |
-hpmt | --hpmt |
-hpmt | --hpmt |
600 |
Performance analysis with the HPM Toolkit |
Performance analysis with the HPM Toolkit |
601 |
|
|
602 |
-gsl | --gsl |
-gsl | --gsl |
603 |
Use GSL to control floating point rounding and precision |
Use GSL to control floating point rounding and precision |
604 |
|
-devel | --devel |
605 |
|
Add additional warning and debugging flags for development |
606 |
|
|
607 |
-mpi | --mpi |
-mpi | --mpi |
608 |
Include MPI header files and link to MPI libraries |
Include MPI header files and link to MPI libraries |
746 |
*curtim = *curtim/1.E6; |
*curtim = *curtim/1.E6; |
747 |
} |
} |
748 |
EOF |
EOF |
749 |
make genmake_tc_1.o >> genmake_warnings 2>&1 |
COMM="$CC $CFLAGS -c genmake_tc_1.c" |
750 |
|
echo $COMM >> genmake_warnings |
751 |
|
$COMM >> genmake_warnings 2>&1 |
752 |
RET_C=$? |
RET_C=$? |
753 |
cat <<EOF > genmake_tc_2.$FS |
cat <<EOF > genmake_tc_2.$FS |
754 |
program hello |
program hello |
758 |
print *," HELLO WORLD", wtime |
print *," HELLO WORLD", wtime |
759 |
end |
end |
760 |
EOF |
EOF |
761 |
$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o >> genmake_warnings 2>&1 |
COMM="$FC $FFLAGS -o genmake_tc genmake_tc_2.$FS genmake_tc_1.o" |
762 |
|
echo $COMM >> genmake_warnings |
763 |
|
$COMM >> genmake_warnings 2>&1 |
764 |
RET_F=$? |
RET_F=$? |
765 |
test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1 |
test -x ./genmake_tc && ./genmake_tc >> genmake_warnings 2>&1 |
766 |
RETVAL=$? |
RETVAL=$? |
773 |
|
|
774 |
|
|
775 |
check_HAVE_SIGREG() { |
check_HAVE_SIGREG() { |
776 |
|
if test ! "x$HAVE_SIGREG" = x ; then |
777 |
|
return |
778 |
|
fi |
779 |
get_fortran_c_namemangling |
get_fortran_c_namemangling |
780 |
cat <<EOF > genmake_tc_1.c |
cat <<EOF > genmake_tc_1.c |
781 |
$FC_NAMEMANGLE |
$FC_NAMEMANGLE |
807 |
return; |
return; |
808 |
} |
} |
809 |
EOF |
EOF |
810 |
make genmake_tc_1.o >> genmake_warnings 2>&1 |
COMM="$CC $CFLAGS -c genmake_tc_1.c" |
811 |
|
echo $COMM >> genmake_warnings |
812 |
|
$COMM >> genmake_warnings 2>&1 |
813 |
RET_C=$? |
RET_C=$? |
814 |
cat <<EOF > genmake_tc_2.$FS |
cat <<EOF > genmake_tc_2.$FS |
815 |
program hello |
program hello |
835 |
|
|
836 |
|
|
837 |
check_HAVE_SETRLSTK() { |
check_HAVE_SETRLSTK() { |
838 |
|
if test "x$HAVE_SETRLSTK" = xt ; then |
839 |
|
DEFINES="$DEFINES -DHAVE_SETRLSTK" |
840 |
|
return |
841 |
|
fi |
842 |
|
if test ! "x$HAVE_SETRLSTK" = x ; then |
843 |
|
return |
844 |
|
fi |
845 |
get_fortran_c_namemangling |
get_fortran_c_namemangling |
846 |
cat <<EOF > genmake_tc_1.c |
cat <<EOF > genmake_tc_1.c |
847 |
$FC_NAMEMANGLE |
$FC_NAMEMANGLE |
857 |
return; |
return; |
858 |
} |
} |
859 |
EOF |
EOF |
860 |
make genmake_tc_1.o >> genmake_warnings 2>&1 |
COMM="$CC $CFLAGS -c genmake_tc_1.c" |
861 |
|
echo $COMM >> genmake_warnings |
862 |
|
$COMM >> genmake_warnings 2>&1 |
863 |
RET_C=$? |
RET_C=$? |
864 |
cat <<EOF > genmake_tc_2.$FS |
cat <<EOF > genmake_tc_2.$FS |
865 |
program hello |
program hello |
903 |
*nbyte = -1; |
*nbyte = -1; |
904 |
} |
} |
905 |
EOF |
EOF |
906 |
make genmake_tc_1.o >> genmake_tc.log 2>&1 |
COMM="$CC $CFLAGS -c genmake_tc_1.c" |
907 |
|
echo $COMM >> genmake_warnings |
908 |
|
$COMM >> genmake_tc.log 2>&1 |
909 |
RET_C=$? |
RET_C=$? |
910 |
cat <<EOF > genmake_tc_2.$FS |
cat <<EOF > genmake_tc_2.$FS |
911 |
program hello |
program hello |
956 |
cat genmake_tnc.F >> genmake_tnc.log |
cat genmake_tnc.F >> genmake_tnc.log |
957 |
echo "=== genmake_tnc.F ===" >> genmake_tnc.log |
echo "=== genmake_tnc.F ===" >> genmake_tnc.log |
958 |
RET_CPP=f |
RET_CPP=f |
959 |
COMM="$CPP $DEFINES $INCLUDES genmake_tnc.F" |
COMM="cat genmake_tnc.F | $CPP $DEFINES $INCLUDES" |
960 |
echo "$COMM" >> genmake_tnc.log |
echo "$COMM" >> genmake_tnc.log |
961 |
$COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t |
eval $COMM > genmake_tnc.$FS 2>/dev/null && RET_CPP=t |
962 |
if test "x$RET_CPP" = xf ; then |
if test "x$RET_CPP" = xf ; then |
963 |
echo " WARNING: CPP failed to pre-process the netcdf test." \ |
echo " WARNING: CPP failed to pre-process the netcdf test." \ |
964 |
>> genmake_tnc.log |
>> genmake_tnc.log |
966 |
>> genmake_tnc.log |
>> genmake_tnc.log |
967 |
fi |
fi |
968 |
echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log |
echo "$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log |
969 |
echo " && $LINK -o genmake_tnc.o $LIBS" >> genmake_tnc.log |
echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc.o $LIBS" >> genmake_tnc.log |
970 |
$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ |
$FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ |
971 |
&& $LINK -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1 |
&& $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS >> genmake_tnc.log 2>&1 |
972 |
RET_COMPILE=$? |
RET_COMPILE=$? |
973 |
cat genmake_tnc.log >> genmake_warnings |
cat genmake_tnc.log >> genmake_warnings |
974 |
|
|
984 |
else |
else |
985 |
# try again with "-lnetcdf" added to the libs |
# try again with "-lnetcdf" added to the libs |
986 |
echo "try again with added '-lnetcdf'" > genmake_tnc.log |
echo "try again with added '-lnetcdf'" > genmake_tnc.log |
987 |
echo "$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS \ " >> genmake_tnc.log |
echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log |
988 |
echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log |
echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log |
989 |
echo " && $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log |
echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log |
990 |
$CPP $DEFINES $INCLUDES genmake_tnc.F > genmake_tnc.$FS 2>/dev/null \ |
cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \ |
991 |
&& $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ |
&& $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ |
992 |
&& $LINK -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1 |
&& $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf >> genmake_tnc.log 2>&1 |
993 |
RET_COMPILE=$? |
RET_COMPILE=$? |
994 |
cat genmake_tnc.log >> genmake_warnings |
cat genmake_tnc.log >> genmake_warnings |
995 |
if test "x$RET_COMPILE" = x0 ; then |
if test "x$RET_COMPILE" = x0 ; then |
996 |
LIBS="$LIBS -lnetcdf" |
LIBS="$LIBS -lnetcdf" |
997 |
HAVE_NETCDF=t |
HAVE_NETCDF=t |
998 |
|
else |
999 |
|
# try again with "-lnetcdff" added to the libs |
1000 |
|
echo "try again with added '-lnetcdff -lnetcdf'" > genmake_tnc.log |
1001 |
|
echo "cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS \ " >> genmake_tnc.log |
1002 |
|
echo " && $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS \ " >> genmake_tnc.log |
1003 |
|
echo " && $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdf" >> genmake_tnc.log |
1004 |
|
cat genmake_tnc.F | $CPP $DEFINES $INCLUDES > genmake_tnc.$FS 2>/dev/null \ |
1005 |
|
&& $FC $FFLAGS $FOPTIM -c genmake_tnc.$FS >> genmake_tnc.log 2>&1 \ |
1006 |
|
&& $LINK $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.o $LIBS -lnetcdff -lnetcdf >> genmake_tnc.log 2>&1 |
1007 |
|
RET_COMPILE=$? |
1008 |
|
cat genmake_tnc.log >> genmake_warnings |
1009 |
|
if test "x$RET_COMPILE" = x0 ; then |
1010 |
|
LIBS="$LIBS -lnetcdff -lnetcdf" |
1011 |
|
HAVE_NETCDF=t |
1012 |
|
fi |
1013 |
fi |
fi |
1014 |
fi |
fi |
1015 |
rm -f genmake_tnc* |
rm -f genmake_tnc* |
1045 |
INCLUDES="-I. $INCLUDES" |
INCLUDES="-I. $INCLUDES" |
1046 |
FFLAGS= |
FFLAGS= |
1047 |
FOPTIM= |
FOPTIM= |
1048 |
|
FEXTRAFLAGS= |
1049 |
CFLAGS= |
CFLAGS= |
1050 |
KFLAGS1= |
KFLAGS1= |
1051 |
KFLAGS2= |
KFLAGS2= |
1058 |
MPIPATH= |
MPIPATH= |
1059 |
TS= |
TS= |
1060 |
PAPIS= |
PAPIS= |
1061 |
|
PCLS= |
1062 |
FOOLAD= |
FOOLAD= |
1063 |
PAPI= |
PAPI= |
1064 |
|
PCL= |
1065 |
HPMT= |
HPMT= |
1066 |
GSL= |
GSL= |
1067 |
|
DEVEL= |
1068 |
HAVE_TEST_L= |
HAVE_TEST_L= |
1069 |
|
|
1070 |
# DEFINES checked by test compilation or command-line |
# DEFINES checked by test compilation or command-line |
1072 |
HAVE_FDATE= |
HAVE_FDATE= |
1073 |
FC_NAMEMANGLE= |
FC_NAMEMANGLE= |
1074 |
HAVE_CLOC= |
HAVE_CLOC= |
1075 |
HAVE_SETRLSTK= |
# HAVE_SETRLSTK= |
1076 |
HAVE_STAT= |
HAVE_STAT= |
1077 |
HAVE_NETCDF= |
HAVE_NETCDF= |
1078 |
HAVE_ETIME= |
HAVE_ETIME= |
1123 |
|
|
1124 |
# The following state can be set directly by command-line switches |
# The following state can be set directly by command-line switches |
1125 |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" |
gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE" |
1126 |
gm_s2="FC CPP IEEE TS PAPIS PAPI HPMT GSL MPI JAM DUMPSTATE STANDARDDIRS" |
gm_s2="FC CPP IEEE TS PAPIS PCLS PAPI PCL HPMT GSL DEVEL MPI JAM DUMPSTATE STANDARDDIRS" |
1127 |
|
|
1128 |
# The following state is not directly set by command-line switches |
# The following state is not directly set by command-line switches |
1129 |
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " |
gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM FEXTRAFLAGS" |
1130 |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" |
1131 |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE" |
gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOST THISUSER THISDATE THISVER MACHINE" |
1132 |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
gm_s6="EXECUTABLE EXEHOOK EXEDIR PACKAGES_CONF" |
1153 |
|
|
1154 |
echo "=== Processing options files and arguments ===" |
echo "=== Processing options files and arguments ===" |
1155 |
gm_local="genmake_local" |
gm_local="genmake_local" |
|
for i in . $MODS ; do |
|
|
if test -r $i/$gm_local ; then |
|
|
. $i/$gm_local |
|
|
break |
|
|
fi |
|
|
done |
|
1156 |
printf " getting local config information: " |
printf " getting local config information: " |
1157 |
if test -f $gm_local ; then |
if test -f $gm_local ; then |
1158 |
echo "using $gm_local" |
echo "using $gm_local" |
1301 |
TS=true ;; |
TS=true ;; |
1302 |
-papis | --papis) |
-papis | --papis) |
1303 |
PAPIS=true ;; |
PAPIS=true ;; |
1304 |
|
-pcls | --pcls) |
1305 |
|
PCLS=true ;; |
1306 |
-foolad | --foolad) |
-foolad | --foolad) |
1307 |
FOOLAD=true ;; |
FOOLAD=true ;; |
1308 |
-papi | --papi) |
-papi | --papi) |
1309 |
PAPI=true ;; |
PAPI=true ;; |
1310 |
|
-pcl | --pcl) |
1311 |
|
PCL=true ;; |
1312 |
-hpmt | --hpmt) |
-hpmt | --hpmt) |
1313 |
HPMT=true ;; |
HPMT=true ;; |
1314 |
|
|
1315 |
-gsl | --gsl) |
-gsl | --gsl) |
1316 |
GSL=true ;; |
GSL=true ;; |
1317 |
|
|
1318 |
|
-devel | --devel) |
1319 |
|
DEVEL=true ;; |
1320 |
|
|
1321 |
-mpi | --mpi) |
-mpi | --mpi) |
1322 |
MPI=true ;; |
MPI=true ;; |
1323 |
-mpi=* | --mpi=*) |
-mpi=* | --mpi=*) |
1366 |
if test -f ./.genmakerc ; then |
if test -f ./.genmakerc ; then |
1367 |
echo |
echo |
1368 |
echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" |
echo "WARNING: genmake2 has detected a copy of the old-style \"./.genmakerc\"" |
1369 |
echo " file. This file format is no longer supported. Please see:" |
echo " file. This file format is no longer supported. For directions on" |
1370 |
echo |
echo " how to setup and use the new \"genmake2\" script, please see:" |
1371 |
echo " http://mitgcm.org/devel_HOWTO/" |
echo " http://mitgcm.org/devel_HOWTO/" |
1372 |
echo |
echo " and send an email to MITgcm-support@mitgcm.org if you need help." |
1373 |
echo " for directions on how to setup and use the new \"genmake2\" input" |
echo "WARNING: ignore \"./.genmakerc\" and continue." |
|
echo " files and send an email to MITgcm-support@mitgcm.org if you want help." |
|
1374 |
echo |
echo |
1375 |
fi |
fi |
1376 |
|
|
1377 |
# Find the MITgcm ${ROOTDIR} |
# Find the MITgcm ${ROOTDIR} |
1378 |
if test "x${ROOTDIR}" = x ; then |
if test "x${ROOTDIR}" = x ; then |
1379 |
tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'` |
tmp=`echo $PWD | sed -e 's/\// /g' | $AWK '{print $NR}'` |
1380 |
if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesup -a -d ../pkg ; then |
if test "x$tmp" = "xbin" -a -d ../model -a -d ../eesupp -a -d ../pkg ; then |
1381 |
ROOTDIR=".." |
ROOTDIR=".." |
1382 |
else |
else |
1383 |
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
for d in . .. ../.. ../../.. ../../../.. ../../../../.. ; do |
1567 |
else |
else |
1568 |
DEFINES="$DEFINES -DTIME_PER_TIMESTEP" |
DEFINES="$DEFINES -DTIME_PER_TIMESTEP" |
1569 |
fi |
fi |
1570 |
|
PACKAGES="$PACKAGES showflops" |
1571 |
fi |
fi |
1572 |
if test ! "x$PAPIS" = x ; then |
if test ! "x$PAPIS" = x ; then |
1573 |
echo " Turning on PAPI flop summary per timestep" |
echo " Turning on PAPI flop summary per timestep" |
1579 |
fi |
fi |
1580 |
INCLUDES="$INCLUDES $PAPIINC" |
INCLUDES="$INCLUDES $PAPIINC" |
1581 |
LIBS="$LIBS $PAPILIB" |
LIBS="$LIBS $PAPILIB" |
1582 |
|
PACKAGES="$PACKAGES showflops" |
1583 |
|
fi |
1584 |
|
if test ! "x$PCLS" = x ; then |
1585 |
|
echo " Turning on PCL counter summary per timestep" |
1586 |
|
echo " Please make sure PCLINC, PCLLIB are defined" |
1587 |
|
if test ! "x$FOOLAD" = x ; then |
1588 |
|
DEFINES="$DEFINES -DUSE_PCL_FLOPS_SFP" |
1589 |
|
else |
1590 |
|
DEFINES="$DEFINES -DUSE_PCL_FLOPS" |
1591 |
|
fi |
1592 |
|
INCLUDES="$INCLUDES $PCLINC" |
1593 |
|
LIBS="$LIBS $PCLLIB" |
1594 |
|
PACKAGES="$PACKAGES showflops" |
1595 |
fi |
fi |
1596 |
if test ! "x$PAPI" = x ; then |
if test ! "x$PAPI" = x ; then |
1597 |
if test ! "x$PAPIS" = x ; then |
if test ! "x$PAPIS" = x ; then |
1605 |
LIBS="$LIBS $PAPILIB" |
LIBS="$LIBS $PAPILIB" |
1606 |
fi |
fi |
1607 |
fi |
fi |
1608 |
|
if test ! "x$PCL" = x ; then |
1609 |
|
if test ! "x$PCLS" = x ; then |
1610 |
|
echo " PCL performance analysis and flop summary per timestep cannot co-exist!" |
1611 |
|
echo " Sticking with PCL flop summary per timestep!" |
1612 |
|
else |
1613 |
|
echo " Turning on performance analysis with PCL" |
1614 |
|
echo " Please make sure PCLINC, PCLLIB are defined" |
1615 |
|
DEFINES="$DEFINES -DUSE_PCL" |
1616 |
|
INCLUDES="$INCLUDES $PCLINC" |
1617 |
|
LIBS="$LIBS $PCLLIB" |
1618 |
|
fi |
1619 |
|
fi |
1620 |
if test ! "x$HPMT" = x ; then |
if test ! "x$HPMT" = x ; then |
1621 |
if test ! "x$PAPI" = x ; then |
if test ! "x$PAPI" = x ; then |
1622 |
echo " PAPI and the HPM Toolkit cannot co-exist!" |
echo " PAPI and the HPM Toolkit cannot co-exist!" |
1623 |
echo " Sticking with PAPI!" |
echo " Sticking with PAPI!" |
1624 |
|
else if test ! "x$PCL" = x ; then |
1625 |
|
echo " PCL and the HPM Toolkit cannot co-exist!" |
1626 |
|
echo " Sticking with PCL!" |
1627 |
else |
else |
1628 |
echo " Turning on performance analysis with the HPM Toolkit" |
echo " Turning on performance analysis with the HPM Toolkit" |
1629 |
echo " Please make sure HPMTINC, HPMTLIB are defined" |
echo " Please make sure HPMTINC, HPMTLIB are defined" |
1631 |
INCLUDES="$INCLUDES $HPMTINC" |
INCLUDES="$INCLUDES $HPMTINC" |
1632 |
LIBS="$LIBS $HPMTLIB" |
LIBS="$LIBS $HPMTLIB" |
1633 |
fi |
fi |
1634 |
|
fi |
1635 |
fi |
fi |
1636 |
if test ! "x$GSL" = x ; then |
if test ! "x$GSL" = x ; then |
1637 |
echo " Turning on use of GSL to control floating point calculations" |
echo " Turning on use of GSL to control floating point calculations" |
1719 |
|
|
1720 |
printf " Can we unlimit the stack size using $FC... " |
printf " Can we unlimit the stack size using $FC... " |
1721 |
check_HAVE_SETRLSTK |
check_HAVE_SETRLSTK |
1722 |
if test "x$HAVE_SETRLSTK" != x ; then |
if test "x$HAVE_SETRLSTK" = xt ; then |
1723 |
echo "yes" |
echo "yes" |
1724 |
else |
else |
1725 |
echo "no" |
echo "no" |
1728 |
|
|
1729 |
printf " Can we register a signal handler using $FC... " |
printf " Can we register a signal handler using $FC... " |
1730 |
check_HAVE_SIGREG |
check_HAVE_SIGREG |
1731 |
if test "x$HAVE_SIGREG" != x ; then |
if test "x$HAVE_SIGREG" = xt ; then |
1732 |
echo "yes" |
echo "yes" |
1733 |
else |
else |
1734 |
echo "no" |
echo "no" |
1846 |
fi |
fi |
1847 |
fi |
fi |
1848 |
|
|
1849 |
#same for exch2 |
#same for pkg/exch2 and pkg/regrid |
1850 |
if test -r $ROOTDIR"/pkg/exch2/Makefile" ; then |
for pdir in exch2 regrid ; do |
1851 |
echo " Making source files in exch2 from templates" |
if test -r $ROOTDIR"/pkg/${pdir}/Makefile" ; then |
1852 |
( cd $ROOTDIR"/pkg/exch2/" && $MAKE ) > make_exch2.errors 2>&1 |
echo " Making source files in pkg/${pdir} from templates" |
1853 |
RETVAL=$? |
( cd $ROOTDIR"/pkg/"${pdir} && $MAKE ) > make_${pdir}.errors 2>&1 |
1854 |
if test "x${RETVAL}" = x0 ; then |
RETVAL=$? |
1855 |
rm -f make_exch2.errors |
if test "x${RETVAL}" = x0 ; then |
1856 |
else |
rm -f make_${pdir}.errors |
1857 |
echo "Error: problem encountered while building source files in exch2:" |
else |
1858 |
cat make_exch2.errors 1>&2 |
echo "Error: problem encountered while building source files in pkg/${pdir}:" |
1859 |
exit 1 |
cat make_${pdir}.errors 1>&2 |
1860 |
|
exit 1 |
1861 |
|
fi |
1862 |
fi |
fi |
1863 |
fi |
done |
1864 |
|
|
1865 |
printf "\n=== Determining package settings ===\n" |
printf "\n=== Determining package settings ===\n" |
1866 |
if test "x${PDEPEND}" = x ; then |
if test "x${PDEPEND}" = x ; then |
1971 |
rm -f ./.tmp_pack |
rm -f ./.tmp_pack |
1972 |
echo " packages are: $PACKAGES" |
echo " packages are: $PACKAGES" |
1973 |
|
|
1974 |
# Check availability of NetCDF and then either build the MNC template |
# Check for package MNC: if NetCDF is available, then build the MNC |
1975 |
# files or delete mnc from the list of available packages. |
# template files ; otherwise, delete mnc from the list of packages. |
1976 |
echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 |
echo $PACKAGES | grep ' mnc ' > /dev/null 2>&1 |
1977 |
RETVAL=$? |
RETVAL=$? |
1978 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
2006 |
fi |
fi |
2007 |
fi |
fi |
2008 |
|
|
2009 |
|
# Check for package PROFILES: if NetCDF is not available, |
2010 |
|
# then delete profiles from the list of available packages. |
2011 |
|
echo $PACKAGES | grep ' profiles ' > /dev/null 2>&1 |
2012 |
|
RETVAL=$? |
2013 |
|
if test "x$RETVAL" = x0 ; then |
2014 |
|
if test "x$HAVE_NETCDF" != xt ; then |
2015 |
|
cat <<EOF |
2016 |
|
|
2017 |
|
********************************************************************* |
2018 |
|
WARNING: the "profiles" package was enabled but tests failed to |
2019 |
|
compile NetCDF applications. Please check that: |
2020 |
|
|
2021 |
|
1) NetCDF is correctly installed for this compiler and |
2022 |
|
2) the LIBS variable (within the "optfile") specifies the correct |
2023 |
|
NetCDF library to link against. |
2024 |
|
|
2025 |
|
Due to this failure, the "profiles" package is now DISABLED. |
2026 |
|
********************************************************************* |
2027 |
|
|
2028 |
|
EOF |
2029 |
|
PACKAGES=`echo $PACKAGES | sed -e 's/profiles//g'` |
2030 |
|
DISABLE="$DISABLE profiles" |
2031 |
|
fi |
2032 |
|
fi |
2033 |
|
|
2034 |
echo " applying package dependency rules" |
echo " applying package dependency rules" |
2035 |
ck= |
ck= |
2036 |
while test "x$ck" != xtt ; do |
while test "x$ck" != xtt ; do |
2037 |
i=0 |
i=0 |
2038 |
# rtot=${#PNAME[@]} |
# rtot=${#PNAME[@]} |
2039 |
rtot=$nname |
rtot=$nname |
2040 |
while test $i -lt $rtot ; do |
while test $i -le $rtot ; do |
2041 |
|
|
2042 |
# Is $pname in the current $PACKAGES list? |
# Is $pname in the current $PACKAGES list? |
2043 |
# pname=${PNAME[$i]} |
# pname=${PNAME[$i]} |
2071 |
|
|
2072 |
# Do we need to add $dname according to the dependency rules? |
# Do we need to add $dname according to the dependency rules? |
2073 |
if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then |
if test "x$pin" = xt -a "x$plus" = "x+" -a "x$din" = xf ; then |
2074 |
|
#echo " " $pname ": need to add :" $dname |
2075 |
in_dis="f" |
in_dis="f" |
2076 |
for dis in $DISABLE ; do |
for dis in $DISABLE ; do |
2077 |
if test "x$dis" = "x$dname" ; then |
if test "x$dis" = "x$dname" ; then |
2216 |
|
|
2217 |
# 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 |
2218 |
# compiler. |
# compiler. |
2219 |
if test -f ./ad_files ; then |
if test -f ./adSrcFiles.tmp ; then |
2220 |
rm -f ./ad_files |
rm -f ./adSrcFiles.tmp |
2221 |
fi |
fi |
2222 |
echo " Creating the list of files for the adjoint compiler." |
echo " Creating the list of files for the adjoint compiler." |
2223 |
for i in $SOURCEDIRS ; do |
for i in $SOURCEDIRS ; do |
2224 |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
list_files=`( cd $i && ls -1 *.list 2>/dev/null )` |
2225 |
for j in $list_files ; do |
for j in $list_files ; do |
2226 |
cat $i/$j >> ad_files |
cat $i/$j >> adSrcFiles.tmp |
2227 |
done |
done |
2228 |
done |
done |
2229 |
if test ! "x"$FS = "x.f" ; then |
if test ! "x"$FS = "x.f" ; then |
2230 |
cat ad_files | sed -e "s/\.f/.$FS/g" > ad_files_f |
cat adSrcFiles.tmp | sed -e "s/\.f/.$FS/g" > adSrcFiles.tmp_f |
2231 |
mv -f ad_files_f ad_files |
mv -f adSrcFiles.tmp_f adSrcFiles.tmp |
2232 |
fi |
fi |
2233 |
|
|
2234 |
echo |
echo |
2261 |
perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h |
perl -i -pe 's/MPI_DISPLACEMENT_CURRENT=-1_8/MPI_DISPLACEMENT_CURRENT=-1/g' mpi_headers/mpif.h |
2262 |
else |
else |
2263 |
echo " We cannot create a copy of mpif.h!" |
echo " We cannot create a copy of mpif.h!" |
2264 |
exit -1 |
# exit -1 |
2265 |
fi |
fi |
2266 |
fi |
fi |
2267 |
|
|
2286 |
exit 1 |
exit 1 |
2287 |
fi |
fi |
2288 |
rm -f .links.tmp/foo |
rm -f .links.tmp/foo |
2289 |
|
|
2290 |
|
if test "x$OPENAD" != x ; then |
2291 |
|
OAD_DONT_COMPILE="/dev/null" |
2292 |
|
OAD_DONT_TRANSFORM="/dev/null" |
2293 |
|
OAD_KEEP_ORIGINAL="/dev/null" |
2294 |
|
OAD_CB2M_FILES="/dev/null" |
2295 |
|
echo " looking for dontCompile file: " |
2296 |
|
for i in "." $MODS ; do |
2297 |
|
if test -r $i"/dontCompile" ; then |
2298 |
|
OAD_DONT_COMPILE=$i"/dontCompile" |
2299 |
|
echo " found $OAD_DONT_COMPILE" |
2300 |
|
break |
2301 |
|
fi |
2302 |
|
done |
2303 |
|
echo " looking for dontTransform file: " |
2304 |
|
for i in "." $MODS ; do |
2305 |
|
if test -r $i"/dontTransform" ; then |
2306 |
|
OAD_DONT_TRANSFORM=$i"/dontTransform" |
2307 |
|
echo " found $OAD_DONT_TRANSFORM" |
2308 |
|
break |
2309 |
|
fi |
2310 |
|
done |
2311 |
|
echo " looking for keepOriginal file: " |
2312 |
|
for i in "." $MODS ; do |
2313 |
|
if test -r $i"/keepOriginal" ; then |
2314 |
|
OAD_KEEP_ORIGINAL=$i"/keepOriginal" |
2315 |
|
echo " found $OAD_KEEP_ORIGINAL" |
2316 |
|
break |
2317 |
|
fi |
2318 |
|
done |
2319 |
|
echo " looking for cb2mFiles: " |
2320 |
|
for i in "." $MODS ; do |
2321 |
|
if test -r $i"/cb2mFiles" ; then |
2322 |
|
OAD_CB2M_FILES=$i"/cb2mFiles" |
2323 |
|
echo " found $OAD_CB2M_FILES" |
2324 |
|
break |
2325 |
|
fi |
2326 |
|
done |
2327 |
|
echo " OpenAD exceptions: " |
2328 |
|
fi |
2329 |
|
|
2330 |
echo "# This section creates symbolic links" > srclinks.tmp |
echo "# This section creates symbolic links" > srclinks.tmp |
2331 |
echo "" >> srclinks.tmp |
echo "" >> srclinks.tmp |
2332 |
printf 'SRCFILES = ' > srclist.inc |
printf 'F77_SRC_FILES = ' > F77srclist.tmp |
2333 |
printf 'CSRCFILES = ' > csrclist.inc |
printf 'NON_AD_F77_SRC_FILES = ' > nonADF77srclist.tmp |
2334 |
printf 'F90SRCFILES = ' > f90srclist.inc |
printf 'C_SRC_FILES = ' > csrclist.tmp |
2335 |
printf 'HEADERFILES = ' > hlist.inc |
printf 'F90_SRC_FILES = ' > F90srclist.tmp |
2336 |
printf 'AD_FLOW_FILES = ' > ad_flow_files.inc |
printf 'H_SRC_FILES = ' > hsrclist.tmp |
2337 |
|
printf 'AD_FLOW_FILES = ' > ad_flow_files.tmp |
2338 |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
alldirs="$SOURCEDIRS $INCLUDEDIRS ." |
2339 |
for d in $alldirs ; do |
for d in $alldirs ; do |
2340 |
deplist= |
deplist= |
2341 |
sfiles=`( cd $d; echo *.[h,c,F] *.flow )` |
sfiles=`( cd $d; echo *.[h,c,F] *.flow )` |
2342 |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
sfiles=`( echo $sfiles; cd $d; echo *.F90 )` |
2343 |
|
if test "x$OPENAD" != x ; then |
2344 |
|
sfiles=`( echo $sfiles | grep -v _cb2m\. )` |
2345 |
|
fi |
2346 |
for sf in $sfiles ; do |
for sf in $sfiles ; do |
2347 |
if test ! -r ".links.tmp/$sf" ; then |
if test ! -r ".links.tmp/$sf" ; then |
2348 |
if test -f "$d/$sf" ; then |
if test -f "$d/$sf" ; then |
2377 |
if test "x$ignore_f" = xf ; then |
if test "x$ignore_f" = xf ; then |
2378 |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
extn=`echo $sf | $AWK -F. '{print $NF}'` |
2379 |
case $extn in |
case $extn in |
2380 |
F) |
F) |
2381 |
echo " \\" >> srclist.inc |
echo " \\" >> F77srclist.tmp |
2382 |
printf " $sf" >> srclist.inc |
printf " $sf" >> F77srclist.tmp |
2383 |
;; |
if test "x$OPENAD" != x ; then |
2384 |
F90) |
basename=${sf%%.F} |
2385 |
echo " \\" >> f90srclist.inc |
isAD=`egrep ^$basename.f'[ ]*' adSrcFiles.tmp` |
2386 |
printf " $sf" >> f90srclist.inc |
if test -z "$isAD" ; then |
2387 |
;; |
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE}` |
2388 |
c) |
if test -z "$toBeIgnored" ; then |
2389 |
echo " \\" >> csrclist.inc |
echo " \\" >> nonADF77srclist.tmp |
2390 |
printf " $sf" >> csrclist.inc |
printf " $sf" >> nonADF77srclist.tmp |
2391 |
;; |
else |
2392 |
h) |
echo " not to be compiled : $sf" |
2393 |
echo " \\" >> hlist.inc |
fi |
2394 |
printf " $sf" >> hlist.inc |
else # file is initially listed as an AD file we want to exclude it |
2395 |
;; |
# or we want to retain the untransformed version |
2396 |
flow) |
notToBeTransformed=`egrep ^$basename'[ ]*' ${OAD_DONT_TRANSFORM}` |
2397 |
echo " \\" >> ad_flow_files.inc |
untransformedVersionToBeKept=`egrep ^$basename'[ ]*' ${OAD_KEEP_ORIGINAL}` |
2398 |
printf " $sf" >> ad_flow_files.inc |
if test -n "$notToBeTransformed"; then |
2399 |
;; |
echo " not to be transformed: $sf" |
2400 |
esac |
fi |
2401 |
fi |
if test -n "$untransformedVersionToBeKept" ; then |
2402 |
|
echo " original to be kept : $sf" |
2403 |
|
fi |
2404 |
|
if test -n "$notToBeTransformed" -o -n "$untransformedVersionToBeKept" ; then |
2405 |
|
echo " \\" >> nonADF77srclist.tmp |
2406 |
|
printf " $sf" >> nonADF77srclist.tmp |
2407 |
|
fi |
2408 |
|
fi |
2409 |
|
fi |
2410 |
|
;; |
2411 |
|
F90) |
2412 |
|
echo " \\" >> F90srclist.tmp |
2413 |
|
printf " $sf" >> F90srclist.tmp |
2414 |
|
;; |
2415 |
|
c) |
2416 |
|
echo " \\" >> csrclist.tmp |
2417 |
|
printf " $sf" >> csrclist.tmp |
2418 |
|
;; |
2419 |
|
h) |
2420 |
|
echo " \\" >> hsrclist.tmp |
2421 |
|
printf " $sf" >> hsrclist.tmp |
2422 |
|
;; |
2423 |
|
flow) |
2424 |
|
echo " \\" >> ad_flow_files.tmp |
2425 |
|
printf " $sf" >> ad_flow_files.tmp |
2426 |
|
;; |
2427 |
|
esac |
2428 |
|
fi |
2429 |
fi |
fi |
2430 |
fi |
fi |
2431 |
done |
done |
2432 |
if test "x$deplist" != x ; then |
if test "x$deplist" != x ; then |
2433 |
echo "" >> srclinks.tmp |
if test "$d" != "." ; then |
2434 |
|
echo "" >> srclinks.tmp |
2435 |
echo "# These files are linked from $d" >> srclinks.tmp |
echo "# These files are linked from $d" >> srclinks.tmp |
2436 |
echo "$deplist :" >> srclinks.tmp |
echo "$deplist :" >> srclinks.tmp |
2437 |
printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp |
# We need to make sure that the link isn't already there. |
2438 |
|
# This may happen when make thinks that a header file has to be "remade" |
2439 |
|
# because a module it depends on has changed. In this case we do nothing. |
2440 |
|
printf "\tif [ ! -L \$@ ]; then \$(LN) %s/\$@ \$@; fi\n" $d >> srclinks.tmp |
2441 |
|
fi |
2442 |
fi |
fi |
2443 |
done |
done |
2444 |
rm -rf .links.tmp |
rm -rf .links.tmp |
2445 |
echo "" >> srclist.inc |
echo "" >> F77srclist.tmp |
2446 |
echo "" >> csrclist.inc |
echo "" >> nonADF77srclist.tmp |
2447 |
echo "" >> f90srclist.inc |
echo "" >> csrclist.tmp |
2448 |
echo "" >> hlist.inc |
echo "" >> F90srclist.tmp |
2449 |
echo "" >> ad_flow_files.inc |
echo "" >> hsrclist.tmp |
2450 |
|
echo "" >> ad_flow_files.tmp |
2451 |
|
|
2452 |
if test -f $MAKEFILE ; then |
if test -f $MAKEFILE ; then |
2453 |
mv -f $MAKEFILE "$MAKEFILE.bak" |
mv -f $MAKEFILE "$MAKEFILE.bak" |
2542 |
KFLAGS1 = ${KFLAGS1} |
KFLAGS1 = ${KFLAGS1} |
2543 |
KFLAGS2 = ${KFLAGS2} |
KFLAGS2 = ${KFLAGS2} |
2544 |
# Optim./debug for FC |
# Optim./debug for FC |
2545 |
FFLAGS = ${FFLAGS} |
FFLAGS = ${FFLAGS} ${FEXTRAFLAGS} |
2546 |
FOPTIM = ${FOPTIM} |
FOPTIM = ${FOPTIM} |
2547 |
# Optim./debug for FC |
# Optim./debug for FC |
2548 |
F90FLAGS = ${F90FLAGS} |
F90FLAGS = ${F90FLAGS} |
2549 |
F90OPTIM = ${F90OPTIM} |
F90OPTIM = ${F90OPTIM} |
2550 |
|
F90FIXEDFORMAT = ${F90FIXEDFORMAT} |
2551 |
# Flags for CC |
# Flags for CC |
2552 |
CFLAGS = ${CFLAGS} |
CFLAGS = ${CFLAGS} |
2553 |
# Files that should not be optimized |
# Files that should not be optimized |
2560 |
|
|
2561 |
EOF |
EOF |
2562 |
|
|
2563 |
cat srclist.inc >> $MAKEFILE |
cat F77srclist.tmp >> $MAKEFILE |
2564 |
cat csrclist.inc >> $MAKEFILE |
cat nonADF77srclist.tmp >> $MAKEFILE |
2565 |
cat f90srclist.inc >> $MAKEFILE |
cat csrclist.tmp >> $MAKEFILE |
2566 |
cat hlist.inc >> $MAKEFILE |
cat F90srclist.tmp >> $MAKEFILE |
2567 |
cat ad_flow_files.inc >> $MAKEFILE |
cat hsrclist.tmp >> $MAKEFILE |
2568 |
|
cat ad_flow_files.tmp >> $MAKEFILE |
2569 |
|
|
2570 |
|
rm -f F77srclist.tmp nonADF77srclist.tmp csrclist.tmp F90srclist.tmp hsrclist.tmp ad_flow_files.tmp |
2571 |
|
|
2572 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
2573 |
echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE |
|
2574 |
echo 'F90FILES = $(F90SRCFILES:.F90=.'$FS90')' >> $MAKEFILE |
# add definitions for preprocessed sources |
2575 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
# and note that not all systems allow case sensitive extensions |
2576 |
|
# hence the $FS and $FS90 here. |
2577 |
|
# for fixed format f90 files we use ff90 or FF90 resp |
2578 |
|
# but these are not expected to be the original source files |
2579 |
|
|
2580 |
|
echo 'F77_PP_SRC_FILES = $(F77_SRC_FILES:.F=.'$FS')' >> $MAKEFILE |
2581 |
|
echo 'F90_PP_SRC_FILES = $(F90_SRC_FILES:.F90=.'$FS90')' >> $MAKEFILE |
2582 |
|
echo 'OBJFILES= $(F77_SRC_FILES:.F=.o) $(C_SRC_FILES:.c=.o) $(F90_SRC_FILES:.F90=.o)' >> $MAKEFILE |
2583 |
|
echo 'FLOFILES = $(AD_FLOW_FILES:.flow=.flowdir)' >> $MAKEFILE |
2584 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
2585 |
echo '.SUFFIXES:' >> $MAKEFILE |
echo '.SUFFIXES:' >> $MAKEFILE |
2586 |
echo '.SUFFIXES: .o .'$FS' .p .F .c .'$FS90' .F90' >> $MAKEFILE |
echo '.SUFFIXES: .o .'$FS' .p .F .c .f'$FS90' .'$FS90' .FF90 .F90 .flowdir .flow' >> $MAKEFILE |
|
rm -f srclist.inc csrclist.inc hlist.inc flist.tmp clist.tmp f90srclist.inc |
|
|
rm -f ad_flow_files.inc |
|
2587 |
|
|
2588 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
2589 |
|
|
2590 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
2591 |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) \$(EMBEDDED_FILES) |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(OBJFILES) \$(EMBEDDED_FILES) |
2592 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
2593 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
2594 |
depend: |
depend: |
2595 |
@make links |
@make links |
2596 |
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) |
2597 |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
2598 |
-rm -f makedepend.out |
-rm -f makedepend.out |
2599 |
|
|
2601 |
|
|
2602 |
libmitgcmuv.a: \$(OBJFILES) |
libmitgcmuv.a: \$(OBJFILES) |
2603 |
ar rcv libmitgcmuv.a \$(OBJFILES) |
ar rcv libmitgcmuv.a \$(OBJFILES) |
2604 |
|
ar d libmitgcmuv.a main.o |
2605 |
|
|
2606 |
links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(SPECIAL_FILES) |
links: \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(SPECIAL_FILES) |
2607 |
|
|
2608 |
small_f: \$(F77FILES) \$(F90FILES) |
small_f: \$(F77_PP_SRC_FILES) \$(F90_PP_SRC_FILES) |
2609 |
|
|
2610 |
output.txt: \$(EXECUTABLE) |
output.txt: \$(EXECUTABLE) |
2611 |
@printf 'running ... ' |
@printf 'running ... ' |
2612 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
2613 |
|
|
2614 |
clean: |
clean: |
2615 |
-rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
-rm -rf *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
2616 |
|
-rm -rf *.o |
2617 |
|
-rm -rf *.$FS *.flowdir |
2618 |
|
-rm -rf *.f$FS90 *_mod.h *_mod.F90 *.FF90 *.mod-whirl ad_input* |
2619 |
|
-rm -rf temp.sed reslice.dat |
2620 |
Clean: |
Clean: |
2621 |
@make clean |
@make clean |
2622 |
@make cleanlinks |
@make cleanlinks |
2623 |
-rm -f \$(SPECIAL_FILES) |
-rm -f \$(SPECIAL_FILES) |
2624 |
-rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log *.bak |
-rm -f genmake_state genmake_*optfile genmake_warnings make.log run.log f90mkdepend.log *.bak |
2625 |
|
-rm -f taf_command taf_output taf_ad.log taf_ad_flow.log |
2626 |
CLEAN: |
CLEAN: |
2627 |
@make Clean |
@make Clean |
2628 |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
-find \$(EXEDIR) -name "*.meta" -exec rm {} \; |
2629 |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
-find \$(EXEDIR) -name "*.data" -exec rm {} \; |
2630 |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
-find \$(EXEDIR) -name "fort.*" -exec rm {} \; |
2631 |
-rm -f \$(EXECUTABLE) *.txt STD* *diagnostics.log datetime |
-rm -f \$(EXECUTABLE) \$(EXE_AD) *.txt STD* *diagnostics.log datetime |
2632 |
|
-rm -f *_MIT_CE_000.opt0000 costfunction*0000 |
2633 |
-rm -rf mnc_test_* |
-rm -rf mnc_test_* |
2634 |
|
|
2635 |
#eh3 Makefile: makefile |
#eh3 Makefile: makefile |
2638 |
cleanlinks: |
cleanlinks: |
2639 |
-find . -type l -exec rm {} \; |
-find . -type l -exec rm {} \; |
2640 |
|
|
2641 |
# Special targets (SPECIAL_FILES) which are create by make |
# Special targets (SPECIAL_FILES) which are created by make |
2642 |
${PACKAGES_DOT_H}: |
${PACKAGES_DOT_H}: |
2643 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
2644 |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
@$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ |
2663 |
|
|
2664 |
decode_files.o : EMBEDDED_FILES.h |
decode_files.o : EMBEDDED_FILES.h |
2665 |
|
|
2666 |
## \$(F77FILES) |
## \$(F77_PP_SRC_FILES) |
2667 |
all_fF.tar.gz : \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile |
all_fF.tar.gz : \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile |
2668 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
2669 |
-tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(F77FILES) Makefile |
-tar -hcf all_fF.tar \$(SPECIAL_FILES) \$(F77_SRC_FILES) \$(C_SRC_FILES) \$(H_SRC_FILES) \$(F90_SRC_FILES) \$(F77_PP_SRC_FILES) Makefile |
2670 |
-rm -f all_fF.tar.gz |
-rm -f all_fF.tar.gz |
2671 |
-gzip all_fF.tar |
-gzip all_fF.tar |
2672 |
|
|
2682 |
# The normal chain of rules is ( .F - .$FS - .o ) |
# The normal chain of rules is ( .F - .$FS - .o ) |
2683 |
|
|
2684 |
## This nullifies any default implicit rules concerning these two file types: |
## This nullifies any default implicit rules concerning these two file types: |
2685 |
## %.o : %.F |
%.o : %.F |
2686 |
|
|
2687 |
.F.$FS: |
.F.$FS: |
2688 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
2690 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
2691 |
.F90.$FS90: |
.F90.$FS90: |
2692 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
2693 |
|
.FF90.f$FS90: |
2694 |
|
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
2695 |
.$FS90.o: |
.$FS90.o: |
2696 |
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
2697 |
|
.f$FS90.o: |
2698 |
|
cp \$< \$(basename \$<).f90 |
2699 |
|
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$(F90FIXEDFORMAT) \$(basename \$<).f90 |
2700 |
.c.o: |
.c.o: |
2701 |
\$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$< |
\$(CC) \$(CFLAGS) \$(DEFINES) \$(INCLUDES) -c \$< |
2702 |
|
.flow.flowdir: |
2703 |
|
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
2704 |
|
|
2705 |
# Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain |
# Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain |
2706 |
.F.p: |
.F.p: |
2708 |
.p.$FS: |
.p.$FS: |
2709 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
2710 |
|
|
2711 |
|
EOF |
2712 |
|
|
2713 |
#========================================= |
#========================================= |
2714 |
#=== Automatic Differentiation Rules === |
#=== Automatic Differentiation Rules === |
2715 |
|
#=== for TAMC/TAF ====================== |
2716 |
|
|
2717 |
|
if test "x$OPENAD" == x ; then |
2718 |
|
|
2719 |
|
cat >>$MAKEFILE <<EOF |
2720 |
|
|
2721 |
TAMC = ${TAMC} |
TAMC = ${TAMC} |
2722 |
TAF = ${TAF} |
TAF = ${TAF} |
2731 |
ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
ad_vars="$ad_vars SVD_TAMC_FLAGS SVD_TAF_FLAGS" |
2732 |
for i in $ad_vars ; do |
for i in $ad_vars ; do |
2733 |
name=$i |
name=$i |
2734 |
t1="t2=\$"`echo $i` |
t1="t2=\$"`echo "$i"` |
2735 |
eval $t1 |
eval $t1 |
2736 |
printf "%-20s = " $name >> $MAKEFILE |
printf "%-20s = " $name >> $MAKEFILE |
2737 |
echo $t2 >> $MAKEFILE |
echo "$t2" | sed -e 's| \+| |g' >> $MAKEFILE |
2738 |
done |
done |
2739 |
|
|
2740 |
echo " Add the source list for AD code generation" |
echo " Add the source list for AD code generation" |
2751 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
2752 |
|
|
2753 |
# ... AD ... |
# ... AD ... |
2754 |
adall: ad_taf |
adall: \$(EXE_AD) |
2755 |
adtaf: ad_taf_output.$FS |
adtaf: ad_taf_output.$FS |
2756 |
adtamc: ad_tamc_output.$FS |
adtamc: ad_tamc_output.$FS |
2757 |
|
|
2758 |
ad_input_code.$FS: \$(AD_FILES) \$(HEADERFILES) |
ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) |
2759 |
@$BASH\$(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 |
@$BASH\$(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 |
2760 |
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h |
2761 |
-rm -f ad_config.template |
-rm -f ad_config.template |
2762 |
@make \$(F77FILES) |
@make \$(F77_PP_SRC_FILES) |
2763 |
@make \$(AD_FLOW_FILES) |
@make \$(FLOFILES) |
2764 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ad_input_code.$FS |
cat \$(FLOFILES) \$(AD_FILES) > ad_input_code.$FS |
2765 |
|
|
2766 |
ad_taf_output.$FS: ad_input_code.$FS |
ad_taf_output.$FS: ad_input_code.$FS |
2767 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
2768 |
|
ls -l ad_input_code_ad.$FS |
2769 |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
2770 |
|
|
2771 |
adtafonly: |
adtafonly: |
2772 |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
\$(TAF) \$(AD_TAF_FLAGS) \$(TAF_EXTRA) ad_input_code.$FS |
2773 |
|
ls -l ad_input_code_ad.$FS |
2774 |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
cat ad_input_code_ad.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ad_taf_output.$FS |
2775 |
|
|
2776 |
ad_taf: ad_taf_output.o \$(OBJFILES) |
\${EXE_AD}: ad_taf_output.o \$(OBJFILES) |
2777 |
\$(LINK) -o ${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
\$(LINK) -o \${EXE_AD} \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) ad_taf_output.o \$(LIBS) |
2778 |
|
|
2779 |
ad_tamc_output.$FS: ad_input_code.$FS |
ad_tamc_output.$FS: ad_input_code.$FS |
2780 |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
\$(TAMC) \$(AD_TAMC_FLAGS) \$(TAMC_EXTRA) ad_input_code.$FS |
2794 |
ftltaf: ftl_taf_output.$FS |
ftltaf: ftl_taf_output.$FS |
2795 |
ftltamc: ftl_tamc_output.$FS |
ftltamc: ftl_tamc_output.$FS |
2796 |
|
|
2797 |
ftl_input_code.$FS: \$(AD_FILES) \$(HEADERFILES) |
ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) |
2798 |
@$BASH\$(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 |
@$BASH\$(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 |
2799 |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
2800 |
-rm -f ftl_config.template |
-rm -f ftl_config.template |
2801 |
@make \$(F77FILES) |
@make \$(F77_PP_SRC_FILES) |
2802 |
@make \$(AD_FLOW_FILES) |
@make \$(AD_FLOW_FILES) |
2803 |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS |
cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS |
2804 |
|
|
2805 |
ftl_taf_output.$FS: ftl_input_code.$FS |
ftl_taf_output.$FS: ftl_input_code.$FS |
2806 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
2807 |
|
ls -l ftl_input_code_ftl.$FS |
2808 |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
2809 |
|
|
2810 |
ftltafonly: |
ftltafonly: |
2811 |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
\$(TAF) \$(FTL_TAF_FLAGS) \$(TAF_EXTRA) ftl_input_code.$FS |
2812 |
|
ls -l ftl_input_code_ftl.$FS |
2813 |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
cat ftl_input_code_ftl.$FS | sed -f \$(TOOLSDIR)/adjoint_sed > ftl_taf_output.$FS |
2814 |
|
|
2815 |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
ftl_taf: ftl_taf_output.o \$(OBJFILES) |
2847 |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h |
2848 |
-rm -f ftl_config.template |
-rm -f ftl_config.template |
2849 |
|
|
2850 |
#========================================= |
EOF |
2851 |
|
|
2852 |
|
fi |
2853 |
|
|
2854 |
|
#=== for OpenAD ======================== |
2855 |
|
|
2856 |
|
if test "x$OPENAD" != x ; then |
2857 |
|
|
2858 |
|
# ============ begin OpenAD specific section ============== |
2859 |
|
|
2860 |
|
cat >>$MAKEFILE <<EOF |
2861 |
|
|
2862 |
|
# all the source files linked from the various locations: |
2863 |
|
ALL_LINKED_FILES= \ |
2864 |
|
\$(F77_SRC_FILES) \ |
2865 |
|
\$(C_SRC_FILES) \ |
2866 |
|
\$(H_SRC_FILES) \ |
2867 |
|
\$(F90_SRC_FILES) \ |
2868 |
|
\$(SPECIAL_FILES) |
2869 |
|
|
2870 |
|
ifndef OPENADROOT |
2871 |
|
\$(error "Error: environment variable OPENADROOT not defined!") |
2872 |
|
endif |
2873 |
|
|
2874 |
|
ifndef XAIFSCHEMAROOT |
2875 |
|
\$(error "Error: environment variable XAIFSCHEMAROOT not defined!") |
2876 |
|
endif |
2877 |
|
|
2878 |
|
ifndef XAIFBOOSTERROOT |
2879 |
|
\$(error "Error: environment variable XAIFBOOSTERROOT not defined!") |
2880 |
|
endif |
2881 |
|
|
2882 |
|
EOF |
2883 |
|
|
2884 |
|
echo " Add the source list for common block to module conversion " |
2885 |
|
echo >> $MAKEFILE |
2886 |
|
printf "CB2M_F90_SRC_NAMES = " >> $MAKEFILE |
2887 |
|
for i in `cat ${OAD_CB2M_FILES}` ; do |
2888 |
|
echo " \\" >> $MAKEFILE |
2889 |
|
printf " $i" >> $MAKEFILE |
2890 |
|
done |
2891 |
|
echo >> $MAKEFILE |
2892 |
|
|
2893 |
|
echo " Add the source list for AD code generation" |
2894 |
|
echo >> $MAKEFILE |
2895 |
|
printf "AD_FILES = " >> $MAKEFILE |
2896 |
|
for i in `cat ${OAD_CB2M_FILES}` ; do |
2897 |
|
echo " \\" >> $MAKEFILE |
2898 |
|
printf " ${i}_mod.f$FS90" >> $MAKEFILE |
2899 |
|
done |
2900 |
|
AD_FILES=`cat adSrcFiles.tmp` |
2901 |
|
for i in $AD_FILES ; do |
2902 |
|
basename=${i%%.f} |
2903 |
|
toBeIgnored=`egrep ^$basename'[ ]*' ${OAD_DONT_COMPILE} ${OAD_DONT_TRANSFORM}` |
2904 |
|
if test -z "$toBeIgnored" ; then |
2905 |
|
echo " \\" >> $MAKEFILE |
2906 |
|
printf " $i" >> $MAKEFILE |
2907 |
|
fi |
2908 |
|
done |
2909 |
|
echo >> $MAKEFILE |
2910 |
|
rm -f adSrcFiles.tmp |
2911 |
|
|
2912 |
|
cat >>$MAKEFILE <<EOF |
2913 |
|
|
2914 |
|
adAll: \$(EXE_AD) |
2915 |
|
.PHONY: adAll |
2916 |
|
|
2917 |
|
CB2M_F90_PP_SRC_FILES=\$(addsuffix _mod.f$FS90, \$(CB2M_F90_SRC_NAMES)) |
2918 |
|
|
2919 |
|
.PRECIOUS: \$(CB2M_F90_PP_SRC_FILES) \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) |
2920 |
|
|
2921 |
|
.PHONY: adDepend |
2922 |
|
adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90) |
2923 |
|
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) |
2924 |
|
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
2925 |
|
-rm -f makedepend.out |
2926 |
|
|
2927 |
|
OPENAD_SUPPORT_F90_SRC_FILES = \ |
2928 |
|
w2f__types.F90 \ |
2929 |
|
OAD_active.F90 \ |
2930 |
|
OAD_cp.F90 \ |
2931 |
|
OAD_rev.F90 \ |
2932 |
|
OAD_tape.F90 |
2933 |
|
|
2934 |
|
OPENAD_SUPPORT_C_SRC_FILES = \ |
2935 |
|
iaddr.c \ |
2936 |
|
timeRatio.c |
2937 |
|
|
2938 |
|
f95_test_mods.f90: \$(OPENAD_SUPPORT_F90_SRC_FILES:F90=$FS90) |
2939 |
|
cat \$^ > \$@ |
2940 |
|
|
2941 |
|
f95_test.f90: all_mods.xb.x2w.w2f.pp.f$FS90 \$(NON_AD_F77_SRC_FILES:.F=_cb2m.f$FS90) ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
2942 |
|
cat \$^ > \$@ |
2943 |
|
|
2944 |
|
f95_test.out: f95_test_mods.f90 f95_test.f90 |
2945 |
|
f95 -fixed -w=unused -maxcontin=132 -c f95_test_mods.f90 > \$@ 2>&1 |
2946 |
|
f95 -fixed -w=unused -maxcontin=132 -c -fixed f95_test.f90 >> \$@ 2>&1 |
2947 |
|
|
2948 |
|
AD_OBJ_FILES=\$(OPENAD_SUPPORT_F90_SRC_FILES:.F90=.o) \$(OPENAD_SUPPORT_C_SRC_FILES:.c=.o) all_mods.xb.x2w.w2f.pp.o ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.o \$(NON_AD_F77_SRC_FILES:.F=_cb2m.o) \$(C_SRC_FILES:.c=.o) \$(F90_SRC_FILES:.F90=.o) |
2949 |
|
|
2950 |
|
\$(EXE_AD): \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(AD_OBJ_FILES) |
2951 |
|
@echo Creating \$@ ... |
2952 |
|
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(AD_OBJ_FILES) \$(LIBS) |
2953 |
|
|
2954 |
|
# makefile debug rule |
2955 |
|
openad: ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
2956 |
|
.PHONY: openad |
2957 |
|
|
2958 |
|
# create the module files |
2959 |
|
%_mod.FF90 : %.h ../OAD_support/cb2mGetModules.csh ../OAD_support/cb2mGetModules.awk |
2960 |
|
../OAD_support/cb2mGetModules.csh $< ../OAD_support/cb2mGetModules.awk |
2961 |
|
|
2962 |
|
# create the header files |
2963 |
|
%_mod.h : %.h ../OAD_support/cb2mGetHeaders.csh ../OAD_support/cb2mGetHeaders.awk |
2964 |
|
../OAD_support/cb2mGetHeaders.csh $< ../OAD_support/cb2mGetHeaders.awk \$(CB2M_F90_SRC_NAMES) |
2965 |
|
|
2966 |
|
# change everybody else to use the new module files: |
2967 |
|
%_cb2m.FF90 : %.F ../OAD_support/cb2mUseModules.bash |
2968 |
|
../OAD_support/cb2mUseModules.bash $< ${MPI} |
2969 |
|
|
2970 |
|
# makefile debug rule |
2971 |
|
small_f: \$(CB2M_F90_PP_SRC_FILES) |
2972 |
|
.PHONY: small_f |
2973 |
|
|
2974 |
|
ad_output.txt: \$(EXE_AD) |
2975 |
|
@printf 'linking data files ... ' |
2976 |
|
\$(LN) -f ../input_ad/data* ../input_ad/eedata . |
2977 |
|
\$(LN) -f ../../global_ocean.90x40x15/input/*.bin . |
2978 |
|
@printf 'running ... ' |
2979 |
|
@./\$(EXE_AD) > \$@ |
2980 |
|
|
2981 |
|
CB2M_AD_FILES=\$(AD_FILES:.f=_cb2m.f$FS90) |
2982 |
|
ad_input_code.f$FS90: ../OAD_support/maxMinDefs.f \$(CB2M_AD_FILES) |
2983 |
|
cat \$^ > \$@ |
2984 |
|
|
2985 |
|
# strip all comments and blanks to reduce |
2986 |
|
# the file size in order to reduce perl's memory requirements |
2987 |
|
ad_input_code_sf.f$FS90 : ad_input_code.f$FS90 |
2988 |
|
cat \$^ | sed -f ../OAD_support/strip.sed | sed -f ../OAD_support/stop2print.sed > \$@ |
2989 |
|
|
2990 |
|
# mfef90 preprocessing |
2991 |
|
# expand statement functions |
2992 |
|
# expose mfef90 specific substring handling |
2993 |
|
# add the w2f__types module |
2994 |
|
ad_input_code_sf.w2f.f$FS90: ad_input_code_sf.f$FS90 mfef90 whirl2f whirl2f_be w2f__types.f90 |
2995 |
|
./mfef90 -r8 -z -F -N132 \$< |
2996 |
|
mv \$<.B \$(basename \$<).B |
2997 |
|
./whirl2f -openad \$(basename \$<).B |
2998 |
|
cat w2f__types.f90 \$(basename \$<).w2f.f > \$@ |
2999 |
|
|
3000 |
|
# canonicalizer |
3001 |
|
ad_input_code_sf.w2f.canon.f$FS90: ad_input_code_sf.w2f.f$FS90 canon.v1.py |
3002 |
|
python canon.v1.py --r8 \$< > \$@ |
3003 |
|
|
3004 |
|
# F -> WHIRL |
3005 |
|
# note that the canonicalized version cuts off at col 72 |
3006 |
|
# doing this also for string constants which is ok as long |
3007 |
|
# as we are in fixed mode and cut of exactly there. |
3008 |
|
# Otherwise mfef90 patches in spaces to fill up to 72 (or 132) |
3009 |
|
# characters respectively. |
3010 |
|
ad_input_code_sf.w2f.canon.B: ad_input_code_sf.w2f.canon.f$FS90 mfef90 |
3011 |
|
./mfef90 -r8 -z -F \$< |
3012 |
|
mv \$<.B \$@ |
3013 |
|
|
3014 |
|
# WHIRL -> XAIF |
3015 |
|
ad_input_code_sf.w2f.canon.xaif : ad_input_code_sf.w2f.canon.B whirl2xaif |
3016 |
|
./whirl2xaif -s -n --debug 1 -o \$@ \$< |
3017 |
|
|
3018 |
|
# XAIF -> XAIF' |
3019 |
|
ad_input_code_sf.w2f.canon.xb.xaif : ad_input_code_sf.w2f.canon.xaif xaif.xsd xaif_base.xsd xaif_inlinable_intrinsics.xsd xaif_derivative_propagator.xsd xaif_output.xsd openad_adm |
3020 |
|
./openad_adm -f -t forward_step -i \$< -c \${XAIFSCHEMAROOT}/schema/examples/inlinable_intrinsics.xaif -o \$@ -I -r |
3021 |
|
|
3022 |
|
# XAIF' -> WHIRL' |
3023 |
|
ad_input_code_sf.w2f.canon.xb.x2w.B : ad_input_code_sf.w2f.canon.xb.xaif xaif2whirl |
3024 |
|
./xaif2whirl --debug 1 --structured ad_input_code_sf.w2f.canon.B \$< |
3025 |
|
|
3026 |
|
# WHIRL' -> F' |
3027 |
|
ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.B whirl2f whirl2f_be |
3028 |
|
./whirl2f -FLIST:ftn_file=\$@ -openad \$< |
3029 |
|
|
3030 |
|
# undo slice hiding |
3031 |
|
# insert template directives |
3032 |
|
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.f$FS90 reslicer.py ../OAD_support/insertTemplateDir.bash |
3033 |
|
python reslicer.py \$< > \$<.1 |
3034 |
|
../OAD_support/insertTemplateDir.bash \$<.1 \$@ |
3035 |
|
rm \$<.1 |
3036 |
|
|
3037 |
|
# postprocess F' |
3038 |
|
ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.f$FS90 multi-pp.pl ../OAD_support/ad_inline.f \$(wildcard ../OAD_support/ad_template.*.f) |
3039 |
|
perl multi-pp.pl -inline=../OAD_support/ad_inline.f \$< |
3040 |
|
# the postprocessor still gets the name wrong |
3041 |
|
cat \$<.pp | sed 's/RETURN//' > \$@ |
3042 |
|
|
3043 |
|
# extract all transformed modules |
3044 |
|
all_mods.xb.x2w.w2f.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
3045 |
|
cat \$< | sed -n '/MODULE /,/END MODULE/p' > \$@ |
3046 |
|
|
3047 |
|
# remove the transformed globals module from the |
3048 |
|
# transformed ad_input_code file |
3049 |
|
# and remove for now the duplicate variables |
3050 |
|
# and fix 2 data statements |
3051 |
|
ad_input_code.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90: ad_input_code_sf.w2f.canon.xb.x2w.w2f.rs.pp.f$FS90 |
3052 |
|
cat \$< | sed '/MODULE /,/END MODULE/d' | sed '/^ INTEGER(w2f__i4) DOLOOP_UB/d' > \$@ |
3053 |
|
|
3054 |
|
# setup some links |
3055 |
|
%.xsd: |
3056 |
|
\$(LN) \${XAIFSCHEMAROOT}/schema/\$@ . |
3057 |
|
|
3058 |
|
mfef90: |
3059 |
|
\$(LN) \${OPEN64ROOT}/crayf90/sgi/mfef90 . |
3060 |
|
|
3061 |
|
# link the support files: |
3062 |
|
\$(OPENAD_SUPPORT_F90_SRC_FILES) \$(OPENAD_SUPPORT_C_SRC_FILES): |
3063 |
|
\$(LN) ../OAD_support/\$@ . |
3064 |
|
|
3065 |
|
whirl2xaif xaif2whirl: |
3066 |
|
\$(LN) \${OPENADFORTTK}/bin/\$@ . |
3067 |
|
|
3068 |
|
%.pl: |
3069 |
|
\$(LN) \${OPENADFORTTK}/bin/\$@ . |
3070 |
|
|
3071 |
|
%.py: |
3072 |
|
\$(LN) \${OPENADROOT}/OpenADFortTk/tools/canonicalize/\$@ . |
3073 |
|
|
3074 |
|
whirl2f whirl2f_be: |
3075 |
|
\$(LN) \${OPEN64ROOT}/whirl2f/\$@ . |
3076 |
|
|
3077 |
|
openad_adm: |
3078 |
|
\$(LN) \${XAIFBOOSTERROOT}/xaifBooster/algorithms/BasicBlockPreaccumulationReverse/test/t \$@ |
3079 |
|
|
3080 |
|
# ============ end OpenAD specific section ============== |
3081 |
|
|
3082 |
EOF |
EOF |
3083 |
|
|
3084 |
|
fi |
3085 |
|
|
3086 |
|
#========================================= |
3087 |
|
|
3088 |
if test "x$EXEHOOK" != x ; then |
if test "x$EXEHOOK" != x ; then |
3089 |
printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE |
printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE |
3090 |
fi |
fi |