Fortran Coder

查看: 7889|回复: 5

[数学库] 求教Pardiso 6.0的用法

[复制链接]

2

帖子

1

主题

0

精华

新人

F 币
15 元
贡献
6 点
发表于 2021-6-5 22:03:09 | 显示全部楼层 |阅读模式
编译环境:WIN10+VS2012+IVF2013
之前使用过MKL下的pardiso求解器,但是功能较少,其函数变量是16个的,无法进行矩阵求逆、求解行列式、线性方程迭代求解等功能(不含dparm变量)。
自己去pardiso官网下载了libpardiso600-WIN-X86-64.lib、libpardiso600-WIN-X86-64.dll、libpardiso600-WIN-X86-64.exp,文件名全部改为libpardiso600,文件路径录入Additional include directories.

在子程序中调用pardiso函数,但是一直提示:错误        1         error #7002: Error in opening the compiled module file.  Check INCLUDE paths.

第一次使用动态链接库,不知道是不是设置有问题,或者是use的模块名字不对,跪求用过的大佬指点。子程序代码如下:

[Fortran] 纯文本查看 复制代码
subroutine RealPardiso(matrix,b,x,N,error)
    use libpardiso600
    implicit none
    integer                   :: n  !// depend on your equation
    integer                   :: i, j, mm, tmp, nn, fileid, first, num, ncolumn, count
    real(kind=8)              :: matrix(n,n), b(n), x(n),dparm(64)
    real(kind=8), allocatable :: aa(:)
    integer, allocatable      :: ia(:), ja(:)
  
    !// =====================the variables of pardiso====================
    integer(kind=8)           :: pt(64)   !// kind=8:x64; kind=4:win32
    integer                   :: maxfct, mtype, phase, nrhs, error, msglvl, mnum,  solver
    integer, allocatable      :: perm(:)
    integer                   :: iparm(64)
    integer, external         :: mkl_get_max_threads
    !// =====================the variables of pardiso====================
  
    
  
    !// input data
    allocate( perm( n ) )
 
    !// =========================store data by CSR format=======================

    num=0
    do I=1,N
        do J=1,N
            if ( abs(matrix(i,j)) /= 0.0d0 ) then
                num=num+1
            endif
        enddo
    enddo

    allocate( aa(num), ja(num), ia(n+1) )  !// store the no-zero element

    ia(1)=1
    count=1
    do I=1,N
        ncolumn=0
        do J=1,N
            if ( abs(matrix(I,J)) /= 0.0d0 ) then
                ncolumn=ncolumn+1
                ja(count)=J
                aa(count)=abs(matrix(I,J))
                count=count+1
            endif
        enddo
        ia(I+1)=count
    enddo

    !// ===========================solve equations=============================
    pt = 0  !// pointer initialization
    maxfct = 1; mnum = 1; mtype = 11  !// mtype = -2: symmetric nonpositive definite matrix, mtype = 2: symmetric positive definite matrix
    perm = 0; nrhs = 1
    x = 0.d0
    iparm(1) = 0  !// iparm use default values
    iparm(3) = mkl_get_max_threads()  !// iparm(3): parallel threads are obtained by MKL. In general, the number of cpus is the same as the number of threads
    error = 0  
    msglvl = 1
    solver=0
    
!     iparm(32)=1
!     iparm(33)=1
    phase = 12  !// LU decompose
    call pardiso( pt, maxfct, mnum, mtype, phase, n, aa, ia, ja, perm, nrhs, iparm, msglvl, b, x, error,dparm  )
!     write(*,*)dparm(32),dparm(33),iparm(33)
    
    
    iparm(8)=100
    iparm(32)=1
!     iparm(33)=1
    solver=0
    phase = 33  !// solve equations
    call pardiso( pt, maxfct, mnum, mtype, phase, n, aa, ia, ja, perm, nrhs, iparm, msglvl, b, x, error,dparm )
    write(*,*)iparm(7),iparm(20),dparm(35)
    do I=1,64
        write(*,*)dparm(I)
    enddo

    phase = -1
    call pardiso (pt, maxfct, mnum, mtype, phase, n, aa, ia, ja, perm, nrhs, iparm, msglvl, b, x, error,dparm)
    
    deallocate( aa, ja, ia, perm )
    !// ===========================stop solving equations=============================
  
end


250

帖子

2

主题

0

精华

宗师

F 币
1730 元
贡献
872 点

规矩勋章

发表于 2021-6-6 10:43:45 | 显示全部楼层
没用过这个库,如果只有lib和dll,应该不要用use语句,直接把lib作为额外的库链接

2

帖子

1

主题

0

精华

新人

F 币
15 元
贡献
6 点
 楼主| 发表于 2021-6-6 12:33:18 | 显示全部楼层
necrohan 发表于 2021-6-6 10:43
没用过这个库,如果只有lib和dll,应该不要用use语句,直接把lib作为额外的库链接 ...

需要进行代码上的操作吗?还是只要把.lib文件添加到source file里就行了?

250

帖子

2

主题

0

精华

宗师

F 币
1730 元
贡献
872 点

规矩勋章

发表于 2021-6-7 07:32:28 | 显示全部楼层
hsq0596 发表于 2021-6-6 12:33
需要进行代码上的操作吗?还是只要把.lib文件添加到source file里就行了?

不需要,我看了那个库的官网,有例子

1

帖子

0

主题

0

精华

新人

F 币
8 元
贡献
1 点
发表于 2022-5-22 00:40:25 | 显示全部楼层
大神您好,可否分享一下该文件和授权,现在学术已经不给权限了……我来晚了,热切期盼啊

2

帖子

1

主题

0

精华

新人

F 币
11 元
贡献
9 点
发表于 2023-2-11 17:34:53 | 显示全部楼层
lodgingking 发表于 2022-5-22 00:40
大神您好,可否分享一下该文件和授权,现在学术已经不给权限了……我来晚了,热切期盼啊 ...

学术版有两个月的权限吧
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-4-19 10:06

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表