Skip to content

Commit 182c31e

Browse files
authored
Merge pull request #1914 from mccode-dev/apply-default-pars
Input flag -y / --yes applies all instrument parameter default values
2 parents 57d567a + afb23b8 commit 182c31e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

common/lib/share/mccode-r.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static long mcseed = 0; /* seed for random generator */
6060
static long mcstartdate = 0; /* start simulation time */
6161
static int mcdisable_output_files = 0; /* --no-output-files */
6262
mcstatic int mcgravitation = 0; /* use gravitation flag, for PROP macros */
63+
mcstatic int mcusedefaults = 0; /* assume default value for all parameters */
6364
mcstatic int mcdotrace = 0; /* flag for --trace and messages for DISPLAY */
6465
mcstatic int mcnexus_embed_idf = 0; /* flag to embed xml-formatted IDF file for Mantid */
6566
#pragma acc declare create ( mcdotrace )
@@ -4432,6 +4433,7 @@ mchelp(char *pgmname)
44324433
" -h --help Show this help message.\n"
44334434
" -i --info Detailed instrument information.\n"
44344435
" --list-parameters Print the instrument parameters to standard out\n"
4436+
" -y --yes Assume default values for all parameters with a default\n"
44354437
" --meta-list Print names of components which defined metadata\n"
44364438
" --meta-defined COMP[:NAME] Print component defined metadata names, or (0,1) if NAME provided\n"
44374439
" --meta-type COMP:NAME Print metadata format type specified in definition\n"
@@ -4720,6 +4722,10 @@ mcparseoptions(int argc, char *argv[])
47204722
mcgravitation = 1;
47214723
else if(!strcmp("-g", argv[i]))
47224724
mcgravitation = 1;
4725+
else if(!strcmp("--yes", argv[i]))
4726+
mcusedefaults = 1;
4727+
else if(!strcmp("-y", argv[i]))
4728+
mcusedefaults = 1;
47234729
else if(!strncmp("--format=", argv[i], 9)) {
47244730
mcformat=&argv[i][9];
47254731
}
@@ -4802,6 +4808,20 @@ mcparseoptions(int argc, char *argv[])
48024808
mcusage(argv[0]);
48034809
}
48044810
}
4811+
if (mcusedefaults) {
4812+
MPI_MASTER(
4813+
printf("Using all default parameter values\n");
4814+
);
4815+
for(j = 0; j < numipar; j++) {
4816+
int status;
4817+
if(mcinputtable[j].val && strlen(mcinputtable[j].val)){
4818+
status = (*mcinputtypes[mcinputtable[j].type].getparm)(mcinputtable[j].val,
4819+
mcinputtable[j].par);
4820+
paramsetarray[j] = 1;
4821+
paramset = 1;
4822+
}
4823+
}
4824+
}
48054825
if(!paramset)
48064826
mcreadparams(); /* Prompt for parameters if not specified. */
48074827
else

tools/Python/mcrun/mccode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def run(self, pipe=False, extra_opts=None, override_mpi=None):
326326
args.extend([f'--{opt}=' + str(val)])
327327

328328
# Handle proxy options without values (flags)
329-
proxy_opts_flags = ['no-output-files', 'info', 'list-parameters', 'meta-list']
329+
proxy_opts_flags = ['no-output-files', 'info', 'list-parameters', 'meta-list', 'yes']
330330
if mccode_config.configuration["MCCODE"] == 'mcstas':
331331
proxy_opts_flags.append('gravitation')
332332

tools/Python/mcrun/mcrun.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ def add_mcstas_options(parser):
265265
metavar='trace', type=int, default=0,
266266
help='Enable trace of %s through instrument' % (mccode_config.configuration["PARTICLE"]))
267267

268+
add('-y', '--yes',
269+
action='store_true', default=False,
270+
help='Assume any default parameter value in instrument')
271+
268272
if (mccode_config.configuration["MCCODE"] == 'mcstas'):
269273
add('-g', '--gravitation', '--gravity',
270274
action='store_true', default=False,

0 commit comments

Comments
 (0)