/** See documentation in DREAM examples) */ void NonDDREAMBayesCalibration:: problem_value(string *chain_filename, string *gr_filename, double &gr_threshold, int &jumpstep, double limits[], int par_num, int &printstep, string *restart_read_filename, string *restart_write_filename) { int j; // BMA TODO: // * Allow user to set the output filenames // parameters to expose to user... int chain_tag_len = std::log10(NonDDREAMInstance->numChains - 1) + 1; std::string chain_tag(chain_tag_len, '0'); std::string chain_fname("dakota_dream_chain"); chain_fname += chain_tag + ".txt"; *chain_filename = chain_fname.c_str(); *gr_filename = "dakota_dream_gr.txt"; gr_threshold = NonDDREAMInstance->grThreshold; jumpstep = NonDDREAMInstance->jumpStep; for ( j = 0; j < par_num; j++ ) { limits[0+j*2] = NonDDREAMInstance->paramMins[j]; limits[1+j*2] = NonDDREAMInstance->paramMaxs[j]; Cout << "min " << j << " = " << limits[0+j*2] << std::endl; Cout << "max " << j << " = " << limits[1+j*2] << std::endl; } // parameters to expose to user... printstep = 10; *restart_read_filename = ""; *restart_write_filename = "dakota_dream_restart.txt"; return; }
int main( int argc, char **argv ) { int badopt= 0; int numfiles= 0; char *outfmt; #ifdef _DCC /* Dice */ expand_args(argc,argv, &argc,&argv); #endif /* _DCC */ infile= outfmt= (char *)0L; whoami= *argv; fin= stdin; fout= stdout; ferr= stderr; while(--argc>0 && !badopt) { char *arg= *++argv; if(*arg=='-') { if(arg[1]=='-') arg= convert_args(*argv); switch(*++arg) { /*-d*/ case 'd': #ifdef DEBUG debuglevel= 1; #else echo("not compiled w/ a symbol DEBUG defined. No debugging information available -- Sorry."); #endif break; /*-E*/ case 'E': if(arg[1]) ++arg; else arg= (--argc > 0) ? *(++argv) : (char *)0L; if(arg && *arg) { if(ferr != stderr) { warn("warning: option `%s' has already been seen!",*argv); fclose(ferr); } ferr= fopen(arg,"w"); if(!ferr) { warn("can't direct error output to `%s' -- will use stderr",arg); ferr= stderr; } } else { warn("missing filename after `%s' option",*argv); ++badopt; } break; /*-?*/ case '?': /*-h*/ case 'h': fprintf(stderr, "usage: %s [options] [-o|>] [outfile] [<] [infiles..]\n\n",whoami); display_args(); badopt= 1; /* hack: means exit. */ break; /*-o*/ case 'o': if(arg[1]) ++arg; else arg= (--argc > 0) ? *(++argv) : (char *)0L; if(arg && *arg) { if(outfmt) warn("option `%s' has already been seen!",*argv); outfmt= arg; } else { warn("missing output filename after `%s' option",*argv); ++badopt; } break; /*-s*/ case 's': warn("silent option `%s' is not yet implemented -- sorry.",*argv); break; /*-v*/ case 'v': display_version_information(); badopt= 1; /* hack: means exit. */ break; /*??*/ default: warn("unrecognized option `%s'",*argv); ++badopt; break; } } else { if(arg && *arg) { if( chain_fname(arg) ) { warn("out of memory... aaaiiiiiieeeeeeeee!"); ++badopt; } else ++numfiles; } else { warn("command line error: can't parse `%s'",arg); ++badopt; } } } if(numfiles) { while( !badopt && (infile= unchain_fname()) ) { if( fin= fopen(infile,"rb") ) { if( fout= outfmt ? fmtopen(outfmt, infile) : stdout ) { badopt= dothehardpart(); if(fout != stdout) fclose(fout); } else ++badopt; /* fmtopen() has already warned */ fclose(fin); } else { warn("can't access your input file `%s'",infile); ++badopt; } } purge_flist(); } else if( !badopt ) { if( fout= outfmt ? fmtopen(outfmt, "stdin") : stdout ) { badopt= dothehardpart(); if(fout != stdout) fclose(fout); } else ++badopt; /* fmtopen() has already warned */ } if(fin && fin != stdin) fclose(fin); if(fout && fout != stdout) fclose(fout); if(ferr && ferr != stderr) fclose(ferr); exit( badopt ? 1:0 ); }