-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cu
100 lines (77 loc) · 2.87 KB
/
main.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Hello world of wave propagation in CUDA. FDTD acoustic wave propagation in homogeneous medium. Second order accurate in time and eigth in space.
Oleg Ovcharenko
Vladimir Kazei, 2019
*/
#include <iostream>
#include <string>
#include "stdio.h"
#include "math.h"
#include "stdlib.h"
#include "string.h"
/*
Add this to c_cpp_properties.json if linting isn't working for CUDA libraries
"includePath": [
"/usr/local/cuda-10.0/targets/x86_64-linux/include",
"${workspaceFolder}/**"
],
*/
#include "btree.cuh"
using namespace std;
/*
===================================================================================
MAIN
===================================================================================
*/
int main(int argc, char *argv[])
{
/* Main program that reads and writes data and read input variables */
bool verb;
sf_init(argc,argv); // init RSF
if(! sf_getbool("verb",&verb)) verb=0;
// Setting up I/O files
sf_file Fvel=NULL;
Fvel = sf_input("vel");
sf_file Freflectivity=NULL;
Freflectivity = sf_input("ref");
// Getting command line parameters
geometry param = getParameters(Fvel);
// Allocate memory for velocity model
velocity h_model = getVelFields (Fvel, Freflectivity, param);
cerr<<"vp = "<<h_model.maxVel<<endl;
cerr<<"param.taperBorder = "<<param.taperBorder<<endl;
// Taper mask
float *h_tapermask = tapermask(param);
// Time stepping
source h_wavelet = fillSrc(param, h_model);
// Data
seismicData h_seisData = allocHostSeisData(param, h_wavelet.timeSamplesNt);
// Set Output files
int dimensions[3] = {h_wavelet.timeSamplesNt,param.nReceptors,param.nShots};
float spacings[3] = {h_wavelet.timeStep,param.modelDx,10};
int origins[3] = {0,0,0};
sf_file Fdata_directWave = createFile3D("comOD",dimensions,spacings,origins);
sf_file Fonly_directWave = createFile3D("OD",dimensions,spacings,origins);
sf_file Fdata = createFile3D("data",dimensions,spacings,origins);
sf_putint(Fdata,"incShots",param.incShots);
sf_putint(Fdata,"incRec",param.incRec);
sf_putint(Fdata,"gxbeg",param.firstReceptorPos);
sf_putint(Fdata,"sxbeg",param.srcPosX);
sf_putint(Fdata,"sybeg",param.srcPosY);
test_getParameters(param, h_wavelet);
// ===================MODELING======================
born(param, h_model, h_wavelet, h_tapermask, h_seisData, Fonly_directWave, Fdata_directWave, Fdata, false);
// =================================================
printf("Clean memory...");
delete[] h_model.velField;
delete[] h_model.extVelField;
delete[] h_model.firstLayerVelField;
delete[] h_seisData.seismogram;
delete[] h_seisData.directWaveOnly;
delete[] h_tapermask;
//delete[] h_time;
delete[] h_wavelet.timeSeries;
return 0;
}