diff --git a/.github/workflows/mcstas-basictest.yml b/.github/workflows/mcstas-basictest.yml index e1f96904b..299598b57 100644 --- a/.github/workflows/mcstas-basictest.yml +++ b/.github/workflows/mcstas-basictest.yml @@ -19,14 +19,15 @@ jobs: matrix: include: # --- built from source via cmake --- - - { method: source, os: ubuntu-24.04, CC: gcc-13, CXX: g++-13, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } - - { method: source, os: ubuntu-24.04, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } + - { method: source, os: ubuntu-24.04, CC: gcc-13, CXX: g++-13, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} + - { method: source, os: ubuntu-24.04, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} # --- built via conda --- - - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } - - { method: conda, os: macos-latest, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: '2' } - - { method: conda, os: windows-latest, CC: cl.exe, CXX: cl.exe, python: "3.13", mpi: 'msmpi', nmpi: 'auto' } + - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} + - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'antlr'} + - { method: conda, os: macos-latest, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: '2', cogen: 'classic'} + - { method: conda, os: windows-latest, CC: cl.exe, CXX: cl.exe, python: "3.13", mpi: 'msmpi', nmpi: 'auto', cogen: 'classic'} - name: ${{ matrix.os }}.${{ matrix.method }}.${{ matrix.CC || 'default' }}.${{ matrix.mpi }} + name: ${{ matrix.os }}.${{ matrix.method }}.${{ matrix.cogen }}.${{ matrix.CC || 'default' }}.${{ matrix.mpi }} runs-on: ${{ matrix.os }} env: CC: ${{ matrix.CC }} @@ -264,6 +265,24 @@ jobs: run: | ./src/devel/bin/mccode-build-conda -m mcstas -s $PWD/src -b $PWD/build_mcstas + - name: Setup mcstas-antlr + id: setup-mcstas-antlr + if: matrix.cogen == 'antlr' + continue-on-error: true + run: | + # Cache checkout src/ with mccode-antlr + if [ "${{ matrix.cogen }}" == "antlr" ]; + then + # Set up config file to use mcstas-antlr + MCCODE_CONFIG=`mcrun --write-user-config | cut -f4 -d\ ` + sed -i.bak s+\"MCCOGEN\"\:\ \"mcstas\",+\"MCCOGEN\"\:\ \"mcstas-antlr\ -I\$\{CONDA_PREFIX\}/share/mcstas/resources\",+g ${MCCODE_CONFIG} + grep -H COGEN ${MCCODE_CONFIG} + MCCODEANTLR_FLAGS__NEXUS=`grep NEXUSFLAGS ${MCCODE_CONFIG} |cut -f4 -d\"` + echo "MCCODEANTLR_FLAGS__NEXUS=${MCCODEANTLR_FLAGS__NEXUS}" >> "$GITHUB_ENV" + # Pre-poulate mccode-antlr cache + mccode-antlr cache populate --from-path src/ --flavor mcstas + fi + - name: Validate build output (conda) id: build-validation if: always() && matrix.method == 'conda' @@ -327,7 +346,7 @@ jobs: fi test -n "$(command -v mcstas${EXESUFFIX})" mcstas${EXESUFFIX} --version - mctest${SUFFIX} --instr=Test_RNG_rand01 --testdir=run_rngtest --suffix=${{ matrix.method }} --uid=${RUNNER_TRACKING_ID} + mctest${SUFFIX} --instr=Test_RNG_rand01 --testdir=run_rngtest --suffix=${{ matrix.cogen }}_${{ matrix.method }} --uid=${RUNNER_TRACKING_ID} export SUM=`find run_rngtest -name rngout.dat | xargs -n1 grep -v \# | ${MD5SUM} | cut -f1 -d\ ` export EXPECTED="f192ce4609e2225bf9d42ce9c5fa5a86" if [ "${EXPECTED}" == "${SUM}" ]; @@ -355,8 +374,8 @@ jobs: fi test -n "$(command -v mcstas${EXESUFFIX})" mcstas${EXESUFFIX} --version - mctest${SUFFIX} --instr=BNL_H8,ISIS_CRISP,templateSANS_Mantid,NCrystal_example,ESS_BEER_MCPL,Test_MCPL_input,Test_MCPL_output,Test_KDSource --testdir=run_basictests --suffix=${{ matrix.method }} --uid=${RUNNER_TRACKING_ID} - mctest${SUFFIX} --mpi=${{ matrix.nmpi }} --instr=BNL_H8,ISIS_CRISP,templateSANS_Mantid,NCrystal_example,ESS_BEER_MCPL,Test_MCPL_input,Test_MCPL_output,Test_KDSource --testdir=run_basictests --suffix=${{ matrix.method }}_${{ matrix.mpi }} --uid=${RUNNER_TRACKING_ID} + mctest${SUFFIX} --instr=BNL_H8,ISIS_CRISP,templateSANS_Mantid,NCrystal_example,ESS_BEER_MCPL,Test_MCPL_input,Test_MCPL_output,Test_KDSource --testdir=run_basictests --suffix=${{ matrix.cogen }}_${{ matrix.method }} --uid=${RUNNER_TRACKING_ID} + mctest${SUFFIX} --mpi=${{ matrix.nmpi }} --instr=BNL_H8,ISIS_CRISP,templateSANS_Mantid,NCrystal_example,ESS_BEER_MCPL,Test_MCPL_input,Test_MCPL_output,Test_KDSource --testdir=run_basictests --suffix=${{ matrix.cogen }}_${{ matrix.method }}_${{ matrix.mpi }} --uid=${RUNNER_TRACKING_ID} - name: Check for modified instruments id: instr-test @@ -412,7 +431,7 @@ jobs: NUMMATCH=`find src/mcstas-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l` if [ "$NUMMATCH" -gt "0" ]; then - ${MCTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir run_mctest --comp=${comp} --suffix=CHANGES_${comp}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MCTEST_EXECUTABLE} failed with exit code $?"; exit 1; } + ${MCTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir run_mctest --comp=${comp} --suffix=${{ matrix.cogen }}_CHANGES_${comp}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MCTEST_EXECUTABLE} failed with exit code $?"; exit 1; } else echo No matching tests found fi @@ -441,7 +460,7 @@ jobs: export SCOPE=" " fi mkdir -p run_mctest && cd run_mctest - ${MCTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MCTEST_EXECUTABLE} failed with exit code $?"; exit 1; } + ${MCTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.cogen }}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MCTEST_EXECUTABLE} failed with exit code $?"; exit 1; } ${MCVIEWTEST_EXECUTABLE} --nobrowse $PWD fi @@ -454,15 +473,15 @@ jobs: set -x # Clear out binaries from sim dir and tar up artifact ls | grep run_ | xargs -n1 ./src/devel/bin/mccode-simdir-cleanfiles -d - tar cvfz mcstas-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_* + tar cvfz mmcstas-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload uses: actions/upload-artifact@v6 if: always() with: - name: mcstas-artefacts-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} - path: "mcstas-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz" + name: mcstas-artefacts-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} + path: "mmcstas-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz" - name: Setup tmate session for manual debugging uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/mcstas-conda-testsuite.yml b/.github/workflows/mcstas-conda-testsuite.yml index 0ecf9039a..033428b6c 100644 --- a/.github/workflows/mcstas-conda-testsuite.yml +++ b/.github/workflows/mcstas-conda-testsuite.yml @@ -16,11 +16,12 @@ jobs: fail-fast: false matrix: include: - - { os: ubuntu-latest, mpi: 'openmpi', nmpi: 'auto' } - - { os: macos-latest, mpi: 'openmpi', nmpi: '2' } - - { os: windows-latest, mpi: 'msmpi', nmpi: 'auto' } + - { os: ubuntu-latest, mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} + - { os: ubuntu-latest, mpi: 'openmpi', nmpi: 'auto', cogen: 'antlr'} + - { os: macos-latest, mpi: 'openmpi', nmpi: '2', cogen: 'classic'} + - { os: windows-latest, mpi: 'msmpi', nmpi: 'auto', cogen: 'classic'} - name: ${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite + name: ${{ matrix.os }}.${{ matrix.mpi }}.${{ matrix.cogen }}.conda-testsuite runs-on: ${{ matrix.os }} defaults: run: @@ -60,6 +61,24 @@ jobs: run: | ./src/devel/bin/mccode-build-conda -m mcstas -s $PWD/src -b $PWD/build_mcstas + - name: Setup mcstas-antlr + id: setup-mcstas-antlr + if: matrix.cogen == 'antlr' + continue-on-error: true + run: | + # Cache checkout src/ with mccode-antlr + if [ "${{ matrix.cogen }}" == "antlr" ]; + then + # Set up config file to use mcstas-antlr + MCCODE_CONFIG=`mcrun --write-user-config | cut -f4 -d\ ` + sed -i.bak s+\"MCCOGEN\"\:\ \"mcstas\",+\"MCCOGEN\"\:\ \"mcstas-antlr\ -I\$\{CONDA_PREFIX\}/share/mcstas/resources\",+g ${MCCODE_CONFIG} + grep -H COGEN ${MCCODE_CONFIG} + MCCODEANTLR_FLAGS__NEXUS=`grep NEXUSFLAGS ${MCCODE_CONFIG} |cut -f4 -d\"` + echo "MCCODEANTLR_FLAGS__NEXUS=${MCCODEANTLR_FLAGS__NEXUS}" >> "$GITHUB_ENV" + # Pre-poulate mccode-antlr cache + mccode-antlr cache populate --from-path src/ --flavor mcstas + fi + - name: Validate build output id: build-validation if: always() @@ -107,7 +126,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=${{ matrix.nmpi }} --uid=${RUNNER_TRACKING_ID} + ${MCTEST_EXECUTABLE} --verbose --testdir $PWD --suffix ${{ matrix.cogen }}_${{ matrix.os }}_${{ matrix.mpi }} --mpi=${{ matrix.nmpi }} --uid=${RUNNER_TRACKING_ID} - name: 'Tar output files' id: tar-package if: always() @@ -117,15 +136,15 @@ jobs: set -x # Clear out binaries from sim dir and tar up artifact ls | grep run_ | xargs -n1 ./src/devel/bin/mccode-simdir-cleanfiles -d - tar cvfz mcstas-${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite_output.tgz run_test-suite + tar cvfz mcstas-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite_output.tgz run_test-suite - name: 'Upload Artifact' id: tar-upload uses: actions/upload-artifact@v6 if: always() with: - name: mcstas-artefacts-${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite - path: "mcstas-${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite_output.tgz" + name: mcstas-artefacts-${{ matrix.os }}.${{ matrix.cogen }}.${{ matrix.mpi }}.conda-testsuite + path: "mcstas-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.mpi }}.conda-testsuite_output.tgz" - name: Setup tmate session for manual debugging uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/mcxtrace-basictest.yml b/.github/workflows/mcxtrace-basictest.yml index ba3f47e57..28716ad0a 100644 --- a/.github/workflows/mcxtrace-basictest.yml +++ b/.github/workflows/mcxtrace-basictest.yml @@ -19,14 +19,15 @@ jobs: matrix: include: # --- built from source via cmake --- - - { method: source, os: ubuntu-24.04, CC: gcc-13, CXX: g++-13, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } - - { method: source, os: ubuntu-24.04, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } + - { method: source, os: ubuntu-24.04, CC: gcc-13, CXX: g++-13, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} + - { method: source, os: ubuntu-24.04, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} # --- built via conda --- - - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto' } - - { method: conda, os: macos-latest, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: '2' } - - { method: conda, os: windows-latest, CC: cl.exe, CXX: cl.exe, python: "3.13", mpi: 'msmpi', nmpi: 'auto' } + - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'classic'} + # - { method: conda, os: ubuntu-latest, CC: gcc, CXX: g++, python: '3.13', mpi: 'openmpi', nmpi: 'auto', cogen: 'antlr'} + - { method: conda, os: macos-latest, CC: clang, CXX: clang++, python: '3.13', mpi: 'openmpi', nmpi: '2', cogen: 'classic'} + - { method: conda, os: windows-latest, CC: cl.exe, CXX: cl.exe, python: "3.13", mpi: 'msmpi', nmpi: 'auto', cogen: 'classic'} - name: ${{ matrix.os }}.${{ matrix.method }}.${{ matrix.CC || 'default' }}.${{ matrix.mpi }} + name: ${{ matrix.os }}.${{ matrix.method }}.${{ matrix.cogen }}.${{ matrix.CC || 'default' }}.${{ matrix.mpi }} runs-on: ${{ matrix.os }} env: CC: ${{ matrix.CC }} @@ -271,6 +272,24 @@ jobs: run: | ./src/devel/bin/mccode-build-conda -m mcxtrace -s $PWD/src -b $PWD/build_mcxtrace + - name: Setup mcxtrace-antlr + id: setup-mcxtrace-antlr + if: matrix.cogen == 'antlr' + continue-on-error: true + run: | + # Cache checkout src/ with mccode-antlr + if [ "${{ matrix.cogen }}" == "antlr" ]; + then + # Set up config file to use mcxtrace-antlr + MCCODE_CONFIG=`mxrun --write-user-config | cut -f4 -d\ ` + sed -i.bak s+\"MCCOGEN\"\:\ \"mcxtrace\",+\"MCCOGEN\"\:\ \"mcxtrace-antlr\ -I\$\{CONDA_PREFIX\}/share/mcxtrace/resources\",+g ${MCCODE_CONFIG} + grep -H COGEN ${MCCODE_CONFIG} + MCCODEANTLR_FLAGS__NEXUS=`grep NEXUSFLAGS ${MCCODE_CONFIG} |cut -f4 -d\"` + echo "MCCODEANTLR_FLAGS__NEXUS=${MCCODEANTLR_FLAGS__NEXUS}" >> "$GITHUB_ENV" + # Pre-poulate mccode-antlr cache + mccode-antlr cache populate --from-path src/ --flavor mcxtrace + fi + - name: Validate build output (conda) id: build-validation if: always() && matrix.method == 'conda' @@ -363,7 +382,7 @@ jobs: test -n "$(command -v mcxtrace${EXESUFFIX})" mcxtrace${EXESUFFIX} --version mxtest${SUFFIX} --instr=JJ_SAXS,ESRF_BM29,Test_MCPL_input,Test_MCPL_output,Test_Absorption --testdir=run_basictests --suffix=${{ matrix.method }} --uid=${RUNNER_TRACKING_ID} - mxtest${SUFFIX} --mpi=${{ matrix.nmpi }} --instr=JJ_SAXS,ESRF_BM29,Test_MCPL_input,Test_MCPL_output,Test_Absorption --testdir=run_basictests --suffix=${{ matrix.method }}_${{ matrix.mpi }} --uid=${RUNNER_TRACKING_ID} + mxtest${SUFFIX} --mpi=${{ matrix.nmpi }} --instr=JJ_SAXS,ESRF_BM29,Test_MCPL_input,Test_MCPL_output,Test_Absorption --testdir=run_basictests --suffix=${{ matrix.cogen }}_${{ matrix.method }}_${{ matrix.mpi }} --uid=${RUNNER_TRACKING_ID} - name: Check for modified instruments id: instr-test @@ -419,7 +438,7 @@ jobs: NUMMATCH=`find src/mcxtrace-comps -name \*.instr -exec grep -H ${comp} \{\} \; | cut -f1 -d: | sort | uniq | wc -l` if [ "$NUMMATCH" -gt "0" ]; then - ${MXTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir run_mxtest --comp=${comp} --suffix=CHANGES_${comp}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MXTEST_EXECUTABLE} failed with exit code $?"; exit 1; } + ${MXTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir run_mxtest --comp=${comp} --suffix=${{ matrix.cogen }}_CHANGES_${comp}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MXTEST_EXECUTABLE} failed with exit code $?"; exit 1; } else echo No matching tests found fi @@ -448,7 +467,7 @@ jobs: export SCOPE=" " fi mkdir -p run_mxtest && cd run_mxtest - ${MXTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MXTEST_EXECUTABLE} failed with exit code $?"; exit 1; } + ${MXTEST_EXECUTABLE} --mpi=${{ matrix.nmpi }} --testdir $PWD $SCOPE --suffix=CHANGES_${{ matrix.cogen }}_${{ matrix.method }}_${{ matrix.CC || 'default' }}_${{ matrix.mpi }} $PERMISSIVE --verbose --uid=${RUNNER_TRACKING_ID} || { echo "${MXTEST_EXECUTABLE} failed with exit code $?"; exit 1; } ${MXVIEWTEST_EXECUTABLE} --nobrowse $PWD fi @@ -461,15 +480,15 @@ jobs: set -x # Clear out binaries from sim dir and tar up artifact ls | grep run_ | xargs -n1 ./src/devel/bin/mccode-simdir-cleanfiles -d - tar cvfz mcxtrace-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_* + tar cvfz mcxtrace-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz run_* - name: 'Upload Artifact' id: tar-upload uses: actions/upload-artifact@v6 if: always() with: - name: mcxtrace-artefacts-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} - path: "mcxtrace-${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz" + name: mcxtrace-artefacts-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }} + path: "mcxtrace-${{ matrix.cogen }}.${{ matrix.os }}.${{ matrix.CC }}.${{ matrix.mpi }}.python-${{ matrix.python }}_output.tgz" - name: Setup tmate session for manual debugging uses: mxschmitt/action-tmate@v3 diff --git a/devel/bin/mccode-create-conda-yml b/devel/bin/mccode-create-conda-yml index 6010682ef..4b2ff0e51 100755 --- a/devel/bin/mccode-create-conda-yml +++ b/devel/bin/mccode-create-conda-yml @@ -21,7 +21,7 @@ def create_deplist( cfg ): return deps #The rest are run-time deps: - deps += ['python','c-compiler','pyaml','numpy','psutil'] + deps += ['python','c-compiler','pyaml','numpy','psutil','mccode-antlr'] if cfg.is_unix: deps += ['bash'] if cfg.is_win: diff --git a/mcstas-comps/contrib/SANSPDBFast.comp b/mcstas-comps/contrib/SANSPDBFast.comp index 757eb58bc..3428d3048 100644 --- a/mcstas-comps/contrib/SANSPDBFast.comp +++ b/mcstas-comps/contrib/SANSPDBFast.comp @@ -56,11 +56,13 @@ NOACC SHARE %{ - %include "read_table-lib"; // for Open_File + // for Open_File + %include "read_table-lib" #include #include %include "mccode-complex-lib" + #ifndef SANSPDB #define SANSPDB #define SANSPDBOrderOfHarmonics 21 diff --git a/mcstas-comps/examples/TUDelft/SESANS_Delft/SESANS_Delft.instr b/mcstas-comps/examples/TUDelft/SESANS_Delft/SESANS_Delft.instr index 67e765e48..a78758bd0 100644 --- a/mcstas-comps/examples/TUDelft/SESANS_Delft/SESANS_Delft.instr +++ b/mcstas-comps/examples/TUDelft/SESANS_Delft/SESANS_Delft.instr @@ -123,7 +123,7 @@ COMPONENT sans_spheres = SANS_spheres2(xwidth=0.02, singlesp=0, Qmind = 0.00003, Qmaxd = 0.001) - WHEN (1==1) AT (0, 0, 2.25) RELATIVE src + AT (0, 0, 2.25) RELATIVE src /* COMPONENT px4 = COPY(px1)(filename="px4") diff --git a/mcstas-comps/examples/Tests_optics/Test_Guides_Curved/Test_Guides_Curved.instr b/mcstas-comps/examples/Tests_optics/Test_Guides_Curved/Test_Guides_Curved.instr index f14429bdd..3c157a6af 100644 --- a/mcstas-comps/examples/Tests_optics/Test_Guides_Curved/Test_Guides_Curved.instr +++ b/mcstas-comps/examples/Tests_optics/Test_Guides_Curved/Test_Guides_Curved.instr @@ -126,6 +126,15 @@ COMPONENT Monitor2_xy4 = Monitor_nD( WHEN (Guide == 4) AT (0, 0, length+2) RELATIVE Guide_Position +/* PW 20260827: I no longer rememeber what (temporary?) purpose this monitor may have had - + Visualisation? Debugging? + Commenting it now, courtesy of mcstas-antlr that evaluates the WHEN condition as + literal WHEN(false) withoout false having a definiton. + ... interestingly a simlar WHEN clause is parsed correctly in ESS_butterfly_MCPL_test? */ + +/* COMPONENT dummy = PSD_monitor_4PI(filename="junk", radius=length+1.1, restore_neutron=1) - WHEN (1==0 ) AT (0,0,0) ABSOLUTE + WHEN (1==0) AT (0,0,0) ABSOLUTE +*/ + END diff --git a/mcstas-comps/union/Union_abs_logger_nD.comp b/mcstas-comps/union/Union_abs_logger_nD.comp index d765f1e0f..939335a3c 100644 --- a/mcstas-comps/union/Union_abs_logger_nD.comp +++ b/mcstas-comps/union/Union_abs_logger_nD.comp @@ -137,7 +137,7 @@ SHARE #error "The Union_init component must be included before this Union_abs_logger_nD component" #endif - %include "monitor_nd-lib" // Internally avoids double import + %include "monitor_nd-lib" %include "read_table-lib" %include "interoff-lib" diff --git a/tools/Python/mcrun/mccode.py b/tools/Python/mcrun/mccode.py index a394dc9be..52fcc4a57 100755 --- a/tools/Python/mcrun/mccode.py +++ b/tools/Python/mcrun/mccode.py @@ -170,11 +170,17 @@ def x_path(file): else: # Generate C-code (implicit: prepare for --trace or --no-trace mode if not no_main / Vitess) LOG.info('Regenerating c-file: %s', basename(self.cpath)) - mccode_bin_abspath = str( pathlib.Path(mccode_config.directories['bindir']) / options.mccode_bin ) + # options.mccode_bin may contain both a binary/cmd and parameters to it - so split by space and use [0] + cogen = options.mccode_bin.split(' ')[0] + cogenparms = ' '.join(options.mccode_bin.split(' ')[1:]) + + mccode_bin_abspath = str( pathlib.Path(mccode_config.directories['bindir']) / cogen ) if not os.path.exists(mccode_bin_abspath): LOG.warning('Full-path code-generator "%s" not found!!', mccode_bin_abspath) mccode_bin_abspath=basename(mccode_bin_abspath) LOG.warning('Attempting replacement by "%s"', mccode_bin_abspath) + if cogenparms is not None: + mccode_bin_abspath = mccode_bin_abspath + ' ' + cogenparms if not options.no_main: trace='-t' @@ -284,6 +290,25 @@ def x_path(file): if re.search('CFLAGS=', line): label, flags = line.split('=', 1) + # mcstas-antlr / mcxtrace-antlr may emit a CFLAGS value that + # spans several lines (e.g. a DEPENDENCY string containing + # embedded newlines). Continuation lines aren't part of the + # generated file's other header-comment fields - they just + # sit before the closing ' */' marker of that comment block - + # so keep consuming lines from the same iterator until we + # see it (bounded, for safety). + extra = 0 + for contline in ccode: + counter += 1 + extra += 1 + contline = contline.decode().rstrip() + contline = re.sub(r'\\', '/', contline) + if contline.strip() == '*/': + break + flags += ' ' + contline.strip() + if extra > 50: + break + # Insert NEXUSFLAGS if instrument/comps request this flags = re.sub(r'\@NEXUSFLAGS\@', mccode_config.compilation['NEXUSFLAGS'], flags)