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

FSD fixes for conservation #495

Merged
merged 40 commits into from
Oct 31, 2024
Merged

FSD fixes for conservation #495

merged 40 commits into from
Oct 31, 2024

Conversation

dabail10
Copy link
Contributor

@dabail10 dabail10 commented Jul 29, 2024

For detailed information about submitting Pull Requests (PRs) to the CICE-Consortium,
please refer to: https://github.com/CICE-Consortium/About-Us/wiki/Resource-Index#information-for-developers

PR checklist

  • Short (1 sentence) summary of your PR:
    This fixes the conservation issues in CICE with the FSD, but also for non-FSD cases!
  • Developer(s):
    @dabail10 , @lettie-roach , @cmbitz
  • Suggest PR reviewers from list in the column to the right.
  • Please copy the PR test results link or provide a summary of testing completed below.
    https://github.com/CICE-Consortium/Test-Results/wiki/icepack_by_hash_forks#925bdea8760a8d833f0550b408226e80a8969378
  • How much do the PR code changes differ from the unmodified code?
    • bit for bit
    • different at roundoff level
    • more substantial
  • Does this PR create or have dependencies on CICE or any other models?
    • Yes
    • No
  • Does this PR add any new test cases?
    • Yes
    • No
  • Is the documentation being updated? ("Documentation" includes information on the wiki or in the .rst files from doc/source/, which are used to create the online technical docs at https://readthedocs.org/projects/cice-consortium-cice/.)
    • Yes
    • No, does the documentation need to be updated at a later time?
      • Yes
      • No
  • Please document the changes in detail, including why the changes are made. This will become part of the PR commit log.
    This is a bug fix plus some rearranging for conservation in CICE. This impacts FSD cases as well as non-FSD cases.

There are two main aspects to the bug fix:

  1. Initial ice and snow volume values at the beginning of the lateral melt routine are now used for updating the snow and ice enthalpy as well other tracers for lateral melting. This is answer changing in all cases!
  2. The other fix is to move the computation of vi0new_lat (lateral growth from FSD) outside of the subroutine fsd_lateral_growth and a check to make sure the category vi0new (vin0new) does not exceed the total vi0new. This is a warning and it recomputes to ensure conservation. This is only answer changing in FSD cases.
  3. There is also a change in definition of floe_area_c, so that it is precisely half way between floe_area_l and floe_area_h. The original computation of floe_area_c based on floe_rad_c biases the area towards the lower value.

Update the fsd subroutine arguments (floe_rad_c, floe_rad_l, floe_binwidth, c_fsd_range) to store static data inside Icepack when computed in Icepack rather than pass them back and forth. Provide an ability to pass out the values from Icepack as optional arguments.

Move the computation of rsiden and get rid of fside which is no longer needed.

Clean up some comments and indentation

Update swccsm3 test, set ktherm=1

Update interface documentation

There is an associated CICE tag to go with this.

Copy link
Contributor

@eclare108213 eclare108213 left a comment

Choose a reason for hiding this comment

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

Initial read-through of the code diffs, trying to understand what's happening here and noting a few things that stand out.
What exactly is the conservation bug fix? There are a lot of changes, so it's not clear.

configuration/driver/icedrv_arrays_column.F90 Outdated Show resolved Hide resolved
configuration/driver/icedrv_arrays_column.F90 Outdated Show resolved Hide resolved
configuration/driver/icedrv_arrays_column.F90 Outdated Show resolved Hide resolved
configuration/driver/icedrv_flux.F90 Show resolved Hide resolved
configuration/driver/icedrv_InitMod.F90 Outdated Show resolved Hide resolved
! floe size distribution
if (tr_fsd) then
if (rsiden(n) > puny) then
if (aicen(n) > puny) then ! not sure if this should be aicen or aicen_init
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the plan for figuring out if it should be aicen or aicen_init? Why not use the most recent value? I guess the vertical melting and lateral melting are proceeding simultaneously, so neither is exactly correct. (aicen+aicen_init)/2?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, is aicen_init at the beginning of the timestep or some other point during the timestep? Seems to be set at the beginning of the lateral_melt subroutine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would think this should be aicen_init, which isn't defined yet. Otherwise aicen might be less than puny from the state variable adjustment immediately above, and the fsd wouldn't be updated equivalently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I look at this code, it seems like the if conditions on rsiden and aicen are kind of redundant. Except in the case where rsiden(n) = 1. This would mean that aicen(n) would go to zero. So, I do think you want a check on the updated aicen(n).

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have concluded that aicen(n) is correct, then please remove the "not sure" comment!

columnphysics/icepack_therm_itd.F90 Show resolved Hide resolved
@@ -1251,37 +1172,37 @@ subroutine lateral_melt (dt, ncat, &
if (z_tracers) &
call lateral_melt_bgc(dt, &
ncat, nblyr, &
rside, vicen_init, & !echmod: use rsiden
rsiden(1), vicen_init, & !echmod: use rsiden !CMB this should be sent rsiden
Copy link
Contributor

Choose a reason for hiding this comment

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

delete comment

columnphysics/icepack_therm_itd.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_therm_itd.F90 Show resolved Hide resolved
@eclare108213
Copy link
Contributor

GHActions/IcepackTesting failed, so I relaunched it.

@dabail10
Copy link
Contributor Author

One of the failed tests is a Picard convergence. I will do some offline testing.

Copy link
Contributor

@eclare108213 eclare108213 left a comment

Choose a reason for hiding this comment

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

some responses -

configuration/driver/icedrv_arrays_column.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_therm_itd.F90 Show resolved Hide resolved
configuration/driver/icedrv_arrays_column.F90 Outdated Show resolved Hide resolved
@apcraig
Copy link
Contributor

apcraig commented Jul 30, 2024

This seems to change answers for all configurations. Is that expected?

There is also an "out of memory" error for one of the tests. The derecho test suite, https://github.com/CICE-Consortium/Test-Results/wiki/icepack_by_hash_forks#925bdea8760a8d833f0550b408226e80a8969378, seems to have the same errors thrown up by github actions.

Please add more information to the PR section "Please document the changes in detail, including why the changes are made. This will become part of the PR commit log" listing and explaining what things changed in greater detail. Also, you indicate a dependency on CICE, does this mean public Icepack interfaces changed and if so, please document that. Good to also explain why answers changed in a little greater detail. Thanks.

@dabail10
Copy link
Contributor Author

This test is failing in github actions. This same test is fine on derecho_intel.

testsuite.macos-latest/conda_macos_restart_col_1x1_swccsm3.macos-latest/logs/icepack.runlog.240730-182013


(picard_solver) picard_solver: Picard solver non-convergence
(icepack_warnings_setabort) T :file /Users/runner/icepack/columnphysics/icepack_therm_mushy.F90 :line 1399
(icepack_warnings_aborted) ... (picard_solver)
(icepack_warnings_aborted) ... (two_stage_solver_nosnow)
(icepack_warnings_aborted) ... (temperature_changes_salinity)
(temperature_changes_salinity)temperature_changes_salinity: Picard solver non-convergence (no snow)
(icepack_warnings_aborted) ... (thermo_vertical)
(icepack_warnings_aborted) ... (icepack_step_therm1)
(icepack_step_therm1) ice: Vertical thermo error, cat 1
(icepack_warnings_aborted) ... (icepack_step_therm1)
(icepack_warnings_aborted) ... (icepack_step_therm1)
(icepack_warnings_aborted) ... (icepack_step_therm1)

(icedrv_system_abort) ABORTED:
(icedrv_system_abort) called from /Users/runner/icepack/configuration/driver/icedrv_step.F90
(icedrv_system_abort) line number 420
(icedrv_system_abort) string = (step_therm1)

@apcraig
Copy link
Contributor

apcraig commented Jul 30, 2024

You could try running that test on derecho with other compilers (gnu, cray?) and also turn on the debug flags to see if it picks anything up.

Could this be a fluke that is related to #494?

Have you tried running in CICE and does the test suite run fine there?

Are there some modifications that could be impacting this test in particular?

@dabail10
Copy link
Contributor Author

I am able to reproduce it on my macos conda environment. There are NaN's in the mushy-layer solution. This case is using the old shortwave (ccsm3) with ktherm=2. I don't think we should be testing this.

@apcraig
Copy link
Contributor

apcraig commented Jul 30, 2024

I am able to reproduce it on my macos conda environment. There are NaN's in the mushy-layer solution. This case is using the old shortwave (ccsm3) with ktherm=2. I don't think we should be testing this.

Can you suggest changes to the swccsm3 test? Always good to review our test suite and continue to make improvements. Feel free to also suggest a couple new tests.

@dabail10
Copy link
Contributor Author

I am testing this out with ktherm=1. I think this might be better.

@apcraig apcraig added the Physics label Aug 8, 2024
@dabail10
Copy link
Contributor Author

What else is needed here? Can I change the swccsm3 to use ktherm=1?

@eclare108213
Copy link
Contributor

Can I change the swccsm3 to use ktherm=1?

Yes.

I'll look at my previous comments to see what can be marked as resolved.

@dabail10
Copy link
Contributor Author

Ok. I have cleaned up the driver code and only the changes related to rside / rsiden are now there.

@dabail10
Copy link
Contributor Author

Weird. It is emailing me and telling me gh-actions is failing.

@apcraig
Copy link
Contributor

apcraig commented Aug 22, 2024

The GH Actions failures are happening with some regularity these days. Restarting them seems to work. Not clear what's going on.

Copy link
Contributor

@eclare108213 eclare108213 left a comment

Choose a reason for hiding this comment

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

This PR is very close, just a few clean-up items.

columnphysics/icepack_therm_itd.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_therm_itd.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_therm_itd.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_therm_itd.F90 Outdated Show resolved Hide resolved
configuration/driver/icedrv_step.F90 Show resolved Hide resolved
@dabail10
Copy link
Contributor Author

I thought I had addressed all of @eclare108213 's comments above. I guess I need some help prototyping these arrays.

@eclare108213
Copy link
Contributor

I thought I had addressed all of @eclare108213 's comments above.

I resolved the ones that you addressed, and there are still a few left. Thanks.

@apcraig
Copy link
Contributor

apcraig commented Oct 23, 2024

No problem, let me create a sandbox with the mods and try to propose something. It could be I'm misreading the code too.

dabail10 and others added 3 commits October 25, 2024 11:20
c_fsd_range in icepack_init_fsd_bounds to pass the arrays back to
the driver.

Pass afsdn into icepack_stgep_therm1 as an optional argument, check
it exists with tr_fsd, and pass it down the calling tree as optional.

Remove fsd variables that are not used in the Icepack driver.

Clean up some indentation and blank spaces

Update Icepack interface documentation
@dabail10
Copy link
Contributor Author

I thought I had addressed all of @eclare108213 's comments above.

I resolved the ones that you addressed, and there are still a few left. Thanks.

I am not finding the unresolved comments. I found one about fside / rside as diagnostics. I think I will add these later.

@eclare108213
Copy link
Contributor

I am not finding the unresolved comments. I found one about fside / rside as diagnostics. I think I will add these later.

Scroll through “Files changed”.
I think they are all in icepack_therm_itd.F90, and all minor but good to clean up now.

@dabail10
Copy link
Contributor Author

Hopefully this is ready for review again.

Copy link
Contributor

@eclare108213 eclare108213 left a comment

Choose a reason for hiding this comment

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

This is a nice cleanup of the code, plus some bug fixes. I spotted a few more minor things, reading through the changes.

! floe size distribution
if (tr_fsd) then
if (rsiden(n) > puny) then
if (aicen(n) > puny) then ! not sure if this should be aicen or aicen_init
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have concluded that aicen(n) is correct, then please remove the "not sure" comment!

columnphysics/icepack_therm_vertical.F90 Outdated Show resolved Hide resolved
columnphysics/icepack_fsd.F90 Outdated Show resolved Hide resolved
@eclare108213
Copy link
Contributor

This PR also redefines
floe_area_c = (floe_area_h+floe_area_l)/c2
instead of using a quadratic formulation. I'm not sure if that qualifies as a bug fix or simply a different choice in the parameterization, but it should probably be mentioned in the PR commit log (above).

@apcraig apcraig self-assigned this Oct 28, 2024
@apcraig
Copy link
Contributor

apcraig commented Oct 28, 2024

@dabail10, can you review the latest comments and update the code if needed. I will start testing again too. Can we get this merged in the next couple days? Once we merge this, we'll have to update the CICE fsd PR to point to the merged Icepack. Trying to hold other PRs at the moment, hoping we can finish this up.

@dabail10
Copy link
Contributor Author

I will try to resolve the remaing issues tomorrow.

@dabail10
Copy link
Contributor Author

I have resolved the most recent issues.

@apcraig
Copy link
Contributor

apcraig commented Oct 30, 2024

I'm running a test suite on derecho. Unless I hear otherwise, I'll assume the fsd results are as expected. Will approve and merge when testing is complete, again, unless others provide additional review/feedback.

Are any updates needed in the PR summary? I will cut and paste that into the merge comment.

@dabail10
Copy link
Contributor Author

I'm running a test suite on derecho. Unless I hear otherwise, I'll assume the fsd results are as expected. Will approve and merge when testing is complete, again, unless others provide additional review/feedback.

Are any updates needed in the PR summary? I will cut and paste that into the merge comment.

I did update the PR summary as requested by @eclare108213.

@apcraig
Copy link
Contributor

apcraig commented Oct 30, 2024

I just updated the PR summary as well. Are any updates needed in the user guide for the fsd changes?

@dabail10
Copy link
Contributor Author

I just updated the PR summary as well. Are any updates needed in the user guide for the fsd changes?

Not at this point. This was just a redo of the code. The options for activating it have not changed. I will have a future PR that will be bringing in an alternative wave fracturing method and the documentation will change then.

@apcraig
Copy link
Contributor

apcraig commented Oct 31, 2024

Testing looks good.

@apcraig
Copy link
Contributor

apcraig commented Oct 31, 2024

All reviews have been resolved. Will merge now. @dabail10, can you update Icepack in the CICE PR to point to the consortium main when you have a chance, then we can merge that too. Thanks.

@apcraig apcraig merged commit 286630f into CICE-Consortium:main Oct 31, 2024
2 checks passed
dabail10 added a commit to ESCOMP/Icepack that referenced this pull request Nov 4, 2024
This is a bug fix plus some rearranging for conservation in CICE. This impacts FSD cases as well as non-FSD cases.

There are two main aspects to the bug fix:

    Initial ice and snow volume values at the beginning of the lateral melt routine are now used for updating the snow and ice enthalpy as well other tracers for lateral melting. This is answer changing in all cases!

    The other fix is to move the computation of vi0new_lat (lateral growth from FSD) outside of the subroutine fsd_lateral_growth and a check to make sure the category vi0new (vin0new) does not exceed the total vi0new. This is a warning and it recomputes to ensure conservation. This is only answer changing in FSD cases.

    There is also a change in definition of floe_area_c, so that it is precisely half way between floe_area_l and floe_area_h. The original computation of floe_area_c based on floe_rad_c biases the area towards the lower value.

Update the fsd subroutine arguments (floe_rad_c, floe_rad_l, floe_binwidth, c_fsd_range) to store static data inside Icepack when computed in Icepack rather than pass them back and forth. Provide an ability to pass out the values from Icepack as optional arguments.

Move the computation of rsiden and get rid of fside which is no longer needed.

Clean up some comments and indentation

Update swccsm3 test, set ktherm=1

Update interface documentation

There is an associated CICE tag to go with this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants