Commit b940b99c authored by Johannes Spazier's avatar Johannes Spazier

- The reading of ASCII grid input files that was broken in previous revisions has been fixed.

- Flushing the output explicitly.
parent 9e4d7de8
...@@ -134,7 +134,9 @@ int main( int argc, char **argv ) ...@@ -134,7 +134,9 @@ int main( int argc, char **argv )
lastPropagation = 0; lastPropagation = 0;
} }
} }
fflush(stdout);
if( Par.outDump ) { if( Par.outDump ) {
if( (elapsed-lastDump) >= Par.outDump ) { if( (elapsed-lastDump) >= Par.outDump ) {
Node.copyIntermediate(); Node.copyIntermediate();
......
...@@ -79,7 +79,7 @@ int ewLoadBathymetry() ...@@ -79,7 +79,7 @@ int ewLoadBathymetry()
} }
// try to allocate memory for GRIDNODE structure and for caching arrays // try to allocate memory for GRIDNODE structure and for caching arrays
printf_v("Size: %d %d %luMB\n", NLon, NLat, sizeof(float)*MAX_VARS_PER_NODE*NLon*NLat/1024/1024); printf_v("Size: %d %d %luMB\n", NLon, NLat, sizeof(float)*MAX_VARS_PER_NODE*NLon*NLat/1024/1024);
if( Node.mallocMem() ) return Err.post( Err.msgAllocateMem() ); if( Node.mallocMem() ) return Err.post( Err.msgAllocateMem() );
if( isBin ) { if( isBin ) {
...@@ -99,36 +99,59 @@ int ewLoadBathymetry() ...@@ -99,36 +99,59 @@ int ewLoadBathymetry()
Dx = Re * g2r( DLon ); // in m along the equator Dx = Re * g2r( DLon ); // in m along the equator
Dy = Re * g2r( DLat ); Dy = Re * g2r( DLat );
/* NOTE: optimal would be reading everything in one step, but that does not work because rows and columns are transposed if( isBin ) {
* (only possible with binary data at all) - use temporary buffer for now (consumes additional memory!) */
float *buf = new float[ NLat*NLon ];
ierr = fread( buf, sizeof(float), NLat*NLon, fp );
for( i=1; i<=NLon; i++ ) { /* NOTE: optimal would be reading everything in one step, but that does not work because rows and columns are transposed
for( j=1; j<=NLat; j++ ) { * (only possible with binary data at all) - use temporary buffer for now (consumes additional memory!) */
float *buf = new float[ NLat*NLon ];
ierr = fread( buf, sizeof(float), NLat*NLon, fp );
m = idx(j,i); for( i=1; i<=NLon; i++ ) {
for( j=1; j<=NLat; j++ ) {
m = idx(j,i);
if( isBin ) if( isBin )
fval = buf[ (j-1) * NLon + (i-1) ]; fval = buf[ (j-1) * NLon + (i-1) ];
//ierr = fread( &fval, sizeof(float), 1, fp ); //ierr = fread( &fval, sizeof(float), 1, fp );
else
ierr = fscanf( fp, " %f ", &fval );
Node(m, iTopo) = fval; Node(m, iTopo) = fval;
Node(m, iTime) = -1; Node(m, iTime) = -1;
Node(m, iD) = -fval; Node(m, iD) = -fval;
if( Node(m, iD) < 0 ) { if( Node(m, iD) < 0 ) {
Node(m, iD) = 0.0f; Node(m, iD) = 0.0f;
} else if( Node(m, iD) < Par.dmin ) { } else if( Node(m, iD) < Par.dmin ) {
Node(m, iD) = Par.dmin; Node(m, iD) = Par.dmin;
}
}
} }
} delete[] buf;
}
} else {
delete[] buf; for( j=1; j<=NLat; j++ ) {
for( i=1; i<=NLon; i++ ) {
m = idx(j,i);
ierr = fscanf( fp, " %f ", &fval );
Node(m, iTopo) = fval;
Node(m, iTime) = -1;
Node(m, iD) = -fval;
if( Node(m, iD) < 0 ) {
Node(m, iD) = 0.0f;
} else if( Node(m, iD) < Par.dmin ) {
Node(m, iD) = Par.dmin;
}
}
}
}
for( k=1; k<MAX_VARS_PER_NODE-2; k++ ) { for( k=1; k<MAX_VARS_PER_NODE-2; k++ ) {
Node.initMemory( k, 0 ); Node.initMemory( k, 0 );
......
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