ユーザ用ツール

サイト用ツール


fortran:ifort

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
fortran:ifort [2014/10/10 13:10]
goto
fortran:ifort [2017/10/03 12:55] (現在)
ライン 68: ライン 68:
 <code bash> <code bash>
 ifort sample.f90 -mkl ifort sample.f90 -mkl
 +</​code>​
 +====== CSRへの変換 ======
 +pardisoはCSRフォーマットを用いるが,coordinateフォーマットから変換するサブルーチンが用意されている.
 +
 +https://​software.intel.com/​en-us/​node/​468628
 +
 +フォーマットについてはこちらから.
 +
 +https://​software.intel.com/​en-us/​node/​471374
 +
 +Fortranの場合,job(1:​8)に与える数値は以下の通りで(だいたい)OK.
 +|job(1)=1|the matrix in the coordinate format is converted to the CSR format.|
 +|job(2)=1|one-based indexing for the matrix in CSR format is used.|
 +|job(3)=1|one-based indexing for the matrix in coordinate format is used.|
 +|job(4)|特に設定不要|
 +|job(5)=nnz| sets number of the non-zero elements of the matrix A if job(1)=1.|
 +|job(6)=0| all arrays acsr, ja, ia are filled in for the output storage.|
 +
 +<code fortran>
 +
 </​code>​ </​code>​
 ====== pardiso の使い方====== ====== pardiso の使い方======
ライン 73: ライン 93:
  
 スパコンの スパコンの
-<​code ​bash>+<​code>​
 /​opt/​app/​intel/​composer_xe_2013.5.192/​mkl/​examples/​solverf/​source/​ /​opt/​app/​intel/​composer_xe_2013.5.192/​mkl/​examples/​solverf/​source/​
 </​code>​ </​code>​
 に入っているサンプルデータを参考に,走らせたいプログラムを作成する. に入っているサンプルデータを参考に,走らせたいプログラムを作成する.
 +include文が大事.
 +自分のプログラムに
 +<code fortran>
 +include '​mkl_pardiso.f77'​
 +</​code>​
 +
 +<code fortran>
 +include '​mkl_pardiso.f90'​
 +</​code>​
 +を入れる.
  
-中身こんな感じ +配列の設定に注意が必要,詳しく以下を参照 
-<code bash> +[http://www.pardiso-project.org/manual/​manual.pdf]
-      PROGRAM pardiso_unsym +
-      IMPLICIT NONE +
-      include '​mkl_pardiso.f77'​ +
-C.. Internal solver memory pointer for 64-bit architectures +
-C.. INTEGER*8 pt(64) +
-C.. Internal solver memory pointer for 32-bit architectures +
-C.. INTEGER*4 pt(64) +
-C.. This is OK in both cases +
-      INTEGER*8 pt(64) +
-C.. All other variables +
-      INTEGER maxfct, mnum, mtype, phase, n, nrhs, error, msglvl +
-      INTEGER iparm(64) +
-      INTEGER ia(6) +
-      INTEGER ja(13) +
-      REAL*8 a(13) +
-      REAL*8 b(5) +
-      REAL*8 x(5) +
-      INTEGER i, idum(1) +
-      REAL*8 ​ ddum(1) +
-C.. Fill all arrays containing matrix data. +
-      DATA n /5/, nrhs /1/, maxfct /1/, mnum /1/ +
-      DATA ia /​1,​4,​6,​9,​12,​14/​ +
-      DATA ja +
-     1 /   ​1, ​   2,          4, +
-     ​2 ​    ​1, ​   2, +
-     ​3 ​                ​3, ​   4,    5, +
-     ​4 ​    ​1, ​         3,    4, +
-     ​5 ​          ​2, ​               5/ +
-      DATA a +
-     1 /1.d0,-1.d0,      -3.d0, +
-     2 -2.d0, 5.d0, +
-     ​3 ​             4.d0, 6.d0, 4.d0, +
-     4 -4.d0, ​      2.d0, 7.d0, +
-     ​5 ​       8.d0,            -5.d0/ +
-C.+
-C.. Set up PARDISO control parameter +
-C.. +
-      do i = 1, 64 +
-         ​iparm(i) = 0 +
-      end do +
-      iparm(1) = 1 ! no solver default +
-      iparm(2) = 2 ! fill-in reordering from METIS +
-      iparm(3) = 1 ! numbers of processors +
-      iparm(4) = 0 ! no iterative-direct algorithm +
-      iparm(5) = 0 ! no user fill-in reducing permutation +
-      iparm(6) = 0 ! =0 solution on the first n compoments of x +
-      iparm(7) = 0 ! not in use +
-      iparm(8) = 9 ! numbers of iterative refinement steps +
-      iparm(9) = 0 ! not in use +
-      iparm(10) = 13 ! perturbe the pivot elements with 1E-13 +
-      iparm(11) = 1 ! use nonsymmetric permutation and scaling MPS +
-      iparm(12) = 0 ! not in use +
-      iparm(13) = 1 ! maximum weighted matching algorithm is switched-on (default for non-symmetric) +
-      iparm(14) = 0 ! Output: number of perturbed pivots +
-      iparm(15) = 0 ! not in use +
-      iparm(16) = 0 ! not in use +
-      iparm(17) = 0 ! not in use +
-      iparm(18) = -1 ! Output: number of nonzeros in the factor LU +
-      iparm(19) = -1 ! Output: Mflops for LU factorization +
-      iparm(20) = 0 ! Output: Numbers of CG Iterations +
-      error = 0 ! initialize error flag +
-      msglvl = 1 ! print statistical information +
-      mtype = 11 ! real unsymmetric +
-C.. Initiliaze the internal solver memory pointer. This is only +
-C necessary for the FIRST call of the PARDISO solver. +
-      do i = 1, 64 +
-         pt(i) = 0 +
-      end do +
-C.. Reordering and Symbolic Factorization,​ This step also allocates +
-C all memory that is necessary for the factorization +
-      phase = 11 ! only reordering and symbolic factorization +
-      CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, +
-     1 idum, nrhs, iparm, msglvl, ddum, ddum, error) +
-      WRITE(*,*) '​Reordering completed ... ' +
-      IF (error .NE. 0) THEN +
-         ​WRITE(*,​*) 'The following ERROR was detected: ', error +
-         STOP 1 +
-      END IF +
-      WRITE(*,*) '​Number of nonzeros in factors = ',​iparm(18) +
-      WRITE(*,*) '​Number of factorization MFLOPS = ',​iparm(19) +
-C.. Factorization. +
-      phase = 22 ! only factorization +
-      CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, +
-     1 idum, nrhs, iparm, msglvl, ddum, ddum, error) +
-      WRITE(*,*) '​Factorization completed ... ' +
-      IF (error .NE. 0) THEN +
-         ​WRITE(*,​*) 'The following ERROR was detected: ', error +
-         STOP 1 +
-      ENDIF +
-C.. Back substitution and iterative refinement +
-      iparm(8) = 2 ! max numbers of iterative refinement steps +
-      phase = 33 ! only factorization +
-      do i = 1, n +
-         b(i) = 1.d0 +
-      end do +
-      CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja, +
-     1 idum, nrhs, iparm, msglvl, b, x, error) +
-      WRITE(*,*) 'Solve completed ... ' +
-      WRITE(*,*) 'The solution of the system is ' +
-      DO i = 1, n +
-         ​WRITE(*,​*) ' x(',​i,'​) = ', x(i) +
-      END DO +
-C.. Termination and release of memory +
-      phase = -1 ! release internal memory +
-      CALL pardiso (pt, maxfct, mnum, mtype, phase, n, ddum, idum, idum, +
-     1 idum, nrhs, iparm, msglvl, ddum, ddum, error) +
-      END+
  
-</​code>​ 
  
 コンパイラオプションは コンパイラオプションは
-<​code ​bash>+<​code>​
 -mkl -mkl
 </​code>​ </​code>​
 でお手軽♪ でお手軽♪
fortran/ifort.1412914240.txt.gz · 最終更新: 2017/10/03 12:55 (外部編集)