19 use mpi,
only : mpi_request_null, mpi_statuses_ignore
48 type(model_state_type),
target,
intent(inout) :: current_state
52 halo_depth = options_get_integer(current_state%options_database,
"halo_depth")
63 type(model_state_type),
target,
intent(inout) :: current_state
77 type(model_state_type),
target,
intent(inout) :: current_state
97 x_target_index, y_target_index, neighbour_location, current_page, source_data)
99 type(model_state_type),
intent(inout) :: current_state
100 integer,
intent(in) :: corner_loc, x_target_index, y_target_index, neighbour_location
101 integer,
intent(inout) :: current_page(:)
102 type(neighbour_description_type),
intent(inout) :: neighbour_description
103 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
105 integer :: page_bookmark, i
107 page_bookmark = current_page(neighbour_location)
109 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer,&
110 current_state%u%data, corner_loc, x_target_index, y_target_index, page_bookmark)
111 page_bookmark=page_bookmark+1
112 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
113 current_state%zu%data, corner_loc, x_target_index, y_target_index, page_bookmark)
114 page_bookmark=page_bookmark+1
117 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
118 current_state%v%data, corner_loc, x_target_index, y_target_index, page_bookmark)
119 page_bookmark=page_bookmark+1
120 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
121 current_state%zv%data, corner_loc, x_target_index, y_target_index, page_bookmark)
122 page_bookmark=page_bookmark+1
125 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
126 current_state%w%data, corner_loc, x_target_index, y_target_index, page_bookmark)
127 page_bookmark=page_bookmark+1
128 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
129 current_state%zw%data, corner_loc, x_target_index, y_target_index, page_bookmark)
130 page_bookmark=page_bookmark+1
132 if (current_state%th%active)
then
133 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
134 current_state%th%data, corner_loc, x_target_index, y_target_index, page_bookmark)
135 page_bookmark=page_bookmark+1
136 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
137 current_state%zth%data, corner_loc, x_target_index, y_target_index, page_bookmark)
138 page_bookmark=page_bookmark+1
140 do i=1,current_state%number_q_fields
141 if (current_state%q(i)%active)
then
142 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
143 current_state%q(i)%data, corner_loc, x_target_index, y_target_index, page_bookmark)
144 page_bookmark=page_bookmark + 1
145 call copy_buffer_to_corner(current_state%local_grid, neighbour_description%recv_corner_buffer, &
146 current_state%zq(i)%data, corner_loc, x_target_index, y_target_index, page_bookmark)
147 page_bookmark=page_bookmark + 1
150 current_page(neighbour_location)=page_bookmark
165 neighbour_location, current_page, source_data)
166 type(model_state_type),
intent(inout) :: current_state
167 integer,
intent(in) :: dim, target_index, neighbour_location
168 integer,
intent(inout) :: current_page(:)
169 type(neighbour_description_type),
intent(inout) :: neighbour_description
170 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
172 integer :: page_bookmark, i
174 page_bookmark = current_page(neighbour_location)
176 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
177 current_state%u%data, dim, target_index, page_bookmark)
178 page_bookmark=page_bookmark+1
179 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
180 current_state%zu%data, dim, target_index, page_bookmark)
181 page_bookmark=page_bookmark+1
184 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
185 current_state%v%data, dim, target_index, page_bookmark)
186 page_bookmark=page_bookmark+1
187 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
188 current_state%zv%data, dim, target_index, page_bookmark)
189 page_bookmark=page_bookmark+1
192 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
193 current_state%w%data, dim, target_index, page_bookmark)
194 page_bookmark=page_bookmark+1
195 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
196 current_state%zw%data, dim, target_index, page_bookmark)
197 page_bookmark=page_bookmark+1
199 if (current_state%th%active)
then
200 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
201 current_state%th%data, dim, target_index, page_bookmark)
202 page_bookmark=page_bookmark+1
203 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
204 current_state%zth%data, dim, target_index, page_bookmark)
205 page_bookmark=page_bookmark+1
207 do i=1,current_state%number_q_fields
208 if (current_state%q(i)%active)
then
209 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
210 current_state%q(i)%data, dim, target_index, page_bookmark)
211 page_bookmark=page_bookmark+1
212 call copy_buffer_to_field(current_state%local_grid, neighbour_description%recv_halo_buffer, &
213 current_state%zq(i)%data, dim, target_index, page_bookmark)
214 page_bookmark=page_bookmark+1
217 current_page(neighbour_location)=page_bookmark
232 pid_location, current_page, source_data)
234 type(model_state_type),
intent(inout) :: current_state
235 integer,
intent(in) :: dim, pid_location, source_index
236 integer,
intent(inout) :: current_page(:)
237 type(neighbour_description_type),
intent(inout) :: neighbour_description
238 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
240 integer :: page_bookmark, i
242 page_bookmark = current_page(pid_location)
245 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer,&
246 current_state%u%data, dim, source_index, page_bookmark)
247 page_bookmark = page_bookmark + 1
248 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer, &
249 current_state%zu%data, dim, source_index, page_bookmark)
250 page_bookmark = page_bookmark + 1
253 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer, &
254 current_state%v%data, dim, source_index, page_bookmark)
255 page_bookmark = page_bookmark + 1
256 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer, &
257 current_state%zv%data, dim, source_index, page_bookmark)
258 page_bookmark = page_bookmark + 1
261 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer, &
262 current_state%w%data, dim, source_index, page_bookmark)
263 page_bookmark = page_bookmark+1
264 call copy_field_to_buffer(current_state%local_grid, neighbour_description%send_halo_buffer, &
265 current_state%zw%data, dim, source_index, page_bookmark)
266 page_bookmark = page_bookmark+1
268 if (current_state%th%active)
then
269 call copy_field_to_buffer(current_state%local_grid, &
270 neighbour_description%send_halo_buffer, current_state%th%data, dim, source_index,&
272 page_bookmark = page_bookmark+1
273 call copy_field_to_buffer(current_state%local_grid, &
274 neighbour_description%send_halo_buffer, current_state%zth%data, dim, source_index, &
276 page_bookmark = page_bookmark+1
279 do i = 1,current_state%number_q_fields
280 if (current_state%q(i)%active)
then
281 call copy_field_to_buffer(current_state%local_grid, &
282 neighbour_description%send_halo_buffer, current_state%q(i)%data, dim, &
283 source_index, page_bookmark)
284 page_bookmark = page_bookmark + 1
285 call copy_field_to_buffer(current_state%local_grid, &
286 neighbour_description%send_halo_buffer, &
287 current_state%zq(i)%data, dim, source_index, page_bookmark)
288 page_bookmark = page_bookmark + 1
291 current_page(pid_location) = page_bookmark
308 x_source_index, y_source_index, pid_location, current_page, source_data)
310 type(model_state_type),
intent(inout) :: current_state
311 integer,
intent(in) :: corner_loc, pid_location, x_source_index, y_source_index
312 integer,
intent(inout) :: current_page(:)
313 type(neighbour_description_type),
intent(inout) :: neighbour_description
314 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
316 integer :: page_bookmark, i
318 page_bookmark = current_page(pid_location)
321 call copy_corner_to_buffer(current_state%local_grid, &
322 neighbour_description%send_corner_buffer,&
323 current_state%u%data, corner_loc, x_source_index, y_source_index, page_bookmark)
324 page_bookmark=page_bookmark+1
325 call copy_corner_to_buffer(current_state%local_grid, &
326 neighbour_description%send_corner_buffer, &
327 current_state%zu%data, corner_loc, x_source_index, y_source_index, page_bookmark)
328 page_bookmark=page_bookmark+1
331 call copy_corner_to_buffer(current_state%local_grid, &
332 neighbour_description%send_corner_buffer, &
333 current_state%v%data, corner_loc, x_source_index, y_source_index, page_bookmark)
334 page_bookmark=page_bookmark+1
335 call copy_corner_to_buffer(current_state%local_grid, &
336 neighbour_description%send_corner_buffer, &
337 current_state%zv%data, corner_loc, x_source_index, y_source_index, page_bookmark)
338 page_bookmark=page_bookmark+1
341 call copy_corner_to_buffer(current_state%local_grid, &
342 neighbour_description%send_corner_buffer, &
343 current_state%w%data, corner_loc, x_source_index, y_source_index, page_bookmark)
344 page_bookmark=page_bookmark+1
345 call copy_corner_to_buffer(current_state%local_grid, &
346 neighbour_description%send_corner_buffer, &
347 current_state%zw%data, corner_loc, x_source_index, y_source_index, page_bookmark)
348 page_bookmark=page_bookmark+1
350 if (current_state%th%active)
then
351 call copy_corner_to_buffer(current_state%local_grid, &
352 neighbour_description%send_corner_buffer,&
353 current_state%th%data, corner_loc, x_source_index, y_source_index, page_bookmark)
354 page_bookmark=page_bookmark+1
355 call copy_corner_to_buffer(current_state%local_grid, &
356 neighbour_description%send_corner_buffer, &
357 current_state%zth%data, corner_loc, x_source_index, y_source_index, page_bookmark)
358 page_bookmark=page_bookmark+1
360 do i=1,current_state%number_q_fields
361 if (current_state%q(i)%active)
then
362 call copy_corner_to_buffer(current_state%local_grid, &
363 neighbour_description%send_corner_buffer, &
364 current_state%q(i)%data, corner_loc, x_source_index, y_source_index, page_bookmark)
365 page_bookmark=page_bookmark+1
366 call copy_corner_to_buffer(current_state%local_grid, &
367 neighbour_description%send_corner_buffer, &
368 current_state%zq(i)%data, corner_loc, x_source_index, y_source_index, page_bookmark)
369 page_bookmark=page_bookmark+1
372 current_page(pid_location)=page_bookmark
378 type(model_state_type),
intent(inout) :: current_state
393 if (current_state%th%active)
then
396 do i=1,current_state%number_q_fields
397 if (current_state%q(i)%active)
then
408 integer,
intent(in) :: neighbour_counts, rank, included_fields
410 if (.not.
first_call .or. log_get_logging_level() .lt. log_debug)
return
411 call log_log(log_debug,
"Rank "//trim(conv_to_string(rank))//
": "//trim(conv_to_string(neighbour_counts))//&
412 " neighbours per timestep over "//trim(conv_to_string(included_fields))//
" fields")
423 type(model_state_type),
intent(inout) :: current_state
424 integer,
intent(in) :: halo_depth
425 logical,
intent(in) :: involve_corners
426 type(field_data_wrapper_type),
dimension(:),
intent(in),
optional :: source_data
431 call perform_local_data_copy_for_field(current_state%u%data, current_state%local_grid, &
432 current_state%parallel%my_rank, halo_depth, involve_corners)
433 call perform_local_data_copy_for_field(current_state%zu%data, current_state%local_grid, &
434 current_state%parallel%my_rank, halo_depth, involve_corners)
437 call perform_local_data_copy_for_field(current_state%v%data, current_state%local_grid, &
438 current_state%parallel%my_rank, halo_depth, involve_corners)
439 call perform_local_data_copy_for_field(current_state%zv%data, current_state%local_grid, &
440 current_state%parallel%my_rank, halo_depth, involve_corners)
443 call perform_local_data_copy_for_field(current_state%w%data, current_state%local_grid, &
444 current_state%parallel%my_rank, halo_depth, involve_corners)
445 call perform_local_data_copy_for_field(current_state%zw%data, current_state%local_grid, &
446 current_state%parallel%my_rank, halo_depth, involve_corners)
448 if (current_state%th%active)
then
449 call perform_local_data_copy_for_field(current_state%th%data, current_state%local_grid, &
450 current_state%parallel%my_rank, halo_depth, involve_corners)
451 call perform_local_data_copy_for_field(current_state%zth%data, current_state%local_grid, &
452 current_state%parallel%my_rank, halo_depth, involve_corners)
454 do i=1,current_state%number_q_fields
455 if (current_state%q(i)%active)
then
456 call perform_local_data_copy_for_field(current_state%q(i)%data, current_state%local_grid, &
457 current_state%parallel%my_rank, halo_depth, involve_corners)
458 call perform_local_data_copy_for_field(current_state%zq(i)%data, current_state%local_grid, &
459 current_state%parallel%my_rank, halo_depth, involve_corners)