Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SYCLIST #883

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions src/amuse/community/syclist/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# standard amuse configuration include
# config.mk will be made after ./configure has run
ifeq ($(origin AMUSE_DIR), undefined)
AMUSE_DIR := $(shell amusifier --get-amuse-dir)
endif
-include $(AMUSE_DIR)/config.mk

MPIFC ?= mpif90
FC = $(MPIFC)

FCFLAGS+= -Isrc/SYCLIST
LDFLAGS += -lm $(MUSE_LD_FLAGS)

OBJS = interface.o

CODEDIR = src/SYCLIST
CODELIB = $(CODEDIR)/libsyclist.a


DOWNLOAD_FROM_WEB = $(PYTHON) ./download.py


all: syclist_worker

download:
$(DOWNLOAD_FROM_WEB)

clean:
$(RM) -rf __pycache__
$(RM) -f *.so *.o *.pyc worker_code.cc worker_code.h
$(RM) *~ worker_code worker_code.f90
make -C $(CODEDIR) clean

distclean: clean
make -C $(CODEDIR) distclean

$(CODELIB): #download
make -C $(CODEDIR) libsyclist.a

worker_code.f90: interface.py
$(CODE_GENERATOR) --type=f90 interface.py SyclistInterface -o $@

syclist_worker: worker_code.f90 $(CODELIB) $(OBJS)
$(MPIFC) $(FCFLAGS) $(FS_FLAGS) $< $(OBJS) $(CODELIB) $(FS_LIBS) -o $@

%.o: %.f90
$(FC) $(FCFLAGS) -c -o $@ $<
1 change: 1 addition & 0 deletions src/amuse/community/syclist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# generated file
100 changes: 100 additions & 0 deletions src/amuse/community/syclist/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python

import subprocess
import os
import urllib.request
import urllib.parse
import urllib.error
from shutil import which
from optparse import OptionParser


class GetCodeFromHttp:
filename_template = "{version}.tar.gz"
name = "SYCLIST"
url_template = "https://github.com/GESEG/SYCLIST/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("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')

url = self.url_template.format(version=self.version)
filename = self.filename_template.format(version=self.version)
filepath = os.path.join(self.src_directory(), filename)
print(
f"downloading version {self.version}"
f"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, self.version
)


def main(version=''):
instance = GetCodeFromHttp()
instance.version = version
instance.start()


def new_option_parser():
result = OptionParser()
result.add_option(
"--version",
default='a38f080e50f157b92684df61e678f97faf24d68e',
dest="version",
help="SYCLIST commit hash to download",
type="string"
)
return result


if __name__ == "__main__":
options, arguments = new_option_parser().parse_args()
main(**options.__dict__)
Loading