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

Init bugs2 #1142

Merged
merged 15 commits into from
Dec 12, 2024
Merged

Init bugs2 #1142

merged 15 commits into from
Dec 12, 2024

Conversation

aronroland
Copy link
Collaborator

@aronroland aronroland commented Dec 16, 2023

Pull Request Summary

Solves uninitialized variables issues and improves/fixes issues with the Neuman boundary condition.

Description

This pull request, solves uninitialized variable issues for TR0 and other bugs connected to initialization issues. Moreover, adding Neumann-type boundary conditions in the RD framework can be accomplished by calculating the solution at the boundary, without modifying the scheme itself. Specifically, a zero-gradient Neumann condition is applied at the boundary. However, this approach becomes less straightforward when dealing with positive source term contributions or phenomena like refraction and frequency shifting. In such scenarios, the Neumann boundary condition, characterized by a zero gradient, is not sufficiently defined. This is because the waves at the boundary may grow, change direction, or modulate, leading to a net influx of energy into the domain. To resolve this, we have developed a solution that involves bypassing the calculation of spectral propagation at Neumann boundary points and excluding the computation of positive source terms.

Please also include the following information:
The code changes are trivial.
It was a bug.
Answers may change for the regtest, where the certain settings are used.

Issue(s) addressed

none issue was raised yet.

Commit Message

Fixing uninitialized issues within the implicit scheme

Check list

Testing

  • How were these changes tested?
    I have checked on certain setups by SHOM (with Heloise Michaud), that this fixes the issues she has found.
  • Have the matrix regression tests been run (if yes, please note HPC and compiler)?
    Will be done by ERDC.
  • Please indicate the expected changes in the regression test output, (Note the list of known non-identical tests.)
    Mostly none ...
  • Please provide the summary output of matrix.comp (matrix.Diff.txt, matrixCompFull.txt and matrixCompSummary.txt):
    Will be done by ERDC

@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland thank you for submitting this PR! As soon as the testing information from ERDC is added we'll start the tests and review.

@JessicaMeixner-NOAA
Copy link
Collaborator

Converting this PR to a draft. Please mark as ready to review with testing information is available. @aronroland @thesser1

@JessicaMeixner-NOAA JessicaMeixner-NOAA marked this pull request as draft January 16, 2024 15:36
@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland @thesser1 will you help make sure that the description of this PR includes all the updates in this branch or confirm that it's all there already?

@aronroland
Copy link
Collaborator Author

sure ...

@thesser1
Copy link
Collaborator

Please see attached results from regtests. Looks like binary differences.
matrixCompFull.txt
matrixCompSummary.txt
matrixDiff.txt

@MatthewMasarik-NOAA
Copy link
Collaborator

Please see attached results from regtests. Looks like binary differences. matrixCompFull.txt matrixCompSummary.txt matrixDiff.txt

Thanks for adding the testing @thesser1, I'll start working on it.

@JessicaMeixner-NOAA
Copy link
Collaborator

@thesser1 is this ready to be marked ready for review?

I did see that some tests had differences in the output of the unstructured grid cases, is this expected with the bug fixes?

THR = DBLE(1.E-15)
IF (SUM(A) .LT. THR) RETURN
IF (EMEAN .LT. TINY(1.d0)) THEN
S = 0
Copy link
Collaborator

@ukmo-ccbunney ukmo-ccbunney Mar 27, 2024

Choose a reason for hiding this comment

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

S and D are zeroed above. Why zero again here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, this was some leftover i cleaned it now, thanks @ukmo-ccbunney

@MatthewMasarik-NOAA
Copy link
Collaborator

@thesser1, I'm going to pause looking at this while there are some questions from Jessica and Chris.

@thesser1
Copy link
Collaborator

All, I had an issue with my netcdf library when I ran matrix.comp. I just noticed it and reran the comparison, and it increased the number of differences. Sorry for posting before checking. Based on comments above, it looks like there will be a fix and rerun needed, but I wanted to make sure the files posted here reflected all regression issues. I am sending differences to Aron, but I would keep this as draft for the time being.

@MatthewMasarik-NOAA
Copy link
Collaborator

All, I had an issue with my netcdf library when I ran matrix.comp. I just noticed it and reran the comparison, and it increased the number of differences. Sorry for posting before checking. Based on comments above, it looks like there will be a fix and rerun needed, but I wanted to make sure the files posted here reflected all regression issues. I am sending differences to Aron, but I would keep this as draft for the time being.

Thanks for the update, @thesser1. Please keep us posted

@aronroland
Copy link
Collaborator Author

Hi @JessicaMeixner-NOAA, we experience all HPCF maintenance. I guess it will be next week. Have a good weekend!

@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland thanks for the update!

@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland - I just wanted to check in to see if there were any updates on this PR.

@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland you mentioned this PR needs to go in first - what is the status of this PR?

@aronroland
Copy link
Collaborator Author

I think we need to rerun the regtests based on the latest merge and comment more on the anticipated changes of the results within the regtests.

@JessicaMeixner-NOAA
Copy link
Collaborator

I think we need to rerun the regtests based on the latest merge and comment more on the anticipated changes of the results within the regtests.

@aronroland sounds great! Looking forward to hearing more from you.

@thesser1
Copy link
Collaborator

I have merged all updates into init_bugs2. I am rerunning the regression tests. We will still need to clarify when and why out_grd and mod_def files are changing even when lateral boundaries are not included in the regression test setup. I will follow up when I have more information.

…nit in w3srce before the call it should not alter the results
@aronroland
Copy link
Collaborator Author

aronroland commented Dec 6, 2024

Hi @ukmo-ccbunney, hi @JessicaMeixner-NOAA ,

we have run the regression tests and looked at the results. Ty will upload the regtest results and I have hopefully cleaned the code so far. As of the differences to the regression tests. I have looked at those and reach following conclusion ...

The non-identical cases essentially consist of two groups. The first group includes the multi-structured part, for which I cannot fully explain the differences. In contrast, for the unstructured part in the multi-structured cases, the differences are attributable to changes made within the source term implementation. Specifically, for the implicit case, the differences stem from how the source terms are called, particularly the modification in w3wave, where the handling of boundary conditions and wetting/drying flags has been introduced at the top level.

mww3_test_03/./work_PR3_UQ_MPI_e_c (1 file differs)
mww3_test_03/./work_PR1_MPI_d2 (14 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2 (16 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2 (7 files differ)
mww3_test_03/./work_PR2_UQ_MPI_d2 (13 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2_c (12 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2_c (8 files differ)
mww3_test_03/./work_PR2_UNO_MPI_d2 (12 files differ)
mww3_test_09/./work_MPI_ASCII (0 files differ)

The next set of differences occurs in the Shinnecock Inlet case (2.17). These differences are expected due to modifications in the code concerning the treatment of TR1 and DB1 for zero-energy conditions. Additionally, for implicit schemes, changes were made in how source terms are applied at the boundary within w3wave. The resulting differences in the outputs are minor.

ww3_tp2.17/./work_mc1 (5 files differ)
ww3_tp2.17/./work_c (9 files differ)
ww3_tp2.17/./work_mc (5 files differ)

In the case of the Booij laboratory experiment, all changes impact the results. Besides issues with lateral boundary conditions and initialization, both TR1 and DB1 are active, leading to the observed differences.

ww3_tp2.19/./work_1A_a (9 files differ)
ww3_tp2.19/./work_1B_a (9 files differ)
ww3_tp2.19/./work_1C_a (9 files differ)

For the global setup, the differences are expected due to changes in DB1 and initialization issues.

ww3_tp2.21/./work_mb (7 files differ)
ww3_tp2.21/./work_b (6 files differ)
ww3_tp2.21/./work_b_metis (6 files differ)

In the Limon case, the differences are attributed to DB1 and initialization issues resolved within the implicit scheme.

ww3_tp2.6/./work_ST4_ASCII (0 files differ)
ww3_tp2.6/./work_pdlib (14 files differ)

For the UFS case, the differences arise from DB1 and initialization issues resolved in the implicit scheme.

ww3_ufs1.1/./work_unstr_c (6 files differ)

@aronroland aronroland marked this pull request as ready for review December 6, 2024 15:25
@thesser1
Copy link
Collaborator

thesser1 commented Dec 6, 2024

matrixCompFull.txt
matrixCompSummary.txt
Please find the attached files for the latest regtest results. The matrixDiff is reporting too large for posting to github.

@JessicaMeixner-NOAA
Copy link
Collaborator

Thank you @aronroland and @thesser1 - I'll start reviewing now!

One quick question: Does this PR close #1017 or any other open issues?

@aronroland
Copy link
Collaborator Author

aronroland commented Dec 6, 2024

yes it does solve issue @1071.

@JessicaMeixner-NOAA
Copy link
Collaborator

@aronroland I have confirmed I have the same differences as you and done a review of the code.

One follow up question: For the UFS case, the differences I'm assuming are actually from the implicit scheme changes versus DB1? Because all of the ufs1.1 cases use DB1 but only the c is the implicit scheme?

If we can confirm that, then I don't have to do an extra test. In the meantime I'm waiting for the comparison of this branch versus itself to confirm we maintain b4b with the new changes on the changed tests (Sorry I forgot to put the compare script in the queue earlier today). Should be ready to merge this late tomorrow/early Wednesday.

@@ -231,12 +232,9 @@ SUBROUTINE W3SDB1 (IX, A, DEPTH, EMEAN, FMEAN, WNMEAN, CG, LBREAK, S, D )
#endif
!
! 0. Initialzations ------------------------------------------------- /
! Never touch this 4 lines below ... otherwise my exceptionhandling will not work.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was doing some testing below - and saw this "Never touch these four lines" comment. I'm assuming @aronroland that the exception handling still works.... but just thought I'd draw attention to this comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @JessicaMeixner-NOAA sorry for my late reply, yes this was a leftover from long ago so I cleaned the code thanks for looking at this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @JessicaMeixner-NOAA, back to your comment on the UFS and the DB1 issue. I have check more the code and the reason is in this case not DB1 but rather my changes in w3wave, where we changed how the source terms are called in the implicit schemes for the sake of neumann boundary but also wetting and drying. I will expand a bit the text so it becomes more clear to everybody.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for replying @aronroland - and thanks for cleaning this up and all the bug fixes!

Copy link
Collaborator

@JessicaMeixner-NOAA JessicaMeixner-NOAA left a comment

Choose a reason for hiding this comment

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

Thanks for your patience as I did one more test and it took a little longer than expected.

I have the same changes as you:

**********************************************************************
********************* non-identical cases ****************************
**********************************************************************
mww3_test_03/./work_PR3_UQ_MPI_e_c                     (1 files differ)
mww3_test_03/./work_PR3_UNO_MPI_e                     (1 files differ)
mww3_test_03/./work_PR2_UNO_MPI_d2                     (8 files differ)
mww3_test_03/./work_PR1_MPI_d2                     (13 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2_c                     (11 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2_c                     (16 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2                     (12 files differ)
mww3_test_03/./work_PR2_UQ_MPI_d2                     (14 files differ)
mww3_test_03/./work_PR3_UQ_MPI_e                     (1 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2                     (16 files differ)
mww3_test_09/./work_MPI_ASCII                     (0 files differ)
ww3_tp2.10/./work_MPI_OMPH                     (7 files differ)
ww3_tp2.16/./work_MPI_OMPH                     (4 files differ)
ww3_tp2.17/./work_mc1                     (6 files differ)
ww3_tp2.17/./work_mc                     (6 files differ)
ww3_tp2.17/./work_c                     (10 files differ)
ww3_tp2.19/./work_1B_a                     (9 files differ)
ww3_tp2.19/./work_1A_a                     (9 files differ)
ww3_tp2.19/./work_1C_a                     (9 files differ)
ww3_tp2.21/./work_b_metis                     (6 files differ)
ww3_tp2.21/./work_mb                     (7 files differ)
ww3_tp2.21/./work_b                     (6 files differ)
ww3_tp2.6/./work_pdlib                     (14 files differ)
ww3_tp2.6/./work_ST4_ASCII                     (0 files differ)
ww3_ufs1.1/./work_unstr_c                     (6 files differ)
ww3_ufs1.3/./work_a                     (3 files differ)

matrixCompFull.txt
matrixCompSummary.txt

Note, the diff file as @thesser1 pointed out is too large.

I did confirm that the answers are reproducible against itself (ie this pr vs this pr), where we only get the expected diffs:

**********************************************************************
********************* non-identical cases ****************************
**********************************************************************
mww3_test_03/./work_PR1_MPI_e                     (1 files differ)
mww3_test_03/./work_PR3_UQ_MPI_e_c                     (1 files differ)
mww3_test_03/./work_PR2_UNO_MPI_e                     (1 files differ)
mww3_test_03/./work_PR2_UNO_MPI_d2                     (8 files differ)
mww3_test_03/./work_PR1_MPI_d2                     (13 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2_c                     (12 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2_c                     (15 files differ)
mww3_test_03/./work_PR3_UNO_MPI_d2                     (15 files differ)
mww3_test_03/./work_PR2_UQ_MPI_d2                     (11 files differ)
mww3_test_03/./work_PR3_UQ_MPI_e                     (1 files differ)
mww3_test_03/./work_PR3_UNO_MPI_e_c                     (1 files differ)
mww3_test_03/./work_PR3_UQ_MPI_d2                     (16 files differ)
mww3_test_09/./work_MPI_ASCII                     (0 files differ)
ww3_tp2.10/./work_MPI_OMPH                     (7 files differ)
ww3_tp2.16/./work_MPI_OMPH                     (4 files differ)
ww3_tp2.6/./work_ST4_ASCII                     (0 files differ)
ww3_ufs1.3/./work_a                     (3 files differ)

matrixCompFull.txt
matrixCompSummary.txt
matrixDiff.txt

Thanks for the bug-fixes!!!!!

@JessicaMeixner-NOAA JessicaMeixner-NOAA merged commit b7afba7 into NOAA-EMC:develop Dec 12, 2024
13 of 14 checks passed
@aronroland
Copy link
Collaborator Author

@JessicaMeixner-NOAA, I hope the text is more clean now and many thanks for the prompt review! Next step is the gse branch.

@JessicaMeixner-NOAA
Copy link
Collaborator

Awesome @aronroland , THANK YOU! Let me know if there's anything else I can do to help!

ukmo-ccbunney added a commit to ukmo-waves/WW3 that referenced this pull request Dec 19, 2024
…ce_refactor

* upstream/develop:
  Addition of Regression Test (ww3_tic1.1/IC4_M10) (NOAA-EMC#1331)
  IC4M10: New wave damping scheme in sea ice (NOAA-EMC#1293)
  Fixing uninitialized issues within the implicit scheme (NOAA-EMC#1142)
  ww3_ufs1.x: fix typo in switch_MPI_OMPH (NOAA-EMC#1323)
  README.md: update with link to doxygen documentation (NOAA-EMC#1316)
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