Commit 1ad087af authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Removed vert_gen_weights3d1d().

parent e06698ab
......@@ -103,92 +103,6 @@ void vert_gen_weights3d(bool expol, int nlev1, size_t gridsize, double *xlev1, i
}
/*
* Create weights for the 1d vertical coordinate from a 3d vertical coordinate
*
* The resulting index sets lev_idx1 and lev_idx2 contain absolute numbers,i.e.
* wrt. the given gridsize. They can directly be used to read values from 3d
* data fields.
*
* 3d1d version of vert_gen_weights() (src/Intlevel.cc)
*/
static
void vert_gen_weights3d1d(bool expol, int nlev1, int gridsize, double *lev1, int nlev2, double *lev2,
int *lev_idx1, int *lev_idx2, double *lev_wgt1, double *lev_wgt2)
{
int i,i1, i2;
int idx1 = 0, idx2 = 0;
double val1, val2 = 0;
for ( i = 0; i < gridsize; i++ )
{
for ( i2 = 0; i2 < nlev2; i2++ )
{
/* Because 2 levels were added to the source vertical coordinate (one on
* top, one at the bottom), its loop starts at 1 */
for ( i1 = 1; i1 < nlev1; i1++ )
{
if ( lev1[(i1-1)*gridsize+i] < lev1[i1*gridsize+i] )
{
idx1 = (i1-1)*gridsize+i;
idx2 = i1*gridsize+i;
}
else
{
idx1 = i1*gridsize+i;
idx2 = (i1-1)*gridsize+i;
}
val1 = lev1[idx1];
val2 = lev1[idx2];
if ( lev2[i2] > val1 && lev2[i2] <= val2 ) break;
}
if ( i1 == nlev1 )
{
if ( expol )
cdoAbort("Level %g at index %d not found! Use extrapolation", lev2[i2],i2);
else
cdoAbort("Level %g at index %d not found!");
}
if ( i1-1 == 0 ) /* destination levels ios not covert by the first two input z levels */
{
lev_idx1[i2*gridsize+i] = gridsize+i;
lev_idx2[i2*gridsize+i] = gridsize+i;
lev_wgt1[i2*gridsize+i] = 0;
lev_wgt2[i2*gridsize+i] = (expol || IS_EQUAL(lev2[i2], val2));
}
else if ( i1 == nlev1-1 ) /* destination level is beyond the last value of the input z field */
{
lev_idx1[i2*gridsize+i] = (nlev1-2)*gridsize+i;
lev_idx2[i2*gridsize+i] = (nlev1-2)*gridsize+i;
lev_wgt1[i2*gridsize+i] = (expol || IS_EQUAL(lev2[i2], val2));
lev_wgt2[i2*gridsize+i] = 0;
}
else /* target z values has two bounday values in input z field */
{
lev_idx1[i2*gridsize+i] = idx1;
lev_idx2[i2*gridsize+i] = idx2;
lev_wgt1[i2*gridsize+i] = (lev1[idx2] - lev2[i2]) / (lev1[idx2] - lev1[idx1]);
lev_wgt2[i2*gridsize+i] = (lev2[i2] - lev1[idx1]) / (lev1[idx2] - lev1[idx1]);
}
/* if (cdoVerbose)
* {
* printf("i:%d i2:%d\ti2*gridsize+i:%d\tlev2[i2]:%g\tidx1:%d\tidx2:%d\tlev1[idx1]:%g\tlev1[idx2]:%g\t",
* i, i2, i2*gridsize+i, lev2[i2], idx1, idx2, lev1[idx1], lev1[idx2]);
* printf("\tlev_wgt1:%g\tlev_wgt2:%g\n", lev_wgt1[i2*gridsize+i], lev_wgt2[i2*gridsize+i]);
* }
*/
/* backshift of the indices because of the two additional levels in input vertical coordinate */
lev_idx1[i2*gridsize+i] -= gridsize;
lev_idx2[i2*gridsize+i] -= gridsize;
}
}
}
void *Intlevel3d(void *argument)
{
size_t gridsize, gridSize, gridsizei, gridsizeo;
......
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