以前のリビジョンの文書です
http://accc.riken.jp/HPC/training/text.html
http://www.k.mei.titech.ac.jp/~stamura/NumericalComputation-Tips.html これくらいオプションをつけて実行すれば,だいたいエラーは検出されそう.
ifort -check all -warn declarations -CB -fpe0 -traceback
コンパイラオプションも参照のこと
デフォルトのスタックサイズが小さすぎて、-openmpをやるときはスタックサイズを増やしてあげないと、頻繁にセグ落ちする。
!$OMP parallel write(*,*) KMP_GET_STACKSIZE_S() !$OMP end parallel
とやると、各スレッドのスタックサイズを返す。これを増やす場合は、最初の!$OMPの前に、
CALL KMP_SET_STACKSIZE_S(size)
とやれば良い。sizeは整数型の変数。所望のスタックサイズ(byte)を書けばよい。
ifortでは出力時に勝手に改行する仕様になっている。 改行を抑制するためには、Format文を使用すればよい。
適当なやり方。
write(*,'(100f)') a(:)
きちんとしたやり方。以下2chより引用。
http://pc12.2ch.net/test/read.cgi/tech/1163319215/532
532 名前:デフォルトの名無しさん [sage]: 2009/03/27(金) 05:59:41 亀だけど、Ifortなら<>がお勧め。 多次元配列の最初の数を入れることが多いです 例 program main implicit none integer,parameter :: num = 9 integer :: ii,jj real :: arry(num,num) do ii=1,num do jj = 1,num arry(ii,jj) = ii*jj enddo enddo write(6,'(<num>F)') arry end program
ifort Version 12.0では以下のようにすれば動いた.
ifort hoge.f90 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
ver 11くらい
ifort file.f90 -lmkl -lmkl_lapack -lmkl_em64t -lguide -lmkl_solver
$ cd /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/ $ sudo gnome-terminal
新しく開いた端末で作業1)。
# . /opt/intel/Compiler/11.0/074/bin/ifortvars.sh intel64 # make libem64t # exit
コードのサンプルは /opt/intel/mkl/10.1.0.015/examples/lapack95/source/ にあり。ここではgesv.f90を参考にしながら説明。
(2010.06.22追記)最近のver.はライブラリの場所が変わったようだ.(というか今まで間違ったファイルを使ってだけかも….) Fortran90でLapack95使ったときのコンパイルコマンド.file.f90のところは適当に修正して下さい.
ifort file.f90 -L/opt/intel/Compiler/11.1/069/mkl/lib/em64t/ -I /opt/intel/Compiler/11.1/069/mkl/include/em64t/lp64/ -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread -O2
以下,古い情報
$ ifort /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/source/gesv.f90 -L/opt/intel/Compiler/11.0/074/mkl/examples/lapack95/lib/em64t/ -I /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/lib/em64t -lmkl_lapack95 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread $ ./a.out < /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/data/gesv.d
ifort /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/source/gesv.f90 -L/opt/intel/Compiler/11.0/074/mkl/examples/lapack95/lib/32 -I /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/lib/32/ -lmkl_lapack95 -lmkl_intel -lmkl_intel_thread -lmkl_core -lguide -lpthread $ ./a.out < /opt/intel/Compiler/11.0/074/mkl/examples/lapack95/data/gesv.d
/opt/intel/mkl/10.1.0.015/examples/lapack95/source/gesv.f90 の最初
USE MKL95_PRECISION, ONLY: WP => SP USE MKL95_LAPACK, ONLY: GESV
/opt/intel/mkl/10.1.0.015/examples/lapack95/source/gesv.f90 の中頃
CALL GESV( A, B )
CALL GESV( AA, BB(:,1), IPIV, INFO )
$ cd /opt/intel/Compiler/11.0/074/mkl/interfaces/blas95 $ sudo gnome-terminal
# . /opt/intel/Compiler/11.0/074/bin/ifortvars.sh intel64 # make libem64t # exit
コードのサンプルは /opt/intel/Compiler/11.0/074/mkl/examples/blas95/source/ にあり。ここでは dgemmx.f90を参考にしながら説明。
$ ifort /opt/intel/Compiler/11.0/074/mkl/include/mkl_blas.f90 /opt/intel/Compiler/11.0/074/mkl/examples/blas95/source/dgemmx.f90 /opt/intel/Compiler/11.0/074/mkl/examples/blas95/source/common_func.f -lmkl_blas95 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread $ ./a.out < /opt/intel/Compiler/11.0/074/mkl/examples/blas/data/dgemmx.d
/opt/intel/Compiler/11.0/074/mkl/examples/blas95/source/dgemmx.f90 のはじめのあたり。
use mkl95_precision, only: wp => dp use mkl95_blas, only: gemm
$ ifort hoge.f90 -lmkl_solver_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
$ ifort hoge.f90 -lmkl_solver -lmkl_intel -lmkl_intel_thread -lmkl_core -lguide -lpthread
$ifort pardiso.f90 /opt/intel/Compiler/11.0/074/mkl/include/mkl_pardiso.f90 -lmkl_solver -lmkl_intel -lmkl_intel_thread -lmkl_core -lguide -lpthread
f77のコードは /opt/intel/Compiler/11.0/074/mkl/examples/solver/source/ 内にあり。
include 'mkl_pardiso.f90' program pardiso_test use MKL_PARDISO implicit none real(8),allocatable::a(:),b(:),x(:) integer::maxfct=1,mnum=1,mtype,phase=13,n,nzero,nrhs=1,iparm(64),msglvl=0,error type(mkl_pardiso_handle) :: pt(64) integer i,j integer,allocatable::ia(:),ja(:),perm(:) !!! this matrix is quoted by slatec document... ! |11 12 0 0 15| A: 11 12 15 | 21 22 | 33 35 | 44 | 51 53 55 ! |21 22 0 0 0| IA: 1 | 4 | 6 | 8 | 9 | 12 ! | 0 0 33 0 35| JA: 1 2 5 | 1 2 | 3 5 | 4 | 1 3 5 ! | 0 0 0 44 0| ! |51 0 53 0 55| !!! set parameter of pardiso pt(:)=mkl_pardiso_handle(0) iparm(1)=0 mtype=11 !!! assign values to variables n=5 nzero=11 allocate(a(nzero),b(n),x(n),ia(n+1),ja(nzero),perm(n)) ia(:)=(/1,4,6,8,9,12/) a(:)=(/11.d0,12.d0,15.d0,21.d0,22.d0,33.d0,35.d0,44.d0,51.d0,53.d0,55.d0/) ja(:)=(/1,2,5,1,2,3,5,4,1,3,5/) !!! calculate b when x=(/1.d0,2.d0,3.d0,4.d0,5.d0/) b(:)=0.d0 do i=1,5 do j=ia(i),ia(i+1)-1 b(i)=b(i)+a(j)*ja(j) end do end do !!! solve linear equation by pardiso call pardiso(pt,maxfct,mnum,mtype,phase,n,a,ia,ja,perm,nrhs,iparm,msglvl,b,x,error) if(error /= 0) then write(*,*) error stop end if write(*,*) x end program pardiso_test
fortran90のサンプルを書き換え。
program pardiso_test implicit none integer lzero,l parameter (lzero=11,l=5) real*8 a(lzero),b(l),x(l) integer maxfct,mnum,mtype,phase,n,nzero,nrhs,iparm(64), $ msglvl,error,pt(64),ia(l+1),ja(lzero),perm(l),i,j data ia /1,4,6,8,9,12/ data ja /1,2,5,1,2,3,5,4,1,3,5/ data a /11.d0,12.d0,15.d0,21.d0,22.d0,33.d0,35.d0, $ 44.d0,51.d0,53.d0,55.d0/ ccc this matrix is quoted by slatec document... c |11 12 0 0 15| A: 11 12 15 | 21 22 | 33 35 | 44 | 51 53 55 c |21 22 0 0 0| IA: 1 | 4 | 6 | 8 | 9 | 12 c | 0 0 33 0 35| JA: 1 2 5 | 1 2 | 3 5 | 4 | 1 3 5 c | 0 0 0 44 0| c |51 0 53 0 55| ccc set parameter of pardiso do i=1,64 pt(i)=0 end do iparm(1)=0 mtype=11 maxfct=1 mnum=1 phase=13 nrhs=1 msglvl=0 ccc assign values to variables n=5 nzero=11 ccc calculate b when x=(/1.d0,2.d0,3.d0,4.d0,5.d0/) b(:)=0.d0 do i=1,5 do j=ia(i),ia(i+1)-1 b(i)=b(i)+a(j)*ja(j) end do end do ccc solve linear equation by pardiso call pardiso(pt,maxfct,mnum,mtype,phase,n,a,ia,ja,perm,nrhs, $ iparm,msglvl,b,x,error) if(error /= 0) then write(*,*) error stop end if write(*,*) x end program
前処理を効率的に行えるようGMRESを改良したもの。前処理に反復解法が使える。