Skip to content

Instantly share code, notes, and snippets.

@zonca
Created March 10, 2014 19:46
Show Gist options
  • Save zonca/9472813 to your computer and use it in GitHub Desktop.
Save zonca/9472813 to your computer and use it in GitHub Desktop.
Test calling Python script from FORTRAN
program SystemTest
print *, "FORTRAN: BLOCKING"
call system("python pythonsleep.py")
print *, "FORTRAN: NONBLOCKING"
call system("python pythonsleep.py &")
print *, "FORTRAN: EXIT"
end program SystemTest
#!/usr/bin/env python
from time import sleep
print "Before"
sleep(5)
print "After"
@zonca
Copy link
Author

zonca commented Mar 10, 2014

Execution:

nebula ~/SEEDME/fortran_callpython$ gfortran fortranmain.f90 
nebula ~/SEEDME/fortran_callpython$ time ./a.out 
 FORTRAN: BLOCKING
PYTHON: Before
PYTHON: After
 FORTRAN: NONBLOCKING
 FORTRAN: EXIT

real        0m5.026s
user        0m0.012s
sys         0m0.004s
PYTHON: Before
nebula ~/SEEDME/fortran_callpython$ PYTHON: After

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment