Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print #9

Closed
mgovoni-devel opened this issue Jul 26, 2019 · 2 comments
Closed

Print #9

mgovoni-devel opened this issue Jul 26, 2019 · 2 comments

Comments

@mgovoni-devel
Copy link
Contributor

So far I see that python print statements are flushed only when forpy is finalized.
Is there a way to flush the output when the python module is invoked? Unfortunately we cannot init/finalize multiple times.

@mgovoni-devel mgovoni-devel changed the title Writing Print Jul 26, 2019
@ylikx
Copy link
Owner

ylikx commented Jul 27, 2019

You can try the equivalent of the following Python code [1]:

import sys
sys.stdout.flush()

Fortran:

type(module_py) :: sys
type(object) :: stdout

! [...]

ierror = import_py(sys, "sys")
ierror = sys%getattribute(stdout, "stdout")
ierror = call_py_noret(stdout, "flush")

! [...]

call sys%destroy
call stdout%destroy

[1] https://stackoverflow.com/questions/230751/how-to-flush-output-of-print-function

@mgovoni-devel
Copy link
Contributor Author

Thanks. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants