Skip to content

Commit

Permalink
added para_range2 to PARA_RANGE.f to support 2D decomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeVandenberghe-NOAA committed May 25, 2021
1 parent 25bf506 commit 37bc963
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions sorc/ncep_post.fd/PARA_RANGE.f
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,42 @@ SUBROUTINE PARA_RANGE (N1,N2,NPROCS,IRANK,ISTA,IEND)
if ( iwork2 > irank ) iend = iend + 1
return
end
!!
!! USAGE: CALL PARA_RANGE2(N1,N2,NPROCS,IRANK,ISTA,IEND)(A)
!! INPUT ARGUMENT LIST:
!! N1 - LAAT INTERATE VALUE I dimension
!! N2 - LAST INTERATE VALUE J dimension
!! NX NUMBER OF subdomains in Z dimension
!! NY NUMBER OF subdomains in Y dimension
!! NX * NY should be the total number of MPI procs
!! NRANK - MY TAKS ID
!!
!! OUTPUT ARGUMENT LIST:
!! ISTA - FIRST LOOP VALUE I
!! IEND - LAST LOOP VALUE I
!! JSTA - FIRST LOOP VALUE J
!! JEND - LAST LOOP VALUE J
!!
!! OUTPUT FILES:
!! STDOUT - RUN TIME STANDARD OUT.
!!
!! SUBPROGRAMS CALLED:
!! UTILITIES:
!! NONE
!! LIBRARY:
!!
!! ATTRIBUTES:
!! LANGUAGE: FORTRAN
!! MACHINE : IBM RS/6000 SP
!!
subroutine para_range2(im,jm,nx,ny,nrank,ista,iend,jsta,jend)
jx=nrank/nx
ix=nrank-(jx*nx)
call para_range(1,im,nx,ix,ista,iend)
call para_range(1,jm,ny,jx,jsta,jend)

This comment has been minimized.

Copy link
@HuiyaChuang-NOAA

HuiyaChuang-NOAA May 26, 2021

Contributor

@GeorgeVandenberghe-NOAA I would think the task ID (the 4th argument) is the same for two calls to para_range.
What do you think?

This comment has been minimized.

Copy link
@GeorgeVandenberghe-NOAA

GeorgeVandenberghe-NOAA May 26, 2021

Author Contributor

It's not the same. The first call determines the I subdomain over the domain 1:IM. The second call determines the J subdomain over the domain 1:JM. Logically it is the cell column number in the first call and the cell row number in the second call. Consider the case NTASKS=60, nx=10,ny=6 So in the case of six latitude subdomains and ten longitude domains, the first call determines the longitude range in the I subdomain and the second determines the latitude range in the J subdomain. There are 10 MPI ranks dealing with a row of longitudes and 6 MPI ranks dealing with a column of latitudes. I use the para_range logic to do the chopping. The number of subdomains is the product of 10 and 6 i.e. 60. I had a surprising amount of trouble keeping this straight in my mind and that's embarrassing. I still need to figure out a way to supply nx and ny for the general case and will probably chose a closest two factors of ntasks pair of numbers. For testing though I will choose nx=2 and ny=ntasks/2, That logically tests the decomposition. The current decomposition is a special case nx=1 and ny=ntasks.

MPI_FIRST will build each of the 2D subdomains into a reordered full record size data structure, build the displacements and scatter the structure for serial NetCDF input files. That's conceptually not difficult and if halos are a nuisance, I can also build them into the data structure. I haven't figured out if that's worth doing or not.

This comment has been minimized.

Copy link
@HuiyaChuang-NOAA

HuiyaChuang-NOAA May 28, 2021

Contributor

Thanks for explanation. You're right.
I will start reviewing other two subroutines

print 101,n,ix,jx,ista,iend,jsta,jend
101 format(16i8)
return
end


0 comments on commit 37bc963

Please sign in to comment.