1d_fd_simple_shear

continuum model for granular flows with pore-pressure dynamics
git clone git://src.adamsgaard.dk/1d_fd_simple_shear
Log | Files | Refs | README | LICENSE Back to index

commit de519ac795f069865beefb13be55713b3413382e
parent 7df64da83d8dbe2582f1db38a6bac9bff131dfe8
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 15 Mar 2020 21:22:38 +0100

Minor syntax tweak, check output file before write and close

Diffstat:
M1d_fd_simple_shear.c | 3+--
Msimulation.c | 10+++++++---
2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/1d_fd_simple_shear.c b/1d_fd_simple_shear.c @@ -263,10 +263,9 @@ main(int argc, char* argv[]) stressiter = 0; do { - if (sim.fluid) { + if (sim.fluid) if (darcy_solver_1d(MAX_ITER_DARCY, RTOL_DARCY)) exit(1); - } compute_effective_stress(); compute_friction(); diff --git a/simulation.c b/simulation.c @@ -496,9 +496,13 @@ write_output_file(const int normalize) snprintf(outfile, sizeof(outfile), "%s.output%05d.txt", sim.name, sim.n_file++); - fp = fopen(outfile, "w"); - print_output(fp, normalize); - fclose(fp); + if ((fp = fopen(outfile, "w")) != NULL) { + print_output(fp, normalize); + fclose(fp); + } else { + dprintf(2, "could not open output file: %s", outfile); + exit(1); + } } void