C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

passing 3D arrrays from c++ to fortran and viceversa

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
NM
Guest





PostPosted: Thu Jul 28, 2005 10:33 pm    Post subject: passing 3D arrrays from c++ to fortran and viceversa Reply with quote



Hello all,

I am supposed to do some mixed programming with c++ and fortran.
I was succeeful in exchanging the 2D arrays from fortran to c++ and the
other way, but was unable
to that same with the 3D arrays, the values passed are not all the
same. I am also pasting the fortran and c++ codes so that you could
have a look at them.

////C++ Code

#include <math.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

extern "C" {
void setup_(int *, int *, int *, int *, int *);
void getsetup_( float *,float *);

}


int main()
{

float **testarr,***arr3d;
int rowfor,colfor,i,j,k=1;
int three,two,one,inc;
setup_(&rowfor,&colfor,&three,&two,&one);

// 2D array dynamical allocation
testarr = new float*[colfor];

for (i=0; i < colfor; i++)
testarr[i]= new float[rowfor];


//3d array dynamic allocation
//cout<<"nThree = "< for(i=0;i {
cout< for(j=0;j cout<<" "<
}

//Printing the 3D array in c++ before getsetup
cout<<"nC++ 3D Array IN C++ BEFORE GETSETUP----------";
for(i=0;i {
cout<<"n";
for(j=0;j {
cout<<"n";
for(k=0;k cout<<" "< }
}

getsetup_(*testarr,&arr3d[0][0][0]);

//Printing the 2D array in c++ after getsetup
cout<<"n C++ 2D Array IN C++ AFTER GETSETUP ----------";
for(i=0;i {
cout< for(j=0;j cout<<" "< }


//Printing the 3D array in c++ after getsetup
cout<<"nC++ 3D Array IN C++ BEFORE GETSETUP----------";
for(i=0;i {
cout<<"n";
for(j=0;j {
cout<<"n";
for(k=0;k cout<<" "< }
}

cout<<"n";

return 0;

}


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Fortran Code

module chek
integer rowfor
integer colfor,onefor,twofor,threefor
real*8, allocatable:: arrfor(:,Smile
real*8, allocatable:: arrfor3d(:,:,Smile
end module chek

subroutine setup(row, col, three, two, one)
use chek
integer row,col,i,j,k,three,two,one
k=1

rowfor = 3
colfor= 10

three = 4
two = 3
one = 2

allocate(arrfor(rowfor,colfor),stat=ierr)
allocate(arrfor3d(one,two,three),stat=ierr)

! Assinging values to 2D array of Fortran
do i=1,rowfor
do j=1,colfor
arrfor(i,j)= 222
end do
end do

! Assinging values to 3D array of Fortran
do i=1,one
do j=1,two
do k=1,three
arrfor3d(i,j,k)= 333
end do
end do
end do

onefor = one
twofor = two
threefor = three
col=colfor
row=rowfor

end subroutine




subroutine getsetup(arr,arr3d)
use chek
real arr(0:rowfor,0:colfor)
real arr3d(0:onefor,0:twofor,0:threefor)
integer i,j,k

print *,''
print *,'@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@'
do i=0,rowfor-1
print *, ' ',(arr(i,j),j=0,colfor-1)
end do


print*,'@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@ '
do i=0,onefor-1
do j=0,twofor-1
print *, ' ',(arr3d(i,j,k),k=0,threefor-1)
enddo
enddo

! Assinging values for the 2D array of c++ with 2d array of fortran
do i=0, rowfor-1
do j=0, colfor-1
arr(i,j)=arrfor(i+1,j+1)
end do
end do


! Assinging values to 3D array of c++ withe the 3D array of fortran
do i=1,onefor
do j=1,twofor
do k=1,threefor
arr3d(i-1,j-1,k-1)=arrfor3d(i,j,k)
enddo
enddo
enddo

end subroutine

////////////////////The Output!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C++ 2D Array IN C++ BEFORE GETSETUP----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ BEFORE GETSETUP----------

1 13
5 17
9 21

2 14
6 18
10 22

3 15
7 19
11 23

4 16
8 20

@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@
1.000000 4.000000 7.000000 10.00000 13.00000 16.00000 19.00000
22.00000 25.00000 28.00000
2.000000 5.000000 8.000000 11.00000 14.00000 17.00000 20.00000
23.00000 26.00000 29.00000
3.000000 6.000000 9.000000 12.00000 15.00000 18.00000 21.00000
24.00000 27.00000 30.00000
@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@
1.000000 2.000000 3.000000 4.000000
0.0000000 0.0000000 0.0000000 0.0000000
0.0000000 0.0000000 0.0000000 0.0000000
13.00000 14.00000 15.00000 16.00000
5.000000 6.000000 7.000000 8.000000
0.0000000 0.0000000 0.0000000 0.0000000
12 24
C++ 2D Array IN C++ AFTER GETSETUP ----------
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
C++ 3D Array IN C++ BEFORE GETSETUP----------

333 333
333 17
9 21

333 333
333 18
10 22

333 333
333 19
11 23

333 333
333 20
12 24

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!////////////////////////////////////////

It can be observed that the 2D arrays are working fine, i.e the changes
done in c++ are reflected in fortran and vice versa, but it doesnt seem
to happen with 3D, some values are not changed as expected. I hope I
have made my point clear.
Any suggestions would be of great help
Thanks in advance

Regards,
NM

Back to top
E. Robert Tisdale
Guest





PostPosted: Fri Jul 29, 2005 1:03 am    Post subject: Re: passing 3D arrrays from c++ to fortran and viceversa Reply with quote



NM wrote:

Quote:
I am supposed to do some mixed [language] programming with C++ and Fortran.
I was successful in exchanging the 2D arrays from Fortran to C++
and the other way but was unable to the same with the 3D arrays.
The values passed are not all the same.
I am also posting the Fortran and C++ codes
so that you could have a look at them.

Fortran array subscripts appear in order from left to right.
C & C++ array subscripts appear in *reverse* order from right to left.
So Fortran and C arrays appear to be transposes of each other.
For an N-dimensional array:

A[n_N]...[n_2][n_1] ~ A(n_1, n_2, ..., n_N)

Fortran 77/90/95 [sub]programs don't understand pointers to pointers
so you must pass a pointer to the first element of the array

&A[0]...[0][0]

For example:

Quote:
cat main.cc
#include <math.h

#include #include <stdlib.h>
#include <time.h>

extern "C" {
void setup_(int& rowfor, int& colfor,
int& three, int& two, int& one) {
rowfor = 3; colfor = 10;
three = 4; two = 3; one = 2;
}
void getsetup_(float* testarr, float* arr3d) {
// ?
}
}

int main(int argc, char* argv[]) {

int rowfor, colfor, three, two, one;
setup_(rowfor, colfor, three, two, one);

// 2D array dynamic allocation
// testarr[colfor][rowfor] ~ testarr(rowfor, colfor)
float** testarr = new float*[colfor];

testarr[0] = new float[rowfor*colfor];
for (int j = 1; j < colfor; ++j)
testarr[j] = testarr[j-1] + rowfor;

// 3D array dynamic allocation
// arr3d[three][two][one] ~ arr3d(one, two, three)
float*** arr3d = new float**[three];

arr3d[0] = new float*[three*two];
for (int i = 1; i < three; ++i)
arr3d[i] = arr3d[i-1] + two;

arr3d[0][0] = new float[three*two*one];
for (int j = 1; j < two; ++j)
arr3d[0][j] = arr3d[0][j-1] + one;
for (int i = 1; i < three; ++i) {
arr3d[i][0] = arr3d[i-1][0] + two*one;
for (int j = 1; j < two; ++j)
arr3d[i][j] = arr3d[i][j-1] + one;
}

// Assigning values to the 2D array of C++
int inc = 0;
for (int i = 0; i < colfor; ++i)
for (int j = 0; j < rowfor; ++j)
testarr[i][j] = ++inc; // testarr(j, i)

// Assigning values to the 3D array of C++
inc = 0;
for (int i = 0; i < three; ++i)
for (int j = 0; j < two; ++j)
for (int k = 0; k < one; ++k)
arr3d[i][j][k]= ++inc; // arr3d(k, j, i)

//Printing the 2D array in C++ before getsetup
std::cout << "nC++ 2D Array IN C++ BEFORE GETSETUP --------";
for (int i = 0; i < colfor; ++i) {
std::cout << std::endl;
for (int j = 0; j < rowfor; ++j)
std::cout << " " << testarr[i][j]; // testarr(j, i)
}

//Printing the 3D array in C++ before getsetup
std::cout << "nC++ 3D Array IN C++ BEFORE GETSETUP --------";
for (int i = 0; i < three; ++i) {
std::cout << "n";
for (int j = 0; j < two; ++j) {
std::cout << "n";
for (int k = 0; k < one; ++k)
std::cout << " " << arr3d[i][j][k]; // arr3d(k,j,i)
}
}

getsetup_(&testarr[0][0], &arr3d[0][0][0]);

//Printing the 2D array in C++ after getsetup
std::cout << "nC++ 2D Array IN C++ AFTER GETSETUP --------";
for (int i = 0; i < colfor; ++i) {
std::cout << std::endl;
for (int j = 0; j < rowfor; ++j)
std::cout << " " << testarr[i][j]; // testarr(j, i)
}

//Printing the 3D array in C++ after getsetup
std::cout << "nC++ 3D Array IN C++ AFTER GETSETUP --------";
for (int i = 0; i < three; ++i) {
std::cout << "n";
for (int j = 0; j < two; ++j) {
std::cout << "n";
for (int k = 0; k < one; ++k)
std::cout << " " << arr3d[i][j][k]; // arr3d(k,j,i)
}
}

std::cout << "n";

// Deallocate arrays in *reverse* order!
delete [] arr3d[0][0];
delete [] arr3d[0];
delete [] arr3d;
delete [] testarr[0];
delete [] testarr;

return 0;
}

Quote:
g++ -Wall -ansi -pedantic -o main main.cc
./main

C++ 2D Array IN C++ BEFORE GETSETUP ----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ BEFORE GETSETUP ----------

1 2
3 4
5 6

7 8
9 10
11 12

13 14
15 16
17 18

19 20
21 22
23 24
C++ 2D Array IN C++ AFTER GETSETUP ----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ AFTER GETSETUP ----------

1 2
3 4
5 6

7 8
9 10
11 12

13 14
15 16
17 18

19 20
21 22
23 24

Of course, Fortran is off-topic in comp.lang.c++.

Quote:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Fortran Code

module chek
integer rowfor
integer colfor,onefor,twofor,threefor
real*8, allocatable:: arrfor(:,Smile
real*8, allocatable:: arrfor3d(:,:,Smile
end module chek

subroutine setup(row, col, three, two, one)
use chek
integer row,col,i,j,k,three,two,one
k=1

rowfor = 3
colfor= 10

three = 4
two = 3
one = 2

allocate(arrfor(rowfor,colfor),stat=ierr)
allocate(arrfor3d(one,two,three),stat=ierr)

! Assinging values to 2D array of Fortran
do i=1,rowfor
do j=1,colfor
arrfor(i,j)= 222
end do
end do

! Assinging values to 3D array of Fortran
do i=1,one
do j=1,two
do k=1,three
arrfor3d(i,j,k)= 333
end do
end do
end do

onefor = one
twofor = two
threefor = three
col=colfor
row=rowfor

end subroutine




subroutine getsetup(arr,arr3d)
use chek
real arr(0:rowfor,0:colfor)
real arr3d(0:onefor,0:twofor,0:threefor)

Fortran thinks that these arrays
are larger than they actually are.
You need to make up your mind here.
It's either

real arr(0:rowfor-1, 0:colfor-1)
real arr3d(0:onefor-1, 0:twofor-1, 0:threefor-1)

or it's

real arr(1:rowfor, 1:colfor)
real arr3d(1:onefor, 1:twofor, 1:threefor)


You can simply write

arr = arrfor

and

arr3d = arrfor3d

to copy the arrays.

Quote:
integer i,j,k

print *,''
print *,'@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@'
do i=0,rowfor-1
print *, ' ',(arr(i,j),j=0,colfor-1)
end do


print*,'@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@ '
do i=0,onefor-1
do j=0,twofor-1
print *, ' ',(arr3d(i,j,k),k=0,threefor-1)
enddo
enddo

! Assinging values for the 2D array of c++ with 2d array of fortran
do i=0, rowfor-1
do j=0, colfor-1
arr(i,j)=arrfor(i+1,j+1)
end do
end do


! Assinging values to 3D array of c++ withe the 3D array of fortran
do i=1,onefor
do j=1,twofor
do k=1,threefor
arr3d(i-1,j-1,k-1)=arrfor3d(i,j,k)
enddo
enddo
enddo

end subroutine

////////////////////The Output!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C++ 2D Array IN C++ BEFORE GETSETUP----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ BEFORE GETSETUP----------

1 13
5 17
9 21

2 14
6 18
10 22

3 15
7 19
11 23

4 16
8 20

@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@
1.000000 4.000000 7.000000 10.00000 13.00000 16.00000 19.00000
22.00000 25.00000 28.00000
2.000000 5.000000 8.000000 11.00000 14.00000 17.00000 20.00000
23.00000 26.00000 29.00000
3.000000 6.000000 9.000000 12.00000 15.00000 18.00000 21.00000
24.00000 27.00000 30.00000
@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@
1.000000 2.000000 3.000000 4.000000
0.0000000 0.0000000 0.0000000 0.0000000
0.0000000 0.0000000 0.0000000 0.0000000
13.00000 14.00000 15.00000 16.00000
5.000000 6.000000 7.000000 8.000000
0.0000000 0.0000000 0.0000000 0.0000000
12 24
C++ 2D Array IN C++ AFTER GETSETUP ----------
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
C++ 3D Array IN C++ BEFORE GETSETUP----------

333 333
333 17
9 21

333 333
333 18
10 22

333 333
333 19
11 23

333 333
333 20
12 24

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!////////////////////////////////////////

It can be observed that the 2D arrays are working fine,
i.e., the changes done in C++ are reflected in Fortran and vice versa
but it doesn't seem to happen with 3D.
Some values are not changed as expected.
I hope [that] I have made my point clear.
Any suggestions would be of great help

Back to top
NM
Guest





PostPosted: Fri Jul 29, 2005 9:51 pm    Post subject: Re: passing 3D arrrays from c++ to fortran and viceversa Reply with quote




E. Robert Tisdale wrote:
Quote:
NM wrote:

I am supposed to do some mixed [language] programming with C++ and Fortran.
I was successful in exchanging the 2D arrays from Fortran to C++
and the other way but was unable to the same with the 3D arrays.
The values passed are not all the same.
I am also posting the Fortran and C++ codes
so that you could have a look at them.

Fortran array subscripts appear in order from left to right.
C & C++ array subscripts appear in *reverse* order from right to left.
So Fortran and C arrays appear to be transposes of each other.
For an N-dimensional array:

A[n_N]...[n_2][n_1] ~ A(n_1, n_2, ..., n_N)

Fortran 77/90/95 [sub]programs don't understand pointers to pointers
so you must pass a pointer to the first element of the array

&A[0]...[0][0]

For example:

cat main.cc
#include #include #include #include
extern "C" {
void setup_(int& rowfor, int& colfor,
int& three, int& two, int& one) {
rowfor = 3; colfor = 10;
three = 4; two = 3; one = 2;
}
void getsetup_(float* testarr, float* arr3d) {
// ?
}
}

int main(int argc, char* argv[]) {

int rowfor, colfor, three, two, one;
setup_(rowfor, colfor, three, two, one);

// 2D array dynamic allocation
// testarr[colfor][rowfor] ~ testarr(rowfor, colfor)
float** testarr = new float*[colfor];

testarr[0] = new float[rowfor*colfor];
for (int j = 1; j < colfor; ++j)
testarr[j] = testarr[j-1] + rowfor;

// 3D array dynamic allocation
// arr3d[three][two][one] ~ arr3d(one, two, three)
float*** arr3d = new float**[three];

arr3d[0] = new float*[three*two];
for (int i = 1; i < three; ++i)
arr3d[i] = arr3d[i-1] + two;

arr3d[0][0] = new float[three*two*one];
for (int j = 1; j < two; ++j)
arr3d[0][j] = arr3d[0][j-1] + one;
for (int i = 1; i < three; ++i) {
arr3d[i][0] = arr3d[i-1][0] + two*one;
for (int j = 1; j < two; ++j)
arr3d[i][j] = arr3d[i][j-1] + one;
}

// Assigning values to the 2D array of C++
int inc = 0;
for (int i = 0; i < colfor; ++i)
for (int j = 0; j < rowfor; ++j)
testarr[i][j] = ++inc; // testarr(j, i)

// Assigning values to the 3D array of C++
inc = 0;
for (int i = 0; i < three; ++i)
for (int j = 0; j < two; ++j)
for (int k = 0; k < one; ++k)
arr3d[i][j][k]= ++inc; // arr3d(k, j, i)

//Printing the 2D array in C++ before getsetup
std::cout << "nC++ 2D Array IN C++ BEFORE GETSETUP --------";
for (int i = 0; i < colfor; ++i) {
std::cout << std::endl;
for (int j = 0; j < rowfor; ++j)
std::cout << " " << testarr[i][j]; // testarr(j, i)
}

//Printing the 3D array in C++ before getsetup
std::cout << "nC++ 3D Array IN C++ BEFORE GETSETUP --------";
for (int i = 0; i < three; ++i) {
std::cout << "n";
for (int j = 0; j < two; ++j) {
std::cout << "n";
for (int k = 0; k < one; ++k)
std::cout << " " << arr3d[i][j][k]; // arr3d(k,j,i)
}
}

getsetup_(&testarr[0][0], &arr3d[0][0][0]);

//Printing the 2D array in C++ after getsetup
std::cout << "nC++ 2D Array IN C++ AFTER GETSETUP --------";
for (int i = 0; i < colfor; ++i) {
std::cout << std::endl;
for (int j = 0; j < rowfor; ++j)
std::cout << " " << testarr[i][j]; // testarr(j, i)
}

//Printing the 3D array in C++ after getsetup
std::cout << "nC++ 3D Array IN C++ AFTER GETSETUP --------";
for (int i = 0; i < three; ++i) {
std::cout << "n";
for (int j = 0; j < two; ++j) {
std::cout << "n";
for (int k = 0; k < one; ++k)
std::cout << " " << arr3d[i][j][k]; // arr3d(k,j,i)
}
}

std::cout << "n";

// Deallocate arrays in *reverse* order!
delete [] arr3d[0][0];
delete [] arr3d[0];
delete [] arr3d;
delete [] testarr[0];
delete [] testarr;

return 0;
}

g++ -Wall -ansi -pedantic -o main main.cc
./main

C++ 2D Array IN C++ BEFORE GETSETUP ----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ BEFORE GETSETUP ----------

1 2
3 4
5 6

7 8
9 10
11 12

13 14
15 16
17 18

19 20
21 22
23 24
C++ 2D Array IN C++ AFTER GETSETUP ----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ AFTER GETSETUP ----------

1 2
3 4
5 6

7 8
9 10
11 12

13 14
15 16
17 18

19 20
21 22
23 24

Of course, Fortran is off-topic in comp.lang.c++.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Fortran Code

module chek
integer rowfor
integer colfor,onefor,twofor,threefor
real*8, allocatable:: arrfor(:,Smile
real*8, allocatable:: arrfor3d(:,:,Smile
end module chek

subroutine setup(row, col, three, two, one)
use chek
integer row,col,i,j,k,three,two,one
k=1

rowfor = 3
colfor= 10

three = 4
two = 3
one = 2

allocate(arrfor(rowfor,colfor),stat=ierr)
allocate(arrfor3d(one,two,three),stat=ierr)

! Assinging values to 2D array of Fortran
do i=1,rowfor
do j=1,colfor
arrfor(i,j)= 222
end do
end do

! Assinging values to 3D array of Fortran
do i=1,one
do j=1,two
do k=1,three
arrfor3d(i,j,k)= 333
end do
end do
end do

onefor = one
twofor = two
threefor = three
col=colfor
row=rowfor

end subroutine




subroutine getsetup(arr,arr3d)
use chek
real arr(0:rowfor,0:colfor)
real arr3d(0:onefor,0:twofor,0:threefor)

Fortran thinks that these arrays
are larger than they actually are.
You need to make up your mind here.
It's either

real arr(0:rowfor-1, 0:colfor-1)
real arr3d(0:onefor-1, 0:twofor-1, 0:threefor-1)

or it's

real arr(1:rowfor, 1:colfor)
real arr3d(1:onefor, 1:twofor, 1:threefor)


You can simply write

arr = arrfor

and

arr3d = arrfor3d

to copy the arrays.

integer i,j,k

print *,''
print *,'@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@'
do i=0,rowfor-1
print *, ' ',(arr(i,j),j=0,colfor-1)
end do


print*,'@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@ '
do i=0,onefor-1
do j=0,twofor-1
print *, ' ',(arr3d(i,j,k),k=0,threefor-1)
enddo
enddo

! Assinging values for the 2D array of c++ with 2d array of fortran
do i=0, rowfor-1
do j=0, colfor-1
arr(i,j)=arrfor(i+1,j+1)
end do
end do


! Assinging values to 3D array of c++ withe the 3D array of fortran
do i=1,onefor
do j=1,twofor
do k=1,threefor
arr3d(i-1,j-1,k-1)=arrfor3d(i,j,k)
enddo
enddo
enddo

end subroutine

////////////////////The Output!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C++ 2D Array IN C++ BEFORE GETSETUP----------
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30
C++ 3D Array IN C++ BEFORE GETSETUP----------

1 13
5 17
9 21

2 14
6 18
10 22

3 15
7 19
11 23

4 16
8 20

@@@@@ C++ 2D array IN Fortran i.e IN GETSETUP @@@@@@@@@@@@@@
1.000000 4.000000 7.000000 10.00000 13.00000 16.00000 19.00000
22.00000 25.00000 28.00000
2.000000 5.000000 8.000000 11.00000 14.00000 17.00000 20.00000
23.00000 26.00000 29.00000
3.000000 6.000000 9.000000 12.00000 15.00000 18.00000 21.00000
24.00000 27.00000 30.00000
@@@@@c++ 3D array in fortran in Getsetup@@@@@@@@@@@@@
1.000000 2.000000 3.000000 4.000000
0.0000000 0.0000000 0.0000000 0.0000000
0.0000000 0.0000000 0.0000000 0.0000000
13.00000 14.00000 15.00000 16.00000
5.000000 6.000000 7.000000 8.000000
0.0000000 0.0000000 0.0000000 0.0000000
12 24
C++ 2D Array IN C++ AFTER GETSETUP ----------
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
222 222 222
C++ 3D Array IN C++ BEFORE GETSETUP----------

333 333
333 17
9 21

333 333
333 18
10 22

333 333
333 19
11 23

333 333
333 20
12 24

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!////////////////////////////////////////

It can be observed that the 2D arrays are working fine,
i.e., the changes done in C++ are reflected in Fortran and vice versa
but it doesn't seem to happen with 3D.
Some values are not changed as expected.
I hope [that] I have made my point clear.
Any suggestions would be of great help

I was pleased to get a quick reply and
Thanks a lot Robert, I fixed my problemm.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.