Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6997 Discussions

Error 'LNK1120/2019' and on PARDISO usage

abhiknm
Novice
347 Views

I am developing a FORTRAN code wherein I am trying to solve a sparse linear system using PARDISO.
For the purpose, I am using Intel oneAPI toolkit (basic+HPC) with MVS Community 2022 (64-bit) on Windows 10.

The structure of the program is as given below.

 

INCLUDE 'mkl_pardiso.f90'
PROGRAM mainprog
USE mkl_pardiso
IMPLICIT NONE
!
! declaration
! other calculations
!
DO i = 1,N
	DO j=1,M
		DO k=1,NN
			DO ii=1,NX
				call solver1 (...)
			ENDDO
!
			DO jj=1,NY
				call solver2 (...)
			ENDDO
!
			DO ii=1,NX
				call solver3 (...)
			ENDDO
!
			DO jj=1,NY
				call solver4 (...)
			ENDDO
		ENDDO
	ENDDO
ENDDO
!
END PROGRAM mainprog
!*****************
SUBROUTINE solver1 (...)
	call pardi1 (...)
END SUBROUTINE solver1
!
SUBROUTINE solver2 (...)
	call pardi1 (...)
END SUBROUTINE solver2
!
SUBROUTINE solver3 (...)
	call pardi2 (...)
END SUBROUTINE solver3
!
SUBROUTINE solver4 (...)
	call pardi2 (...)
END SUBROUTINE solver4
!*********************
!
INCLUDE 'mkl_pardiso.f90'
SUBROUTINE pardi1
USE mkl_pardiso
! calculation
END SUBROUTINE pardi1
!
INCLUDE 'mkl_pardiso.f90'
SUBROUTINE pardi2
USE mkl_pardiso
! calculation
END SUBROUTINE pardi2

 

The subroutines 'pardi1' and 'pardi2' call PARDISO to solve real and structurally symmetric matrix equation.
On building, I am getting following two errors.
1. "error LNK2019: unresolved external symbol PARDISO_D referenced in function PARDI1"
2. "fatal error LNK1120: 1 unresolved externals"

The structure of subroutine pardi1(or pardi2) is as given below.

 

INCLUDE 'mkl_pardiso.f90'
SUBROUTINE PARDI1(...)
USE mkl_pardiso
IMPLICIT NONE
!
! declaration of input and output to the subroutine (intents)
!============ for PARDISO =======================
!.. Internal solver memory pointer 
TYPE(MKL_PARDISO_HANDLE), ALLOCATABLE :: pt(:)
!.. All other variables
INTEGER :: maxfct, mnum, mtype, phase, n, nrhs, error, msglvl, nnz
INTEGER :: error1
INTEGER, ALLOCATABLE :: iparm( : )
INTEGER, ALLOCATABLE :: ia( : )			! 'rowIndex' array
INTEGER, ALLOCATABLE :: ja( : )			! 'columns' array
DOUBLE PRECISION, ALLOCATABLE :: a( : ) ! 'values' array
DOUBLE PRECISION, ALLOCATABLE :: b( : )
DOUBLE PRECISION, ALLOCATABLE :: x( : )
INTEGER :: i, idum(1)
DOUBLE PRECISION :: ddum(1)
!
!.. Fill all arrays containing matrix data.
nrhs = 1 
maxfct = 1 
mnum = 1
ALLOCATE (a(..),ja(..),ia(..),b(..),x(..))
a=0.0
ia=0
ja=0
b=0.0
x=0.0
! assigning 'values' array
!
! assigning 'columns' array
!
! assigning 'rowIndex' array
!
! assigning array 'b'
!
!.. Set up PARDISO control parameter
!..
ALLOCATE(iparm(64))
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 ! solution on the first n components 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 ! perturb 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 ON
        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 = 1 ! real and structurally symmetric
!
!.. Initialize the internal solver memory pointer. This is only
! necessary for the FIRST call of the PARDISO solver.
!
ALLOCATE (pt(64))
DO i = 1, 64
   pt(i)%DUMMY =  0 
END DO
!
!.. Reordering and Symbolic Factorization, This step also allocates
! 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,idum, nrhs, iparm, msglvl, ddum, ddum, error)
!
!WRITE(*,*) 'Reordering completed ... '
IF (error /= 0) THEN
   WRITE(*,*) 'The following ERROR was detected: ', error
   GOTO 1000
END IF
!WRITE(*,*) 'Number of nonzeros in factors = ',iparm(18)
!WRITE(*,*) 'Number of factorization MFLOPS = ',iparm(19)
!
!.. Factorization.
phase = 22 ! only factorization
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja,idum, nrhs, iparm, msglvl, ddum, ddum, error)
!WRITE(*,*) 'Factorization completed ... '
IF (error /= 0) THEN
   WRITE(*,*) 'The following ERROR was detected: ', error
   GOTO 1000
ENDIF
!
!.. Back substitution and iterative refinement
iparm(8) = 2 ! max numbers of iterative refinement steps
phase = 33 ! only solving
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, a, ia, ja,idum, nrhs, iparm, msglvl, b, x, error)
!WRITE(*,*) 'Solve completed ... '
IF (error /= 0) THEN
   WRITE(*,*) 'The following ERROR was detected: ', error
   GOTO 1000
ENDIF
!
!WRITE(*,*) 'The solution of the system is '
! reassigning the solution to vector X

!
1000 CONTINUE
!
!.. Termination and release of memory
phase = -1 ! release internal memory
CALL pardiso (pt, maxfct, mnum, mtype, phase, n, ddum, idum, idum,idum, nrhs, iparm, msglvl, ddum, ddum, error1)
!
IF (ALLOCATED(ia))      DEALLOCATE(ia)
IF (ALLOCATED(ja))      DEALLOCATE(ja)
IF (ALLOCATED(a))       DEALLOCATE(a)
IF (ALLOCATED(b))       DEALLOCATE(b)
IF (ALLOCATED(x))       DEALLOCATE(x)
IF (ALLOCATED(iparm))   DEALLOCATE(iparm)
!
IF (error1 /= 0) THEN
   WRITE(*,*) 'The following ERROR on release stage was detected: ', error1
   STOP 1
ENDIF
!
IF (error /= 0) STOP 1
DEALLOCATE (pt)
!
END SUBROUTINE PARDI1

 

 

Kindly advise on the errors as well as the PARDISO usage (subroutine pardi1/2).

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
189 Views

Please take a look at the MKL Linker Adviser follow this link - https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html

to see how properly link against oneMKL for Windows.





View solution in original post

4 Replies
mecej4
Honored Contributor III
294 Views

Did you forget to add the MKL libraries to the linker settings in your project? You have a call to pardiso(), which gets resolved to the specific name PARDISO_D when the real argument arrays are of type double precision. The libraries that must be linked in depends on whether you are targeting IA32 or X64.

abhiknm
Novice
281 Views

Dear @mecej4 ,
I tried. Now, I am getting an error as "fatal error LNK1181: cannot open input file 'C:\Program.obj' ".
Actually, this is the first time I am using this set of compiler and libraries. Hence, not quite familiar with the linkages.

0 Kudos
Gennady_F_Intel
Moderator
190 Views

Please take a look at the MKL Linker Adviser follow this link - https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html

to see how properly link against oneMKL for Windows.





abhiknm
Novice
172 Views

Dear @Gennady_F_Intel ,
Thanks for the answer. I tried the adviser suggested by you. The 'LNK' type errors are resolved but to my surprise, another error is appearing. The same code was reading the same input file well. But now, while reading a character string followed by an integer on the very first input line, it says "A breakpoint instruction (__debugbreak() statement or a similar call) was executed in code.exe". The corresponding instruction in the code is, "READ(11,*) Str, OPTN" and the corresponding line in input file is, "OPTION: 4" (Str and OPTN are character string and integer respectively in the declarations).
The following message also appears.

forrtl: severe (59): list-directed I/O syntax error, unit 11, file D:\coding\code\code\INPUT.txt
Image    PC     Routine      Line      Source
libifcoremdd.dll 00007FFC3045F275 Unknown Unknown Unknown
libifcoremdd.dll 00007FFC3045E73A Unknown Unknown Unknown
code.exe 00007FF6CC61461F prog 85 prog.f90
code.exe 00007FF6CD00D9DB Unknown Unknown Unknown
code.exe 00007FF6CD032C99 Unknown Unknown Unknown
code.exe 00007FF6CD032B3E Unknown Unknown Unknown
code.exe 00007FF6CD0329FE Unknown Unknown Unknown
code.exe 00007FF6CD032D2E Unknown Unknown Unknown
KERNEL32.DLL 00007FFC97F87344 Unknown Unknown Unknown
ntdll.dll 00007FFC988426B1 Unknown Unknown Unknown.

Before, trying PARDISO, the same program and input files were working well with my own written subroutine instead of calling PARDISO.

I will see it separately. Right now, I am accepting both the answers as solutions.

0 Kudos
Reply