14 use mpi,
only : mpi_request_null
39 type(model_state_type),
target,
intent(inout) :: current_state
41 if (.not. is_component_enabled(current_state%options_database,
"diverr"))
then
42 call log_master_log(log_error,
"The pressure source component requires the diverr component to be enabled")
46 allocate(
send_buffer_x(current_state%local_grid%size(z_index)-1, current_state%local_grid%size(y_index)), &
47 current_state%psrce_recv_buffer_x(current_state%local_grid%size(z_index)-1, current_state%local_grid%size(y_index)))
50 allocate(
send_buffer_y(current_state%local_grid%size(z_index)-1, current_state%local_grid%size(x_index)), &
51 current_state%psrce_recv_buffer_y(current_state%local_grid%size(z_index)-1, current_state%local_grid%size(x_index)))
53 current_state%psrce_x_hs_send_request=mpi_request_null
54 current_state%psrce_y_hs_send_request=mpi_request_null
55 current_state%psrce_x_hs_recv_request=mpi_request_null
56 current_state%psrce_y_hs_recv_request=mpi_request_null
62 type(model_state_type),
target,
intent(inout) :: current_state
65 if (.not. current_state%halo_column)
call calculate_psrce(current_state)
72 type(model_state_type),
target,
intent(inout) :: current_state
75 if (
allocated(current_state%psrce_recv_buffer_x))
deallocate(current_state%psrce_recv_buffer_x)
77 if (
allocated(current_state%psrce_recv_buffer_y))
deallocate(current_state%psrce_recv_buffer_y)
85 type(model_state_type),
target,
intent(inout) :: current_state
87 integer :: k, local_y, local_x, corrected_y, corrected_x
88 logical :: last_x, last_y
90 local_y=current_state%column_local_y
91 local_x=current_state%column_local_x
92 last_y = local_y == current_state%local_grid%local_domain_end_index(y_index)
93 last_x = local_x == current_state%local_grid%local_domain_end_index(x_index)
94 if (last_x .or. last_y)
then
95 corrected_x=local_x-current_state%local_grid%halo_size(x_index)
96 corrected_y=local_y-current_state%local_grid%halo_size(y_index)
98 do k=2,current_state%local_grid%size(z_index)
100 current_state%p%data(k, local_y, local_x)=current_state%p%data(k, local_y, local_x)+&
101 4.0_default_precision*(current_state%global_grid%configuration%vertical%tzc2(k)*&
102 current_state%sw%data(k, local_y, local_x)-&
103 current_state%global_grid%configuration%vertical%tzc1(k)*current_state%sw%data(k-1, local_y, local_x))
106 current_state%p%data(k, local_y, local_x)=current_state%p%data(k, local_y, local_x)+&
107 current_state%global_grid%configuration%horizontal%cx * current_state%su%data(k, local_y, local_x)
110 current_state%p%data(k, local_y, local_x)=current_state%p%data(k, local_y, local_x)+&
111 current_state%global_grid%configuration%horizontal%cy * current_state%sv%data(k, local_y, local_x)
114 if (local_x .gt. 3)
then
115 current_state%p%data(k, local_y, local_x)=current_state%p%data(k, local_y, local_x)-&
116 current_state%global_grid%configuration%horizontal%cx * current_state%su%data(k, local_y, local_x-1)
121 current_state%global_grid%configuration%horizontal%cx * current_state%su%data(k, local_y, local_x)
125 if (local_y .gt. 3 .and. local_x .gt. 3)
then
126 current_state%p%data(k, local_y, local_x)=current_state%p%data(k, local_y, local_x)-&
127 current_state%global_grid%configuration%horizontal%cy * current_state%sv%data(k, local_y-1, local_x)
131 current_state%global_grid%configuration%horizontal%cy * current_state%sv%data(k, local_y, local_x)
140 type(model_state_type),
target,
intent(inout) :: current_state
145 if (current_state%local_grid%neighbours(x_index,3) .eq. current_state%parallel%my_rank)
then
149 10, current_state%parallel%neighbour_comm, current_state%psrce_x_hs_send_request, ierr)
153 if (current_state%local_grid%neighbours(y_index,3) .eq. current_state%parallel%my_rank)
then
157 10, current_state%parallel%neighbour_comm, current_state%psrce_y_hs_send_request, ierr)
165 type(model_state_type),
target,
intent(inout) :: current_state
170 if (current_state%local_grid%neighbours(x_index,2) .ne. current_state%parallel%my_rank)
then
171 call mpi_irecv(current_state%psrce_recv_buffer_x,
size(current_state%psrce_recv_buffer_x), precision_type, &
172 current_state%local_grid%neighbours(x_index,2), 10, current_state%parallel%neighbour_comm, &
173 current_state%psrce_x_hs_recv_request, ierr)
177 if (current_state%local_grid%neighbours(y_index,2) .ne. current_state%parallel%my_rank)
then
178 call mpi_irecv(current_state%psrce_recv_buffer_y,
size(current_state%psrce_recv_buffer_y), precision_type, &
179 current_state%local_grid%neighbours(y_index,2), 10, current_state%parallel%neighbour_comm, &
180 current_state%psrce_y_hs_recv_request, ierr)