19 integer(kind=MPI_ADDRESS_KIND) :: lb
20 integer(kind=MPI_ADDRESS_KIND) :: sizes
33 icomm = mpi_comm_world
36 call mpi_type_get_extent(mpi_real,lb,sizes,
ierrmpi)
37 if (sizes /= size_real)
call mpistop(
"Incompatible real size")
38 call mpi_type_get_extent(mpi_double_precision,lb,sizes,
ierrmpi)
39 if (sizes /= size_double)
call mpistop(
"Incompatible double size")
40 call mpi_type_get_extent(mpi_integer,lb,sizes,
ierrmpi)
41 if (sizes /= size_int)
call mpistop(
"Incompatible integer size")
42 call mpi_type_get_extent(mpi_logical,lb,sizes,
ierrmpi)
43 if (sizes /= size_logical)
call mpistop(
"Incompatible logical size")
51 call mpi_barrier(mpi_comm_world,
ierrmpi)
60 integer,
dimension(ndim+1) :: sizes, subsizes, start
61 integer :: i^
d, ic^
d, nx^
d, nxco^
d, nxg^
d, idir
63 nx^
d=ixmhi^
d-ixmlo^
d+1;
69 ^
d&subsizes(^
d)=nxg^
d;
73 call mpi_type_create_subarray(
ndim+1,sizes,subsizes,start, &
74 mpi_order_fortran,mpi_double_precision, &
81 ^
d&subsizes(^
d)=nxco^
d;
83 ^
d&start(^
d)=ixmlo^
d-1;
85 call mpi_type_create_subarray(
ndim+1,sizes,subsizes,start, &
86 mpi_order_fortran,mpi_double_precision, &
93 ^
d&subsizes(^
d)=nx^
d+1;
95 ^
d&start(^
d)=ixmlo^
d-1;
97 call mpi_type_create_subarray(
ndim+1,sizes,subsizes,start, &
98 mpi_order_fortran,mpi_double_precision, &
107 ^
d&subsizes(^
d)=nxco^
d+
kr(ic^
d,1)*
kr(idir,^
d);
109 ^
d&start(^
d)=ixmlo^
d-
kr(ic^
d,1)*
kr(idir,^
d);
112 call mpi_type_create_subarray(
ndim+1,sizes,subsizes,start, &
113 mpi_order_fortran,mpi_double_precision, &
119 ^d&sizes(^d)=ixghi^d+1;
123 ^d&subsizes(^d)=nxco^d+kr(ic^d,1)*kr(idir,^d);
125 ^d&start(^d)=ixmlo^d-kr(ic^d,1)*kr(idir,^d)+(ic^d-1)*nxco^d;
127 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
128 mpi_order_fortran,mpi_double_precision, &
129 type_sub_block_stg(idir,ic^d),ierrmpi)
130 call mpi_type_commit(type_sub_block_stg(idir,ic^d),ierrmpi)
135 ^d&sizes(^d)=ixghi^d;
138 ^d&subsizes(^d)=nxco^d;
140 ^d&start(^d)=ixmlo^d-1+(ic^d-1)*nxco^d;
142 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
143 mpi_order_fortran,mpi_double_precision, &
144 type_sub_block(ic^d),ierrmpi)
145 call mpi_type_commit(type_sub_block(ic^d),ierrmpi)
148 ^d&sizes(^d)=ixghi^d;
150 ^d&subsizes(^d)=nx^d;
152 ^d&start(^d)=ixmlo^d-1;
154 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
155 mpi_order_fortran,mpi_double_precision, &
156 type_block_io,ierrmpi)
157 call mpi_type_commit(type_block_io,ierrmpi)
158 size_block_io={nx^d*}*nw*size_double
160 ^d&sizes(^d)=ixmhi^d-ixmlo^d+1;
162 ^d&subsizes(^d)=sizes(^d);
166 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
167 mpi_order_fortran,mpi_double_precision, &
168 type_block_xcc_io,ierrmpi)
169 call mpi_type_commit(type_block_xcc_io,ierrmpi)
171 ^d&sizes(^d)=ixmhi^d-ixmlo^d+2;
173 ^d&subsizes(^d)=sizes(^d);
177 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
178 mpi_order_fortran,mpi_double_precision, &
179 type_block_xc_io,ierrmpi)
180 call mpi_type_commit(type_block_xc_io,ierrmpi)
182 ^d&sizes(^d)=ixmhi^d-ixmlo^d+1;
183 sizes(ndim+1)=nw+nwauxio
184 ^d&subsizes(^d)=sizes(^d);
185 subsizes(ndim+1)=nw+nwauxio
188 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
189 mpi_order_fortran,mpi_double_precision, &
190 type_block_wcc_io,ierrmpi)
191 call mpi_type_commit(type_block_wcc_io,ierrmpi)
193 ^d&sizes(^d)=ixmhi^d-ixmlo^d+2;
194 sizes(ndim+1)=nw+nwauxio
195 ^d&subsizes(^d)=sizes(^d);
196 subsizes(ndim+1)=nw+nwauxio
199 call mpi_type_create_subarray(ndim+1,sizes,subsizes,start, &
200 mpi_order_fortran,mpi_double_precision, &
201 type_block_wc_io,ierrmpi)
202 call mpi_type_commit(type_block_wc_io,ierrmpi)
210 character(len=*),
intent(in) :: message
213 write(*, *)
"ERROR for processor",
mype,
":"
214 write(*, *) trim(message)
subroutine, public init_comm_types
Create and store the MPI types that will be used for parallel communication.
subroutine, public comm_start
Initialize the MPI environment.
subroutine, public comm_finalize
Finalize (or shutdown) the MPI environment.
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer type_coarse_block
MPI type for block coarsened by 2, and for its children blocks.
integer ixghi
Upper index of grid block arrays.
integer, dimension(3, 3) kr
Kronecker delta tensor.
integer, parameter ndim
Number of spatial dimensions for grid variables.
logical stagger_grid
True for using stagger grid.
integer, dimension(^nd, 2^d &) type_coarse_block_stg
MPI type for staggered block coarsened by 2, and for its children blocks.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
integer, dimension(:), allocatable, parameter d
integer ierrmpi
A global MPI error return code.
integer npe
The number of MPI tasks.
integer type_block
MPI type for block including ghost cells and its size.
integer nghostcells
Number of ghost cells surrounding a grid.
integer type_block_io_stg
MPI type for IO of staggered variables.
integer size_block_io_stg
integer, parameter ixglo
Lower index of grid block arrays (always 1)