tgranular: support and document simulation naming - granular - granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/granular
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 05b91832152f7b9b8a44ecfe460b965eb864cac6
 (DIR) parent 355386ab0005d3ba09358f192fc20e04a14a7b5c
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Thu, 25 Mar 2021 22:38:24 +0100
       
       granular: support and document simulation naming
       
       Diffstat:
         M granular.1                          |       9 +++++++++
         M granular.c                          |       5 +++++
       
       2 files changed, 14 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/granular.1 b/granular.1
       t@@ -19,6 +19,15 @@ reads
        .Xr granular 5
        data with grain properties from stdin, simulates granular interaction
        over time, and prints the resultant state.
       +If
       +.Ar name
       +is set, the simulation state is written to files in
       +.Xr granular 5
       +format in the current directory.
       +The files are named
       +.Pa <name>.outputDDDDD.txt ,
       +where DDDDD is an integer counter starting from 00000, and incrementing
       +by 1 for each new file.
        .Pp
        The options are as wollows:
        .Bl -tag -width Ds
 (DIR) diff --git a/granular.c b/granular.c
       t@@ -53,6 +53,11 @@ main(int argc, char *argv[])
                        usage();
                } ARGEND;
        
       +        if (argc == 1 && argv[0])
       +                snprintf(sim.name, sizeof(sim.name), "%s", argv[0]);
       +        else if (argc > 1)
       +                usage();
       +
                sim_read_grains(&sim, stdin);
                if (sim.t < sim.t_end)
                        sim_run_time_loop(&sim);