From 273d2313b401c988c6544f2f0be6f503921dc1c5 Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Mon, 1 Jul 2024 14:56:52 -0700 Subject: [PATCH 01/11] rm Number type --- Number.H | 96 +------------------------------------------------------- heat.C | 9 ------ 2 files changed, 1 insertion(+), 104 deletions(-) diff --git a/Number.H b/Number.H index 0a1ddd9..e1933a8 100644 --- a/Number.H +++ b/Number.H @@ -19,101 +19,7 @@ typedef long double fpnumber; #error UNRECOGNIZED FPTYPE #endif -// Encapsulate a floating point number to easily track various metrics. -// Note: Doing this well is complicated by the mix of types in numerical -// statements (e.g. int*double) made explicit by modern compilers. -class Number { - public: - static void *operator new(std::size_t sz) { Number::nbytes += sz; return ::operator new(sz); }; - static void *operator new[](std::size_t sz) { Number::nbytes += sz; return ::operator new(sz); }; - static char const *counts_string() { static char counts[256]; - snprintf(counts, sizeof(counts), "Adds:%d, Mults:%d, Divs:%d, Bytes:%d", Number::nadds, Number::nmults, Number::ndivs, (int) Number::nbytes); - return counts; }; - inline Number() : x(0) {}; - inline Number(fpnumber _x) : x(_x) {}; -#if FPTYPE!=2 - inline Number(double _x) : x((fpnumber) _x) {}; -#endif - inline Number(int _x) : x((fpnumber) _x) {}; - - inline Number &operator=(const Number& rhs) { this->x = rhs.x; return *this; }; - inline operator fpnumber() const { return x; }; - inline operator int() const { return static_cast(x); }; -#if FPTYPE!=2 - inline operator double() const { return static_cast(x); }; -#endif - private: - static int nadds; - static int nmults; - static int ndivs; - static std::size_t nbytes; - fpnumber x; - - #pragma omp threadprivate(nadds) - #pragma omp threadprivate(nmults) - #pragma omp threadprivate(ndivs) - #pragma omp threadprivate(nbytes) - - // Various operators on Number w/mix of int - friend Number operator+(const Number& lhs, const Number& rhs) { Number::nadds++; return lhs.x + rhs.x; }; - friend Number operator+(const int& lhs, const Number& rhs) { Number::nadds++; return lhs + rhs.x; }; - friend Number operator+(const Number& lhs, const int& rhs) { Number::nadds++; return lhs.x + rhs; }; - friend Number operator+(const double& lhs, const Number& rhs) { Number::nadds++; return lhs + rhs.x; }; - friend Number operator+(const Number& lhs, const double& rhs) { Number::nadds++; return lhs.x + rhs; }; - friend Number operator+=(Number& lhs, const Number& rhs) { Number::nadds++; return lhs.x += rhs.x; }; - friend Number operator+=(Number& lhs, const double& rhs) { Number::nadds++; return lhs.x += rhs; }; - friend Number operator+=(double& lhs, const Number& rhs) { Number::nadds++; return lhs += rhs.x; }; - friend Number operator-(const Number& lhs, const Number& rhs) { Number::nadds++; return lhs.x - rhs.x; }; - friend Number operator-(const int& lhs, const Number& rhs) { Number::nadds++; return lhs - rhs.x; }; - friend Number operator-(const Number& lhs, const int& rhs) { Number::nadds++; return lhs.x - rhs; }; - friend Number operator-(const double& lhs, const Number& rhs) { Number::nadds++; return lhs - rhs.x; }; - friend Number operator-(const Number& lhs, const double& rhs) { Number::nadds++; return lhs.x - rhs; }; - friend Number operator-(const Number& rhs) { Number::nadds++; return -rhs.x; }; - friend Number operator-=(Number& lhs, const Number& rhs) { Number::nadds++; return lhs.x -= rhs.x; }; - friend Number operator*(const Number& lhs, const Number& rhs) { Number::nmults++; return lhs.x * rhs.x; }; - friend Number operator*(const int& lhs, const Number& rhs) { Number::nmults++; return lhs * rhs.x; }; - friend Number operator*(const Number& lhs, const int& rhs) { Number::nmults++; return lhs.x * rhs; }; - friend Number operator*(const double& lhs, const Number& rhs) { Number::nmults++; return lhs * rhs.x; }; - friend Number operator*(const Number& lhs, const double& rhs) { Number::nmults++; return lhs.x * rhs; }; - friend Number operator*=(Number& lhs, const Number& rhs) { Number::nmults++; return lhs.x *= rhs.x; }; - friend Number operator/(const Number& lhs, const Number& rhs) { Number::ndivs++; return lhs.x / rhs.x; }; - friend Number operator/(const int& lhs, const Number& rhs) { Number::ndivs++; return lhs / rhs.x; }; - friend Number operator/(const Number& lhs, const int& rhs) { Number::ndivs++; return lhs.x / rhs; }; - friend Number operator/(const double& lhs, const Number& rhs) { Number::ndivs++; return lhs / rhs.x; }; - friend Number operator/(const Number& lhs, const double& rhs) { Number::ndivs++; return lhs.x / rhs; }; - friend Number operator/=(Number& lhs, const Number& rhs) { Number::ndivs++; return lhs.x /= rhs.x; }; - friend bool operator< (const Number& lhs, const Number& rhs){ return lhs.x < rhs.x; } - friend bool operator< (const int& lhs, const Number& rhs){ return lhs < rhs.x; } - friend bool operator< (const Number& lhs, const int& rhs){ return lhs.x < rhs; } - friend bool operator< (const double& lhs, const Number& rhs){ return lhs < rhs.x; } - friend bool operator< (const Number& lhs, const double& rhs){ return lhs.x < rhs; } - friend bool operator> (const Number& lhs, const Number& rhs){ return rhs < lhs; } - friend bool operator> (const int& lhs, const Number& rhs){ return rhs < lhs; } - friend bool operator> (const Number& lhs, const int& rhs){ return rhs < lhs; } - friend bool operator> (const double& lhs, const Number& rhs){ return rhs < lhs; } - friend bool operator> (const Number& lhs, const double& rhs){ return rhs < lhs; } - friend bool operator<=(const Number& lhs, const Number& rhs){ return !(lhs > rhs); } - friend bool operator<=(const int& lhs, const Number& rhs){ return !(lhs > rhs); } - friend bool operator<=(const Number& lhs, const int& rhs){ return !(lhs > rhs); } - friend bool operator<=(const double& lhs, const Number& rhs){ return !(lhs > rhs); } - friend bool operator<=(const Number& lhs, const double& rhs){ return !(lhs > rhs); } - friend bool operator>=(const Number& lhs, const Number& rhs){ return !(lhs < rhs); } - friend bool operator>=(const int& lhs, const Number& rhs){ return !(lhs < rhs); } - friend bool operator>=(const Number& lhs, const int& rhs){ return !(lhs < rhs); } - friend bool operator>=(const double& lhs, const Number& rhs){ return !(lhs < rhs); } - friend bool operator>=(const Number& lhs, const double& rhs){ return !(lhs < rhs); } - friend bool operator==(const Number& lhs, const Number& rhs){ return lhs.x == rhs.x; } - friend bool operator==(const int& lhs, const Number& rhs){ return lhs == rhs.x; } - friend bool operator==(const Number& lhs, const int& rhs){ return lhs.x == rhs; } - friend bool operator==(const double& lhs, const Number& rhs){ return lhs == rhs.x; } - friend bool operator==(const Number& lhs, const double& rhs){ return lhs.x == rhs; } - friend bool operator!=(const Number& lhs, const Number& rhs){ return !(lhs == rhs); } - friend bool operator!=(const int& lhs, const Number& rhs){ return !(lhs == rhs); } - friend bool operator!=(const Number& lhs, const int& rhs){ return !(lhs == rhs); } - friend bool operator!=(const double& lhs, const Number& rhs){ return !(lhs == rhs); } - friend bool operator!=(const Number& lhs, const double& rhs){ return !(lhs == rhs); } - friend std::ostream& operator<<(std::ostream& os, const Number& rhs) { os << rhs.x; return os; } -}; +#define Number double #define TSTART -1 #define TFINAL -2 diff --git a/heat.C b/heat.C index fd3d66a..3a42398 100644 --- a/heat.C +++ b/heat.C @@ -2,12 +2,6 @@ #include "heat.H" -// Number class' statics -int Number::nadds = 0; -int Number::nmults = 0; -int Number::ndivs = 0; -std::size_t Number::nbytes = 0; - // Command-line argument variables int noout = 0; int savi = 0; @@ -141,9 +135,6 @@ int finalize(int ti, Number maxt, Number change) if (outi) { printf("Iteration %04d: last change l2=%g\n", ti, (double) change); -#ifndef _OPENMP - printf("Counts: %s\n", Number::counts_string()); -#endif } delete [] curr; From f814e4355e36f13a7036e9a03cdefed223c5d5dd Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Mon, 1 Jul 2024 15:45:40 -0700 Subject: [PATCH 02/11] rm C++ code --- Number.H | 6 ++---- args.C | 12 ++++++------ crankn.C | 2 +- heat.C | 26 +++++++++++++------------- heat.H | 1 - makefile | 19 ++++++------------- 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/Number.H b/Number.H index e1933a8..df5c4e7 100644 --- a/Number.H +++ b/Number.H @@ -1,14 +1,12 @@ #include -#include "Half.H" - #ifndef FPTYPE #define FPTYPE 2 #endif // 0=half, 1=float, 2=double, 3=quad #if FPTYPE == 0 -typedef half_float::half fpnumber; +#error Half is disabled #elif FPTYPE == 1 typedef float fpnumber; #elif FPTYPE == 2 @@ -19,7 +17,7 @@ typedef long double fpnumber; #error UNRECOGNIZED FPTYPE #endif -#define Number double +#define Number fpnumber #define TSTART -1 #define TFINAL -2 diff --git a/args.C b/args.C index dc02e1c..c2a7145 100644 --- a/args.C +++ b/args.C @@ -8,7 +8,7 @@ static char clargs[2048]; char const *q = style[1]=='s'?"\"":""; \ void *valp = (void*) &VAR; \ int const len = strlen(#VAR)+1; \ - std::stringstream strmvar; \ + char valstr[64]; \ for (i = 1; i < argc; i++) \ {\ int valid_style = style[1]=='d'||style[1]=='g'||style[1]=='s'; \ @@ -25,23 +25,23 @@ static char clargs[2048]; *((char**) valp) = (char*) strdup(argv[i]+len); \ }\ }\ - strmvar << VAR; \ + snprintf(valstr, sizeof(valstr), #STYLE, VAR); \ if (help) \ {\ char tmp[256]; \ int len = snprintf(tmp, sizeof(tmp), " %s=%s%s%s", \ - #VAR, q, strmvar.str().c_str(), q);\ + #VAR, q, valstr, q);\ snprintf(tmp, sizeof(tmp), "%s (%s)", #HELP, #TYPE); \ fprintf(stderr, " %s=%s%s%s%*s\n", \ - #VAR, q, strmvar.str().c_str(), q, 80-len, tmp);\ + #VAR, q, valstr, q, 80-len, tmp);\ }\ else \ { \ char tmp[64]; \ fprintf(stderr, " %s=%s%s%s\n", \ - #VAR, q, strmvar.str().c_str(), q);\ + #VAR, q, valstr, q);\ snprintf(tmp, sizeof(tmp), " %s=%s%s%s\n", \ - #VAR, q, strmvar.str().c_str(), q);\ + #VAR, q, valstr, q);\ strcat(clargs, tmp); \ } \ } diff --git a/crankn.C b/crankn.C index 59809cb..6aabbd1 100644 --- a/crankn.C +++ b/crankn.C @@ -31,7 +31,7 @@ initialize_crankn(int n, Number const w = alpha * dt / dx / dx; // Build a tri-diagonal matrix - Number *cn_Amat = new Number[3*n](); + Number *cn_Amat = (Number*) malloc(3*n*sizeof(Number)); cn_Amat[0+0*3] = 0.0; cn_Amat[1+0*3] = 1.0; diff --git a/heat.C b/heat.C index 3a42398..2be030e 100644 --- a/heat.C +++ b/heat.C @@ -87,13 +87,13 @@ initialize(void) Nt = (int) (maxt/dt); dx = lenx/(Nx-1); - curr = new Number[Nx](); - back1 = new Number[Nx](); + curr = (Number*) malloc(Nx * sizeof(Number)); + back1 = (Number*) malloc(Nx * sizeof(Number)); if (save) { - exact = new Number[Nx](); - change_history = new Number[Nx](); - error_history = new Number[Nx](); + exact = (Number*) malloc(Nx * sizeof(Number)); + change_history = (Number*) malloc(Nx * sizeof(Number)); + error_history = (Number*) malloc(Nx * sizeof(Number)); } assert(strncmp(alg, "ftcs", 4)==0 || @@ -115,7 +115,7 @@ initialize(void) initialize_crankn(Nx, alpha, dx, dt, &cn_Amat); if (!strncmp(alg, "dufrank", 7)) - back2 = new Number[Nx](); + back2 = (Number*) malloc(Nx * sizeof(Number)); // Initial condition set_initial_condition(Nx, back1, dx, ic); @@ -137,13 +137,13 @@ int finalize(int ti, Number maxt, Number change) printf("Iteration %04d: last change l2=%g\n", ti, (double) change); } - delete [] curr; - delete [] back1; - if (back2) delete [] back2; - if (exact) delete [] exact; - if (change_history) delete [] change_history; - if (error_history) delete [] error_history; - if (cn_Amat) delete [] cn_Amat; + free(curr); + free(back1); + if (back2) free(back2); + if (exact) free(exact); + if (change_history) free(change_history); + if (error_history) free(error_history); + if (cn_Amat) free(cn_Amat); if (strncmp(alg, "ftcs", 4)) free((void*)alg); if (strncmp(ic, "const(1)", 8)) free((void*)ic); diff --git a/heat.H b/heat.H index d0580d7..6306327 100644 --- a/heat.H +++ b/heat.H @@ -23,5 +23,4 @@ // Lets overlook the fact that we're including one // header inside of another just for convenience -#include "Half.H" #include "Number.H" diff --git a/makefile b/makefile index dd85bf4..fb4c6fd 100644 --- a/makefile +++ b/makefile @@ -11,7 +11,7 @@ RUNAME ?= heat_results PIPEWIDTH ?= 0.1 RM = rm -HDR = Number.H Half.H +HDR = Number.H heat.H SRC = heat.C utils.C args.C exact.C ftcs.C crankn.C dufrank.C OBJ = $(SRC:.C=.o) GCOV = $(SRC:.C=.C.gcov) $(SRC:.C=.gcda) $(SRC:.C=.gcno) $(HDR:.H=.H.gcov) @@ -19,14 +19,13 @@ EXE = heat # Implicit rule for object files %.o : %.C - $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ + $(CC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@ # Help is default target help: @echo "Targets:" @echo " heat: makes the default heat application (double precision)" @echo " heat-omp: makes default heat application with openmp threads" - @echo " heat-half: makes the heat application with half precision" @echo " heat-single: makes the heat application with single precision" @echo " heat-double: makes the heat application with double precision" @echo " heat-long-double: makes the heat application with long-double precision" @@ -36,10 +35,10 @@ help: # Linking the final heat app heat: $(OBJ) - $(CXX) -o heat $(OBJ) $(LDFLAGS) -lm + $(CC) -o heat $(OBJ) $(LDFLAGS) -lm -heat-omp: CXX=clang -heat-omp: CXXFLAGS=-fopenmp +heat-omp: CC=clang +heat-omp: CCFLAGS=-fopenmp heat-omp: LDFLAGS=-lomp -lstdc++ heat-omp: $(OBJ) heat-omp: heat @@ -48,12 +47,6 @@ heat-omp: heat # All objects depend on header $(OBJ): $(HDR) -# Convenience variable/target for half-precision -heat-half: CPPFLAGS=-DFPTYPE=0 -heat-half: $(OBJ) -heat-half: heat - mv heat heat-half - # Convenience variable/target for single-precision heat-single: CPPFLAGS=-DFPTYPE=1 heat-single: $(OBJ) @@ -81,7 +74,7 @@ plot: check_clean: $(RM) -rf check check_crankn check_dufrank - $(RM) -rf heat heat-omp heat-half heat-single heat-double heat-long-double + $(RM) -rf heat heat-omp heat-single heat-double heat-long-double clean: check_clean $(RM) -f $(OBJ) $(EXE) $(GCOV) From cdd41f11810c9277119ac7fee724e40be2821b68 Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Mon, 1 Jul 2024 16:06:13 -0700 Subject: [PATCH 03/11] rm last ref to "half" --- args.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/args.C b/args.C index c2a7145..6aba189 100644 --- a/args.C +++ b/args.C @@ -121,7 +121,7 @@ process_args(int argc, char **argv) HANDLE_ARG(save, int, %d, save error in every saved solution); HANDLE_ARG(outi, int, %d, output progress every i-th solution step); HANDLE_ARG(noout, int, %d, disable all file outputs); - HANDLE_ARG(prec, const int, %d, precision 0=half/1=float/2=double/3=long double) + HANDLE_ARG(prec, const int, %d, precision 1=float/2=double/3=long double) if (help) handle_help(argv[0]); From 017a75f7bec3b9a5227ca8afa95ffe3eee78ef5c Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Mon, 1 Jul 2024 17:40:08 -0700 Subject: [PATCH 04/11] re-add half support --- Number.H | 2 +- args.C | 2 +- makefile | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Number.H b/Number.H index df5c4e7..198858f 100644 --- a/Number.H +++ b/Number.H @@ -6,7 +6,7 @@ // 0=half, 1=float, 2=double, 3=quad #if FPTYPE == 0 -#error Half is disabled +typedef _Float16 fpnumber; #elif FPTYPE == 1 typedef float fpnumber; #elif FPTYPE == 2 diff --git a/args.C b/args.C index 6aba189..e6a4a45 100644 --- a/args.C +++ b/args.C @@ -25,7 +25,7 @@ static char clargs[2048]; *((char**) valp) = (char*) strdup(argv[i]+len); \ }\ }\ - snprintf(valstr, sizeof(valstr), #STYLE, VAR); \ + snprintf(valstr, sizeof(valstr), #STYLE, (TYPE) VAR); \ if (help) \ {\ char tmp[256]; \ diff --git a/makefile b/makefile index fb4c6fd..75cb57e 100644 --- a/makefile +++ b/makefile @@ -19,7 +19,7 @@ EXE = heat # Implicit rule for object files %.o : %.C - $(CC) -c $(CCFLAGS) $(CPPFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ # Help is default target help: @@ -38,7 +38,7 @@ heat: $(OBJ) $(CC) -o heat $(OBJ) $(LDFLAGS) -lm heat-omp: CC=clang -heat-omp: CCFLAGS=-fopenmp +heat-omp: CFLAGS=-fopenmp heat-omp: LDFLAGS=-lomp -lstdc++ heat-omp: $(OBJ) heat-omp: heat @@ -47,6 +47,13 @@ heat-omp: heat # All objects depend on header $(OBJ): $(HDR) +# Convenience variable/target for half-precision +heat-half: CPPFLAGS=-DFPTYPE=0 +heat-half: CFLAGS=-Wno-format +heat-half: $(OBJ) +heat-half: heat + mv heat heat-half + # Convenience variable/target for single-precision heat-single: CPPFLAGS=-DFPTYPE=1 heat-single: $(OBJ) From ea19dd7a68d80a13be698591a4a33667a508a88f Mon Sep 17 00:00:00 2001 From: remontel Date: Fri, 5 Jul 2024 10:42:29 -0700 Subject: [PATCH 05/11] added vscode settings and shared library source code --- .vscode/settings.json | 23 +++++++ helloPy.C | 144 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 helloPy.C diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e13a10f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,23 @@ +{ + "python.pythonPath": "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/bin/python3", + "python.languageServer": "Pylance", + "python.analysis.typeCheckingMode": "basic", + "python.analysis.autoSearchPaths": true, + "python.analysis.useLibraryCodeForTypes": true, + "code-runner.executorMap": { + "python": "python -u" + }, + "code-runner.runInTerminal": true, + "code-runner.saveFileBeforeRun": true, + "python.linting.enabled": true, + "python.linting.ruffEnabled": true, + "python.linting.pylintEnabled": false, + "python.linting.ruffArgs": [], + "files.associations": { + "libfoo.C": "cpp", + "utils.C": "cpp", + "helloPy.C": "cpp", + "ftcs.C": "cpp", + "heat.C": "cpp" + } +} diff --git a/helloPy.C b/helloPy.C new file mode 100644 index 0000000..da8d02a --- /dev/null +++ b/helloPy.C @@ -0,0 +1,144 @@ +#include +#include "heat.H" // Include the header for the heat equation solver +// #include // for OpenMP parallelization + +// Define a structure to hold problem data +typedef struct { + double lenx; + double alpha; + int nx; + double dx; + double dt; + double *uk; + double *uk1; +} HeatProblem; + +// Global variable to hold the problem data +static HeatProblem problem; + +/* +// Define a new Python function +static PyObject* foo_func(PyObject *self, PyObject *args) { + return PyUnicode_FromString("hello world"); +} +*/ + +// Function to initialize the heat equation problem +static PyObject* init_problem(PyObject *self, PyObject *args) { + double lenx, alpha; + int nx; + if (!PyArg_ParseTuple(args, "ddi", &lenx, &alpha, &nx)) { + return NULL; + } + + problem.lenx = lenx; + problem.alpha = alpha; + problem.nx = nx; + problem.dx = lenx / (nx - 1); + problem.dt = 0.0; // Default value, will be set in solve function + problem.uk = (double *)malloc(nx * sizeof(double)); + problem.uk1 = (double *)malloc(nx * sizeof(double)); + + if (!problem.uk || !problem.uk1) { + return PyErr_NoMemory(); + } + + // Initialize uk and uk1 with initial conditions (i.e., zero) + for (int i = 0; i < nx; i++) { + problem.uk[i] = 0.0; + problem.uk1[i] = 0.0; + } + + Py_RETURN_NONE; +} + +// Function to solve the heat equation +static PyObject* solve_heat_equation(PyObject *self, PyObject *args) { + double dx, dt, maxt; + int nt; + if (!PyArg_ParseTuple(args, "dddi", &dx, &dt, &maxt, &nt)) { + return NULL; + } + + problem.dx = dx; + problem.dt = dt; + double alpha = problem.alpha; + double lenx = problem.lenx; + int nx = problem.nx; + + double bc0 = 0.0; // Boundary condition at x=0 + double bc1 = 0.0; // Boundary condition at x=lenx + + bool stable = true; + int time_steps = (int)(maxt / dt); + + for (int t = 0; t < time_steps; t++) { + stable = update_solution_ftcs(nx, problem.uk, problem.uk1, alpha, dx, dt, bc0, bc1); + if (!stable) { + PyErr_SetString(PyExc_RuntimeError, "Solution became unstable"); + return NULL; + } + + // Swap uk and uk1 for next iteration + double *temp = problem.uk1; + problem.uk1 = problem.uk; + problem.uk = temp; + } + + // Return the final solution as a Python list + PyObject *result = PyList_New(nx); + for (int i = 0; i < nx; i++) { + PyList_SetItem(result, i, PyFloat_FromDouble(problem.uk[i])); + } + + return result; +} + + +/* +// Declare methods in the module +static PyMethodDef FooMethods[] = { + {"foo_func", foo_func, METH_NOARGS, "Return the string 'hello world'"}, + {NULL, NULL, 0, NULL} // Sentinel +}; +*/ + +// Declare methods in the module +static PyMethodDef HeatMethods[] = { + {"init_problem", init_problem, METH_VARARGS, "Initialize the heat equation problem"}, + {"solve_heat_equation", solve_heat_equation, METH_VARARGS, "Solve the heat equation"}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + + +/* +// Define the module structure +static struct PyModuleDef foomodule = { + PyModuleDef_HEAD_INIT, + "foo", // name of module + NULL, // module documentation, may be NULL + -1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables. + FooMethods +}; +*/ + +// Define the module structure +static struct PyModuleDef heatmodule = { + PyModuleDef_HEAD_INIT, + "heat", /* name of module */ + NULL, /* module documentation, may be NULL */ + -1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */ + HeatMethods +}; + +/* +// Initialize the module +PyMODINIT_FUNC PyInit_helloPy(void) { + return PyModule_Create(&foomodule); +} +*/ + +// Initialize the module +PyMODINIT_FUNC PyInit_helloPy(void) { + return PyModule_Create(&heatmodule); +} \ No newline at end of file From d3a98aaa83f49d095daa889b7d71c9363d73d919 Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Fri, 5 Jul 2024 19:45:47 -0700 Subject: [PATCH 06/11] fix prec printing --- utils.C | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/utils.C b/utils.C index 55f1ac8..9b28b4c 100644 --- a/utils.C +++ b/utils.C @@ -78,17 +78,16 @@ write_array(int t, int n, Number dx, Number const *a) fprintf(outf, "# %s\n", vname); for (i = 0; i < n; i++) { -#if FPTYPE == 0 - fprintf(outf, "%- 7.5e %- 7.5e\n", double(i*dx), double(a[i])); -#elif FPTYPE == 1 - fprintf(outf, "%- 11.9e %- 11.9e\n", (double) (i*dx), (double) a[i]); -#elif FPTYPE == 2 - fprintf(outf, "%- 19.17e %- 19.17e\n", (double) (i*dx), (double) a[i]); -#elif FPTYPE == 3 - fprintf(outf, "%- 27.25Le %- 27.25Le\n", (fpnumber) (i*dx), (fpnumber) a[i]); -#elif -#error UNKNOWN FPTYPE -#endif + if (sizeof(fpnumber) == 2) + fprintf(outf, "%- .4e %- .4e\n", (double) i*dx, (double) a[i]); + else if (sizeof(fpnumber) == 4) + fprintf(outf, "%- .7e %- .7e\n", (double) i*dx, (double) a[i]); + else if (sizeof(fpnumber) == 8) + fprintf(outf, "%- .16e %- .16e\n", (double) i*dx, (double) a[i]); + else if (sizeof(fpnumber) == 10) + fprintf(outf, "%- .19Le %- .19Le\n", (long double) i*dx, (long double) a[i]); + else if (sizeof(fpnumber) == 16) + fprintf(outf, "%- .34Le %- .34Le\n", (long double) i*dx, (long double) a[i]); } fclose(outf); } From 4290cdb54a5f178b2dc970de8f8ea98d15b2f96a Mon Sep 17 00:00:00 2001 From: remontel Date: Wed, 10 Jul 2024 14:42:35 -0700 Subject: [PATCH 07/11] Configured IntelliSense for Python headers and updated settings.json --- .vscode/c_cpp_properties.json | 22 ++++++++++++++++++++++ .vscode/settings.json | 23 ++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..e1b4277 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,22 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**", + "/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12" + ], + "defines": [], + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-x64" + } + ], + "version": 4 + } + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index e13a10f..9df717e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,18 +1,39 @@ { - "python.pythonPath": "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/bin/python3", + // Path to the Python interpreter + "python.defaultInterpreterPath": "/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/bin/python3", + + // Use Pylance as the language server "python.languageServer": "Pylance", + + // Basic type checking mode "python.analysis.typeCheckingMode": "basic", + + // Automatically search for import paths "python.analysis.autoSearchPaths": true, + + // Use library code for types "python.analysis.useLibraryCodeForTypes": true, + + // Code Runner extension settings "code-runner.executorMap": { "python": "python -u" }, "code-runner.runInTerminal": true, "code-runner.saveFileBeforeRun": true, + + // Enable linting "python.linting.enabled": true, + + // Use Ruff as the linter "python.linting.ruffEnabled": true, + + // Disable Pylint "python.linting.pylintEnabled": false, + + // Additional arguments for Ruff (empty in this case) "python.linting.ruffArgs": [], + + // File associations to specify how certain files are treated "files.associations": { "libfoo.C": "cpp", "utils.C": "cpp", From 755001f9d0df07c497b67afdfbd74f0d36f01e0c Mon Sep 17 00:00:00 2001 From: "Mark C. Miller" Date: Wed, 10 Jul 2024 19:56:25 -0700 Subject: [PATCH 08/11] fix arg utils for type --- Number.H | 10 ++++- args.C | 125 +++++++++++++++++++++++++++++++++---------------------- utils.C | 13 +----- 3 files changed, 85 insertions(+), 63 deletions(-) diff --git a/Number.H b/Number.H index 198858f..246efa2 100644 --- a/Number.H +++ b/Number.H @@ -1,5 +1,3 @@ -#include - #ifndef FPTYPE #define FPTYPE 2 #endif @@ -7,12 +5,20 @@ // 0=half, 1=float, 2=double, 3=quad #if FPTYPE == 0 typedef _Float16 fpnumber; +#define FPFMT "%- .4g" +#define FPCAST double #elif FPTYPE == 1 typedef float fpnumber; +#define FPFMT "%- .7g" +#define FPCAST double #elif FPTYPE == 2 typedef double fpnumber; +#define FPFMT "%- .16g" +#define FPCAST double #elif FPTYPE == 3 typedef long double fpnumber; +#define FPFMT ((sizeof(fpnumber)==10)?"%- .19Lg":"%- .34Lg") +#define FPCAST long double #else #error UNRECOGNIZED FPTYPE #endif diff --git a/args.C b/args.C index e6a4a45..0243748 100644 --- a/args.C +++ b/args.C @@ -2,48 +2,75 @@ static char clargs[2048]; -#define HANDLE_ARG(VAR, TYPE, STYLE, HELP) \ +#define HANDLE_HELP(VAR, HELP, STYLE) \ + if (help) \ + {\ + char tmp[256]; \ + int len = snprintf(tmp, sizeof(tmp), " %s=%s(%s%s%s)", \ + VAR, #STYLE, q, valstr, q);\ + snprintf(tmp, sizeof(tmp), "%s", HELP); \ + fprintf(stderr, " %s=%s(%s%s%s)%*s\n", \ + VAR, #STYLE, q, valstr, q, 100-len, tmp);\ + }\ + else \ + { \ + char tmp[64]; \ + fprintf(stderr, " %s=%s(%s%s%s)\n", \ + VAR, #STYLE, q, valstr, q);\ + snprintf(tmp, sizeof(tmp), " %s=%s(%s%s%s)\n", \ + VAR, #STYLE, q, valstr, q);\ + strcat(clargs, tmp); \ + } + +#define HANDLE_FARG(VAR, HELP) \ { \ - char const *style = #STYLE; \ - char const *q = style[1]=='s'?"\"":""; \ void *valp = (void*) &VAR; \ + char const *q = ""; \ int const len = strlen(#VAR)+1; \ char valstr[64]; \ for (i = 1; i < argc; i++) \ {\ - int valid_style = style[1]=='d'||style[1]=='g'||style[1]=='s'; \ if (strncmp(argv[i], #VAR"=", len)) \ continue; \ - assert(valid_style); \ if (strlen(argv[i]+len)) \ - {\ - if (style[1] == 'd') /* int */ \ - *((int*) valp) = (int) strtol(argv[i]+len,0,10); \ - else if (style[1] == 'g') /* double */ \ - *((Number*) valp) = (fpnumber) strtod(argv[i]+len,0); \ - else if (style[1] == 's') /* char* */ \ - *((char**) valp) = (char*) strdup(argv[i]+len); \ - }\ + *((fpnumber*) valp) = (fpnumber) strtod(argv[i]+len,0); \ }\ - snprintf(valstr, sizeof(valstr), #STYLE, (TYPE) VAR); \ - if (help) \ + snprintf(valstr, sizeof(valstr), FPFMT, (double) VAR); \ + HANDLE_HELP(#VAR, #HELP, float) \ +} + +#define HANDLE_IARG(VAR, HELP) \ +{ \ + void *valp = (void*) &VAR; \ + char const *q = ""; \ + int const len = strlen(#VAR)+1; \ + char valstr[64]; \ + for (i = 1; i < argc; i++) \ {\ - char tmp[256]; \ - int len = snprintf(tmp, sizeof(tmp), " %s=%s%s%s", \ - #VAR, q, valstr, q);\ - snprintf(tmp, sizeof(tmp), "%s (%s)", #HELP, #TYPE); \ - fprintf(stderr, " %s=%s%s%s%*s\n", \ - #VAR, q, valstr, q, 80-len, tmp);\ + if (strncmp(argv[i], #VAR"=", len)) \ + continue; \ + if (strlen(argv[i]+len)) \ + *((int*) valp) = (int) strtol(argv[i]+len,0,10); \ }\ - else \ - { \ - char tmp[64]; \ - fprintf(stderr, " %s=%s%s%s\n", \ - #VAR, q, valstr, q);\ - snprintf(tmp, sizeof(tmp), " %s=%s%s%s\n", \ - #VAR, q, valstr, q);\ - strcat(clargs, tmp); \ - } \ + snprintf(valstr, sizeof(valstr), "%d", (int) VAR); \ + HANDLE_HELP(#VAR, #HELP, int) \ +} + +#define HANDLE_SARG(VAR, HELP) \ +{ \ + void *valp = (void*) &VAR; \ + char const *q = "\""; \ + int const len = strlen(#VAR)+1; \ + char valstr[64]; \ + for (i = 1; i < argc; i++) \ + {\ + if (strncmp(argv[i], #VAR"=", len)) \ + continue; \ + if (strlen(argv[i]+len)) \ + *((char**) valp) = (char*) strdup(argv[i]+len); \ + }\ + snprintf(valstr, sizeof(valstr), "%s", (char*) VAR); \ + HANDLE_HELP(#VAR, #HELP, string) \ } extern Number alpha; @@ -80,11 +107,11 @@ static void handle_ic_help() fprintf(stderr, " ic=\"step(L,Mx,R)\" a step function with value L for x=Mx\n"); fprintf(stderr, " ic=\"rand(S,B,A)\" random values in the range [B-A,B+A] using seed S\n"); fprintf(stderr, " ic=\"sin(A,w)\" a sin wave with amplitude A and frequency w\n"); - fprintf(stderr, " ic=\"spikes(C,A0,X0,A1,X1,...)\" a constant value, C with N spikes of amplitude Ai at position Xi\n"); + fprintf(stderr, " ic=\"spikes(C,A0,X0,A1,X1,...)\" a constant value, C with spikes of amplitude Ai at position Xi\n"); fprintf(stderr, " ic=\"file(foo.dat)\" : read initial condition data from the file foo.dat\n"); fprintf(stderr, "Be sure to use double-quotes (\") as shown and you may also need to set boundary" - "\nconditions such that they *combine* smoothly with the initial conditions.\n"); + "\nconditions such that they *combine* smoothly with the initial condition.\n"); } void @@ -101,27 +128,27 @@ process_args(int argc, char **argv) if (help) fprintf(stderr, "Usage: %s = =...\n", argv[0]); - HANDLE_ARG(alpha, fpnumber, %g, material thermal diffusivity (sq-meters/second)); - HANDLE_ARG(lenx, fpnumber, %g, material length (meters)); - HANDLE_ARG(dx, fpnumber, %g, x-incriment. Best if lenx/dx==int. (meters)); - HANDLE_ARG(dt, fpnumber, %g, t-incriment (seconds)); - HANDLE_ARG(maxt, fpnumber, %g, >0:max sim time (seconds) | <0:min l2 change in soln); - HANDLE_ARG(bc0, fpnumber, %g, boundary condition @ x=0: u(0,t) (Kelvin)); - HANDLE_ARG(bc1, fpnumber, %g, boundary condition @ x=lenx: u(lenx,t) (Kelvin)); - HANDLE_ARG(runame, char*, %s, name to give run and results dir); - HANDLE_ARG(ic, char*, %s, initial condition @ t=0: u(x,0) (Kelvin)); - HANDLE_ARG(alg, char*, %s, algorithm ftcs|dufrank|crankn); + HANDLE_FARG(alpha, material thermal diffusivity (sq-meters/second)); + HANDLE_FARG(lenx, material length (meters)); + HANDLE_FARG(dx, x-incriment. Best if lenx/dx==int. (meters)); + HANDLE_FARG(dt, t-incriment (seconds)); + HANDLE_FARG(maxt, >0:max sim time (seconds) | <0:min l2 change in soln); + HANDLE_FARG(bc0, boundary condition @ x=0: u(0,t) (Kelvin)); + HANDLE_FARG(bc1, boundary condition @ x=lenx: u(lenx,t) (Kelvin)); + HANDLE_SARG(runame, name to give run and results dir); + HANDLE_SARG(ic, initial condition @ t=0: u(x,0) (Kelvin)); + HANDLE_SARG(alg, algorithm ftcs|dufrank|crankn); #ifdef _OPENMP - HANDLE_ARG(nt, int, %d, number of parallel tasks); + HANDLE_IARG(nt, number of parallel tasks); #else - HANDLE_ARG(nt, int, %d, parallel tasking is DISABLED!!); + HANDLE_IARG(nt, parallel tasking is DISABLED!!); nt = 0; #endif - HANDLE_ARG(savi, int, %d, save every i-th solution step); - HANDLE_ARG(save, int, %d, save error in every saved solution); - HANDLE_ARG(outi, int, %d, output progress every i-th solution step); - HANDLE_ARG(noout, int, %d, disable all file outputs); - HANDLE_ARG(prec, const int, %d, precision 1=float/2=double/3=long double) + HANDLE_IARG(savi, save every i-th solution step); + HANDLE_IARG(save, save error in every saved solution); + HANDLE_IARG(outi, output progress every i-th solution step); + HANDLE_IARG(noout, disable all file outputs); + HANDLE_IARG(prec, precision 1=float/2=double/3=long double) if (help) handle_help(argv[0]); diff --git a/utils.C b/utils.C index 9b28b4c..4c3f917 100644 --- a/utils.C +++ b/utils.C @@ -77,18 +77,7 @@ write_array(int t, int n, Number dx, Number const *a) outf = fopen(fname,"w"); fprintf(outf, "# %s\n", vname); for (i = 0; i < n; i++) - { - if (sizeof(fpnumber) == 2) - fprintf(outf, "%- .4e %- .4e\n", (double) i*dx, (double) a[i]); - else if (sizeof(fpnumber) == 4) - fprintf(outf, "%- .7e %- .7e\n", (double) i*dx, (double) a[i]); - else if (sizeof(fpnumber) == 8) - fprintf(outf, "%- .16e %- .16e\n", (double) i*dx, (double) a[i]); - else if (sizeof(fpnumber) == 10) - fprintf(outf, "%- .19Le %- .19Le\n", (long double) i*dx, (long double) a[i]); - else if (sizeof(fpnumber) == 16) - fprintf(outf, "%- .34Le %- .34Le\n", (long double) i*dx, (long double) a[i]); - } + fprintf(outf, FPFMT " " FPFMT "\n", (FPCAST) i*dx, (FPCAST) a[i]); fclose(outf); } From 0ee3d4a50abb3589630eaf21c977b41cabb6420d Mon Sep 17 00:00:00 2001 From: remontel Date: Tue, 16 Jul 2024 16:29:19 -0700 Subject: [PATCH 09/11] Rename files from .C/.H to .c/.h for transition from C++ to C --- Number.H => Number.h | 0 args.C => args.c | 0 crankn.C => crankn.c | 0 dufrank.C => dufrank.c | 0 exact.C => exact.c | 0 ftcs.C => ftcs.c | 0 heat.C => heat.c | 0 heat.H => heat.h | 0 utils.C => utils.c | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename Number.H => Number.h (100%) rename args.C => args.c (100%) rename crankn.C => crankn.c (100%) rename dufrank.C => dufrank.c (100%) rename exact.C => exact.c (100%) rename ftcs.C => ftcs.c (100%) rename heat.C => heat.c (100%) rename heat.H => heat.h (100%) rename utils.C => utils.c (100%) diff --git a/Number.H b/Number.h similarity index 100% rename from Number.H rename to Number.h diff --git a/args.C b/args.c similarity index 100% rename from args.C rename to args.c diff --git a/crankn.C b/crankn.c similarity index 100% rename from crankn.C rename to crankn.c diff --git a/dufrank.C b/dufrank.c similarity index 100% rename from dufrank.C rename to dufrank.c diff --git a/exact.C b/exact.c similarity index 100% rename from exact.C rename to exact.c diff --git a/ftcs.C b/ftcs.c similarity index 100% rename from ftcs.C rename to ftcs.c diff --git a/heat.C b/heat.c similarity index 100% rename from heat.C rename to heat.c diff --git a/heat.H b/heat.h similarity index 100% rename from heat.H rename to heat.h diff --git a/utils.C b/utils.c similarity index 100% rename from utils.C rename to utils.c From e708adc0c78d8a6985189a7fd9de949d81f02900 Mon Sep 17 00:00:00 2001 From: remontel Date: Tue, 16 Jul 2024 16:36:45 -0700 Subject: [PATCH 10/11] Transition from C++ to C: Replace bool with int, rename file extensions, and update Makefile - Replace all instances of 'bool' with 'int' in source files - Replace 'true' with '1' and 'false' with '0' - Rename all .C files to .c and .H files to .h - Update Makefile to reflect changes in file extensions --- Number.h | 2 +- args.c | 2 +- crankn.c | 6 +++--- dufrank.c | 6 +++--- exact.c | 2 +- ftcs.c | 8 ++++---- heat.c | 30 +++++++++++++++--------------- heat.h | 17 ++++++++--------- makefile | 15 ++++++++++----- utils.c | 2 +- 10 files changed, 47 insertions(+), 43 deletions(-) diff --git a/Number.h b/Number.h index 198858f..b326298 100644 --- a/Number.h +++ b/Number.h @@ -1,4 +1,4 @@ -#include + #ifndef FPTYPE #define FPTYPE 2 diff --git a/args.c b/args.c index e6a4a45..67e2cf0 100644 --- a/args.c +++ b/args.c @@ -1,4 +1,4 @@ -#include "heat.H" +#include "heat.h" static char clargs[2048]; diff --git a/crankn.c b/crankn.c index 6aabbd1..e76e7aa 100644 --- a/crankn.c +++ b/crankn.c @@ -1,4 +1,4 @@ -#include "heat.H" +#include "heat.h" // Licensing: This code is distributed under the GNU LGPL license. // Modified: 30 May 2009 Author: John Burkardt @@ -79,7 +79,7 @@ r83_np_sl ( int n, Number const *a_lu, Number const *b, Number *x) } } -bool +int update_solution_crankn(int n, Number *curr, Number const *last, Number const *cn_Amat, @@ -90,5 +90,5 @@ update_solution_crankn(int n, curr[0] = bc_0; curr[n-1] = bc_1; - return true; + return 1; } diff --git a/dufrank.c b/dufrank.c index cb2a063..b551fb1 100644 --- a/dufrank.c +++ b/dufrank.c @@ -1,6 +1,6 @@ -#include "heat.H" +#include "heat.h" -bool // false if unstable, true otherwise +int // 0 if unstable, 1 otherwise update_solution_dufrank( int n, // number of samples Number *uk, // new array of u(x,k) to compute/return @@ -22,5 +22,5 @@ update_solution_dufrank( uk[0 ] = bc0; uk[n-1] = bc1; - return true; + return 1; } diff --git a/exact.c b/exact.c index 385cd3a..6610aa9 100644 --- a/exact.c +++ b/exact.c @@ -1,4 +1,4 @@ -#include "heat.H" +#include "heat.h" void compute_exact_steady_state_solution(int n, Number *a, Number dx, char const *ic, diff --git a/ftcs.c b/ftcs.c index bf20a4e..38c18e9 100644 --- a/ftcs.c +++ b/ftcs.c @@ -1,6 +1,6 @@ -#include "heat.H" +#include "heat.h" -bool // false if unstable, true otherwise +int // false if unstable, true otherwise update_solution_ftcs( int n, // number of samples Number *uk, // new array of u(x,k) to compute/return @@ -12,7 +12,7 @@ update_solution_ftcs( Number r = alpha * dt / (dx * dx); // sanity check for stability - if (r > 0.5) return false; + if (r > 0.5) return 0; // FTCS update algorithm #pragma omp parallel for @@ -23,5 +23,5 @@ update_solution_ftcs( uk[0 ] = bc0; uk[n-1] = bc1; - return true; + return 1; } diff --git a/heat.c b/heat.c index 2be030e..24a1aee 100644 --- a/heat.c +++ b/heat.c @@ -1,6 +1,6 @@ -#include +#include -#include "heat.H" +#include "heat.h" // Command-line argument variables int noout = 0; @@ -11,14 +11,14 @@ int nt = 0; // number of parallel tasks char const *runame = "heat_results"; char const *alg = "ftcs"; char const *ic = "const(1)"; -Number lenx = Number(1.0); -Number alpha = Number(0.2); -Number dt = Number(0.004); -Number dx = Number(0.1); -Number bc0 = Number(0.0); -Number bc1 = Number(1.0); -Number maxt = Number(2.0); -Number min_change = Number(1e-8*1e-8); +Number lenx = 1.0; +Number alpha = 0.2; +Number dt = 0.004; +Number dx = 0.1; +Number bc0 = 0.0; +Number bc1 = 1.0; +Number maxt = 2.0; +Number min_change = 1e-8*1e-8; // Various arrays of numerical data Number *curr = 0; // current solution @@ -58,19 +58,19 @@ extern void compute_exact_steady_state_solution(int n, Number *a, Number dx, char const *ic, Number alpha, Number t, Number bc0, Number bc1); -extern bool +extern int update_solution_ftcs(int n, Number *curr, Number const *back1, Number alpha, Number dx, Number dt, Number bc_0, Number bc_1); -extern bool +extern int update_solution_crankn(int n, Number *curr, Number const *back1, Number const *cn_Amat, Number bc_0, Number bc_1); -extern bool +extern int update_solution_dufrank(int n, Number *curr, Number const *back1, Number const *back2, Number alpha, Number dx, Number dt, @@ -150,7 +150,7 @@ int finalize(int ti, Number maxt, Number change) return retval; } -static bool +static int update_solution() { if (!strcmp(alg, "ftcs")) @@ -159,7 +159,7 @@ update_solution() return update_solution_crankn(Nx, curr, back1, cn_Amat, bc0, bc1); else if (!strcmp(alg, "dufrank")) return update_solution_dufrank(Nx, curr, back1, back2, alpha, dx, dt, bc0, bc1); - return false; + return 0; } static Number diff --git a/heat.h b/heat.h index 6306327..51b023f 100644 --- a/heat.h +++ b/heat.h @@ -3,19 +3,18 @@ #include #include -#include +#include #ifdef HAVE_FEENABLEEXCEPT #define _GNU_SOURCE #include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include #ifdef _OPENMP #include @@ -23,4 +22,4 @@ // Lets overlook the fact that we're including one // header inside of another just for convenience -#include "Number.H" +#include "Number.h" diff --git a/makefile b/makefile index 75cb57e..7bde885 100644 --- a/makefile +++ b/makefile @@ -11,14 +11,19 @@ RUNAME ?= heat_results PIPEWIDTH ?= 0.1 RM = rm -HDR = Number.H heat.H -SRC = heat.C utils.C args.C exact.C ftcs.C crankn.C dufrank.C -OBJ = $(SRC:.C=.o) -GCOV = $(SRC:.C=.C.gcov) $(SRC:.C=.gcda) $(SRC:.C=.gcno) $(HDR:.H=.H.gcov) +# Headers +HDR = Number.h heat.h +# Source Files +SRC = heat.c utils.c args.c exact.c ftcs.c crankn.c dufrank.c +# Object Files +OBJ = $(SRC:.c=.o) +# Coverage Files +GCOV = $(SRC:.c=.c.gcov) $(SRC:.c=.gcda) $(SRC:.c=.gcno) $(HDR:.h=.h.gcov) +# Executable EXE = heat # Implicit rule for object files -%.o : %.C +%.o : %.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ # Help is default target diff --git a/utils.c b/utils.c index 55f1ac8..9480068 100644 --- a/utils.c +++ b/utils.c @@ -1,4 +1,4 @@ -#include "heat.H" +#include "heat.h" extern int Nx; extern Number *exact; From 620fb87fda8e546912080cded4af19f45684dcdf Mon Sep 17 00:00:00 2001 From: remontel Date: Tue, 16 Jul 2024 16:39:23 -0700 Subject: [PATCH 11/11] changes made to vscode settings --- .DS_Store | Bin 0 -> 6148 bytes .vscode/.DS_Store | Bin 0 -> 6148 bytes .vscode/settings.json | 6 +++++- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .DS_Store create mode 100644 .vscode/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0