Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Libraries

sada77
Beginner
3,263 Views
Hallo,
does anybody knows how to use libraries in fortran?
For example, I would like to use GMRES subprogram for solving linear system of equations. At the beginning I define:

extarnal gmres

and then somewhere in the program I call the subroutine:

call gmres(....)

But I cannot build .exe file because there is an error:

GMRES.obj : error LNK2001: unresolved external symbol _GMRES@28

Does anybody know what is the problem and how I am supose to include those external libraries?
I am using Visual Fortran 5.0
Thanks,
S.
0 Kudos
17 Replies
h-faber
Beginner
3,263 Views
Hi,
I have never worked with external but usually use CALL in combination with SUBROUTINE. Did you try your gmres as SUBROUTINE instead of external?
0 Kudos
Steven_L_Intel1
Employee
3,263 Views
There's nothing wrong with the EXTERNAL as it is. The question is - where is routine GMRES defined? If it is Fortran code, it needs to have been compiled by the same compiler (DVF 5 you are using?) If it is C code, then you have to determine what calling convention is required and perhaps add directives to adjust them. See the Programmer's Guide chapter on mixed-language programming for more information.
0 Kudos
sada77
Beginner
3,263 Views
I am using Fortran compiler, and gmres is subroutine of fortran. And I found that on libraries help mani.
But my probelm is how to solve (which solver to use) very simple linear equation system:
A * x = b
Does anybody know if there is any library in fortran doing that and how to use it?
How can I find this Programmers Manual, because I have some problems to find it on my computer, is there any online version?
Regards,
S.
0 Kudos
h-faber
Beginner
3,263 Views
Hi,
there are three interesting pdf files usually in
C:programsintelfortrancompiler80docs

for_igs.pdf
for_lib.pdf
for_lang.pdf
0 Kudos
Steven_L_Intel1
Employee
3,263 Views
GMRES is not provided by the Fortran compiler you are using and is not to be found in the compiler documentation. I don't know where you saw it.

A Google search shows GMRES as a routine available in MATLAB (a commercial product.) You will have to find either source for a GMRES routine or use someone else's library that provides one.
0 Kudos
christianmeiners
Beginner
3,263 Views
Hi!

If it is only a very simple (small N) system of linear equations, you should consider to use a direct solver instead of the iterative approach GMRES. Use, for instance, LU-Decomposition. You can find appropriate Fortran code in the book "Numerical Recipes in Fortran". You could also use the routines provided by LAPACK (In this case e.g. ZGETRS and ZGETRF and the corresponding depencdencies). Fortran77-Reference code is available at www.netlib.org/Lapack. However, these are not tuned for best performance but may work well for small problem sizes. Hope that helps!
0 Kudos
cyrillique
Beginner
3,263 Views
If you're using CVF, then you can use IMSL library. In this casea routine you need to solve your set of equations depends on your matrix A type. Take a look at C:Program FilesMicrosoft Visual StudioDF98IMSLHELP, file called MATH.pdf chapter 1. You'll find there a lot of routines for linear systems solving. To use this library, specify before declaration block in your program "USE dflib". Good luck!
0 Kudos
sada77
Beginner
3,263 Views
I have already tried to use LU Decompostion and it is slow. My matrix is A(1200 x 1200) elements.
And I tried to use LINPACK too, but the problem is that I need to call some subroutines (which are external) and I dont know how to include them in my project. That doesnt go automatically, and therefore, I cannot build the code.
Does anybody know how to include this in the libraries, or in a project, or how to install LINPACK?
Regards,
S.
0 Kudos
Steven_L_Intel1
Employee
3,263 Views
IMSL is provided only in the CVF Professional Edition and does not involve USE DFLIB. I don't think this particular routine is provided by IMSL anyway.

CVF does provide the Compaq Extended Math Library in all editions, though I don't think it was in DVF 5. I don't think GMRES is there either.
0 Kudos
cyrillique
Beginner
3,263 Views
Yes, "use dflib" isn't necessary for using IMSL, sorry, and i'm not sure either if it is involved in 5.0 version. But still ifS. wants to use subroutines instead of libraries, he can search for it in http://www.netlib.org/toms/. Me personally, i usedNSPIVbut i had a sparse matrix. Though the algorithm no 576, for example,seems to suit for general problems. It uses a modification of gaussian elimination.
0 Kudos
John4
Valued Contributor I
3,263 Views
GMRES is indeed provided with the professional editions of CVF and IVF. The section numbers in the library helpare 1.1.20 and 1.3.20 respectively.
I guess that the error shown during linking is due to a missing USE statement (e.g., USE NUMERICAL_LIBRARIES).
If working under IVF, additional instructions included in the READMEfile must be followed prior to compiling any code that uses IMSL libraries.
0 Kudos
brianlamm
Beginner
3,263 Views

Hi Steve,

He could try using MKL implementation of PARDISO.

PARDISO, especially as implemented in MKL, is almost across the board superior to All other Commercially available linear system solvers, even the hugely more expensive HSL routine (MA57 in particular).

I suggest he look at

http://www.intel.com/cd/software/products/asmo-na/eng/perflib/mkl/266853.htm

as well as

ftp://ftp.numerical.rl.ac.uk/pub/reports/shgNAGIR20041.pdf

wherein it reads "The codes BCSLIB-EXT, MA57, and PARDISO have the fastest solve times." for definite systems and "Overall, PARDISO was the fastest code on our set of inde nite problems." for indefinite systems.

He will have to (possibly) learn to input the Compressed Sparse Row format arrays required by PARDISO, but it's not terribly difficult.

I've found PARDISO to be very memory efficient and blisteringly fast on IA-32, and I'm going to see soon what's it's efficiency/speed characteristics are on EM64T. But first I've got to get my head around IVF 9.1.

Anyway, it says quite a bit that Intel goliath "picked up" PARDISO for inclusion in its MKL.

0 Kudos
cyrillique
Beginner
3,263 Views
Brian-Lamm, as you've used PARDISO, could you suggest me if I can use iton a personal one-processor (AMD Athlon)machine? Shall it conserve all its perfomances then? Have you compared pardiso with DSS?
Ibeg pardon for an off-top, but I didn't find another way to contact Brian.
0 Kudos
christianmeiners
Beginner
3,263 Views
@sada77: By the way, if no commercial library is avaliable for you, check out for this great compilation of free packages:
http://www.netlib.org/utk/people/JackDongarra/la-sw.html
Maybe, there is a routine (or package) that better fits your needs (or is easier to include in your projekt).
0 Kudos
brianlamm
Beginner
3,263 Views

My experience is soley with PARDISO; I've not used the DSS MKL "components" implementation of sparese solver.

Yes, exe's built (currently one can only statically link to mkl_solver.lib) against PARDISO will run properly on single processor machines.

You would be well advised to visit the MKL forum for (much more expert) advice.

0 Kudos
gavyas
Beginner
3,263 Views

Hi,

GMRES is not predefined in Fortran...you have to get the separate code from other sources like netlib.org etc..I got it from there but got stucked somewhere in debugging..

0 Kudos
Dishaw__Jim
Beginner
3,263 Views

I would like to second the recommendation to use PARDISO. The performance is very impressive--single/dual Intel or AMD, all very fast. In my code I call PARDISO anywhere from 2 to several thousand times on sparse linear systems ranging in size from 4x4 to 83700x83700 (even larger for "real world problems"). One of the nice features with PARDISO is that the setup is separate from the solving, to wit:

    ! Create a handle for the sparse direct solver
    error = dss_create(handle, MKL_DSS_DEFAULTS)
        
    IF(error .NE. MKL_DSS_SUCCESS) THEN
        WRITE(*,*) 'Unable to initialize DSS, error = ', error
        STOP
    END IF

    CALL initialize_sparse_matrix(transport_data, nRows, nElements)

    error = dss_define_structure(handle, &
        MKL_DSS_NON_SYMMETRIC, &
        rowIndex, nRows, nRows, columns, &
        nElements)   ! Number of non-zero elements

    IF(error .NE. MKL_DSS_SUCCESS) THEN
        WRITE(*,*) 'Unable to define structure, error = ', error
        STOP
    END IF    
    
    ! Reorder the matrix.  Pass a dummy permutation matrix
    ! because we are going to let DSS figure it out
    perm = 0
    error = dss_reorder(handle, MKL_DSS_AUTO_ORDER, perm)
    IF(error .NE. MKL_DSS_SUCCESS) THEN
        WRITE(*,*) 'Unable to reorder matrix, error = ', error
        STOP
    END IF

Then, to solve a system, requires

    ! Factor the matrix.
    error = dss_factor_real( handle, MKL_DSS_DEFAULTS, values)    
    IF (error .NE. MKL_DSS_SUCCESS) THEN
        WRITE(*,*) 'Unable to factor matrix, error = ', error
        STOP
    END IF

    ! Solve the system    
    ! Passing BJface(1,1) passes the start of the array.  Due to Fortran's 
    ! sequence association rules, the array will be arranged in the correct 
    ! order.  This should work for any compiler and avoid an expensive 
    ! (both in memory and execution time) penalty associated with a RESHAPE.
    error = dss_solve_real(handle, MKL_DSS_DEFAULTS, &
        BJextface(1,1), 1, BJface(1,1))
    IF (error .NE. MKL_DSS_SUCCESS) THEN
        WRITE(*,*) 'Unable to factor matrix, error = ', error
        STOP
    END IF

On a slightly separte note, Intel also has a cluster version of PARDISO (which is interesting because it was designed for a shared uniform memory architecture--OpenMP style vice MPI). We have been toying with the idea of picking up a license for Cluster MKL to try it out.

0 Kudos
Reply