Skip to content

Commit

Permalink
smoke test for NFsim runs with bash and python3 on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jul 28, 2024
1 parent 8b020bb commit b9988df
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 45 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
brew install llvm
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
source /Users/runner/.bash_profile
ln -s $(which gfortran-14) /usr/local/bin/gfortran
gcc --version
gfortran --version
Expand Down Expand Up @@ -218,7 +219,7 @@ jobs:
mkdir build
cd build
PATH="/c/Program\ Files/LLVM/bin:$PATH"
export PATH="/c/Program\ Files/LLVM/bin:$PATH"
cmake \
-G Ninja \
Expand Down Expand Up @@ -248,6 +249,9 @@ jobs:
echo "working dir is $PWD"
cd build
export PATH="/d/a/_temp/msys64/clang64/bin:$PATH"
pacman -Sy --noconfirm diffutils
ctest -VV
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
/all_solvers/*

.DS_Store

NFsim_v1.11/tests/smoke/SimID_273069657_0_.gdat
NFsim_v1.11/tests/smoke/SimID_273069657_0_.species
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ if (${OPTION_TARGET_DOCS})
endif()

if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
elseif (MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines")
endif()

Expand Down
78 changes: 39 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
FROM ubuntu:20.04 as build
FROM ubuntu:22.04 as build

RUN apt-get -y update && apt-get install -y apt-utils && \
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \
libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python

#
# build PETSc with mpich for static linking
#
RUN mkdir /usr/local/petsc && \
cd /usr/local/petsc && \
wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.7.tar.gz && \
tar xzf petsc-3.7.7.tar.gz && \
cd petsc-3.7.7 && \
./configure --with-shared-libraries=0 --download-fblaslapack=1 --with-debugging=1 --download-mpich && \
make PETSC_DIR=/usr/local/petsc/petsc-3.7.7 PETSC_ARCH=arch-linux2-c-debug all

ENV PETSC_DIR=/usr/local/petsc/petsc-3.7.7 \
PETSC_ARCH=arch-linux2-c-debug
libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python3

##
## build PETSc with mpich for static linking
##
#RUN mkdir /usr/local/petsc && \
# cd /usr/local/petsc && \
# wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.7.tar.gz && \
# tar xzf petsc-3.7.7.tar.gz && \
# cd petsc-3.7.7 && \
# ./configure --with-shared-libraries=0 --download-fblaslapack=1 --with-debugging=1 --download-mpich && \
# make PETSC_DIR=/usr/local/petsc/petsc-3.7.7 PETSC_ARCH=arch-linux2-c-debug all

#ENV PETSC_DIR=/usr/local/petsc/petsc-3.7.7 \
# PETSC_ARCH=arch-linux2-c-debug

COPY . /vcellroot

Expand All @@ -41,30 +41,30 @@ RUN /usr/bin/cmake \
-DOPTION_TARGET_HY3S_SOLVERS=OFF \
.. && \
make && \
ctest
ctest -VV

##
## build FiniteVolume with PETSc (FiniteVolume_PETSc_x64)
##
#RUN mkdir -p /vcellroot/build_PETSc/bin
#WORKDIR /vcellroot/build_PETSc
#
# build FiniteVolume with PETSc (FiniteVolume_PETSc_x64)
#
RUN mkdir -p /vcellroot/build_PETSc/bin
WORKDIR /vcellroot/build_PETSc

RUN /usr/bin/cmake \
-DOPTION_TARGET_MESSAGING=ON \
-DOPTION_TARGET_PARALLEL=OFF \
-DOPTION_TARGET_PETSC=ON \
-DOPTION_TARGET_CHOMBO2D_SOLVER=OFF \
-DOPTION_TARGET_CHOMBO3D_SOLVER=OFF \
-DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
-DOPTION_TARGET_FV_SOLVER=ON \
-DOPTION_TARGET_STOCHASTIC_SOLVER=OFF \
-DOPTION_TARGET_NFSIM_SOLVER=OFF \
-DOPTION_TARGET_MOVINGBOUNDARY_SOLVER=OFF \
-DOPTION_TARGET_SUNDIALS_SOLVER=OFF \
-DOPTION_TARGET_HY3S_SOLVERS=OFF \
.. && \
make && \
ctest
#RUN /usr/bin/cmake \
# -DOPTION_TARGET_MESSAGING=ON \
# -DOPTION_TARGET_PARALLEL=OFF \
# -DOPTION_TARGET_PETSC=ON \
# -DOPTION_TARGET_CHOMBO2D_SOLVER=OFF \
# -DOPTION_TARGET_CHOMBO3D_SOLVER=OFF \
# -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
# -DOPTION_TARGET_FV_SOLVER=ON \
# -DOPTION_TARGET_STOCHASTIC_SOLVER=OFF \
# -DOPTION_TARGET_NFSIM_SOLVER=OFF \
# -DOPTION_TARGET_MOVINGBOUNDARY_SOLVER=OFF \
# -DOPTION_TARGET_SUNDIALS_SOLVER=OFF \
# -DOPTION_TARGET_HY3S_SOLVERS=OFF \
# .. && \
# make && \
# ctest


FROM eclipse-temurin:17 as jre-build
Expand Down Expand Up @@ -96,7 +96,7 @@ RUN apt-get install -qq -y -o=Dpkg::Use-Pty=0 gcc gfortran zlib1g \
libhdf5-103 libhdf5-cpp-103 libcurl4-openssl-dev zip

COPY --from=build /vcellroot/build/bin /vcellbin
COPY --from=build /vcellroot/build_PETSc/bin/FiniteVolume_PETSc_x64 /vcellbin/
#COPY --from=build /vcellroot/build_PETSc/bin/FiniteVolume_PETSc_x64 /vcellbin/
WORKDIR /vcellbin
ENV PATH=/vcellbin:$PATH

19 changes: 18 additions & 1 deletion NFsim_v1.11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,27 @@ endif (UNIX)
set(exe_target NFsim)
if (ARCH_64bit)
set(exe_target ${exe_target}_x64)
endif (ARCH_64bit)
endif (ARCH_64bit)

enable_testing()

add_executable(${exe_target} ${SRC_FILES})
target_link_libraries(${exe_target} vcommons vcellmessaging)

if (MINGW)
set(test_nfsim_exe ${CMAKE_BINARY_DIR}/bin/${exe_target}.exe)
set(python_cmd py)
else (MINGW)
set(test_nfsim_exe ${CMAKE_BINARY_DIR}/bin/${exe_target})
set(python_cmd python3)
endif (MINGW)
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR}/tests/smoke)

# smoke test as a python script
add_test(NAME ${exe_target}_smoke_python COMMAND ${python_cmd} ${test_dir}/smoke.py ${test_nfsim_exe} WORKING_DIRECTORY ${test_dir})

# smoke test as a bash script
add_test(NAME ${exe_target}_smoke_bash COMMAND bash -c "${test_dir}/smoke.sh ${test_nfsim_exe}" WORKING_DIRECTORY ${test_dir})

install(TARGETS ${exe_target} RUNTIME DESTINATION ${OPTION_EXE_DIRECTORY})

12 changes: 12 additions & 0 deletions NFsim_v1.11/tests/smoke/SimID_273069657_0_.gdat.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# time O0_MT0_tot_Count O0_MT1_tot_Count O0_MT2_tot_Count O0_MT3_tot_Count O0_MT4_tot_Count s0_Count s1_Count s2_Count s3_Count s4_Count
0.00000000e+00 6.02000000e+02 9.03000000e+02 1.20400000e+03 0.00000000e+00 0.00000000e+00 6.02000000e+02 9.03000000e+02 1.20400000e+03 0.00000000e+00 0.00000000e+00
1.00000000e-01 5.37000000e+02 9.68000000e+02 1.13900000e+03 0.00000000e+00 0.00000000e+00 5.37000000e+02 9.68000000e+02 1.13900000e+03 0.00000000e+00 0.00000000e+00
2.00000000e-01 5.24000000e+02 9.81000000e+02 1.12600000e+03 0.00000000e+00 0.00000000e+00 5.24000000e+02 9.81000000e+02 1.12600000e+03 0.00000000e+00 0.00000000e+00
3.00000000e-01 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00
4.00000000e-01 5.30000000e+02 9.75000000e+02 1.13200000e+03 0.00000000e+00 0.00000000e+00 5.30000000e+02 9.75000000e+02 1.13200000e+03 0.00000000e+00 0.00000000e+00
5.00000000e-01 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00
6.00000000e-01 5.21000000e+02 9.84000000e+02 1.12300000e+03 0.00000000e+00 0.00000000e+00 5.21000000e+02 9.84000000e+02 1.12300000e+03 0.00000000e+00 0.00000000e+00
7.00000000e-01 5.20000000e+02 9.85000000e+02 1.12200000e+03 0.00000000e+00 0.00000000e+00 5.20000000e+02 9.85000000e+02 1.12200000e+03 0.00000000e+00 0.00000000e+00
8.00000000e-01 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00
9.00000000e-01 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00
1.00000000e+00 5.33000000e+02 9.72000000e+02 1.13500000e+03 0.00000000e+00 0.00000000e+00 5.33000000e+02 9.72000000e+02 1.13500000e+03 0.00000000e+00 0.00000000e+00
1 change: 1 addition & 0 deletions NFsim_v1.11/tests/smoke/SimID_273069657_0_.nfsimInput

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions NFsim_v1.11/tests/smoke/SimID_273069657_0_.species.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# nfsim generated species list for system: 'nameless'
# warning! this feature is not yet fully tested!
MT0(AAA~c0,AAB~0) 532
MT1(AAA~c0,AAB~0) 973
MT2(AAA~c0,AAB~0) 1134
69 changes: 69 additions & 0 deletions NFsim_v1.11/tests/smoke/smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3

import os
import posixpath
import subprocess
import sys

# get the directory of this script
test_dir = os.path.dirname(os.path.realpath(__file__))
# in the path replace \ with /, D:\ with /d/
test_dir = test_dir.replace("\\", "/")
# tell os.path.join to use / as the path separator
os.path.sep = "/"
exe = sys.argv[1]

print(f"test_dir: {test_dir}")
print(f"exe: {exe}")

input_file = posixpath.join(test_dir, "SimID_273069657_0_.nfsimInput")
output = posixpath.join(test_dir, "SimID_273069657_0_.gdat")
expected_output = posixpath.join(test_dir, "SimID_273069657_0_.gdat.expected")
species = posixpath.join(test_dir, "SimID_273069657_0_.species")
expected_species = posixpath.join(test_dir, "SimID_273069657_0_.species.expected")

if not posixpath.exists(exe):
print(f"NFsim executable {exe} not found. Exiting...")
sys.exit(1)

if not posixpath.exists(input_file):
print(f"Input file {input_file} not found. Exiting...")
sys.exit(1)

if not posixpath.exists(expected_output):
print(f"Expected output file {expected_output} not found. Exiting...")
sys.exit(1)

if not posixpath.exists(expected_species):
print(f"Expected species file {expected_species} not found. Exiting...")
sys.exit(1)

command = [exe, "-seed", "505790288", "-vcell", "-xml", input_file, "-o", output, "-sim", "1.0", "-ss", species, "-oStep", "20", "-notf", "-utl", "1000", "-cb", "-pcmatch", "-tid", "0"]
print(" ".join(command))

try:
subprocess.check_call(command)
except subprocess.CalledProcessError:
print("NFsim failed to run. Exiting...")
sys.exit(1)

# verify that the output files exist
if not os.path.isfile(output):
print(f"Output file {output} not found. Exiting...")
sys.exit(1)

if not os.path.isfile(species):
print(f"Species file {species} not found. Exiting...")
sys.exit(1)

# verify that the output files match the expected output files
if open(output).read() != open(expected_output).read():
print(f"Output file {output} does not match expected output {expected_output}. Exiting...")
sys.exit(1)

if open(species).read() != open(expected_species).read():
print(f"Species file {species} does not match expected species {expected_species}. Exiting...")
sys.exit(1)

print("NFsim solver completed and solution matched expected output. Exiting...")
sys.exit(0)
62 changes: 62 additions & 0 deletions NFsim_v1.11/tests/smoke/smoke.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
set -e
EXE=$1

echo "Running NFsim solver with test2.sh $EXE"

# get the directory of this script
TEST_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

INPUT="${TEST_DIR}/SimID_273069657_0_.nfsimInput"
OUTPUT="${TEST_DIR}/SimID_273069657_0_.gdat"
EXPECTED_OUTPUT="${TEST_DIR}/SimID_273069657_0_.gdat.expected"
SPECIES="${TEST_DIR}/SimID_273069657_0_.species"
EXPECTED_SPECIES="${TEST_DIR}/SimID_273069657_0_.species.expected"

if [ ! -f $EXE ]; then
echo "NFsim executable $EXE not found. Exiting..."
exit 1
fi
if [ ! -f $INPUT ]; then
echo "Input file $INPUT not found. Exiting..."
exit 1
fi
if [ ! -f $EXPECTED_OUTPUT ]; then
echo "Expected output file $EXPECTED_OUTPUT not found. Exiting..."
exit 1
fi
if [ ! -f $EXPECTED_SPECIES ]; then
echo "Expected species file $EXPECTED_SPECIES not found. Exiting..."
exit 1
fi


command="$EXE -seed 505790288 -vcell -xml $INPUT -o $OUTPUT -sim 1.0 -ss $SPECIES -oStep 20 -notf -utl 1000 -cb -pcmatch -tid 0"
echo $command
if ! $command; then
echo "NFsim failed to run. Exiting..."
exit 1
fi

# verify that the output files exist
if [ ! -f $OUTPUT ]; then
echo "Output file $OUTPUT not found. Exiting..."
exit 1
fi
if [ ! -f $SPECIES ]; then
echo "Species file $SPECIES not found. Exiting..."
exit 1
fi

# verify that the output files match the expected output files
if ! diff $OUTPUT $EXPECTED_OUTPUT; then
echo "Output file $OUTPUT does not match expected output $EXPECTED_OUTPUT. Exiting..."
exit 1
fi
if ! diff $SPECIES $EXPECTED_SPECIES; then
echo "Species file $SPECIES does not match expected species $EXPECTED_SPECIES. Exiting..."
exit 1
fi

echo "NFsim solver complted and solution matched expected output. Exiting..."
exit 0
4 changes: 2 additions & 2 deletions VCellMessaging/include/VCELL/SimulationMessaging.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _SIMULATIONMESSAGING_H_
#define _SIMULATIONMESSAGING_H_

#include <deque>
#include <vector>
#ifdef USE_MESSAGING
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -145,7 +145,7 @@ class SimulationMessaging
private:
SimulationMessaging();
static SimulationMessaging *m_inst;
std::deque<WorkerEvent *> events;
std::vector<WorkerEvent *> events;
int workerEventOutputMode;

void sendStatus();
Expand Down
5 changes: 4 additions & 1 deletion VCellMessaging/src/SimulationMessaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ void SimulationMessaging::sendStatus() {
WorkerEventLocker locker(*this);
if (events.size( ) > 0 ) {
workerEvent = events.front( );
events.pop_front( );
if (!events.empty())
{
events.erase(events.begin());
}
}
else {
return;
Expand Down

0 comments on commit b9988df

Please sign in to comment.