oblique_mc

Monte Carlo in Single Layer Biological Tissue
git clone anongit@rnpnr.xyz:oblique_mc.git
Log | Files | Refs | Feed | README | LICENSE

Commit: e61932fff7f8f64383ef88e70006a399f64409c1
Parent: 74d39ebcf070926907c079a18022d1a7aef8a72b
Author: Randy Palamar
Date:   Fri, 12 Apr 2024 15:07:34 -0600

allow output prefix to be specified in config.h

Diffstat:
Mconfig.def.h | 4++++
Mmc.c | 10++++++----
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,5 +1,9 @@ /* global data that will not be modified at runtime */ +/* optional prefix to append to output files. if specified + * as {} a prefix must be specified on command line */ +static s8 g_output_prefix = s8("out/ex"); + /* simulation output extent [cm] */ static Rect g_extent = { .top = 1.5, diff --git a/mc.c b/mc.c @@ -554,9 +554,11 @@ print_progress(time_t start) int main(int argc, char *argv[]) { - if (argc != 2) - die("usage: %s output_prefix\n", argv[0]); - s8 pre = (s8){.data = (u8 *)argv[1], .len = c_str_len(argv[1])}; + if (argv[1]) + g_output_prefix = (s8){(u8 *)argv[1], c_str_len(argv[1])}; + if (g_output_prefix.len == 0) + die("usage: %s [output_prefix]\n", argv[0]); + /* TODO: check if prefix contains directories and ensure they exist */ init(); @@ -609,7 +611,7 @@ main(int argc, char *argv[]) pthread_mutex_destroy(&completed_photons.lock); - dump_output(pre, Rd_xy_out); + dump_output(g_output_prefix, Rd_xy_out); return 0; }