diff --git a/.github/workflows/mcstas-conda-testsuite.yml b/.github/workflows/mcstas-conda-testsuite.yml index 629e2cf7c..d27ac04dd 100644 --- a/.github/workflows/mcstas-conda-testsuite.yml +++ b/.github/workflows/mcstas-conda-testsuite.yml @@ -107,8 +107,7 @@ jobs: export TMPDIR=${HOME}/tmp fi # Run the test with 2 core mpi - ${MCTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.os }}_${{ matrix.mpi }} --mpi=2 - + ${MCTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.os }}_${{ matrix.mpi }} --mpi=auto - name: 'Tar output files' id: tar-package if: always() @@ -200,31 +199,33 @@ jobs: for tgz in downloaded_artifacts/*/*.tgz; do work=$(mktemp -d) tar xzf "$tgz" -C "$work" - mv "$work"/run_test-suite/* mcstas-nightly/ - - # Linux (ubuntu-latest) is the reference platform; the label - # name itself embeds a version string and timestamp we can't - # predict, so identify it via the source artifact/tarball name - # instead of hardcoding it. - if [[ "$tgz" == *"ubuntu-latest"* ]]; then - REFLABEL=$(basename "$labeldir") - fi + artifact_name=$(basename "$(dirname "$tgz")") + + for labeldir in "$work"/run_test-suite/*/; do + if [[ "$artifact_name" == *"ubuntu-latest"* ]]; then + REFLABEL=$(basename "$labeldir") + fi + mv $labeldir mcstas-nightly/ + done + done rm -rf "$work" - done if [ -z "$REFLABEL" ]; then - echo "ERROR: could not identify the Linux/reference column (ubuntu-latest artifact missing?)" - exit 1 + echo "WARNING: could not identify the ubuntu-latest/conda reference column" + else + echo "REFLABEL=$REFLABEL" >> "$GITHUB_ENV" + echo "Reference column: $REFLABEL" fi - echo "REFLABEL=$REFLABEL" >> "$GITHUB_ENV" - echo "Reference column: $REFLABEL" - ls mcstas-nightly - - name: 'Run mcviewtest across all platform columns' id: viewtest run: | - cd "$PWD/mcstas-nightly" && mcviewtest --reflabel "$REFLABEL" --nobrowse + cd "$PWD/mcstas-nightly" + if [ -z "$REFLABEL" ]; then + mcviewtest --reflabel "$REFLABEL" --nobrowse + else + mcviewtest --reflabel --nobrowse + fi - name: 'Tar mcstas-nightly output (all platform folders + comparison table)' id: tar-package diff --git a/.github/workflows/mcxtrace-conda-testsuite.yml b/.github/workflows/mcxtrace-conda-testsuite.yml index ff0247e77..bce716a2e 100644 --- a/.github/workflows/mcxtrace-conda-testsuite.yml +++ b/.github/workflows/mcxtrace-conda-testsuite.yml @@ -107,7 +107,7 @@ jobs: export TMPDIR=${HOME}/tmp fi # Run the test with 2 core mpi - ${MXTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.os }}_${{ matrix.mpi }} --mpi=2 + ${MXTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.os }}_${{ matrix.mpi }} --mpi=auto - name: 'Tar output files' id: tar-package @@ -201,35 +201,33 @@ jobs: for tgz in downloaded_artifacts/*/*.tgz; do work=$(mktemp -d) tar xzf "$tgz" -C "$work" - labeldir=$(ls -d "$work"/run_test-suite/*/) - mv "$labeldir" mcxtrace-nightly/ - - # Linux (ubuntu-latest) is the reference platform; the label - # name itself embeds a version string and timestamp we can't - # predict, so identify it via the source artifact/tarball name - # instead of hardcoding it. - if [[ "$tgz" == *"ubuntu-latest"* ]]; then + artifact_name=$(basename "$(dirname "$tgz")") + + for labeldir in "$work"/run_test-suite/*/; do + if [[ "$artifact_name" == *"ubuntu-latest"* ]]; then REFLABEL=$(basename "$labeldir") fi + mv $labeldir mcxtrace-nightly/ + done + done rm -rf "$work" - done if [ -z "$REFLABEL" ]; then - echo "ERROR: could not identify the Linux/reference column (ubuntu-latest artifact missing?)" - exit 1 - fi - + echo "WARNING: could not identify the ubuntu-latest/conda reference column" + else echo "REFLABEL=$REFLABEL" >> "$GITHUB_ENV" echo "Reference column: $REFLABEL" - ls mcxtrace-nightly + fi - name: 'Run mxviewtest across all platform columns' id: viewtest run: | - set -e - set -u - set -x - cd "$PWD/mcxtrace-nightly" && mxviewtest --reflabel "$REFLABEL" --nobrowse + cd "$PWD/mcxtrace-nightly" + if [ -z "$REFLABEL" ]; then + mxviewtest --reflabel "$REFLABEL" --nobrowse + else + mxviewtest --reflabel --nobrowse + fi - name: 'Tar mcxtrace-nightly output (all platform folders + comparison table)' id: tar-package diff --git a/mcstas-comps/samples/PowderN.comp b/mcstas-comps/samples/PowderN.comp index 36f6baf58..81809bea1 100644 --- a/mcstas-comps/samples/PowderN.comp +++ b/mcstas-comps/samples/PowderN.comp @@ -745,7 +745,10 @@ SHARE /* check if a line_info element has been recorded already - not on OpenACC */ #ifndef OPENACC if (v >= line_info->v_min && v <= line_info->v_max && line_info->neutron_passed >= CHAR_BUF_LENGTH) { - line = (int)floor (v - line_info->v_min) * CHAR_BUF_LENGTH / (line_info->v_max - line_info->v_min); + double frac = (v - line_info->v_min) / (line_info->v_max - line_info->v_min); + line = (int)floor(frac * CHAR_BUF_LENGTH); + if (line < 0) line = 0; + if (line >= CHAR_BUF_LENGTH) line = CHAR_BUF_LENGTH - 1; Nq = line_info->xs_Nq[line]; *sum = line_info->xs_sum[line]; if (!Nq && *sum == 0) { @@ -1172,10 +1175,11 @@ TRACE if (neutrontype == 3) { /* Make coherent scattering event */ if (line_info.count > 0) { /* choose line */ - if (Nq > 1) + if (Nq > 1) { line = floor (Nq * rand01 ()); /* Select between Nq powder lines */ - else - line = 0; + if (line >= Nq) line = (int)Nq - 1; /* guard rand01()==1.0 edge case */ + } else + line = 0; if (line_info.w_v[line]) arg = line_info.q_v[line] * (1 + line_info.w_v[line] * randnorm ()) / (2.0 * v); else diff --git a/mcxtrace-comps/samples/PowderN.comp b/mcxtrace-comps/samples/PowderN.comp index 554381372..6599e9548 100644 --- a/mcxtrace-comps/samples/PowderN.comp +++ b/mcxtrace-comps/samples/PowderN.comp @@ -596,7 +596,10 @@ SHARE /* check if a line_info element has been recorded already - not on OpenACC */ #ifndef OPENACC if (k >= line_info->k_min && k <= line_info->k_max && line_info->photon_passed >= CHAR_BUF_LENGTH) { - line = (int)floor (k - line_info->k_min) * CHAR_BUF_LENGTH / (line_info->k_max - line_info->k_min); + double frac = (k - line_info->k_min) / (line_info->k_max - line_info->k_min); + line = (int)floor(frac * CHAR_BUF_LENGTH); + if (line < 0) line = 0; + if (line >= CHAR_BUF_LENGTH) line = CHAR_BUF_LENGTH - 1; Nq = line_info->xs_Nq[line]; *sum = line_info->xs_sum[line]; if (!Nq && *sum == 0) { @@ -1070,9 +1073,10 @@ TRACE if (photontype == 3) { /* Make coherent scattering event */ if (line_info.count > 0) { /* choose line */ - if (Nq > 1) + if (Nq > 1) { line = floor (Nq * rand01 ()); /* Select between Nq powder lines */ - else + if (line >= Nq) line = (int)Nq - 1; /* guard rand01()==1.0 edge case */ + } else line = 0; if (line_info.w[line]) arg = line_info.q[line] * (1 + line_info.w[line] * randnorm ()) / (2.0 * k);