Skip to content

Commit

Permalink
fixed indentation in subroutine optimize_latlon() of preprocess_ldas_…
Browse files Browse the repository at this point in the history
…routines.F90
  • Loading branch information
gmao-rreichle committed May 20, 2024
1 parent e3f5f35 commit ddb4178
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions GEOSldas_App/preprocess_ldas_routines.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,7 @@ subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file, run_di
!tmpint, & ! 10
!tmpreal, & ! 11
!tmpint ! 12 * (previously "tile_id")

if(typ==MAPL_Land) then
total_land=total_land+1
landPosition(j) = landPosition(j)+1
Expand Down Expand Up @@ -2451,14 +2452,14 @@ subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file, run_di
! redistribute IMS and try to make it >=2 (may be impossible for large N_Proc)
do i = 1, N_proc
if(IMS(i) == 0) then
n = maxloc(IMS,DIM=1)
IMS(i) = 1
IMS(n) = IMS(n)-1
n = maxloc(IMS,DIM=1)
IMS(i) = 1
IMS(n) = IMS(n)-1
endif
if(IMS(i) == 1) then
n = maxloc(IMS,DIM=1)
IMS(i) = 2
IMS(n) = IMS(n)-1
n = maxloc(IMS,DIM=1)
IMS(i) = 2
IMS(n) = IMS(n)-1
endif
enddo
if( any(IMS <=1) ) then
Expand Down Expand Up @@ -2493,7 +2494,7 @@ subroutine optimize_latlon(fname_tilefile, N_proc_string, optimized_file, run_di

contains

! ***************************************************************************
! ---------------------------------------------------

elemental function rms(rates) result (f)
real :: f
Expand All @@ -2517,24 +2518,24 @@ elemental function rms(rates) result (f)
tmpint=tmpint+landPosition(n)
if(local == N_proc .and. n < e) cycle ! all lefteover goes to the last process
if( n==e ) then
local_land(local)=tmpint
exit
endif

if( tmpint .ge. avg_land ) then
if (forward .or. n-n0 == 1 ) then
local_land(local)=tmpint
tmpint=0
n0=n
forward = .false.
else
local_land(local) = tmpint - landPosition(n)
tmpint= landPosition(n)
n0 = n-1
forward = .true.
endif
local = local + 1
endif
local_land(local)=tmpint
exit
endif
if( tmpint .ge. avg_land ) then
if (forward .or. n-n0 == 1 ) then
local_land(local)=tmpint
tmpint=0
n0=n
forward = .false.
else
local_land(local) = tmpint - landPosition(n)
tmpint= landPosition(n)
n0 = n-1
forward = .true.
endif
local = local + 1
endif
enddo
f = 0.0
do proc = 1, N_proc
Expand All @@ -2543,7 +2544,7 @@ elemental function rms(rates) result (f)
deallocate(local_land)
end function rms

! ***************************************************************************
! ---------------------------------------------------

elemental function rms_cs(rates) result (f)
real :: f
Expand Down Expand Up @@ -2605,6 +2606,8 @@ elemental function rms_cs(rates) result (f)
deallocate(local_land)
end function rms_cs

! ---------------------------------------------------

subroutine equal_partition(array, distribute)
integer, intent(in) :: array(:)
integer, intent(inout) :: distribute(:)
Expand Down Expand Up @@ -2635,7 +2638,7 @@ subroutine equal_partition(array, distribute)
do j = 2, n ! array element

best = arraySum(n) + 1 ! or the max int
! the ith partition in front of p
! the ith partition in front of p
do p = 1, j
tmp_max = max(table(i-1,p), arraySum(j)-arraySum(p))
if (tmp_max < best) then
Expand All @@ -2645,7 +2648,7 @@ subroutine equal_partition(array, distribute)
enddo
table(i,j) = best
partition(i,j) = pos
enddo
enddo
enddo

! trace back the partition
Expand Down Expand Up @@ -2674,7 +2677,7 @@ subroutine equal_partition(array, distribute)
print*, "Average : ", arraySum(n)/(k*1.0)
print*, "Worst : ", table(k,n)
deallocate(table, arraySum, partition)
end subroutine equal_partition
end subroutine equal_partition

end subroutine optimize_latlon

Expand Down

0 comments on commit ddb4178

Please sign in to comment.