Skip to content

Commit

Permalink
Set berg%id everywhere %iceberg_num is set
Browse files Browse the repository at this point in the history
- This calls the new generate_id() function and stores
  the 64-bit %id in the iceberg everywhere we first create
  %iceberg_num.
  • Loading branch information
adcroft committed Jun 15, 2017
1 parent 33e090d commit e7fc83f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion icebergs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module ice_bergs
use ice_bergs_framework, only: monitor_a_berg
use ice_bergs_framework, only: is_point_within_xi_yj_bounds
use ice_bergs_framework, only: test_check_for_duplicate_ids_in_list
use ice_bergs_framework, only: generate_id

use ice_bergs_io, only: ice_bergs_io_init,write_restart,write_trajectory
use ice_bergs_io, only: read_restart_bergs,read_restart_bergs_orig,read_restart_calving
Expand Down Expand Up @@ -4044,6 +4045,7 @@ subroutine calve_icebergs(bergs)
newberg%start_lat=newberg%lat
newberg%start_year=bergs%current_year
newberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i+(iNg*(j-1))) ! unique number for each iceberg
newberg%id = generate_id(grd, i, j)
newberg%start_day=bergs%current_yearday+ddt/86400.
newberg%start_mass=bergs%initial_mass(k)
newberg%mass_scaling=bergs%mass_scaling(k)
Expand All @@ -4065,7 +4067,6 @@ subroutine calve_icebergs(bergs)
icnt=icnt+1
bergs%nbergs_calved=bergs%nbergs_calved+1
bergs%nbergs_calved_by_class(k)=bergs%nbergs_calved_by_class(k)+1
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
enddo
icntmax=max(icntmax,icnt)
enddo
Expand Down
21 changes: 11 additions & 10 deletions icebergs_io.F90
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module ice_bergs_io
use ice_bergs_framework, only: ignore_ij_restart, use_slow_find,generate_test_icebergs,print_berg
use ice_bergs_framework, only: force_all_pes_traj
use ice_bergs_framework, only: check_for_duplicates_in_parallel
use ice_bergs_framework, only: split_id, id_from_2_ints, generate_id

implicit none ; private

Expand Down Expand Up @@ -560,7 +561,7 @@ subroutine read_restart_bergs_orig(bergs,Time)
localberg%iceberg_num=get_int(ncid, iceberg_numid, k)
else
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
endif
localberg%start_day=get_double(ncid, start_dayid, k)
localberg%start_mass=get_double(ncid, start_massid, k)
Expand Down Expand Up @@ -677,25 +678,25 @@ subroutine generate_bergs_orig(bergs, Time)
localberg%uvel=1.
localberg%vvel=0.
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg B
localberg%uvel=-1.
localberg%vvel=0.
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg C
localberg%uvel=0.
localberg%vvel=1.
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg D
localberg%uvel=0.
localberg%vvel=-1.
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
endif
enddo; enddo
Expand Down Expand Up @@ -892,7 +893,7 @@ subroutine read_restart_bergs(bergs,Time)
if (bergs%grd%area(localberg%ine,localberg%jne) .ne. 0) then
if (iceberg_num(k)==-1) then ! If using an old_restart then iceberg_num needs to be generated
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(localberg%ine,localberg%jne))+(localberg%ine+(iNg*(localberg%jne-1)))
grd%iceberg_counter_grd(localberg%ine,localberg%jne)=grd%iceberg_counter_grd(localberg%ine,localberg%jne)+1
localberg%id = generate_id(grd, localberg%ine, localberg%jne)
endif
call add_new_berg_to_list(bergs%list(localberg%ine,localberg%jne)%first, localberg)
else
Expand Down Expand Up @@ -1058,22 +1059,22 @@ subroutine generate_bergs(bergs,Time)
!Berg A
call loc_set_berg_pos(grd, 0.9, 0.5, 1., 0., localberg)
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg B
call loc_set_berg_pos(grd, 0.1, 0.5, -1., 0., localberg)
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg C
call loc_set_berg_pos(grd, 0.5, 0.9, 0., 1., localberg)
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
!Berg D
call loc_set_berg_pos(grd, 0.5, 0.1, 0., -1., localberg)
localberg%iceberg_num=((iNg*jNg)*grd%iceberg_counter_grd(i,j))+(i +(iNg*(j-1))) ! unique number for each iceberg
grd%iceberg_counter_grd(i,j)=grd%iceberg_counter_grd(i,j)+1
localberg%id = generate_id(grd, i, j)
call add_new_berg_to_list(bergs%list(i,j)%first, localberg)
endif
enddo; enddo
Expand Down

0 comments on commit e7fc83f

Please sign in to comment.