Skip to content
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

make cice grid #8

Closed
wants to merge 4 commits into from
Closed

make cice grid #8

wants to merge 4 commits into from

Conversation

anton-seaice
Copy link
Contributor

@anton-seaice anton-seaice commented Mar 20, 2024

Created a cice grid generation script, using the esmgrids package.

The script creates a cice grid from the mom supergrid and the ocean mask file. The scripts adds the git commit of this script and the input path and md5sum of the mom files to the netcdf output. I added as close as we can get to cf-compliance and a CRS (See #7).

The differences between versions are in ... notebook and explored below in more detail. By the look of things, 1 deg and 0.25 degree files are inherited / historical and 0.1 deg was made for OM2 using the esmgrids package.

  1. Mismatched 0.25 degree ulat/ulon corner and also in 0.1 degree ulat/ulon. These should be fixed now.
  2. uarea - The 1deg and 0.25deg (i.e. inherited) uareas had some discepancy in them at the join. The new ones appear to be correct, see CICE grid generation from MOM supergrid  #6 (comment). The rest of the uarea in 0.25 deg doesn't match well however, and it looks like it was just set equal to tarea!
  3. AngleT. Only 0.1 degree was wrong and it was being set the same as angle U. This is being updated in esmgrids to use the correct angle from the MOM supergrid. (For completeness, although I think its unrelated, there was an upstream change between CICE5 and CICE6 to use a vector average to calculate angleT rather than a numerical average. The only details given seem to say it was a bug fix so that angles are averaged correctly. The method used in this PR is to get angleT from the MOM supergrid.)

Differences ( I filtered differences less than 2e-6):

1deg

new vars not in old?
{'tripolar'}
missing vars in new?
{'lont_bonds', 'lonu_bonds', 'latu_bonds', 'latt_bonds', 'hue', 'hun'}
htn anom min: nan, anom max: nan
uarea anom min: -1186349698.6215067, anom max: 33617654.79803729
tlat anom min: nan, anom max: nan
ulon anom min: nan, anom max: nan
angle anom min: nan, anom max: nan
tlon anom min: nan, anom max: nan
hte anom min: nan, anom max: nan
ulat anom min: nan, anom max: nan
tarea anom min: -19085417.985637665, anom max: 9877771.11514306
angleT anom min: nan, anom max: nan

025deg

new vars not in old?
{'tripolar'}
missing vars in new?
set()
htn anom min: nan, anom max: nan
uarea anom min: -69552757.44506374, anom max: 7366673.800787419
tlat anom min: nan, anom max: nan
ulon anom min: 3.620558794636963e-05, anom max: 3.141592653589793
angle anom min: -1.5707963267948966, anom max: 1.5707963267948966
tlon anom min: nan, anom max: nan
hte anom min: nan, anom max: nan
ulat anom min: -0.0018422347075643941, anom max: 0.0018422347075643941
tarea anom min: nan, anom max: nan
angleT anom min: nan, anom max: nan

01deg

new vars not in old?
{'tripolar'}
missing vars in new?
{'clat_t', 'clon_t', 'clat_u', 'clon_u'}
htn anom min: nan, anom max: nan
uarea anom min: nan, anom max: nan
tlat anom min: nan, anom max: nan
ulon anom min: nan, anom max: nan
angle anom min: nan, anom max: nan
tlon anom min: nan, anom max: nan
hte anom min: nan, anom max: nan
ulat anom min: nan, anom max: nan
tarea anom min: nan, anom max: nan
angleT anom min: -3.139931603248902, anom max: 1.1133153100325133

image

Even ignoring the join, its not clear why 0.25 deg uarea has changed, but it looks like it was set equal to tarea in the old grid

Screen Shot 2024-03-20 at 4 43 47 pm
Screen Shot 2024-03-20 at 4 51 32 pm

Known issues:

  1. Patterning in htn/hte in mom grid? - 1deg grid has oscillations in dyu access-om2#271

See companion PR for esmgrids repo

To-do:

  • test with OM2?
  • release.

@anton-seaice anton-seaice self-assigned this Mar 20, 2024
@anton-seaice
Copy link
Contributor Author

@aekiss & @ezhilsabareesh8 . This is ready for review. I haven't tested with OM2 or OM3 yet. This change is in conjunction with COSIMA/esmgrids#6

@anton-seaice anton-seaice marked this pull request as ready for review March 21, 2024 23:25
@aidanheerdegen
Copy link

So grids for all three resolutions need to be updated with non-trivial (more than metadata) changes?

@anton-seaice
Copy link
Contributor Author

So grids for all three resolutions need to be updated with non-trivial (more than metadata) changes?

That's my suggestion. We have to come up with a plan on how to validate the changes though.

@ezhilsabareesh8
Copy link
Contributor

When running the OM3 MOM6-CICE6 0.25-degree configuration using the make_cice_grid.py script in conjunction with the esmgrids tool (pull request), an error related to mask mismatch has been encountered. This issue arises specifically with the newly generated kmt.nc file, whereas there is no such error when using the OM2's kmt.nc mask file.

The error occurs within the code section linked here.

ERROR: CICE n, mesh_internal, mask_file =      165 0   1
ERROR: CICE n, mesh_internal, mask_file =      166 0   1
ERROR: CICE n, mesh_internal, mask_file =      286 1   0
ERROR: CICE n, mesh_internal, mask_file =      309 0   1
ERROR: CICE n, mesh_internal, mask_file =      310 0   1
ERROR: CICE n, mesh_internal, mask_file =      311 0   1
ERROR: CICE n, mesh_internal, mask_file =      332 0   1
ERROR: CICE n, mesh_internal, mask_file =      352 0   1
ERROR: CICE n, mesh_internal, mask_file =      372 0   1
ERROR: CICE n, mesh_internal, mask_file =      411 1   0
ERROR: CICE n, mesh_internal, mask_file =      412 1   0
ERROR: CICE n, mesh_internal, mask_file =      472 1   0
ERROR: CICE n, mesh_internal, mask_file =      552 1   0
ERROR: CICE n, mesh_internal, mask_file =      592 0   1
ERROR: CICE n, mesh_internal, mask_file =      610 1   0
ERROR: CICE n, mesh_internal, mask_file =      612 0   1
ERROR: CICE n, mesh_internal, mask_file =      626 1   0
ERROR: CICE n, mesh_internal, mask_file =      644 1   0
ERROR: CICE n, mesh_internal, mask_file =      647 1   0
ERROR: CICE n, mesh_internal, mask_file =      668 1   0
ERROR: CICE n, mesh_internal, mask_file =      685 1   0
(abort_ice)ABORTED:
 (abort_ice) called from ice_mesh_mod.F90
 (abort_ice) line number          688
 (abort_ice) error =  ice_mesh_check:
 ERROR: (abort_ice) ice_mesh_check:

@minghangli-uni
Copy link
Contributor

@ezhilsabareesh8 Did you generate the ice grid grid.nc using the same make_cice_grid.py script?

I havent got the mask mismatch yet, but using the make_cice_grid.py along with the esmgrids tool, I got the ice mesh mismatch, which was encountered in #101

ERROR: CICE n, mesh_lon , lon, diff_lon =        1    358.1250000000000        88.1250000000000            -0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      2.1250000000000        92.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1     10.1250000000000       100.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      6.1250000000000        96.1250000000000             0.90000D+02

@anton-seaice
Copy link
Contributor Author

Thanks both

Can you both try using pbs_make_cice_grids.sh to confirm its not due to different input files?

i.e. qsub pbs_make_cice_grid.sh

@ezhilsabareesh8
Copy link
Contributor

Thanks @anton-seaice. I ran pbs_make_cice_grids.sh to execute make_cice_grid.py and generate grid and mask files, still I am experiencing the mask mismatch error, however there is no issues with the grid.nc file for me

@anton-seaice
Copy link
Contributor Author

Ok. I am not sure then. It works with the OM3 in 1degree configuration.

Can you share your configuration ?

@ezhilsabareesh8
Copy link
Contributor

I have just updated the 025 deg configuration in this branch of MOM6-CICE6. Please have a look and change the input kmt.nc file to the newer one generated from make_cice_grid.py to reproduce the error

@anton-seaice
Copy link
Contributor Author

It turns out the ocean_mask I was using was out of date. I updated to the one from /g/data/ik11/inputs/access-om2/input_20230515_025deg_topog/mom_025deg/ocean_mask.nc and the model starts now.

@anton-seaice
Copy link
Contributor Author

@ezhilsabareesh8 Did you generate the ice grid grid.nc using the same make_cice_grid.py script?

I havent got the mask mismatch yet, but using the make_cice_grid.py along with the esmgrids tool, I got the ice mesh mismatch, which was encountered in #101

ERROR: CICE n, mesh_lon , lon, diff_lon =        1    358.1250000000000        88.1250000000000            -0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      2.1250000000000        92.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1     10.1250000000000       100.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      6.1250000000000        96.1250000000000             0.90000D+02

I am guessing your mesh file was made without the wrap_lons set to True?

parser.add_argument(

@minghangli-uni
Copy link
Contributor

@ezhilsabareesh8 Did you generate the ice grid grid.nc using the same make_cice_grid.py script?
I havent got the mask mismatch yet, but using the make_cice_grid.py along with the esmgrids tool, I got the ice mesh mismatch, which was encountered in #101

ERROR: CICE n, mesh_lon , lon, diff_lon =        1    358.1250000000000        88.1250000000000            -0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      2.1250000000000        92.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1     10.1250000000000       100.1250000000000             0.90000D+02

 (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:
ERROR: CICE n, mesh_lon , lon, diff_lon =        1      6.1250000000000        96.1250000000000             0.90000D+02

I am guessing your mesh file was made without the wrap_lons set to True?

parser.add_argument(

@anton-seaice I had some settings mixed up earlier. Now the grid works fine now.

@ezhilsabareesh8
Copy link
Contributor

I am guessing your mesh file was made without the wrap_lons set to True?

The mesh file was generated using wrap_lons

netcdf access-om2-025deg-ESMFmesh {
dimensions:
	nodeCount = 1555447 ;
	coordDim = 2 ;
	elementCount = 1555200 ;
	maxNodePElement = 4 ;
variables:
	double nodeCoords(nodeCount, coordDim) ;
		nodeCoords:units = "degrees" ;
	int elementConn(elementCount, maxNodePElement) ;
		elementConn:long_name = "Node indices that define the element connectivity" ;
	int numElementConn(elementCount) ;
		numElementConn:long_name = "Number of nodes per element" ;
	double centerCoords(elementCount, coordDim) ;
		centerCoords:units = "degrees" ;
	byte elementMask(elementCount) ;
	double elementArea(elementCount) ;

// global attributes:
		:gridType = "unstructured mesh" ;
		:timeGenerated = "2024-02-21 13:00:53.889926" ;
		:created_by = "ek4684" ;
		:inputFile = "ocean_hgrid.nc, ocean_mask.nc" ;
		:history = "Created using: python3 /g/data/tm70/ek4684/inputs/access-om3/0.x.0/025deg/share/generate_mesh.py --grid-type=mom --grid-filename=ocean_hgrid.nc --mesh-filename=access-om2-025deg-ESMFmesh.nc --mask-filename=ocean_mask.nc --wrap-lons"

@aidanheerdegen
Copy link

Can I suggest you add tests to make sure this is doing what you think it should. e.g. you could start with a test grid, generate the inputs from it and check it recreates the grid correctly.

@micaeljtoliveira
Copy link

Can I suggest you add tests to make sure this is doing what you think it should. e.g. you could start with a test grid, generate the inputs from it and check it recreates the grid correctly.

I second that, as it looks like it is critical that this script works correctly and might need to use it a few times while setting up the different configurations.

In order to have tests+CI+coverage out-of-the-box, might be worth moving this to https://github.com/COSIMA/om3-utils

@anton-seaice
Copy link
Contributor Author

Thanks both - I will work on some tests. I am planning on covering:

  • The data in the grid. I will make some MOM grids using https://github.com/nikizadehgfdl/ocean_model_grid_generator and then generate cice grids using this script. Ill then generate the cice grid using a different script and compare the results. The main issue with this method is I end up writing the code and the test and might put the same errors in both.
  • Check for cf-attributes in the data vars
  • Check for global attributes (existence of a crs which gdal accepts, md5 sum).

We could probably extend it to test against the esmf mesh files too.

@anton-seaice
Copy link
Contributor Author

Moving to COSIMA/om3-utils#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants