Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
*.bin
*~

# Executables and binaries
bin/**
src/generate_make.sh
gamer
GAMER_CompareData
GAMER_ExtractUniform
GAMER_ExtractProfile
.vscode

# Build files
src/generate_make.sh
src/Makefile
src/Makefile.log
tool/analysis/gamer_compare_data/Makefile
tool/analysis/gamer_extract_profile/Makefile
tool/analysis/gamer_extract_uniform/Makefile

# Settings
.vscode
src/.local_settings
41 changes: 40 additions & 1 deletion src/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
"Default values are marked by '*'.\n"\
"Use -lh to show a detailed help message.\n"
GAMER_EPILOG = "2023 Computational Astrophysics Lab, NTU. All rights reserved.\n"
GAMER_TOOL_PATHS = [
os.path.join("..", "tool", "analysis", "gamer_compare_data"),
os.path.join("..", "tool", "analysis", "gamer_extract_uniform"),
os.path.join("..", "tool", "analysis", "gamer_extract_profile"),
]

LOGGER = logging.getLogger()
LOG_FORMAT = "%(asctime)s %(levelname)-8s: %(message)s"
Expand Down Expand Up @@ -455,6 +460,12 @@ def load_arguments( sys_setting : SystemSetting ):
help="Output detailed compilation commands.\n"
)

# generate Makefile for tools
parser.add_argument( "--tools", type=str2bool, metavar="BOOLEAN",
default=False,
help="Generate Makefile for the analysis tools.\n"
)

# A. options of diffierent physical models
parser.add_argument( "--model", type=str, metavar="TYPE", gamer_name="MODEL",
default="HYDRO", choices=["HYDRO", "ELBDM", "PAR_ONLY"],
Expand Down Expand Up @@ -1168,7 +1179,7 @@ def warning( paths, **kwargs ):
# 5.5 Set the GPU
gpu_setup = set_gpu( gpus, flags, args )

# 6. Create Makefile
# 6. Create Makefile for GAMER
# 6.1 Read
with open( GAMER_MAKE_BASE, "r" ) as make_base:
makefile = make_base.read()
Expand Down Expand Up @@ -1212,5 +1223,33 @@ def warning( paths, **kwargs ):

LOGGER.info("========================================")
LOGGER.info("%s is created."%GAMER_MAKE_OUT)

# 7. Create Makefile for tools
if args['tools']:
all_key_vals = { **sims, **paths, **compiles, **gpu_setup }
for tool_path in GAMER_TOOL_PATHS:
tool_make_base = os.path.join( tool_path, GAMER_MAKE_BASE )
tool_make_out = os.path.join( tool_path, GAMER_MAKE_OUT )

# 7.1 Read
with open( tool_make_base, "r" ) as make_base:
makefile = make_base.read()

# 7.2 Replace
for key, val in all_key_vals.items():
makefile, num = re.subn(r"@@@%s@@@"%key, val, makefile)
if num > 0: LOGGER.debug("%-25s : %s"%(key, val))

for key in re.findall(r"@@@(.+?)@@@", makefile):
makefile, num = re.subn(r"@@@%s@@@"%key, "", makefile)
if num == 0: raise BaseException("The string @@@%s@@@ is not replaced correctly."%key)
LOGGER.warning("@@@%s@@@ is replaced to '' since the value is not given or the related option is disabled."%key)

# 7.3 Write
with open( tool_make_out, "w") as make_out:
make_out.write( command + makefile )

LOGGER.info("%s is created."%tool_make_out)

if args["verbose_make"]: LOGGER.info("%s is in verbose mode."%GAMER_MAKE_OUT)
LOGGER.info("========================================")
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,7 @@ EXECUTABLE := GAMER_CompareData

# simulation options
#######################################################################################################
# model: HYDRO/ELBDM
SIMU_OPTION += -DMODEL=HYDRO

# double precision
#SIMU_OPTION += -DFLOAT8

# double precision for particle floating-point attributes
#SIMU_OPTION += -DFLOAT8_PAR

# long integer for particle integer attributes
SIMU_OPTION += -DINT8_PAR

# debug mode
#SIMU_OPTION += -DGAMER_DEBUG

# support HDF5 format
SIMU_OPTION += -DSUPPORT_HDF5



# siimulation parameters
#######################################################################################################
NLEVEL := 10 # level : 0 ~ NLEVEL-1
MAX_PATCH := 2000000 # maximum number of patches in each level

NLEVEL := $(strip $(NLEVEL))
MAX_PATCH := $(strip $(MAX_PATCH))

SIMU_PARA = -DNLEVEL=$(NLEVEL) -DMAX_PATCH=$(MAX_PATCH)
SIMU_OPTION := @@@SIMU_OPTION@@@



Expand All @@ -54,11 +26,10 @@ vpath %.cpp ./ GAMER_Functions

# rules and targets
#######################################################################################################
HDF5_PATH := /software/hdf5/default
#HDF5_PATH := /software/hdf5/1.10.6-intel-2023.1.0
HDF5_PATH := @@@HDF5_PATH@@@

CC := icpc
CFLAG := -O3 -w1 -g -diag-disable=10441
CC := @@@CXX@@@
CFLAG := @@@CXXFLAG@@@

INCLUDE := -I./Header
ifeq "$(findstring SUPPORT_HDF5, $(SIMU_OPTION))" "SUPPORT_HDF5"
Expand All @@ -75,7 +46,7 @@ OBJ := $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(SOURCE))


$(OBJ_DIR)/%.o : %.cpp
$(CC) $(CFLAG) $(SIMU_PARA) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<
$(CC) $(CFLAG) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<

$(EXECUTABLE): $(OBJ)
$(CC) $(CFLAG) -o $@ $^ $(LIB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,9 @@ EXECUTABLE := GAMER_ExtractProfile



# siimulation options
# simulation options
#######################################################################################################
# model: HYDRO/MHD/ELBDM
SIMU_OPTION += -DMODEL=HYDRO

# double precision
#SIMU_OPTION += -DFLOAT8

# double precision for particle floating-point attributes
#SIMU_OPTION += -DFLOAT8_PAR

# long integer for particle integer attributes
SIMU_OPTION += -DINT8_PAR

# debug mode
#SIMU_OPTION += -DGAMER_DEBUG

# support HDF5 format
SIMU_OPTION += -DSUPPORT_HDF5



# siimulation parameters
#######################################################################################################
NLEVEL := 10 # level : 0 ~ NLEVEL-1
NCOMP_PASSIVE := 0 # number of passive scalars
MAX_PATCH := 2000000 # the maximum number of patches in each level

NLEVEL := $(strip $(NLEVEL))
NCOMP_PASSIVE := $(strip $(NCOMP_PASSIVE))
MAX_PATCH := $(strip $(MAX_PATCH))

SIMU_PARA = -DNLEVEL=$(NLEVEL) -DMAX_PATCH=$(MAX_PATCH) -DNCOMP_PASSIVE=$(NCOMP_PASSIVE)
SIMU_OPTION := @@@SIMU_OPTION@@@



Expand All @@ -65,14 +35,10 @@ vpath %.cpp ./ GAMER_Functions GAMER_Functions/Interpolation

# rules and targets
#######################################################################################################
HDF5_PATH := /software/hdf5/default

CC := icpc
CFLAG := -O3 -w1 -g #-xSSE4.2 -fp-model precise
#CFLAG := -O3 -w1 -mp1
HDF5_PATH := @@@HDF5_PATH@@@

#CC := g++
#CFLAG := -O3 -Wall
CC := @@@CXX@@@
CFLAG := @@@CXXFLAG@@@

#LIB := -limf

Expand All @@ -95,7 +61,7 @@ OBJ := $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(SOURCE))


$(OBJ_DIR)/%.o : %.cpp
$(CC) $(CFLAG) $(SIMU_PARA) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<
$(CC) $(CFLAG) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<

$(EXECUTABLE): $(OBJ)
$(CC) $(CFLAG) -o $@ $^ $(LIB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,9 @@ EXECUTABLE = GAMER_ExtractUniform



# siimulation options
# simulation options
#######################################################################################################
# model: HYDRO/MHD/ELBDM
SIMU_OPTION += -DMODEL=HYDRO

# double precision
#SIMU_OPTION += -DFLOAT8

# double precision for particle floating-point attributes
#SIMU_OPTION += -DFLOAT8_PAR

# long integer for particle integer attributes
SIMU_OPTION += -DINT8_PAR

# enable OpenMP parallelization
SIMU_OPTION += -DOPENMP

# debug mode
#SIMU_OPTION += -DGAMER_DEBUG

# support HDF5 format
SIMU_OPTION += -DSUPPORT_HDF5

# serial version (no MPI is required)
#SIMU_OPTION += -DSERIAL



# siimulation parameters
#######################################################################################################
NLEVEL = 10 # level : 0 ~ NLEVEL-1
NCOMP_PASSIVE = 0 # number of passive scalars
MAX_PATCH = 1000000 # the maximum number of patches in each level

NLEVEL := $(strip $(NLEVEL))
NCOMP_PASSIVE := $(strip $(NCOMP_PASSIVE))
MAX_PATCH := $(strip $(MAX_PATCH))

SIMU_PARA = -DNLEVEL=$(NLEVEL) -DMAX_PATCH=$(MAX_PATCH) -DNCOMP_PASSIVE=$(NCOMP_PASSIVE)
SIMU_OPTION := @@@SIMU_OPTION@@@



Expand Down Expand Up @@ -75,21 +39,11 @@ vpath %.cpp ./ GAMER_Functions GAMER_Functions/Interpolation

# rules and targets
#######################################################################################################
HDF5_PATH := /software/hdf5/default
MPI_PATH := /software/openmpi/default
#MPI_PATH := /opt/mpi/openmpi/1.6.0-intel
#MPI_PATH := /usr/local/mpi/openmpi-1.8.4-intel-15.0
#HDF5_PATH := /projects/ncsa/grav/softwares/miniconda2


ifeq "$(findstring SERIAL, $(SIMU_OPTION))" ""
CXX := $(MPI_PATH)/bin/mpicxx
else
CXX := icpc
endif
HDF5_PATH := @@@HDF5_PATH@@@
MPI_PATH := @@@MPI_PATH@@@

CFLAG := -O3 -w1
#CFLAG := -O3 -Wall
CXX := @@@CXX@@@
CFLAG := @@@CXXFLAG@@@

ifeq "$(findstring GAMER_DEBUG, $(SIMU_OPTION))" "GAMER_DEBUG"
CFLAG += -g
Expand Down Expand Up @@ -119,7 +73,7 @@ OBJ := $(patsubst %.cpp, $(OBJ_PATH)/%.o, $(SOURCE))


$(OBJ_PATH)/%.o : %.cpp
$(CXX) $(CFLAG) $(SIMU_PARA) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<
$(CXX) $(CFLAG) $(SIMU_OPTION) $(INCLUDE) -o $@ -c $<

$(EXECUTABLE): $(OBJ)
$(CXX) $(CFLAG) -o $@ $^ $(LIB)
Expand Down