Skip to content
Snippets Groups Projects
Commit 4d5ad270 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Extract common test data generator code into header.

parent 410f50ab
No related branches found
No related tags found
No related merge requests found
......@@ -57,15 +57,11 @@ modelRegionCompute(double region[], int nlev, int nlat, int nlon,
for (unsigned j = 0; j < n; ++j)
for (unsigned i = 0; i < m; ++i)
region[k * kstride + j * jstride + i]
= sign_flat(round((cos(2.0 * M_PI
* (lons[(i + is + (unsigned)tsID)
%(unsigned)nlon] - lons[0])
/ (lons[nlon-1] - lons[0]))
* sin(2.0 * M_PI
* (lats[(j + js + k + ks)%(unsigned)nlat]
- lats[0])
/ (lats[nlat-1] - lats[0]))
) * mscale)) * mrscale;
= dg_wobble((lons[(i + is + (unsigned)tsID)%(unsigned)nlon] - lons[0])
/ (lons[nlon-1] - lons[0]),
(lats[(j + js + k + ks)%(unsigned)nlat] - lats[0])
/ (lats[nlat-1] - lats[0]),
mscale, mrscale);
}
#ifdef USE_MPI
......
......@@ -51,11 +51,10 @@ modelRegionCompute(double region[], size_t offset, size_t len,
int j = (int)(global_pos % (size_t)(nlon * nlat) / (size_t)nlon);
int i = (int)(global_pos % (size_t)nlon);
region[local_pos]
= sign_flat(round((cos(2.0 * M_PI * (lons[(i + tsID)%nlon] - lons[0])
/ (lons[nlon-1] - lons[0]))
* sin(2.0 * M_PI * (lats[(j + k)%nlat] - lats[0])
/ (lats[nlat-1] - lats[0]))
) * mscale)) * mrscale;
= dg_wobble((lons[(i + tsID)%nlon] - lons[0])
/ (lons[nlon-1] - lons[0]),
(lats[(j + k)%nlat] - lats[0])
/ (lats[nlat-1] - lats[0]), mscale, mrscale);
}
}
......
......@@ -6,6 +6,7 @@
#endif
#include <inttypes.h>
#include <math.h>
#include <time.h>
void
......@@ -19,6 +20,15 @@ sign_flat(double v)
return v;
}
/* data generator function */
static inline double
dg_wobble(double frac_x, double frac_y, double mscale, double mrscale)
{
double r = sign_flat(round((cos(2.0 * M_PI * frac_x)
* sin(2.0 * M_PI * frac_y)) * mscale)) * mrscale;
return r;
}
time_t
cditime2time_t(int date, int timeofday);
void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment