Skip to content

Commit

Permalink
small patch to improve the way command line arguments are read in so …
Browse files Browse the repository at this point in the history
…all arguments work even when the -m argument is given after the particle or lookup counts
  • Loading branch information
jtramm committed Sep 18, 2018
1 parent e93d769 commit 4ed30ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# User Options
#===============================================================================

COMPILER = gnu
COMPILER = intel
OPTIMIZE = yes
DEBUG = no
PROFILE = no
Expand Down
16 changes: 14 additions & 2 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ Input read_CLI( int argc, char * argv[] )
// defaults to no temperature dependence (Doppler broadening)
input.doppler = 1;

int default_lookups = 1;
int default_particles = 1;

// Collect Raw Input
for( int i = 1; i < argc; i++ )
{
Expand Down Expand Up @@ -114,8 +117,11 @@ Input read_CLI( int argc, char * argv[] )
{
input.simulation_method = EVENT_BASED;
// Also resets default # of lookups
input.lookups = input.lookups * input.particles;
input.particles = 0;
if( default_lookups && default_particles )
{
input.lookups = input.lookups * input.particles;
input.particles = 0;
}
}
else
print_CLI_error();
Expand All @@ -124,15 +130,21 @@ Input read_CLI( int argc, char * argv[] )
else if( strcmp(arg, "-l") == 0 )
{
if( ++i < argc )
{
input.lookups = atoi(argv[i]);
default_lookups = 0;
}
else
print_CLI_error();
}
// particles (-p)
else if( strcmp(arg, "-p") == 0 )
{
if( ++i < argc )
{
input.particles = atoi(argv[i]);
default_particles = 0;
}
else
print_CLI_error();
}
Expand Down

0 comments on commit 4ed30ba

Please sign in to comment.