Enable buffered I/O to stdout with Intel ifort compiler

一世执手 提交于 2019-12-12 20:23:51

问题


I've read the Intel docs about enabling buffered I/O with ifort (using -assume buffered_io or FORT_BUFFERED=true), and this works for output directly to files. However, we have large applications that are writing to stdout (e.g. write(*,*) or write(stdout,*)), which is redirected to a file. Neither of the buffering techniques work in this case.

Other than refactoring the code to write directly to files, is there a method to enable buffered I/O on stdout with ifort? This is enabled by default on, for example, gfortran.

We're using ifort 12.0 on SLES 11.

Update: Thanks for the comments. I'm investigating stdbuf and/or piping through a buffering program (like tee) as a workaround. As yet, I haven't been able to make a measurable difference.

Update 2:

I've tried some experiments with Douglas's suggestion, piping through another program. tee and cat both buffer, in face the buffering seems to done by the pipe itself at about 8K. However, the overhead of the original write() calls, plus the pipe, plus the system calls of the piping program (tee, cat etc.) are too high to make this a workable solution.

来源:https://stackoverflow.com/questions/12511620/enable-buffered-i-o-to-stdout-with-intel-ifort-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!