def save(source_path, options): """ Save a directory or file by overwriting and pushing to git. Only allows saving to a top-level directory or file. """ util.check_git() ssh_url = "[email protected]:%s/%s.git" % (options.github, Const.REPO_NAME) repo_url = "https://github.com/%s/%s.git" % (options.github, Const.REPO_NAME) tmp_repo = os.path.expanduser("~/%s" % Const.TMP_GIT_DIR) basename = options.outfile or os.path.basename(util.sanitize_path(source_path)) path_in_repo = os.path.join(tmp_repo, basename) if not os.path.exists(source_path): util.exit_runtime_error("There doesn't seem to be a file or directory at %s" % source_path) if os.path.isdir(tmp_repo): # TODO - Add a local repository to be optimized, git reset hard head # Currently, it deletes the repository each time shutil.rmtree(tmp_repo) # Remove the old repo to be completely to be safe # Clone the repo util.info("Cloning the git repository...") util.info("Trying to clone via SSH first.") if not util.exec_cmd_status("git clone %s %s" % (ssh_url, tmp_repo)): util.info("Couldn't clone via SSH, trying https://...") util.info("Since we're not using SSH," + "Github will prompt for your username and password.") util.info("We don't store it!") (status, output) = util.exec_cmd_output("git clone %s %s" % (repo_url, tmp_repo)) if not status: util.exit_runtime_error("Failed to clone git repository: %s" % output) # Move target file / directory over try: if os.path.isfile(source_path): shutil.copy2(source_path, path_in_repo) elif os.path.isdir(source_path): # shutil.copytree doesn't overwrite an existing directory if os.path.isdir(path_in_repo): shutil.rmtree(path_in_repo) shutil.copytree(source_path, os.path.join(tmp_repo, basename)) except IOError, e: util.exit_runtime_error( "Error while trying to move contents to the git repository: %s" % e)
def set_dirs(PATHS): MOVEEXEC = True PATHS['BUILD'] = 'SRC' PATHS['PROB'] = os.getcwd() for n in range(len(sys.argv)): if sys.argv[n] == '-dir' and n < len(sys.argv) - 1: MOVEEXEC = False PATHS['BUILD'] = util.sanitize_path(sys.argv[n+1]) PATHS['SRC'] = os.path.join(PATHS['BUILD'], 'source','') for key in list(PATHS): if PATHS[key][0] != '/': PATHS[key] = os.path.join(PATHS['PROB'], PATHS[key], '') util.make_dir(PATHS[key]) return MOVEEXEC
def build(PROBLEM, PATHS): print("") print("********************************************************************************") print("") print(" BHLIGHT BUILD SCRIPT") print("") print(" OPTIONS:") print(" -help (print this message and exit)") print(" -debug (use debug compile params)") print(" -force (do not abort upon compile-time warnings/errors)") print(" -noclean (do not delete old source files)") print(" -noparam (do not create new parameter file)") print(" -dir /path/to/target (create target dir and build there)") print("") print("********************************************************************************") print("") if is_user_help(): sys.exit() # PROCESS USER INPUT DEBUG = is_user_debug() FORCE = is_user_force() MOVEEXEC = set_dirs(PATHS) NOPARAM = is_user_noparam() NOCLEAN = is_user_noclean() CLEAN = not NOCLEAN WRITE_PARAM = not NOPARAM KEEP_SRC = '-src' in sys.argv REMOVE_SRC = not KEEP_SRC # get version VERSION = get_version() # PRINT TO TERMINAL AND LOGFILE LOGFILE = os.path.join(PATHS['BUILD'], 'log_build') util.log_output(sys, LOGFILE) # SEARCH FOR MACHINE host = get_host(PATHS) if DEBUG and 'DEBUG_FLAGS' not in host.keys(): util.warn("Debug compiler options not set! Using normal compiler flags.") host['DEBUG_FLAGS'] = host['COMPILER_FLAGS'] C_FLAGS = '-std=c99 ' if 'MEM_MODEL' in host: C_FLAGS += "-mcmodel=" + host['MEM_MODEL'] + ' ' else: C_FLAGS += "-mcmodel=medium " if DEBUG: C_FLAGS += host['DEBUG_FLAGS'] else: C_FLAGS += host['COMPILER_FLAGS'] # MATH AND DYNAMIC LINKING LIB_FLAGS = '-lm -ldl' LIBRARIES = '' INCLUDES = '' # GSL if 'GSL_DIR' not in host: host['GSL_DIR'] = '' host['GSL_DIR'] = util.sanitize_path(host['GSL_DIR']) LIB_FLAGS += (' -lgsl -lgslcblas' + ' -Wl,-rpath=' + host['GSL_DIR'] + 'lib/') LIBRARIES += '-L' + host['GSL_DIR'] + 'lib/' INCLUDES += '-I' + host['GSL_DIR'] + 'include/' # MPI if 'MPI_DIR' in host: host['MPI_DIR'] = util.sanitize_path(host['MPI_DIR']) LIB_FLAGS += (' -Wl,-rpath=' + host['MPI_DIR'] + 'lib/') LIBRARIES += ' -L' + host['MPI_DIR'] + 'lib/' INCLUDES += ' -I' + host['MPI_DIR'] + 'include/' # HDF5 if 'HDF5_DIR' in host: host['HDF5_DIR'] = util.sanitize_path(host['HDF5_DIR']) LIB_FLAGS += (' -lhdf5_hl -lhdf5' +' -Wl,-rpath=' + host['HDF5_DIR'] + 'lib/') LIBRARIES += ' -L' + host['HDF5_DIR'] + 'lib/' INCLUDES += ' -I' + host['HDF5_DIR'] + 'include/' print(" CONFIGURATION\n") set_cparm("VERSION", '"{}"'.format(VERSION)) print_config("VERSION", VERSION) print_config("MACHINE", host['NAME']) print_config("PROBLEM", PROBLEM) print_config("BUILD DIR", PATHS['BUILD']) print_config("COMPILER", host['COMPILER']) print_config("GSL_DIR", host['GSL_DIR']) if 'MPI_DIR' in host: print_config("MPI_DIR", host['MPI_DIR']) if 'HDF5_DIR' in host: print_config("HDF5_DIR", host['HDF5_DIR']) if 'EXECUTABLE' in host: print_config("EXECUTABLE", host['EXECUTABLE']) if 'MPI_EXECUTABLE' in host: print_config("MPI_EXECUTABLE", host['MPI_EXECUTABLE']) print_config("C_FLAGS", C_FLAGS) print_config("LIB_FLAGS", LIB_FLAGS) print_config("LIBRARIES", LIBRARIES) print_config("INCLUDES", INCLUDES) print_config("OPENMP", CPARMS['OPENMP']) print("\n COMPILE-TIME PARAMETERS\n") print_config("N1TOT", CPARMS['N1TOT']) print_config("N2TOT", CPARMS['N2TOT']) print_config("N3TOT", CPARMS['N3TOT']) print_config("N1CPU", CPARMS['N1CPU']) print_config("N2CPU", CPARMS['N2CPU']) print_config("N3CPU", CPARMS['N3CPU']) print_config("METRIC", CPARMS['METRIC']) print_config("RECONSTRUCTION", CPARMS['RECONSTRUCTION']) if util.parm_is_active(CPARMS, 'EOS'): print_config("EOS", CPARMS['EOS']) else: set_cparm("EOS", 'EOS_TYPE_GAMMA') if util.parm_is_active(CPARMS, 'RADIATION'): print_config("RADIATION", CPARMS['RADIATION']) if util.parm_is_active(CPARMS, 'NU_BINS'): print_config('NU_BINS', CPARMS['NU_BINS']) else: set_cparm("NU_BINS", 200) if util.parm_is_active(CPARMS, 'NTH'): print_config("NTH", CPARMS["NTH"]) else: set_cparm("NTH", 8) if util.parm_is_active(CPARMS, 'NPHI'): print_config("NPHI", CPARMS["NPHI"]) else: set_cparm("NPHI", 8) if util.parm_is_active(CPARMS, "NU_BINS_SPEC"): print_config("NU_BINS_SPEC", CPARMS["NU_BINS_SPEC"]) else: set_cparm("NU_BINS_SPEC", 200) if util.parm_is_active(CPARMS, "BURROWS_OPACITIES"): print_config("BURROWS_OPACITIES", CPARMS["BURROWS_OPACITIES"]) else: set_cparm("BURROWS_OPACITIES", 0) if util.parm_is_active(CPARMS, "HDF5_OPACITIES"): print_config("HDF5_OPACITIES", CPARMS["HDF5_OPACITIES"]) else: set_cparm("HDF5_OPACITIES", 0) else: set_cparm("RADIATION", 0) if util.parm_is_active(CPARMS, 'ELECTRONS'): print_config("ELECTRONS", CPARMS['ELECTRONS']) else: set_cparm("ELECTRONS", 0) if util.parm_is_active(CPARMS,'NVAR_PASSIVE'): print_config("NVAR_PASSIVE", CPARMS["NVAR_PASSIVE"]) else: set_cparm("NVAR_PASSIVE", 0) if util.parm_is_active(CPARMS, 'GAMMA_FALLBACK'): print_config('GAMMA_FALLBACK', CPARMS['GAMMA_FALLBACK']) else: set_cparm('GAMMA_FALLBACK', 0) if util.parm_is_active(CPARMS, 'EXIT_ON_INIT'): print_config('EXIT_ON_INIT', CPARMS['EXIT_ON_INIT']) else: set_cparm('EXIT_ON_INIT', 0) if util.parm_is_active(CPARMS, 'OUTPUT_EOSVARS'): print_config("OUTPUT_EOSVARS", CPARMS["OUTPUT_EOSVARS"]) else: set_cparm("OUTPUT_EOSVARS", 0) if CPARMS['RADIATION']: if 'EXPTAU_WEIGHTS' in CPARMS.keys(): print_config('EXPTAU_WEIGHTS', CPARMS['EXPTAU_WEIGHTS']) else: set_cparm('EXPTAU_WEIGHTS', 1) if util.parm_is_active(CPARMS,'ELECTRONS')\ and CPARMS['EOS'] != 'EOS_TYPE_GAMMA': raise ValueError("ELECTRONS only compatible with Gamma law EOS.\n" +"Please set EOS = EOS_TYPE_GAMMA.\n") if CPARMS['EOS'] == 'EOS_TYPE_TABLE' and CPARMS['NVAR_PASSIVE'] < 2: raise ValueError("Tabulated EOS requires at least two passive scalars\n" +"for the electron fraction Ye.\n" +"Please set NVAR_PASSIVE >= 2\n" +"and ensure your problem generator sets it appropriately.\n") if CPARMS['EOS'] == 'EOS_TYPE_TABLE' \ and CPARMS['METRIC'] == 'MKS' \ and CPARMS['NVAR_PASSIVE'] < 3: raise ValueError("Tabulated EOS and MKS metric requires at least three\n" +"passive scalars, for Ye and atmosphere markers.\n" +"Please set NVAR_PASSIVE >= 3\n" +"and ensure your problem generator sets it appropriately.\n") if util.parm_is_active(CPARMS,'ESTIMATE_THETAE') \ and (CPARMS['RADIATION'] == 'RADTYPE_NEUTRINOS'): raise ValueError("Neutrinos not compatible " +"with estimating electron temperature.") if CPARMS['EOS'] == 'EOS_TYPE_POLYTROPE': util.gentle_warn("The polytropic EOS is totally untested. " +"Use at your own risk!\n") if CPARMS['EOS'] != 'EOS_TYPE_GAMMA' and not CPARMS['OUTPUT_EOSVARS']: util.gentle_warn("Setting OUTPUT_EOSVARS = True.") set_cparm("OUTPUT_EOSVARS", 1) print_config("OUTPUT_EOSVARS", CPARMS["OUTPUT_EOSVARS"]) NEED_UNITS = (util.parm_is_active(CPARMS, 'RADIATION') or util.parm_is_active(CPARMS, 'COULOMB') or CPARMS['EOS'] == 'EOS_TYPE_TABLE') if util.parm_is_active(CPARMS, 'FLATEMISS'): if not util.parm_is_active(CPARMS, 'EMISSTYPE_FLAT'): util.gentle_warn("Flatemiss active, but not emission type.\n" +"Setting EMISSTYPE_FLAT = ANTINU_ELECTRON.\n") set_cparm("EMISSTYPE_FLAT", "ANTINU_ELECTRON") if util.parm_is_active(CPARMS, 'RADIATION') \ and 'X1R_RAD_BOUND' in CPARMS.keys(): if CPARMS['X1R_RAD_BOUND'] == 'BC_CAMERA' \ and CPARMS['METRIC'] == 'MINKOWSKI': util.warn("X1R_RAD_BOUND BC_CAMERA is " +"not supported for Minkowski metrics.") print("\n EXTRA PARAMETERS\n") for k,v in REPVARS.items(): print_config(k,v) # Set core runtime parameters set_rparm('tf', 'double') set_rparm('dt', 'double') if CPARMS['METRIC'] == 'MINKOWSKI': set_rparm('x1Min', 'double', default = 0.) set_rparm('x1Max', 'double', default = 1.) set_rparm('x2Min', 'double', default = 0.) set_rparm('x2Max', 'double', default = 1.) set_rparm('x3Min', 'double', default = 0.) set_rparm('x3Max', 'double', default = 1.) if CPARMS['METRIC'] == 'MKS': set_rparm('a', 'double', default = 0.5) set_rparm('hslope', 'double', default = 0.3) set_rparm('poly_xt', 'double', default = 0.82) set_rparm('poly_alpha', 'double', default = 14.) set_rparm('mks_smooth', 'double', default = 0.5) set_rparm('Rout', 'double', default = 40.) set_rparm('Rout_vis', 'double', default = 40.) #if util.parm_is_active(CPARMS, 'RADIATION'): # set_rparm('Rout_rad', 'double') if NEED_UNITS: if CPARMS['METRIC'] == 'MINKOWSKI': set_rparm('L_unit', 'double') set_rparm('M_unit', 'double') if CPARMS['METRIC'] == 'MKS': set_rparm('M_unit', 'double') set_rparm('mbh', 'double', default = 1.989e34) if CPARMS['EOS'] == 'EOS_TYPE_GAMMA': set_rparm('gam', 'double', default = 5./3.) set_rparm('cour', 'double', default = 0.9) if util.parm_is_active(CPARMS, 'RADIATION'): set_rparm('cour_cool', 'double', default = 0.25) if util.parm_is_active(CPARMS, 'ELECTRONS'): set_rparm('game', 'double', default = 4./3.) set_rparm('gamp', 'double', default = 5./3.) set_rparm('fel0', 'double', default = 0.01) set_rparm('tptemin', 'double', default = 1.e-3) set_rparm('tptemax', 'double', default = 1.e3) if util.parm_is_active(CPARMS, 'RADIATION'): if not util.parm_is_active(CPARMS, 'ELECTRONS'): set_rparm('tp_over_te', 'double', default = 1.) set_rparm('nph_per_proc', 'double', default = 1.e5) set_rparm('numin', 'double', default = 1.e8) set_rparm('numax', 'double', default = 1.e20) set_rparm('tune_emiss', 'double', default = 1.) set_rparm('tune_scatt', 'double', default = 1.) set_rparm('t0_tune_emiss', 'double', default = -1.) set_rparm('t0_tune_scatt', 'double', default = -1.) set_rparm('thetae_max', 'double', default = 1.e3) set_rparm('sigma_max', 'double', default = 1.) set_rparm('kdotk_tol', 'double', default = 1.e-6) set_rparm('Nph_to_track', 'double', default = 0.); set_rparm('thbin', 'int', default = 8); set_rparm('phibin', 'int', default = 8); if util.parm_is_active(CPARMS, 'FLATEMISS'): set_rparm('cnu_flat', 'double', default = 1.) set_rparm('init_from_grmhd', 'string', default = 'No') set_rparm('DTd', 'double', default = 0.5) set_rparm('DTl', 'double', default = 0.1) set_rparm('DTr', 'double', default = 1000.) set_rparm('DNr', 'integer', default = 1024) set_rparm('DTp', 'integer', default = 100) set_rparm('DTf', 'integer', default = 1) set_rparm('outputdir', 'string', default = './') # some fixes for fortran compilation USE_FORTRAN = util.parm_is_active(CPARMS,'BURROWS_OPACITIES') FORT_USE_MPI = (CPARMS['N1CPU'] > 1 or CPARMS['N2CPU'] > 1 or CPARMS['N3CPU'] > 1) FORT_USE_MPI_STR = 'TRUE' if FORT_USE_MPI else 'FALSE' if CPARMS['N1TOT'] > 1 and CPARMS['N2TOT'] > 1 and CPARMS['N2TOT'] > 1: FORT_NDIM=3 elif ((CPARMS['N1TOT'] > 1 and CPARMS['N2TOT'] > 1) or (CPARMS['N1TOT'] > 1 and CPARMS['N3TOT'] > 1) or (CPARMS['N2TOT'] > 1 and CPARMS['N3TOT'] > 1)): FORT_NDIM=2 else: FORT_NDIM=1 if USE_FORTRAN: # -lgfortran for gcc -lifcore -limf for icc LIB_FLAGS += ' ' + host['FORTLINK'] if len(host['FORTLIB']) > 0: LIBRARIES += ' -L' + host['FORTLIB'] if DEBUG: if 'FDEBUG_FLAGS' not in host.keys(): util.warn("Fortran debug options not set! Using normal fortran flags.") host['FDEBUG_FLAGS'] = host['FCFLAGS'] FCFLAGS = host['FDEBUG_FLAGS'] else: FCFLAGS = host['FCFLAGS'] FCFLAGS += (' -DUSE_MPI=' + FORT_USE_MPI_STR + ' -DNDIM=' + str(FORT_NDIM)) # GET ALL SOURCE FILES SRC_CORE = util.get_files(PATHS['CORE'], '*.c') INC_CORE = util.get_files(PATHS['CORE'], '*.h') if USE_FORTRAN: F90_CORE = util.get_files(PATHS['CORE'], '*.f90') else: F90_CORE = [] SRC_PROB = util.get_files(PATHS['PROB'], '*.c') INC_PROB = util.get_files(PATHS['PROB'], '*.h') # Clean if necessary if CLEAN: util.make_clean(PATHS['SRC']) # COPY SOURCE FILES TO BUILD_DIR for src in SRC_CORE: call(['cp', src, PATHS['SRC'] + src.rsplit('/',1)[1]]) for inc in INC_CORE: call(['cp', inc, PATHS['SRC'] + inc.rsplit('/',1)[1]]) if USE_FORTRAN: for src in F90_CORE: call(['cp', src, PATHS['SRC'] + src.rsplit('/',1)[1]]) for src in SRC_PROB: call(['cp', src, PATHS['SRC'] + src.rsplit('/',1)[1]]) for inc in INC_PROB: call(['cp', inc, PATHS['SRC'] + inc.rsplit('/',1)[1]]) # WRITE PARAMETERS FILE pf = open(PATHS['SRC'] + 'params.h', 'w') for KEY in CPARMS: if isinstance(CPARMS[KEY], str): pf.write("#define " + KEY + " (" + CPARMS[KEY] + ")\n") else: # True/False autocast to 1/0. pf.write("#define " + KEY + " (%g)\n" % CPARMS[KEY]) pf.close() # GET SINGLE LISTS OF ALL SOURCE, OBJECT, AND HEADER FILES SRC_ALL = util.get_files(PATHS['SRC'], '*.c') INC_ALL = util.get_files(PATHS['SRC'], '*.h') SRC = '' OBJ = '' INC = '' for n in range(len(SRC_ALL)): SRC += '%s ' % os.path.basename(SRC_ALL[n]) OBJ += '%s.o ' % os.path.basename(SRC_ALL[n])[:-2] for n in range(len(INC_ALL)): INC += '%s ' % os.path.basename(INC_ALL[n]) if USE_FORTRAN: F90 = '' FOBJ = '' for src in F90_CORE: F90 += '%s ' % os.path.basename(src) FOBJ += '%s.o ' % os.path.basename(src)[:-4] # WRITE MAKEFILE os.chdir(PATHS['SRC']) mf = open('makefile', 'w') mf.write('CC = ' + host['COMPILER'] + '\n') if USE_FORTRAN: mf.write('F90 = ' + host['FORTRAN_COMP'] + '\n') mf.write('CCFLAGS = ' + C_FLAGS + ' ' + LIBRARIES + ' ' + INCLUDES + '\n') if USE_FORTRAN: mf.write('FCFLAGS = ' + FCFLAGS + '\n') mf.write('LIB_FLAGS = ' + LIB_FLAGS + '\n') mf.write('CC_COMPILE = $(CC) $(CCFLAGS) -c' + '\n') mf.write('CC_LOAD = $(CC) $(CCFLAGS)' + '\n') if USE_FORTRAN: mf.write('FSRC = ' + F90 + '\n') mf.write('FOBJ = ' + FOBJ + '\n') else: mf.write('FSRC = \n') mf.write('FOBJ = \n') mf.write('SRC = ' + SRC + '\n') mf.write('OBJ = ' + OBJ + '\n') mf.write('INC = ' + INC + '\n') mf.write('EXE = bhlight' + '\n') mf.write('.c.o:' + '\n') mf.write('\t$(CC_COMPILE) $*.c' + '\n') if USE_FORTRAN: mf.write('%.o: %.f90 makefile' + '\n') mf.write('\t$(F90) $(FCFLAGS) -c $<\n') mf.write('all: $(EXE)' + '\n') mf.write('$(OBJ): $(INC) makefile' + '\n') mf.write('$(EXE): $(OBJ) $(FOBJ) $(INC) makefile' + '\n') mf.write('\t$(CC_LOAD) $(OBJ) $(FOBJ) $(LIB_FLAGS) -o $(EXE)\n') mf.write('clean:\n') mf.write('\t$(RM) $(SRC) $(FSRC) $(OBJ) $(FOBJ) $(EXE) $(INC)\n') mf.close() print("\n COMPILING SOURCE\n") ncomp = 0 first_error = 1 if DEBUG: popen = subprocess.Popen(['make'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) else: popen = subprocess.Popen(['make','-j','10'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) for stdout_line in iter(popen.stdout.readline, ""): if stdout_line.rstrip()[-2:] == '.c' or stdout_line.rstrip()[-4:] == '.f90': print(" [" + util.color.BOLD + util.color.BLUE + "%2d%%" % (100.*float(ncomp)/len(SRC_ALL+F90_CORE)) + util.color.NORMAL + "] " + util.color.BOLD + stdout_line.rsplit(' -c ',1)[1].rstrip().lstrip().split('/')[-1] + util.color.NORMAL) ncomp += 1 for stderr_line in iter(popen.stderr.readline, ""): # THIS ALSO FAILS FOR WARNINGS!!! if first_error == 1: util.warn("COMPILER ERROR") first_error = 0 print(stderr_line.rstrip()) if first_error != 1 and not FORCE: util.warn("COMPILATION FAILED") sys.exit() obj_files = util.get_files(PATHS['SRC'], '*.o') for f in obj_files: os.remove(f) os.rename(PATHS['SRC'] + 'bhlight', PATHS['BUILD'] + 'bhlight') if REMOVE_SRC: import shutil shutil.rmtree(PATHS['SRC']) print("\n BUILD SUCCESSFUL") # CREATE RUNTIME PARAMETERS FILE PARAMFILE = PATHS['BUILD'] + PARAM_NAME if WRITE_PARAM: with open(PARAMFILE, 'w') as pf: pf.write("### RUNTIME PARAMETERS ###\n") pf.write("\n# COORDINATES\n") write_rparm(pf, 'tf') write_rparm(pf, 'dt') if CPARMS['METRIC'] == 'MINKOWSKI': write_rparm(pf, 'x1Min') write_rparm(pf, 'x1Max') write_rparm(pf, 'x2Min') write_rparm(pf, 'x2Max') write_rparm(pf, 'x3Min') write_rparm(pf, 'x3Max') if CPARMS['METRIC'] == 'MKS': write_rparm(pf, 'Rout') if util.parm_is_active(CPARMS, 'RADIATION'): write_rparm(pf, 'Rout_rad') if NEED_UNITS: pf.write("\n# UNITS\n") if CPARMS['METRIC'] == 'MINKOWSKI': write_rparm(pf, 'L_unit') write_rparm(pf, 'M_unit') if CPARMS['METRIC'] == 'MKS': write_rparm(pf, 'mbh') write_rparm(pf, 'M_unit') pf.write("\n# FLUID\n") write_rparm(pf, 'cour') if util.parm_is_active(CPARMS, 'RADIATION'): write_rparm(pf, 'cour_cool') if CPARMS['EOS'] == 'EOS_TYPE_GAMMA': write_rparm(pf, 'gam') if CPARMS['EOS'] == 'EOS_TYPE_TABLE': write_rparm(pf, 'eospath') if util.parm_is_active(CPARMS, 'ELECTRONS'): pf.write("\n# ELECTRONS\n") write_rparm(pf, 'game') write_rparm(pf, 'gamp') write_rparm(pf, 'fel0') write_rparm(pf, 'tptemin') write_rparm(pf, 'tptemax') if util.parm_is_active(CPARMS, 'RADIATION'): pf.write("\n# RADIATION\n") if not util.parm_is_active(CPARMS, 'ELECTRONS'): write_rparm(pf, 'tp_over_te') write_rparm(pf, 'nph_per_proc') write_rparm(pf, 'numin') write_rparm(pf, 'numax') write_rparm(pf, 'tune_emiss') write_rparm(pf, 'tune_scatt') write_rparm(pf, 't0_tune_emiss') write_rparm(pf, 't0_tune_scatt') write_rparm(pf, 'thetae_max') write_rparm(pf, 'sigma_max') write_rparm(pf, 'kdotk_tol') write_rparm(pf, 'Nph_to_track') write_rparm(pf, 'thbin') write_rparm(pf, 'phibin') if util.parm_is_active(CPARMS, 'BURROWS_OPACITIES'): write_rparm(pf, 'opac_param_file') write_rparm(pf, 'opac_file') if util.parm_is_active(CPARMS, 'HDF5_OPACITIES'): write_rparm(pf, 'opac_file') write_rparm(pf, 'init_from_grmhd') pf.write("\n# OUTPUT\n") write_rparm(pf, 'DTd') write_rparm(pf, 'DTl') write_rparm(pf, 'DTr') write_rparm(pf, 'DNr') write_rparm(pf, 'DTp') write_rparm(pf, 'DTf') write_rparm(pf, 'outputdir') if len(RPARMS.keys()) > 0: pf.write("\n# PROBLEM\n") prob_keys = RPARMS.keys() for key in list(prob_keys): write_rparm(pf, key) print("\n RUNTIME PARAMETER FILE CREATED") if MOVEEXEC: os.rename(PATHS['BUILD'] + 'bhlight', PATHS['BUILD'] + '../bhlight') if WRITE_PARAM: os.rename(PATHS['BUILD'] + PARAM_NAME, PATHS['BUILD'] + '../' + PARAM_NAME) print("") sys.exit()
help='Index to plot in multi-d quantity') parser.add_argument('--serial', dest='serial', default=False, action='store_true', help='Run in serial') parser.add_argument('--nproc', dest='nproc', default=None, type=int, help=('Number of parallel processe to use. ' + 'If not set, defaults to all available cores.')) args = parser.parse_args() dfold = util.sanitize_path(args.dumpfolder) if not os.path.exists(dfold): print('ERROR Folder ' + dfnam + ' does not exist!') sys.exit() tmpdir = 'FRAMES' util.safe_remove(tmpdir) os.mkdir(tmpdir) dfnams = io.get_dumps_full(dfold) hdr = io.load_hdr(dfnams[0]) geom = io.load_geom(hdr) num_files = len(dfnams) def make_frame(pair):
def main(): """ Parses command line options, then delegates to various other functions. """ usage_str = """ %prog OPTION [FILENAME | dir: DIRECTORY | repo] | Download a file from Github %prog push OPTION [FILEPATH | DIRPATH] | Push a file to Github Examples: `grabrc .emacs` -- Download .emacs from Github. `grabrc dir:.emacs.d --outfile .irssiconfig` - Download the .emacs.d directory from Github. `grabrc repo --destdir=/tmp/` -- Download and untar the repository in /tmp/. `grabrc push /home/user/.vimrc` -- Save ~/.vimrc to Github, overwriting the existing .vimrc. """ parser = OptionParser(usage=usage_str, version="r33") download_group = OptionGroup(parser, "Download: All (files, directories, repositories)") download_group.add_option("-o", "-O", "--name", "--outfile", dest="outfile", action="store", metavar="NAME", help="Rename the downloaded item to NAME.") download_group.add_option("-d", "--destdir", dest="destdir", action="store", metavar="DIR", help="Place the downloaded item in DIR. \ Default: The current directory.") download_group.add_option("--no-backup", dest="nobackup", action="store_true", help="If the file already exists, don't make a backup. \ Default: False. If the item already exists, it will be backed up.") dir_group = OptionGroup(parser, "Download: Repositories") dir_group.add_option("-k", "--keep-tar", dest="tar", action="store_true", help="Download the repository as a tar.gz file. \ Default: Untar the repository.") dir_group.add_option("-z", "--keep-zip", dest="zip", action="store_true", help="Download the repository as a .zip.") filegroup = OptionGroup(parser, "Download: Files") filegroup.add_option("-a", "--append", dest="append", action="store_true", help="If file already exists, append to existing file. \ Default: Back up existing file") filegroup.add_option("-r", "--replace", dest="replace", action="store_true", help="If the file already exists, replace it") filegroup.add_option("-p", "--print", dest="stdout", action="store_true", help="Print the file to the console instead of saving it.") savegroup = OptionGroup(parser, "Upload") savegroup.add_option("-m", "--message", dest="message", help="Specify a commit message for saving a file to Github.") # Validate and parse options, set mode map(parser.add_option_group, [download_group, filegroup, dir_group]) (opts, args) = parser.parse_args() logging.debug("Options and arguments: %s / %s" % (opts, args)) # Simple substitute for logging def usage_exit(level, reason): parser.print_help() print "[%s] %s" % (level.upper(), reason) sys.exit(1) try_msg = "Try either 'grabrc FILE' to download a file from Github \ or 'grabrc push FILEPATH' to upload a file." # Validate options: number of arguments if len(args) > 2 or len(args) == 0: usage_exit("error", "Invalid number of arguments. " + try_msg) # Validate options: either "save" or empty mode = "download" if len(args) == 1: arg = args[0] if arg == "save": usage_exit("error", "Please specify a file to save.") elif arg == "repo": mode = "repo" else: download_name = arg elif "push" in args: mode = "upload" upload_filepath = (n for n in args if n != "push").next() else: usage_exit("error", "Invalid arguments. " + try_msg) # Validate options: invalid combinations if opts.append and opts.replace: util.exit_runtime_error("Both --append and --replace were selected. Please select only one.") if opts.zip and opts.tar: util.exit_runtime_error("Both --keep-zip and --keep-tar were selected. Please select only one.") # Set defaults opts.destdir = opts.destdir or os.getcwd() opts.destdir = util.sanitize_path(opts.destdir) if opts.outfile: opts.outfile = util.sanitize_path(opts.outfile) # Check config file (~/.grabrc) for Github username configpath = "%s/.grabrc" % os.path.expanduser("~") if opts.__dict__.get('github'): github_acc = opts.github # Interactively prompt for username if ~/.grabrc does not exist if not os.path.isfile(configpath): print """\ ======================================================== Welcome! This seems to be your first time starting %s. Please enter your Github username. %s will search for files in the repository named %s""" \ % (Const.PROG_NAME, Const.PROG_NAME, Const.REPO_NAME) github_acc = raw_input('-- Github account: ') cfile = open(configpath, 'w+') cfile.write(github_acc) else: cfile = open(configpath, 'r+') github_acc = cfile.readline().strip() cfile.close() opts.github = github_acc logging.debug("Github account: %s" % github_acc) # Execute actual script DIR_PREFIX = "dir:" if mode == "upload": uploader.save(upload_filepath, opts) elif mode == "download": if download_name.startswith(DIR_PREFIX): downloader.download_subdirectory(download_name[len(DIR_PREFIX):], opts) else: downloader.download_file(download_name, opts) elif mode == "repo": downloader.download_repo_nongit(opts)
def build(PROBLEM, PATHS): print("") print("********************************************************************************") print("") print(" BHLIGHT BUILD SCRIPT") print("") print(" OPTIONS:") print(" -help (print this message and exit)") print(" -debug (use debug compile params)") print(" -force (do not abort upon compile-time warnings/errors)") print(" -noclean (do not delete old source files)") print(" -noparam (do not create new parameter file)") print(" -dir /path/to/target (create target dir and build there)") print("") print("********************************************************************************") print("") if is_user_help(): sys.exit() # PROCESS USER INPUT DEBUG = is_user_debug() FORCE = is_user_force() MOVEEXEC = set_dirs(PATHS) NOPARAM = is_user_noparam() NOCLEAN = is_user_noclean() CLEAN = not NOCLEAN WRITE_PARAM = not NOPARAM # get version VERSION = get_version() # PRINT TO TERMINAL AND LOGFILE LOGFILE = os.path.join(PATHS['BUILD'], 'log_build') util.log_output(sys, LOGFILE) # SEARCH FOR MACHINE machines = util.get_files(PATHS['MACHINE'], '*') for n in range(len(machines)): machines[n] = machines[n].split('/')[-1].replace('.py', '') machine = __import__(machines[n]) if machine.matches_host() == True: break del machine try: machine except NameError: util.warn("HOST " + os.uname()[1] + " UNKNOWN"); sys.exit() host = machine.get_options() if DEBUG and 'DEBUG_FLAGS' not in host.keys(): util.warn("Debug compiler options not set! Using normal compiler flags.") host['DEBUG_FLAGS'] = host['COMPILER_FLAGS'] C_FLAGS = '-std=c99 -mcmodel=medium ' if DEBUG: C_FLAGS += host['DEBUG_FLAGS'] else: C_FLAGS += host['COMPILER_FLAGS'] # MATH AND DYNAMIC LINKING LIB_FLAGS = '-lm -ldl' LIBRARIES = '' INCLUDES = '' # GSL host['GSL_DIR'] = util.sanitize_path(host['GSL_DIR']) LIB_FLAGS += (' -lgsl -lgslcblas' + ' -Wl,-rpath=' + host['GSL_DIR'] + 'lib/') LIBRARIES += '-L' + host['GSL_DIR'] + 'lib/' INCLUDES += '-I' + host['GSL_DIR'] + 'include/' # MPI if 'MPI_DIR' in host: host['MPI_DIR'] = util.sanitize_path(host['MPI_DIR']) LIB_FLAGS += (' -Wl,-rpath=' + host['MPI_DIR'] + 'lib/') LIBRARIES += ' -L' + host['MPI_DIR'] + 'lib/' INCLUDES += ' -I' + host['MPI_DIR'] + 'include/' # HDF5 if 'HDF5_DIR' in host: host['HDF5_DIR'] = util.sanitize_path(host['HDF5_DIR']) LIB_FLAGS += (' -lhdf5_hl -lhdf5' +' -Wl,-rpath=' + host['HDF5_DIR'] + 'lib/') LIBRARIES += ' -L' + host['HDF5_DIR'] + 'lib/' INCLUDES += ' -I' + host['HDF5_DIR'] + 'include/' print(" CONFIGURATION\n") def print_config(key, var): print(" " + util.color.BOLD + "{:<15}".format(key) + util.color.NORMAL + str(var)) set_cparm("VERSION", '"{}"'.format(VERSION)) set_cparm("PROBLEM_NAME", '"{}"'.format(PROBLEM)) print_config("VERSION", VERSION) print_config("MACHINE", host['NAME']) print_config("PROBLEM", PROBLEM) print_config("BUILD DIR", PATHS['BUILD']) print_config("COMPILER", host['COMPILER']) print_config("GSL_DIR", host['GSL_DIR']) if 'MPI_DIR' in host: print_config("MPI_DIR", host['MPI_DIR']) if 'HDF5_DIR' in host: print_config("HDF5_DIR", host['HDF5_DIR']) print_config("EXECUTABLE", host['EXECUTABLE']) print_config("C_FLAGS", C_FLAGS) print_config("LIB_FLAGS", LIB_FLAGS) print_config("LIBRARIES", LIBRARIES) print_config("INCLUDES", INCLUDES) print_config("OPENMP", CPARMS['OPENMP']) print("\n COMPILE-TIME PARAMETERS\n") print_config("N1TOT", CPARMS['N1TOT']) print_config("N2TOT", CPARMS['N2TOT']) print_config("N3TOT", CPARMS['N3TOT']) print_config("N1CPU", CPARMS['N1CPU']) print_config("N2CPU", CPARMS['N2CPU']) print_config("N3CPU", CPARMS['N3CPU']) print_config("METRIC", CPARMS['METRIC']) print_config("RECONSTRUCTION", CPARMS['RECONSTRUCTION']) if util.parm_is_active(CPARMS, 'RADIATION'): print_config("RADIATION", CPARMS['RADIATION']) if util.parm_is_active(CPARMS, 'NTH'): print_config("NTH", CPARMS["NTH"]) else: set_cparm("NTH", 8) if util.parm_is_active(CPARMS, 'NPHI'): print_config("NPHI", CPARMS["NPHI"]) else: set_cparm("NPHI", 8) if util.parm_is_active(CPARMS, "NU_BINS_EMISS"): print_config("NU_BINS_EMISS", CPARMS["NU_BINS_EMISS"]) else: set_cparm("NU_BINS_EMISS", 200) if util.parm_is_active(CPARMS, "NU_BINS_SPEC"): print_config("NU_BINS_SPEC", CPARMS["NU_BINS_SPEC"]) else: set_cparm("NU_BINS_SPEC", 200) if util.parm_is_active(CPARMS, "SUPPRESS_FLR_RADIATION"): print_config("SUPPRESS_FLR_RADIATION", CPARMS["SUPPRESS_FLR_RADIATION"]) else: set_cparm("SUPPRESS_FLR_RADIATION", 0) else: set_cparm("RADIATION", 0) if util.parm_is_active(CPARMS, 'ELECTRONS'): print_config("ELECTRONS", CPARMS['ELECTRONS']) else: set_cparm("ELECTRONS", 0) if util.parm_is_active(CPARMS, 'FLOORADV'): print_config("FLOORADV", CPARMS['FLOORADV']) else: set_cparm("FLOORADV", 0) #if util.parm_is_active(CPARMS,'NVAR_PASSIVE'): # print_config("NVAR_PASSIVE", CPARMS["NVAR_PASSIVE"]) #else: # set_cparm("NVAR_PASSIVE", 0) #if util.parm_is_active(CPARMS, 'OUTPUT_EOSVARS'): # print_config("OUTPUT_EOSVARS", CPARMS["OUTPUT_EOSVARS"]) #else: # set_cparm("OUTPUT_EOSVARS", 0) # Set core runtime parameters set_rparm('tf', 'double') set_rparm('dt', 'double') if CPARMS['METRIC'] == 'MINKOWSKI': set_rparm('x1Min', 'double', default = 0.) set_rparm('x1Max', 'double', default = 1.) set_rparm('x2Min', 'double', default = 0.) set_rparm('x2Max', 'double', default = 1.) set_rparm('x3Min', 'double', default = 0.) set_rparm('x3Max', 'double', default = 1.) if CPARMS['METRIC'] == 'MKS': set_rparm('a', 'double', default = 0.5) set_rparm('hslope', 'double', default = 0.3) set_rparm('Rout', 'double', default = 40.) set_rparm('Rout_vis', 'double', default = 40.) if CPARMS['METRIC'] == 'MMKS': set_rparm('a', 'double', default = 0.5) set_rparm('hslope', 'double', default = 0.3) set_rparm('poly_xt', 'double', default = 0.82) set_rparm('poly_alpha', 'double', default = 14.) set_rparm('mks_smooth', 'double', default = 0.5) set_rparm('Rout', 'double', default = 40.) set_rparm('Rout_vis', 'double', default = 40.) if util.parm_is_active(CPARMS, 'RADIATION'): set_rparm('Rout_rad', 'double', default = 40.) if (util.parm_is_active(CPARMS, 'RADIATION') or util.parm_is_active(CPARMS, 'COULOMB')): if CPARMS['METRIC'] == 'MINKOWSKI': set_rparm('L_unit', 'double') set_rparm('M_unit', 'double') if CPARMS['METRIC'] == 'MKS' or CPARMS['METRIC'] == 'MMKS': set_rparm('M_unit', 'double') set_rparm('mbh', 'double', default = 1.989e34) set_rparm('gam', 'double', default = 5./3.) set_rparm('cour', 'double', default = 0.9) if util.parm_is_active(CPARMS, 'ELECTRONS'): set_rparm('game', 'double', default = 4./3.) set_rparm('gamp', 'double', default = 5./3.) set_rparm('fel0', 'double', default = 0.01) set_rparm('tptemin', 'double', default = 1.e-3) set_rparm('tptemax', 'double', default = 1.e3) if util.parm_is_active(CPARMS, 'RADIATION'): if not util.parm_is_active(CPARMS, 'ELECTRONS'): set_rparm('tp_over_te', 'double', default = 1.) set_rparm('nph_per_proc', 'double', default = 1.e5) set_rparm('numin_emiss', 'double', default = 1.e8) set_rparm('numax_emiss', 'double', default = 1.e20) set_rparm('numin_spec', 'double', default = 1.e8) set_rparm('numax_spec', 'double', default = 1.e20) set_rparm('tune_emiss', 'double', default = 1.) set_rparm('tune_scatt', 'double', default = 1.) set_rparm('t0_tune_emiss', 'double', default = -1.) set_rparm('t0_tune_scatt', 'double', default = -1.) set_rparm('thetae_max', 'double', default = 1.e3) set_rparm('sigma_max', 'double', default = 1.) set_rparm('kdotk_tol', 'double', default = 1.e-6) set_rparm('Nph_to_track', 'double', default = 0.); set_rparm('init_from_grmhd', 'string', default = 'No') set_rparm('DTd', 'double', default = 0.5) set_rparm('DTl', 'double', default = 0.1) set_rparm('DTr', 'double', default = 1000.) set_rparm('DNr', 'integer', default = 1024) set_rparm('DTp', 'integer', default = 100) set_rparm('DTf', 'integer', default = 1) set_rparm('outputdir', 'string', default = './') # GET ALL SOURCE FILES SRC_CORE = util.get_files(PATHS['CORE'], '*.c') INC_CORE = util.get_files(PATHS['CORE'], '*.h') SRC_PROB = util.get_files(PATHS['PROB'], '*.c') INC_PROB = util.get_files(PATHS['PROB'], '*.h') # Clean if necessary if CLEAN: util.make_clean(PATHS['SRC']) # COPY SOURCE FILES TO BUILD_DIR for src in SRC_CORE: call(['cp', src, PATHS['SRC'] + src.rsplit('/',1)[1]]) for inc in INC_CORE: call(['cp', inc, PATHS['SRC'] + inc.rsplit('/',1)[1]]) for src in SRC_PROB: call(['cp', src, PATHS['SRC'] + src.rsplit('/',1)[1]]) for inc in INC_PROB: call(['cp', inc, PATHS['SRC'] + inc.rsplit('/',1)[1]]) # WRITE PARAMETERS FILE pf = open(PATHS['SRC'] + 'params.h', 'w') for KEY in CPARMS: if isinstance(CPARMS[KEY], str): pf.write("#define " + KEY + " (" + CPARMS[KEY] + ")\n") else: pf.write("#define " + KEY + " (%g)\n" % CPARMS[KEY]) pf.close() # GET SINGLE LISTS OF ALL SOURCE, OBJECT, AND HEADER FILES SRC_ALL = util.get_files(PATHS['SRC'], '*.c') INC_ALL = util.get_files(PATHS['SRC'], '*.h') SRC = '' OBJ = '' INC = '' for n in range(len(SRC_ALL)): SRC += '%s ' % os.path.basename(SRC_ALL[n]) OBJ += '%s.o ' % os.path.basename(SRC_ALL[n])[:-2] for n in range(len(INC_ALL)): INC += '%s ' % os.path.basename(INC_ALL[n]) # WRITE MAKEFILE os.chdir(PATHS['SRC']) mf = open('makefile', 'w') mf.write('CC = ' + host['COMPILER'] + '\n') mf.write('CCFLAGS = ' + C_FLAGS + ' ' + LIBRARIES + ' ' + INCLUDES + '\n') mf.write('LIB_FLAGS = ' + LIB_FLAGS + '\n') mf.write('CC_COMPILE = $(CC) $(CCFLAGS) -c' + '\n') mf.write('CC_LOAD = $(CC) $(CCFLAGS)' + '\n') mf.write('.c.o:' + '\n') mf.write('\t$(CC_COMPILE) $*.c' + '\n') mf.write('EXE = bhlight' + '\n') mf.write('all: $(EXE)' + '\n') mf.write('SRC = ' + SRC + '\n') mf.write('OBJ = ' + OBJ + '\n') mf.write('INC = ' + INC + '\n') mf.write('$(OBJ): $(INC) makefile' + '\n') mf.write('$(EXE): $(OBJ) $(INC) makefile' + '\n') mf.write('\t$(CC_LOAD) $(OBJ) $(LIB_FLAGS) -o $(EXE)\n') mf.write('clean:\n') mf.write('\t$(RM) $(SRC) $(OBJ) $(EXE) $(INC)\n') mf.close() print("\n COMPILING SOURCE\n") ncomp = 0 first_error = 1 if DEBUG: popen = subprocess.Popen(['make'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) else: popen = subprocess.Popen(['make','-j','10'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) for stdout_line in iter(popen.stdout.readline, ""): if stdout_line.rstrip()[-2:] == '.c': print(" [" + util.color.BOLD + util.color.BLUE + "%2d%%" % (100.*float(ncomp)/len(SRC_ALL)) + util.color.NORMAL + "] " + util.color.BOLD + stdout_line.rsplit('-c',1)[1].rstrip().lstrip().split('/')[-1] + util.color.NORMAL) ncomp += 1 for stderr_line in iter(popen.stderr.readline, ""): # THIS ALSO FAILS FOR WARNINGS!!! if first_error == 1: util.warn("COMPILER ERROR") first_error = 0 print(stderr_line.rstrip()) if first_error != 1 and not FORCE: util.warn("COMPILATION FAILED") sys.exit() obj_files = util.get_files(PATHS['SRC'], '*.o') for f in obj_files: os.remove(f) os.rename(PATHS['SRC'] + 'bhlight', PATHS['BUILD'] + 'bhlight') print("\n BUILD SUCCESSFUL") # CREATE RUNTIME PARAMETERS FILE PARAMFILE = PATHS['BUILD'] + PARAM_NAME if WRITE_PARAM: with open(PARAMFILE, 'w') as pf: pf.write("### RUNTIME PARAMETERS ###\n") pf.write("\n# COORDINATES\n") write_rparm(pf, 'tf') write_rparm(pf, 'dt') if CPARMS['METRIC'] == 'MINKOWSKI': write_rparm(pf, 'x1Min') write_rparm(pf, 'x1Max') write_rparm(pf, 'x2Min') write_rparm(pf, 'x2Max') write_rparm(pf, 'x3Min') write_rparm(pf, 'x3Max') if CPARMS['METRIC'] == 'MKS' or CPARMS['METRIC'] == 'MMKS': write_rparm(pf, 'Rout') if util.parm_is_active(CPARMS, 'RADIATION'): write_rparm(pf, 'Rout_rad') if (util.parm_is_active(CPARMS, 'RADIATION') or util.parm_is_active(CPARMS, 'COULOMB')): pf.write("\n# UNITS\n") if CPARMS['METRIC'] == 'MINKOWSKI': write_rparm(pf, 'L_unit') write_rparm(pf, 'M_unit') if CPARMS['METRIC'] == 'MKS' or CPARMS['METRIC'] == 'MMKS': write_rparm(pf, 'mbh') write_rparm(pf, 'M_unit') pf.write("\n# FLUID\n") write_rparm(pf, 'gam') write_rparm(pf, 'cour') if util.parm_is_active(CPARMS, 'ELECTRONS'): pf.write("\n# ELECTRONS\n") write_rparm(pf, 'game') write_rparm(pf, 'gamp') write_rparm(pf, 'fel0') write_rparm(pf, 'tptemin') write_rparm(pf, 'tptemax') if util.parm_is_active(CPARMS, 'RADIATION'): pf.write("\n# RADIATION\n") if not util.parm_is_active(CPARMS, 'ELECTRONS'): write_rparm(pf, 'tp_over_te') write_rparm(pf, 'nph_per_proc') write_rparm(pf, 'numin_emiss') write_rparm(pf, 'numax_emiss') write_rparm(pf, 'numin_spec') write_rparm(pf, 'numax_spec') write_rparm(pf, 'tune_emiss') write_rparm(pf, 'tune_scatt') write_rparm(pf, 't0_tune_emiss') write_rparm(pf, 't0_tune_scatt') write_rparm(pf, 'thetae_max') write_rparm(pf, 'sigma_max') write_rparm(pf, 'kdotk_tol') write_rparm(pf, 'Nph_to_track') pf.write("\n# OUTPUT\n") write_rparm(pf, 'DTd') write_rparm(pf, 'DTl') write_rparm(pf, 'DTr') write_rparm(pf, 'DNr') write_rparm(pf, 'DTp') write_rparm(pf, 'DTf') write_rparm(pf, 'outputdir') if len(RPARMS.keys()) > 0: pf.write("\n# PROBLEM\n") prob_keys = RPARMS.keys() for key in list(prob_keys): write_rparm(pf, key) print("\n RUNTIME PARAMETER FILE CREATED") if MOVEEXEC: os.rename(PATHS['BUILD'] + 'bhlight', PATHS['BUILD'] + '../bhlight') if WRITE_PARAM: os.rename(PATHS['BUILD'] + PARAM_NAME, PATHS['BUILD'] + '../' + PARAM_NAME) print("") sys.exit()