Home > Back-end >  The program compiled no problem, stop running is why ah.. Great god refer to consult to you all!!!!!
The program compiled no problem, stop running is why ah.. Great god refer to consult to you all!!!!!

Time:04-10

# include
#include
# include
# include
# include
# define R 61
# define S 61
# define N 195
# define dt 0.04
# define PI 3.141593



Int main ()
{
Int r, s, n, k, NFFT;
Float w, t;
P_re float p * * *, * * *, * * * p_im, p0, * * * * * * p0_re, p0_im * * *, * * * m, m_re * * *, * * * m_im;
The FILE * fp1, * fp2;
Void FFT (double sr [61] [195] [61], a double sx [61] [195] [61], int m0, int inv);
Float * * * create_3_array (int m, int n, int t);
P=create_3_array (r, n, s);
P_re=create_3_array (r, n, s);
P_im=create_3_array (r, n, s);
P0=create_3_array (r, n, s);
P0_re=create_3_array (r, n, s);
P0_im=create_3_array (r, n, s);
M=create_3_array (r, n, s);
M_re=create_3_array (r, n, s);
M_im=create_3_array (r, n, s);


/* read data to the p [] [] [] */
If (fp1=fopen (shot_fullwave_new44_use - 6 _new_sun. "dat", "rb")==NULL)
{
Printf (" Open failed \ n ");
exit(0);
}
The else
for(s=0; S<=S; S++)
{
For (r=0; R<=R; R++)
{
for(n=0; N<=N; N++)
{
Fread (& amp; P [r] [n] [s], sizeof (float), 1, fp1);
}
}
Putchar (" \ n ");
}
fclose(fp1);
/* computing FFT frequency */
K=log (N)/log (2);
If (N> Pow (2 k))
K=k + 1;
NFFT=pow (2 k);
Printf (" NFFT=% d k=% d \ n ", NFFT, k);
/* for p_re p_im initialise */
for(s=0; S<=S; S++)
{
For (r=0; R<=R; R++)
{
for(n=0; N<=N; N++)
{
P_re [r] [n] [s]=p [r] [n] [s].
P_im [r] [n] [s]=0.0;
}
}
}
/* to p_re p_im for time dimension FFT, ifft */
FFT (p_re p_im, k, 1);
FFT (p_re p_im, k, 1);
/* * read data/
Output_m. Dat "fp2=fopen ("," wb ");
If (fp2==NULL)
Printf (" NULL2 ");
The else
{
for(s=0; S{
For (r=0; R{
for(n=0; NFwrite (& amp; P [r] [n] [s], sizeof (float), 1, fp2);
}
}
}
return 0;

}

/* FFT/ifft *
Void FFT (double sr [61] [195] [61], a double sx [61] [195] [61], int m0, int inv)
{
Int r, s, I, j, lm, li, k, LMX, np, lix, was;
Double t1, t2, c, f, CV, st and ct;
If (m0 & lt; 0)
return;
LMX=1;
for(i=1; I<=m0; + + I)
LMX +=LMX;
CV=2.0 * PI/LMX (double);
Ct=cos (CV);
St=- inv * sin (CV);
Np=LMX;
Was=m0-2;
for(s=0; S{
For (r=0; R{
for(i=1; I<=was; + + I)
{
Lix=LMX;
LMX/=2;
C=ct;
F=st.
For (li=0; Li{
J=li;
K=j + LMX;
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=t1;
Sx [r] [k] [s]=t2;
+ + j;
+ + k;
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=c * t1 - f * t2;
Sx [r] [k] [s]=f * t1 + c * t2;
}
For (lm=2; Lm{
CV=c;
C=ct - st * * c f;
CV + ct f=st * * f;
For (li=0; Li{
J=li + lm;
K=LMX + j.
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=c * t1 - f * t2;
Sx [r] [k] [s]=f * t1 + c * t2;
}
}
CV=ct;
Ct ct=2.0 * * ct - 1.0;
St=2.0 * st * CV;
}
If (m0 & gt;
=2)For (li=0; Li{
J=li;
K=j + 2;
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=t1;
Sx [r] [k] [s]=t2;
+ + j;
+ + k;
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=inv * t2;
Sx [r] [k] [s]=- inv * t1;
}
For (li=0; Li{
J=li;
K=j + 1;
T1=sr [r] [j] [s] - sr [r] [k] [s].
T2=sx [r] [j] [s] - sx [r] [k] [s].
The sr [r] [j] [s] +=sr [r] [k] [s].
Sx [r] [j] [s] +=sx [r] [k] [s].
The sr [r] [k] [s]=t1;
Sx [r] [k] [s]=t2;
}
LMX=np/2;
J=0;
for(i=1; I{
K=LMX.
While (k<=j)
{
J -=k;
K/=2;
}
J +=k;
If (i{
T1=sr [r] [j] [s].
The sr [r] [j] [s]=sr [r] [I] [s].
The sr [r] [I] [s]=t1;
T1=sx [r] [I] [s].
Sx [r] [j] [s]=sx [r] [I] [s].
Sx [r] [I] [s]=t1;
}
}
If (inv!=1)
return;
T1=1.0/np;
for(i=0; I{
The sr [r] [I] [s] *=t1; Sx [r] [I] [s] *=t1;
}
}
}
}
Float * * * create_3_array (int m, int n, int t)
{
Float * * * array=NULL;
int i,j;
Array=(float) * * * malloc (sizeof (float) * * * m);
for(i=0; I{
Array [I]=(float) * * malloc (sizeof (float *) * n);
for(j=0; JArray [I] [j]=(float *) malloc (sizeof (float) * t);
}
Return array;
}

CodePudding user response:

 int main () 
{
Int r, s, n, k, NFFT;
Float w, t;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related