void TInputFile::initializeScriptAfterSimulation(my_string gotScript, my_string gotParameter){ vector<my_string> scriptParam; while(!gotParameter.empty()){ scriptParam.push_back(gotParameter.extract_sub_str(*"#")); gotParameter.remove(0,1); } valuesToPassToScriptAfterSimulations=new my_string[scriptParam.size()]; numValuesToPassToScriptAfterSimulations=scriptParam.size(); for(int i=0;i<scriptParam.size();++i){ if(scriptParam[i].contains("SIMINPUTNAME")){ my_string a=scriptParam[i].extract_after(11); if(a.empty()) valuesToPassToScriptAfterSimulations[i]=newSimulationProgramInputFilenames[0]; else valuesToPassToScriptAfterSimulations[i]=newSimulationProgramInputFilenames[a.toInt()]; } else { if(scriptParam[i]=="SIMNUM") checkParametersPassedToScriptAfterSimulations=true; else { //check priors if(priors->isPrior(scriptParam[i])) checkParametersPassedToScriptAfterSimulations=true; } valuesToPassToScriptAfterSimulations[i]=scriptParam[i]; } } if(checkParametersPassedToScriptAfterSimulations) scriptAfterSimulations=new TExecuteProgram(gotScript.c_str()); else scriptAfterSimulations=new TExecuteProgram(gotScript.c_str(), valuesToPassToScriptAfterSimulations, numValuesToPassToScriptAfterSimulations); }
//--------------------------------------------------------------------------- TInputFile::TInputFile(my_string siminputname, TPriorVector* gotPriors){ //siminputname may contain several files.... my_string buf, extension; while(!siminputname.empty()){ buf=siminputname.extract_sub_str('#'); siminputname.remove(0,1); buf.trim_blanks(); if(!buf.empty()){ simulationProgramInputFilenames.push_back(buf); extension=buf.get_file_extension(); buf.remove_file_extension(); buf+="-temp"; buf+=extension; newSimulationProgramInputFilenames.push_back(buf); } } priors=gotPriors; checkParametersPassedToSimulationProgram=false; checkParametersPassedToScriptAfterSimulations=false; }
//------------------------------------------------------------------------------ void TInputFile::initializeSimulationProgramm(my_string gotSimulationprogram, my_string gotParameter){ vector<my_string> simParam; while(!gotParameter.empty()){ simParam.push_back(gotParameter.extract_sub_str(*"#")); gotParameter.remove(0,1); } valuesToPassToSimulationProgramm=new my_string[simParam.size()]; numValuesToPassToSimulationProgramm=simParam.size(); for(int i=0;i<(int)simParam.size();++i){ //check tags if(simParam[i].contains("SIMINPUTNAME")){ my_string a=simParam[i].extract_after(11); if(a.empty()) valuesToPassToSimulationProgramm[i]=newSimulationProgramInputFilenames[0]; else valuesToPassToSimulationProgramm[i]=newSimulationProgramInputFilenames[a.toInt()]; } else { if(simParam[i]=="SIMNUM"){ checkParametersPassedToSimulationProgram=true; break; } else { //check priors if(priors->isPrior(simParam[i])){ checkParametersPassedToSimulationProgram=true; } } valuesToPassToSimulationProgramm[i]=simParam[i]; } } if(gotSimulationprogram=="INTERNALGLM"){ if(!checkParametersPassedToSimulationProgram) throw TException("The INTERNALGLM program requires model parameter tag as arguments!", _FATAL_ERROR); simulationProgram=new TGLM(valuesToPassToSimulationProgramm, numValuesToPassToSimulationProgramm); } else { if(checkParametersPassedToSimulationProgram) simulationProgram=new TExecuteProgram(gotSimulationprogram.c_str()); else simulationProgram=new TExecuteProgram(gotSimulationprogram.c_str(), valuesToPassToSimulationProgramm, numValuesToPassToSimulationProgramm); } }