回 帖 发 新 帖 刷新版面

主题:求问:调用imsl库的Fortran程序之Makefile怎么写?4楼更新错误了

[color=FF0000][color=800080]这是一个调用到imsl库的例子程序:[/color][/color]
! ================ Program start ============== 
! Declare which IMSL functions will be used
!            use numerical_libraries
       USE LSARG_INT
       USE WRRRN_INT
! Declare variables
       PARAMETER (LDA=3, N=3)
       REAL A(LDA,LDA), B(N), X(N)
!
!               Set values for A and B
!
!               A =     (33.0 16.0 72.0)
!                       (-24.0 -10.0 -57.0)
!                       (18.0 -11.0 7.0)
!
!               B =     (129.0 -96.0 8.5)
!
       DATA A/33.0, -24.0, 18.0, 16.0, -10.0, -11.0, 72.0, -57.0, 7.0/
       DATA B/129.0, -96.0, 8.5/
!
! The main IMSL function call to solve for x in Ax=B.
! This is the floating point version, to use double-precision, call DLSARG.
!
       CALL LSARG(A,B,X)

! Now print the solution x using WRRRN, a printing utility

       CALL WRRRN('X',X,1,N,1)
       END
! ================ Program End ==============

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
[color=FF0000]我的Makefile:[/color]

# The compiler
FC=ifort
F90=ifort
# Compiler options

FFLAGS="-openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include"
F90FLAGS="$FFLAGS"
FCFLAGS="$F90FLAGS"

INTEL_INCLUDE = -I/opt/intel/Compiler/11.1/059/include/intel64:/opt/intel/Compiler/11.1/059/include/ia32
IMSL_INCLUDE = -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include
INCLUDE_PATH = $(INTEL_INCLUDE) $(IMSL_INCLUDE)

# List of executables to be built within the package
PROGRAMS = imsl-test

# "make" builds all
all: $(PROGRAMS)

imsl-test.o: imsl-test.f

%.o: %.f
    $(FC) $(F90FLAGS) $(INCLUDE_PATH) -c $(LINK_F90)

# Utility targets
.PHONY: clean veryclean

clean:
    rm -f *.o *.mod *.MOD

veryclean: clean
    rm -f *~ $(PROGRAMS)
    
#######################################

[color=FF00FF]补充说明:不用Makefile编译程序可以顺利生成a.out文件
ifort $F90FLAGS *.f $LINK_F90[/color]
[color=FF0000]现在的错误提示:[/color]

[dengk001@node14 imsl-test]$ make
ifort "FLAGS" -I/opt/intel/Compiler/11.1/059/include/intel64:/opt/intel/Compiler/11.1/059/include/ia32 -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include -c "INK_FNL"
ifort: error #10236: File not found:  'FLAGS'
ifort: error #10236: File not found:  'INK_FNL'
ifort: command line error: no files specified; for help type "ifort -help"
make: *** [imsl-test.o] 错误 1    

本人很菜,不知道该怎么办,搞了块一个星期了,就这个Makefile写不好,由于文件比较多,所以如果编译的时候一个一个的加太麻烦。希望高手解答!小弟不胜感激!

回复列表 (共9个回复)

沙发

"$FFLAGS" 这种写法不对  要写成$(FFLAGS) 其他类似

FFLAGS="-openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include"
不需要加""

LINK_F90没看见定义

板凳


我按照您说的修改了,但是还是错误:

FFLAGS=-openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include


LD_LIBRARY_PATH = -L/opt/intel/Compiler/11.1/059/lib/intel64:/opt/intel/Compiler/11.1/059/lib/ia32
IMSL_LINK = -L/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/lib
LIB_ARCH=/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64

LINK_FNL_SHARED=-L$(LIB_ARCH)/lib -Bdynamic -limsl -limslsuperlu -limslscalar -limslblas -limslmpistub -limf -Xlinker -rpath -Xlinker $(FNL_DIR)/$(LIB_ARCH)/li
LINK_FNL_STATIC=-L$(LIB_ARCH)/lib -Bstatic -Wl,--start-group -limsl -limslsuperlu -limslscalar -limslblas -limsls_err -limslmpistub -Wl,--end-group -Bdynamic
LINK_FNL=$(LINK_FNL_SHARED)  


LINK_F90_SHARED=$(LINK_FNL_SHARED)
LINK_F90_STATIC=$(LINK_FNL_STATIC)
LINK_F90=$(LINK_FNL) $(LD_LIBRARY_PATH) $(IMSL_LINK)


错误提示一样的!

3 楼

你的提示错误说明有
'FLAGS'和'INK_FNL'

这俩我都没看见,说明你的makefile不全

4 楼

#$preamble
# A simple hand-made makefile for a package including applications
# built from Fortran 90 sources, taking into account the usual
# dependency cases.

# This makefile works with the GNU make command, the one find on
# GNU/Linux systems and often called gmake on non-GNU systems, if you
# are using an old style make command, please see the file
# Makefile_oldstyle provided with the package.

# ======================================================================
# Let's start with the declarations
# ======================================================================

# The compiler
FC=ifort
F90=ifort

##############################################

FFLAGS=-openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include
F90FLAGS=$(FFLAGS)

#F90FLAGS = -O
#F90FLAGS = -O3 -Wall -frecord-marker=4

###############################################
IMSL_LIB_ARCH=/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64
INTEL_LIB_32=/opt/intel/Compiler/11.1/059/lib/intel64:/opt/intel/Compiler/11.1/059/lib/ia32
INTEL_LIB_64=/opt/intel/Compiler/11.1/059/lib/intel64:/opt/intel/Compiler/11.1/059/lib/intel64

LIBS_DIR= -L$(IMSL_LIB_ARCH)/lib -libimslhpc_s -limsl -limslsuperlu -limslscalar -limslblas -limslmpistub -libimsllapack -L$(INTEL_LIB_32) -L$(INTEL_LIB_64)

LINK_F90= $(LIBS_DIR)

##########################################

IMSL_INCLUDE = -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include
INTEL_INCLUDE_64 = -I/opt/intel/Compiler/11.1/059/include/intel64
INTEL_INCLUDE_32 = -I/opt/intel/Compiler/11.1/059/include/ia32

INCLUDE_DIR = $(IMSL_INCLUDE) $(INTEL_INCLUDE_64) $(INTEL_INCLUDE_32)

##############################################

# List of executables to be built within the package
PROGRAMS = imsl-test

# "make" builds all
all: $(PROGRAMS)


imsl-test:imsl-test.f

%.o: %.f
    $(F90) -c $(F90FLAGS) $(INCLUDE_DIR) $(LINK_F90)

# Utility targets
.PHONY: clean veryclean

clean:
    rm -f *.o *.mod *.MOD

veryclean: clean
    rm -f *~ $(PROGRAMS)    
##############################################################################

程序还是原来的程序!

[color=FF0000][b]错误提示:[/b][/color]
[dengk001@node18 imsl-test]$ make
ifort -openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include   imsl-test.f   -o imsl-test
/tmp/ifortd2bunA.o: In function `MAIN__':
imsl-test.f:(.text+0xd8): undefined reference to `s_lsarg_'
imsl-test.f:(.text+0x150): undefined reference to `s_wrrrn1d_'
make: *** [imsl-test] Error 1
[dengk001@node18 imsl-test]$




5 楼

你这样写

%.o: %.f
    $(F90) -c $(F90FLAGS) $(INCLUDE_DIR) $(LINK_F90)

是啥意思,没有源,怎么生成?连个-o都没有

既然没有链接阶段,那就把-c去掉,-c表示只编译不链接。有-c你得告诉链接器怎么生成代码

看你的output
ifort -openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include   imsl-test.f   -o imsl-test
这行显示我就没在makefile里找到相应的地方。

$(F90) -c $(F90FLAGS) $(INCLUDE_DIR) $(LINK_F90)
表示完全不同



6 楼


那我怎么修改啊,我刚开始写Makefile,没办法,开山弟子

7 楼

如果就一个源程序
all:imsl-test.f
$(F90)  $(F90FLAGS) $(INCLUDE_DIR) $(LINK_F90) imsl-test.f
直接make就得了

多个源代码,如果还链接不同,就改的多了,具体你可以找lapack等开源的源代码,看人家是怎么写的。

8 楼


谢谢你啊,刚刚通过你的指点,通了一点瞧了!!太感谢了,激动!!

9 楼

最终解决了

#$preamble
# A simple hand-made makefile for a package including applications
# built from Fortran 90 sources, taking into account the usual
# dependency cases.

# This makefile works with the GNU make command, the one find on
# GNU/Linux systems and often called gmake on non-GNU systems, if you
# are using an old style make command, please see the file
# Makefile_oldstyle provided with the package.

# ======================================================================
# Let's start with the declarations
# ======================================================================

# The compiler
FC=ifort
F90=ifort

#######################

unlimit=unlimited

##############################################

FFLAGS=-openmp -fp-model precise -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include
F90FLAGS=$(FFLAGS)

#F90FLAGS = -O
#F90FLAGS = -O3 -Wall -frecord-marker=4

###############################################
IMSL_LIB_ARCH=/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/lib
INTEL_LIB_32=/opt/intel/Compiler/11.1/059/lib/intel64:-L/opt/intel/Compiler/11.1/059/lib/ia32
INTEL_LIB_64=/opt/intel/Compiler/11.1/059/lib/intel64:-L/opt/intel/Compiler/11.1/059/lib/intel64

#LIBS_DIR= -L$(IMSL_LIB_ARCH)/lib -libimslhpc_s -limsl -limslsuperlu -limslscalar -limslblas -limslmpistub -libimsllapack -L$(INTEL_LIB_32) -L$(INTEL_LIB_64)
LIBS_DIR= -L$(IMSL_LIB_ARCH) -limsl -limslsuperlu -limslscalar -limslblas -limslmpistub -L$(INTEL_LIB_32) -L$(INTEL_LIB_64)

LINK_F90= $(LIBS_DIR)

##########################################

IMSL_INCLUDE = -I/opt/imsl/imsl/install/imsl/fnl600/rdhin111e64/include
INTEL_INCLUDE_64 = -I/opt/intel/Compiler/11.1/059/include/intel64
INTEL_INCLUDE_32 = -I/opt/intel/Compiler/11.1/059/include/ia32

INCLUDE_DIR = $(IMSL_INCLUDE) $(INTEL_INCLUDE_64) $(INTEL_INCLUDE_32)

##############################################

# List of executables to be built within the package
PROGRAMS = imsl-test.f
# "make" builds all
all: $(PROGRAMS)


#########imsl-test:imsl-test.f

########%.o: %.f
    $(F90) $(F90FLAGS) $(INCLUDE_DIR) $(PROGRAMS) $(LINK_F90) -limf -lm

# Utility targets
.PHONY: clean veryclean

clean:
    rm -f *.o *.mod *.MOD

veryclean: clean
    rm -f *~ $(PROGRAMS)

我来回复

您尚未登录,请登录后再回复。点此登录或注册