Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
!***********************************************************************
!
!
SUBROUTINE read_b_bin
!
!
!***********************************************************************
!
!
! Subroutine to read in the data associated with the bodies from
! the BINARY input file.
!=======================================================================
USE fly_h
implicit none
INCLUDE 'mpif.h'
! Declaration of local variables.
! -------------------------------
INTEGER(KIND=MPI_ADDRESS_KIND) :: startIndex
INTEGER :: p,tag,istatus(MPI_STATUS_SIZE)
CHARACTER(LEN=4) :: ifl
CHARACTER(LEN=256) :: name_file
!
! mass_read is the value of the mass of each body of the simulation
!
!=======================================================================
! propagate the mass_read value to all bodies
DO p=1,nb_loc
mass(p)=mass_read
ENDDO
! Read in body data.
! ------------------
IF(nbodies.GT.nbodsmax) &
CALL error('read_b_bin error1: inconsistent input')
IF (me.EQ.0) THEN ! PE 0 execute the read operation
! Open input body data file.
! --------------------------
pos_rmt=0.0
name_file=ibodfile
IF(tstep.GT.1000) WRITE(ifl,'(I4.4)') tstep
IF(tstep.GE.100 .AND. tstep .LT. 1000) WRITE(ifl,'(I3.3)') tstep
IF(tstep.GE.10 .AND. tstep .LT. 100) WRITE(ifl,'(I2.2)') tstep
IF(tstep.LT. 10) WRITE(ifl,'(I1.1)') tstep
name_file=TRIM(name_file)//ifl
call c_open_b_bin(name_file)
nlong=nb_res_loc(me+1)*3
call c_read_b_bin(pos(1,1),nlong)
DO PE_indx=1,NPES-1 ! read and transmit
nlong=nb_res_loc(pe_indx+1)*3
call c_read_b_bin(pos_rmt(1,1),nlong)
tag = 1
CALL MPI_SEND(pos_rmt(1,1),NLONG, MPI_REAL8, PE_indx, tag, MPI_COMM_WORLD, ierror)
ENDDO
nlong=nb_res_loc(me+1)*3
call c_read_b_bin(vel(1,1),nlong)
DO PE_indx=1,NPES-1 ! read and transmit
nlong=nb_res_loc(pe_indx+1)*3
call c_read_b_bin(pos_rmt(1,1),nlong)
tag = 2
CALL MPI_SEND(pos_rmt(1,1),NLONG, MPI_REAL8, PE_indx, tag, MPI_COMM_WORLD, ierror)
ENDDO
call c_close_b_bin()
ELSE
NLONG=nb_res_loc(me+1)*3
tag=1
CALL MPI_RECV(pos(1,1), NLONG, MPI_REAL8, PE0, tag, MPI_COMM_WORLD, istatus, ierror)
tag=2
CALL MPI_RECV(vel(1,1), NLONG, MPI_REAL8, PE0, tag, MPI_COMM_WORLD, istatus, ierror)
ENDIF ! IF (me.eq.NPES-1)
CALL MPI_BARRIER(MPI_COMM_WORLD,ierror)
IF(me.eq.0) THEN
write(uterm,*) 'pos first = ', pos(1:3,1)
write(uterm,*) 'vel first = ', vel(1:3,1)
call flush(uterm)
ENDIF
CALL MPI_BARRIER(MPI_COMM_WORLD,ierror)
IF(me.eq.npes-1) THEN
write(uterm,*) 'pos last = ', pos(1:3,nb_res_loc(me+1))
write(uterm,*) 'vel last = ', vel(1:3,nb_res_loc(me+1))
call flush(uterm)
ENDIF
CALL MPI_BARRIER(MPI_COMM_WORLD,ierror)
RETURN
END