Skip to content

Commit

Permalink
Streamlined add-to-layer
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 7, 2016
1 parent 10265d4 commit 11e430a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/util/module_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,12 @@ end subroutine util_init_list
end interface

interface
subroutine util_add_to_layer(user,surfi,fcrat,xl,yl)
subroutine util_add_to_layer(user,surfi,crater)
use module_globals
implicit none
type(usertype),intent(in) :: user
type(surftype),intent(inout) :: surfi
real(DP),intent(in) :: fcrat
real(SP),intent(in) :: xl,yl
type(cratertype),intent(in) :: crater
end subroutine util_add_to_layer
end interface

Expand Down
13 changes: 6 additions & 7 deletions src/util/util_add_to_layer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
! Notes :
!
!**********************************************************************************************************************************
subroutine util_add_to_layer(user,surfi,fcrat,xl,yl)
subroutine util_add_to_layer(user,surfi,crater)
use module_globals
use module_util, EXCEPT_THIS_ONE => util_add_to_layer
implicit none

! Arguments
type(usertype),intent(in) :: user
type(surftype),intent(inout) :: surfi
real(DP),intent(in) :: fcrat
real(SP),intent(in) :: xl,yl
type(cratertype),intent(in) :: crater

! Internals
integer(I4B) :: layer,l
Expand All @@ -37,17 +36,17 @@ subroutine util_add_to_layer(user,surfi,fcrat,xl,yl)
! add to successive layers, destroying smaller craters if they exist
do l=user%numlayers,1,-1
! mark layer as available if nothing as big is now recorded there:
if ((fcrat * COOKIESIZE) > surfi%diam(l) ) then
if ((crater%fcrat * COOKIESIZE) > surfi%diam(l) ) then
call util_remove_from_layer(surfi,l)
layer = l
end if
end do

! Emplace a new crater if requested and a spot is available
if (layer>0) then
surfi%diam(layer) = fcrat
surfi%xl(layer) = xl
surfi%yl(layer) = yl
surfi%diam(layer) = crater%fcrat
surfi%xl(layer) = crater%xl
surfi%yl(layer) = crater%yl
else
write(*,*)
write(*,*) 'WARNING! No free layer to add crater pixel. Consider increasing NUMLAYERS'
Expand Down

0 comments on commit 11e430a

Please sign in to comment.