Hi everyone,
I critically need help to solve this problem related to pointer in C++
Basically, I have a C/C++ program "retardselfener g" calling a Fortran 90 subroutine "surfGF4.f9 0". 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,s igm21,sigm22,si gmN_1N_1,sigmN_ 1N,sigmNN_1,sig mNN;
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 *noisevarleft11 x = &noisevarleft11 ;
double *noisevarleft12 x = &noisevarleft21 ;
............... ............... .....
............... ............... ....etc
noisevarrightNN _1x =&noisevarright NN_1;
noisevarrightNN x = &noisevarrightN N;
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_lef t11.txt", "w");
out11x = fopen("noisevar left11.txt", "w");
sigm11_w = (fftw_complex *) fftw_malloc(siz eof(fftw_comple x) * len);
sigm11_t = (fftw_complex *) fftw_malloc(siz eof(fftw_comple x) * len);
assert(sigm11_w != NULL);
assert(sigm11_t != NULL);
assert(len == length_FFT);
p = fftw_plan_dft_1 d(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];
*noisevarleft11 x[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(131 3): 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(131 5): error: operand of "*" must be a pointer
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(131 5): error: expression must have pointer-to-object type
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(131 6): error: expression must have pointer-to-object type
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 6): error: identifier "T_left" is undefined
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 6): error: expression must have pointer-to-object type
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 8): error: expression must have pointer-to-object type
fprintf(out11x, "%lf", noisevarleft11[i][1]);
..............
.............et c
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
I critically need help to solve this problem related to pointer in C++
Basically, I have a C/C++ program "retardselfener g" calling a Fortran 90 subroutine "surfGF4.f9 0". 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,s igm21,sigm22,si gmN_1N_1,sigmN_ 1N,sigmNN_1,sig mNN;
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 *noisevarleft11 x = &noisevarleft11 ;
double *noisevarleft12 x = &noisevarleft21 ;
............... ............... .....
............... ............... ....etc
noisevarrightNN _1x =&noisevarright NN_1;
noisevarrightNN x = &noisevarrightN N;
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_lef t11.txt", "w");
out11x = fopen("noisevar left11.txt", "w");
sigm11_w = (fftw_complex *) fftw_malloc(siz eof(fftw_comple x) * len);
sigm11_t = (fftw_complex *) fftw_malloc(siz eof(fftw_comple x) * len);
assert(sigm11_w != NULL);
assert(sigm11_t != NULL);
assert(len == length_FFT);
p = fftw_plan_dft_1 d(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];
*noisevarleft11 x[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(131 3): 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(131 5): error: operand of "*" must be a pointer
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(131 5): error: expression must have pointer-to-object type
*sigm11_w[i][j] = *sigm11x[i][j];
^
GlobalRev.c(131 6): error: expression must have pointer-to-object type
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 6): error: identifier "T_left" is undefined
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 6): error: expression must have pointer-to-object type
*noisevarleft11 x[i][j] = - (pow(exp(hbar*w/(k_B*T_left))-1,-1) + 0.5)*hbar*h*len *(*sigm11x[i][j]);
^
GlobalRev.c(131 8): error: expression must have pointer-to-object type
fprintf(out11x, "%lf", noisevarleft11[i][1]);
..............
.............et c
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
Comment