Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method to allow adding an additional directory to find components #50

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

shervin86
Copy link

@shervin86 shervin86 commented Sep 7, 2022

By default components are looked for in the current working directory or the standard McStas folders. When using the instrument database, it is necessary to place components in several special folders. This method is currently used in the description of the ThALES instrument (prototype).

@shervin86 shervin86 marked this pull request as ready for review September 7, 2022 09:23
@mads-bertelsen
Copy link
Collaborator

This update would make McStasScript use the components in the custom folder, but the actual McStas simulation would not look in the custom folder, and thus McStasScript would not be in sync with the McStas behaviour. Would need to modify McStas behaviour in order for this to work, but I am not aware of any features in McStas that would allow this. Will ask around to hear if other McStas developers know of a potential solution.

@shervin86
Copy link
Author

McStas has the following option from the command line: --search-dir=DIR. We should just make sure that McStasscript uses this commandline option.

@mads-bertelsen
Copy link
Collaborator

McStasScript uses the mcrun command which does not have the --search-dir option. If one compiles the mcstas code into c with the mcstas command, that options exists, but then one also have to do a system dependent compile step from .c to executable. I am not prepared to take on the scope in McStasScript.

Perhaps we could instead make a run folder with links to all the files in the component folder? That way the component folder would not be poluted by the genrated files, nor would the components / data files need to be duplicated which would take up unnecessary space.

@willend
Copy link
Contributor

willend commented Apr 14, 2023

McStas 3.3 has a couple of relevant features in this respect, from the CHANGELOG, on the python level:

- mcrun now forwards the -I input to the code-generator, which allows you to add a chosen folder
  with extra components etc. to your search path. Setting the -I flag implies recompilation (-c).
  (Please also note the related SEARCH grammar below which allows working on the component search
  path directly via the instrument or component grammar.)

And in the McStas grammar as such:

- A new syntax called SEARCH has been added to the grammar, allowing users to run append a directory
   to the mcstas search path when looking for components. The syntax may be given in two forms in the
   instrument- or component-header directly after a SHELL token and before the DEPENDENCY, DECLARE
   tokens:
      SEARCH "/the/path/to/add/"
      SEARCH SHELL "the_executable --and --some --options"
   But you may also apply the same two SEARCH forms in connection with a component instance in TRACE, e.g.:
      TRACE
      ...
      SEARCH SHELL "readout-config --show compdir"
      COMPONENT readout = Readout(ring="RING", fen="FEN", tube="TUBE", a="left", b="right", ...)
      AT (0, 0, 0) ABSOLUTE
      ...

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.

3 participants