Hi Everyone,
I am a structural engineer with non-programming background. I've had help from here before, so I am posting a question again in hope of a solution.
I am using a software (OpenSees.exe) which calls a .DLL file that I have created. In the .cpp file, there is condition when fulfilled, the program has to crash (it correspond to the failure of a structure!). It uses command exit(-1) to do that. The code is provided below:
1 2 3 4
if (qTrial<=Fcrmin) {
opserr<<"Elastomer failed in buckling\n";
exit(-1);
}
Now the problem is that I am calling the .DLL file in a loop through OpenSees.exe, and if one analysis fails, I want to move on to the next one in the loop without OpenSees.exe crashing. So I was wondering if there is a way that when the failure condition is met, instead of using exit(-1) to crash the whole OpenSees.exe, I can get some sort of failure tag output and save it to a variable, and if the value of variable is 0 (or 1, whatever), I move to the next analysis in the loop.
Wait, that code is in the OpenSees source? Or your DLL' s source?
If it is in the OpenSees source, I recommend you fill out the survey on their website and submit a request for the developers to implement more correct behavior, if you believe there is one.
For now, though, you may have to program the loop from your end, and run OpenSees once for each iteration of the loop.
It's in the .DLL file, not OpenSees.exe, which is a kind of interpreter. I build my structural analysis model through .tcl file, then source/loads it through OpenSees.exe which calls the .DLL file and runs the program.
The loop is in .tcl file, which looks something like this:
1 2 3 4 5 6
proc lat {i} {
source test.tcl
}
for {set i 1} {$i <5} {incr i} {
lat $i
}
test.tcl is the my structural definition file, which calls the mentioned. DLL file.
I've looked again at the OpenSees site, and I realize now that OpenSees.exe is a modified Tcl interpreter. Right?
The problem is that the DLL is, for all intents and purposes, an integral part of the application process. When you exit(-1) you aren't terminating your DLL, you are terminating the process (the OpenSees interpreter).
Don't do that.
Figure out another way to do it. In Tcl, the proper way is to return an error code, which your loop can trap with a catch statement.
1 2 3 4 5 6 7 8 9
proc lat i {
# perform the test here, output good stuff after success
}
for {set i 1} {$i < 5} {incr i} {
if {[catch {lat $i}]} {
#output error stuff (since the test failed)
}
}