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

add carbon to conservation check analysis member #5151

Merged
merged 8 commits into from
Sep 22, 2022

Conversation

maltrud
Copy link
Contributor

@maltrud maltrud commented Aug 23, 2022

This PR adds carbon to the conservation check analysis member. output is written to both the log file and conservation check netcdf file. carbon variables are written to the netcdf file even if BGC is not turned on (unless the user modifies streams.ocean), but not to the log file.

@maltrud maltrud added mpas-ocean BFB PR leaves answers BFB BGC labels Aug 23, 2022
@maltrud maltrud requested review from katsmith133 and jonbob August 23, 2022 22:00
@jonbob
Copy link
Contributor

jonbob commented Sep 1, 2022

@maltrud - I tested this in a ne30pg2_r05_EC30to60E2r2 BGCEXP_CNTL_CNPECACNT_1850 configuration and it died after the first month with:

CRITICAL ERROR: WARNING: relative carbon error exceeds bounds

I think you need some kind of accumulator for the number of times you've added sums into the accumulation arrays? In my case, after it went to output the carbon conservation information after a month, the relative error and accumulated relative error are the same:

 RELATIVE CARBON ERROR = -1.30190623E-08

 Accumulated absolute carbon error (kg)  -4.74559000E+08

 Accumulated relative carbon error =     -1.30190623E-08

but the bounds checks you're applying to the accumulated one has been multiplied by the number of time steps while the relative one is compared to a hardcoded 1.0e-08. That one might need to have some factor that considers the number of steps/days that have been accumulated, especially since the budget output could be per step/day/month/year?

Anyway, I'm retesting with 2.0e-08 just to see if that allows it to hold together....

@mark-petersen
Copy link
Contributor

As a first sanity test, I compiled MPAS-Ocean standalone with gnu and intel, optimized and debug, and ran the nightly suite with config_AM_conservationCheck_enable = .true.. Everything passed. Admittedly, these tests are not exercising the BGC or carbon parts of this code.

@maltrud can you describe here your testing and results with this analysis member on and ocean BGC variables on?

@jonbob
Copy link
Contributor

jonbob commented Sep 14, 2022

I ran a six-month test with @maltrud's new updates and get this:

cpl log:
seq_diagBGC_print_mct) NET CARBON BUDGET (kg-C/m2s*1e10): period =  monthly: date =     10701     0
                           atm            lnd            rof            ocn         ice nh         ice sh            glc        *SUM*
     surface co2   -11.21169829    10.64144230     0.00000000     0.57025599     0.00000000     0.00000000     0.00000000    -0.00000000
    black carbon    -0.00087513     0.00045669     0.00000000     0.00039630     0.00002091     0.00000121     0.00000000    -0.00000002
    orgnc carbon    -0.03525708     0.01548958     0.00000000     0.01815866     0.00147425     0.00012680     0.00000000    -0.00000779
     i-o inorgnc     0.00000000     0.00000000     0.00000000     0.82734918    -0.48548555    -0.34238301     0.00000000    -0.00051938
     i-o   orgnc     0.00000000     0.00000000     0.00000000    -0.27792464    -0.26325037     0.54110534     0.00000000    -0.00006967
           *SUM*   -11.24783050    10.65738857     0.00000000     1.13823550    -0.74724076     0.19885035     0.00000000    -0.00059685

and the ocn log:
MPAS-Ocean name             kg/s (raw sum)    coupler name    short name         kg/m^2/s*1.e6 (flux)
 MarBL SrcSink+sedFlux      -2.09418656E-11                                      -0.00000000
 sedimentFlux                3.37745618E+04                                       0.00006621
 surfaceFlux                 6.33063584E+04                                       0.00012411
 CO2 gas Flux                2.90800701E+04                                       0.00005701
 Ice-Ocean Organic Flux     -1.41769673E+04                                      -0.00002779
 Ice-Ocean Inorganic Flux    4.22031762E+04                                       0.00008273
 SUM FLUXES (surf + sed)     9.70809202E+04                                       0.00019032

so the fluxes that both calculate match very well.

@maltrud -- does it make sense in the ocn budget to scale the fluxes to be kg/m^2/s1.e10 instead of kg/m^2/s1.e6? We might get a few more significant digits that way....

@maltrud
Copy link
Contributor Author

maltrud commented Sep 15, 2022

@jonbob yes I should have used 1.e10 instead of 1.e6 for consistency with the cpl output. I'll push that change asap.

@rljacob
Copy link
Member

rljacob commented Sep 15, 2022

@katsmith133 please review.

Copy link

@katsmith133 katsmith133 left a comment

Choose a reason for hiding this comment

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

Approving based upon @jonbob's test and visual inspection

@jonbob
Copy link
Contributor

jonbob commented Sep 20, 2022

Thanks @maltrud -- after the latest update, the output now looks like:

MPAS-Ocean name             kg/s (raw sum)    coupler name    short name         kg/m^2/s*1.e10 (flux)
 MarBL SrcSink+sedFlux      -2.09418656E-11                                      -0.00000000
 sedimentFlux                3.37745618E+04                                       0.66211500
 surfaceFlux                 6.33063584E+04                                       1.24105503
 CO2 gas Flux                2.90800701E+04                                       0.57008440
 Ice-Ocean Organic Flux     -1.41769673E+04                                      -0.27792464
 Ice-Ocean Inorganic Flux    4.22031762E+04                                       0.82734918
 SUM FLUXES (surf + sed)     9.70809202E+04                                       1.90317003

and it much easier to compare with the cpl budget

Copy link
Contributor

@jonbob jonbob left a comment

Choose a reason for hiding this comment

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

Approved, based on testing

jonbob
jonbob approved these changes Sep 20, 2022
jonbob added a commit that referenced this pull request Sep 21, 2022
…(PR #5151)

Add carbon to mpas-ocean conservation check analysis member

This PR adds carbon to the conservation check analysis member. Output is
written to both the log file and conservation check netcdf file. Carbon
variables are written to the netcdf file even if BGC is not turned on
(unless the user modifies streams.ocean), but not to the log file.

[BFB]
@jonbob
Copy link
Contributor

jonbob commented Sep 21, 2022

passes sanity testing, merged to next

@jonbob jonbob merged commit e4a1392 into master Sep 22, 2022
@jonbob jonbob deleted the maltrud/ocean/add-carbon-conservation-check branch September 22, 2022 18:01
@jonbob
Copy link
Contributor

jonbob commented Sep 22, 2022

merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFB PR leaves answers BFB BGC mpas-ocean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants