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

support C-grid connectivity in deseas #39

Merged
merged 12 commits into from
Nov 4, 2024
Merged

Conversation

aekiss
Copy link
Contributor

@aekiss aekiss commented Oct 21, 2024

fixes #37

@aekiss
Copy link
Contributor Author

aekiss commented Oct 21, 2024

@ezhilsabareesh8 could you try this out with your C-grid workflow please?

You'll need to add --grid_type C to any invocations of deseas, fill_fraction, check_nonadvective and fix_nonadvective.

@aekiss aekiss changed the title support c-grid connectivity in deseas support C-grid connectivity in deseas Oct 21, 2024
@ezhilsabareesh8
Copy link
Contributor

@aekiss I tired deseas with --grid_type C, here is the output after deseas for the same input file. Marginal seas are removed in both workflows.

topo_deseas_bgrid
topo_deseas_cgrid
I am trying to generate the topography from scratch using both B grid and C grid type, will update here shortly.

@aekiss
Copy link
Contributor Author

aekiss commented Oct 22, 2024

OK thanks @ezhilsabareesh8 - referring to this list the only differences I can see are the Malacca Strait is now open and there are a couple more wet points at the mouth of the Baltic.

Is your script on github somewhere I can take a look?

@ezhilsabareesh8
Copy link
Contributor

referring to this list the only differences I can see are the Malacca Strait is now open and there are a couple more wet points at the mouth of the Baltic.

Thanks @aekiss, compared to OM2, I think the Mediterranean, red and black sea are removed in the current workflow, even when the --grid_type is C.

OM2 topo:
bathymetry_hudsons_bay_OM2

My script is here /g/data/tm70/ek4684/domain-tools/gen_topo.sh

@aekiss
Copy link
Contributor Author

aekiss commented Oct 22, 2024

referring to this list the only differences I can see are the Malacca Strait is now open and there are a couple more wet points at the mouth of the Baltic.

Thanks @aekiss, compared to OM2, I think the Mediterranean, red and black sea are removed in the current workflow, even when the --grid_type is C.

I meant the only noticeable improvements in using grid_type C are Malacca Strait and the mouth of the Baltic. This suggest we'll need hand-edits prior to deseas.

@aekiss
Copy link
Contributor Author

aekiss commented Oct 22, 2024

deseas is also generating a lot of spurious land points in the middle of the ocean, regardless of grid_type. Was this happening before my code changes?
Screenshot 2024-10-22 at 2 40 42 pm

@ezhilsabareesh8
Copy link
Contributor

ezhilsabareesh8 commented Oct 22, 2024

deseas is also generating a lot of spurious land points in the middle of the ocean, regardless of grid_type

I also noticed this. I think it is happening after code changes, it was better before
Screenshot 2024-10-22 at 3 35 56 pm

New (after code changes):

Screenshot 2024-10-22 at 3 33 59 pm

@aekiss
Copy link
Contributor Author

aekiss commented Oct 22, 2024

do the spurious land points also appear using --grid_type B?

@ezhilsabareesh8
Copy link
Contributor

ezhilsabareesh8 commented Oct 22, 2024

do the spurious land points also appear using --grid_type B?

Yes but it is comparatively lesser than --grid_type C. Also I am getting this warning WARNING: could not number all the seas. Algorithm reached maximum number of iterations. when I run with --grid_type C

Screenshot 2024-10-22 at 4 27 40 pm

@ezhilsabareesh8
Copy link
Contributor

I am trying to generate the topography from scratch using both B grid and C grid type, will update here shortly

When I generate everything from scratch it seems okay, there are no spurious land points. I did the following

# Interpolate topography on horizontal grid:
./topogtools gen_topo -i GEBCO_2024.nc -o topog_new.nc --hgrid ocean_hgrid.nc --tripolar --longitude-offset -100 

# Fill cells that have a sea area fraction smaller than 0.5:
./topogtools fill_fraction -i topog_new.nc -o topog_new_fillfraction.nc  --fraction 0.5 --grid_type B

# Remove seas:
./topogtools deseas -i topog_new_fillfraction.nc -o topog_new_fillfraction_0.5_deseas_grid_B.nc --grid_type B

--grid_type B
Screenshot 2024-10-22 at 11 00 09 pm

--grid_type c

Screenshot 2024-10-22 at 11 07 09 pm

@aekiss
Copy link
Contributor Author

aekiss commented Oct 22, 2024

Great! With --grid_type C it's also retained the Med, Red & Baltic seas, but we still need to fix up the Black Sea, I guess by opening up the Bosphorus and Dardanelles.

Are Malacca and Sunda straits open? It's hard to tell.

@micaeljtoliveira
Copy link
Contributor

Sorry for not looking at this earlier. Happy to see that this seems to work as expected. I'll do a more thorough review tomorrow.

@ezhilsabareesh8
Copy link
Contributor

Malacca

Malacca and Sunda straits are open when --grid_type C

--grid_type B

Screenshot 2024-10-23 at 1 48 05 pm

--grid_type C

Screenshot 2024-10-23 at 1 45 26 pm

@aekiss
Copy link
Contributor Author

aekiss commented Oct 23, 2024

Dardanelles is open with --grid_type C, but Bosphorus needs to be manually opened to connect the Black Sea
Screenshot 2024-10-23 at 2 23 06 pm

@aekiss
Copy link
Contributor Author

aekiss commented Oct 23, 2024

I'm still getting this with --grid_type C (not B). It's apparently unable to remove the last 185 seas. Some sort of bug - I'll try to fix it.

Numbering seas
       # Iter   # Changes      # Seas
           1     1168182        2054
           2       39772         780
           3       14051         455
           4        7208         324
           5        6029         271
           6        4903         244
           7        4692         231
           8        4220         220
           9        3954         213
          10        3255         207
          11        3213         202
          12        2552         199
          13         661         197
          14         353         195
          15         283         193
          16         250         191
          17         243         190
          18         227         189
          19         168         188
          20         145         187
          21         128         186
          22         114         185
          23          54         185
          24          39         185
          25          39         185
...
         149          39         185
         150          39         185
WARNING: could not number all the seas. Algorithm reached maximum number of iterations.

@micaeljtoliveira
Copy link
Contributor

micaeljtoliveira commented Oct 23, 2024

It's apparently unable to remove the last 185 seas. Some sort of bug - I'll try to fix it.

@aekiss I'm afraid it's not a bug, but rather a "feature". The maximum number of diffusion iterations is hard-coded, most likely to avoid an infinite loop in case the code has some issue. I would suggest to increase that number to a much larger value.

EDIT: better yet, add this value to the CLI, so that the user can choose this value (and keep the default reasonable).

@micaeljtoliveira
Copy link
Contributor

Oh, scrap that. I now see that the algorithm seems stuck. Yes, definitely a bug.

@aekiss
Copy link
Contributor Author

aekiss commented Oct 23, 2024

I've pushed a commit to this PR that fixes the issue

…ix_nonadvective, check_nonadvective; require B grid for fix_nonadvective, check_nonadvective
@aekiss
Copy link
Contributor Author

aekiss commented Oct 24, 2024

@micaeljtoliveira sorry for the churn, I think it's ready for review now.

I've streamlined the code, only requiring grid_type for deseas. The other methods obtain grid_type from the input .nc file (or default to B-grid if the file has no valid grid_type attribute, for backwards compatibility).

Copy link
Contributor

@micaeljtoliveira micaeljtoliveira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aekiss Overall looks good.

That was quite a nasty little bug...

src/topography.f90 Show resolved Hide resolved
src/topography.f90 Outdated Show resolved Hide resolved
src/topography.f90 Outdated Show resolved Hide resolved
Co-authored-by: Micael Oliveira <[email protected]>
@micaeljtoliveira micaeljtoliveira merged commit 1b255f1 into master Nov 4, 2024
4 checks passed
micaeljtoliveira pushed a commit that referenced this pull request Nov 4, 2024
@micaeljtoliveira micaeljtoliveira deleted the iss37-cgrid branch December 6, 2024 00:39
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.

Optionally support C-grid connectivity in deseas
3 participants