24 module block_control_mod
26 use mpp_mod,
only:
mpp_error, note, warning, fatal
35 integer,
dimension(:,:),
allocatable :: ix
41 integer,
dimension(:),
allocatable :: ii
42 integer,
dimension(:),
allocatable :: jj
48 integer :: nx_block, ny_block
50 integer :: isc, iec, jsc, jec
52 integer,
dimension(:),
allocatable :: ibs , & !< block extents for mpp-style
56 type(
ix_type),
dimension(:),
allocatable :: ix
58 integer,
dimension(:),
allocatable :: blksz
60 integer,
dimension(:,:),
allocatable :: blkno
61 integer,
dimension(:,:),
allocatable :: ixp
63 type(
pk_type),
dimension(:),
allocatable :: index
79 nx_block, ny_block, message)
80 character(len=*),
intent(in) :: component
82 integer,
intent(in) :: isc, iec, jsc, jec, kpts
83 integer,
intent(in) :: nx_block, ny_block
84 logical,
intent(inout) :: message
103 integer,
dimension(nx_block) :: i1, i2
104 integer,
dimension(ny_block) :: j1, j2
105 character(len=256) :: text
106 integer :: i, j, nblks, ix, ii, jj
109 if ((mod(iec-isc+1,nx_block) .ne. 0) .or. (mod(jec-jsc+1,ny_block) .ne. 0))
then
110 write( text,
'(a,a,2i4,a,2i4,a)' ) trim(component),
'define_blocks: domain (',&
111 (iec-isc+1), (jec-jsc+1),
') is not an even divisor with definition (',&
112 nx_block, ny_block,
') - blocks will not be uniform'
119 if (iec-isc+1 .lt. nx_block) &
120 call mpp_error(fatal,
'block_control: number of '//trim(component)//.gt.
' nxblocks &
121 &number of elements in MPI-domain size')
122 if (jec-jsc+1 .lt. ny_block) &
123 call mpp_error(fatal,
'block_control: number of '//trim(component)//.gt.
' nyblocks &
124 &number of elements in MPI-domain size')
128 nblks = nx_block*ny_block
134 block%nx_block = nx_block
135 block%ny_block = ny_block
138 if (.not.
allocated(block%ibs)) &
139 allocate (block%ibs(nblks), &
149 block%ibs(blocks) = i1(i)
150 block%jbs(blocks) = j1(j)
151 block%ibe(blocks) = i2(i)
152 block%jbe(blocks) = j2(j)
153 allocate(block%ix(blocks)%ix(i1(i):i2(i),j1(j):j2(j)) )
158 block%ix(blocks)%ix(ii,jj) = ix
174 kpts, blksz, message)
175 character(len=*),
intent(in) :: component
177 integer,
intent(in) :: isc, iec, jsc, jec, kpts
178 integer,
intent(inout) :: blksz
179 logical,
intent(inout) :: message
193 integer :: nblks, lblksz, tot_pts, nb, ix, ii, jj
194 character(len=256) :: text
196 tot_pts = (iec - isc + 1) * (jec - jsc + 1)
201 nblks = tot_pts/blksz
202 if (mod(tot_pts,blksz) .gt. 0)
then
208 if (mod(tot_pts,blksz) .ne. 0)
then
209 write( text,
'(a,a,2i4,a,i4,a,i4)' ) trim(component),
'define_blocks_packed: domain (',&
210 (iec-isc+1), (jec-jsc+1),
') is not an even divisor with definition (',&
211 blksz,
') - blocks will not be uniform with a remainder of ',mod(tot_pts,blksz)
223 if (.not.
allocated(block%blksz)) &
224 allocate (block%blksz(nblks), &
225 block%index(nblks), &
226 block%blkno(isc:iec,jsc:jec), &
227 block%ixp(isc:iec,jsc:jec))
232 if (nb .EQ. nblks) lblksz = tot_pts - (nb-1) * blksz
233 block%blksz(nb) = lblksz
234 allocate (block%index(nb)%ii(lblksz), &
235 block%index(nb)%jj(lblksz))
244 if (ix .GT. blksz)
then
248 block%ixp(ii,jj) = ix
249 block%blkno(ii,jj) = nb
250 block%index(nb)%ii(ix) = ii
251 block%index(nb)%jj(ix) = jj
257 end module block_control_mod
subroutine, public define_blocks_packed(component, Block, isc, iec, jsc, jec, kpts, blksz, message)
Creates and populates a data type which is used for defining the sub-blocks of the MPI-domain to enha...
subroutine, public define_blocks(component, Block, isc, iec, jsc, jec, kpts, nx_block, ny_block, message)
Sets up "blocks" used for OpenMP threading of column-based calculations using rad_n[x/y]xblock from c...
Block data and extents for OpenMP threading of column-based calculations.
Type to dereference packed index from global index.
Type to dereference packed index from global indices.
subroutine mpp_compute_extent(isg, ieg, ndivs, ibegin, iend, extent)
Computes extents for a grid decomposition with the given indices and divisions.