LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Arroyo, Elkin (elkin.arroyo_at_[hidden])
Date: 2006-01-06 15:04:36


Hola !
 
I am trying to execute an external program in several procesors. Below is
a copy of my current code. I am getting a problem after executing the command
system. The node is unable to see the executable that I want to run. Any suggestion ?
is there any other way to wath I intend ?
 
This code is being running in a SGI Altrix machine with 128 processors
 
program parallelRunSim
! // -*- Fortran90 -*-
!/*****************************************************************************/
!/* */
!/* (c) Copyright 2005 */
!/* Texas A&M University */
!/* All left reserved. */
!/* */
!/* See http://pumpjack.tamu.edu/ for further details. */
!/* */
!/*****************************************************************************/
! This program is intendent to be used in conjunction with the ensemble Kalman
! filter code writen by earroyo. The purpose of the program is to call the
! forward simulator @frontsim/@eclipse in parallel instead of sequential
! as the current version of the code does it.
!
! Elkin Rafael Arroyo-Negrete
! Numerica Ltda
! Texas A&M University
USE MPI
USE IFPORT
USE mod_string_function
IMPLICIT NONE
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)
integer ne ! Number of ensemble members or number of times I want to run the simulator
character(len=128) wrkdir ! working dir
character(len=128) command ! command to call the simulator @frontsim
character(len=128) inputfile ! simulator input data file
character(len=128) execommand ! final command to send to the system @frontsim -override -data inputfile
character(len=128) mod_wrk_dir ! working dir for each member wrkdir/member001
character(len=128) dummy01 ! intermedia variable
character(LEN=256) cwdir ! directory from were we are running the application
integer i,ios
logical statu
integer(4) ISTATUS

call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)

! Mater must read the configuration file provided by the EnKF program
! this information should be send to each processor via MPI_SEND
if(rank .eq. 0) then
  ! Read configuration file
  open(UNIT=777,FILE="simInfo.enkf",STATUS='OLD',IOSTAT=ios)
  if(abs(ios)>1) then
    write(0,*) ">>>>>>>> FATAL ERROR:"
    write(6,*) "parallelRunSim:"
    write(0,*) "Problems opening file simInfo.enkf "
    call MPI_FINALIZE(ierror)
    stop "Stopping the program..."
  endif
  read(777,*) ne ! read the number of times the simulator should be called
  read(777,*) wrkdir ! read the prefix where data file for each simulation is saved
  read(777,*) command ! read the name of the simulator can be @frontsim or @eclipse
  read(777,*) inputfile ! read the input data file for the simulator
  close(777)
! Current working dir
ISTATUS=GETCWD(cwdir)
! Now send the information to each processor
  do i=1,size-1
     call MPI_SEND(command,128,MPI_CHARACTER,i,tag,MPI_COMM_WORLD,ierror)
     call MPI_SEND(wrkdir, 128,MPI_CHARACTER,i,tag,MPI_COMM_WORLD,ierror)
     call MPI_SEND(inputfile,128,MPI_CHARACTER,i,tag,MPI_COMM_WORLD,ierror)
     call MPI_SEND(ne ,1 ,MPI_INTEGER ,i,tag,MPI_COMM_WORLD,ierror)
     call MPI_SEND(cwdir, 256,MPI_CHARACTER,i,tag,MPI_COMM_WORLD,ierror)
  enddo
else
! On each processor listen to the information send by the master
  call MPI_RECV(command,128,MPI_CHARACTER,0,tag,MPI_COMM_WORLD,status,ierror)
  call MPI_RECV(wrkdir ,128,MPI_CHARACTER,0,tag,MPI_COMM_WORLD,status,ierror)
  call MPI_RECV(inputfile,128,MPI_CHARACTER,0,tag,MPI_COMM_WORLD,status,ierror)
  call MPI_RECV(ne ,1 ,MPI_INTEGER ,0,tag,MPI_COMM_WORLD,status,ierror)
  call MPI_RECV(cwdir, 256,MPI_CHARACTER, 0,tag,MPI_COMM_WORLD,status,ierror)
endif
dummy01=concatenate(wrkdir,"/","member")
! Now each processor even the master should call the simulator
do i=rank+1,ne,size
   execommand =concatenate_space(command,"-override -data ",command)
   mod_wrk_dir=add_suffix(dummy01,i)
   write(6,*) "parallelRunSim:"
   write(6,'(A10,I4,A8,A20,A35)')"From node ",rank," at dir ",mod_wrk_dir," calling the simulator with command"
   write(6,'(A79)') execommand
   
  ! this CPU should go up to the member dir for
   ISTATUS=CHDIR(mod_wrk_dir)
   statu=system(execommand)
   ! come back to the initial working wir
   ISTATUS=CHDIR(cwdir)
   if(statu) then
     write(0,*) ">>>>>>> FATAL ERROR"
     write(0,*) "parallelRunSim:"
     write(0,*) "At node ",rank," while running the simulator with command"
     write(0,'(A79)') execommand
     call MPI_FINALIZE(ierror)
     stop 'A unxpected problem executing the command was found, stopping program...'
  endif
enddo
call MPI_FINALIZE(ierror)
end program parallelRunSim