Skip to content

Commit

Permalink
Start grd%iceberg_counter at 0 and increment before generating berg
Browse files Browse the repository at this point in the history
- I can not figure out why we would initialize the counter to 1 and then
  increment after generating a berg. Starting at 0 and incrementing before
  generating a berg means the counter is now a counter of how many bergs
  were calved in that cell.
  • Loading branch information
adcroft committed Jun 18, 2017
1 parent df4e43a commit 3038a47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions icebergs_framework.F90
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ subroutine ice_bergs_framework_init(bergs, &
allocate( bergs%nbergs_calved_by_class(nclasses) ); bergs%nbergs_calved_by_class(:)=0
allocate( grd%parity_x(grd%isd:grd%ied, grd%jsd:grd%jed) ); grd%parity_x(:,:)=1.
allocate( grd%parity_y(grd%isd:grd%ied, grd%jsd:grd%jed) ); grd%parity_y(:,:)=1.
allocate( grd%iceberg_counter_grd(grd%isd:grd%ied, grd%jsd:grd%jed) ); grd%iceberg_counter_grd(:,:)=1
allocate( grd%iceberg_counter_grd(grd%isd:grd%ied, grd%jsd:grd%jed) ); grd%iceberg_counter_grd(:,:)=0

!write(stderrunit,*) 'diamonds: copying grid'
! Copy data declared on ice model computational domain
Expand Down Expand Up @@ -2377,12 +2377,12 @@ integer(kind=8) function generate_id(grd, i, j)
! Local variables
integer :: ij ! Hash of i,j

! Increment counter in calving cell
grd%iceberg_counter_grd(i,j) = grd%iceberg_counter_grd(i,j) + 1
! ij is unique number for each grid cell (32-bit integers allow for ~1/100th degree global resolution)
ij = ij_component_of_id(grd, i, j)
! Generate a 64-bit id
generate_id = id_from_2_ints( grd%iceberg_counter_grd(i,j), ij )
! Increment counter in calving cell
grd%iceberg_counter_grd(i,j) = grd%iceberg_counter_grd(i,j) + 1

end function generate_id

Expand Down
2 changes: 1 addition & 1 deletion icebergs_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ subroutine read_restart_calving(bergs)
else
if (verbose.and.mpp_pe().eq.mpp_root_pe()) write(*,'(a)') &
'diamonds, read_restart_calving: iceberg_counter_grd WAS NOT FOUND in the file. Setting to 0.'
grd%iceberg_counter_grd(:,:)=1
grd%iceberg_counter_grd(:,:) = 0
endif
bergs%restarted=.true.
else
Expand Down

0 comments on commit 3038a47

Please sign in to comment.