Skip to content

Commit

Permalink
Merge pull request #308 from jcrivenaes/c-refactor
Browse files Browse the repository at this point in the history
refactor + tests: remove xtgverbose etc and add tests
  • Loading branch information
jcrivenaes authored Mar 3, 2020
2 parents ca2650f + d54bc00 commit f299608
Show file tree
Hide file tree
Showing 23 changed files with 477 additions and 600 deletions.
3 changes: 1 addition & 2 deletions src/xtgeo/clib/etc/extra/attic/snippets_tests/libxtg.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ float x_interp_map_nodes (
float *z_v,
float x,
float y,
int method,
int debug
int method
);

int x_ijk2ib (
Expand Down
51 changes: 25 additions & 26 deletions src/xtgeo/clib/xtg/cube_export_rmsregular.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
****************************************************************************************
***************************************************************************************
*
* NAME:
* cube_export_rmsregular.c
Expand All @@ -12,7 +12,7 @@
* xori...zinc i cube origin + increment in xyz
* rotation i Cube rotation (degrees)
* yflip i Cube YFLIP index (needed?)
* p_val_v i 1D Array of cube values of ncx*ncy*ncz size
* cubevalsv i 1D Array of cube values of ncx*ncy*ncz size
* nval i Number of elements in array
* file i File to export to
* option i For future use
Expand All @@ -28,41 +28,40 @@
***************************************************************************************
*/

#include "logger.h"
#include "libxtg.h"
#include "libxtg_.h"
#include "logger.h"

int cube_export_rmsregular (
int nx,
int ny,
int nz,
double xori,
double yori,
double zori,
double xinc,
double yinc,
double zinc,
double rotation,
int yflip,
float *p_val_v,
long nval,
char *file
)
int
cube_export_rmsregular(int nx,
int ny,
int nz,
double xori,
double yori,
double zori,
double xinc,
double yinc,
double zinc,
double rotation,
int yflip,
float *cubevalsv,
long nval,
char *file)
{

/* locals */
FILE *fc;
int swap, i, j, k;
long ic;
double xmax,ymax,zmax;
double xmax, ymax, zmax;
float value;

logger_info(LI, FI, FU, "Export cube to RMS regular format");

/* if (yflip == -1) { */
/* xtg_speak(sub, 2, "Swap axes..."); */
/* cube_swapaxes(&nx, &ny, nz, &yflip, xori, &xinc, yori, &yinc, */
/* &rotation, p_val_v, 0, debug); */
/* &rotation, cubevalsv, 0, debug); */
/* xtg_speak(sub, 2, "Swap axes...done"); */
/* } */

Expand All @@ -76,7 +75,6 @@ int cube_export_rmsregular (
ymax = yori + yinc * (ny - 1);
zmax = zori + zinc * (nz - 1);


fprintf(fc, "Xmin/Xmax/Xinc: %11.3lf %11.3lf %le\n", xori, xmax, xinc);
fprintf(fc, "Ymin/Ymax/Yinc: %11.3lf %11.3lf %le\n", yori, ymax, yinc);
fprintf(fc, "Zmin/Zmax/Zinc: %11.3lf %11.3lf %le\n", zori, zmax, zinc);
Expand All @@ -92,15 +90,16 @@ int cube_export_rmsregular (

ic = x_ijk2ic(i, j, k, nx, ny, nz, 0);

value = p_val_v[ic];
value = cubevalsv[ic];
if (value > UNDEF_LIMIT) {
value=UNDEF_CUBE_RMS;
value = UNDEF_CUBE_RMS;
}

/* byte swapping if needed */
if (swap == 1) SWAP_FLOAT(value);
if (swap == 1)
SWAP_FLOAT(value);

if (fwrite(&value, 4, 1, fc) !=1 ) {
if (fwrite(&value, 4, 1, fc) != 1) {
logger_error(LI, FI, FU, "Write failed in routine %s", FU);
fclose(fc);
return -1;
Expand Down
4 changes: 2 additions & 2 deletions src/xtgeo/clib/xtg/cube_import_segy.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ void cube_import_segy (
/* rotation; compute for first inline... */

x_vector_info2(xpos[0],xpos[1],ypos[0], ypos[1], &ss, &rotrad,
&rot, 1, XTGDEBUG);
&rot, 1);

*rotation = rot;

Expand All @@ -650,7 +650,7 @@ void cube_import_segy (

/* Y dir */
x_vector_info2(xpos[0],xpos[2],ypos[0], ypos[2], &ss, &rotrad,
&rot2, 1, XTGDEBUG);
&rot2, 1);

/* deltas for Y dir */
*yinc = ss/(nxlines-1);
Expand Down
4 changes: 2 additions & 2 deletions src/xtgeo/clib/xtg/grd3d_calc_dxdy.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ grd3d_calc_dxdy(int nx,
for (n = 0; n <= 3; n++) {
ii = 0 + n * 6;
x_vector_info2(c[ii], c[ii + 3], c[ii + 1], c[ii + 4], &vlen, &arad,
&adeg, 1, XTGDEBUG);
&adeg, 1);
plen = plen + vlen;
}
dx[ic] = plen / 4.0;
Expand All @@ -101,7 +101,7 @@ grd3d_calc_dxdy(int nx,
ii = 6 + n * 3;

x_vector_info2(c[ii], c[ii + 6], c[ii + 1], c[ii + 7], &vlen, &arad,
&adeg, 1, XTGDEBUG);
&adeg, 1);
plen = plen + vlen;
}
dy[ic] = plen / 4.0;
Expand Down
2 changes: 1 addition & 1 deletion src/xtgeo/clib/xtg/grd3d_geometrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ grd3d_geometrics(int nx,
/* rotation (test along x, sufficient?)*/

x_vector_info2(tmp_x[ib], tmp_x[ibn], tmp_y[ib], tmp_y[ibn], &dum1,
&dum2, &vrotx_ic, 1, XTGDEBUG);
&dum2, &vrotx_ic, 1);

/* special case if angle is close to 0 or 360: then problems
in averaging may occur. The solution is to avoid numbers
Expand Down
Loading

0 comments on commit f299608

Please sign in to comment.