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

Again about VC++

dmitri_rubisov
Beginner
550 Views
Does not seem that anyone paid attention to my previous reques. I am repeating it as a new posting.
Sorry for getting back to an old question. I am not a professional programmer but have to do it occasionally. I was trying to use Lapack from Visual C++. My question is how to declare a two dimensional array in C++ so that it is correctly passed to Fortran. A simple example of a call of a Lapack function would help tremendously. Thanks, Dmitri
0 Kudos
4 Replies
Todd_R_Intel
Employee
550 Views

Dmitri,

Thanks for your post. I'm afraid I don't have any exampleson hand of calling LAPACK from C++ with 2 dimensionalarrays. When I call LAPACK from C, I usually use a 1D array. I'll see what I can cook up.

Anyone else have a quick example?

Todd

0 Kudos
dmitri_rubisov
Beginner
550 Views
Thanks. Do you mean that you declared all double arrays as one dimensional and stored them column by column? That's easy.
DmR
0 Kudos
Todd_R_Intel
Employee
550 Views

Yes. I store matrices in a single dimension arrays with data stored in columns (columns are stored contiguously in Fortran as opposed to the row-major format of C++). The LDA parameter (stands forleading dimension of the matrix A)found in many BLAS and LAPACK functions determines the distance between elements of the same row. LDA thereby imposes the 2D structure of the matrix on the 1 dimensional array.

Todd

0 Kudos
prfarid
Beginner
550 Views

Hi Todd,

could you please help me in the following problem. I noticed you could pass arrays to fortan.

thanks

Farid

> In the following code when I pass the array to the fortran code I have a
> problem
> When I change the array in FORTRAN for each entry such as FA(4)=4 I don't
> receive any error messages and it's ok, but when I 'm using loop for
> chaning the content of array such as FA(i)=i*6 or copying FA array to
> another array I'm receiving following error message I've already tried
> __cdecl and __stdcall.
> Could you please tell me your idea about this problem or give me some code
> which work properly on your machine, I have VS 6 and have no problem with
> version of software (In passing single parameters to fortran I have no
> problem).
> I do really appriciate your help and unerstand you are very busy esp in
> these days.
>
>
> Thanks & Regards
> Farid
>
>
>
>
> ERRORs:
> NTR2CALL error LNK2019: unresolved external symbol _ALI@12 referenced in
> function _main
> NTR2CALL fatal error LNK1120: 1 unresolved externals
>
> =====================================================FORTRAN
> SUBROUTINE ALI(a,b,FA)
> Real*8 a,b
> integer i
> Real*8 FA(10)
>
> b=110+a
>
> DO i = 1, 6
> FA(i)=1
> enddo
>
> END SUBROUTINE ALI
> =====================================================VC++
> // external Fortran function prototype
> #include "stdafx.h"
> using namespace std;
> #include "iostream"
>
> extern "C" {void ALI(double&,double&,double*);}
> #pragma comment(lib, "Lib1.lib")
>
> void main()
> {
> double a,b;
> int i=0;
> double FA[10]={1,2,3,4,5,6,7,8,9,10};
> cout<
> <<"Enter a"
> <
> <> cin>>a;
> ALI(a,b,FA);
>
> cout<
> <<"b=a+110= "
> <
> <
> <
> <> for (i=0;i<10;i++)
> {
> cout<<" "<;
> }
> cout<
> <
> <> return;
> }
>



0 Kudos
Reply