fpm, CD/CI, ford setup

This commit is contained in:
John S. Urban 2023-06-09 19:25:34 -04:00
parent 57f13bc321
commit faa9d9aaa4
16 changed files with 674 additions and 10 deletions

46
.github/workflows/deploy_api_docs.yml.OFF vendored Executable file
View file

@ -0,0 +1,46 @@
#name: Build FORD docs & deploy to gh-pages
name: FORD docs deployed to main
on:
push:
branches:
- main
jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade pip ford
- name: Checkout main
uses: actions/checkout@v1
- name: Build docs
run: |
ford --version
ford ford.md
ls
tree
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#BRANCH: gh_pages
BRANCH: main
FOLDER: docs/fpm-ford
TARGET_FOLDER: docs/fpm-ford
# ford(1) deletes the output directory before running
# so be careful to specify a unique subdirectory in
# your ford(1) configuration files
# valid inputs are ['SSH', 'ACCESS_TOKEN', 'GITHUB_TOKEN', 'BRANCH',
# 'FOLDER', 'TARGET_FOLDER', 'BASE_BRANCH', 'COMMIT_MESSAGE', 'CLEAN',
# 'CLEAN_EXCLUDE', 'GIT_CONFIG_NAME', 'GIT_CONFIG_EMAIL', 'REPOSITORY_NAME',
# 'WORKSPACE', 'SINGLE_COMMIT', 'LFS', 'SILENT', 'PRESERVE']

23
.github/workflows/docs.yml vendored Executable file
View file

@ -0,0 +1,23 @@
name: FORD docs deployed to gh-pages
on: [push, pull_request]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: pip install ford
- name: Build Documentation
run: ford ford.md
- uses: JamesIves/github-pages-deploy-action@3.7.1
if: github.event_name == 'push'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/fpm-ford
CLEAN: true

110
.github/workflows/test_gfortran_macos.yml.OFF vendored Executable file
View file

@ -0,0 +1,110 @@
name: macos with gfortran
on: [push, pull_request]
jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ macos-latest ]
include:
- os: macos-latest
gcc_v: 12
env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}
TZ: UTC+04:00
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Install GFortran macOS
run: |
ls /usr/local/bin/gfortran-*
ln -f -s /usr/local/bin/gfortran-${GCC_V} /usr/local/bin/gfortran
which gfortran-${GCC_V}
which gfortran
## Alternative:
#conda create -n gf gfortran
#conda activate gf
- name: Install fpm
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir -p /Users/runner/bin tmp
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -t unlimited -v unlimited
gfortran fpm.F90 -Jtmp -Itmp -o /Users/runner/bin/fpm
rm -f tmp/*.mod
ls -l
- name: Display environment
run: |
echo $PATH
pwd
uname -a
ulimit -a
echo "end" > foo.f90
gfortran -cpp -E -dM foo.f90
gfortran --version
fpm --version
ulimit -a
- name: tests MacOS (release)
run: |
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -t unlimited -v unlimited
exec 2>&1
set -x
#fpm test --profile release --verbose --flag -fno-automatic # looks like bug where formats go on stack anyway
#fpm test --profile debug --verbose --flag -fmax-stack-var-size=0 # Apparently infinite loop
#fpm test --profile debug --verbose --flag -fmax-stack-var-size=2024 # loop
#fpm test --profile debug --verbose --flag -frecursive
#fpm test --profile debug --verbose --flag -static
#timeout 0.5h fpm test --profile debug --verbose
ulimit -S -t 1800
fpm test --profile debug --verbose
- name: tests MacOS (debug)
run: |
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -t unlimited -v unlimited
exec 2>&1
set -x
ulimit -S -t 1800
fpm test --profile debug --verbose
- name: cleanup MacOS
run: ls -ltras
# -fno-automatic
# Treat each program unit (except those marked as RECURSIVE) as if
# the "SAVE" statement were specified for every local variable and
# array referenced in it. Does not affect common blocks. (Some
# Fortran compilers provide this option under the name -static or
# -save.) The default, which is -fautomatic, uses the stack for
# local variables smaller than the value given by
# -fmax-stack-var-size. Use the option -frecursive to use no static
# memory.
#
# Local variables or arrays having an explicit "SAVE" attribute are
# silently ignored unless the -pedantic option is added.
# -fmax-stack-var-size=n
# This option specifies the size in bytes of the largest array that
# will be put on the stack; if the size is exceeded static memory is
# used (except in procedures marked as RECURSIVE). Use the option
# -frecursive to allow for recursive procedures which do not have a
# RECURSIVE attribute or for parallel programs. Use -fno-automatic to
# never use the stack.
#
# This option currently only affects local arrays declared with
# constant bounds, and may not apply to all character variables.
# Future versions of GNU Fortran may improve this behavior.
#
# The default value for n is 32768.
# -frecursive
# Allow indirect recursion by forcing all local arrays to be
# allocated on the stack. This flag cannot be used together with
# -fmax-stack-var-size= or -fno-automatic.

View file

@ -0,0 +1,74 @@
name: windows mingw64 with gfortran
on: [push, pull_request]
env:
CTEST_TIME_TIMEOUT: "50" # some failures hang forever
jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include: [
{ msystem: MINGW64, arch: x86_64 },
]
env:
FC: gfortran
TZ: UTC+04:00
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v2
- name: Setup MinGW native environment
uses: msys2/setup-msys2@v2
if: contains(matrix.msystem, 'MINGW')
with:
msystem: ${{ matrix.msystem }}
update: false
install: >-
git
wget
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-gcc-fortran
- name: Install fpm
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir -p tmp
gfortran fpm.F90 -Jtmp -Itmp -static -o fpm
rm -f tmp/*.mod
ls -l
- name: tests (release)
run: |
gfortran --version
PATH=$PATH:.
./fpm test --compiler gfortran --profile release -flag "-D _WIN32"
env:
FPM_COMPILER: gfortran
CC: gcc
CXX: g++
FC: gfortran
TZ: UTC+04:00
- name: tests (debug)
run: |
PATH=$PATH:.
gfortran --version
./fpm test --compiler gfortran --profile debug -flag "-D _WIN32"
env:
FPM_COMPILER: gfortran
CC: gcc
CXX: g++
FC: gfortran
TZ: UTC+04:00
- name: cleanup
run: ls -ltras

View file

@ -0,0 +1,65 @@
name: msys windows gfortran
on: [push, pull_request]
env:
CTEST_TIME_TIMEOUT: "5" # some failures hang forever
FC: gfortran
TZ: UTC+04:00
jobs:
gfortran-windows-msys2-mingw64:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Setup MinGW (MSYS2)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
git
wget
mingw-w64-x86_64-gcc-fortran
mingw-w64-x86_64-meson
mingw-w64-x86_64-ninja
- name: Install fpm
shell: msys2 {0}
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir tmp
gfortran fpm.F90 -Itmp -Jtmp -o fpm
- name: Run tests and demo programs (debug)
shell: msys2 {0}
run: |
gfortran --version
./fpm test --profile release -flag "-D _WIN32"
env:
FC: gfortran
TZ: UTC+04:00
- name: Run tests and demo programs (release)
shell: msys2 {0}
run: |
gfortran --version
./fpm test --profile release -flag "-D _WIN32"
env:
FC: gfortran
TZ: UTC+04:00
- name: Build with meson
shell: msys2 {0}
run: |
meson --version
meson setup build -Dbuildtype=debug
meson compile -C build
- name: cleanup
run: dir

View file

@ -0,0 +1,54 @@
name: msys windows gfortran
on: [push, pull_request]
env:
CTEST_TIME_TIMEOUT: "5" # some failures hang forever
FC: gfortran
TZ: UTC+04:00
jobs:
gfortran-windows-msys2-mingw64:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Setup MinGW (MSYS2)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
git
wget
mingw-w64-x86_64-gcc-fortran
- name: Install fpm
shell: msys2 {0}
run: |
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir tmp
gfortran fpm.F90 -Jtmp -Itmp -static -o fpm
rm -f tmp/*.mod
- name: Run tests and demo programs (debug)
shell: msys2 {0}
run: |
gfortran --version
./fpm test --profile release -flag "-D _WIN32"
env:
FC: gfortran
TZ: UTC+04:00
- name: Run tests and demo programs (release)
shell: msys2 {0}
run: |
gfortran --version
./fpm test --profile release -flag "-D _WIN32"
env:
FC: gfortran
TZ: UTC+04:00
- name: cleanup
run: dir

View file

@ -0,0 +1,66 @@
name: ubuntu with gfortran
on: [push, pull_request]
jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest ]
include:
- os: ubuntu-latest
gcc_v: 12
env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}
TZ: UTC+04:00
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Install GFortran Linux
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bingcov gcov /usr/bin/gcov-${GCC_V}
- name: Install fpm
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir -p /home/runner/.local/bin tmp
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
gfortran fpm.F90 -Itmp -Jtmp -static -o /home/runner/.local/bin/fpm
rm -f tmp/*.mod
ls -l
- name: Display environment
run: |
#make -k -p -fNOTTHERE
echo "end" > foo.f90
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
gfortran -cpp -E -dM foo.f90
gfortran --version
fpm --version
- name: ubuntu with gfortran (debug)
run: |
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
fpm test --profile debug --verbose
- name: ubuntu with gfortran (release)
run: |
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
fpm test --profile release
# - name: Run demo programs (fpm run)
# run: fpm run --profile release
- name: cleanup Linux
run: ls -ltras

View file

@ -0,0 +1,66 @@
name: windows with gfortran
on: [push, pull_request]
jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
gcc_v: [10] # Version of GFortran we want to use.
include:
- os: windows-latest
os-arch: windows-x86_64
release-flags: --flag '--static -g -fbacktrace -O3'
exe: .exe
env:
FC: gfortran
GCC_V: ${{ matrix.gcc_v }}
TZ: UTC+04:00
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Install fpm
run: |
echo PATH %PATH%
pwd
curl https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90 --output fpm.F90
mkdir tmp
gfortran -static fpm.F90 -Itmp -Jtmp -o fpm -D_WIN32 2>&1
dir
shell: cmd
- name: Display environment
run: |
echo PATH %PATH%
pwd
uname -a
echo "end" > foo.f90
gfortran -cpp -E -dM foo.f90
fpm --version
fpm build --verbose
gfortran --version
shell: cmd
- name: tests MSWindows (debug)
run: |
fpm test --profile debug -flag "-static -D _WIN32" --verbose 2>&1
shell: cmd
- name: tests MSWindows (release)
run: |
fpm test --profile release -flag "-static -D _WIN32" --verbose 2>&1
shell: cmd
- name: cleanup MSWindows
run: dir
shell: cmd
#set PATH=%PATH%;%CD%
#make -k -p -fNOTTHERE

70
.github/workflows/test_ifx_ubuntu.yml.OFF vendored Executable file
View file

@ -0,0 +1,70 @@
name: linux with intel ifx compiler
on: [push, pull_request]
jobs:
# Build with Intel ifx toolchain
intel-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
fc: [ifx]
cc: [icc]
env:
FC: ${{ matrix.fc }}
CC: ${{ matrix.cc }}
FPM_COMPILER: ifx
TZ: UTC+04:00
APT_PACKAGES: >-
intel-oneapi-compiler-fortran
intel-oneapi-compiler-dpcpp-cpp-and-cpp
intel-oneapi-mkl-devel
asciidoctor
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Add Intel repository
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: Install Intel oneAPI compiler
run: |
sudo apt-get install ${{ env.APT_PACKAGES }}
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Install fpm
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir -p /home/runner/.local/bin tmp
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
ifx fpm.F90 -Itmp -module tmp -o /home/runner/.local/bin/fpm
ls -l
rm -fv *.mod tmp/*.mod
- name: Run Intel unit tests on Linux
run: |
printenv TZ
printenv FPM_COMPILER
printenv OMP_NUM_THREADS
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
fpm test --profile release --compiler ifx
ls -l
env:
OMP_NUM_THREADS: 2,1

70
.github/workflows/test_intel_ubuntu.yml vendored Executable file
View file

@ -0,0 +1,70 @@
name: linux with intel
on: [push, pull_request]
jobs:
# Build with Intel toolchain
intel-build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
fc: [ifort]
cc: [icc]
env:
FC: ${{ matrix.fc }}
CC: ${{ matrix.cc }}
FPM_COMPILER: ifort
TZ: UTC+04:00
APT_PACKAGES: >-
intel-oneapi-compiler-fortran
intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
intel-oneapi-mkl-devel
asciidoctor
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Add Intel repository
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
- name: Install Intel oneAPI compiler
run: |
sudo apt-get install ${{ env.APT_PACKAGES }}
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
- name: Install fpm
run: |
echo $PATH
pwd
uname -a
wget https://raw.githubusercontent.com/urbanjost/index/main/bootstrap/fpm.F90
mkdir -p /home/runner/.local/bin tmp
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
ifort fpm.F90 -Itmp -module tmp -o /home/runner/.local/bin/fpm
ls -l
rm -fv *.mod tmp/*.mod
- name: Run Intel unit tests on Linux
run: |
printenv TZ
printenv FPM_COMPILER
printenv OMP_NUM_THREADS
ulimit -c unlimited -d unlimited -f unlimited -m unlimited -s unlimited -t unlimited -v unlimited -x unlimited
fpm test --profile release --compiler ifort
ls -l
env:
OMP_NUM_THREADS: 2,1

View file

@ -44,3 +44,23 @@ Examples
hp "2 -- complex sqrt =" -> (0.00000,-1.414214)
hp -c "radians (1,pi_over_2)p ^ * degrees =" -> (1.000000,180.000000) p
```
## Build and Test with FPM
To build with fpm(1)
( as described at [Fortran Package Manager](https://github.com/fortran-lang/fpm) )
enter:
```bash
git clone https://github.com/sgeard/hp.git
cd hp
fpm test
fpm run
```
or just list it as a dependency in your fpm.toml project file.
```toml
[dependencies]
hp = { git = "https://github.com/sgeard/hp.git" }
```

View file

@ -9,10 +9,10 @@ F:= ifort
SRC := rpn_stack.f90 rpn_stack_sm.f90 linked_list.f90 amap.f90
OBJ := $(SRC:%.f90=%.o)
hp: hp.f90 $(OBJ)
$(F) -o $@ hp.f90 $(OBJ) $(F_OPTS)
hp: ../app/main.f90 $(OBJ)
$(F) -o $@ ../app/main.f90 $(OBJ) $(F_OPTS)
hp.exe: hp.f90 GNUmakefile
hp.exe: /app/main.f90 GNUmakefile
$(F) -o $@ $< $(F_OPTS)
rpn_stack_sm.o: rpn_stack_sm.f90
@ -27,8 +27,8 @@ linked_list.o: linked_list.f90
amap.o: amap.f90
$(F) -c -o $@ $< $(F_OPTS)
test_amap: test_amap.f90 amap.o
$(F) -o $@ test_amap.f90 amap.o
test_amap: ../test/test_amap.f90 amap.o
$(F) -o $@ ../test/test_amap.f90 amap.o
clean:
@rm -vf *.o *.mod *.smod *~
@ -41,8 +41,8 @@ force: veryclean
export: hp.tar
hp.tar: GNUmakefile hp.f90 $(SRC)
tar cf $@ hp.f90 $(SRC) GNUmakefile
hp.tar: GNUmakefile ../app/hp.f90 $(SRC)
tar cf $@ ../app/hp.f90 $(SRC) GNUmakefile
help:
@echo "SRC = $(SRC)"

View file

@ -177,7 +177,7 @@ contains
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 0
iomsg = ""
!iomsg = ""
write(6,'(a)', iostat=iostat, iomsg=iomsg) trim(adjustl(key%k))
end subroutine write_key_t
@ -189,7 +189,7 @@ contains
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg
iostat = 0
iomsg = ""
!iomsg = ""
write(6,'(f0.6)', iostat=iostat, iomsg=iomsg) value%v
end subroutine write_value_t
end module amap

View file

@ -153,7 +153,7 @@ contains
complex(8) :: z
character(len=:), allocatable :: str_re, str_im
iostat = 0
iomsg = ""
!iomsg = ""
z = se%zdata
if (complex_mode) then
call to_string(z%re,str_re)