Skip to content

Add nowritefile parameter to all Union loggers and abs_loggers - #2607

Open
mads-bertelsen-agentic wants to merge 15 commits into
mccode-dev:mainfrom
mads-bertelsen-agentic:nowritefile_for_union
Open

Add nowritefile parameter to all Union loggers and abs_loggers#2607
mads-bertelsen-agentic wants to merge 15 commits into
mccode-dev:mainfrom
mads-bertelsen-agentic:nowritefile_for_union

Conversation

@mads-bertelsen-agentic

@mads-bertelsen-agentic mads-bertelsen-agentic commented Aug 26, 2026

Copy link
Copy Markdown

Free-form text area

Please describe what your PR is adding in terms of features or bugfixes:

The nowritefile parameter, already standard for monitors, skips writing output data to disk when set. This adds the same feature to all Union logger and abs_logger components: a new int nowritefile=0 setting parameter, a documentation line under %P, and the save section wrapped in an if (!nowritefile) statement.

Union_abs_logger_nD already had the parameter and inherits the if-statement from Monitor_nD through SAVE INHERIT; its documentation line was corrected from 'Not functional for Union version'.


Declaration of use of AI-tools

  • Please add a checkmark here if you used AI-tools during the work for this contribution
  • Furter, please describe how / where and for what the tools were used:

Development OS / boundary conditions

Please describe what OS you developed and tested your additions on, and if any special dependencies are required:
UTM Virtual machine OS X 14.6.1 (23G93)


PR Checklist for contributing to McStas/McXtrace

For a coherent and useful contribution to McStas/McXtrace, please fill in relevant parts of the checklist:

  • My contribution includes patches to an existing component file

    • I have used the mcdoc utility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)
    • I have ensured that basic use of the component is OK (e.g. an instrument using it compiles?)
    • I have used the mctest utility to test one or more instruments making use of the component (please attach mcviewtest report as screenshot in comments)
    • I have used the mccode-clangformat tool to apply the standard McCode component indentation scheme
    • I have used the mcrun --c-lint "linter" and followed advice to remove most / all warnings that are raised
  • My contribution includes patches to an existing instrument file

    • I have used the mcdoc utility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)
    • I have used the mctest utility to test the instrument (please attach mcviewtest report as screenshot in comments)
    • I have used the mcrun --c-lint "linter" and followed advice to remove most / all warnings that are raised
  • My contribution includes a new component file

    • I have ensured that naming of parameters are in the style of existing components. (Please check the McStas or McXtrace NOMENCLATURE docs.)
    • I have ensured that component parameters are in the usually units of McStas or McXtrace (SI + neutron/x-ray 'usual' units)
    • I have used the mcdoc utility and rendered a reasonable documentation page for the component (please attach as screenshot in comments!)
    • I have ensured that basic use of the component is OK (e.g. an instrument using it compiles?)
    • I have included a corresponding example instrument and will fill in the new instrument section below
    • I have used the mccode-clangformat tool to apply the standard McCode component indentation scheme
    • My new component is added within the contrib component category
  • My contribution includes a new instrument file

    • I have used the mcdoc utility and rendered a reasonable documentation page for the instrument (please attach as screenshot in comments!)
    • I have ensured that basic use of the instrument is OK (e.g. it compiles?)
    • ... and provided reasonable default parameters in that instrument that produce reasonable output
    • ... and maybe even added a %Example: line to describe expected behaviour
    • I have used the mcrun --c-lint "linter" and followed advice to remove most / all warnings that are raised
    • My new instrument is added within the examples hierarchy in a folder in the style of examples/ESS/New_stuff/New_stuff.instr
    • My new instrument has a new, unique filename, not clashing with existing example instruments
    • My new instrument requires a data/input file. If the datafile is specific for my instrument I have left it in the same example folder, but if general use I have placed it in the global data folder.
  • My work touches the code-generator in mccode/src

    • I have added reasoning and documentation for the change through an ADR record in our GRAMMAR section
    • I am attaching test output in the comments
  • My work touches / adds to the runtime lib code (.c,.h etc in multiple locations

    • I am have added reasoning and documentation for the change below
    • I am attaching test output in the comments
  • My PR is meant to fix a specific, existing issue

  • My contribution contains something else

    • Explanation is added in free form text above or below the checklist

The nowritefile parameter, already standard for monitors, skips writing
output data to disk when set. This adds the same feature to all Union
logger and abs_logger components: a new int nowritefile=0 setting
parameter, a documentation line under %P, and the save section wrapped
in an if (!nowritefile) statement.

Union_abs_logger_nD already had the parameter and inherits the
if-statement from Monitor_nD through SAVE INHERIT; its documentation
line was corrected from 'Not functional for Union version'.
@mads-bertelsen-agentic
mads-bertelsen-agentic marked this pull request as draft August 26, 2026 10:30
@mads-bertelsen
mads-bertelsen marked this pull request as ready for review August 28, 2026 11:03
@willend

willend commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Hi @mads-bertelsen-agentic, @mads-bertelsen

The Windows test is failing - very likely due to a too long path / filename.
Screenshot 2026-08-29 at 09 15 42

I've dug out just the relevant portion of the test output in the attached zip-file for convenience
run_mctest.zip

The failing instruments all seem to error in compilation with this type of output:

more ....(long path)/Unit_test_abs_logger_1D_space_event/compile_stdout.txt 
INFO: No output directory specified (--dir)
INFO: Using directory: "Unit_test_abs_logger_1D_space_event_20260828_135650"
INFO: Regenerating c-file: Unit_test_abs_logger_1D_space_event.c
WARNING: Full-path code-generator "C:\Users\runneradmin\micromamba\envs\mcstas\bin\mcstas" not found!!
WARNING: Attempting replacement by "mcstas"
DEBUG: CMD: mcstas -t -o Unit_test_abs_logger_1D_space_event.c Unit_test_abs_logger_1D_space_event.instr


Fatal error: mcstas: Instrument definition file `Unit_test_abs_logger_1D_space_event.instr' not found


Program aborted.
INFO: call to mcstas failed with Command 'mcstas -t -o Unit_test_abs_logger_1D_space_event.c Unit_test_abs_logger_1D_space_event.instr' returned non-zero exit status 1.
ERROR: Code generation failed for instrument Unit_test_abs_logger_1D_space_event.instr using code generator mcstas

Part of the issue comes from a requirement to make output folders unique (including details on platform and execution conditions) - and while I can correct / solve part of the problem by adjusting mctest itself - these instrument filenames / component names are themselves also getting very long... :-)

(I suggest stylistic changes along the lines of e.g. Unit_test -> Unittest, abs_logger -> abslog, space -> xyz, event -> list)

@willend

willend commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Rebased PR branch to current state of main @mads-bertelsen-agentic @mads-bertelsen

@willend

willend commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

@mads-bertelsen-agentic, @mads-bertelsen there is in fact a good chance the rebase will let the tests to run through - I'd still like the stylistic filename changes..

@willend willend mentioned this pull request Aug 29, 2026
2 tasks
@mads-bertelsen

Copy link
Copy Markdown
Contributor

Great catch! Didn’t think of that long filename issue even though I have encountered it on windows systems before.

Happy to shorten the names of the test instruments, changing the component names themselves would require updating a lot of instruments, in repo and outside, so hope it’s acceptable to leave those as they are.

@willend

willend commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

@mads-bertelsen another complexity occurred - testing multiple comps with similar names easily leads to folder-clashes in the CI - but have nailed it now I think...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Union loggers should have ‘nowritefile’ input-switch like other monitors

3 participants