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

Iwd #125

Merged
merged 7 commits into from
Nov 1, 2023
Merged

Iwd #125

merged 7 commits into from
Nov 1, 2023

Conversation

jasontempestholt
Copy link
Collaborator

Correction to N2 mean calculation and initialization of tdiss

Copy link
Collaborator

@chris-O-wilson chris-O-wilson left a comment

Choose a reason for hiding this comment

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

For the expression N2mean(:,:) = SUM( e3w_n(:,:,:) * rn2(:,:,:) * wmask(:,:,:) , DIM=3 ) / (ht_n(:,:) + 1._wp - tmask(:,:,1) ) * tmask(:,:,1) , I am slightly concerned about the term 1._wp - tmask(:,:,1) in the denominator.

I see that it's there to handle regions where ht_n might be zero (presumably where tmask=0). However, in shallow shelf regions, e.g. depths between 50m and mindepth, where tdiss is important, this will add 1 to the depth where tmask=1 (wet points), therefore adding an error.

Arguably, that error could be balanced to some extent by tuning rn_kappa_tdiss, but there could be a spatial gradient in the error if the bathymetry was shallow and sloping. That might make it a bit messy to describe in the paper, as tdiss differs in form from that used in Jayne and St. Laurent / Simmons et al.

An alternative would be to add an IF loop to only calculate tdiss where ht_n > 0._wp and to define tdiss=0 elsewhere (fine if it's initialised to zero anyway).

Also, the final term which multiplies the fraction by tmask(:,:,1) might not be needed. If the sum over k of wmask(:,:,:) in the numerator has the same zero pattern as tmask(:,:,1), then the latter might be superfluous.

Copy link
Collaborator

@chris-O-wilson chris-O-wilson left a comment

Choose a reason for hiding this comment

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

As far as I can see, the current code in MY_SRC_TIDE for this branch does not use the halos for the variable h2rough, i.e. there is nowhere where the index of h2rough extends past the inner sub-domains. This halo exchange initialisation could have been necessary if h2rough had needed to be differenced in space or averaged onto another C-grid point.

Could it be instead that this attempt to squash the bug is superfluous and that a later commit actually fixed it? i.e. does the model now run fine if the line 217 with the extra CALL lbc_lnk(...) is commented out?

Copy link
Collaborator

@chris-O-wilson chris-O-wilson left a comment

Choose a reason for hiding this comment

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

Similar to the comment about the other, possibly superfluous, CALL lbc_lnk(...).

I've edited your comment only @jasontempestholt, to reflect that mpp_max is a global max across procs., in case the user thought that nksr would somehow be set to the same value across each proc.    Hope you don't mind me committing directly to the IWD branch, as this is only a comment change.
@jasontempestholt
Copy link
Collaborator Author

h2rough is used to calculate tdiss which is used across halo boundary, hence h3rough needs to be valid in halos. Andrew C's advice is to not assume this is done on reading the data in. Given this is only one on init seams safer to leave in.

Copy link
Collaborator

@chris-O-wilson chris-O-wilson left a comment

Choose a reason for hiding this comment

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

@jasontempestholt Is step.F90_debug needed? All I can see if I compare this with step.F90 in master is a load of additional write(67,*) (...) statements and related, which I assume are the extras you mentioned in your email to Andrew and I at 1451 on 30/10. Aren't these only to write out values related to your method of debugging rather than material changes?

@jasontempestholt
Copy link
Collaborator Author

agreed , not the best place for it here feel free to delete and I'll add to a debug branch

@chris-O-wilson
Copy link
Collaborator

h2rough is used to calculate tdiss which is used across halo boundary, hence h3rough needs to be valid in halos. Andrew C's advice is to not assume this is done on reading the data in. Given this is only one on init seams safer to leave in.

Fair point about tdiss halos, although it's those that we should probably really care about.

If we knew that h2rough would not be used other than in the tdiss calculation, as it stands, then a halo exchange immediately after the DO-loops where tdiss is defined as a function of h2rough and N2mean could be cleaner and safest, as it would then catch uninitialised halos in both of these vars. Not critical to this iteration of the code, but it might be something for later perhaps.

@jasontempestholt
Copy link
Collaborator Author

we'll want to leave the halo exchange as is - these are super expensive so need to avoid putting them in the time stepping part if possilbe

@chris-O-wilson
Copy link
Collaborator

chris-O-wilson commented Nov 1, 2023 via email

@chris-O-wilson
Copy link
Collaborator

chris-O-wilson commented Nov 1, 2023 via email

As agreed with @jasontempestholt.   The original commit had only added debug diagnostic output.
Copy link
Collaborator

@chris-O-wilson chris-O-wilson left a comment

Choose a reason for hiding this comment

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

All good! Thanks for putting up with my nitpicking and my mistakes. It's been really helpful to work together on this. Thanks! C

@jasontempestholt jasontempestholt merged commit e1c5525 into master Nov 1, 2023
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.

3 participants