@@ -8,13 +8,13 @@ subroutine check(err, message)
8
8
use mpi
9
9
use pnetcdf
10
10
implicit none
11
- integer err
11
+ integer err, ierr
12
12
character (len=* ) message
13
13
14
14
! It is a good idea to check returned value for possible error
15
15
if (err .NE. NF90_NOERR) then
16
16
write (6 ,* ) trim (message), trim (nf90mpi_strerror(err))
17
- call MPI_Abort(MPI_COMM_WORLD, - 1 , err )
17
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr )
18
18
end if
19
19
end subroutine check
20
20
@@ -23,17 +23,19 @@ program main
23
23
use pnetcdf
24
24
implicit none
25
25
26
- logical verbose
26
+ logical verbose, using_bb
27
27
integer i, j, ncid, varid, err, ierr, rank, nprocs, info
28
- integer no_err, cmode, get_args
28
+ integer no_err, cmode, get_args, idx
29
29
integer dimid(2 ), req(2 ), status (2 )
30
30
integer (kind= MPI_OFFSET_KIND) start(2 )
31
31
integer (kind= MPI_OFFSET_KIND) count (2 )
32
32
integer (kind= MPI_OFFSET_KIND) stride(2 )
33
33
integer (kind= MPI_OFFSET_KIND) imap(2 )
34
- integer (kind= MPI_OFFSET_KIND) bufsize
34
+ integer (kind= MPI_OFFSET_KIND) bufsize, inq_bufsize
35
+ integer (kind= MPI_OFFSET_KIND) usage, acc_usage
35
36
real var(6 ,4 )
36
37
character (len= 256 ) :: filename, cmd, msg
38
+ character (len= 512 ) :: hints
37
39
38
40
call MPI_INIT(ierr)
39
41
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
@@ -54,6 +56,12 @@ program main
54
56
' is designed to run on 1 process'
55
57
endif
56
58
59
+ call getenv(" PNETCDF_HINTS" , hints)
60
+ idx = index (hints, " nc_burst_buf=enable" )
61
+
62
+ using_bb = .FALSE.
63
+ if (idx > 0 ) using_bb = .TRUE.
64
+
57
65
call MPI_Info_create(info, ierr)
58
66
! call MPI_Info_set(info, "romio_pvfs2_posix_write","enable",ierr)
59
67
@@ -90,10 +98,29 @@ program main
90
98
enddo
91
99
enddo
92
100
93
- ! bufsize must be max of data type converted before and after
94
- bufsize = 4 * 6 * 8
95
- err = nf90mpi_buffer_attach(ncid, bufsize)
96
- call check(err, ' Error at nf90mpi_buffer_attach ' )
101
+ if (.NOT. using_bb) then
102
+ ! bufsize must be max of data type converted before and after
103
+ bufsize = 4 * 6 * 8
104
+ acc_usage = 0
105
+ err = nf90mpi_buffer_attach(ncid, bufsize)
106
+ call check(err, ' Error at nf90mpi_buffer_attach ' )
107
+
108
+ err = nf90mpi_inq_buffer_size(ncid, inq_bufsize)
109
+ call check(err, ' Error at nf90mpi_inq_buffer_size ' )
110
+
111
+ if (inq_bufsize .NE. bufsize) then
112
+ print * ," Error: expect bufsize " ,bufsize," but got " ,inq_bufsize
113
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
114
+ end if
115
+
116
+ err = nf90mpi_inq_buffer_usage(ncid, usage)
117
+ call check(err, ' Error at nf90mpi_inq_buffer_usage ' )
118
+
119
+ if (usage .NE. acc_usage) then
120
+ print * ," Error: expect buf usage " ,acc_usage," but got " ,usage
121
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
122
+ end if
123
+ end if
97
124
98
125
! write var to the NC variable in the matrix transposed way
99
126
count (1 ) = 2
@@ -115,16 +142,50 @@ program main
115
142
stride, imap)
116
143
call check(err, ' Error at nf90mpi_bput_var ' )
117
144
145
+ acc_usage = acc_usage + count (1 ) * count (2 ) * 8
146
+
147
+ if (.NOT. using_bb) then
148
+ err = nf90mpi_inq_buffer_usage(ncid, usage)
149
+ call check(err, ' Error at nf90mpi_inq_buffer_usage ' )
150
+
151
+ if (usage .NE. acc_usage) then
152
+ print * ," Error: expect buf usage " ,acc_usage," but got " ,usage
153
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
154
+ end if
155
+ end if
156
+
118
157
! write the second two columns of the NC variable in the matrix transposed way
119
158
start(1 ) = 3
120
159
start(2 ) = 1
121
160
err = nf90mpi_bput_var(ncid, varid, var(1 :,3 :), req(2 ), start, count, &
122
161
stride, imap)
123
162
call check(err, ' Error at nf90mpi_bput_var ' )
124
163
164
+ acc_usage = acc_usage + count (1 ) * count (2 ) * 8
165
+
166
+ if (.NOT. using_bb) then
167
+ err = nf90mpi_inq_buffer_usage(ncid, usage)
168
+ call check(err, ' Error at nf90mpi_inq_buffer_usage ' )
169
+
170
+ if (usage .NE. acc_usage) then
171
+ print * ," Error: expect buf usage " ,acc_usage," but got " ,usage
172
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
173
+ end if
174
+ end if
175
+
125
176
err = nf90mpi_wait_all(ncid, 2 , req, status)
126
177
call check(err, ' Error at nf90mpi_wait_all ' )
127
178
179
+ if (.NOT. using_bb) then
180
+ err = nf90mpi_inq_buffer_usage(ncid, usage)
181
+ call check(err, ' Error at nf90mpi_inq_buffer_usage ' )
182
+
183
+ if (usage .NE. 0 ) then
184
+ print * ," Error: expect buf usage 0 but got " ,usage
185
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
186
+ end if
187
+ end if
188
+
128
189
! check each bput status
129
190
do i = 1 , 2
130
191
if (status (i) .ne. NF90_NOERR) then
@@ -135,6 +196,12 @@ program main
135
196
err = nf90mpi_buffer_detach(ncid)
136
197
call check(err, ' Error at nf90mpi_buffer_detach ' )
137
198
199
+ err = nf90mpi_inq_buffer_size(ncid, inq_bufsize)
200
+ if (err .NE. NF90_ENULLABUF) then
201
+ print * ," Error: unexpected error code " ,err
202
+ call MPI_Abort(MPI_COMM_WORLD, - 1 , ierr)
203
+ end if
204
+
138
205
! the output from command "ncmpidump -v var test.nc" should be:
139
206
! var =
140
207
! 50, 56, 62, 68,
0 commit comments