Commit b15a550c authored by tilman.metz's avatar tilman.metz

Stopped support for segy and simplified the output

Segy isn't used in our working group and therfore not tested.
Also an segy Input for the obeserved seismograms is missing.
In future options for reading binary and ascii seismograms should be implemented
parent c9e22a3e
......@@ -191,12 +191,9 @@ The last option (\textbf{READREC}=2) is very attractive for 3D FWI because it de
\end{verbatim}
For the seismogram output every \textbf{NDT}th sample is written to file starting at timestep \textbf{NDTSHIFT} of the FD modeling. The file format can be choosen with \textbf{SEIS\_FORMAT}:\\
0: SEG-Y (ASCII-text/native 4-byte-floats (IEEE on PC)/little endian on PC)\\
1: SU (native 4-byte-floats (IEEE on PC)/little endian on PC)\\
2: TEXTUAL (native ASCII)\\
3: BINARY (IEEE-4-byte-floats on PC/little endian on PC)\\
4: SEG-Y (ASCII-text/native 4-byte-floats (IEEE on PC)/little endian on PC)\\
5: SEG-Y (ASCII-text/IBM-4-byte-floats on PC/big endian on PC) \\
We recommend the use of the SU-format. This format stores a header in front of each trace with information like time sampling, source and receiver position and tracenumber. Seismic Unix offers different functions for data processing of SU-files.\\
The seismograms are stored for each component, each shot and each iteration in the folder \textit{su}. \textbf{SEIS\_FILE} defines the name of the files, here for example \textit{cal\_toy\_vx\_it3.su.shot2}
\subsubsection*{Snapshots}
......
......@@ -94,7 +94,6 @@ IFOS_UTIL = \
writedsk.c \
writemod.c \
writepar.c \
rwsegy.c \
IFOS_SRC = \
ifos3d.c \
......
......@@ -45,7 +45,7 @@ float *** ptaus, float *** ptaup, float *peta, float **srcpos, int nsrc, int **r
extern int NX, NY, NZ, L, MYID, IDX, IDY, IDZ, FW, POS[4], NT, NDT, NDTSHIFT;
extern int FDCOEFF;
extern int READREC, NPROCX,NPROCY,NPROCZ, FW, ABS_TYPE, SRCREC, FREE_SURF;
extern int SNAP, SEISMO, SEIS_FORMAT[6], SNAP_FORMAT;
extern int SNAP, SEISMO, SEIS_FORMAT, SNAP_FORMAT;
extern int NSHOTS_STEP;
/*extern int RUN_MULTIPLE_SHOTS; no determination is done for the output check whether the simulation runs with one or multiple shot
-> directorys specified in input file should work in both cases */
......@@ -308,16 +308,14 @@ float *** ptaus, float *** ptaup, float *peta, float **srcpos, int nsrc, int **r
/*Checking SEISMOGRAM Output Particle velocities */
/*-------------------------------------- */
if (SEISMO>0) {
switch (SEIS_FORMAT[0]){
case 0: sprintf(file_ext,"sgy"); break;
switch (SEIS_FORMAT){
case 0: sprintf(file_ext,"su"); break;
case 1: sprintf(file_ext,"su"); break;
case 2: sprintf(file_ext,"txt"); break;
case 3: sprintf(file_ext,"bin"); break;
case 4: sprintf(file_ext,"sgy"); break;
case 5: sprintf(file_ext,"sgy"); break;
}
/*if ((RUN_MULTIPLE_SHOTS)||(SEIS_FORMAT[4])) {
/*if ((RUN_MULTIPLE_SHOTS)||(SEIS_FORMAT)) {
possibly many files ... -> perform check of write and execute permission for directories, only
fprintf(fp," Check accessibility for seismogram files (multiple shots) ... \n");
......@@ -354,7 +352,7 @@ float *** ptaus, float *** ptaup, float *peta, float **srcpos, int nsrc, int **r
fprintf(fp," Check accessibility for seismogram files ... \n");
if (SEIS_FORMAT[0]==2) strcpy(xmod,"a");
if (SEIS_FORMAT==2) strcpy(xmod,"a");
else strcpy(xmod,"ab");
switch (SEISMO){
case 1: /* particle velocities only */
......
......@@ -31,7 +31,7 @@ void exchange_par(void){
extern float XREC1, XREC2, YREC1, YREC2, ZREC1, ZREC2;
extern float ALPHA, BETA, VPPML;
extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST;
extern int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT[6], FREE_SURF, READMOD, READREC;
extern int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT, FREE_SURF, READMOD, READREC;
extern int BOUNDARY, REC_ARRAY, LOG, IDX, IDY, IDZ, ABS_TYPE;
extern float TSNAP1, TSNAP2, TSNAPINC, FW, REFREC[4], DAMPING, FPML;
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE];
......@@ -123,12 +123,8 @@ void exchange_par(void){
idum[27] = NDT;
idum[28] = NDTSHIFT;
idum[29] = SEIS_FORMAT[0];
idum[30] = SEIS_FORMAT[1];
idum[31] = SEIS_FORMAT[2];
idum[32] = SEIS_FORMAT[3];
idum[33] = SEIS_FORMAT[4];
idum[34] = SEIS_FORMAT[5];
idum[29] = SEIS_FORMAT;
idum[35] = RUN_MULTIPLE_SHOTS;
idum[36] = SNAP_PLANE;
......@@ -252,12 +248,7 @@ void exchange_par(void){
NDT = idum[27];
NDTSHIFT = idum[28];
SEIS_FORMAT[0] = idum[29];
SEIS_FORMAT[1] = idum[30];
SEIS_FORMAT[2] = idum[31];
SEIS_FORMAT[3] = idum[32];
SEIS_FORMAT[4] = idum[33];
SEIS_FORMAT[5] = idum[34];
SEIS_FORMAT = idum[29];
RUN_MULTIPLE_SHOTS= idum[35];
SNAP_PLANE= idum[36];
......
......@@ -119,7 +119,7 @@ void note(FILE *fp);
void outseis(FILE *fp, FILE *fpdata, int comp, float **section,
int **recpos, int **recpos_loc, int ntr, float ** srcpos_loc,
int nsrc, int ns, int seis_form[6]);
int nsrc, int ns, int seis_form);
float *rd_sour(int *nts,FILE* fp_source);
......
......@@ -28,7 +28,7 @@ float DX, DY, DZ, TIME, DT, TS, PLANE_WAVE_DEPTH, PHI;
float TSNAP1, TSNAP2, TSNAPINC, *FL, TAU, REC_ARRAY_DEPTH, REC_ARRAY_DIST;
float XREC1, XREC2, YREC1, YREC2, ZREC1=0.0, ZREC2=0.0;
float REFREC[4]={0.0, 0.0, 0.0, 0.0}, DAMPING=8.0, VPPML, FPML;
int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT[6]={0, 0, 0, 0, 0, 0}, FREE_SURF, READMOD, MOD_FORMAT, READREC, REC_ARRAY, LOG, FDORDER, FW=0, ABS_TYPE, BLOCK;
int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT, FREE_SURF, READMOD, MOD_FORMAT, READREC, REC_ARRAY, LOG, FDORDER, FW=0, ABS_TYPE, BLOCK;
int NX, NY, NZ=1, NT, SOURCE_SHAPE, SOURCE_TYPE, SNAP, SNAP_FORMAT, BOUNDARY, SRCREC, SNAP_PLANE;
float ALPHA, BETA;
int NXG, NYG, NZG, IDX, IDY, IDZ, L=1, NX1, NX2, NY1, NY2, NZ1, NZ2, DRX, DRZ, RUN_MULTIPLE_SHOTS, FDCOEFF;
......
......@@ -245,7 +245,7 @@ if(METHOD) nseismograms+=4;
if(HESS) memgrad+=3*fac2*fac3;
if(LBFGS) membfgs=NUMPAR*BFGSNUM*3*fac3;
}
memtotal=memdyn+memmodel+memseismograms+membuffer+(buffsize*pow(2.0,-20.0))+memgrad+memdynf+membfgs;
memtotal=memdyn+memmodel+memseismograms+membuffer+(buffsize*pow(2.0,-20.0))+memgrad+memdynf+membfgs+memcpml;
if (MYID==0){
fprintf(FP,"\n ------------------ MEMORY ALLOCATION --------------------------- \n");
......
......@@ -2,23 +2,23 @@
* Copyright (C) 2015 For the list of authors, see file AUTHORS.
*
* This file is part of IFOS3D.
*
*
* IFOS3D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
*
* IFOS3D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with IFOS3D. See file COPYING and/or
* along with IFOS3D. See file COPYING and/or
* <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/
/*------------------------------------------------------------------------
* Write seismograms to disk
* Write seismograms to disk
* ----------------------------------------------------------------------*/
#include "fd.h"
......@@ -28,28 +28,14 @@
void outseis(FILE *fp, FILE *fpdata, int comp, float **section,
int **recpos, int **recpos_loc, int ntr, float ** srcpos,
int nsrc, int ns, int seis_form[6]){
int **recpos, int **recpos_loc, int ntr, float **srcpos,
int nsrc, int ns, int seis_form) {
/* declaration of extern variables */
extern int NDT,NDTSHIFT, FDMPIVERS;
extern int NDT;
extern float DX, DY, DZ, TIME, DT, REFREC[4];
extern char * FILEINP[STRING_SIZE];
extern int ASCIIEBCDIC,LITTLEBIG,IEEEIBM;
/* declaration of extern functions from rwsegy.c */
extern int DDN_wsegytxth(FILE * outstream, int asciiebcdic, char * kindofdata, char * infilename, int ns, float dt, int ndt);
extern int DDN_wsegybinh(FILE * outstream, int lbendian, int ieeeibm, int meterfeet, int ns,
float dt, int ndt, int ntrpr, int nart);
extern int DDN_wbindata(FILE * outstream, int outlen, float * indata, int inlen, int first,
int step, int padding, int lbendian, int ieeeibm, int meterfeet);
extern int DDN_wtxtdata(FILE * outstream, int outlen, float * indata, int inlen, int first, int step, int padding, int asciiebcdic, int meterfeet, char * dataformat, char * dataseperator, char * dataendmark);
extern int DDN_wtraceh(FILE * outstream, int lbendian, int ieeeibm, int meterfeet, int susegy,
int ns, float dt, float dtshift, float srctime, int traceno, int globrecno, int shotno,
int recno, int comp, int trid, int ntraces, int **recpos, int **recpos_loc, float ** srcpos,
int nsrc, float xcoo, float ycoo);
extern int LITTLEBIG;
/* declaration of local variables */
int i,j, * pint;
segy tr;
......@@ -57,72 +43,43 @@ int nsrc, int ns, int seis_form[6]){
float xr, yr, zr, y, z, scalefac, tfloat; /*x*/
float XS=0.0, YS=0.0, ZS=0.0;
const float scale=3.0;
char kindofdata[STRING_SIZE];
char * infilename;
float indatap[ns];
infilename=(char *)FILEINP;
strncpy(kindofdata,"synthetic seismograms modeled by ifos",STRING_SIZE);
if (FDMPIVERS==33)
strncat(kindofdata," (3D isotropic elastic)",STRING_SIZE-sizeof("synthetic seismograms modeled by ifos"));
else if (FDMPIVERS==32)
strncat(kindofdata," (3D isotropic acoustic)",STRING_SIZE-sizeof("synthetic seismograms modeled by ifos"));
kindofdata[STRING_SIZE-1]='\0';
if (nsrc==1){
/* only if one source position is specified in SOURCE_FILE,
if (nsrc==1) {
/* only if one source position is specified in SOURCE_FILE,
source coordinates are written into trace header fields */
XS=srcpos[1][1];
YS=srcpos[2][1];
XS=srcpos[1][1];
YS=srcpos[2][1];
ZS=srcpos[3][1];
}
}
scalefac=pow(10.0,scale);
switch(seis_form[0]){
switch (seis_form) {
case 0 :
case 4 :
case 5 :
/* fprintf(stderr,"BEEN HERE !!!\n") */
DDN_wsegytxth(fpdata, seis_form[1], kindofdata, infilename,ns,DT,NDT);
DDN_wsegybinh(fpdata, seis_form[2], seis_form[3], seis_form[4], ns, DT, NDT, ntr, 0);
for(tracl=1;tracl<=ntr;tracl++){
DDN_wtraceh(fpdata, seis_form[2], seis_form[3], seis_form[4], 1, ns, DT*NDT, DT*NDTSHIFT, 0.0, tracl, recpos_loc[4][tracl], nsrc,
tracl, comp, 1, ntr, recpos, recpos_loc, srcpos, nsrc, 0, 0);
for(j=0;j<ns;j++) indatap[j]=section[tracl][j+1];
DDN_wbindata(fpdata, ns, indatap, ns, 0, 1, 0, seis_form[2], seis_form[3], seis_form[4]);
}
break;
case 1 : /* SU caution: allows IBM floats!*/
for(tracl=1;tracl<=ntr;tracl++){
DDN_wtraceh(fpdata, seis_form[2], seis_form[3], seis_form[4], 0, ns, DT*NDT, DT*NDTSHIFT, 0.0, tracl, recpos_loc[4][tracl], nsrc,
tracl, comp, 1, ntr, recpos, recpos_loc, srcpos, nsrc, 0, 0);
for(j=0;j<ns;j++) indatap[j]=section[tracl][j+1];
DDN_wbindata(fpdata, ns, indatap, ns, 0, 1, 0, seis_form[2], seis_form[3], seis_form[4]);
}
break;
case 7 : /* SU ~ (IEEE) SEGY without file-headers and slightly modified trace headers (original version) */
for(tracl=1;tracl<=ntr;tracl++){
xr=recpos[1][recpos_loc[4][tracl]]*DX;
yr=recpos[2][recpos_loc[4][tracl]]*DY;
zr=recpos[3][recpos_loc[4][tracl]]*DZ;
/*x=xr-REFREC[1];*/
y=yr-REFREC[2];
z=zr-REFREC[3];
case 1 : /* SU ~ (IEEE) */
/* fprintf(stderr,"BEEN HERE !!!\n"); */
for (tracl=1; tracl<=ntr; tracl++) {
xr=recpos[1][recpos_loc[4][tracl]]*DX;
yr=recpos[2][recpos_loc[4][tracl]]*DY;
zr=recpos[3][recpos_loc[4][tracl]]*DZ;
/*x=xr-REFREC[1];*/
y=yr-REFREC[2];
z=zr-REFREC[3];
tr.tracl=recpos_loc[4][tracl]; /* trace sequence number within line */
tr.ep=comp;
tr.cdp=recpos_loc[4][tracl];
//tr.cdp=recpos_loc[4][tracl];
tr.trid=1; /* trace identification code: 1=seismic*/
tr.offset=iround(sqrt((XS-xr)*(XS-xr)
+(YS-yr)*(YS-yr)
+(ZS-zr)*(ZS-zr))*scalefac);
+(YS-yr)*(YS-yr)
+(ZS-zr)*(ZS-zr))*scalefac);
tr.gelev=iround(yr*scalefac);
tr.sdepth=iround(YS*scalefac); /* source depth (positive) */
/* angle between receiver position and reference point
(sperical coordinate system: used for tunnel geometry) */
tr.gdel=iround(atan2(-y,z)*180.0*scalefac/PI);
/* angle between receiver position and reference point
(sperical coordinate system: used for tunnel geometry) */
tr.gdel=iround(atan2(-y,z)*180.0*scalefac/PI);
tr.gwdep=iround(sqrt(z*z+y*y)*scalefac);
tr.scalel=(short)(-scale);
......@@ -130,120 +87,241 @@ int nsrc, int ns, int seis_form[6]){
tr.sx=iround(XS*scalefac); /* X source coordinate */
tr.sy=iround(ZS*scalefac); /* Z source coordinate */
/* group coordinates */
/* group coordinates */
tr.gx=iround(xr*scalefac);
tr.gy=iround(zr*scalefac);
tr.gy=iround(zr*scalefac);
tr.ns=(unsigned short)ns; /* number of samples in this trace */
tr.dt=(unsigned short)iround(((float)NDT*DT)*1.0e6); /* sample interval in micro-seconds */
tr.d1=(float)(TIME/ns); /* sample spacing for non-seismic data */
tr.f1=0.0; /* first sample location for non-seismic data */
tr.d2=0.0; /* sample spacing between traces */
tr.f2=0.0;
tr.d1=0;
tr.tracr=0 ; /* trace sequence number within reel */
tr.fldr=0 ; /* field record number */
tr.tracf=0 ; /* trace number within field record */
tr.ep=0 ; /* energy source point number */
tr.cdpt=0 ; /* trace number within CDP ensemble */
tr.nvs=0 ; /* number of vertically summed traces (see vscode
in bhed structure) */
tr.nhs=0 ; /* number of horizontally summed traces (see vscode
in bhed structure) */
tr.duse=0 ; /* data use:
1 = production
2 = test */
tr.gdel=0 ; /* datum elevation at receiver group */
tr.sdel=0 ; /* datum elevation at source */
tr.gwdep=0 ; /* water depth at receiver group */
tr.counit=0 ; /* coordinate units code:
for previous four entries
1 = length (meters or feet)
2 = seconds of arc (in this case, the
X values are longitude and the Y values
are latitude, a positive value designates
the number of seconds east of Greenwich
or north of the equator */
tr.wevel=0 ; /* weathering velocity */
tr.swevel=0 ; /* subweathering velocity */
tr.sut=0 ; /* uphole time at source */
tr.gut=0 ; /* uphole time at receiver group */
tr.sstat=0 ; /* source static correction */
tr.gstat=0 ; /* group static correction */
tr.tstat=0 ; /* total static applied */
tr.laga=0 ; /* lag time A, time in ms between end of 240-
byte trace identification header and time
break, positive if time break occurs after
end of header, time break is defined as
the initiation pulse which maybe recorded
on an auxiliary trace or as otherwise
specified by the recording system */
tr.lagb=0 ; /* lag time B, time in ms between the time break
and the initiation time of the energy source,
may be positive or negative */
tr.delrt=0 ; /* delay recording time, time in ms between
initiation time of energy source and time
when recording of data samples begins
(for deep water work if recording does not
start at zero time) */
tr.muts=0 ; /* mute time--start */
tr.mute=0 ; /* mute time--end */
tr.gain=0 ; /* gain type of field instruments code:
1 = fixed
2 = binary
3 = floating point
4 ---- N = optional use */
tr.igc=0 ; /* instrument gain constant */
tr.igi=0 ; /* instrument early or initial gain */
tr.corr=0 ; /* correlated:
1 = no
2 = yes */
tr.sfs=0 ; /* sweep frequency at start */
tr.sfe=0 ; /* sweep frequency at end */
tr.slen=0 ; /* sweep length in ms */
tr.styp=0 ; /* sweep type code:
1 = linear
2 = cos-squared
3 = other */
tr.stas=0 ; /* sweep trace length at start in ms */
tr.stae=0 ; /* sweep trace length at end in ms */
tr.tatyp=0 ; /* taper type: 1=linear, 2=cos^2, 3=other */
tr.afilf=0 ; /* alias filter frequency if used */
tr.afils=0 ; /* alias filter slope */
tr.nofilf=0 ; /* notch filter frequency if used */
tr.nofils=0 ; /* notch filter slope */
tr.lcf=0 ; /* low cut frequency if used */
tr.hcf=0 ; /* high cut frequncy if used */
tr.lcs=0 ; /* low cut slope */
tr.hcs=0 ; /* high cut slope */
tr.year=0 ; /* year data recorded */
tr.day=0 ; /* day of year */
tr.hour=0 ; /* hour of day (24 hour clock) */
tr.minute=0 ; /* minute of hour */
tr.sec=0 ; /* second of minute */
tr.timbas=0 ; /* time basis code:
1 = local
2 = GMT
3 = other */
tr.trwf=0 ; /* trace weighting factor, defined as 1/2^N
volts for the least sigificant bit */
tr.grnors=0 ; /* geophone group number of roll switch
position one */
tr.grnofr=0 ; /* geophone group number of trace one within
original field record */
tr.grnlof=0 ; /* geophone group number of last trace within
original field record */
tr.gaps=0 ; /* gap size (total number of groups dropped) */
tr.otrav=0 ; /* overtravel taper code:
1 = down (or behind)
2 = up (or ahead) */
/* local assignments */
tr.f1=0.0; /* first sample location for non-seismic data */
tr.d2=0.0; /* sample spacing between traces */
tr.f2=0.0; /* first trace location */
tr.ungpow=0.0; /* negative of power used for dynamic
range compression */
tr.unscale=0.0; /* reciprocal of scaling factor to normalize
range */
tr.ntr=0 ; /* number of traces */
tr.mark=0 ;
for (j=1; j<=ns; j++) {
tr.data[j]=section[tracl][j];
}
fwrite(&tr,240,1,fpdata);
if (seis_form[3]) for(j=0;j<ns;j++) tr.data[j]=section[tracl][j+1]/0.3048; /* FEET */
else for(j=0;j<ns;j++) tr.data[j]=section[tracl][j+1];
fwrite(tr.data,4,ns,fpdata);
}
break;
case 6 : /* pseudo-SU (segy-traces headers & traces) rwsegy.c */
for(tracl=1;tracl<=ntr;tracl++){
DDN_wtraceh(fpdata, seis_form[2], seis_form[3], seis_form[4], 1, ns, DT*NDT, DT*NDTSHIFT, 0.0, tracl, recpos_loc[4][tracl], nsrc,
tracl, comp, 1, ntr, recpos, recpos_loc, srcpos, nsrc, 0, 0);
for(j=0;j<ns;j++) indatap[j]=section[tracl][j+1];
DDN_wbindata(fpdata, ns, indatap, ns, 0, 1, 0, seis_form[2], seis_form[3], seis_form[4]);
fwrite(&tr.data[1],4,ns,fpdata);
}
break;
case 2 :if (ASCIIEBCDIC==seis_form[1]){
if (seis_form[4]==1) /*OUTPUT IN FEET*/ switch(seis_form[3]){
case 1: for(j=1;j<=ns;j++){ /*ASCII ONE COLUMN PER TRACE */
for(i=1;i<=ntr;i++) fprintf(fpdata,"%e\t", section[i][j]/0.3048);
fprintf(fpdata,"\n");
}
break;
case 2: for(i=1;i<=ntr;i++) /*ASCII ONE LINE*/ for(j=1;j<=ns;j++) fprintf(fpdata,"%e ",section[i][j]/0.3048);
break;
case 3: for(i=1;i<=ntr;i++){ /*ASCII ONE LINE PER RECEIVER */
for(j=1;j<=ns;j++) fprintf(fpdata,"%e\t", section[i][j]/0.3048);
fprintf(fpdata,"\n");
}
break;
default:for(i=1;i<=ntr;i++) /*ASCII ONE COLUMN*/ for(j=1;j<=ns;j++) fprintf(fpdata,"%e\n",section[i][j]/0.3048);
}
else /*OUTPUT IN METER*/ switch(seis_form[3]){
case 1: for(j=1;j<=ns;j++){ /*ASCII ONE COLUMN PER TRACE */
for(i=1;i<=ntr;i++) fprintf(fpdata,"%e\t", section[i][j]);
fprintf(fpdata,"\n");
}
break;
case 2: for(i=1;i<=ntr;i++) /*ASCII ONE LINE*/ for(j=1;j<=ns;j++) fprintf(fpdata,"%e ",section[i][j]);
break;
case 3: for(i=1;i<=ntr;i++){ /*ASCII ONE LINE PER RECEIVER */
for(j=1;j<=ns;j++) fprintf(fpdata,"%e\t", section[i][j]);
fprintf(fpdata,"\n");
}
break;
default:for(i=1;i<=ntr;i++) /*ASCII ONE COLUMN*/ for(j=1;j<=ns;j++) fprintf(fpdata,"%e\n",section[i][j]);
}
}
else{
switch(seis_form[3]){
case 1:for(j=1;j<=ns;j++){ /*ASCII ONE COLUMN PER TRACE */
for(i=1;i<=ntr;i++) fprintf(fpdata,"%e\t", section[i][j]);
fprintf(fpdata,"\n");
}
break;
case 2:
case 3:
default:
/* dseperator[]="\t", ddataendmark[]="\n", ddataformat[]="%e"
DDN_wtxtdata(fpdata,outlen,&indata,inlen,0,1,0,seis_form[1],seis_form[4], char * dataformat, char * dataseperator, char * dataendmark); */
;
case 2 :
for (j=1; j<=ns; j++) { /*ASCII ONE COLUMN PER TRACE */
for (i=1; i<=ntr; i++) {
fprintf(fpdata,"%e\t", section[i][j]);
}
fprintf(fpdata,"\n");
}
break;
case 3 : /*BINARY */
if ((seis_form[3]==IEEEIBM)&&(seis_form[2]==LITTLEBIG)){ /* OUTPUT NATIVE FLOATS */
if (seis_form[4]==1){ /*OUTPUT IN FEET*/
for(i=1;i<=ntr;i++) for(j=1;j<=ns;j++){
tfloat=section[i][j]/0.3048;
fwrite(&tfloat,sizeof(float),1,fpdata);
if (!LITTLEBIG) { /* OUTPUT NATIVE FLOATS */
for (i=1; i<=ntr; i++) for (j=1; j<=ns; j++) {
fwrite(&section[i][j],sizeof(float),1,fpdata);
}
}
else for(i=1;i<=ntr;i++) for(j=1;j<=ns;j++) fwrite(&section[i][j],sizeof(float),1,fpdata);
}
else {
if ((seis_form[3]==IEEEIBM)&&(seis_form[2]!=LITTLEBIG)) /* SWAP FLOATS */ {
if (seis_form[4]==1) /*OUTPUT IN FEET*/ for(i=1;i<=ntr;i++) for(j=1;j<=ns;j++){
tfloat=section[i][j]/0.3048;
pint=(int *) &tfloat;
*pint=((*pint>>24)&0xff)|((*pint&0xff)<<24)|((*pint>>8)&0xff00)|((*pint&0xff00)<<8);
fwrite(&tfloat,sizeof(float),1,fpdata);
}
else for(i=1;i<=ntr;i++) for(j=1;j<=ns;j++){
tfloat=section[i][j];
pint=(int *) &tfloat;
*pint=((*pint>>24)&0xff)|((*pint&0xff)<<24)|((*pint>>8)&0xff00)|((*pint&0xff00)<<8);
fwrite(&tfloat,sizeof(float),1,fpdata);
}
}
else
for(i=1;i<=ntr;i++) for(j=1;j<=ns;j++) DDN_wbindata(fpdata,1,&section[i][j],1,0,1,0,seis_form[2],seis_form[3],seis_form[4]); /* probably extremely slow !!! */
}
} else {
/* SWAP FLOATS */
for (i=1; i<=ntr; i++) for (j=1; j<=ns; j++) {
tfloat=section[i][j];
pint=(int *) &tfloat;
*pint=((*pint>>24)&0xff)|((*pint&0xff)<<24)|((*pint>>8)&0xff00)|((*pint&0xff00)<<8);
/* explanation:
* (*pint>>24)&0xff shifts 3 bytes (3*8) to the right and takes with &=and only the least significant byte (other bytes 0) 0 0 0 1
(*pint&0xff)<<24 sets the first 3 bytes to zero (takes only the least significant byte) than shifts 3 bytes to the left (0 0 0 1 -> 1 0 0 0)
(*pint>>8)&0xff00 shifts 1 byte to the right and than takes only 3rd byte (0 0 1 0)
(*pint&0xff00)<<8 sets bytes 1,2,4 to zero and shifts 1 byte to the left (0 1 0 0)
The |=or operator adds all for parts to the swaped float
*/
fwrite(&tfloat,sizeof(float),1,fpdata);
}
}
break;
default :
fprintf(fp," Don't know data format for seismograms !\n");
fprintf(fp," Don't know data format for seismograms ! Choose SEIS_FORMAT 1-3 \n");
fprintf(fp," No output written. ");
}
fclose(fpdata);
}
......@@ -33,14 +33,14 @@ void read_par_json(FILE *fp, char *fileinp) {
extern float DX, DY, DZ, TIME, DT, TS, *FL, TAU, PLANE_WAVE_DEPTH, PHI;
extern float XREC1, XREC2, YREC1, YREC2, ZREC1, ZREC2, ALPHA, BETA;
extern float REC_ARRAY_DEPTH, REC_ARRAY_DIST;
extern int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT[6], FREE_SURF, READMOD, MOD_FORMAT, READREC, RUN_MULTIPLE_SHOTS;
extern int SEISMO, NDT, NDTSHIFT, NGEOPH, SEIS_FORMAT, FREE_SURF, READMOD, MOD_FORMAT, READREC, RUN_MULTIPLE_SHOTS;
extern int BOUNDARY, REC_ARRAY, IDX, IDY, IDZ, ABS_TYPE;
extern float TSNAP1, TSNAP2, TSNAPINC, REFREC[4], DAMPING, FPML, VPPML;
extern char MFILE[STRING_SIZE], SIGNAL_FILE[STRING_SIZE];
extern char SNAP_FILE[STRING_SIZE], SOURCE_FILE[STRING_SIZE], REC_FILE[STRING_SIZE];
extern char SEIS_FILE[STRING_SIZE],GRAD_FILE[STRING_SIZE], SEIS_OBS_FILE[STRING_SIZE],INV_FILE[STRING_SIZE];
extern int NPROCX,NPROCY,NPROCZ;
extern int ASCIIEBCDIC,LITTLEBIG,IEEEIBM;
extern int LITTLEBIG;
extern float REFSRC[3], SRCTSHIFT;
extern int SRC_MF, SIGNAL_FORMAT;
......@@ -505,35 +505,17 @@ void read_par_json(FILE *fp, char *fileinp) {
fprintf(fp," Variable NDTSHIFT is set to default value %d.\n",NDT);
}
if (get_int_from_objectlist("SEIS_FORMAT",number_readobjects,&SEIS_FORMAT[0],varname_list, value_list)) {
if (get_int_from_objectlist("SEIS_FORMAT",number_readobjects,&SEIS_FORMAT,varname_list, value_list)) {
err("Variable SEIS_FORMAT could not be retrieved from the json input file!");
} else {
if (SEIS_FORMAT[0]==4) {
SEIS_FORMAT[0]=0;
}
if (SEIS_FORMAT[0]==5) {
SEIS_FORMAT[0]=0;
SEIS_FORMAT[1]=1;
SEIS_FORMAT[3]=1;
SEIS_FORMAT[4]=0;
SEIS_FORMAT[5]=0;
}
}
}
}/*end of seismo*/
if (get_int_from_objectlist("ASCIIEBCDIC",number_readobjects,&ASCIIEBCDIC,varname_list, value_list)) {
ASCIIEBCDIC=0;
}
if (get_int_from_objectlist("LITTLEBIG",number_readobjects,&LITTLEBIG,varname_list, value_list)) {
LITTLEBIG=0;
}
if (get_int_from_objectlist("IEEEIBM",number_readobjects,&IEEEIBM,varname_list, value_list)) {
IEEEIBM=0;
}
/*=================================
section inversion parameters
......
/*------------------------------------------------------------------------
* Copyright (C) 2015 For the list of authors, see file AUTHORS.
*
* This file is part of IFOS3D.
*
* IFOS3D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.0 of the License only.
*
* IFOS3D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IFOS3D. See file COPYING and/or
* <http://www.gnu.org/licenses/gpl-2.0.html>.
--------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------
* reading and writing SEG-Y, SU, BIN, TXT and UKOOA P190
*
* CAUTION: tested for LITTLEBIG=ASCIIEBCDIC=IEEEIBM=0 only
* (no other suitable computer for further test available)
------------------------------------------------------------------------------ */
#include <stdio.h>
#include <math.h>