Reputation: 1363
We are developing a numerical simulation program in FORTRAN90 (procedural, not OO and unfortunately some COMMON blocks are present but no GOTO's :-) ) and are thinking of using Python to help us in unit-testing (retroactively) and verification testing. We would like to set up a testing environment in Python to a) do unit-testing and b) do verification testing (i.e. run small test cases with well-known solutions). We would like to be able to group different tests together (by FORTRAN90 procedure for unit-testing or by problem topic for verification testing) and allow tests to be run either individually or by group.
The simulation program is text-input/output based, so we could come up with some input files to be run and compared to verified output files. For unit testing, however, I guess we will probably need to write wrappers for each FORTRAN90 subroutine.
Has anybody been in a likewise situation before? What tips can you give us?
thanks.
(btw rewriting the FORTRAN90 code in Python is not (yet) an option)
Upvotes: 0
Views: 467
Reputation: 515
If you use the "os.system()" function, this can be used to call linux/unix commands from the python script directly. You can also use the "subprocess" module.
Use it like this:
os.system("ls -G")
This will call 'ls -G' from python just like if you were calling it yourself. You can easily compile and call fortran code using this command as well. Or, if you're familiar with bash scripting, you could use that as a wrapper for your unit testing as well. The scientific computing community seems to like perl for these types of tasks, but python should work just fine.
At least you're working with fortran90 and not fortran77. Those goto statements can make debugging a code excessively interesting. :P
Upvotes: 1
Reputation: 4767
Here is a link that provides some insight into how you can go about with your task :
This link also provides references to two modules -f2py and fwrap. The link for f2py seems to be broken, hence you can refer to f2py documentation here
Upvotes: 0