Hi everyone,
I critically need help to solve this problem related to pointer in C++
Basically, I have a C/C++ program "retardselfenerg" calling a Fortran 90 subroutine "surfGF4.f90". i am so doubtful if my definitions of pointer variables and their use in calling function are correct.
#include<bla bla bla......h>
#include<bla bla bla.h>
double surfGF4_(double*, double*, double*, double*, double*, double*, double*, double*, double*);
void retardselfenerg(real d_omega, int len)
{
int i,j;
double sigm11,sigm12,sigm21,sigm22,sigmN_1N_1,sigmN_1N,si gmNN_1,sigmNN;
double *sigm11x = &sigm11;
double *sigm12x = &sigm12;
double *sigm21x = &sigm21;
double *sigm22x = &sigm22;
double *sigmN_1N_1x = &sigmN_1N_1;
double *sigmN_1Nx = &sigmN_1N;
double *sigmNN_1x = &sigmNN_1;
double *sigmNNx = &sigmNN;
double noisevarleft11, noisevarleft12, noisevarleft21, noisevarleft22, noisevarrightN_1N_1, noisevarrightN_1N, noisevarrightNN_1, noisevarrightNN;
double *noisevarleft11x = &noisevarleft11;
double *noisevarleft12x = &noisevarleft21;
...................................
..................................etc
noisevarrightNN_1x =&noisevarrightNN_1;
noisevarrightNNx = &noisevarrightNN;
FILE *out11, *out12, *out21, *out22, *outN_1N_1, *outN_1N, *outNN_1,
*outNN, *out11x, *out12x, *out21x, *out22x, *outN_1N_1x, *outN_1Nx, *outNN_1x, *outNNx;
double w, dw;
double k_B = 1;
double hbar = 0.06465;
fftw_complex *sigm11_w, *sigm11_t;
fftw_plan p;
out11 = fopen("self_left11.txt", "w");
out11x = fopen("noisevarleft11.txt", "w");
sigm11_w = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * len);
sigm11_t = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * len);
assert(sigm11_w != NULL);
assert(sigm11_t != NULL);
assert(len == length_FFT);
p = fftw_plan_dft_1d(len, sigm11_w, sigm11_t, FFTW_FORWARD, FFTW_ESTIMATE);
dw = 2.0*M_PI/(h*len);
for (i=0; i<len; i++)
{
w = i * dw;
for (j=0; j<2; ++j)
{
surfGF4_(w, sigm11x, sigm12x, sigm21x, sigm22x, sigmN_1N_1x, sigmN_1Nx, sigmNN_1x, sigmNNx);
/* sigm11[i][j] = *sigm11x[i][j]; */
*sigm11_w[i][j] = *sigm11x[i][j];
*noisevarleft11x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len*(*sigm11x[i][j]);
}
fprintf(out11x, "%lf", noisevarleft11[i][1]);
}
......................
......................etc
The corresponding fortran 90 program looks something like this
subroutine surfGF4(w, sigm11, sigm12, sigm21, sigm22, sigmN_1N_1, sigmN_1N, sigmNN_1, sigmNN)
implicit none
........................
......................
real, dimension (1,2) :: sigm11, sigm12, sigm21, sigm22, sigmN_1N_1, sigmN_1N, sigmNN_1, sigmNN
......................etc
It is necessary to know something about FFTW (fastest fourier transform in the west) library function in this case.
I use SSH and linux icc compiler to compile this program but I get this error in compilation
GlobalRev.c(1313): error: argument of type "double" is incompatible with parameter of type "double *"
surfGF4_(w, sigm11x, sigm12x, sigm21x, sigm22x, sigmN_1N_1x, sigmN_1Nx, sigmNN_1x, sigmNNx);
^
GlobalRev.c(1315): error: operand of "*" must be a pointer
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(1315): error: expression must have pointer-to-object type
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(1316): error: expression must have pointer-to-object type
*noisevarleft11x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len*(*sigm11x[i][j]);
^
GlobalRev.c(1316): error: identifier "T_left" is undefined
*noisevarleft11x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len*(*sigm11x[i][j]);
^
GlobalRev.c(1316): error: expression must have pointer-to-object type
*noisevarleft11x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len*(*sigm11x[i][j]);
^
GlobalRev.c(1318): error: expression must have pointer-to-object type
fprintf(out11x, "%lf", noisevarleft11[i][1]);
..............
.............etc
The most serious error is perhaps the one which says
"error: expression must have pointer-to-object type"
I have repeatedly re-checked my definition of pointer and its use in this program (also considering the use of libary function FFTW in defining complex variables) and also the use of those variables in calling function, but I still could not solve the problem. I think most likely the cause of error is in defining which one is pointer and which one is variable to which th pointer points, but I couldn't see which one is wrong. Could someone expert on C/C++ outthere help me on this please? Thanks in advance.
regards