Is there a good way to ask Fortran to not buffer stdout? In MPI_Init, we currently do setbuf(stdout, NULL), so it works correctly for C programs, but this doesn't seem to affect the Fortran programs. -- Pavan -- Pavan Balaji http://www.mcs.anl.gov/~balaji
As you've found, Fortran's and C's IO buffering scheme are independent. AFAIK, there isn't any portable way to do setbuf(stdout,NULL) in Fortran. Because of that, Fortran programmers usually put flush() after their stdout write() to make sure they can see their outputs. Not sure that helps, Bill may know better about Fortran runtime. A.Chan ----- "Pavan Balaji" <[email protected]> wrote:
Is there a good way to ask Fortran to not buffer stdout? In MPI_Init, we currently do setbuf(stdout, NULL), so it works correctly for C programs, but this doesn't seem to affect the Fortran programs.
-- Pavan
-- Pavan Balaji http://www.mcs.anl.gov/~balaji
On 10/27/2010 02:20 AM, Anthony Chan wrote:
As you've found, Fortran's and C's IO buffering scheme are independent. AFAIK, there isn't any portable way to do setbuf(stdout,NULL) in Fortran. Because of that, Fortran programmers usually put flush() after their stdout write() to make sure they can see their outputs. Not sure that helps, Bill may know better about Fortran runtime.
Right. We don't have control on the application, so we can't really depend on flush(). There seem to be some compiler-specific environment variables such as GFORTRAN_UNBUFFERED_ALL=y, which seem to do this. But again, we don't really know the compiler either. If there are a set of environment variables for the standard compilers (gnu, intel, pgi, ...), I can automatically set all of them in Hydra to at least help in some cases. -- Pavan -- Pavan Balaji http://www.mcs.anl.gov/~balaji
I am not sure all fortran compilers provide mechanism to do the equivalence of setbuf(stdout,NULL), so not sure if it is a good way to solve the hydra problem (which I don't fully understand). My understanding of the reason that MPI_Init doing setbuf(stdout,NULL) is to ensure that C layer won't interfere with the Fortran runtime's IO buffering. Would that be OK that hydra doesn't do any IO buffering for Fortran and just let endusers deal with it themselves, i.e. gfortran users need o set GFORTRAN_UNBUFFERED_ALL through mpiexec if they need unbuffering of IOs ? A.Chan ----- "Pavan Balaji" <[email protected]> wrote:
On 10/27/2010 02:20 AM, Anthony Chan wrote:
As you've found, Fortran's and C's IO buffering scheme are independent. AFAIK, there isn't any portable way to do setbuf(stdout,NULL) in Fortran. Because of that, Fortran programmers usually put flush() after their stdout write() to make sure they can see their outputs. Not sure that helps, Bill may know better about Fortran runtime.
Right. We don't have control on the application, so we can't really depend on flush(). There seem to be some compiler-specific environment
variables such as GFORTRAN_UNBUFFERED_ALL=y, which seem to do this. But again, we don't really know the compiler either.
If there are a set of environment variables for the standard compilers
(gnu, intel, pgi, ...), I can automatically set all of them in Hydra to at least help in some cases.
-- Pavan
-- Pavan Balaji http://www.mcs.anl.gov/~balaji
There's no standard way to do this in Fortran. Providing hooks to make use of environment variables that some Fortran environments provide makes sense, though note that real Fortran users will probably use a commercial compiler for the (usually) superior performance of the generated code, so digging into what gfortran accepts won't be enough. Bill On Oct 27, 2010, at 11:45 AM, Anthony Chan wrote:
I am not sure all fortran compilers provide mechanism to do the equivalence of setbuf(stdout,NULL), so not sure if it is a good way to solve the hydra problem (which I don't fully understand). My understanding of the reason that MPI_Init doing setbuf(stdout,NULL) is to ensure that C layer won't interfere with the Fortran runtime's IO buffering. Would that be OK that hydra doesn't do any IO buffering for Fortran and just let endusers deal with it themselves, i.e. gfortran users need o set GFORTRAN_UNBUFFERED_ALL through mpiexec if they need unbuffering of IOs ?
A.Chan
----- "Pavan Balaji" <[email protected]> wrote:
On 10/27/2010 02:20 AM, Anthony Chan wrote:
As you've found, Fortran's and C's IO buffering scheme are independent. AFAIK, there isn't any portable way to do setbuf(stdout,NULL) in Fortran. Because of that, Fortran programmers usually put flush() after their stdout write() to make sure they can see their outputs. Not sure that helps, Bill may know better about Fortran runtime.
Right. We don't have control on the application, so we can't really depend on flush(). There seem to be some compiler-specific environment
variables such as GFORTRAN_UNBUFFERED_ALL=y, which seem to do this. But again, we don't really know the compiler either.
If there are a set of environment variables for the standard compilers
(gnu, intel, pgi, ...), I can automatically set all of them in Hydra to at least help in some cases.
-- Pavan
-- Pavan Balaji http://www.mcs.anl.gov/~balaji
William Gropp Deputy Director for Research Institute for Advanced Computing Applications and Technologies Paul and Cynthia Saylor Professor of Computer Science University of Illinois Urbana-Champaign
It sounds like we should do what we can then add an FAQ entry. -d On Nov 2, 2010, at 7:49 AM, William Gropp wrote:
There's no standard way to do this in Fortran. Providing hooks to make use of environment variables that some Fortran environments provide makes sense, though note that real Fortran users will probably use a commercial compiler for the (usually) superior performance of the generated code, so digging into what gfortran accepts won't be enough.
Bill
On Oct 27, 2010, at 11:45 AM, Anthony Chan wrote:
I am not sure all fortran compilers provide mechanism to do the equivalence of setbuf(stdout,NULL), so not sure if it is a good way to solve the hydra problem (which I don't fully understand). My understanding of the reason that MPI_Init doing setbuf(stdout,NULL) is to ensure that C layer won't interfere with the Fortran runtime's IO buffering. Would that be OK that hydra doesn't do any IO buffering for Fortran and just let endusers deal with it themselves, i.e. gfortran users need o set GFORTRAN_UNBUFFERED_ALL through mpiexec if they need unbuffering of IOs ?
A.Chan
----- "Pavan Balaji" <[email protected]> wrote:
On 10/27/2010 02:20 AM, Anthony Chan wrote:
As you've found, Fortran's and C's IO buffering scheme are independent. AFAIK, there isn't any portable way to do setbuf(stdout,NULL) in Fortran. Because of that, Fortran programmers usually put flush() after their stdout write() to make sure they can see their outputs. Not sure that helps, Bill may know better about Fortran runtime.
Right. We don't have control on the application, so we can't really depend on flush(). There seem to be some compiler-specific environment
variables such as GFORTRAN_UNBUFFERED_ALL=y, which seem to do this. But again, we don't really know the compiler either.
If there are a set of environment variables for the standard compilers
(gnu, intel, pgi, ...), I can automatically set all of them in Hydra to at least help in some cases.
-- Pavan
-- Pavan Balaji http://www.mcs.anl.gov/~balaji
William Gropp Deputy Director for Research Institute for Advanced Computing Applications and Technologies Paul and Cynthia Saylor Professor of Computer Science University of Illinois Urbana-Champaign
participants (4)
-
Anthony Chan -
Darius Buntinas -
Pavan Balaji -
William Gropp