commit a4b9b3cadad2a9cc40ea76c202bfebb91fecdeb5
parent 3c032ad517b519a8b500dc877e3a6ce2067b770b
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 11 Dec 2019 13:09:50 +0100
Check simulation size before initializing arrays
Diffstat:
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/max_depth_simple_shear.c b/max_depth_simple_shear.c
@@ -187,6 +187,7 @@ main(int argc, char* argv[])
return 1;
}*/
+ sim.nz = 1;
prepare_arrays(&sim);
if (!isnan(new_phi))
diff --git a/simulation.c b/simulation.c
@@ -9,6 +9,11 @@
void
prepare_arrays(struct simulation* sim)
{
+ if (sim->nz < 2) {
+ fprintf(stderr, "error: grid size (nz) must be at least 2 but is %d\n",
+ sim->nz);
+ exit(1);
+ }
sim->z = linspace(sim->origo_z, /* spatial coordinates */
sim->origo_z + sim->L_z,
sim->nz);