-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fixes for uninitialized variables (snan testing) #579
Changes from all commits
9f3b82f
48fc180
0b73aca
1ffe517
8478874
46c053c
68db317
75bde7c
c6922c7
52e8102
17c6183
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ module ice_grid | |
use ice_domain, only: blocks_ice, nblocks, halo_info, distrb_info, & | ||
ew_boundary_type, ns_boundary_type, init_domain_distribution | ||
use ice_fileunits, only: nu_diag, nu_grid, nu_kmt, & | ||
get_fileunit, release_fileunit | ||
get_fileunit, release_fileunit, flush_fileunit | ||
use ice_gather_scatter, only: gather_global, scatter_global | ||
use ice_read_write, only: ice_read, ice_read_nc, ice_read_global, & | ||
ice_read_global_nc, ice_open, ice_open_nc, ice_close_nc | ||
|
@@ -384,11 +384,9 @@ subroutine init_grid2 | |
! T-grid cell and U-grid cell quantities | ||
!----------------------------------------------------------------- | ||
|
||
! tarea(:,:,:) = c0 | ||
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -486,7 +484,7 @@ subroutine init_grid2 | |
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block, & | ||
!$OMP angle_0,angle_w,angle_s,angle_sw) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -642,7 +640,7 @@ subroutine popgrid | |
kmt(:,:,:) = c0 | ||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -785,7 +783,7 @@ subroutine popgrid_nc | |
kmt(:,:,:) = c0 | ||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -1104,7 +1102,7 @@ subroutine latlongrid | |
|
||
!$OMP PARALLEL DO PRIVATE(iblk,this_block,ilo,ihi,jlo,jhi,i,j) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -1198,15 +1196,9 @@ subroutine rectgrid | |
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & | ||
file=__FILE__, line=__LINE__) | ||
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j) | ||
do iblk = 1, nblocks | ||
do j = 1, ny_block | ||
do i = 1, nx_block | ||
ANGLE(i,j,iblk) = c0 ! "square with the world" | ||
enddo | ||
enddo | ||
enddo | ||
!$OMP END PARALLEL DO | ||
hm (:,:,:) = c0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to initialize to zero in all of the block (also valid for kmt) and angle? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few different grid initialiizations (popgrid, popgrid_nc, latlon, rectangular, etc), and they don't all initialize the variables in the same way. I believe zero-ing these out here is required for the rectangular grid option that is used for the box setups. It is not needed for the popgrid option that we use for our more standard gx3+ testing. It could be that a better solution is to make all the grid options behave in the same way, but it wasn't clear to me what those requirements should be, so I went this direction. |
||
kmt(:,:,:) = c0 | ||
angle(:,:,:) = c0 ! "square with the world" | ||
|
||
allocate(work_g1(nx_global,ny_global)) | ||
|
||
|
@@ -1396,7 +1388,7 @@ subroutine cpomgrid | |
kmt(:,:,:) = c0 | ||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -1636,11 +1628,10 @@ subroutine makemask | |
!----------------------------------------------------------------- | ||
|
||
bm = c0 | ||
! uvm = c0 | ||
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -1663,12 +1654,19 @@ subroutine makemask | |
field_loc_center, field_type_scalar) | ||
call ice_timer_stop(timer_bound) | ||
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j) | ||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
do j = 1, ny_block | ||
do i = 1, nx_block | ||
tmask(i,j,iblk) = .false. | ||
umask(i,j,iblk) = .false. | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
jhi = this_block%jhi | ||
|
||
! needs to cover halo (no halo update for logicals) | ||
tmask(:,:,iblk) = .false. | ||
umask(:,:,iblk) = .false. | ||
do j = jlo-nghost, jhi+nghost | ||
do i = ilo-nghost, ihi+nghost | ||
if ( hm(i,j,iblk) > p5) tmask(i,j,iblk) = .true. | ||
if (uvm(i,j,iblk) > p5) umask(i,j,iblk) = .true. | ||
enddo | ||
|
@@ -1684,11 +1682,14 @@ subroutine makemask | |
tarean(:,:,iblk) = c0 | ||
tareas(:,:,iblk) = c0 | ||
|
||
do j = 1, ny_block | ||
do i = 1, nx_block | ||
do j = jlo,jhi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the ghost cells for these masks filled later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are not, but the halos are never accessed, so there is no error when we initialize with snan. There are probably many arrays that have uninitialized memory, but that's fine. In many ways, that's what we want. We want to only initialize memory that we think is used. That way we can trap code (or learn more about our codes) when an snan actually triggers an error. If we initialized everything explicitly to zero just for the sake of doing so, the snan testing wouldn't tell us anything. |
||
do i = ilo,ihi | ||
|
||
if (ULAT(i,j,iblk) >= -puny) lmask_n(i,j,iblk) = .true. ! N. Hem. | ||
if (ULAT(i,j,iblk) < -puny) lmask_s(i,j,iblk) = .true. ! S. Hem. | ||
if (ULAT(i,j,iblk) >= -puny) then | ||
lmask_n(i,j,iblk) = .true. ! N. Hem. | ||
else | ||
lmask_s(i,j,iblk) = .true. ! S. Hem. | ||
endif | ||
|
||
! N hemisphere area mask (m^2) | ||
if (lmask_n(i,j,iblk)) tarean(i,j,iblk) = tarea(i,j,iblk) & | ||
|
@@ -1743,7 +1744,7 @@ subroutine Tlatlon | |
!$OMP x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4, & | ||
!$OMP tx,ty,tz,da) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -1915,7 +1916,7 @@ subroutine to_ugrid(work1,work2) | |
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -2000,7 +2001,7 @@ subroutine to_tgrid(work1, work2) | |
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -2073,7 +2074,7 @@ subroutine gridbox_corners | |
|
||
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block) | ||
do iblk = 1, nblocks | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
this_block = get_block(blocks_ice(iblk),iblk) | ||
ilo = this_block%ilo | ||
ihi = this_block%ihi | ||
jlo = this_block%jlo | ||
|
@@ -2400,8 +2401,9 @@ subroutine get_bathymetry | |
do iblk = 1, nblocks | ||
do j = 1, ny_block | ||
do i = 1, nx_block | ||
k = min(nint(kmt(i,j,iblk)),nlevel) | ||
if (k > puny) bathymetry(i,j,iblk) = depth(k) | ||
k = nint(kmt(i,j,iblk)) | ||
if (k > nlevel) call abort_ice(subname//' kmt gt nlevel error') | ||
if (k > 0) bathymetry(i,j,iblk) = depth(k) | ||
enddo | ||
enddo | ||
enddo | ||
|
@@ -2491,8 +2493,8 @@ subroutine get_bathymetry_popfile | |
do iblk = 1, nblocks | ||
do j = 1, ny_block | ||
do i = 1, nx_block | ||
k = kmt(i,j,iblk) | ||
if (k > nlevel) call abort_ice(subname//' kmt/nlevel error') | ||
k = nint(kmt(i,j,iblk)) | ||
if (k > nlevel) call abort_ice(subname//' kmt gt nlevel error') | ||
if (k > 0) bathymetry(i,j,iblk) = depth(k) | ||
enddo | ||
enddo | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this change allows jlo=jhi, i.e. 1x1 domains, which weren't allowed before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. This is where the 1x1 blocks failed. The 1x1 and 2x2 are still producing different results from the other block sizes and decomps, but they are running and part of our test suite now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to elaborate a bit further. Before this fix, jhi was not set properly if the active block size was 1. It remained the default (ny_block - nghost), see line 194. This section of code is where the lo/hi indices are set for padded blocks. It worked fine as long as the block size was at least 2.