I have a watershed model executable in linux that when executed, reads from a number of input text files. When I find that executable via shell and execute it (without root), everything works fine. However, I’m writing a c++ program that needs to call the executable and so thought I’d simply use system(). When I do, the model executes but then returns an “end-of-file” runtime error associated with one of the primary input text files. I have no idea why the program would execute fine when I execute manually via shell but return an error when executed via the system() command.
I’m guessing that nobody will know what the problem is right away but I have no idea about where to start my investigation. I’d appreciate any suggestions.
Thanks!
My system command is:
system("/home/name/SWAT/olentangy/Scenarios/Default/TxtInOut/swat");
The error I receive is:
forrtl: severe (24): end-of-file during read, unit 23, file /home/name/EO_G/EIGHT/EIGHT/file.cio
Image PC Routine Line Source
swat 0821D03F Unknown Unknown Unknown
swat 0821BD35 Unknown Unknown Unknown
swat 081D78D1 Unknown Unknown Unknown
swat 081ABD66 Unknown Unknown Unknown
swat 081AB621 Unknown Unknown Unknown
swat 081BC9DF Unknown Unknown Unknown
Even though
swatis arguably buggy in its behavior, you can still work around it in your parent program:Replace this:
with this: