Commit a2eb8bc4 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add preliminary test of netCDF input data path.

* This test currently only checks if a single missing value is
  successfully written out and counted on input.
parent 068ab9ab
......@@ -360,6 +360,9 @@ tests/simple_model_helper.c -text
tests/simple_model_helper.h -text
tests/stream_cksum.c -text
tests/stream_cksum.h -text
tests/test_cdf_read.c -text
tests/test_cdf_transformation.in -text
tests/test_cdf_write.c -text
tests/test_chunk_cksum.in -text
tests/test_cksum_extra.in -text
tests/test_cksum_grib.in -text
......
......@@ -660,6 +660,8 @@ PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
MPI_LAUNCH
ENABLE_NETCDF_FALSE
ENABLE_NETCDF_TRUE
ENABLE_ALL_STATIC_FALSE
ENABLE_ALL_STATIC_TRUE
ENABLE_CDI_LIB
......@@ -27043,6 +27045,14 @@ else
fi
 
 
if test x$ENABLE_NETCDF = xyes; then
ENABLE_NETCDF_TRUE=
ENABLE_NETCDF_FALSE='#'
else
ENABLE_NETCDF_TRUE='#'
ENABLE_NETCDF_FALSE=
fi
# ----------------------------------------------------------------------
# Compile with MPI support
# Check whether --enable-mpi was given.
......@@ -28063,7 +28073,7 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
 
 
ac_config_files="$ac_config_files tests/test_cksum_grib tests/test_cksum_nc tests/test_cksum_nc2 tests/test_cksum_nc4 tests/test_cksum_extra tests/test_cksum_service tests/test_cksum_ieg tests/test_chunk_cksum tests/test_f2003 tests/pio_write_run tests/pio_write_deco2d_run tests/pio_cksum_mpinonb tests/pio_cksum_fpguard tests/pio_cksum_asynch tests/pio_cksum_writer tests/pio_cksum_cdf tests/test_resource_copy_mpi_run tables/gen_tableheaderfile util/serialrun"
ac_config_files="$ac_config_files tests/test_cksum_grib tests/test_cksum_nc tests/test_cksum_nc2 tests/test_cksum_nc4 tests/test_cksum_extra tests/test_cksum_service tests/test_cksum_ieg tests/test_chunk_cksum tests/test_f2003 tests/pio_write_run tests/pio_write_deco2d_run tests/pio_cksum_mpinonb tests/pio_cksum_fpguard tests/pio_cksum_asynch tests/pio_cksum_writer tests/pio_cksum_cdf tests/test_resource_copy_mpi_run tests/test_cdf_transformation tables/gen_tableheaderfile util/serialrun"
 
 
ac_config_files="$ac_config_files Makefile src/Makefile interfaces/Makefile app/Makefile tests/Makefile examples/Makefile cdi.settings examples/pio/Makefile src/pkgconfig/cdi.pc src/pkgconfig/cdipio.pc"
......@@ -28218,6 +28228,10 @@ if test -z "${ENABLE_ALL_STATIC_TRUE}" && test -z "${ENABLE_ALL_STATIC_FALSE}";
as_fn_error $? "conditional \"ENABLE_ALL_STATIC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_NETCDF_TRUE}" && test -z "${ENABLE_NETCDF_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_NETCDF\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_MPI_TRUE}" && test -z "${USE_MPI_FALSE}"; then
as_fn_error $? "conditional \"USE_MPI\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
......@@ -29429,6 +29443,7 @@ do
"tests/pio_cksum_writer") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_writer" ;;
"tests/pio_cksum_cdf") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_cdf" ;;
"tests/test_resource_copy_mpi_run") CONFIG_FILES="$CONFIG_FILES tests/test_resource_copy_mpi_run" ;;
"tests/test_cdf_transformation") CONFIG_FILES="$CONFIG_FILES tests/test_cdf_transformation" ;;
"tables/gen_tableheaderfile") CONFIG_FILES="$CONFIG_FILES tables/gen_tableheaderfile" ;;
"util/serialrun") CONFIG_FILES="$CONFIG_FILES util/serialrun" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
......@@ -31249,6 +31264,7 @@ _LT_EOF
"tests/pio_cksum_writer":F) chmod a+x "$ac_file" ;;
"tests/pio_cksum_cdf":F) chmod a+x "$ac_file" ;;
"tests/test_resource_copy_mpi_run":F) chmod a+x "$ac_file" ;;
"tests/test_cdf_transformation":F) chmod a+x "$ac_file" ;;
"tables/gen_tableheaderfile":F) chmod a+x "$ac_file" ;;
"util/serialrun":F) chmod a+x "$ac_file" ;;
 
......
......@@ -124,6 +124,7 @@ AC_CHECK_LIB(m, floor)
# ----------------------------------------------------------------------
# Add basic configure options
ACX_OPTIONS
AM_CONDITIONAL([ENABLE_NETCDF],[test x$ENABLE_NETCDF = xyes])
# ----------------------------------------------------------------------
# Compile with MPI support
AC_ARG_ENABLE(mpi,AS_HELP_STRING([--enable-mpi],[Compile with MPI compiler [default=no]]),enable_mpi=yes,enable_mpi=no)
......@@ -359,6 +360,7 @@ AC_CONFIG_FILES([tests/test_cksum_grib \
tests/pio_cksum_writer \
tests/pio_cksum_cdf \
tests/test_resource_copy_mpi_run \
tests/test_cdf_transformation \
tables/gen_tableheaderfile \
util/serialrun],[chmod a+x "$ac_file"])
......
......@@ -8,10 +8,14 @@ TESTS = cksum_verify \
pio_write_run pio_cksum_mpinonb pio_cksum_fpguard \
pio_cksum_asynch pio_cksum_writer pio_cksum_cdf \
test_resource_copy pio_write_deco2d_run \
test_f2003
test_f2003 test_cdf_transformation
check_PROGRAMS = cksum_verify test_grib cksum_write cksum_read pio_write \
test_resource_copy cksum_write_chunk pio_write_deco2d
if ENABLE_NETCDF
check_PROGRAMS += test_cdf_write test_cdf_read
endif
#
test_grib_SOURCES = test_grib.c
cksum_verify_SOURCES = cksum_verify.c
......@@ -33,6 +37,8 @@ test_resource_copy_SOURCES = test_resource_copy.c \
test_resource_copy_LDADD = $(UUID_C_LIB) $(LDADD)
test_resource_copy_mpi_SOURCES = test_resource_copy.c \
create_uuid.h create_uuid.c
test_cdf_write_SOURCES = test_cdf_write.c
test_cdf_read_SOURCES = test_cdf_read.c
AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS)
if USE_MPI
......@@ -51,7 +57,7 @@ endif
LDADD = ../src/libcdi.la -lm
AM_CPPFLAGS = -I$(top_srcdir)/src
#
# EXTRA_DIST = $(TESTS)
EXTRA_DIST = test_cdf_write.c test_cdf_read.c
#
CLEANFILES = `ls *~ *.grb *.nc *.srv *.ext example_*.cksum`
#
......
......@@ -82,13 +82,15 @@ TESTS = cksum_verify$(EXEEXT) test_cksum_grib test_cksum_nc \
test_cksum_nc4 test_cksum_ieg test_chunk_cksum pio_write_run \
pio_cksum_mpinonb pio_cksum_fpguard pio_cksum_asynch \
pio_cksum_writer pio_cksum_cdf test_resource_copy$(EXEEXT) \
pio_write_deco2d_run test_f2003 $(am__append_1)
pio_write_deco2d_run test_f2003 test_cdf_transformation \
$(am__append_2)
check_PROGRAMS = cksum_verify$(EXEEXT) test_grib$(EXEEXT) \
cksum_write$(EXEEXT) cksum_read$(EXEEXT) pio_write$(EXEEXT) \
test_resource_copy$(EXEEXT) cksum_write_chunk$(EXEEXT) \
pio_write_deco2d$(EXEEXT) $(am__EXEEXT_1)
@USE_MPI_TRUE@am__append_1 = test_resource_copy_mpi_run
@USE_MPI_TRUE@am__append_2 = test_resource_copy_mpi
pio_write_deco2d$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
@ENABLE_NETCDF_TRUE@am__append_1 = test_cdf_write test_cdf_read
@USE_MPI_TRUE@am__append_2 = test_resource_copy_mpi_run
@USE_MPI_TRUE@am__append_3 = test_resource_copy_mpi
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/config/mkinstalldirs \
......@@ -102,6 +104,7 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(srcdir)/pio_cksum_asynch.in $(srcdir)/pio_cksum_writer.in \
$(srcdir)/pio_cksum_cdf.in \
$(srcdir)/test_resource_copy_mpi_run.in \
$(srcdir)/test_cdf_transformation.in \
$(top_srcdir)/config/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = \
......@@ -126,9 +129,11 @@ CONFIG_CLEAN_FILES = test_cksum_grib test_cksum_nc test_cksum_nc2 \
test_cksum_ieg test_chunk_cksum test_f2003 pio_write_run \
pio_write_deco2d_run pio_cksum_mpinonb pio_cksum_fpguard \
pio_cksum_asynch pio_cksum_writer pio_cksum_cdf \
test_resource_copy_mpi_run
test_resource_copy_mpi_run test_cdf_transformation
CONFIG_CLEAN_VPATH_FILES =
@USE_MPI_TRUE@am__EXEEXT_1 = test_resource_copy_mpi$(EXEEXT)
@ENABLE_NETCDF_TRUE@am__EXEEXT_1 = test_cdf_write$(EXEEXT) \
@ENABLE_NETCDF_TRUE@ test_cdf_read$(EXEEXT)
@USE_MPI_TRUE@am__EXEEXT_2 = test_resource_copy_mpi$(EXEEXT)
am_cksum_read_OBJECTS = cksum_read.$(OBJEXT) var_cksum.$(OBJEXT) \
stream_cksum.$(OBJEXT) ensure_array_size.$(OBJEXT)
cksum_read_OBJECTS = $(am_cksum_read_OBJECTS)
......@@ -169,6 +174,14 @@ pio_write_deco2d_OBJECTS = $(am_pio_write_deco2d_OBJECTS)
@USE_MPI_FALSE@ $(am__DEPENDENCIES_2)
@USE_MPI_TRUE@pio_write_deco2d_DEPENDENCIES = ../src/libcdipio.la \
@USE_MPI_TRUE@ $(am__DEPENDENCIES_2)
am_test_cdf_read_OBJECTS = test_cdf_read.$(OBJEXT)
test_cdf_read_OBJECTS = $(am_test_cdf_read_OBJECTS)
test_cdf_read_LDADD = $(LDADD)
test_cdf_read_DEPENDENCIES = ../src/libcdi.la
am_test_cdf_write_OBJECTS = test_cdf_write.$(OBJEXT)
test_cdf_write_OBJECTS = $(am_test_cdf_write_OBJECTS)
test_cdf_write_LDADD = $(LDADD)
test_cdf_write_DEPENDENCIES = ../src/libcdi.la
am_test_grib_OBJECTS = test_grib.$(OBJEXT)
test_grib_OBJECTS = $(am_test_grib_OBJECTS)
test_grib_LDADD = $(LDADD)
......@@ -227,11 +240,13 @@ am__v_CCLD_1 =
SOURCES = $(cksum_read_SOURCES) $(cksum_verify_SOURCES) \
$(cksum_write_SOURCES) $(cksum_write_chunk_SOURCES) \
$(pio_write_SOURCES) $(pio_write_deco2d_SOURCES) \
$(test_cdf_read_SOURCES) $(test_cdf_write_SOURCES) \
$(test_grib_SOURCES) $(test_resource_copy_SOURCES) \
$(test_resource_copy_mpi_SOURCES)
DIST_SOURCES = $(cksum_read_SOURCES) $(cksum_verify_SOURCES) \
$(cksum_write_SOURCES) $(cksum_write_chunk_SOURCES) \
$(pio_write_SOURCES) $(pio_write_deco2d_SOURCES) \
$(test_cdf_read_SOURCES) $(test_cdf_write_SOURCES) \
$(test_grib_SOURCES) $(test_resource_copy_SOURCES) \
$(test_resource_copy_mpi_SOURCES)
am__can_run_installinfo = \
......@@ -495,6 +510,8 @@ test_resource_copy_LDADD = $(UUID_C_LIB) $(LDADD)
test_resource_copy_mpi_SOURCES = test_resource_copy.c \
create_uuid.h create_uuid.c
test_cdf_write_SOURCES = test_cdf_write.c
test_cdf_read_SOURCES = test_cdf_read.c
AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS)
@USE_MPI_FALSE@pio_write_LDADD = $(LDADD) $(UUID_C_LIB)
@USE_MPI_TRUE@pio_write_LDADD = ../src/libcdipio.la $(UUID_C_LIB)
......@@ -506,7 +523,7 @@ AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS)
LDADD = ../src/libcdi.la -lm
AM_CPPFLAGS = -I$(top_srcdir)/src
#
# EXTRA_DIST = $(TESTS)
EXTRA_DIST = test_cdf_write.c test_cdf_read.c
#
CLEANFILES = `ls *~ *.grb *.nc *.srv *.ext example_*.cksum`
#
......@@ -579,6 +596,8 @@ pio_cksum_cdf: $(top_builddir)/config.status $(srcdir)/pio_cksum_cdf.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
test_resource_copy_mpi_run: $(top_builddir)/config.status $(srcdir)/test_resource_copy_mpi_run.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
test_cdf_transformation: $(top_builddir)/config.status $(srcdir)/test_cdf_transformation.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
clean-checkPROGRAMS:
@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
......@@ -613,6 +632,14 @@ pio_write_deco2d$(EXEEXT): $(pio_write_deco2d_OBJECTS) $(pio_write_deco2d_DEPEND
@rm -f pio_write_deco2d$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(pio_write_deco2d_OBJECTS) $(pio_write_deco2d_LDADD) $(LIBS)
test_cdf_read$(EXEEXT): $(test_cdf_read_OBJECTS) $(test_cdf_read_DEPENDENCIES) $(EXTRA_test_cdf_read_DEPENDENCIES)
@rm -f test_cdf_read$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_cdf_read_OBJECTS) $(test_cdf_read_LDADD) $(LIBS)
test_cdf_write$(EXEEXT): $(test_cdf_write_OBJECTS) $(test_cdf_write_DEPENDENCIES) $(EXTRA_test_cdf_write_DEPENDENCIES)
@rm -f test_cdf_write$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_cdf_write_OBJECTS) $(test_cdf_write_LDADD) $(LIBS)
test_grib$(EXEEXT): $(test_grib_OBJECTS) $(test_grib_DEPENDENCIES) $(EXTRA_test_grib_DEPENDENCIES)
@rm -f test_grib$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test_grib_OBJECTS) $(test_grib_LDADD) $(LIBS)
......@@ -643,6 +670,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_model.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/simple_model_helper.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream_cksum.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cdf_read.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_cdf_write.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_grib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_resource_copy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_resource_copy_mpi-create_uuid.Po@am__quote@
......
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "cdi.h"
int main(int argc, const char **argv)
{
const char *fname = "test.nc";
int countMissingValues = 1;
/* todo: handle optional arguments here to increase test coverage */
if (argc)
fname = argv[1];
int streamID = streamOpenRead(fname);
if (streamID < 0)
{
fprintf(stderr, "Open failed for file %s: %s\n",
fname, cdiStringError(streamID));
return EXIT_FAILURE;
}
int vlistID = streamInqVlist(streamID);
size_t nVars = (size_t)vlistNvars(vlistID);
double *buf = NULL;
size_t bufSize = 0;
size_t allNmissSum = 0;
for (int tsID = 0; streamInqTimestep(streamID, tsID); ++tsID)
{
for (size_t varID = 0; varID < nVars; ++varID)
{
size_t memSize = (size_t)vlistInqVarSize(vlistID, varID)
* sizeof (double);
int nmiss;
if (memSize > bufSize)
{
double *temp = realloc(buf, memSize);
if (!temp)
{
perror("read buffer reallocation failed");
return EXIT_FAILURE;
}
buf = temp;
}
streamReadVar(streamID, (int)varID, buf, &nmiss);
allNmissSum += (size_t)nmiss;
}
++tsID;
}
if (countMissingValues)
printf("missing values count = %zu\n", allNmissSum);
streamClose(streamID);
return EXIT_SUCCESS;
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
#! @SHELL@
set -e
[ x${DEBUG+set} != xset ] || set -x
if [ @ENABLE_NETCDF@ != yes ]; then
exit 77
fi
ncdatafile="test$$.nc"
tempfiles="${ncdatafile}"
trap "EC=\$? ; \rm -f ${tempfiles}; exit \$EC" EXIT
./test_cdf_write "${ncdatafile}"
digest=$(./test_cdf_read "${ncdatafile}")
missValueCount=$(echo "$digest" | @SED@ -n '/^missing values count =/{
s/^missing values count *= *//
p
q
}')
if [ "$missValueCount" -ne 1 ]; then
echo "Mismatch in expected number of missing values!" >&2
exit 1
fi
#
# Local Variables:
# mode: sh
# End:
#
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "cdi.h"
struct cart_coord {
double lat, lon;
};
static double
my_gamma_dist(double x);
static void
compute_curvilinear(double *coords_,
const struct cart_coord a[4], size_t sizex, size_t sizey);
#define DEG2RAD(phi) ((M_PI / 180.0) * (phi))
#define RAD2DEG(phi) ((180./M_PI) * (phi))
#define missValue (-50.0)
int main(int argc, const char **argv)
{
/* todo: handle optional arguments here to increase test coverage */
const char *fname = "test.nc";
if (argc)
fname = argv[1];
int streamID = streamOpenWrite(fname, FILETYPE_NC);
if ( streamID < 0 )
{
fprintf(stderr, "Open failed on %s: %s\n", fname,
cdiStringError(streamID));
return EXIT_FAILURE;
}
enum {
sizey = 40,
sizex = 2 * sizey,
};
size_t datasize = (size_t)sizex * (size_t)sizey;
int gridID = gridCreate(GRID_CURVILINEAR, (int)datasize);
gridDefXsize(gridID, sizex);
gridDefYsize(gridID, sizey);
{
/* anti-clockwise coordinates around Amazonia */
static struct cart_coord region[4]
= { { .lon = DEG2RAD(-85.0), .lat = DEG2RAD(-25.0) },
{ .lon = DEG2RAD(-44.0), .lat = DEG2RAD(-18.0) },
{ .lon = DEG2RAD(-50.0), .lat = DEG2RAD(7.0) },
{ .lon = DEG2RAD(-80.0), .lat = DEG2RAD(10.0) } };
double (*gridCoords)[sizey][sizex]
= (double (*)[sizey][sizex])
malloc(sizeof (*gridCoords) * sizey * sizex * 2);
if (gridCoords == NULL)
{
perror("grid coordinate memory allocation failed");
return EXIT_FAILURE;
}
compute_curvilinear((double *)gridCoords, region, sizex, sizey);
gridDefXvals(gridID, (double *)(gridCoords[1]));
gridDefYvals(gridID, (double *)(gridCoords[0]));
free(gridCoords);
}
int zaxisID = zaxisCreate(ZAXIS_SURFACE, 1);
int vlistID = vlistCreate();
int varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_INSTANT);
vlistDefVarMissval(vlistID, varID, missValue);
int taxisID = taxisCreate(TAXIS_ABSOLUTE);
vlistDefTaxis(vlistID, taxisID);
streamDefVlist(streamID, vlistID);
(void)streamDefTimestep(streamID, 0);
{
double (*data)[sizex] = malloc(sizeof (**data) * sizex * sizey);
if (!data)
{
perror("data values memory allocation failed");
return EXIT_FAILURE;
}
for (size_t j = 0; j < sizey; ++j)
for (size_t i = 0; i < sizex; ++i)
{
data[j][i] = my_gamma_dist((double)i/(double)(sizex - 1));
}
data[sizey/3][sizex/2] = missValue;
streamWriteVar(streamID, 0, (const double *)data, 1);
free(data);
}
streamClose(streamID);
return EXIT_SUCCESS;
}
static inline double
cart_distance(struct cart_coord p1, struct cart_coord p2)
{
double d_lat = sin((p1.lat-p2.lat)/2.0),
d_lon = sin((p1.lon - p2.lon)/2.0),
d = 2.0 * asin(sqrt(d_lat * d_lat +
cos(p1.lat)*cos(p2.lat) * (d_lon * d_lon)));
return d;
}
static inline struct cart_coord
intermediate_coord(struct cart_coord p1, struct cart_coord p2, double f)
{
double d = cart_distance(p1, p2),
sine_of_d = sin(d),
A = sin((1 - f) * d) / sine_of_d,
B = sin(f * d) / sine_of_d,
x = A * cos(p1.lat) * cos(p1.lon) + B * cos(p2.lat) * cos(p2.lon),
y = A * cos(p1.lat) * sin(p1.lon) + B * cos(p2.lat) * sin(p2.lon),
z = A * sin(p1.lat) + B * sin(p2.lat);
struct cart_coord ic = { .lat = atan2(z, sqrt(x * x + y * y)),
.lon = atan2(y, x) };
return ic;
}
static void
compute_curvilinear(double *coords_,
const struct cart_coord a[4], size_t sizex, size_t sizey)
{
double (*coords)[sizey][sizex] = (double (*)[sizey][sizex])coords_;
for (size_t j = 0; j < sizey; ++j)
{
double g = (double)j / (double)(sizey - 1);
/* compute start/end coordinates of great circle in x direction */
struct cart_coord gc_left = intermediate_coord(a[0], a[3], g),
gc_right = intermediate_coord(a[1], a[2], g);
for (size_t i = 0; i < sizex; ++i)
{
double f = (double)i / (double)(sizex - 1);
struct cart_coord pij = intermediate_coord(gc_left, gc_right, f);
coords[0][j][i] = RAD2DEG(pij.lat);
coords[1][j][i] = RAD2DEG(pij.lon);
}
}
}
static double
my_gamma_dist(double x)
{
enum {
k = 9,
};
const double theta = 0.5;
x *= 20.0;
double pdf_x = 1.0 / ( tgamma(k) * pow(theta, k) ) * pow(x, k - 1)
* exp(-x/theta);
return pdf_x;
}
/*
* Local Variables:
* c-file-style: "Java"
* c-basic-offset: 2
* indent-tabs-mode: nil
* show-trailing-whitespace: t
* require-trailing-newline: t
* End:
*/
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