Skip to content

Commit

Permalink
Landmaskb (#8)
Browse files Browse the repository at this point in the history
* boxislands land mask

* adjusted landmask

* add kmt_type option to grid namelist
  • Loading branch information
eclare108213 authored Nov 16, 2021
1 parent 63d0f48 commit 34a3ada
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 35 deletions.
24 changes: 21 additions & 3 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ subroutine input_data
use ice_arrays_column, only: bgc_data_dir, fe_data_type
use ice_grid, only: grid_file, gridcpl_file, kmt_file, &
bathymetry_file, use_bathymetry, &
bathymetry_format, &
bathymetry_format, kmt_type, &
grid_type, grid_format, grid_system, &
dxrect, dyrect, &
pgl_global_ext
Expand Down Expand Up @@ -185,7 +185,7 @@ subroutine input_data
bathymetry_file, use_bathymetry, nfsd, bathymetry_format, &
ncat, nilyr, nslyr, nblyr, &
kcatbound, gridcpl_file, dxrect, dyrect, &
close_boundaries, orca_halogrid, grid_system
close_boundaries, orca_halogrid, grid_system, kmt_type

namelist /tracer_nml/ &
tr_iage, restart_age, &
Expand Down Expand Up @@ -332,6 +332,7 @@ subroutine input_data
bathymetry_file = 'unknown_bathymetry_file'
bathymetry_format = 'default'
use_bathymetry = .false.
kmt_type = 'file'
kmt_file = 'unknown_kmt_file'
version_name = 'unknown_version_name'
ncat = 0 ! number of ice thickness categories
Expand Down Expand Up @@ -706,6 +707,7 @@ subroutine input_data
call broadcast_scalar(bathymetry_file, master_task)
call broadcast_scalar(bathymetry_format, master_task)
call broadcast_scalar(use_bathymetry, master_task)
call broadcast_scalar(kmt_type, master_task)
call broadcast_scalar(kmt_file, master_task)
call broadcast_scalar(kitd, master_task)
call broadcast_scalar(kcatbound, master_task)
Expand Down Expand Up @@ -1362,6 +1364,7 @@ subroutine input_data
if (trim(grid_type) == 'tripole') tmpstr2 = ' : user-defined grid with northern hemisphere zipper'
write(nu_diag,1030) ' grid_type = ',trim(grid_type),trim(tmpstr2)
write(nu_diag,1030) ' grid_system = ',trim(grid_system)
write(nu_diag,1030) ' kmt_type = ',trim(kmt_type)
if (trim(grid_type) /= 'rectangular') then
if (use_bathymetry) then
tmpstr2 = ' : bathymetric input data is used'
Expand Down Expand Up @@ -1945,7 +1948,8 @@ subroutine input_data
write(nu_diag,1031) ' grid_file = ', trim(grid_file)
write(nu_diag,1031) ' gridcpl_file = ', trim(gridcpl_file)
write(nu_diag,1031) ' bathymetry_file = ', trim(bathymetry_file)
write(nu_diag,1031) ' kmt_file = ', trim(kmt_file)
if (trim(kmt_type) == 'file') &
write(nu_diag,1031) ' kmt_file = ', trim(kmt_file)
endif
write(nu_diag,1011) ' orca_halogrid = ', orca_halogrid

Expand Down Expand Up @@ -2037,6 +2041,20 @@ subroutine input_data
abort_list = trim(abort_list)//":26"
endif

if (kmt_type /= 'file' .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)
abort_list = trim(abort_list)//":27"
endif

if (grid_type /= 'column' .and. &
grid_type /= 'rectangular' .and. &
kmt_type /= 'file') then
if (my_task == master_task) write(nu_diag,*) subname//' ERROR: need kmt file, kmt_type=',trim(kmt_type)
abort_list = trim(abort_list)//":28"
endif

if (kdyn == 1 .and. &
evp_algorithm /= 'standard_2d' .and. &
evp_algorithm /= 'shared_mem_1d') then
Expand Down
205 changes: 173 additions & 32 deletions cicecore/cicedynB/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module ice_grid
gridcpl_file , & ! input file for POP coupling grid info
grid_file , & ! input file for POP grid info
kmt_file , & ! input file for POP grid info
kmt_type , & ! options are file, default, boxislands
bathymetry_file, & ! input bathymetry for seabed stress
bathymetry_format, & ! bathymetry file format (default or pop)
grid_spacing , & ! default of 30.e3m or set by user in namelist
Expand Down Expand Up @@ -1345,47 +1346,63 @@ subroutine rectgrid

if (trim(ew_boundary_type) == 'cyclic') 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
enddo
enddo
if (trim(kmt_type) == 'boxislands') then

call get_box_kmt(work_g1)

else ! default

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

endif ! kmt_type

elseif (trim(ew_boundary_type) == 'open') then

! land in the upper left and lower right corners,
! otherwise open boundaries
imid = nint(aint(real(nx_global)/c2))
jmid = nint(aint(real(ny_global)/c2))
if (trim(kmt_type) == 'boxislands') then

do j = 3,ny_global-2
do i = 3,nx_global-2
work_g1(i,j) = c1 ! open central domain
enddo
enddo
call get_box_kmt(work_g1)

if (nx_global > 5 .and. ny_global > 5) then
else ! default

do j = 1, jmid+2
do i = 1, imid+2
work_g1(i,j) = c1 ! open lower left corner
enddo
enddo
! land in the upper left and lower right corners,
! otherwise open boundaries
imid = nint(aint(real(nx_global)/c2))
jmid = nint(aint(real(ny_global)/c2))

do j = max(jmid-2,1), ny_global
do i = max(imid-2,1), nx_global
work_g1(i,j) = c1 ! open upper right corner
enddo
enddo
do j = 3,ny_global-2
do i = 3,nx_global-2
work_g1(i,j) = c1 ! open central domain
enddo
enddo

endif
if (nx_global > 5 .and. ny_global > 5) then

if (close_boundaries) then
work_g1(:, 1:2) = c0
work_g1(:, ny_global-1:ny_global) = c0
work_g1(1:2, :) = c0
work_g1(nx_global-1:nx_global, :) = c0
endif
do j = 1, jmid+2
do i = 1, imid+2
work_g1(i,j) = c1 ! open lower left corner
enddo
enddo

do j = max(jmid-2,1), ny_global
do i = max(imid-2,1), nx_global
work_g1(i,j) = c1 ! open upper right corner
enddo
enddo

endif ! > 5x5 grid

if (close_boundaries) then
work_g1(:, 1:2) = c0
work_g1(:, ny_global-1:ny_global) = c0
work_g1(1:2, :) = c0
work_g1(nx_global-1:nx_global, :) = c0
endif

endif ! kmt_type

elseif (trim(ew_boundary_type) == 'closed') then

Expand All @@ -1401,6 +1418,130 @@ subroutine rectgrid

end subroutine rectgrid

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

! Complex land mask for testing box cases
! Requires nx_global, ny_global > 20
! Assumes work array has been initialized to 1 (ocean) and north and
! south land boundaries have been applied (ew_boundary_type='cyclic')

subroutine get_box_kmt (work)

use ice_constants, only: c0, c1, c20

real (kind=dbl_kind), dimension(:,:), intent(inout) :: work

integer (kind=int_kind) :: &
i, j, k, & ! indices
nxb, nyb ! convenient cell-block sizes for building the mask

character(len=*), parameter :: subname = '(get_box_kmt)'

! number of cells in 5% of global grid x and y lengths
nxb = int(real(nx_global, dbl_kind) / c20, int_kind)
nyb = int(real(ny_global, dbl_kind) / c20, int_kind)

if (nxb < 1 .or. nyb < 1) &
call abort_ice(subname//'ERROR: requires larger grid size')

! northeast triangle
k = 0
do j = ny_global, ny_global-3*nyb, -1
k = k+1
do i = nx_global-3*nxb+k, nx_global
work(i,j) = c0
enddo
enddo

! northwest docks
do j = ny_global-3*nyb, ny_global
do i = 1, 1
work(i,j) = c0
enddo
enddo
do i = 1, 2*nxb
do j = ny_global-3*nyb, ny_global-nyb-2
work(i,j) = c0
enddo
do j = ny_global-nyb, ny_global-nyb+1
work(i,j) = c0
enddo
enddo

! southwest docks
do j = 2*nyb, 3*nyb
do i = 1, 1
work(i,j) = c0
enddo
enddo
do j = 1, 2*nyb
do i = 2, nxb
work(i,j) = c0
enddo
do i = 2*nxb-1, 2*nxb
work(i,j) = c0
enddo
do i = 2*nxb+2,4*nxb
work(i,j) = c0
enddo
enddo

! tiny island
do j = 14*nyb, 14*nyb+1
do i = 14*nxb, 14*nxb+1
work(i,j) = c0
enddo
enddo

! X islands
! left triangle
k = 0
do i = 2*nxb, 4*nxb
k=k+1
do j = 10*nyb+k, 14*nyb-k
work(i,j) = c0
enddo
enddo
! upper triangle
k = 0
do j = 14*nyb, 12*nyb, -1
k=k+1
do i = 2*nxb+2+k, 6*nxb-2-k
work(i,j) = c0
enddo
enddo
! diagonal
k = 0
do j = 10*nyb, 14*nyb
k=k+1
do i = 2*nxb+4+k, 2*nxb+6+k
work(i,j) = c0
enddo
enddo
! lower right triangle
k = 0
do j = 12*nyb, 10*nyb, -1
k=k+1
do i = 5*nxb+k, 8*nxb
work(i,j) = c0
enddo
enddo

! bar islands
do i = 10*nxb, 16*nxb
do j = 4*nyb, 5*nyb
work(i,j) = c0
enddo
do j = 6*nyb+2, 8*nyb
work(i,j) = c0
enddo
do j = 8*nyb+2, 8*nyb+3
work(i,j) = c0
enddo
enddo

end subroutine get_box_kmt

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

! CPOM displaced pole grid and land mask. \\
Expand Down
1 change: 1 addition & 0 deletions configuration/scripts/ice_in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
grid_type = 'displaced_pole'
grid_system = 'B'
grid_file = 'grid'
kmt_type = 'file'
kmt_file = 'kmt'
bathymetry_file = 'unknown_bathymetry_file'
bathymetry_format = 'default'
Expand Down
38 changes: 38 additions & 0 deletions configuration/scripts/options/set_nml.boxislands
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
npt = 48
kmt_type = 'boxislands'
ice_ic = 'default'
histfreq = 'd','x','x','x','x'
grid_type = 'rectangular'
dxrect = 16.e5
dyrect = 16.e5
close_boundaries = .false.
ew_boundary_type = 'cyclic'
ns_boundary_type = 'open'
ktherm = -1
kstrength = 0
kdyn = 1
kridge = -1
ktransport = -1
coriolis = 'constant'
atmbndy = 'constant'
atm_data_type = 'box2001'
ice_data_type = 'box2001'
calc_strair = .false.
restore_ice = .false.
f_aice = 'd'
f_hi = 'd'
f_hs = 'd'
f_Tsfc = 'd'
f_uvel = 'd'
f_vvel = 'd'
f_uatm = 'd'
f_vatm = 'd'
f_uocn = 'd'
f_vocn = 'd'
f_strairx = 'd'
f_strairy = 'd'
f_strocnx = 'd'
f_strocny = 'd'
f_divu = 'd'
f_sig1 = 'd'
f_sig2 = 'd'
1 change: 1 addition & 0 deletions doc/source/cice_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ either Celsius or Kelvin units).
"kice", "thermal conductivity of fresh ice (:cite:`Bitz99`)", "2.03 W/m/deg"
"kitd", "type of itd conversions (0 = delta function, 1 = linear remap)", "1"
"kmt_file", "input file for land mask info", ""
"kmt_type", "file, default or boxislands", "file"
"krdg_partic", "ridging participation function", "1"
"krdg_redist", "ridging redistribution function", "1"
"krgdn", "mean ridge thickness per thickness of ridging ice", ""
Expand Down
1 change: 1 addition & 0 deletions doc/source/user_guide/ug_case_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ grid_nml
"", "``1``", "new formulation with round numbers", ""
"", "``2``", "WMO standard categories", ""
"", "``3``", "asymptotic scheme", ""
"``kmt_type``", "string", "file, default or boxislands", "file"
"``kmt_file``", "string", "name of land mask file to be read", "'unknown_kmt_file'"
"``nblyr``", "integer", "number of zbgc layers", "0"
"``ncat``", "integer", "number of ice thickness categories", "0"
Expand Down

0 comments on commit 34a3ada

Please sign in to comment.