73 |
fi |
fi |
74 |
} |
} |
75 |
|
|
76 |
|
# Check for broken environments (eg. cygwin, MacOSX w/HFS+) that |
77 |
|
# cannot distinguish [*.F/*.F90] from [*.f/*.f90] files. |
78 |
|
check_for_broken_Ff() { |
79 |
|
# Do we have defaults for $FS and/or $FS90 ? |
80 |
|
tfs=f |
81 |
|
tfs9=f90 |
82 |
|
if test "x$FS" != x ; then |
83 |
|
tfs="$FS" |
84 |
|
fi |
85 |
|
if test "x$FS90" != x ; then |
86 |
|
tfs9="$FS90" |
87 |
|
fi |
88 |
|
|
89 |
|
# First check the ability to create a *.F/.f pair. |
90 |
|
cat <<EOF >> genmake_hello.F |
91 |
|
program hello |
92 |
|
write(*,*) 'hi' |
93 |
|
stop |
94 |
|
end |
95 |
|
EOF |
96 |
|
cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1 |
97 |
|
RETVAL=$? |
98 |
|
if test "x$RETVAL" != x0 ; then |
99 |
|
if test "x$FS" = x ; then |
100 |
|
FS='fs' |
101 |
|
FS90='fs90' |
102 |
|
check_for_broken_Ff |
103 |
|
else |
104 |
|
cat <<EOF 2>&1 |
105 |
|
ERROR: Your file system cannot distinguish between *.F and *.f files |
106 |
|
(fails the "cp" test) and this program cannot find a suitable |
107 |
|
replacement extension. Please try a different build environment or |
108 |
|
contact the <MITgcm-support@mitgcm.org> list for help. |
109 |
|
|
110 |
|
EOF |
111 |
|
exit -1 |
112 |
|
fi |
113 |
|
return |
114 |
|
fi |
115 |
|
rm -f genmake_hello.* |
116 |
|
|
117 |
|
# Check the ability of ${MAKE} and ${LN} to use the current set |
118 |
|
# of extensions. |
119 |
|
cat <<EOF >> genmake_hello.F |
120 |
|
program hello |
121 |
|
write(*,*) 'hi' |
122 |
|
stop |
123 |
|
end |
124 |
|
EOF |
125 |
|
test -e Makefile && mv -f Makefile Makefile.bak |
126 |
|
cat <<EOF >> Makefile |
127 |
|
.SUFFIXES: |
128 |
|
genmake_hello.$tfs: genmake_hello.F |
129 |
|
$LN genmake_hello.F genmake_hello.$tfs |
130 |
|
EOF |
131 |
|
$MAKE "genmake_hello."$tfs > /dev/null 2>&1 |
132 |
|
RETVAL=$? |
133 |
|
if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then |
134 |
|
if test "x$FS" = x ; then |
135 |
|
FS='fs' |
136 |
|
FS90='fs9' |
137 |
|
check_for_broken_Ff |
138 |
|
else |
139 |
|
cat <<EOF 2>&1 |
140 |
|
ERROR: Your file system cannot distinguish between *.F and *.f files |
141 |
|
(fails the "make/ln" test) and this program cannot find a suitable |
142 |
|
replacement extension. Please try a different build environment or |
143 |
|
contact the <MITgcm-support@mitgcm.org> list for help. |
144 |
|
|
145 |
|
EOF |
146 |
|
exit -1 |
147 |
|
return |
148 |
|
fi |
149 |
|
fi |
150 |
|
rm -f genmake_hello.* Makefile |
151 |
|
test -e Makefile && mv -f Makefile.bak Makefile |
152 |
|
|
153 |
|
# If we make it here, use the extensions |
154 |
|
FS=$tfs |
155 |
|
FS90=$tfs9 |
156 |
|
return |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
# Guess possible config options for this host |
# Guess possible config options for this host |
161 |
find_possible_configs() { |
find_possible_configs() { |
162 |
|
|
581 |
|
|
582 |
|
|
583 |
check_netcdf_libs() { |
check_netcdf_libs() { |
584 |
cat <<EOF > genmake_tnc.F |
cat <<EOF > genmake_tnc.for |
585 |
program fgennc |
program fgennc |
586 |
#include "netcdf.inc" |
#include "netcdf.inc" |
587 |
integer iret, ncid, xid |
integer iret, ncid, xid |
593 |
IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) |
IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret) |
594 |
end |
end |
595 |
EOF |
EOF |
596 |
$CPP genmake_tnc.F > genmake_tnc.f \ |
$CPP genmake_tnc.for > genmake_tnc.f \ |
597 |
&& $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1 |
&& $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f $LIBS >> genmake_tnc.log 2>&1 |
598 |
RET_COMPILE=$? |
RET_COMPILE=$? |
599 |
test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 |
test -x ./genmake_tnc && ./genmake_tnc >> genmake_tnc.log 2>&1 |
602 |
HAVE_NETCDF=t |
HAVE_NETCDF=t |
603 |
else |
else |
604 |
# try again with "-lnetcdf" added to the libs |
# try again with "-lnetcdf" added to the libs |
605 |
$CPP genmake_tnc.F > genmake_tnc.f \ |
$CPP genmake_tnc.for > genmake_tnc.f \ |
606 |
&& $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \ |
&& $FC $FFLAGS $FOPTIM -o genmake_tnc genmake_tnc.f \ |
607 |
$LIBS -lnetcdf >> genmake_tnc_2.log 2>&1 |
$LIBS -lnetcdf >> genmake_tnc_2.log 2>&1 |
608 |
RET_COMPILE=$? |
RET_COMPILE=$? |
688 |
if test "x$MITGCM_IEEE" != x ; then |
if test "x$MITGCM_IEEE" != x ; then |
689 |
IEEE=$MITGCM_IEEE |
IEEE=$MITGCM_IEEE |
690 |
fi |
fi |
691 |
|
FS= |
692 |
|
FS90= |
693 |
|
|
694 |
AUTODIFF_PKG_USED=f |
AUTODIFF_PKG_USED=f |
695 |
AD_OPTFILE= |
AD_OPTFILE= |
867 |
-fc=* | --fc=*) |
-fc=* | --fc=*) |
868 |
FC=$ac_optarg ;; |
FC=$ac_optarg ;; |
869 |
|
|
870 |
|
-fs | --fs) |
871 |
|
ac_prev=FS ;; |
872 |
|
-fs=* | --fs=*) |
873 |
|
FS=$ac_optarg ;; |
874 |
|
|
875 |
|
-fs90 | --fs90) |
876 |
|
ac_prev=FS90 ;; |
877 |
|
-fs90=* | --fs90=*) |
878 |
|
FS90=$ac_optarg ;; |
879 |
|
|
880 |
-ieee | --ieee) |
-ieee | --ieee) |
881 |
IEEE=true ;; |
IEEE=true ;; |
882 |
-noieee | --noieee) |
-noieee | --noieee) |
986 |
fi |
fi |
987 |
fi |
fi |
988 |
|
|
989 |
|
# Check for broken systems that cannot correctly distinguish *.F and *.f files |
990 |
|
check_for_broken_Ff |
991 |
|
|
992 |
echo " getting AD_OPTFILE information: " |
echo " getting AD_OPTFILE information: " |
993 |
if test "x${AD_OPTFILE}" = x ; then |
if test "x${AD_OPTFILE}" = x ; then |
994 |
if test "x$MITGCM_AD_OF" = x ; then |
if test "x$MITGCM_AD_OF" = x ; then |
1042 |
CPP=cpp |
CPP=cpp |
1043 |
fi |
fi |
1044 |
#EH3 === UGLY === |
#EH3 === UGLY === |
1045 |
# The following an ugly little hack to check for $CPP in /lib/ and it |
# The following is an ugly little hack to check for $CPP in /lib/ and |
1046 |
# should eventually be replaced with a more general function that |
# it should eventually be replaced with a more general function that |
1047 |
# searches a combo of the user's path and a list of "usual suspects" |
# searches a combo of the user's path and a list of "usual suspects" |
1048 |
# to find the correct location for binaries such as $CPP. |
# to find the correct location for binaries such as $CPP. |
1049 |
for i in " " "/lib/" ; do |
for i in " " "/lib/" ; do |
1747 |
cat f90srclist.inc >> $MAKEFILE |
cat f90srclist.inc >> $MAKEFILE |
1748 |
cat hlist.inc >> $MAKEFILE |
cat hlist.inc >> $MAKEFILE |
1749 |
cat ad_flow_files.inc >> $MAKEFILE |
cat ad_flow_files.inc >> $MAKEFILE |
1750 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
1751 |
echo 'F77FILES = $(SRCFILES:.F=.f)' >> $MAKEFILE |
echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE |
1752 |
echo 'F90FILES = $(F90SRCFILES:.F90=.f90)' >> $MAKEFILE |
echo 'F90FILES = $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE |
1753 |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1754 |
|
echo >> $MAKEFILE |
1755 |
|
echo '.SUFFIXES:' >> $MAKEFILE |
1756 |
|
echo '.SUFFIXES: .o .F .p .'$FS' .c .F90 .'$FS90 >> $MAKEFILE |
1757 |
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 |
1758 |
rm -f ad_flow_files.inc |
rm -f ad_flow_files.inc |
1759 |
|
|
1760 |
cat >>$MAKEFILE <<EOF |
cat >>$MAKEFILE <<EOF |
1761 |
|
|
|
.SUFFIXES: |
|
|
.SUFFIXES: .o .f .p .F .c .F90 .f90 |
|
|
|
|
1762 |
all: \$(EXECUTABLE) |
all: \$(EXECUTABLE) |
1763 |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) |
\$(EXECUTABLE): \$(SPECIAL_FILES) \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) \$(OBJFILES) |
1764 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
1765 |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) |
1766 |
depend: |
depend: |
1767 |
@make links |
@make links |
1768 |
\$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
\$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(SRCFILES) |
1769 |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) |
1770 |
-rm -f makedepend.out |
-rm -f makedepend.out |
1771 |
|
|
1778 |
@\$(EXECUTABLE) > \$@ |
@\$(EXECUTABLE) > \$@ |
1779 |
|
|
1780 |
clean: |
clean: |
1781 |
-rm -rf *.o *.f *.p *.f90 *.mod ${RMFILES} work.{pc,pcl} *.template |
-rm -rf *.o *.$FS *.p *.$FS90 *.mod ${RMFILES} work.{pc,pcl} *.template |
1782 |
Clean: |
Clean: |
1783 |
@make clean |
@make clean |
1784 |
@make cleanlinks |
@make cleanlinks |
1808 |
@echo Creating \$@ ... |
@echo Creating \$@ ... |
1809 |
echo "$FC_NAMEMANGLE" > \$@ |
echo "$FC_NAMEMANGLE" > \$@ |
1810 |
|
|
1811 |
# The normal chain of rules is ( .F - .f - .o ) |
# The normal chain of rules is ( .F - .$FS - .o ) |
1812 |
.F.f: |
|
1813 |
|
%.o : %.F |
1814 |
|
|
1815 |
|
.F.$FS: |
1816 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1817 |
.f.o: |
.$FS.o: |
1818 |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
\$(FC) \$(FFLAGS) \$(FOPTIM) -c \$< |
1819 |
.F90.f90: |
.F90.$FS90: |
1820 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1821 |
.f90.o: |
.$FS90.o: |
1822 |
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
\$(F90C) \$(F90FLAGS) \$(F90OPTIM) -c \$< |
1823 |
.c.o: |
.c.o: |
1824 |
\$(CC) \$(CFLAGS) -c \$< |
\$(CC) \$(CFLAGS) -c \$< |
1825 |
|
|
1826 |
# Special exceptions that use the ( .F - .p - .f - .o ) rule-chain |
# Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain |
1827 |
.F.p: |
.F.p: |
1828 |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
\$(CPP) \$(DEFINES) \$(INCLUDES) > \$@ |
1829 |
.p.f: |
.p.$FS: |
1830 |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
\$(KPP) \$(KFLAGS1)\$@ \$(KFLAGS2) \$< |
1831 |
|
|
1832 |
#========================================= |
#========================================= |
1951 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
1952 |
echo "Error: unable to add file \"$i\" to the exceptions list" |
echo "Error: unable to add file \"$i\" to the exceptions list" |
1953 |
fi |
fi |
1954 |
echo "$base.f: $base.p" >> $MAKEFILE |
echo "$base.$FS: $base.p" >> $MAKEFILE |
1955 |
done |
done |
1956 |
|
|
1957 |
echo " Making list of NOOPTFILES" |
echo " Making list of NOOPTFILES" |
1961 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
1962 |
echo "Error: unable to add file \"$i\" to the exceptions list" |
echo "Error: unable to add file \"$i\" to the exceptions list" |
1963 |
fi |
fi |
1964 |
echo "$base.o: $base.f" >> $MAKEFILE |
echo "$base.o: $base.$FS" >> $MAKEFILE |
1965 |
printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE |
printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE |
1966 |
done |
done |
1967 |
|
|