Hello,
Off the bat, I would like to mention that I am not using the intel visual fortran compiler, but rather Gfortran, but I haven't had much luck in finding active forums for Gfortran, thought I check here.
I have a program which calls an external .exe. This software is off the shelf and I am aware that it was also written in fortran. Lets call is xyz.exe. My program writes the input files for xyz.exe, and then calls it from within. I use the intrinsic procedure execute_command_line to run xyz.exe. Once it finishes running the simulation, my program performs the analysis, writes a new input file depending on the previous time-step results and calls xyz.exe again. This was I am able to run a dynamic simulation using a software which was actually written for steady state cases.
I usually set up a cumulative run overnight and go home. Come back in the morning to look at the results.
Now for the most part, xyz.exe is fairly reliable, but sometimes maybe once a week, it gets stuck in an iterative loop. The makers of xyz.exe have put in a limit of the max number of iterations, but they missed accounting for a scenario if their solver gets stuck within a particular iteration, which is what happens to me once a week, when I come back in the morning to see that the complete simulation has not been completed. It is a numerical issue because of finite precision and an extremely stiff system. It gets solved if I change the initial input by say about 0.001, which makes no difference for me in terms of simulation results, but xyz.exe now converges.
Now I want a way to time the run of xyz.exe and if reaches a threshold, say 300 seconds, terminate it. Now an average single time-step run of xyz.exe takes about 3-4 seconds, so if it has reached 300 seconds it effectively means it is stuck in an iterative loop. How can I do this?
I want to begin a time counter before calling xyz.exe, call xyz.exe using execute_command_line, terminate xyz.exe if it reaches 300 seconds, check if my time counter has reached 300, if it has modify the input by the trivial amount and re-run xyz.exe, hoping it would converge this time.
Any advice on how to do this would be quite helpful.
Thanks
AKP