76 |
# Check for broken environments (eg. cygwin, MacOSX w/HFS+) that |
# Check for broken environments (eg. cygwin, MacOSX w/HFS+) that |
77 |
# cannot distinguish [*.F/*.F90] from [*.f/*.f90] files. |
# cannot distinguish [*.F/*.F90] from [*.f/*.f90] files. |
78 |
check_for_broken_Ff() { |
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. |
# First check the ability to create a *.F/.f pair. |
90 |
cat <<EOF >> ./hello.F |
cat <<EOF >> genmake_hello.F |
91 |
program hello |
program hello |
92 |
write(*,*) 'hi' |
write(*,*) 'hi' |
93 |
stop |
stop |
94 |
end |
end |
95 |
EOF |
EOF |
96 |
cp ./hello.F ./hello.f |
cp genmake_hello.F "genmake_hello."$tfs > /dev/null 2>&1 |
97 |
RETVAL=$? |
RETVAL=$? |
98 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
99 |
FEXT='fp' |
if test "x$FS" = x ; then |
100 |
F90EXT='fp90' |
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 |
return |
114 |
fi |
fi |
115 |
rm -f ./hello.f |
rm -f genmake_hello.* |
116 |
|
|
117 |
# Then check the ability of ${MAKE} to use the two. |
# 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 |
test -e Makefile && mv -f Makefile Makefile.bak |
126 |
cat <<EOF >> Makefile |
cat <<EOF >> Makefile |
127 |
.SUFFIXES: |
.SUFFIXES: |
128 |
hello.f: hello.F |
genmake_hello.$tfs: genmake_hello.F |
129 |
cp -f hello.F hello.f |
$LN genmake_hello.F genmake_hello.$tfs |
130 |
EOF |
EOF |
131 |
( $MAKE hello.f ) > /dev/null 2>&1 |
$MAKE "genmake_hello."$tfs > /dev/null 2>&1 |
132 |
RETVAL=$? |
RETVAL=$? |
133 |
if test "x$RETVAL" != x0 -o ! -f ./hello.f ; then |
if test "x$RETVAL" != x0 -o ! -e "genmake_hello."$tfs ; then |
134 |
FEXT='fp' |
if test "x$FS" = x ; then |
135 |
F90EXT='fp90' |
FS='fs' |
136 |
return |
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 |
fi |
150 |
rm -f ./hello.f ./hello.F Makefile |
rm -f genmake_hello.* Makefile |
151 |
test -e Makefile && mv -f Makefile.bak Makefile |
test -e Makefile && mv -f Makefile.bak Makefile |
152 |
|
|
153 |
# Both tests passed, so use the default. |
# If we make it here, use the extensions |
154 |
FEXT='F' |
FS=$tfs |
155 |
F90EXT='F90' |
FS90=$tfs9 |
156 |
|
return |
157 |
} |
} |
158 |
|
|
159 |
|
|
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 |
FEXT= |
FS= |
692 |
F90EXT= |
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) |
987 |
fi |
fi |
988 |
|
|
989 |
# Check for broken systems that cannot correctly distinguish *.F and *.f files |
# Check for broken systems that cannot correctly distinguish *.F and *.f files |
990 |
if test "x$FEXT" = x -a "x$F90EXT" = x ; then |
check_for_broken_Ff |
|
check_for_broken_Ff |
|
|
fi |
|
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 |
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 |
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:.'$FEXT'=.f)' >> $MAKEFILE |
echo 'F77FILES = $(SRCFILES:.F=.'$FS')' >> $MAKEFILE |
1752 |
echo 'F90FILES = $(F90SRCFILES:.'$F90EXT'=.f90)' >> $MAKEFILE |
echo 'F90FILES = $(F90SRCFILES:.F=.'$FS90')' >> $MAKEFILE |
1753 |
echo 'OBJFILES = $(SRCFILES:.'$FEXT'=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.'$F90EXT'=.o)' >> $MAKEFILE |
echo 'OBJFILES = $(SRCFILES:.F=.o) $(CSRCFILES:.c=.o) $(F90SRCFILES:.F90=.o)' >> $MAKEFILE |
1754 |
echo >> $MAKEFILE |
echo >> $MAKEFILE |
1755 |
echo '.SUFFIXES:' >> $MAKEFILE |
echo '.SUFFIXES:' >> $MAKEFILE |
1756 |
echo '.SUFFIXES: .o .f .p .'$FEXT' .c .'$F90EXT' .f90' >> $MAKEFILE |
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 |
|
|
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 ( .$FEXT - .f - .o ) |
# The normal chain of rules is ( .F - .$FS - .o ) |
1812 |
.$FEXT.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 |
.$F90EXT.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 ( .$FEXT - .p - .f - .o ) rule-chain |
# Special exceptions that use the ( .F - .p - .$FS - .o ) rule-chain |
1827 |
.$FEXT.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 |
|
|