Sun Studio 12: Fortran プログラミングガイド

11.3.2 複素数データ

Fortran の複素数データ項については、2 つの float または 2 つの double からなる 1 つの C の構造体へのポインタとして渡します。

表 11–4 複素数データを渡す

Fortran が C を呼び出す 

C が Fortran を呼び出す 


complex w
double complex z
external CCmplx
call CCmplx(w,z)
...

------------------------------

struct cpx {float r, i;};
struct dpx {double r,i;};
void ccmplx_(
   struct cpx *w,
   struct dpx *z)
{
    w -> r = 32.;
    w -> i = .007;
    z -> r = 66.67;
    z -> i = 94.1;
} 

struct cpx {float r, i;};
struct cpx d1;
struct cpx *w = &d1
struct dpx {double r, i;};
struct dpx d2;
struct dpx *z = &d2
fcmplx_( w, z );
...

---------------

subroutine FCmplx( w, z )
  complex w
  double complex z
  w = (32., .007)
  z = (66.67, 94.1)
  return
end 

64 ビット環境では、COMPLEX 値がレジスタに戻されま す。