the main driver
()
| 237 | |
| 238 | |
| 239 | def main(): |
| 240 | """the main driver""" |
| 241 | |
| 242 | # note: you need to put a space at the start of the string |
| 243 | # that gives defines so that the '-' is not interpreted as |
| 244 | # an option itself |
| 245 | # https://stackoverflow.com/questions/16174992/cant-get-argparse-to-read-quoted-string-with-dashes-in-it |
| 246 | |
| 247 | parser = argparse.ArgumentParser() |
| 248 | parser.add_argument("--odir", type=str, default="", |
| 249 | help="output directory") |
| 250 | parser.add_argument("--defines", type=str, default="", |
| 251 | help="preprocessor defines to interpret") |
| 252 | parser.add_argument("--nadv", type=int, default=0, |
| 253 | help="the number of pure advected quantities") |
| 254 | parser.add_argument("variables_file", type=str, nargs=1, |
| 255 | help="input variable definition file") |
| 256 | |
| 257 | args = parser.parse_args() |
| 258 | |
| 259 | if args.odir != "" and not os.path.isdir(args.odir): |
| 260 | try: |
| 261 | os.makedirs(args.odir) |
| 262 | except FileExistsError: |
| 263 | # this exception is needed in case of a race condition |
| 264 | # to create the directory by another make target |
| 265 | pass |
| 266 | |
| 267 | doit(args.variables_file[0], args.odir, args.defines, args.nadv) |
| 268 | |
| 269 | |
| 270 | if __name__ == "__main__": |