程序如下:
[Fortran] 纯文本查看 复制代码 subroutine ricker(fz,tmax,dt,rick) Bind(C,Name="ricker")
use,intrinsic :: iso_c_binding
implicit none
integer(c_int) i,fz,tmax
real(c_float) dt,t,rick(0:tmax)
real,parameter :: PAI=3.141593
open(10,file='ricker.dat')
do i=0,tmax
t=i*dt
!rick(i)=(1-2*(PAI*fz*(t-1.2/fz))**2)*exp(-(PAI*fz*(t-1.2/fz))**2)
rick(i)=0.0
write(10,*) t,rick(i)
end do
close(10)
end subroutine ricker
[C] 纯文本查看 复制代码 #include <stdio.h>
void ricker(int fz,int tmax,float dt,float rick[]);
int main()
{
int fz,tmax;
float dt,t,rick[tmax+1];
fz=40;
tmax=500;
dt=0.001;
ricker(fz,tmax,dt,rick);
printf("ricker wavelet is computed!");
getchar();
return 0;
}
|