Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug for Nx Ny in swath grid #2840

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- fixed a bug in generate_newnxy in MAPL_SwathGridFactory.F90 (NX*NY=Ncore)
- pFIO Clients don't send "Done" message when there is no request
- Update `components.yaml`
- ESMA_cmake v3.45.1
Expand Down
58 changes: 30 additions & 28 deletions base/MAPL_SwathGridFactory.F90
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,8 @@ function make_new_grid(this, unusable, rc) result(grid)

_UNUSED_DUMMY(unusable)

!!if (mapl_am_I_root()) write(6,*) 'MAPL_SwathGridFactory.F90: bf this%create_basic_grid'
grid = this%create_basic_grid(_RC)
!!if (mapl_am_I_root()) write(6,*) 'MAPL_SwathGridFactory.F90: af this%create_basic_grid'
call this%add_horz_coordinates_from_file(grid,_RC)
!!if (mapl_am_I_root()) write(6,*) 'MAPL_SwathGridFactory.F90: af this%add_horz_coordinates_from_file'

_RETURN(_SUCCESS)
end function make_new_grid

Expand Down Expand Up @@ -483,6 +479,7 @@ subroutine initialize_from_config_with_prefix(this, config, prefix, unusable, rc

call lgr%debug(' %a %a', 'CurrTime =', trim(tmp))


if ( index(tmp, 'T') /= 0 .OR. index(tmp, '-') /= 0 ) then
call ESMF_TimeSet(currTime, timeString=tmp, _RC)
else
Expand Down Expand Up @@ -718,6 +715,7 @@ subroutine initialize_from_config_with_prefix(this, config, prefix, unusable, rc
endif
! ims is set at here
call this%check_and_fill_consistency(_RC)
call lgr%debug(' %a %i5 %i5', 'nx, ny (check_and_fill_consistency) = ', this%nx, this%ny)

_RETURN(_SUCCESS)

Expand Down Expand Up @@ -864,7 +862,6 @@ subroutine check_and_fill_consistency(this, unusable, rc)
call this%generate_newnxy(_RC)
end if
end if

_RETURN(_SUCCESS)

contains
Expand Down Expand Up @@ -1145,43 +1142,48 @@ subroutine generate_newnxy(this,unusable,rc)
class (KeywordEnforcer), optional, intent(in) :: unusable
integer, optional, intent(out) :: rc
integer :: n
integer :: j, pet_count

_UNUSED_DUMMY(unusable)

pet_count = this%nx * this%ny
n = this%im_world/this%nx
if (n < 2) then
this%nx = generate_new_decomp(this%im_world,this%nx)
deallocate(this%ims)
allocate(this%ims(0:this%nx-1))
call MAPL_DecomposeDim(this%im_world, this%ims, this%nx)
do j = this%im_world/2, 1, -1
if ( mod(pet_count, j) == 0 .and. this%im_world/j >= 2 ) then
exit ! found a decomposition
end if
end do
this%nx = j
this%ny = pet_count/j
end if

n = this%jm_world/this%ny
if (n < 2) then
this%ny = generate_new_decomp(this%jm_world,this%ny)
deallocate(this%jms)
allocate(this%jms(0:this%ny-1))
call MAPL_DecomposeDim(this%jm_world, this%jms, this%ny)
do j = this%jm_world/2, 1, -1
if ( mod(pet_count, j) == 0 .and. this%jm_world/j >=2 ) then
exit ! found a decomposition
end if
end do
this%ny = j
this%nx = pet_count/j
end if

if ( this%im_world/this%nx < 2 .OR. this%jm_world/this%ny < 2 ) then
_FAIL ('Algorithm failed')
end if

if (allocated(this%ims)) deallocate(this%ims)
allocate(this%ims(0:this%nx-1))
call MAPL_DecomposeDim(this%im_world, this%ims, this%nx)
if (allocated(this%jms)) deallocate(this%jms)
allocate(this%jms(0:this%ny-1))
call MAPL_DecomposeDim(this%jm_world, this%jms, this%ny)

_RETURN(_SUCCESS)

end subroutine generate_newnxy

function generate_new_decomp(im,nd) result(n)
integer, intent(in) :: im, nd
integer :: n
logical :: canNotDecomp

canNotDecomp = .true.
n = nd
do while(canNotDecomp)
if ( (im/n) < 2) then
n = n/2
else
canNotDecomp = .false.
end if
enddo
end function generate_new_decomp

subroutine init_halo(this, unusable, rc)
class (SwathGridFactory), target, intent(inout) :: this
Expand Down
Loading