Mixing C++/Fortran using Two-Dimensional Array
From: WereWolf (werewolf_at_phreaker.net)
Date: 05/23/04
- Next message: Dr Ivan D. Reid: "Re: [f77] Choosing a complete path"
- Previous message: Gerry Thomas: "Re: Steve Lionel - Simple Program Fails with IVF 8.0"
- Next in thread: Atmapuri: "Re: Mixing C++/Fortran using Two-Dimensional Array"
- Reply: Atmapuri: "Re: Mixing C++/Fortran using Two-Dimensional Array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 23 May 2004 09:36:24 +0200
Hi everybody.
I'm writting a code.cpp to call a fortran routine.
In the code.cpp, I allocate dynamically two 2-dim arrays with values I
calaculated before.
I should pass these arrays in argument to the fortran routine to read the
1st array and fill up the 2nd array in it...
I don't know how to do that in fortran.
I'm not an expert (I never used fortran before).
I tried simple static C-style arrays tab1[const1][const2] and
tab2[const1][const2] and it works fine with these fortran lines:
...
integer, intent (in), dimension(nsite,natm) :: attype
double precision, intent (inout), dimension(nsite,natm) :: result
do i=1,nsite
do j=1,natm
write(*,*) i,j,attype
result(i;j)=i+j
enddo
enndo
...
But as I said, my problem is that I calculate nsite and natm in the C++
routine so I cannot use them as size of an array (not constant).
So I need to dynamically allocate them...
Is there an equivalent type in fortran for the int ** type ? (I saw a
pointer type but I don't know if I can use it)
If yes, what should I declare in the fortran routine and how to use it ?
(if I know this pointer will point a zone of memory allocated by the c++
routine)
Summary:
There is a c++ routine in which 2 values are calculated.
These values are used to dynamically allocate 2 2-dim arrays.
The c++ routine fills up the 1st array.
Then it has to call a fortran routine with these arrays.
The fortran routine fills up the 2nd array.
In the end it reads the 2nd array filled up by the fortran routine.
I hope you understand what I wanted to tell you.
Thank you very much for you help !
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.689 / Virus Database: 450 - Release Date: 21/05/2004
- Next message: Dr Ivan D. Reid: "Re: [f77] Choosing a complete path"
- Previous message: Gerry Thomas: "Re: Steve Lionel - Simple Program Fails with IVF 8.0"
- Next in thread: Atmapuri: "Re: Mixing C++/Fortran using Two-Dimensional Array"
- Reply: Atmapuri: "Re: Mixing C++/Fortran using Two-Dimensional Array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|