Skip to content

Commit

Permalink
Add new geometries and tests (CICE-Consortium#61)
Browse files Browse the repository at this point in the history
* Change averaging for C grid

* Fix masking

* Use the A averager

* Fix halo updates

* - Add wall kmt_type
- Add blockep4, uniformp5, medblocke, blocke to ice_data_type
- Add ability to check if C/CD fields are on restart file and skip
- Add new tests to gridsys_suite
- Update documentation with new namelist

* Rename box2000 to boxwallp5

Co-authored-by: David Bailey <dbailey@ucar.edu>
  • Loading branch information
apcraig and dabail10 authored Feb 11, 2022
1 parent 08d8730 commit 09238c7
Show file tree
Hide file tree
Showing 11 changed files with 359 additions and 62 deletions.
38 changes: 36 additions & 2 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,7 @@ subroutine input_data

if (kmt_type /= 'file' .and. &
kmt_type /= 'channel' .and. &
kmt_type /= 'wall' .and. &
kmt_type /= 'default' .and. &
kmt_type /= 'boxislands') then
if (my_task == master_task) write(nu_diag,*) subname//' ERROR: unknown kmt_type=',trim(kmt_type)
Expand Down Expand Up @@ -2712,6 +2713,8 @@ subroutine set_state_var (nx_block, ny_block, &
trim(ice_data_type) == 'smallblock' .or. &
trim(ice_data_type) == 'channel' .or. &
trim(ice_data_type) == 'bigblock' .or. &
trim(ice_data_type) == 'blockep5' .or. &
trim(ice_data_type) == 'uniformp5' .or. &
trim(ice_data_type) == 'gauss') then

hbar = c2 ! initial ice thickness
Expand All @@ -2724,7 +2727,9 @@ subroutine set_state_var (nx_block, ny_block, &
endif
enddo

elseif (trim(ice_data_type) == 'boxslotcyl') then
elseif (trim(ice_data_type) == 'boxslotcyl' .or. &
trim(ice_data_type) == 'medblocke' .or. &
trim(ice_data_type) == 'blocke') then

hbar = c1 ! initial ice thickness (1 m)
do n = 1, ncat
Expand Down Expand Up @@ -2781,7 +2786,8 @@ subroutine set_state_var (nx_block, ny_block, &
enddo ! i
enddo ! j

elseif (trim(ice_data_type) == 'uniform') then
elseif ((trim(ice_data_type) == 'uniform') .or. &
(trim(ice_data_type) == 'uniformp5')) then
! all cells not land mask are ice
icells = 0
do j = jlo, jhi
Expand All @@ -2807,6 +2813,34 @@ subroutine set_state_var (nx_block, ny_block, &
enddo
enddo

elseif (trim(ice_data_type) == 'blocke' .or. &
trim(ice_data_type) == 'blockep5') then
! block on east half of domain
icells = 0
do j = jlo, jhi
do i = ilo, ihi
if (iglob(i) >= nx_global/2) then
icells = icells + 1
indxi(icells) = i
indxj(icells) = j
endif
enddo
enddo

elseif (trim(ice_data_type) == 'medblocke') then
! block on east half of domain in center of domain
icells = 0
do j = jlo, jhi
do i = ilo, ihi
if (jglob(j) > ny_global/4 .and. jglob(j) < 3*nx_global/4 .and. &
iglob(i) >= nx_global/2) then
icells = icells + 1
indxi(icells) = i
indxj(icells) = j
endif
enddo
enddo

elseif (trim(ice_data_type) == 'smallblock') then
! 2x2 ice in center of domain
icells = 0
Expand Down
14 changes: 11 additions & 3 deletions cicecore/cicedynB/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1410,9 +1410,17 @@ subroutine rectgrid

elseif (trim(kmt_type) == 'channel') then

do j = 3,ny_global-2 ! closed top and bottom
do i = 1,nx_global ! open sides
work_g1(i,j) = c1 ! NOTE nx_global > 5
do j = 3,ny_global-2 ! closed top and bottom
do i = 1,nx_global ! open sides
work_g1(i,j) = c1 ! NOTE nx_global > 5
enddo
enddo

elseif (trim(kmt_type) == 'wall') then

do j = 1,ny_global ! open except
do i = 1,nx_global-2 ! closed east edge
work_g1(i,j) = c1
enddo
enddo

Expand Down
116 changes: 66 additions & 50 deletions cicecore/cicedynB/infrastructure/ice_restart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,27 @@ subroutine restartfile (ice_ic)
'vvel',1,diag,field_loc_NEcorner, field_type_vector)

if (grid_ice == 'CD') then
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,vvelE,'ruf8', &
'vvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,uvelN,'ruf8', &
'uvelN',1,diag,field_loc_Nface, field_type_vector)
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
if (query_field(nu_restart,'uvelE')) &
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
if (query_field(nu_restart,'vvelE')) &
call read_restart_field(nu_restart,0,vvelE,'ruf8', &
'vvelE',1,diag,field_loc_Eface, field_type_vector)
if (query_field(nu_restart,'uvelN')) &
call read_restart_field(nu_restart,0,uvelN,'ruf8', &
'uvelN',1,diag,field_loc_Nface, field_type_vector)
if (query_field(nu_restart,'vvelN')) &
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
endif

if (grid_ice == 'C') then
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
if (query_field(nu_restart,'uvelE')) &
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
if (query_field(nu_restart,'vvelN')) &
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
endif

!-----------------------------------------------------------------
Expand Down Expand Up @@ -443,18 +449,24 @@ subroutine restartfile (ice_ic)
'stress12_4',1,diag,field_loc_center,field_type_scalar) ! stress12_4

if (grid_ice == 'CD' .or. grid_ice == 'C') then
call read_restart_field(nu_restart,0,stresspT,'ruf8', &
'stresspT' ,1,diag,field_loc_center,field_type_scalar) ! stresspT
call read_restart_field(nu_restart,0,stressmT,'ruf8', &
'stressmT' ,1,diag,field_loc_center,field_type_scalar) ! stressmT
call read_restart_field(nu_restart,0,stress12T,'ruf8', &
'stress12T',1,diag,field_loc_center,field_type_scalar) ! stress12T
call read_restart_field(nu_restart,0,stresspU,'ruf8', &
'stresspU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stresspU
call read_restart_field(nu_restart,0,stressmU,'ruf8', &
'stressmU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stressmU
call read_restart_field(nu_restart,0,stress12U,'ruf8', &
'stress12U',1,diag,field_loc_NEcorner,field_type_scalar) ! stress12U
if (query_field(nu_restart,'stresspT')) &
call read_restart_field(nu_restart,0,stresspT,'ruf8', &
'stresspT' ,1,diag,field_loc_center,field_type_scalar) ! stresspT
if (query_field(nu_restart,'stressmT')) &
call read_restart_field(nu_restart,0,stressmT,'ruf8', &
'stressmT' ,1,diag,field_loc_center,field_type_scalar) ! stressmT
if (query_field(nu_restart,'stress12T')) &
call read_restart_field(nu_restart,0,stress12T,'ruf8', &
'stress12T',1,diag,field_loc_center,field_type_scalar) ! stress12T
if (query_field(nu_restart,'stresspU')) &
call read_restart_field(nu_restart,0,stresspU,'ruf8', &
'stresspU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stresspU
if (query_field(nu_restart,'stressmU')) &
call read_restart_field(nu_restart,0,stressmU,'ruf8', &
'stressmU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stressmU
if (query_field(nu_restart,'stress12U')) &
call read_restart_field(nu_restart,0,stress12U,'ruf8', &
'stress12U',1,diag,field_loc_NEcorner,field_type_scalar) ! stress12U
endif

if (trim(grid_type) == 'tripole') then
Expand Down Expand Up @@ -509,33 +521,37 @@ subroutine restartfile (ice_ic)

if (grid_ice == 'CD' .or. grid_ice == 'C') then

call read_restart_field(nu_restart,0,work1,'ruf8', &
'icenmask',1,diag,field_loc_center, field_type_scalar)

icenmask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) icenmask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO

call read_restart_field(nu_restart,0,work1,'ruf8', &
'iceemask',1,diag,field_loc_center, field_type_scalar)
if (query_field(nu_restart,'icenmask')) then
call read_restart_field(nu_restart,0,work1,'ruf8', &
'icenmask',1,diag,field_loc_center, field_type_scalar)

icenmask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) icenmask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO
endif

iceemask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) iceemask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO
if (query_field(nu_restart,'iceemask')) then
call read_restart_field(nu_restart,0,work1,'ruf8', &
'iceemask',1,diag,field_loc_center, field_type_scalar)

iceemask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) iceemask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO
endif

endif

Expand Down
29 changes: 28 additions & 1 deletion cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module ice_restart
implicit none
private
public :: init_restart_write, init_restart_read, &
read_restart_field, write_restart_field, final_restart
read_restart_field, write_restart_field, final_restart, &
query_field

integer (kind=int_kind) :: ncid

Expand Down Expand Up @@ -886,6 +887,32 @@ subroutine define_rest_field(ncid, vname, dims)

end subroutine define_rest_field

!=======================================================================

! Inquire field existance
! author T. Craig

logical function query_field(nu,vname)

integer (kind=int_kind), intent(in) :: nu ! unit number
character (len=*) , intent(in) :: vname ! variable name

! local variables

integer (kind=int_kind) :: status, varid
character(len=*), parameter :: subname = '(query_field)'

query_field = .false.
#ifdef USE_NETCDF
status = nf90_inq_varid(ncid,trim(vname),varid)
if (status == nf90_noerr) query_field = .true.
#else
call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(ice_ic), &
file=__FILE__, line=__LINE__)
#endif

end function query_field

!=======================================================================

end module ice_restart
Expand Down
29 changes: 28 additions & 1 deletion cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module ice_restart
implicit none
private
public :: init_restart_write, init_restart_read, &
read_restart_field, write_restart_field, final_restart
read_restart_field, write_restart_field, final_restart, &
query_field

type(file_desc_t) :: File
type(var_desc_t) :: vardesc
Expand Down Expand Up @@ -929,6 +930,32 @@ subroutine define_rest_field(File, vname, dims)

end subroutine define_rest_field

!=======================================================================

! Inquire field existance
! author T. Craig

logical function query_field(nu,vname)

integer (kind=int_kind), intent(in) :: nu ! unit number
character (len=*) , intent(in) :: vname ! variable name

! local variables

integer (kind=int_kind) :: status, varid
character(len=*), parameter :: subname = '(query_field)'

query_field = .false.
#ifdef USE_NETCDF
status = pio_inq_varid(File,trim(vname),vardesc)
if (status == PIO_noerr) query_field = .true.
#else
call abort_ice(subname//'ERROR: USE_NETCDF cpp not defined for '//trim(ice_ic), &
file=__FILE__, line=__LINE__)
#endif

end function query_field

!=======================================================================

end module ice_restart
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/options/set_nml.boxchan
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ f_tauby = 'd1'
f_divu = 'd1'
f_sig1 = 'd1'
f_sig2 = 'd1'
f_sigP = 'd1'
56 changes: 56 additions & 0 deletions configuration/scripts/options/set_nml.boxwall
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
days_per_year = 360
use_leap_years = .false.
npt = 240
ice_ic = 'default'
restart_ext = .true.
histfreq = 'd','1','x','x','x'
grid_type = 'rectangular'
kmt_type = 'wall'
dxrect = 16.e5
dyrect = 16.e5
close_boundaries = .false.
ew_boundary_type = 'cyclic'
ns_boundary_type = 'cyclic'
tr_iage = .false.
tr_FY = .false.
tr_lvl = .false.
tr_pond_lvl = .false.
ktherm = -1
kstrength = 0
kdyn = 1
kridge = -1
ktransport = -1
coriolis = 'zero'
atmbndy = 'constant'
atm_data_type = 'uniform_east'
ocn_data_type = 'calm'
ice_data_type = 'blocke'
calc_strair = .false.
rotate_wind = .false.
restore_ice = .false.
f_aice = 'd1'
f_hi = 'd1'
f_hs = 'd'
f_Tsfc = 'd'
f_uvel = 'd1'
f_vvel = 'd1'
f_uatm = 'd'
f_vatm = 'd'
f_uocn = 'd'
f_vocn = 'd'
f_strairx = 'd1'
f_strairy = 'd1'
f_strtltx = 'd1'
f_strtlty = 'd1'
f_strcorx = 'd1'
f_strcory = 'd1'
f_strocnx = 'd1'
f_strocny = 'd1'
f_strintx = 'd1'
f_strinty = 'd1'
f_taubx = 'd1'
f_tauby = 'd1'
f_divu = 'd1'
f_sig1 = 'd1'
f_sig2 = 'd1'
f_sigP = 'd1'
Loading

0 comments on commit 09238c7

Please sign in to comment.