Skip to content

Clean up some diagnostics and ensure that diagnostics return AbstractOperations#94

Closed
navidcy wants to merge 19 commits into
mainfrom
ncc/diags-return-abstract-operations
Closed

Clean up some diagnostics and ensure that diagnostics return AbstractOperations#94
navidcy wants to merge 19 commits into
mainfrom
ncc/diags-return-abstract-operations

Conversation

@navidcy
Copy link
Copy Markdown
Member

@navidcy navidcy commented Mar 4, 2026

Continuing #71

#71 (comment)

Also includes #99

Comment thread src/Diagnostics/interface_fluxes.jl Outdated
Comment thread src/Diagnostics/interface_fluxes.jl Outdated
Comment on lines +143 to +146
function net_ocean_freshwater_flux(esm::EarthSystemModel; reference_salinity = 35)
ρᵒᶜ = esm.interfaces.ocean_properties.reference_density
S₀ = convert(typeof(ρᵒᶜ), reference_salinity)
net_ocean_frashwater_flux = - ρᵒᶜ / S₀ * net_ocean_salinity_flux(esm)
return Field(net_ocean_frashwater_flux)
return - ρᵒᶜ / S₀ * net_ocean_salinity_flux(esm)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is wrong right? we are actually given the freshwater flux. using a reference salinity will introduce an error that will prevent us from closing a water budget?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also is the sign - because salt flux is negative freshwater flux?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The negative sign is exactly because of that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment could be apropos!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

gotcha!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't use salt/salinity anymore to infer the freshwater fluxes but rather we read the freshwater fluxes from the coupler.

Copy link
Copy Markdown
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

good improvement, but I'm worried that providing temperature fluxes is not sustainable. I also worry about the approximatudes of a reference_salinity. Why don't we actually save the freshwater flux? This is hard to recover afterwards, eg if it comes from the atmosphere model's precipitation or land runoff

@navidcy
Copy link
Copy Markdown
Member Author

navidcy commented Mar 4, 2026

good improvement, but I'm worried that providing temperature fluxes is not sustainable. I also worry about the approximatudes of a reference_salinity. Why don't we actually save the freshwater flux? This is hard to recover afterwards, eg if it comes from the atmosphere model's precipitation or land runoff

To be honest, regarding temp-heat dings: the important diagnostics are the heat fluxes! I'm very happy to drop the temperature fluxes; nobody ever uses/analyses/plots those!

@glwagner
Copy link
Copy Markdown
Member

glwagner commented Mar 4, 2026

ok yeah i def think we should drop temperature fluxes!

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2026

@navidcy
Copy link
Copy Markdown
Member Author

navidcy commented Mar 4, 2026

ok yeah i def think we should drop temperature fluxes!

a9d7255

Return the sea ice-ocean salinity flux (g/kg m s⁻¹) at the sea ice-ocean interface
in a coupled `esm`.
"""
function sea_ice_ocean_salinity_flux(esm::EarthSystemModel)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is worth noting that this flux actually has units g / kg * m / s. "salinity" is properly unitless, (or just 1/1000). there is another quantity, the "salt flux", which we think would probably have kg * m/s (eg a mass flux)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's exactly what's mentioned in the docstring, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it doesnt say anything about the salt flux but you're right that it mentions the units

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perhaps when writing the docstrings I've used "salt flux" and "salinity flux" interchangeably.
Is there a difference between the two I should be aware of?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Your message suggests they are different. Salt flux is the mass of the salt, salinity is the "relative saltiness".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

perhaps my head is spinning now and I'm not communicating clearly? I banged it the other day and today it decided to hurt...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but isn't that an approximation, and not the true salinity flux which uses the surface salinity (prognostic, depends on xy)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sᵒᶜ = ocean_surface_salinity[i, j, 1]

Copy link
Copy Markdown
Member Author

@navidcy navidcy Mar 4, 2026

Choose a reason for hiding this comment

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

I see... so essentially J^S is the freshwater fluxes after multiplied by the surface salinity. So we should recover the freshwater fluxes by dividing by the actual surface salinity, not any reference salinity value, right?

That's what you are saying?

@navidcy navidcy changed the title Diagnostics return AbstractOperations Clean up some diagnostics and ensure that diagnostics return AbstractOperations Mar 4, 2026
@taimoorsohail
Copy link
Copy Markdown
Collaborator

Yep agree to drop salt and temperature fluxes!

@navidcy
Copy link
Copy Markdown
Member Author

navidcy commented Mar 4, 2026

Yep agree to drop salt and temperature fluxes!

done

Comment thread src/Diagnostics/interface_fluxes.jl
Comment thread src/Diagnostics/interface_fluxes.jl
Comment thread src/Diagnostics/interface_fluxes.jl
Comment thread src/Diagnostics/interface_fluxes.jl Outdated
navidcy and others added 6 commits March 4, 2026 11:49
* Modified freshwater flux definitions to match volume fluxes from interfaces

* Update freshwater diagnostics docs and calls

* Align freshwater diagnostics to mass flux units

* Remove redundant sea-ice freshwater write in net ocean assembly

* Apply suggestions from code review

---------

Co-authored-by: Navid C. Constantinou <navidcy@users.noreply.github.com>
@navidcy navidcy requested a review from glwagner March 4, 2026 12:07
@navidcy
Copy link
Copy Markdown
Member Author

navidcy commented Mar 4, 2026

@glwagner you approved but lots has changed; could you have another look?

Comment thread src/EarthSystemModels/InterfaceComputations/component_interfaces.jl Outdated
function atmosphere_ocean_freshwater_flux(esm::EarthSystemModel)
ρᵒᶜ = esm.interfaces.ocean_properties.reference_density
return ρᵒᶜ * esm.interfaces.atmosphere_ocean_interface.fluxes.freshwater_flux
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess there is a conflict here in terminology. probably the property should be changed to freshwater_volume_flux and we can define freshwater_flux as a mass flux.

Copy link
Copy Markdown
Member Author

@navidcy navidcy Mar 4, 2026

Choose a reason for hiding this comment

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

Or we can rename all freshwater flux diagnostics to freshwater_mass_flux?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and you propose defining freshwater_flux as a volume flux?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

esm.interfaces.atmosphere_ocean_interface.fluxes.freshwater_flux

is a volume flux, right?

We leave that as is, and the freshwater_flux diagnostics (which are mass fluxes) we add the _mass_ make it explicit that they differ from the

esm.interfaces.atmosphere_ocean_interface.fluxes.freshwater_flux

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is one option.

I am proposing a different path: define freshwater_flux as a mass flux, and rename the internal variable to make specific that it is a volume flux.

The reason to do this is that we really want to work with mass fluxes and a volume flux is not something user facing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Gotcha! Deal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a big change, right? I mean, there are a lot of places where in the internals of the coupler there is freshwater_flux and all need to change to freshwater_volume_flux?

The same should happen in the ocean-sea ice coupler?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isn't it just a search and replace?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sure, the workload is not my concern.
I just wanna confirm I understood correctly what I need to search and replace for.

Copy link
Copy Markdown
Member Author

@navidcy navidcy Mar 16, 2026

Choose a reason for hiding this comment

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

Could you do it, perhaps?
I'm getting confused which variables are already in mass flux and which in volume flux....

return Field(sea_ice_ocean_freshwater_flux)
end
sea_ice_ocean_freshwater_flux(esm::EarthSystemModel) =
esm.interfaces.sea_ice_ocean_interface.fluxes.freshwater_flux
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this exists. It's a salt flux, so we need to convert it to freshwater.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah scratch it. I didn't see it is part of this PR to add it

@navidcy
Copy link
Copy Markdown
Member Author

navidcy commented May 23, 2026

Too many merge conflicts; closing in favour of #281

@navidcy navidcy closed this May 23, 2026
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