Skip to content

Commit

Permalink
Updating code environment (#27)
Browse files Browse the repository at this point in the history
* fortran compiler flag change due to gcc>=10 argument mismatch error.

* docker container with github container registry

* docker file path change

* ci test dependency

* ubuntu version latest

* back to dockerhub

* test without canceling action

* ubuntu 18 needs update

* remove python2

* unit tests bug fix

* optimization ci test
  • Loading branch information
dreamer2368 authored Dec 16, 2024
1 parent ce250f8 commit 5a24cd2
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 20 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: docker-image
on:
workflow_call:

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: dreamer2368/magudi/magudi_env
DOCKERPATH: docker

jobs:
docker-ci:
runs-on: ubuntu-latest
name: "docker env"
env:
DOCKERPATH: docker
steps:
- name: test command
run: echo "docker-ci command"
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: Ana06/[email protected]
id: files
- name: DockerPATH configuration
run: echo "DOCKERPATH=$DOCKERPATH"
- name: DockerPATH - check if files in docker path changed
if: contains(steps.files.outputs.all,env.DOCKERPATH) || contains(steps.files.outputs.all,'docker.yml')
run: |
echo "CI container needs rebuilding..."
echo "CI_NEEDS_REBUILD=true" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
if: env.CI_NEEDS_REBUILD
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
if: env.CI_NEEDS_REBUILD
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=sha
flavor: latest=true
- name: Build Container motd
if: env.CI_NEEDS_REBUILD
run: |
echo "#!/bin/bash" > ${{env.DOCKERPATH}}/motd.sh
echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo magudi_env/CI Development Container" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo \"Revision: `echo ${GITHUB_SHA} | cut -c1-8`\"" >> ${{env.DOCKERPATH}}/motd.sh
echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh
chmod 755 ${{env.DOCKERPATH}}/motd.sh
cat ${{env.DOCKERPATH}}/motd.sh
- name: Docker Image - Build and push
if: env.CI_NEEDS_REBUILD
uses: docker/build-push-action@v5
with:
push: true
context: ${{ env.DOCKERPATH }}
tags: ${{ steps.meta.outputs.tags }}
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
20 changes: 14 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ on:
pull_request:

jobs:
docker-image:
uses: ./.github/workflows/docker.yml
magudi-unit:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: [docker-image]
container:
image: dreamer2368/magudi_env:latest
image: ghcr.io/dreamer2368/magudi/magudi_env:latest
# image: dreamer2368/magudi_env:latest
options: --user 1001 --privileged
name: CPU-test
steps:
Expand All @@ -34,9 +38,11 @@ jobs:
cd build
CTEST_OUTPUT_ON_FAILURE=TRUE make test
optim-grad-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# needs: [docker-image]
container:
image: dreamer2368/magudi_env:latest
image: ghcr.io/dreamer2368/magudi/magudi_env:latest
# image: dreamer2368/magudi_env:latest
options: --user 1001 --privileged
name: Optimization-gradient-test
steps:
Expand All @@ -58,9 +64,11 @@ jobs:
- name: Multi-point optimization gradient accuracy
run: bash .github/workflows/optim_grad_test.sh
optim-test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# needs: [docker-image]
container:
image: dreamer2368/magudi_env:latest
image: ghcr.io/dreamer2368/magudi/magudi_env:latest
# image: dreamer2368/magudi_env:latest
options: --user 1001 --privileged
name: Optimization-test
steps:
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ endif()
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -show COMMAND awk "{print $1}" OUTPUT_VARIABLE CMAKE_Fortran_COMPILER_PATH)
execute_process(COMMAND basename ${CMAKE_Fortran_COMPILER_PATH} OUTPUT_VARIABLE CMAKE_Fortran_COMPILER_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)

if(CMAKE_Fortran_COMPILER_NAME STREQUAL "gfortran" OR CMAKE_Fortran_COMPILER_NAME STREQUAL "powerpc64-bgq-linux-gfortran")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-form -fmodule-private -fimplicit-none -cpp -pedantic-errors -std=f2008")
if(CMAKE_Fortran_COMPILER_NAME STREQUAL "gfortran" OR CMAKE_Fortran_COMPILER_NAME STREQUAL "powerpc64-bgq-linux-gfortran")
### For GCC compiler < 10
# set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-form -fmodule-private -fimplicit-none -cpp -pedantic-errors -std=f2008")
### For GCC compiler >= 10
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-form -fmodule-private -fimplicit-none -cpp -fallow-argument-mismatch -std=f2008")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -fbacktrace -Wall -Wextra -Waliasing -Wno-unused-dummy-argument -Wno-unused-parameter -ffree-line-length-none -fall-intrinsics -fcheck=all -g")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ftree-vectorize -ffast-math -funroll-loops")
elseif(CMAKE_Fortran_COMPILER_NAME STREQUAL "ifort")
Expand All @@ -74,7 +77,8 @@ set(CMAKE_Fortran_FORMAT "FREE")
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)

if(NOT CMAKE_C_COMPILER_ID STREQUAL "XL")
set(CMAKE_C_FLAGS_DEBUG "-std=c89 -pedantic-errors")
# set(CMAKE_C_FLAGS_DEBUG "-std=c89 -pedantic-errors")
set(CMAKE_C_FLAGS_DEBUG "-std=c89")
endif()

configure_file(${PROJECT_SOURCE_DIR}/include/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:22.04

ENV USERNAME=test

Expand All @@ -16,19 +16,18 @@ WORKDIR /home/$USERNAME
RUN sudo apt-get install -yq git
RUN sudo apt-get install -yq make cmake gcc gfortran libmpich-dev
RUN sudo apt-get install -yq vim
RUN sudo apt-get install -yq python python3
RUN sudo apt-get install -yq python3-pip
RUN sudo apt-get install -yq curl
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
RUN sudo python2 get-pip.py
RUN sudo apt-get install -yq python3 python3-pip
# RUN sudo apt-get install -yq curl
# RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
# RUN sudo python2 get-pip.py
RUN sudo apt-get install -yq git-lfs
RUN sudo apt-get install -yq valgrind
RUN sudo apt-get install -yq hdf5-tools

RUN echo "numpy" >> requirements.txt
RUN echo "scipy" >> requirements.txt
RUN cp requirements.txt requirements.2.txt
RUN sudo pip install -r ./requirements.2.txt
# RUN cp requirements.txt requirements.2.txt
# RUN sudo pip install -r ./requirements.2.txt

RUN echo "argparse" >> requirements.txt
RUN echo "tables" >> requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion test/adjoint_relation/full_rhs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exampleDir="AcousticMonopole"
cp -r ../../examples/${exampleDir} ./
cp ../../utils/python/plot3dnasa.py ./${exampleDir}
cd ${exampleDir}
python2 config.py
python3 config.py
mpirun -n 2 $1/full_rhs
if [ $? -eq 0 ]; then
cd ..
Expand Down
1 change: 1 addition & 0 deletions test/boundary_operator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ program boundary_operator

call A%cleanup()

call cleanupErrorHandler()
call MPI_Finalize(ierror)
if (.not. success) stop -1
stop 0
Expand Down
2 changes: 1 addition & 1 deletion test/linearized_relation/full_rhs_linearized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exampleDir="AcousticMonopole"
cp -r ../../examples/${exampleDir} ./
cp ../../utils/python/plot3dnasa.py ./${exampleDir}
cd ${exampleDir}
python2 config.py
python3 config.py
mpirun -n 2 $1/full_rhs_linearized
if [ $? -eq 0 ]; then
cd ..
Expand Down
10 changes: 9 additions & 1 deletion utils/python/plot3dnasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
'cartesian_grid', 'cubic_bspline_support', 'tanh_support',
'find_extents']

# scipy.signal.cubic is deprecated after scipy>=1.11.0.
# equivalent function
def cubic(x):
from scipy.interpolate import BSpline
out = BSpline.basis_element([-2, -1, 0, 1, 2])(x)
out[(x < -2) | (x > 2)] = 0.0
return out

def fdcoeff(stencil, order=1):
from scipy.linalg import solve
from scipy.special import gamma
Expand Down Expand Up @@ -769,7 +777,7 @@ def cartesian_grid(filename, block_index=0):
return x, y, z

def cubic_bspline_support(x, x_min, x_max, strict=True):
from scipy.signal import cubic
# from scipy.signal import cubic
if x.max() < x_min or x.min() > x_max:
return np.zeros_like(x)
if strict:
Expand Down

0 comments on commit 5a24cd2

Please sign in to comment.