| 查看: 1059 | 回复: 4 | |||
[求助]
帮忙看看人工合成地震记录的小程序的错误点,始终运行不了,又找不到错在哪里?谢谢 已有1人参与
|
|
//正演(合成地震记录) /**************************************************/ //库头文件 #include"stdio.h" #include"stdlib.h" #include"math.h" /***************************************************/ //预处理宏定义 #define L_R 69 #define Trace 31 #define dx 1 //道间距 #define sample 512 #define dt 0.001 #define pi 3.1415926 /****************************************************/ //声明函数 int Ricker(float *x,float y);//雷克子波 int Reflect(float *x,float *y,float r[]);//反射系数 int Conv(float *x,float la,float *y,float lb,float c[]);//褶积 /****************************************************/ //主函数部分 int main() { FILE *fp_reflect,*fp_conv; if((fp_reflect=fopen("reflect.dat","wb" )==NULL)printf("can not open the reflect file\n" ;if((fp_conv=fopen("conv.dat","wb" )==NULL)printf("can not open the conv file\n" ;int i; float F;//子波主频 float Ri[L_R]={0.},Re[sample],Co[sample],P[3],VP[3]; //定义地层模型参数 for(i=0;i<3;i++) { printf("please input the magnitude of VP[%d]\n",i); scanf("%f",VP+i); printf("please input the magnitude of P[%d]\n",i); scanf("%f",P+i); } printf("please input the frequency of wave\n" ;scanf("%d",&F); for(i=0;i<Trace;i++) { Reflect(VP,P,Re); Conv(Re,sample,Ri,L_R,Co); fwrite(Re,sizeof(float),sample,fp_reflect );//frite读一个实数或者结构体变量的值 fwrite(Co,sizeof(float),sample,fp_conv ); } fclose(fp_reflect); fclose(fp_conv); } /****************************************************/ //定义子函数 int Ricker(float *x,float y) { FILE *fp; if((fp=(fopen("Ricker.txt","w" ))==NULL)printf("can not open the file\n" ;int i; float t; for(i=1;i<=L_R/2;i++) { t=i*dt; *(x+L_R/2) = 1.0; x[L_R/2+i] = cos(2*pi*y*t)*exp(-pow(pi*y*t,2)); x[L_R/2-i] = x[L_R/2+i]; } for(i=0;i<L_R;i++) { fprintf(fp,"%f",x+i); } fclose(fp); return 1; } int Reflect(float *x,float *y,float r[]) { int i,Z1,Z2; static int h=25; Z1=(int)h/x[0]*dt; Z2=(int)Z1+h/x[1]*dt; for(i=0;i<sample;i++) { if(i==Z1) r=(x[1]*y[1]-x[0]*y[0])/(x[1]*y[1]+x[0]*y[0]); if(i==Z2) r=(x[2]*y[2]-x[1]*y[1])/(x[1]*y[1]+x[2]*y[2]); else r=0.; } return 1; } int Conv(float *x,float la,float *y,float lb,float c[]) { int i,j; for(i=1;i<=la+lb-1;i++) { c=0.; for(j=0;j<i&&i-j<lb;j++) { c=c+x[j]*x[i-j-1]; } } return 1; } |
» 猜你喜欢
中国科学院华南植物园2025年各类人才招聘宣公告
已经有3人回复
ACS期刊投稿快要正式接受了,副主编提出引用已发表图片或数据引用的书面许可,求助!
已经有11人回复
地球物理学和空间物理学论文润色/翻译怎么收费?
已经有228人回复
香港中文大学(深圳)2025年招聘简章
已经有2人回复
1014511134
专家顾问 (正式写手)
-

专家经验: +82 - 应助: 102 (高中生)
- 金币: 5098.7
- 散金: 20
- 红花: 16
- 帖子: 424
- 在线: 182.4小时
- 虫号: 3220970
- 注册: 2014-05-20
- 性别: GG
- 专业: 应用地球物理学
- 管辖: 程序语言
2楼2015-10-12 10:27:31
3楼2019-04-19 13:53:51
baobiao007
木虫 (职业作家)
中国特色
- 应助: 201 (大学生)
- 金币: 6482.7
- 散金: 557
- 红花: 40
- 帖子: 3050
- 在线: 1009.9小时
- 虫号: 505962
- 注册: 2008-02-18
- 专业: 应用地球物理学

4楼2019-04-19 19:20:01
5楼2019-04-19 19:21:41












)==NULL)
回复此楼
