24 #include <fms_platform.h> 32 integer,
dimension(:,:), _allocatable :: ix _null
36 integer,
dimension(:), _allocatable :: ii _null
37 integer,
dimension(:), _allocatable :: jj _null
41 integer :: nx_block, ny_block
43 integer :: isc, iec, jsc, jec
45 integer,
dimension(:), _allocatable :: ibs _null, & !< block extents for mpp-style
49 type(
ix_type),
dimension(:), _allocatable :: ix _null
51 integer,
dimension(:), _allocatable :: blksz _null
53 integer,
dimension(:,:), _allocatable :: blkno _null
54 integer,
dimension(:,:), _allocatable :: ixp _null
56 type(
pk_type),
dimension(:), _allocatable :: index _null
91 subroutine define_blocks (component, Block, isc, iec, jsc, jec, kpts, &
92 nx_block, ny_block, message)
93 character(len=*),
intent(in) :: component
95 integer,
intent(in) :: isc, iec, jsc, jec, kpts
96 integer,
intent(in) :: nx_block, ny_block
97 logical,
intent(inout) :: message
115 integer,
dimension(nx_block) :: i1, i2
116 integer,
dimension(ny_block) :: j1, j2
117 character(len=256) :: text
118 integer :: i, j, nblks, ii, jj
121 if ((mod(iec-isc+1,nx_block) .ne. 0) .or. (mod(jec-jsc+1,ny_block) .ne. 0))
then 122 write( text,
'(a,a,2i4,a,2i4,a)' ) trim(component),
'define_blocks: domain (',&
123 (iec-isc+1), (jec-jsc+1),
') is not an even divisor with definition (',&
124 nx_block, ny_block,
') - blocks will not be uniform' 131 if (iec-isc+1 .lt. nx_block) &
132 call mpp_error(fatal,
'block_control: number of '//trim(component)//.gt.
' nxblocks & 133 &number of elements in MPI-domain size')
134 if (jec-jsc+1 .lt. ny_block) &
135 call mpp_error(fatal,
'block_control: number of '//trim(component)//.gt.
' nyblocks & 136 &number of elements in MPI-domain size')
137 call mpp_compute_extent(isc,iec,nx_block,i1,i2)
138 call mpp_compute_extent(jsc,jec,ny_block,j1,j2)
140 nblks = nx_block*ny_block
146 block%nx_block = nx_block
147 block%ny_block = ny_block
150 if (.not._allocated(block%ibs)) &
151 allocate (block%ibs(nblks), &
161 block%ibs(blocks) = i1(i)
162 block%jbs(blocks) = j1(j)
163 block%ibe(blocks) = i2(i)
164 block%jbe(blocks) = j2(j)
165 allocate(block%ix(blocks)%ix(i1(i):i2(i),j1(j):j2(j)) )
170 block%ix(blocks)%ix(ii,jj) = ix
208 kpts, blksz, message)
209 character(len=*),
intent(in) :: component
211 integer,
intent(in) :: isc, iec, jsc, jec, kpts
212 integer,
intent(inout) :: blksz
213 logical,
intent(inout) :: message
227 integer :: nblks, lblksz, tot_pts, ii, jj, nb, ix
228 character(len=256) :: text
230 tot_pts = (iec - isc + 1) * (jec - jsc + 1)
235 if (mod(tot_pts,blksz) .eq. 0)
then 236 nblks = tot_pts/blksz
238 nblks = ceiling(
real(tot_pts)/
real(blksz))
243 if (mod(tot_pts,blksz) .ne. 0)
then 244 write( text,
'(a,a,2i4,a,i4,a,i4)' ) trim(component),
'define_blocks_packed: domain (',&
245 (iec-isc+1), (jec-jsc+1),
') is not an even divisor with definition (',&
246 blksz,
') - blocks will not be uniform with a remainder of ',mod(tot_pts,blksz)
258 if (.not. _allocated(block%blksz)) &
259 allocate (block%blksz(nblks), &
260 block%index(nblks), &
261 block%blkno(isc:iec,jsc:jec), &
262 block%ixp(isc:iec,jsc:jec))
267 if (nb .EQ. nblks) lblksz = tot_pts - (nb-1) * blksz
268 block%blksz(nb) = lblksz
269 allocate (block%index(nb)%ii(lblksz), &
270 block%index(nb)%jj(lblksz))
279 if (ix .GT. blksz)
then 283 block%ixp(ii,jj) = ix
284 block%blkno(ii,jj) = nb
285 block%index(nb)%ii(ix) = ii
286 block%index(nb)%jj(ix) = jj
subroutine, public define_blocks(component, Block, isc, iec, jsc, jec, kpts, nx_block, ny_block, message)
subroutine, public define_blocks_packed(component, Block, isc, iec, jsc, jec, kpts, blksz, message)