Skip to content

Commit

Permalink
Merge branch 'main' into updates/orbital_elements
Browse files Browse the repository at this point in the history
  • Loading branch information
rieder committed Apr 23, 2024
2 parents b9a1fd7 + b4e5c01 commit 0fb85d5
Show file tree
Hide file tree
Showing 6 changed files with 1,308 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- mpich
- openmpi
os:
- ubuntu-22.04
# - ubuntu-22.04
- ubuntu-20.04
# macOS is not ready yet - needs other setup of prerequisites
# - macos-12
Expand Down
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="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__)
Loading

0 comments on commit 0fb85d5

Please sign in to comment.