Commit c24e9159 authored by Matthias Rüster's avatar Matthias Rüster
Browse files

Write binary XYZ grid file

parent 0e0e7f24
Pipeline #21062 passed with stages
in 11 seconds
......@@ -472,18 +472,21 @@ int cOgrd::write_XYZ( const char *fname )
int i,j;
char *f_name = new char [strlen(fname)+5];
char *f_name = new char [strlen(fname)+5];
sprintf( f_name, "%s.xyz", fname );
fp = fopen( f_name, "wt" );
fp = fopen( f_name, "wb" );
delete [] f_name;
for( j=0; j<ny; j++ ) {
for( i=0; i<nx; i++ ) {
if( isnan(val[idx(i,j)]) )
fprintf( fp, " %g %g NaN\n", getX(i,j), getY(i,j) );
else
fprintf( fp, " %g %g %g\n", getX(i,j), getY(i,j), val[idx(i,j)] );
double x = getX(i,j);
double y = getY(i,j);
double v = val[idx(i,j)];
fwrite(&x, sizeof(double), 1, fp);
fwrite(&y, sizeof(double), 1, fp);
fwrite(&v, sizeof(double), 1, fp);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment