1. lapack-3.7.1をダウンロード
2. tar zxvf lapack-3.7.1.tgz
3. cp make.inc.example make.inc
4. make.incの編集
FORTRAN = gfortran FORTRAN = pgf90 #OPTS = -O2 -frecursive OPTS = -O3 DRVOPTS = $(OPTS) #NOOPT = -O0 -frecursive NOOPT =
# Define LOADER and LOADOPTS to refer to the loader and desired # load options for your machine. # #LOADER = gfortran LOADER = pgf90 LOADOPTS =
5. lapack-3.7.1/INSTALL の second_INT_ETIME.f dsecond_INT_ETIME.f の編集
* INTRINSIC ETIME
のように ETIMEを内部関数宣言をコメントアウトする
6. コンパイル実行
make blaslib make lapacklib make tmglib
を実行する
7. root権限で、 /usr/local/lapack-3.7.1 を作成する
8. 作成された ライブラリーを名前を変更して保存
sudo cp librefblas.a /usr/local/lapack-3.7.1/lib/libblas.a sudo cp liblapack.a /usr/local/lapack-3.7.1/lib/liblapack.a sudo cp libtmglib.a /usr/local/lapack-3.7.1/lib/libtmg.a
9. このままだと fortran77 でしか利用できないので、LAPACK95を追加でインストールする
http://www.netlib.org/lapack95/
10. lapack95.tgz の解凍
11. モジュール保存用ディレクトリの作成
cd LAPACK95/ mkdir lapack95_modules
12. make.incの編集 およびコンパイル
#FC = f95 -free #FC1 = f95 -fixed FC = pgf90 FC1 = pgf90 # -dcfuns Enable recognition of non-standard double # precision complex intrinsic functions # -dusty Allows the compilation and execution of "legacy" # software by downgrading the category of common # errors found in such software from "Error" to # -ieee=full enables all IEEE arithmetic facilities # including non-stop arithmetic. #OPTS0 = -u -V -dcfuns -dusty -ieee=full OPTS0 = -O3 MODLIB = -I./../lapack95_modules OPTS1 = -c $(OPTS0) OPTS3 = $(OPTS1) $(MODLIB) OPTL = -o OPTLIB = #LAPACK_PATH = /usr/local/lib/LAPACK3/ LAPACK_PATH = /usr/local/lapack-3.7.1/lib LAPACK95 = ../lapack95.a #LAPACK77 = $(LAPACK_PATH)/lapack.a #TMG77 = $(LAPACK_PATH)/tmglib.a #BLAS = $(LAPACK_PATH)/blas.a LAPACK77 = $(LAPACK_PATH)/liblapack.a TMG77 = $(LAPACK_PATH)/libtmg.a BLAS = $(LAPACK_PATH)/libblas.a
make single_double_complex_dcomplex
として、コンパイルする
13. 作成されたモジュール(lapack_95_modulesの中に4つ作成されている)とライブラリ(lapack95.a)をコピー
sudo mkdir /usr/local/lapack-3.7.1/include sudo cp ./lapack_95_modules/* /usr/local/lapack-3.7.1/include sudo cp ./lapack95.a /usr/local/lapack-3.7.1/lib/liblapack95.a
14. 他のfortranで利用する場合には、
pgf90 test.f90 -I/usr/local/lapack-3.7.1/include/ -L/usr/local/lapack-3.7.1/lib -llapack95 -llapack -lblas
のようにしてコンパイルする
または、コンパイルとリンクを分ける場合には、
pgf90 -c test.f90 -I/usr/local/lapack-3.7.1/module pgf90 test.o -L/usr/local/lapack-3.7.1/lib -llapack95 -llapack -lblas -o EOF_exe
のようにする。これら2つの場合において、-llapack95 -llapack -lblas の順番を守る必要がある。
また test.f90 では
program test implicit none integer,parameter :: kz = 30 real*8 ecopy(1:kz,1:kz) real*8 lcopy(1:kz) real*8 work_array(1:3*kz-1) integer work integer info call dsyev( 'V', 'U', kz, ecopy, kz, lcopy, work_array, work, info ) stop end program test
のように、特にuse や includeなどを書く必要は無いようです。