私はプログラミングを始めたばかりで、C++ コードで Fortran 77 共通ブロックを呼び出したいと考えています。実際、私のようなQ&Aをいくつか読んだことがありますが、あまり明確ではありませんでした....
この共通ブロックは、別の Fortran 77 サブルーチンによって定義されます。
サンプルコードは次のとおりです。
株式会社コモン:
!test common block:
real delta(5,5)
common /test/ delta
!save /test/ delta ! any differences if I comment this line?
tstfunc.f
subroutine tstfunc()
implicit none
include 'common.inc'
integer i,j
do i = 1, 5
do j = 1, 5
delta(i,j)=2
if(i.ne.j) delta(i,j)=0
write (*,*) delta(i,j)
end do
end do
end
tst01.cpp
#include <iostream>
extern "C"
{
void tstfunc_();
};
void printmtrx(float (&a)[5][5]){
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
std::cout<<a[j][i]<<'\t';
a[j][i]+=2;
}
std::cout<<std::endl;
}
}
int main()
{
//start...
tstfunc_();
printmtrx(delta);//here i want to call delta and manipulate it.
return 0;
}
delta
(common.inc から) C++ 関数に渡したい場合printmtrx()
、どうすればよいですか?