configure.py - hyschive/gamer-fork GitHub Wiki
This page includes:
- Adding new source files
- Adding new library paths
- Adding new compiler flag types
- Rules of Makefile_base
Adding new source files
Edit the section "source files" in the Makefile_base
to add new source files.
Adding new simulation options
-
Add a Python argument reader for the new simulation option under
load_arguments()
. Here is a simple example of the argument reader:parser.add_argument( "--new_argument", type=int, metavar="INTEGER", gamer_name="NAME_IN_GAMER", default=0, help="Your help message.\n" )
-
Please check out the available options at argparse document.
-
gamer_name
is the simulation option name in GAMER. -
default
is the default value of the argument. If the argument default depends on other arguments, setdefault=None
and assign the default value underset_conditional_defaults()
. For example, the default ofbitwise_reproducibility
isTrue
when enabling--debug
but otherwise isFalse
.def set_conditional_defaults( args ): ... if args["new_argument"] == None: args["new_argument"] = default_value_of_true if args["other_argument"] else default_value_of_false ... return args
-
-
[Optional] If the argument depends on other arguments, add
depend={"depend_arg1":depend_value1, "depend_arg2":depend_value2}
so the argument will be loaded only ifdepend_arg1==depend_value1
anddepend_arg2==depend_value2
.parser.add_argument( "--new_argument", type=int, metavar="INTEGER", gamer_name="NEW_SIMUALTION_OPTION", default=0, depend={"depend_arg1":depend_value1, "depend_arg2":depend_value2}, help="Your help message.\n" )
-
[Optional] To validate the input values, add
constraint={ val1:{"arg1":["a", "b"], val2:{"arg2":"c"} }
, which will check whether the argumentarg1
is eithera
orb
when the input value isval1
and whether the argumentarg2
isc
when the input value isval2
. An error will be raised if any constraints are violated. For example, the following code asserts--eos=GAMMA
when adopting either--flux=ROE
or--flux=EXACT
.parser.add_argument( "--flux", type=str, metavar="TYPE", gamer_name="RSOLVER", choices=["EXACT", "ROE", "HLLE", "HLLC", "HLLD"], constraint={ "ROE":{"eos":"GAMMA"}, "EXACT":{"eos":"GAMMA"} }, ... )
-
[Optional] Add additional checks in
validation()
and warning messages inwarning()
underFunctions
.validation()
def validation( paths, depends, constraints, **kwargs ): success = True ... if kwargs["new_argument"] < -1: LOGGER.error("Your error message.") success = False ... if not success: raise BaseException("The above validation failed.") return
warning()
def warning( paths, **kwargs ): ... if kwargs["new_argument"] == 0: LOGGER.warning("Your warning message.") ... return
Adding new library paths
-
Add
NEW_PATH := @@@NEW_PATH@@@
under thelibrary paths
section inMakefile_base
.# library paths ####################################################################################################### ... other paths ... NEW_PATH := @@@NEW_PATH@@@ ...
-
Add
NEW_PATH /path/of/new
in your machine configuration fileconfigs/YOUR.config
.# 1. Paths ... other paths ... NEW_PATH /path/of/new ...
Adding new compiler flag types
-
Add
NEW_FLAG := @@@NEW_FLAG@@@
under thecompilers and flags
section inMakefile_base
.# compilers and flags ####################################################################################################### ... other flags ... NEW_FLAG := @@@NEW_FLAG@@@ ...
-
Add
["NEW_FLAG":""]
in the dictionary variableflags
ofload_config()
inconfigure.py
.def load_config( config ): LOGGER.info("Using %s as the config."%(config)) paths, compilers = {}, {"CXX":"", "CXX_MPI":""} flags = {"CXXFLAG":"", "OPENMPFLAG":"", "LIBFLAG":"", "NVCCFLAG_COM":"", "NVCCFLAG_FLU":"", "NVCCFLAG_POT":""} gpus = {"GPU_COMPUTE_CAPABILITY":""} ... return paths, compilers, flags
[!IMPORTANT] All flags must be set in
flags
; otherwise, they will be interpreted as library paths.
-
Add
NEW_FLAG -new_flag
in your machine configuration fileconfigs/YOUR.config
.# 2. Compiler flags ... other flags ... NEW_FLAG -new_flag ...
Makefile_base
Rules of - The strings to be replaced by
configure.py
must be sandwiched by@@@
.