- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a problem with running the following simple program using MPI.
test.f:
IMPLICIT NONE
INTEGER :: I, IERR
CALL MPI_INIT(IERR)
WRITE(*,'(A)', advance='no') 'input i: '
READ(*,*) I
WRITE(*,*) 'I =', I
CALL MPI_FINALIZE(IERR)
END
command line:
mpiifort test.f
mpirun -np 1 ./a.out
Here, input i: should be displayed first, but nothing appears on the screen. If I enter 1 where nothing is displayed, it shows
mpiexec -np 1 ./a.out
1
input i: I = 1
Like this, input i: is displayed late.
If I compile with gfortran using mpif90, it works normally.
Also, it works normally if I run it without using mpirun - just launch ./a.out.
if I use the non-standard traditional extension method like below, it also works normally.
WRITE(*,‘(A$)’) 'input i: ’
I think this is a bug of Intel-fortran-compiler, both ifort and ifx gave the same results.
The OS is ROCKY linux 8 and the compiler version is as follows:
ifort -V Intel® Fortran Intel® 64 Compiler Classic for applications running on Intel® 64, Version 2021.9.0 Build 20230302_000000 Copyright © 1985-2023 Intel Corporation. All rights reserved.
Regards,
Tetsuya Mishima
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not convinced that non-advancing i/o to standard output (i.e. not a file) is a thing you can reasonably expect to work. It is rather dependant on what standard output is connected to and its functionality.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This probably will not run as you would expect under MPI. input/output for programs under MPI pass the IO through MPI's daemons which launch and control the process(es). These daemons buffer output, typically at line boundaries, not character boundaries. So what you are trying to do makes no sense under MPI.
This is why most MPI programs are designed to read input from files ( only rank 0 should be reading stdin ) and write output to files.
You can see the behavior of stdout buffering by writing a simple hello world that prints hello and it's rank number. what you will find with -np great than 1 is that the order of output from the ranks is random BUT each line is intact - characters are not splattered all over the place. This is because the MPI daemons are buffering at the line level, without synchronization, and atomically send each line intact to stdout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your comments.
The conventional approach using $ has been working as expected for over 10 years. Additionally, I am aware of the bug fix related to non-MPI sequential cases in the following link:
That's why I potsed here.
If my case aligns with the expected standard behavior of MPI, I will continue using the traditional $ method.
Regards,
Tetsuya Mishima
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page