-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into updates/orbital_elements
- Loading branch information
Showing
6 changed files
with
1,308 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# standard amuse configuration include | ||
# config.mk will be made after ./configure has run | ||
#AMUSE_DIR?=/disks/strw3/por/amuse-svn | ||
#AMUSE_DIR?=/disks/strw3/por/amuse-svn | ||
ifeq ($(origin AMUSE_DIR), undefined) | ||
AMUSE_DIR := $(shell amusifier --get-amuse-dir) | ||
endif | ||
export AMUSE_DIR | ||
|
||
-include $(AMUSE_DIR)/config.mk | ||
|
||
MPICXX ?= mpicxx | ||
|
||
CFLAGS += -Wall -g -std=c++11 -I$(AMUSE_DIR)/lib/stopcond -pthread | ||
CXXFLAGS += $(CFLAGS) | ||
LDFLAGS += -lm $(MUSE_LD_FLAGS) | ||
|
||
OBJS = interface.o | ||
|
||
CODELIB = src/Hermite_GRX/src/libhermite_grx.a | ||
|
||
DOWNLOAD_FROM_WEB = $(PYTHON) ./download.py | ||
|
||
all: hermite_grx_worker | ||
|
||
clean: | ||
$(RM) -f *.so *.o *.pyc worker_code.cc worker_code.h | ||
$(RM) *~ hermite_grx_worker worker_code.cc | ||
$(RM) -f *~ | ||
make -C src clean | ||
|
||
download: | ||
if [ -d "src" ]; then \ | ||
echo "src directory exists, skipping download"; \ | ||
else \ | ||
mkdir src; \ | ||
$(DOWNLOAD_FROM_WEB); \ | ||
fi | ||
|
||
$(CODELIB): download | ||
make -C src/Hermite_GRX/src all | ||
|
||
worker_code.cc: interface.py | ||
$(CODE_GENERATOR) --type=c interface.py HermiteGRXInterface -o $@ | ||
|
||
worker_code.h: interface.py | ||
$(CODE_GENERATOR) --type=H -i amuse.community.interface.stopping_conditions.StoppingConditionInterface interface.py HermiteGRXInterface -o $@ | ||
|
||
hermite_grx_worker: worker_code.cc worker_code.h $(CODELIB) $(OBJS) | ||
$(MPICXX) $(CXXFLAGS) $< -o $@ $(OBJS) $(CODELIB) -L./src/Hermite_GRX/src -L$(AMUSE_DIR)/lib/stopcond -lstopcond -lhermite_grx | ||
|
||
interface.o: interface.cc | ||
$(CXX) $(CXXFLAGS) -c -o $@ $< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# generated file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env python | ||
|
||
import subprocess | ||
import os | ||
import urllib.request | ||
import urllib.parse | ||
import urllib.error | ||
from shutil import which | ||
import argparse | ||
|
||
|
||
class GetCodeFromHttp: | ||
filename_template = "{version}.tar.gz" | ||
name = ["Hermite_GRX"] | ||
url_template = [ | ||
"https://github.com/amusecode/Hermite_GRX/archive/{version}.tar.gz", | ||
] | ||
version = [ | ||
"", | ||
] | ||
|
||
def directory(self): | ||
return os.path.abspath(os.path.dirname(__file__)) | ||
|
||
def src_directory(self): | ||
return os.path.join(self.directory(), "src") | ||
|
||
def unpack_downloaded_file(self, filename, name, version): | ||
print(f"unpacking {filename}") | ||
arguments = ["tar", "-xf"] | ||
arguments.append(filename) | ||
subprocess.call(arguments, cwd=os.path.join(self.src_directory())) | ||
subprocess.call( | ||
["mv", f"{name}-{version}", name], cwd=os.path.join(self.src_directory()) | ||
) | ||
print("done") | ||
|
||
def start(self): | ||
if os.path.exists("src"): | ||
counter = 0 | ||
while os.path.exists(f"src.{counter}"): | ||
counter += 1 | ||
if counter > 100: | ||
print("too many backup directories") | ||
break | ||
os.rename("src", f"src.{counter}") | ||
|
||
os.mkdir("src") | ||
|
||
for i, url_template in enumerate(self.url_template): | ||
url = url_template.format(version=self.version[i]) | ||
filename = self.filename_template.format(version=self.version[i]) | ||
filepath = os.path.join(self.src_directory(), filename) | ||
print(f"downloading version {self.version[i]} from {url} to {filename}") | ||
if which("wget") is not None: | ||
arguments = ["wget", url] | ||
subprocess.call(arguments, cwd=os.path.join(self.src_directory())) | ||
elif which("curl") is not None: | ||
arguments = ["curl", "-L", "-O", url] | ||
subprocess.call(arguments, cwd=os.path.join(self.src_directory())) | ||
else: | ||
urllib.request.urlretrieve(url, filepath) | ||
print("downloading finished") | ||
self.unpack_downloaded_file(filename, self.name[i], self.version[i]) | ||
|
||
|
||
def main(hermite_grx_version=""): | ||
version = [ | ||
hermite_grx_version, | ||
] | ||
instance = GetCodeFromHttp() | ||
instance.version = version | ||
instance.start() | ||
|
||
|
||
def new_argument_parser(): | ||
result = argparse.ArgumentParser() | ||
result.add_argument( | ||
"--seba-version", | ||
default="c69fa0af018adbbd13d30a7e853c0179b8afbf7f", | ||
dest="hermite_grx_version", | ||
help="Hermite_GRX commit hash to download", | ||
type=str, | ||
) | ||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
arguments = new_argument_parser().parse_args() | ||
main(**arguments.__dict__) |
Oops, something went wrong.