Commit 633a4a2b authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Enable parsing of --version option

parent 3e4f0a26
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -88,12 +88,22 @@ int main(int argc, char **argv) {
  string config_file = "../../test_data/cluster/DEDFB";
  string data_file = "../../test_data/cluster/DCLU";
  string output_path = ".";
  if (argc != 2) {
    if (argc == 4) {
      config_file = string(argv[1]);
      data_file = string(argv[2]);
      output_path = string(argv[3]);
    }
    cluster(config_file, data_file, output_path, mpidata);
  } else { // argc == 2
    string arg = argv[1];
    if (arg.compare("--version") == 0) {
      printf("np_cluster v%s.\n", NPTM_VERSION);
    } else {
      printf("ERROR: unrecognized argument \"%s\".\n", argv[1]);
      ierr = 1;
    }
  }
#ifdef MPI_VERSION
  MPI_Finalize();
#endif
+15 −5
Original line number Diff line number Diff line
@@ -85,12 +85,22 @@ int main(int argc, char **argv) {
  string config_file = "../../test_data/inclusion/DEDFB";
  string data_file = "../../test_data/inclusion/DINCLU";
  string output_path = ".";
  if (argc != 2) {
    if (argc == 4) {
      config_file = string(argv[1]);
      data_file = string(argv[2]);
      output_path = string(argv[3]);
    }
    inclusion(config_file, data_file, output_path, mpidata);
  } else { // argc == 2
    string arg = argv[1];
    if (arg.compare("--version") == 0) {
      printf("np_inclusion v%s.\n", NPTM_VERSION);
    } else {
      printf("ERROR: unrecognized argument \"%s\".\n", argv[1]);
      ierr = 1;
    }
  }
#ifdef MPI_VERSION
  MPI_Finalize();
#endif
+13 −2
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ import pdb
import random
import yaml

## \cond
__version__ = "0.10.9"
## \endcond

## \brief 3D software generation capability flag.
allow_3d = True
try:
@@ -51,7 +55,10 @@ from sys import argv
def main():
    result = 0
    config = parse_arguments()
    if (config['help_mode'] or config['yml_file_name'] == ""):
    if config['version_mode']:
        print("model_maker.py v%s."%__version__)
        exit(0)
    elif (config['help_mode'] or config['yml_file_name'] == ""):
        print_help()
    else:
        sconf, gconf = load_model(config['yml_file_name'])
@@ -610,11 +617,14 @@ def parse_arguments():
    config = {
        'yml_file_name': "",
        'help_mode': False,
        'version_mode': False
    }
    yml_set = False
    for arg in argv[1:]:
        if (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        elif (not yml_set):
            if (not arg.startswith("--")):
                config['yml_file_name'] = arg
@@ -627,7 +637,7 @@ def parse_arguments():
def print_help():
    print("###############################################           ")
    print("#                                             #           ")
    print("#           NPtm_code MODEL_MAKER             #           ")
    print("#           NPTM_code MODEL_MAKER             #           ")
    print("#                                             #           ")
    print("###############################################           ")
    print("                                                          ")
@@ -639,6 +649,7 @@ def print_help():
    print("                                                          ")
    print("Valid options are:                                        ")
    print("--help                Print this help and exit.           ")
    print("--version             Print script version and exit.      ")
    print("                                                          ")

## \brief Print a summary of model properties.
+8 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ from math import log10
from sys import argv

## \cond
__version__ = "0.10.9"
number_reg = re.compile(r'-?[0-9]\.[0-9]+E?[-+][0-9]{2,5}')
## \endcond

@@ -62,6 +63,9 @@ def main():
    if config['help_mode'] or len(argv) == 1:
        config['help_mode'] = True
        print_help()
    elif config['version_mode']:
        print("pycompare.py v%s."%__version__)
        exit(0)
    else:
        compare_log = compare_files(config)
        errors = compare_log['errors']
@@ -498,6 +502,7 @@ def parse_arguments():
        'log_html': False,
        'log_level': 1, # ERR = 0, WARN = 1, NOISE = 2, FULL = 3
        'say_progress': True,
        'version_mode': False,
        'warning_threshold': 0.005,
    }
    arg_index = 1
@@ -545,6 +550,8 @@ def parse_arguments():
            config['say_progress'] = False
        elif (arg.startswith("--quick")):
            config['check_all'] = False
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        elif (arg.startswith("--warn")):
            config['warning_threshold'] = float(split_arg[1])
        else:
@@ -573,6 +580,7 @@ def print_help():
    print("                          warning level, ERR prints only error mismatches (default is WARN).")
    print("--no-progress             Disable progress logging.")
    print("--quick                   Stop on first mismatch (default is to perform a full check).")
    print("--version                 Print script version and exit.      ")
    print("--warn                    Set a fractional threshold for numeric warning (default = 0.005).")
    print("                                            ")

+15 −5
Original line number Diff line number Diff line
@@ -85,12 +85,22 @@ int main(int argc, char **argv) {
  string config_file = "../../test_data/sphere/DEDFB";
  string data_file = "../../test_data/sphere/DSPH";
  string output_path = ".";
  if (argc != 2) {
    if (argc == 4) {
      config_file = string(argv[1]);
      data_file = string(argv[2]);
      output_path = string(argv[3]);
    }
    sphere(config_file, data_file, output_path, mpidata);
  } else { // argc == 2
    string arg = argv[1];
    if (arg.compare("--version") == 0) {
      printf("np_sphere v%s.\n", NPTM_VERSION);
    } else {
      printf("ERROR: unrecognized argument \"%s\".\n", argv[1]);
      ierr = 1;
    }
  }
#ifdef MPI_VERSION
  MPI_Finalize();
#endif
Loading