Fortran 90/95 library for sparse matrices?
Asked Answered
N

1

16

I am looking for a library for dealing with sparse matrices in fortran 90/95. I only need very basic operations like matrix-vector multiplication. What do you suggest I use?

I have searched around and an extension(?) to BLAS called "sparse blas", documented in chapter 3 of the blast technical forum specification:

http://www.netlib.org/blas/blast-forum/,

seems ideal. According to that document, there should be a fortran 95 interface to the library. However, I haven't been able to find an actual implementation of this specification anywhere that I was able to download. I am kind of getting the impression that the fortran 95 sparse blas specification isn't really implemented anywhere? Not as open source anyway.

I also found a library called sparsekit:

http://people.sc.fsu.edu/~jburkardt/f_src/sparsekit/sparsekit.html

Anyone got any experience with either one of these two, or any other sparse matrix library for fortran 90/95? I would like advice on which one to use, and also where to get it (in the case of sparsekit the source code is available through the above link). Is there anything like a "standard" for sparse matrices, like BLAS is for dense ones?

Cheers,

Arne

Nonlinearity answered 8/9, 2012 at 6:6 Comment(5)
F95, it being a minor revision of the language, often goes under F90. It's been a while since I've done anything with large matrices, but this seems to be people.sc.fsu.edu/~jburkardt/f_src/blas2/blas2.html the F90 version.Quarles
Thanks Idigas, but I don't think that's it. It seems to me, what you're linking to is the BLAS library, and that "sparse blas" is not part of that. For example, there should be a subroutine (according to the specification) called "duscr_begin" (or possibly "blas_duscr_begin"), which is the sub you use to initialize a sparse matrix, which I haven't found anywhere in the BLAS library. I even downloaded all the files from netlib.org/sparse-blas/index.html, and did "grep -i duscr_begin *.f" without any luck. I found that very confusing.Nonlinearity
Ah, could be. I only looked at it hastily last time.Quarles
Actually I think the F90 interface to the sparse BLAS is exactly on the page you linked to. Just download the shell script package from: http://www.netlib.org/toms/818 and run it through /bin/sh. The *.f90 files will then be created. Let me know, if you have no Bourne shell available (e.g. if you work under Windows).Mezzosoprano
physics.jacobs-university.de/theine/research/splasTintinnabulation
N
16

OK, I'll partially answer my own questions:

Where to find a full f95 implementation of Sparse BLAS was provided by @alexurba above:

http://www.netlib.org/toms/818

That was it! This script creates all the source code in the folder that you run it (I have never seen software provided in this manner before).

To make the INSTALL script work I needed to do some changes: The install instructions tell you to edit the INSTALL script and choose the appropriate "arch". Your choices are: AIX, ALPHA, CRAY, HP, NAG, SGI and SUN. Neither of these seemed appropriate to me, as I am using linux and the only fortran compiler I have on this computer is gfortran. I didn't quite understand the purpose of this option, but what I did that worked was the following:

1) In INSTALL, make up a new "arch" I called GNU by setting the variable SB_ARCH='GNU'. 2) In SOFTWARE/Makefile change FC = f90 to FC = gfortran, 3) In TESTER/ copy the file Makefile.NAG to Makefile.GNU, change FC = f90 to FC = gfortran, and change all instances of the the word 'NAG' to 'GNU'. (You'll probably also want to change the FFLAGS option in the Makefiles.)

After this I ran INSTALL, and then TESTER/test_all, and the tests spit out "0.000..." as errors, which I assume to mean everything is working.

I must say I found finding this source code unusually difficult. Luckily this thread comes up quite high on google when searching "fortran 90 sparse matrix library" now.

My final solution: Ironically, after finally finding a full implementation of Sparse BLAS I have decided that for my problem it is better to use a more direct approach, since all I'll probably need is matrix-vector multiplication: Figure out what sparse matrix representation to use (Compressed Sparse Row (CSR) seems to be appropriate for my problem), dig out the corresponding matrix-vector multiplication routine from the Sparse BLAS source code, see how it wants it input, and just use that directly in my code.

Nonlinearity answered 11/9, 2012 at 22:43 Comment(2)
I am at the point where and the tests spit out "0.000..." as errors, which I assume to mean everything is working. Now, how to use this library (or libraries?) where I need them? Which files should I copy into the directory containing my own programs?Textual
The link doesn't work anymore, do you know where one might find it?Naldo

© 2022 - 2024 — McMap. All rights reserved.