From: Craig Powers on
Ron Shepard wrote:
> In article
> <cfd4dd2d-9f17-4322-ba9c-90c2c6ecf35d(a)w27g2000pre.googlegroups.com>,
> LQH <luuquanghung(a)gmail.com> wrote:
>
>> TARGET = ../exe
>> FC = f90
>> FFLAGS =
>> OBJS = \
>> commons.o \
>> main.o
>> .f90.o:
>> ${FC} -c ${FFLAGS} ${OBJS} $< -o $@
>> main.o : commons.o
>> .SUFFIXES :
>> .SUFFIXES : .o .f90
>> ${TARGET} : ${OBJS}
>> ${FC} ${FFLAGS} ${OBJS} -o $@
>
> It is difficult to debug makefiles in newsgroups because of the
> nonprinting characters. However, I think the problem is the .f90.o
> implicit rule. This line should begin with a tab character, and it
> incorrectly references ${OBS}. I think it should be something like
>
> <tab>${FC} -c ${FFLAGS} -o $@ $<
>
> Similarly, the last line should be something like
>
> <tab>${FC} ${FFLAGS} -o $@ $<

I would have thought that the last line is OK as is. At any rate, it's
roughly how my (working) Makefile does the target for doing the linking
of the objects:
<tab>$(FC) $(OPTFLAGS) -o $(BINDIR)/$(EXEC_NAME) $(OBJS) $(LIBS)
$(LINKFLAGS)

(all on the same line)

Which does bring me to note, a single FFLAGS is not necessarily
appropriate to handle flags for both the compile and link stage. If
your project ends up using any external libraries, you'll probably want
a variable to include libraries and/or linker options.
From: Louis Krupp on
LQH wrote:
> Hi all,
>
> Thank you for your reply. Unfortunately, none of Ron, DPB or Rudra is
> working for my example.
>
> To make it easier to talk, I have upload these files to this address:
> http://www.vietscholars.com/makefile.zip.
>
> Can you help to correct it or make it work?

You don't say what happens when you try to use your makefile, but I'll
take a wild guess at something that might be a problem. When you type
"make", do you give it a target? If you don't, it defaults to the first
target in the makefile, which is main.o, and not ../exe. To build
.../exe, you might try reordering your makefile to be something like this:

-----

TARGET = ../exe
FC = f90
OBJS = \
commons.o \
main.o

${TARGET} : ${OBJS}
${FC} ${OBJS} -o $@ $<

main.o:main.f90 commons.o
$(FC) -c main.f90

commons.o:commons.f90
$(FC) -c commons.f90

-----

Others here will know more, but this might be a good start. And if it
doesn't work, please report exactly what happens.

Louis
From: Eli Osherovich on
On Feb 1, 2:51 am, LQH <luuquangh...(a)gmail.com> wrote:
> Hi all,
>
> Thank you for your reply. Unfortunately, none of Ron, DPB or Rudra is
> working for my example.
>
> To make it easier to talk, I have upload these files to this address:http://www.vietscholars.com/makefile.zip.
>
> Can you help to correct it or make it work?
>
> Thank you!
>
> LQH.
>

It works for me. Though I replaced f90 with gfortran since this is how
my compiler is called.
From: LQH on
I recheck the complier issue, and suddently found out that the
compiler is the problem.

We use the Lahey/Fujitsu Fortran HPC version. It includes two part,
the normal: frt (f90/f77), and the parallel mpifrt.

After switch to the mpifrt, it works. When both of them can compile
the fortran program in HPC, only mpifrt could deal with the module
object.

Thank Louis, Eli, and others for nice suggestion.

Good luck!