who can give me an example on how to edit the makefile

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

who can give me an example on how to edit the makefile

Postby rahu07 » Thu May 17, 2012 9:24 am

this is my makefile with lapack,I don't know how to correct it .who can help me .thank you !
!*******************************
FC = ifort
GF = gfortran
FCOPTIM =
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64
LIBDIR =/home/hu/zhaoran/lap_test
LIBS =-L$(LIBDIR) -llapack -lrefblas

OBJECTS1 = main.o

Main : $(OBJECTS1)
$(GF) -o Main $(OBJECTS1) $(CCFLAGS)

clean :
rm *.o

main.o : main.f90
$(GF) -c $(CCFLAGS) main.f90
rahu07
 
Posts: 4
Joined: Thu May 17, 2012 9:01 am

Re: who can give me an example on how to edit the makefile

Postby admin » Thu May 17, 2012 2:08 pm

The following should work

Code: Select all
GF    = gfortran
FCOPTIM =  -O3
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64
LIBDIR =/home/hu/zhaoran/lap_test
LIBS =-L$(LIBDIR) -llapack -lrefblas

OBJECTS1 = main.o

Main : $(OBJECTS1)
   $(GF) $(CCFLAGS) -o Main $(OBJECTS1) $(LIBS)

clean :
   rm *.o

.SUFFIXES: .f90 .o

.f90.o:
   $(GF) $(FCFLAGS) -c $< -o $@
   
admin
Site Admin
 
Posts: 502
Joined: Wed Dec 08, 2004 7:07 pm

Re: who can give me an example on how to edit the makefile

Postby rahu07 » Thu May 17, 2012 8:35 pm

Thank you ,Thank you very much!
but I also have another question. If there many files in the project ,but Iuse the lapack just in the file gmres.f90
how to edit the makefile?
the following is my makefile
--------------------------------------------------------------
FC = ifort
GF = gfortran
FCOPTIM =
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64

OBJECTS1 = module.o BDP.o cg.o coedge.o gas.o\
gmres.o gmres_sai.o intepol.o juhe_peizhi.o main.o \
mesh.o mlfma.o mm_ll.o \
pre.o precon.o sai.o sub.o \
translation.o vvv.o zmn.o


Main : $(OBJECTS1)
$(GF) -o MLFMA1 $(OBJECTS1) $(CCFLAGS)

clean :
rm *.o

module.o : module.f90
$(GF) -c $(CCFLAGS) module.f90
BDP.o : BDP.f90
$(GF) -c $(CCFLAGS) BDP.f90
cg.o : cg.f90
$(GF) -c $(CCFLAGS) cg.f90
coedge.o : coedge.f90
$(GF) -c $(CCFLAGS) coedge.f90
gas.o : gas.f90
$(GF) -c $(CCFLAGS) gas.f90
gmres.o : gmres.f90
$(GF) -c $(CCFLAGS) gmres.f90
gmres_sai.o : gmres_sai.f90
$(GF) -c $(CCFLAGS) gmres_sai.f90
intepol.o : intepol.f90
$(GF) -c $(CCFLAGS) intepol.f90
juhe_peizhi.o : juhe_peizhi.f90
$(GF) -c $(CCFLAGS) juhe_peizhi.f90
main.o : main.f90
$(GF) -c $(CCFLAGS) main.f90
mesh.o : mesh.f90
$(GF) -c $(CCFLAGS) mesh.f90
mlfma.o : mlfma.f90
$(GF) -c $(CCFLAGS) mlfma.f90
mm_ll.o : mm_ll.f90
$(GF) -c $(CCFLAGS) mm_ll.f90

pre.o : pre.f90
$(GF) -c $(CCFLAGS) pre.f90
precon.o : precon.f90
$(GF) -c $(CCFLAGS) precon.f90
sai.o : sai.f90
$(GF) -c $(CCFLAGS) sai.f90
sub.o : sub.f90
$(GF) -c $(CCFLAGS) sub.f90
translation.o : translation.f90
$(GF) -c $(CCFLAGS) translation.f90
vvv.o : vvv.f90
$(GF) -c $(CCFLAGS) vvv.f90
zmn.o : zmn.f90
$(GF) -c $(CCFLAGS) zmn.f90
rahu07
 
Posts: 4
Joined: Thu May 17, 2012 9:01 am

Re: who can give me an example on how to edit the makefile

Postby rahu07 » Thu May 17, 2012 8:45 pm

admin wrote:The following should work

Code: Select all
GF    = gfortran
FCOPTIM =  -O3
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64
LIBDIR =/home/hu/zhaoran/lap_test
LIBS =-L$(LIBDIR) -llapack -lrefblas

OBJECTS1 = main.o

Main : $(OBJECTS1)
   $(GF) $(CCFLAGS) -o Main $(OBJECTS1) $(LIBS)

clean :
   rm *.o

.SUFFIXES: .f90 .o

.f90.o:
   $(GF) $(FCFLAGS) -c $< -o $@
   


Thank you ,Thank you very much!
but I also have another question. If there many files in the project ,but Iuse the lapack just in the file gmres.f90
how to edit the makefile?
the following is my makefile
--------------------------------------------------------------
FC = ifort
GF = gfortran
FCOPTIM =
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64

OBJECTS1 = module.o BDP.o cg.o coedge.o gas.o\
gmres.o gmres_sai.o intepol.o juhe_peizhi.o main.o \
mesh.o mlfma.o mm_ll.o \
pre.o precon.o sai.o sub.o \
translation.o vvv.o zmn.o


Main : $(OBJECTS1)
$(GF) -o MLFMA1 $(OBJECTS1) $(CCFLAGS)

clean :
rm *.o

module.o : module.f90
$(GF) -c $(CCFLAGS) module.f90
BDP.o : BDP.f90
$(GF) -c $(CCFLAGS) BDP.f90
cg.o : cg.f90
$(GF) -c $(CCFLAGS) cg.f90
coedge.o : coedge.f90
$(GF) -c $(CCFLAGS) coedge.f90
gas.o : gas.f90
$(GF) -c $(CCFLAGS) gas.f90
gmres.o : gmres.f90
$(GF) -c $(CCFLAGS) gmres.f90
gmres_sai.o : gmres_sai.f90
$(GF) -c $(CCFLAGS) gmres_sai.f90
intepol.o : intepol.f90
$(GF) -c $(CCFLAGS) intepol.f90
juhe_peizhi.o : juhe_peizhi.f90
$(GF) -c $(CCFLAGS) juhe_peizhi.f90
main.o : main.f90
$(GF) -c $(CCFLAGS) main.f90
mesh.o : mesh.f90
$(GF) -c $(CCFLAGS) mesh.f90
mlfma.o : mlfma.f90
$(GF) -c $(CCFLAGS) mlfma.f90
mm_ll.o : mm_ll.f90
$(GF) -c $(CCFLAGS) mm_ll.f90

pre.o : pre.f90
$(GF) -c $(CCFLAGS) pre.f90
precon.o : precon.f90
$(GF) -c $(CCFLAGS) precon.f90
sai.o : sai.f90
$(GF) -c $(CCFLAGS) sai.f90
sub.o : sub.f90
$(GF) -c $(CCFLAGS) sub.f90
translation.o : translation.f90
$(GF) -c $(CCFLAGS) translation.f90
vvv.o : vvv.f90
$(GF) -c $(CCFLAGS) vvv.f90
zmn.o : zmn.f90
$(GF) -c $(CCFLAGS) zmn.f90
rahu07
 
Posts: 4
Joined: Thu May 17, 2012 9:01 am

Re: who can give me an example on how to edit the makefile

Postby admin » Thu May 17, 2012 9:00 pm

You just have to use a general rule to get .o from .f90 files.
Even If you use only one LAPACK call in only one routine, you will need to link you main executable MLFMA1 with the LAPACK and BLAS libraries,

Try this
Code: Select all
FC = ifort
GF = gfortran
FCOPTIM =
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64
LIBDIR =/home/hu/zhaoran/lap_test
LIBS =-L$(LIBDIR) -llapack -lrefblas

OBJECTS1 = module.o BDP.o cg.o coedge.o gas.o\
gmres.o gmres_sai.o intepol.o juhe_peizhi.o main.o \
mesh.o mlfma.o mm_ll.o \
pre.o precon.o sai.o sub.o \
translation.o vvv.o zmn.o


Main : $(OBJECTS1)
$(GF)  $(CCFLAGS) -o MLFMA1 $(OBJECTS1) $(LIBS)

clean :
rm *.o

.SUFFIXES: .f90 .o

.f90.o:
   $(GF) $(FCFLAGS) -c $< -o $@
admin
Site Admin
 
Posts: 502
Joined: Wed Dec 08, 2004 7:07 pm

Re: who can give me an example on how to edit the makefile

Postby rahu07 » Thu May 17, 2012 9:12 pm

admin wrote:You just have to use a general rule to get .o from .f90 files.
Even If you use only one LAPACK call in only one routine, you will need to link you main executable MLFMA1 with the LAPACK and BLAS libraries,

Try this
Code: Select all
FC = ifort
GF = gfortran
FCOPTIM =
FCFLAGS = $(FCOPTIM)
CCFLAGS = -O3 -m64
LIBDIR =/home/hu/zhaoran/lap_test
LIBS =-L$(LIBDIR) -llapack -lrefblas

OBJECTS1 = module.o BDP.o cg.o coedge.o gas.o\
gmres.o gmres_sai.o intepol.o juhe_peizhi.o main.o \
mesh.o mlfma.o mm_ll.o \
pre.o precon.o sai.o sub.o \
translation.o vvv.o zmn.o


Main : $(OBJECTS1)
$(GF)  $(CCFLAGS) -o MLFMA1 $(OBJECTS1) $(LIBS)

clean :
rm *.o

.SUFFIXES: .f90 .o

.f90.o:
   $(GF) $(FCFLAGS) -c $< -o $@


Yes ,thanks for your advice ! thank you very much!!
rahu07
 
Posts: 4
Joined: Thu May 17, 2012 9:01 am


Return to Linking Problem

Who is online

Users browsing this forum: No registered users and 1 guest

cron