5
implicit double precision (a-h,o-z)
7
c FORTRAN program to test message passing routines
9
c LOG is the FORTRAN unit number for standard output.
12
parameter (MAXLEN = 262144 )
13
#include "msgtypesf.h"
19
c Always the first thing to do is call pbeginf
25
c who am i and how many processes
30
c now try broadcasting messages from all nodes to every other node
31
c send each process my id as a message
33
call evbgin('Hello test')
36
do 10 iproc = 0,nproc-1
38
call brdcst(itype, itest, mitob(1),iproc)
40
write(LOG,1) me, itest
41
1 format(' me=',i3,', itest=',i3)
44
call evend('Hello test')
45
call evbgin('Counter test')
47
c now try using the shared counter
51
write(LOG,*) ' process ',me,' got ',nxtval(mproc)
54
call evend('Counter test')
56
c now time sending a message round a ring
59
call evbgin('Ring test')
61
left = mod(me + nproc - 1, nproc)
62
iright = mod(me + 1, nproc)
65
30 if (me .eq. 0) then
67
call snd(itype, buf, lenbuf, left, 1)
68
call rcv(itype, buf, lenbuf, lenmes, iright, node, 1)
69
used = tcgtime() - start
71
rate = 1.0d-6 * dble(nproc * lenbuf) / used
75
write(LOG,31) lenbuf, used, rate
77
call rcv(itype, buf, lenbuf, lenmes, iright, node, 1)
78
call snd(itype, buf, lenbuf, left, 1)
81
if (lenbuf .le. mdtob(MAXLEN)) goto 30
82
31 format(' len=',i7,' bytes, used=',f8.2,' cs, rate=',f10.6,' Mb/s')
83
call evend('Ring test')
90
buf(i) = dble(ibuf(i))
93
call igop(itype, ibuf, MAXLEN, "+")
94
call dgop(dtype, buf, MAXLEN, "+")
97
iresult = i*nproc*(nproc-1)/2
98
if (ibuf(i).ne.iresult.or.buf(i).ne.dble(iresult))
99
. call error('TestGlobals: global sum failed', i)
102
if (me.eq.0) write(LOG,*) 'global sums OK'
106
c Check that everyone can open, write, read and close
107
c a binary FORTRAN file
109
call pfname('junk',fname)
110
open(9,file=fname,form='unformatted',status='unknown',
112
write(9,err=1001) buf
115
close(9,status='delete')
116
call event('Read file OK')
118
if (me.eq.0) call stats
120
c Always the last thing to do is call pend
124
c check that everyone makes it thru after pend .. NODEID
125
c is not actually guaranteed to work outside of pbegin/pend
126
c section ... it may return junk. All you should do is exit
127
c is some FORTRAN supported fashion
129
write(LOG,32) nodeid()
130
32 format(' Process ',i4,' after pend')
133
c error returns for FORTRAN I/O
135
1000 call error('failed to open fortran binary file',-1)
136
1001 call error('failed to write fortran binary file',-1)
137
1002 call error('failed to read fortran binary file',-1)
140
subroutine pfname(name, fname)
141
character*(*) name, fname
143
c construct a unique filename by appending the process
144
c number after the stub name
145
c i.e. <fname> = <name>.<mynode>
147
c find last non-blank character in name
149
do 10 i = len(name),1,-1
150
if (name(i:i).ne.' ') goto 20
152
call error('pfname: name is all blanks!',i)
154
c check that have room to store result and then write result
156
20 if (i+4.gt.len(fname))
157
& call error('pfname: fname too short for name.id',len(fname))
159
write(fname(i+1:i+4),1) nodeid()
163
subroutine error(s,i)
170
$ ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'/
172
$ ' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'/)