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

Unhelpful fact-checking of tracer initial condition file #1641

Open
ashjbarnes opened this issue Oct 9, 2024 · 0 comments
Open

Unhelpful fact-checking of tracer initial condition file #1641

ashjbarnes opened this issue Oct 9, 2024 · 0 comments

Comments

@ashjbarnes
Copy link
Contributor

ashjbarnes commented Oct 9, 2024

It's complicated to explain how I got here so bear with me:

In extending the regional-mom6 package to work with curved boundaries, like the NWA-25 domain, I initially forgot to regrid the initial condition tracer file onto the new hgrid. There was a hardcoded line where, under the assumption of a simple horizintal grid on lines of constant lat / lon, my initial condition was being regridded onto constant lat/lon lines, ignoring the curved northern boundary. The variables had coordinates salt(yh,xh) and the coordinates themselves were defined in the netcdf as yh(yh), which contained lat/lon values

At this point, the model ran, except there were boundary issues due to the weird initial condition. I subsequently fixed things so that we have salt(ny,nx), lat(ny,nx) and lon(ny,nx) now. The encoding for my initial condition looks like this:

dimensions:
	ny = 780 ;
	nx = 740 ;
	zl = 65 ;
variables:
	double xh(ny, nx) ;

	double yh(ny, nx) ;

	double salt(zl, ny, nx) ;

		salt:coordinates = "xh yh" ;

	double temp(zl, ny, nx) ;

		temp:coordinates = "xh yh" ;

	double zl(zl) ;

where I've deleted most of the metadata to reduce clutter. However, despite having exactly the same dimensions and metadata, MOM6 now crashes throwing:

Could not find variable nx in file init_tracers.nc, thrown in line 881 of MOM_io

This is odd, since nx ought just to be an index, not a variable. Previously, the coordinates were populated with incorrect latitude and longitude lines, but this passed the MOM_io test. I then populated the netcdf with new coordinate variables nx and ny with integer indices. The model ran fine.

Finally, I populated nx and ny with random floats, and this also ran fine.

What was intriguing about this, is that the velocity initial condition file does not have values for nx,ny,nxp,nyp, and this has never caused an issue for me before.

This suggests to me that the way that the initial condition tracers are being read in is erroneously checking for the existence of index variables, even if they have no meaning and MOM6 has no need for them, whereas this isn't the case for the velocities.

I've had a look in MOM_state_initialization.F90, but my understanding of the codebase isn't strong enough to figure out exactly what the difference between the initialize_temp_salt_from_file and initialize_velocity_from_file might be.

Perhaps this is a total misunderstanding on my part and someone can help me, but if this isn't the intended behaviour I'd suggest either:

  1. Relax the variable checking requirements on initialize_temp_salt_from_file that causes it to crash if index variables aren't present.
  2. Update the error message being thrown on line 637 (read_param_int: Unable to find variable) to explain that if the variable in question isn't actually meant to be a variable, you ought to populate this file with dummy data as a workaround
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

No branches or pull requests

1 participant