tMinor syntax tweak, check output file before write and close - cngf-pf - continuum model for granular flows with pore-pressure dynamics (renamed from 1d_fd_simple_shear)
(HTM) git clone git://src.adamsgaard.dk/cngf-pf
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit de519ac795f069865beefb13be55713b3413382e
(DIR) parent 7df64da83d8dbe2582f1db38a6bac9bff131dfe8
(HTM) 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:
M 1d_fd_simple_shear.c | 3 +--
M simulation.c | 10 +++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/1d_fd_simple_shear.c b/1d_fd_simple_shear.c
t@@ -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();
(DIR) diff --git a/simulation.c b/simulation.c
t@@ -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