Closed willend closed 5 years ago
Admittedly it is being very conservative and picky, in that it wants to make sure that the merged file has consistent comments as well.
But the use-case of forcing the merge to take place anyway (possibly with comments from both files kept in a clearly denoted fashion) is something that has come up many times. So I definitely support some sort of development in this direction.
Just need to find the time :-)
Sounds good - did you find the time yet? ;-) (Just kidding)
As I more or less needed the possibility "now" I have hacked up yet another little crazy fucker of a McStas instrument file - MCPL_merge.instr: https://github.com/McStasMcXtrace/McCode/blob/master/mcstas-comps/examples/MCPL_merge.instr
(- needs an updated MCPL_input to work: https://github.com/McStasMcXtrace/McCode/blob/master/mcstas-comps/misc/MCPL_input.comp)
But what if I have 11 mcpl files? ;-)
Just kidding, good that you have a short term workaround. I guess it should not be super difficult to simply add a "--merge-and-strip-comments" feature to mcpltool which does something similar and just nukes all comments (but inserts a new warning comment). Care must of course still be taken to enable the right settings (double precision/polarisation/userflags) to ensure that no particle is lost.
And I am to late to return the wishes for a nice weekend, so please have a nice next weekend instead ;-)
In MCPL v1.3.0 which was just released, the mcpltool has a new --forcemerge option as requested:
--forcemerge [--keepuserflags] FILEOUT FILE1 FILE2 ... FILEN
Like --merge but works with incompatible files as well, at the
heavy price of discarding most metadata like comments and blobs.
Userflags will be discarded unless --keepuserflags is specified.
It will select the format of the output files so as to be able to accommodate all particles in the input. Example: 15 input files are use single-precision storage and 1 use double-precision storage, so the output will use double-precision storage. Another example: If any input file has polarisation enabled, the output will have it enabled as well.
It performs all particle transfers loss-lessly (i.e. nothing lost by unpacking+repacking) via the new mcpl_transfer_last_read_particle function from the C API.
It is documented on https://mctools.github.io/mcpl/usage_cmdline/
And just to be clear: It is strongly recommended to use the standard --merge whenever possible! The new --forcemerge
option is intended as a last-resort only.
Juggling mcpl output files split using the DG framework ess_mcplextra_filterfile, I wanted to merge two mcpl files, but mcpltool complains that
(Admittedly this is kind of a stupid example since they originated from the same MCNP ssw write in the first place...)
Isn't mcpltool a little picky here since the only difference is stuff in the comments? Headers of the two files are visible below: