Hi Alan
number_of_runs was there as left over from something else I was trying.
The main issue was that INP_File and Run_Number weren't being replaced by the input filename or the run number.
I managed to solve it with this:
macro Sequential_Refinement(numruns, ident) { Sequential_Refinement(numruns, ident, , INP_File, Run_Number) }
macro Sequential_Refinement(numruns, ident, output) { Sequential_Refinement(numruns, ident, output, INP_File, Run_Number) }
macro Sequential_Refinement(numruns, ident, output, INPFILE, RUNNUMBER) 'This one would almost never be called directly
{
num_runs numruns
'saves a backup of the original input
#if Run_Number == 0;
system_before_save_OUT { copy INPFILE##.inp INPFILE##.backup }
#endif
'Save each input file with the run number and some other identifier
system_before_save_OUT { copy INPFILE##.inp INPFILE##_##RUNNUMBER##_##ident##.backup }
'copy the output of the nth file and use it as the input for the (n+1)th file
out_file = Concat(String(INPFILE), ".INP");
'restores the original input file. This is what I would like to run automatically on stop or refinement error.
#if Run_Number == numruns-1;
system_after_save_OUT { copy INPFILE##.backup INPFILE##.inp }
#endif
'output every refined parameter
#m_ifarg output "" #m_else
out_prm_vals_on_convergence output
#m_endif
}
The macro is written with my own placeholders: INPFILE and RUNNUMBER
Sequential_Refinement(numruns, ident, output, INPFILE, RUNNUMBER)
This macro call would almost never be used.
I then have another macro call this macro
macro Sequential_Refinement(numruns, ident, output) { Sequential_Refinement(numruns, ident, output, INP_File, Run_Number) }
Here, I put in the Topas keywords (?) INP_File and Run_Number, and everything gets replaced as I want.
The output call at the end doesn't actually work, as it gets overwritten every time, and you end up with only the results from the last file.