Newsgroups: comp.parallel.pvm
From: Denny Moore <dmoore@bbn.com>
Subject: PVM/Fortan & I/O problems
Organization: BBN Corporation
Date: Wed, 18 Dec 1996 10:15:04 -0500
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="pvm"
Message-ID: <32B80A78.41C67EA6@bbn.com>

I am using pvm 3.3.11 on a BBN TC2000 [BFLY] (don't laugh; the machine has a great
debugger).  I am having problems with a master-slave program and file I/O for a
Fortran test case.  I am creating a master program that spawns a worker and
creates a direct access file for the worker to read.  The worker is apparently
opening the file OK, however, I get a file read error (past end-of-file) as if
the file doesn't exist.  I suspect the worker is not getting the correct file
handle info.  Also stdout messages from the worker are not being printed.  Something
is wrong with file I/O; what am I missing.

I have attached the master & worker fortran src, the make file and a print of
the messages that I get when I run the sample.  

Any help would be greatly appreciated.

*************************************************************************
  ___
 /  /_    
/__/(-/)/)V 
__________/
 
Denny Moore						dmoore@bbn.com
BBN Systems & Technologies				yilderim@aol.com
Union Station						mooresw@acm.org
New London, CT 06320                                    (860) 447-5925 (W)
					                (860) 447-1132 (Fax)
							(860) 536-3988 (H)
*************************************************************************

The compulsive programmer's pride and elation are very brief.  His success
consists of his having shown the computer who its master is.  And having
demonstrated that he can make it do this much, he immediately sets out to
make it do even more.  Thus the entire cycle begins again.

Joseph Weizenbaum

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

      program sara_master

      include 'fpvm3.h'

      integer   NTASKS
      parameter (NTASKS = 1)
      parameter (FROMMASTER_MSG	= 1)
      parameter (FROMWORKER_MSG	= 2)
      logical forever
      integer	     tids(NTASKS), rc, i, index, tid, 
     &               bufid, bytes, msgtype, chunksize
      character*80 command,buffer

      print *, '*********** Starting pvm_sara example ************'
      call pvmfmytid(rc)
      if (rc .lt. 0) then
        print *, 'SARA MASTER: Unable to enroll this task.'
        print *, '   Return code= ', rc, '.  Quitting.'
        stop
      else 
        print *, 'SARA MASTER: Enrolled as task id = ', rc
      endif

      print *, 'SARA MASTER: Spawning solver task'
      call pvmfspawn('/usr/dmoore/dev/sara4dp/pvm3/examples/sara_slave',
     &               PVMDEFAULT, ' ', NTASKS,
     &               tids, rc)
      if (rc .eq. NTASKS) then
        print *, 'SARA MASTER: Successfully spawned ', rc,
     $           ' solve task.'
      else 
        print *, 'SARA MASTER: Not able to spawn solve task!'
        stop
      endif

      open(unit=12,status='new',access='direct',
     $     form='unformatted',recl=10)
      do i = 1,5
        write(12,rec=i)i*10
        write(*,*)'writing i = ',i*10
      enddo
      close(12)


      print *, 'SARA MASTER: call worker'
      msgtype = FROMMASTER_MSG
      command = 'read'
      call pvmfinitsend(PVMDEFAULT, rc)
      call pvmfpack(STRING, command, 80, 1, rc)
      call pvmfsend(tids(1), msgtype, rc)

      print *, 'SARA MASTER: Waiting for result from solve task'
      msgtype = FROMWORKER_MSG
      call pvmfrecv(-1, msgtype, bufid)
      call pvmfbufinfo(bufid, bytes, msgtype, tid, rc)
      call pvmfunpack(STRING, buffer, 80, 1, rc)
      write(*,*)buffer
      print *, '---------------------------------------------------'
      print *, 'SARA MASTER: solver has finished'

      print *, 'SARA MASTER: All Done!' 
      call pvmfexit(rc)
      stop

      end
----------

      program sara_worker

      include 'fpvm3.h'

      parameter(FROMMASTER_MSG	= 1)
      parameter(FROMWORKER_MSG	= 2)

      integer      i, masterid, rc, index, msgtype, chunksize
      character*80 command

      call pvmfmytid(rc)
      if (rc .lt. 0) then
        print *, 'SARA WORKER: Unable to enroll this task.'
	print *, '   Return code = ', rc, '.   Quitting.'
        stop
      else
        print *, 'SARA WORKER: Enrolled as task id = ', rc
      endif

      msgtype = FROMMASTER_MSG
      call pvmfparent(masterid)
      call pvmfrecv(masterid, msgtype, rc)
      call pvmfunpack(STRING, command, 80, 1, rc)

      open(unit=12,status='old',access='direct',
     $     form='unformatted',recl=10,iostat=io,err=998)
      do i = 1,5
        read(12,rec=i,iostat=io,err=999)k
        write(*,*)'reading i = ',k
      enddo
      close(12)

      msgtype = FROMWORKER_MSG
      command = 'worker done'
      call pvmfinitsend(PVMDEFAULT, rc)
      call pvmfpack(STRING, command, 80, 1, rc)
      call pvmfsend(masterid, msgtype, rc)
      call pvmfexit(rc)
      stop

 998  write(*,*)'OPEN ERROR iostat = ',io
      msgtype = FROMWORKER_MSG
      command = 'open error'
      call pvmfinitsend(PVMDEFAULT, rc)
      call pvmfpack(STRING, command, 80, 1, rc)
      call pvmfsend(masterid, msgtype, rc)
      call pvmfexit(rc)

 999  write(*,*)'READ ERROR iostat = ',io
      msgtype = FROMWORKER_MSG
      command = 'read error'
      call pvmfinitsend(PVMDEFAULT, rc)
      call pvmfpack(STRING, command, 80, 1, rc)
      call pvmfsend(masterid, msgtype, rc)
      call pvmfexit(rc)

      stop

      end
----------

###############################################################################
# PVM Sara Makefile
# FILE: make.pvm_sara.f
# DESCRIPTION:  Makefile for pvm sara example.  Fortran Language
# AUTHOR: Denny Moore
# PVM VERSION: 3.x
# USE: make -f make.pvm_sara.f 
# LAST REVISED: 
###############################################################################

F77 	  =	f77 -g
MASTER 	  = 	sara_master
MASTERSRC = 	pvm_sara.master.f
WORKER 	  = 	sara_slave
WORKERSRC = 	pvm_sara.worker.f
PVMDIR    =     ${PVM_ROOT}
INCLUDE   =     -I${PVMDIR}/include
LIBS      =     -L${PVMDIR}/lib/BFLY -lfpvm3 -lpvm3


doit:  	${MASTER} ${WORKER}

${MASTER}: ${MASTERSRC} 
	${F77} ${MASTERSRC} ${INCLUDE} ${LIBS} -o ${MASTER}

${WORKER}: ${WORKERSRC}
	${F77} ${WORKERSRC} ${INCLUDE} ${LIBS} -o ${WORKER}




sara_master
 *********** Starting pvm_sara example ************
 SARA MASTER: Enrolled as task id =       262150
 SARA MASTER: Spawning solver task
 SARA MASTER: Successfully spawned            1 solve task.
 writing i =           10
 writing i =           20
 writing i =           30
 writing i =           40
 writing i =           50
 SARA MASTER: call worker
 SARA MASTER: Waiting for result from solve task
 read error                                                                      
 ---------------------------------------------------
 SARA MASTER: solver has finished
 SARA MASTER: All Done!




