Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AWehrhahn/SMElib
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Dec 8, 2020
2 parents 7905d48 + f9f5c95 commit 74633f9
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 34 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/clean_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'Delete old artifacts'
on: [push]


jobs:
delete-artifacts:
runs-on: ubuntu-latest
steps:
- uses: kolpav/purge-artifacts-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
expire-in: 0 # Setting this to 0 will delete all artifacts
194 changes: 194 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: make

on:
push:
branches: [master]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
create_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: GitHub Tag
id: tag_release
# You may pin to the exact commit or the version.
# uses: mathieudutour/github-tag-action@1bab3ab0712cafa42b54c512453487b89bb06504
uses: mathieudutour/github-tag-action@v5
with:
# Required for permission to tag the repo.
github_token: ${{ secrets.GITHUB_TOKEN }}
# Which type of bump to use when none explicitly provided (default: `patch`).
# default_bump: # optional, default is patch

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.tag_release.outputs.new_tag }}
release_name: Release ${{ steps.tag_release.outputs.new_tag }}
draft: false
prerelease: false

manylinux-build:
needs: [create_release]
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: manylinux2010-gfortran
compiler: gfortran
container: quay.io/pypa/manylinux2010_x86_64
- name: manylinux2010-f2c
compiler: f2c
container: quay.io/pypa/manylinux2010_x86_64

container: ${{ matrix.container }}
steps:
# We need to install packages first, because the checkout needs gcc already
- run: yum install -y gcc-gfortran f2c cmake autoconf automake libtool
- run: git clone https://github.com/AWehrhahn/SMElib .
- name: Replace Makefile
if: matrix.compiler == 'f2c'
run: rm Makefile.am && mv Makefile_f2c.am Makefile.am
- name: Run F2C
if: matrix.compiler == 'f2c'
run: f2c -w -a -C++ -Nn1604 -Nq1200 -dsrc/eos/ src/eos/*.f & f2c -w -a -C++ -dsrc/sme/ src/sme/*.f
- run: ./bootstrap && ./configure --prefix=$PWD
- run: make install
- run: zip -r ${{ matrix.name }} lib share

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ matrix.name }}.zip
asset_name: ${{ matrix.name }}.zip
asset_content_type: application/zip

build:
needs: create_release
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu-gfortran
runs_on: ubuntu-latest
packages: gfortran
outputs: lib share
- name: ubuntu-f2c
runs_on: ubuntu-latest
packages: f2c
outputs: lib share
- name: windows-gfortran
runs_on: ubuntu-latest
packages: gfortran mingw-w64 mingw-w64-tools mingw-w64-common gfortran-mingw-w64 gfortran-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-x86-64
cxx: x86_64-w64-mingw32-gcc
f77: x86_64-w64-mingw32-gfortran
config_flags: --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
outputs: bin share
# F2C doesn't work for Windows, use gfortran instead
# will figure this out when possible
# - name: windows-f2c
# runs_on: ubuntu-latest
# packages: f2c mingw-w64 mingw-w64-tools mingw-w64-common gcc-mingw-w64 gcc-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-x86-64
# cxx: x86_64-w64-mingw32-gcc
# config_flags: --build=x86_64-pc-linux-gnu --host=x86_64-w64-mingw32
# outputs: bin share
- name: macos-gfortran
runs_on: macos-latest
packages: automake libtool
cxx: gcc-9
f77: gfortran-9
outputs: lib share
- name: macos-f2c
runs_on: macos-latest
taps: FranklinChen/tap
packages: automake libtool
cxx: gcc-9
outputs: lib share

# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.runs_on }}

steps:
- uses: actions/checkout@v2

- name: Install packages
if: matrix.runs_on == 'ubuntu-latest'
run: sudo apt-get install -y ${{ matrix.packages }}

- name: Install packages
if: matrix.runs_on == 'macos-latest'
run: brew tap ${{ matrix.taps }} && brew install ${{ matrix.packages }}

- name: Install F2C
if: matrix.name == 'macos-f2c'
run: brew install --verbose --HEAD franklinchen/tap/f2c

- name: Run F2C
if: matrix.name == 'ubuntu-f2c' || matrix.name == 'windows-f2c' || matrix.name == 'macos-f2c'
run: f2c -w -a -C++ -Nn1604 -Nq1200 -dsrc/eos/ src/eos/*.f & f2c -w -a -C++ -dsrc/sme/ src/sme/*.f

- name: Replace Makefile.am
if: matrix.name == 'ubuntu-f2c' || matrix.name == 'windows-f2c'
run: rm Makefile.am && mv Makefile_f2c.am Makefile.am

- name: Replace Makefile.am
if: matrix.name == 'macos-f2c'
run: rm Makefile.am && mv Makefile_mac.am Makefile.am

- name: Copy F2C headers
if: matrix.name == 'windows-f2c'
run: cp /usr/include/f2c.h src/eos/ & cp /usr/include/f2c.h src/sme/

- name: Run Bootstrap and Configure
env:
CXX: ${{ matrix.cxx }}
F77: ${{ matrix.f77 }}
run: ./bootstrap && ./configure --prefix=$PWD ${{ matrix.config_flags }}

- name: Install
env:
CXX: ${{ matrix.cxx }}
F77: ${{ matrix.f77 }}
run: make install

- name: Zip data # This would actually build your project, using zip for an example artifact
run: zip -r ${{ matrix.name }} ${{ matrix.outputs }}

- name: Archive compiled library
uses: actions/upload-artifact@v2
with:
name: library
path: ${{ matrix.name }}.zip

- name: Prepare Test Environment
if: matrix.name != 'windows-gfortran' && matrix.name != 'windows-f2c'
run: pip3 install -r test/requirements.txt

- name: Test Library
if: matrix.name != 'windows-gfortran' && matrix.name != 'windows-f2c'
run: python3 -m pytest

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ matrix.name }}.zip
asset_name: ${{ matrix.name }}.zip
asset_content_type: application/zip
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ src/sme/.deps/
build/
test/__pycache__/
dev/
kp_q_spln.c
src/eos/eos_eqns.c
src/eos/eos_math_special.c
src/eos/eos.c
src/sme/hlinop.c
src/sme/hlinprof.c
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ jobs:
- python3-pip
cache:
- pip
- os: linux
name: f2c
env:
- TARGET=linux-f2c
- OUTPUT_DIRS="lib share"
addons:
apt:
packages:
- g++
- f2c
- make
- python3.5
- python3-venv
- python3-pip
cache:
- pip
before_install:
- f2c -w -a -C++ -Nn1604 -Nq1200 -dsrc/eos/ src/eos/*.f
- f2c -w -a -c++ -dsrc/sme/ src/sme/*.f
- rm makefile.am
- mv makefile_f2c.am makefile.am
- os: linux
name: manylinux2010
services:
Expand Down
41 changes: 41 additions & 0 deletions Makefile_f2c.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4

lib_LTLIBRARIES = libsme.la
libsme_la_SOURCES = \
src/sme/platform.h \
src/sme/sme_synth_faster.cpp \
src/eos/eos.c \
src/eos/eos_eqns.c \
src/eos/eos_math_special.c \
src/eos/kp_q_spln.c \
src/sme/hlinop.c \
src/sme/hlinprof.c
libsme_la_LDFLAGS = -fPIC -version-info 5:22:0 -shared -no-undefined
libsme_la_CPPFLAGS = -fPIC -shared
libsme_la_LIBADD = -lc -l:libf2c.a -lm -lstdc++

dist_pkgdata_DATA = src/data/bpo_self.grid.INTEL \
src/data/Fe1_Bautista2017.dat.INTEL \
src/data/NH_Stancil2018.dat.INTEL \
src/data/stehle_long.dat.INTEL \
src/data/vcsbalmer.dat

BUILT_SOURCES = src/sme/platform.h old_link

CLEANFILES = src/sme/platform.h

PLATFORM = @TARGET@
MACHINE = @TARGET_CPU@
BITS = 64
SHL_EXT = "$(PLATFORM).$(MACHINE).$(BITS)"

DATA_DIR = @datadir@/libsme/

src/sme/platform.h:
echo '#define PLATFORM "$(PLATFORM)"' > src/sme/platform.h
echo '#define DATA_DIR "$(DATA_DIR)"' >> src/sme/platform.h

old_link: libsme.la
$(MKDIR_P) $(@OUTPUT_DIR@) && cd $(@OUTPUT_DIR@) && $(LN_S) -f libsme@EXTENSION@ sme_synth.so.$(SHL_EXT)
42 changes: 42 additions & 0 deletions Makefile_mac.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4

lib_LTLIBRARIES = libsme.la
libsme_la_SOURCES = \
src/sme/platform.h \
src/sme/sme_synth_faster.cpp \
src/eos/eos.c \
src/eos/eos_eqns.c \
src/eos/eos_math_special.c \
src/eos/kp_q_spln.c \
src/sme/hlinop.c \
src/sme/hlinprof.c
libsme_la_LDFLAGS = -fPIC -version-info 5:22:0 -shared -no-undefined
libsme_la_CPPFLAGS = -fPIC -shared
# Here we assume that f2c has been installed using homebrew, since the automatic detection seems to fail...
libsme_la_LIBADD = -lc /usr/local/Cellar/f2c/HEAD/lib/libf2c.a -lm -lstdc++

dist_pkgdata_DATA = src/data/bpo_self.grid.INTEL \
src/data/Fe1_Bautista2017.dat.INTEL \
src/data/NH_Stancil2018.dat.INTEL \
src/data/stehle_long.dat.INTEL \
src/data/vcsbalmer.dat

BUILT_SOURCES = src/sme/platform.h old_link

CLEANFILES = src/sme/platform.h

PLATFORM = @TARGET@
MACHINE = @TARGET_CPU@
BITS = 64
SHL_EXT = "$(PLATFORM).$(MACHINE).$(BITS)"

DATA_DIR = @datadir@/libsme/

src/sme/platform.h:
echo '#define PLATFORM "$(PLATFORM)"' > src/sme/platform.h
echo '#define DATA_DIR "$(DATA_DIR)"' >> src/sme/platform.h

old_link: libsme.la
$(MKDIR_P) $(@OUTPUT_DIR@) && cd $(@OUTPUT_DIR@) && $(LN_S) -f libsme@EXTENSION@ sme_synth.so.$(SHL_EXT)
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.com/AWehrhahn/SMElib.svg?branch=master)](https://travis-ci.com/AWehrhahn/SMElib)

![CMake](https://github.com/AWehrhahn/SMElib/workflows/CMake/badge.svg)
# SMElib
Spectroscopy Made Easy Source Library

Expand All @@ -11,7 +11,9 @@ spectrum of a star with a model spectrum. Since its initial release in

## Download
You can find compiled versions of the library for Unix, Mac OS, and Windows under [Releases](https://github.com/AWehrhahn/SMElib/releases).
Note that depending on your system you might have to install libgfortran (version 3) as well.

There are two versions for each OS. The gfortran version uses gfortran to compile the Fortran code, while the [F2C](https://www.netlib.org/f2c/) version first converts the Fortran code to C++ code. The difference between these two are that f2c does not require libgfortran, but gives slightly numerical differences. It also appears to run faster in preliminary tests.
Note that depending on your system you might have to install libgfortran as well.

## Notes
- SMElib requires libgfortran on most OSs to be installed. The exact version, depends on the version of SMELib that you are installing. If PySME fails to load the library try adding that libgfortran file in the same directory.
Expand Down
Loading

0 comments on commit 74633f9

Please sign in to comment.