Skip to content
Merged
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
53 changes: 53 additions & 0 deletions src/amuse/community/hermite_grx/Makefile
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 $@ $<
1 change: 1 addition & 0 deletions src/amuse/community/hermite_grx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# generated file
90 changes: 90 additions & 0 deletions src/amuse/community/hermite_grx/download.py
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="e0cf110efc344011674b9d92d72b67629e2c1bd6",
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__)
Loading