E3SM-Ocean-Discussion / E3SM

Ocean discussion repository, for ocean issues and longer-term pull requests for E3SM source code. Please make pull requests that are ready to merge into https://github.com/E3SM-Project/E3SM
https://e3sm.org
Other
1 stars 0 forks source link

Switch global ocean in init mode to E3SM shared constants #96

Closed xylar closed 5 months ago

xylar commented 7 months ago

This merge also migrates the computation of the Coriolis parameter to using E3SM shared constants.

The unused constants module imports are removed from several init mode utilities to ensure that they don't use constants that are inconsistent with E3SM's versions.

I have made local symlinks to the shared constants and kinds file for convenience in building using MPAS-Ocean's not-very-sophisticated build system.

xylar commented 7 months ago

@proteanplanet, this my proposed fix to https://github.com/E3SM-Project/E3SM/issues/6387. Please have a look, though I am fully aware that MPAS-Ocean init mode is nothing you have detailed knowledge about (nor should you!).

@mark-petersen, I know I'm asking a lot of you at a busy time but please give this a look when you can.

xylar commented 7 months ago

Testing

I ran the pr suite on Chrysalis with Intel and OpenMPI using this branch, and using https://github.com/MPAS-Dev/compass/pull/810 as a baseline (because this addresses recent non-BFB issue on Chrysalis).

Tests other than global ocean are BFB as expected. Global ocean forward runs show differences in T, S, layer thickness and velocity on the order of 1e-8 (so definitely not negligible).

proteanplanet commented 7 months ago

We should include a sea ice solution in this. I will take care of that this week.

xylar commented 7 months ago

@proteanplanet, since these changes are specific to mpas-ocean standalone, we shouldn't mix them with E3SM changes to any component. We should take care of that in a separate PR.

xylar commented 5 months ago

@mark-petersen and @proteanplanet, this would be nice to have before we create a SORRM mesh. Can you let me know if it's ready to go to E3SM?

proteanplanet commented 5 months ago

@xylar I will test this in a G-case 1-month run and report back here. Apologies for the delay. Too many things going on.

xylar commented 5 months ago

@proteanplanet, this only involves init mode in standalone so no need to run any simulations, though you could as a do-no-harm test. Just a quick code inspection will suffice before this goes to E3SM.

I will point you to the initial condition this code produces (I just need to find the path).

xylar commented 5 months ago

I verified that I get slightly different values for fCell with this code than before this change.

Before, see:

/lcrc/group/e3sm/ac.xylar/compass_1.4/chrysalis/test_20240611/sowiscr3_expand_rx1_mask/ocean/global_ocean/SOwISC12to30/WOA23/init/initial_state/initial_state.nc

This change:

/lcrc/group/e3sm/ac.xylar/compass_1.4/chrysalis/test_20240617/sowisc12to30e3r3_fix_coriolis/ocean/global_ocean/SOwISC12to30/WOA23/init/initial_state/initial_state.nc

Before:

 fCell = -0.000140769901625857, -0.000140704437612956, -0.00014083233024888, 
    -0.000140767163629124, -0.00014070142243594, -0.000140635078080735, 
    -0.000141022649665392, -0.000140958688777142, -0.000140894242018246, 
    -0.000140829320395959, -0.000140763846645755, -0.00014069784697824, 
    -0.000141086005207922, -0.000141083668731909, -0.000141019781326067, 
    -0.000140955517779708, -0.000140890854883258, -0.000140825741406588, 
...

This change:

 fCell = -0.000140769969519198, -0.000140704505474723, -0.000140832398172331, 
    -0.000140767231521144, -0.000140701490296253, -0.000140635145909051, 
    -0.000141022717680633, -0.000140958756761535, -0.000140894309971556, 
    -0.000140829388317958, -0.000140763914536176, -0.000140697914836829, 
    -0.00014108607325372, -0.000141083736776579, -0.000141019849339925, 
    -0.000140955585762572, -0.000140890922834935, -0.00014082580932686, 
...

The corresponding latCell (identical for both) is:

 latCell = -1.30628095579851, -1.30456946509689, -1.30792322431631, 
    -1.30620915702955, -1.30449089505505, -1.30276777196906, 
    -1.31299288231411, -1.31127831767717, -1.30956185509607, 
    -1.30784381625203, -1.30612220091371, -1.3043977544342, 
    -1.31470228273184, -1.31463904399789, -1.31291575362999, 
    -1.31119360249962, -1.30947194755724, -1.3077494233053,
...

I verified that the first entry seems right given:

   real(R8),parameter :: SHR_CONST_PI      = 3.14159265358979323846_R8  ! pi
   real(R8),parameter :: SHR_CONST_SDAY    = 86164.0_R8      ! sec in siderial day ~ sec
   real(R8),parameter :: SHR_CONST_OMEGA   = 2.0_R8*SHR_CONST_PI/SHR_CONST_SDAY ! earth rot ~ rad/sec
   ...
   fCell(iCell) = 2.0_RKIND * SHR_CONST_OMEGA * sin(latCell(iCell))
xylar commented 5 months ago

Thanks @proteanplanet and @mark-petersen!

Closing in favor of https://github.com/E3SM-Project/E3SM/pull/6481