gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1565 Posts in 517 Topics by 752 Members - Latest Member: zaikunzhang September 25, 2021, 04:59:28 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Macintosh  |  How do I call LAPACK or BLAS routines from Absoft Fortran
gfx
gfxgfx
 

Author Topic: How do I call LAPACK or BLAS routines from Absoft Fortran  (Read 8519 times)

alice11

  • Newbie
  • *
  • Posts: 4
How do I call LAPACK or BLAS routines from Absoft Fortran
« on: December 25, 2010, 01:23:51 PM »
Hi

I am trying to call a lapack routine (Dpotrf) from my Fortran 90 code and I couldn't get it to work. In general, I find Absoft lack of any kind of documentation on Lapack and Blas to be frustrating. When I search google for Lapack I get info on every other compiler but nothing from Absoft. Absoft /LIB directory seems to have a bunch of different libraries that seem relevant--libAbsoftLapack.a, libreflapack.a, liblapack.a, etc, etc--but it is not clear which one(s) should be linked. It is also not clear if any Blas library should be linked. Also, what should be the calling convention: fortran 90 or 77? If anybody is successfully using Lapack or Blas on Absoft, I'd really appreciate some help here.

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #1 on: December 26, 2010, 12:01:58 PM »
If you are using AbsoftTools to build your project, select Project Options from the Project menu. On the General tab, click on the check boxes for LAPACK and BLAS. If you are compiling from the Terminal, add the following options:

-lreflapack -lrefblas

The above applies to V11.0 and V11.0. If you are using an earlier version, reply with your version.

alice11

  • Newbie
  • *
  • Posts: 4
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #2 on: December 26, 2010, 05:54:44 PM »
Thanks for the response. I assumed that the "REF" versions were using F77 calling scheme. Is that right? If so, is there an alternative library that would allow me to use the F90 interfaces. I see some libraries called libAbsoftlapack.a and liblapack.a. What are these for?

Finally, what is the role of checking those boxes on the options page? Do they serve as adding a library path (-L)?

thanks

alice11

  • Newbie
  • *
  • Posts: 4
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #3 on: December 26, 2010, 05:57:25 PM »
Sorry, forgot to mention this. I was trying to compile this code below, checking the lapack and blas options. Can you tell me why it's not compiling?

 program example
 
  use la_precision, only: wp=>dp
  use F95_Lapack,   only: la_gesv
 
  implicit none
 
  character(len=*), parameter :: fmt='(7(1X,F9.3))'
 
  integer :: j,n,nrhs
 
  real(wp), allocatable :: a(:,:),b(:,:)
 
  n=5 ; nrhs=2
 
  call random_number(a)
 
  do j = 1, nrhs ; b(:,j) = sum(a,dim=2)*j ; enddo
 
  call la_gesv(a,b)
 
  write(*,*) 'The solution:'
 
  do j = 1,nrhs ; write(*,fmt) b(:,j) ; end do
 
  end program example




forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #4 on: December 27, 2010, 06:41:27 AM »
libreflapack.a and librefblas.a are the "reference" builds of these libraries. They were from the latest sources available at the time: V3.2.1. (V3.3 was made available on 11/14/2010.) Source and makefiles are on your CDROM or downloaded disk image.

The check boxes simply add -lreflapack and -lrefblas to the build. Since the libraries are located in the Absoft lib directory, no -L option is necessary.

LAPACKF95 is no longer included with Pro Fortran. It has not been updated since 2000 and has not kept pace with the reference builds of the underlying libraries. You can easily download and build it from here:

http://www.netlib.org/lapack95/

However, you may need to also download and build much earlier versions of the underlying libraries; LAPACK and BLAS for it to work properly. Also, other Absoft provided libraries such as IMSL will not work properly if you do so.

alice11

  • Newbie
  • *
  • Posts: 4
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #5 on: December 27, 2010, 12:32:03 PM »
Thanks again. This is extremely helpful. But I am not sure I understand this fully. Do I need to put any USE statement in my program to be able to use these libraries. If so, what should be the name of the module that I am "USING"? This is how I usually do with libraries when I use F90 conventions. Or do I use external statements to call the routines?

Also, are the REFERENCE versions optimized for Mac OSX? Do they include ALL the Lapack routines? Finally, I see some scalapack and Blacs libraries in my /LIB folder. Is it possible to make use of these? Can I just add them using -lscalapack to my code?

Thanks again!!

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
Re: How do I call LAPACK or BLAS routines from Absoft Fortran
« Reply #6 on: December 28, 2010, 06:36:12 AM »
The LAPACK and BLAS libraries supplied on OS X are complete. They are FORTRAN 77 so no USE statement is required. For example:

INTEGER, PARAMETER :: LDA=100, LDB=100, N=50, NRHS=50
INTEGER INFO, IPIV(N)
REAL(KIND(1.0D0)), DIMENSION(LDA,N) :: A
REAL(KIND(1.0D0)), DIMENSION(LDB,NRHS) :: B
...
CALL DGESV(N, NRHS, A, LDA, IPIV, B, LDB, INFO)

EXTERNAL statements can be used, but are not necessary unless you are passing the name of an LAPACK subroutine as an argument in your code.

Yes, they are optimized for OS X. Complete timing and test code is included with the sources I mentioned earlier.

ScaLapack and BLACS are for use with MPI. They are built against the Argonne version MPICH2. They can be used by adding them as files to your project or with -lscalapack -lblacs -lblacsC -lblacsF77

You cannot use the MPI library that Apple supplies with Fortran code. Apple did not include the Fortran interfaces. Instructions for building MPICH are here:

http://www.absoft.com/Products/Compilers/Fortran/Linux/fortran95/BuildingMPICH-2_MacIntel_v101.pdf

All Absoft supplied libraries are built with:

-O3 -YEXT_NAMES=LCS -YEXT_SFX="_"

lower case names with a trailing underscore is the default for the compiler. You do not need to add these options to use the libraries.

Absoft User Forum  |  Support  |  Macintosh  |  How do I call LAPACK or BLAS routines from Absoft Fortran
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!