MPI每个过程都会在它的转动中发挥作用

时间:2014-04-11 08:17:34

标签: process mpi

我编写了一个mpi程序,其中每个进程每次等待调用一个名为read data的函数。不幸的是程序编译成功,但每次我尝试运行它我得到一个名为 forrtl的fortran错误:严重(157):程序异常 - 访问冲突

你可以帮我找出它为什么会发生......?我附上以下代码

        PROGRAM DS2V
    !

    USE MOLECS
    USE GEOMETRY
    USE STREAM
    USE CELLS
    USE CALC
    USE SAMPLES
    USE MOLFILE
    USE TWISTER


    !


    IMPLICIT NONE

    INCLUDE 'mpif.h'
    !
    INTEGER :: IRUN,ISAMP,N,NN,II,NMII,MM,MOVS,KSA,SAMPS,ERROR,IFXF,
 +             ITBFF,IEOPT,ISTART,IEND,IFILE,MYID,NPROCS,IERR,ID
    INTEGER :: STATUS(MPI_STATUS_SIZE)
    REAL :: A,RANF,TE,FNUMF,COMTEFF,FACN
    !

    CALL MPI_INIT(IERR)
    CALL MPI_COMM_SIZE(MPI_COMM_WORLD,NPROCS,IERR)
    CALL MPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR)

    ID = MYID
    NVER=4
    MVER=5

    IRUN=0
    !

    IF (MYID == 0) THEN
        OPEN (8,FILE='RUNIND')
        PRINT*,'PROCESS',MYID,'WRITING FILE RUNID'
        CLOSE (8)
        !--RUN INDICATOR FILE
        OPEN (9,FILE='DIAG.TXT',FORM='FORMATTED',STATUS='REPLACE')
        PRINT*,'PROCESS',MYID,'CREATING FILE DIAG.TXT'
        WRITE (9,*,IOSTAT=ERROR)
        IF (ERROR /= 0) THEN 
            WRITE (*,*) 'Stop the DS2.EXE that is 
 +already running and try again'       
        STOP
        ELSE
         WRITE (9,*) 'File DIAG.TXT has been opened'
    END IF 
    END IF

    CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
    !

   IF (MYID == 0) THEN
    DO WHILE ((IRUN < 1).OR.(IRUN > 3))
      WRITE (*,*) 'DS2 Version',NVER,'.',MVER
      WRITE (*,*) 'Send 1 to continue the current run
 +, or'   
      WRITE (*,*) 'send 2 to adapt cells and then 
 +continue, or'    
      WRITE (*,*) 'send 3 to start a new run :-'
    !
     READ (*,*) IRUN

    END DO
   END IF

   CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
   PRINT*,'PROCESSOR',MYID,'LEFT THE BARRIER'
   CALL MPI_BCAST(IRUN,1,MPI_INTEGER,0,MPI_COMM_WORLD,IERR)


    IF (MYID == 0) THEN
    IF (IRUN == 1) WRITE (9,*) 'Continuing the current run'
    IF (IRUN == 2) WRITE (9,*) 'Adapting the cells'
    IF (IRUN == 3) WRITE (9,*) 'Starting a new run'
    END IF
    IVELS=0    !--OPTIONAL MENU LATER
    !
    J4=4   !--PV subscripts numbers to avoid crashes when PV is dimensioned to 3
    J5=5
    J12=12  !--similar for ccell
    !
    !--set the number of previous collision partners to be retained
    NIPC=1
    !--there appears to be no gain in values greater than one
    !

    !
      NBAD=0        !--number of boundary adaptions
      IFILENT=0     !--becomes 1 if there is a molecule entry file
      IFILGEN=0     !--becomes 2 if a molecule output file is to be generated at an internal line
      IEFILE=0      !--becomes 1 if the output file is active
    !
    !--open a new flow history file

     IF(MYID==0) THEN
      OPEN (10,FILE='FHIST.SCR',FORM='BINARY',STATUS='REPLACE',
 +                                                  ACTION='WRITE')
        PRINT*,'PROCESS',MYID,'IS WRITING FHIST.SCR'     
      CLOSE (10)
    !
    END IF

    CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
    PRINT*,'PROCESSOR',MYID,'LEFT THE BARRIER'

    IFILE = 0
    DO IFILE=0,NPROCS-1
        IF (MYID == IFILE) THEN
            PRINT*,'PROCESSOR',MYID,'IS READING DATA'
            CALL READ_DATA(ID)
            PRINT*,'PROCESSOR',MYID,'SUCCESSFULLY READ DATA'
         ELSE
           CALL MPI_BARRIER(MPI_COMM_WORLD,IERR)
         END IF  
    END DO      

   CALL MPI_BARRIER(MPI_COMM_WORLD,IERR) 


   CALL MPI_FINALIZE(IERR)   

        END PROGRAM DS2V
    !

这是我从mpi获得的输出

PROCESS           0 WRITING FILE RUNID
PROCESS           0 CREATING FILE DIAG.TXT
DS2 Version           4 .           5
Send 1 to continue the current run, or
send 2 to adapt cells and then continue, or
send 3 to start a new run :-
3
PROCESSOR           0 LEFT THE BARRIER
PROCESS           0 IS WRITING FHIST.SCR
PROCESSOR           0 LEFT THE BARRIER
PROCESSOR           0 IS READING DATA
I HAVE RECEIVED ID FROM MAIN           0
The number of divisions in the x direction is         230
The number of divisions in the y direction is          95
The Scale Factor is   800.0000    
The data summary DS2VD.TXT has been written
forrtl: severe (157): Program Exception - access violation
Image              PC                Routine            Line        Source             
DeinoFMPI.dll      0000000180001581  Unknown               Unknown  Unknown
DSMC_READ_DATA_TE  0000000140003FDC  MAIN__                    139  MAIN_PROGRAM.for
DSMC_READ_DATA_TE  0000000140150D8C  Unknown               Unknown  Unknown
DSMC_READ_DATA_TE  00000001400E05F7  Unknown               Unknown  Unknown
DSMC_READ_DATA_TE  00000001400E04FE  Unknown               Unknown  Unknown
kernel32.dll       0000000077A1652D  Unknown               Unknown  Unknown
ntdll.dll          0000000077C4C521  Unknown               Unknown  Unknown

正如您所看到的,只有进程0成功运行子例程

你能帮帮我..?

谢谢

0 个答案:

没有答案