Skip to content

Commit

Permalink
Merge pull request #5 from MilanSkocic/dev
Browse files Browse the repository at this point in the history
0.2.2
  • Loading branch information
MilanSkocic authored Dec 17, 2023
2 parents 81897f1 + 9b29257 commit 4603938
Show file tree
Hide file tree
Showing 60 changed files with 1,589 additions and 355 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- name: Gfortran
run: |
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-10 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-10 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-10
- name: Set FPM
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: "v0.9.0"
- name: Gfortran version
run : gfortran --version
- name: Checkout
uses: actions/checkout@v4
- name: Compile
run: |
. ./configure.sh
make
macos:
runs-on: macos-latest
steps:
- name: Gfortran
run: |
brew reinstall gcc@10 gcc@13
- name: Set FPM
uses: fortran-lang/setup-fpm@v5
with:
fpm-version: "v0.9.0"
- name: Gfortran version
run : gfortran --version
- name: Checkout
uses: actions/checkout@v4
- name: Compile
run: |
. ./configure.sh
make
windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: MSYS2, Gfortran, fpm
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: >-
mingw-w64-x86_64-gcc-fortran
mingw-w64-x86_64-fpm
git
make
- name: Gfortran version
run : gfortran --version
- name: Checkout
uses: actions/checkout@v4
- name: Compile
run: |
. ./configure.sh
make
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ __pycache__

.DS_Store

*generator*

pywrapper/pyiapws/*.h
pywrapper/pyiapws/*.a
pywrapper/pyiapws/*.dll
Expand Down
14 changes: 9 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
A Makefile is provided, which uses `fpm <https://fpm.fortran-lang.org/en/index.html>`_, for building the library.
A Makefile is provided, which uses `fpm <https://fpm.fortran-lang.org>`_, for building the library.

On windows, `msys2 <https://www.msys2.org>`_ needs to be installed.
On windows, `msys2 <https://www.msys2.org>`_ needs to be installed. The MSVC compiler is only necessary
for compiling the python wrapper.
Add the msys2 binary (usually C:\msys64\usr\bin) to the path in order to be able to use make.

On Darwin, the `gcc <https://formulae.brew.sh/formula/gcc>`_ toolchain needs to be installed.

Build: the configuration file will set all the environmental variables necessary for the compilation

.. code-block:: bash
source configuration
chmod +x configure.sh
. ./configure.sh
make
Run tests

.. code-block:: bash
fpm test
make test
Install

Expand All @@ -34,4 +37,5 @@ If building the python wrapper is needed:
.. code-block:: bash
cd pywrapper
python setup.py bdist_wheel
make clean
make plat=(windows, linux or darwin)
78 changes: 59 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,91 @@ else
install_dir=$(DEFAULT_INSTALL_DIR)
endif

.PHONY: all clean install uninstall copy_h copy_a shared_linux shared_windows shared_darwin
.PHONY: clean install uninstall copy_h copy_a shared_linux shared_windows shared_darwin

all: $(LIBNAME)
all: clean $(LIBNAME)

$(LIBNAME): build copy_h copy_a shared copy_shared
$(LIBNAME): build copy_a shared copy_h copy_shared

build: clean
generator:
make -C srcgen generator

build: generator
fpm build --profile=release

build_debug: generator
fpm build --profile=debug

test: build
fpm test --profile=release

test_debug: build_debug
fpm test --profile=debug

example: build
fpm run --profile=release --example --all

example_debug: build_debug
fpm run --profile=debug --example --all

shared: shared_$(PLATFORM)

copy_shared: copy_shared_$(PLATFORM)

shared_linux:
gfortran -shared -o $(BUILD_DIR)/lib$(LIBNAME).so -Wl,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive
$(FC) -shared -o $(BUILD_DIR)/lib$(LIBNAME).so -Wl,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive

shared_darwin:
gfortran -dynamiclib -install_name @rpath/lib$(LIBNAME).dylib -static-libgfortran -static-libquadmath -static-libgcc -o $(BUILD_DIR)/lib$(LIBNAME).dylib -Wl,-all_load $(BUILD_DIR)/lib$(LIBNAME).a -Wl,-noall_load
$(FC) -dynamiclib -install_name @rpath/lib$(LIBNAME).dylib $(FPM_LDFLAGS) -o $(BUILD_DIR)/lib$(LIBNAME).dylib -Wl,-all_load $(BUILD_DIR)/lib$(LIBNAME).a

shared_windows:
gfortran -shared -static -o $(BUILD_DIR)/lib$(LIBNAME).dll -Wl,--out-implib=$(BUILD_DIR)/lib$(LIBNAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive
$(FC) -shared $(FPM_LDFLAGS) -o $(BUILD_DIR)/lib$(LIBNAME).dll -Wl,--out-implib=$(BUILD_DIR)/lib$(LIBNAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive

copy_a:
cp $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)
cp -f $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)
cp -f $(BUILD_DIR)/lib$(LIBNAME).a $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).a

copy_h:
cp $(INCLUDE_DIR)/$(LIBNAME)*.h $(PYW_MOD_DIR)/
cp -f $(INCLUDE_DIR)/$(LIBNAME)*.h $(PYW_MOD_DIR)/

copy_shared_linux:
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).so
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(PYW_MOD_DIR)

copy_shared:
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(PYW_MOD_DIR) | true
copy_shared_darwin:
cp $(BUILD_DIR)/lib$(LIBNAME).dylib $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dylib
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(PYW_MOD_DIR)

copy_shared_windows:
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dll
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(BUILD_DIR)/lib$(LIBNAME)-$(PLATFORM)-$(ARCH)-$(VERSION).dll.a
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(PYW_MOD_DIR)
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(PYW_MOD_DIR)

clean:
fpm clean --all
rm -f src/*.mod
make -C srcgen clean
make -C $(PYW_MOD_DIR) clean

install: install_dirs install_$(PLATFORM)

install:
install_dirs:
mkdir -p $(install_dir)/bin
mkdir -p $(install_dir)/include
mkdir -p $(install_dir)/lib
fpm install --prefix=$(install_dir)
cp -f ./include/*.h $(install_dir)/include
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(install_dir)/lib | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(install_dir)/lib | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(install_dir)/lib | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(install_dir)/bin | true

install_linux:
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(install_dir)/lib

install_darwin:
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(install_dir)/lib

install_windows:
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(install_dir)/lib
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(install_dir)/bin

uninstall:
rm -f $(install_dir)/include/$(LIBNAME)*.h
Expand Down
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
.. |cidev| image:: https://github.com/MilanSkocic/iapws/actions/workflows/ci.yml/badge.svg?branch=dev
.. |cimain| image:: https://github.com/MilanSkocic/iapws/actions/workflows/ci.yml/badge.svg?branch=main

dev |cidev| / main |cimain|

Introduction
================

.. image:: ./media/logo-iapws.png
:width: 200

.. readme_inclusion_start
`ipaws` is a Fortran library providing the formulas for computing light and heavy water properties.
Expand Down
27 changes: 25 additions & 2 deletions configuration → configure.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
LIBNAME="iapws"

# environment variables
FC=gfortran
PYW_DIR="./pywrapper"
BUILD_DIR="./build"
INCLUDE_DIR="./include"
Expand All @@ -11,6 +12,22 @@ FPM_LDFLAGS="-static"
DEFAULT_INSTALL_DIR="$HOME/.local"
PLATFORM="linux"

IFS='-'
tmp=$(gcc -dumpmachine)
read -a tmp_arr <<< "$tmp"
ARCH="${tmp_arr[0]}"

IFS="="
while read -r line; do
# Reading line by line
if [[ $line == "version"* ]]
then
read -a tmp_arr <<< "$line"
VERSION=${tmp_arr[1]:2:5}
break
fi
done < "fpm.toml"

if [[ "$OSTYPE" == "msys" ]]; then
DEFAULT_INSTALL_DIR="${APPDATA//\\//}/local"
PLATFORM="windows"
Expand All @@ -31,14 +48,20 @@ export PYW_MOD_DIR
export BUILD_DIR
export INCLUDE_DIR
export PLATFORM
export ARCH
export VERSION
export FC

echo "OS TYPE=" $OSTYPE
echo "PLATFORM=" $PLATFORM
echo "ARCH=" $ARCH
echo "VERSION=" $VERSION
echo "DEFAULT INSTALL DIR=" $DEFAULT_INSTALL_DIR
echo "FPM_FLAGS=" $FPM_FFLAGS
echo "FPM_CFLAGS=" $FPM_CFLAGS
echo "FPM_LDFLAGS=" $FPM_LDFLAGS
echo "PYW DIR=" $PYW_DIR
echo "PYW MOD DIR=" $PYW_MOD_DIR
echo "BUILD DIR" $BUILD_DIR
echo "INCLUDE_DIR" $INCLUDE_DIR
echo "BUILD DIR=" $BUILD_DIR
echo "INCLUDE_DIR=" $INCLUDE_DIR
echo "FC=" $FC
2 changes: 1 addition & 1 deletion documentation/ford/conf.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ summary: IAPWS - Water properties
project_github: https://github.com/MilanSkocic/iapws
project_download: https://github.com/MilanSkocic/iapws/releases
author: Milan Skocic
author_email: [email protected]
email: [email protected]
github: https://github.com/MilanSkocic
website: https://milanskocic.github.io/iapws/index.html
src_dir: ../../src
Expand Down
25 changes: 24 additions & 1 deletion documentation/sphinx/source/api/iapws.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ Fortran

.. literalinclude:: ../../../../src/iapws_g704.f90
:language: Fortran

IAPWS R283: Critical Constants
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* `iapws_r283.f90`: Module for IAPWS R2-83

.. literalinclude:: ../../../../src/iapws_r283.f90
:language: Fortran

* `iapws_r283_capi.f90`: C API for IAPWS R2-83.

.. literalinclude:: ../../../../src/iapws_r283_capi.f90
:language: Fortran

IAPWS G704: Gas solubilities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -23,7 +36,7 @@ Fortran
.. literalinclude:: ../../../../src/iapws_g704.f90
:language: Fortran

* `iapws_g704.f90`: C API for the IAPWS module.
* `iapws_g704_capi.f90`: C API for IAPWS G7-04.

.. literalinclude:: ../../../../src/iapws_g704_capi.f90
:language: Fortran
Expand All @@ -36,6 +49,16 @@ C
.. literalinclude:: ../../../../include/iapws.h
:language: C

.. _iapws_r283_capi:

IAPWS R283: Critical Constants
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* `iapws_r283.h`: C header.

.. literalinclude:: ../../../../include/iapws_r283.h
:language: C

IAPWS G704: Gas solubilities
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
9 changes: 9 additions & 0 deletions documentation/sphinx/source/api/pyiapws.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
pyipaws
================

IAPWS R283: Critical Constants
----------------------------------

.. automodule:: pyiapws.r283
:members:

The constants are defined as in the :ref:`C header <iapws_r283_capi>` without
the prefix *iapws_r283_capi_*.

IAPWS G704: Gas solubilities
-------------------------------

Expand Down
5 changes: 2 additions & 3 deletions documentation/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@

# General information about the project.
project = "iapws"
copyright = mod.__copyright__[14:]
author = mod.__author__
author = "M. Skocic"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -118,7 +117,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = mod.__package_name__
htmlhelp_basename = "iapws"


# -- Options for LaTeX output ---------------------------------------------
Expand Down
Loading

0 comments on commit 4603938

Please sign in to comment.