Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Creating custom grids for MOM6+CICE

peterchu

cwc950106
New Member
Please search for "gen_cice_gridfiles" in this notebook.

Hi Gustavo,

The file "gen_cice_gridfiles" cannot be downloaded from the notebook. When I click the "gen_cice_gridfiles.ncl" in the notebook, the webpage shows "Pages not found". Could you please provide an available link?
 

gmarques

Gustavo Marques
Moderator
Staff member
Yes, the link is broken but the code is listed in the same gist. I am also including the code below.


Code:
B.3: gen_cice_gridfiles.ncl
Note: Update the file paths following the begin keyword in the script accordingly.
; gen_cice_gridfiles.ncl

; Input/Output File Paths:
; ===================================================================

; Input Vertical Grid File:
in_vgridPath      = "/glade/p/work/altuntas/mom.input/tx0.66v1/case_input_171220/INPUT/ocean_vgrid.nc"

; Input Topography File:
in_topoPath       = "/glade/p/work/altuntas/mom.input/tx0.66v1/case_input_171220/INPUT/ocean_topog.nc"

; Input Horizontal Grid File:
in_superGridPath  = "/glade/p/work/altuntas/mom.input/tx0.66v1/gen_grid_171220/tx0.66v1_grid.nc"

; Input Mask File:
in_maskPath       = "/glade/p/work/altuntas/mom.input/tx0.66v1/gen_grid_171220/ocean_mask_edited.nc"

; Output Horizontal Grid File (binary):
out_hgridPath     = "/glade/p/work/altuntas/mom.input/tx0.66v1/cice_input_171220/horiz_grid_20171220.ieeer8"

; Output Topography file (binary):
out_topoPath      = "/glade/p/work/altuntas/mom.input/tx0.66v1/cice_input_171220/topography_20171220.ieeei4"

; ===================================================================

in_vgridFile = addfile(in_vgridPath,"r")
in_topoFile = addfile(in_topoPath,"r")
in_superGridFile = addfile(in_superGridPath,"r")

sizes = dimsizes(in_topoFile->depth)
ny = sizes(0)
nx = sizes(1)

vgridSizes = dimsizes(in_vgridFile->dz)
ndepth = vgridSizes(0)
depths = new(ndepth, double)

depths(0) = in_vgridFile->dz(0)
do k=1,ndepth-1
depths(k) = in_vgridFile->dz(k) + depths(k-1)
end do

; fill in kmt:
kmt = new((/ny,nx/), integer)
kmt = ndepth
kmt!0 = "ny"
kmt!1 = "nx"

in_maskFile = addfile(in_maskPath,"r")
msk = toint(in_maskFile->mask)

do j=0,ny-1
do i=0,nx-1
do k=0,ndepth-1
if (in_topoFile->depth(j,i) .lt. depths(k))
kmt(j,i) = k
if ( msk(j,i).lt.1 .and. kmt(j,i).gt.0 ) then
print(" "+j+" "+i+" "+in_topoFile->depth(j,i)+" "+depths(k)+" "+(k-1) )
end if
break   
end if
end do   
end do
end do

dtr = get_d2r("double")
PI  = get_pi("double")

ulat = dtr * in_superGridFile->qlat(1:ny,1:nx)
ulon = dtr * in_superGridFile->qlon(1:ny,1:nx)
htn = (in_superGridFile->dxCv) * 100.0 ; convert to cm
hte = (in_superGridFile->dyCu) * 100.0 ; convert to cm
hus = (in_superGridFile->dxCu) * 100.0 ; convert to cm
huw = (in_superGridFile->dyCv) * 100.0 ; convert to cm
angle = dtr * (in_superGridFile->angle)

print(" "+max(htn)+" "+min(htn))
print(" "+max(hte)+" "+min(hte))

; write the topography file
setfileoption("bin","WriteByteOrder","BigEndian")
system("/bin/rm -f " + out_topoPath)
fbindirwrite(out_topoPath, (kmt))

; write the horizontal grid file
system("/bin/rm -f " + out_hgridPath)
fbindirwrite(out_hgridPath, (ulat))
fbindirwrite(out_hgridPath, (ulon))
fbindirwrite(out_hgridPath, (htn))
fbindirwrite(out_hgridPath, (hte))
fbindirwrite(out_hgridPath, (hus))
fbindirwrite(out_hgridPath, (huw))
fbindirwrite(out_hgridPath, (angle))
 

paulhall

Paul Hall
Member
I recently tried creating a CICE grid for a custom MOM6 grid using the python and ncl scripts in this thread (which I had used successfully in the past). However, when I try to run a case with the new set of grids I now get the following error message in the cesm log file (excerpted):
dec1767.hsn.de.hpc.ucar.edu 25: ERROR: CICE n, mesh_lon , lon, diff_lon = 1 215.9300000000000 -64.1917550934441 -0.79878D+02
dec1767.hsn.de.hpc.ucar.edu 25:
dec1767.hsn.de.hpc.ucar.edu 25: (abort_ice)ABORTED:
dec1767.hsn.de.hpc.ucar.edu 25: (abort_ice) called from ice_mesh_mod.F90
dec1767.hsn.de.hpc.ucar.edu 25: (abort_ice) line number 647
dec1767.hsn.de.hpc.ucar.edu 25: (abort_ice) error = ice_mesh_check:
dec1767.hsn.de.hpc.ucar.edu 25: ERROR: (abort_ice) ice_mesh_check:

and see the following in the cice log file (the ULON and ULON min/max values seem off):
(ice_comp_nuopc):(InitializeAdvertise)WARNING: tfrz_option from driver linear_s
alt is overwriting tfrz_option from cice namelist mushy
(ice_comp_nuopc):(InitializeAdvertise)WARNING: atmiter_ from driver 0.10000D-
01 is overwritting atmiter_conv from cice namelist 0.00000D+00
mesh file for cice domain is
/glade/u/home/paulhall/CESM/SASIP/grids/n100/ESMF_mesh_sasip_n100.nc
mask file for cice domain is
/glade/u/home/paulhall/CESM/SASIP/grids/n100/ESMF_mesh_sasip_n100.nc
(ice_read_xyt) read_global 98 1 503316480.000000
503316480.000000 5033164800000.00
(ice_read_global) read_global 99 1 -1.777781880591592E+306
8.515146846555257E+294 -1.777781880583230E+308
(ice_read_global) read_global 99 2 -2.893653090372116E+301
1.180408341142792E+308 Infinity
(ice_read_global) read_global 99 7 0.000000000000000E+000
0.000000000000000E+000 0.000000000000000E+000
(ice_read_global) read_global 99 3 -2.708864630005210E+299
1.221661105937845E+300 9.324806461428189E+301
(ice_read_global) read_global 99 4 -6.106018129814693E-257
2.422516750935218E+270 7.752053602992255E+273

min/max ULON: -1.657941094533100E+303 Infinity
min/max ULAT: -1.018593986527287E+308 4.878819762417483E+296
min/max TLON: -180.000000000000 180.000000000000
min/max TLAT: -89.7889613300025 89.9514162758023

min/max NLON: -180.000000000000 180.000000000000
min/max NLAT: -89.9467305341177 89.8260581488775
min/max ELON: -180.000000000000 180.000000000000
min/max ELAT: -80.8717325355776 87.8815721249592

(abort_ice)ABORTED:
(abort_ice) called from ice_mesh_mod.F90
(abort_ice) line number 647
(abort_ice) error = ice_mesh_check:
ERROR: (abort_ice) ice_mesh_check:
This occurs while running with cesm2_3_alpha17a (I had previously had success using a different custom CICE+MOM6 grids using cesm2_3_beta14). Any ideas where I'm going wrong (or if changes are needed to how custom CICE grids are generated)?

Thanks in advance or any insights!
 
Top