PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Implied-do read/write and MPI

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Phil Livermore



Joined: 27 Sep 2004
Posts: 4

PostPosted: Tue Jun 14, 2005 8:28 am    Post subject: Implied-do read/write and MPI Reply with quote

The following code should write and read a file of 28*28*30*8 + 8 bytes long, and indeed it does when compiled and run in serial mode (with the MPI bits commented out).

When compiled and run as below, it also works if the implied-do read/write statements are replaced by WRITE(2) TEMP etc.

However, as shown below, the code
(a) writes a binary file 4 bytes too long
(b) crashes when it tries to read it.

This problem is particularly frustrating as the implied-do read/write commands were in fact a workaround for a bug in the Intel fortran compiler, which produces segmentation faults when reading/writing large arrays with commands like write(2) TEMP(:,:,:)

Any thoughts on a viable workaround?

Phil

****************

PROGRAM TRY

IMPLICIT NONE
INTEGER :: N1, N2, N3, IOS, MPIERR, MPIRANK, MPISIZE
REAL( KIND = 8), DIMENSION(28,28,30) :: TEMP
include 'mpif.h'
CALL MPI_INIT(MPIERR)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPIRANK, MPIERR)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPISIZE, MPIERR)

IF( MPIRANK .eq. 0) PRINT*, 'NUMBER OF COMPUTE PROCESSORS USED IS ', MPISIZE - 1



IF(MPIRANK .eq. 0) THEN


OPEN(2, FILE = './temp.out', STATUS = 'REPLACE', FORM = 'UNFORMATTED', IOSTAT = IOS)
IF( IOS .eq. 0) THEN
WRITE(2)(((TEMP(N1, N2, N3), N1 = 1, 28), N2 = 1, 28), N3 = 1,30)
CLOSE(2)
ELSE
PRINT*, 'ERROR ON TRYING TO WRITE TO FILE TEMP.OUT'
ENDIF

PRINT*, 'WRITE SUCCESSFUL'

OPEN(2, FILE = './temp.out', STATUS = 'OLD', FORM = 'UNFORMATTED', IOSTAT = IOS)
IF( IOS .eq. 0) THEN
READ(2) (((TEMP(N1, N2, N3), N1 = 1, 28), N2 = 1, 28), N3 = 1,30)
CLOSE(2)
ELSE
PRINT*, 'ERROR ON TRYING TO READ FROM FILE TEMP.OUT'
ENDIF


ENDIF

! Parallel stuff:
CALL MPI_FINALIZE(MPIERR)



STOP

END PROGRAM TRY
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5815
Location: The Portland Group Inc.

PostPosted: Tue Jun 14, 2005 9:22 am    Post subject: Reply with quote

Hi Phil,

I was able to run successfully the program here using the 6.0-4 and 5.2-4 compilers in both 32 and 64-bits.

Code:
% pgf90 try.f -I/opt/mpi/mpich/include -L/opt/mpi/mpich/lib -lmpich -Mextend -fastsse -V6.0-4
% mpirun -np 4 a.out
 NUMBER OF COMPUTE PROCESSORS USED IS             3
 WRITE SUCCESSFUL
 READ SUCCESSFUL
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
FORTRAN STOP
% ll temp.out
-rw-rw-r--  1 apps sw 188168 2005-06-14 09:01 temp.out


Which version of the compilers are you using? What flags do you use to compile with? What OS are you using? How was your MPICH library built (compiler, flags, etc.)?

Thanks,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group