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

Read CO2 from file #3522

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Read CO2 from file #3522

merged 1 commit into from
Jan 22, 2025

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Jan 16, 2025

Currently, when running AMIP, ClimaCoupler is responsible for updating the concentration of CO2 used for the radiation transport. This means that:

  1. ClimaAtmos by itself cannot use observed CO2 concentrations
  2. ClimaCoupler has to maintain specialized code just to update these values

The reason for why this was done is because originally only ClimaCoupler had the infrastructure to read in files. However, this is no longer the case and ClimaAtmos is already updating values read from files for aerosols and ozone.
This PR adds CO2 to the list.

@Sbozzolo Sbozzolo force-pushed the gb/co2 branch 6 times, most recently from d26180d to c6460fd Compare January 17, 2025 01:50
@Sbozzolo Sbozzolo requested a review from szy21 January 17, 2025 01:50
@Sbozzolo Sbozzolo force-pushed the gb/co2 branch 2 times, most recently from 0680575 to d40b6db Compare January 17, 2025 01:51
Copy link
Member

@szy21 szy21 left a comment

Choose a reason for hiding this comment

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

Thanks!

NEWS.md Outdated
### Read CO2 from file

`ClimaAtmos` now uses data from the Mauna Loa CO2 measurements to set CO2
concentration. This is currently only relevant for radiation transport with
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
concentration. This is currently only relevant for radiation transport with
concentration. This is currently only relevant for radiation transfer with

function co2_cache(::PrescribedCO2, Y, start_date)
FT = Spaces.undertype(axes(Y.c))
# co2 is well mixed, so it is just a number, but we create an array to
# update it with evalaute!
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# update it with evalaute!
# update it with evaluate!

src/solver/type_getters.jl Outdated Show resolved Hide resolved
src/solver/types.jl Outdated Show resolved Hide resolved
src/solver/types.jl Outdated Show resolved Hide resolved
@Sbozzolo Sbozzolo force-pushed the gb/co2 branch 3 times, most recently from 900462f to ee10e56 Compare January 17, 2025 23:30
Sbozzolo added a commit to CliMA/ClimaCoupler.jl that referenced this pull request Jan 17, 2025
Sbozzolo added a commit to CliMA/ClimaCoupler.jl that referenced this pull request Jan 17, 2025
Sbozzolo added a commit to CliMA/ClimaCoupler.jl that referenced this pull request Jan 17, 2025
@Sbozzolo Sbozzolo marked this pull request as ready for review January 18, 2025 00:12
@Sbozzolo Sbozzolo force-pushed the gb/co2 branch 3 times, most recently from 7b2558c to 3c8bd25 Compare January 18, 2025 00:28
src/callbacks/callbacks.jl Outdated Show resolved Hide resolved
src/solver/model_getters.jl Outdated Show resolved Hide resolved
src/solver/model_getters.jl Outdated Show resolved Hide resolved
@Sbozzolo Sbozzolo force-pushed the gb/co2 branch 5 times, most recently from 077ed0c to 5f465a8 Compare January 21, 2025 00:10
@Sbozzolo Sbozzolo added this pull request to the merge queue Jan 21, 2025
@Sbozzolo Sbozzolo removed this pull request from the merge queue due to a manual request Jan 21, 2025
Sbozzolo added a commit to CliMA/ClimaUtilities.jl that referenced this pull request Jan 21, 2025
Recent PRs in `ClimaCore` and
`ClimaComms` (CliMA/ClimaCore.jl#2114 and
CliMA/ClimaComms.jl#103) changed how contexts
are adapted to GPUs. This, coupled with
CliMA/ClimaAtmos.jl#3522, prompted me to look
again at the `TimeVaryingInputs0D` struct.

This struct is used in two main ways:
- to set site-level forcings/parameters (in ClimaLand)
- to set fields that have constant value on the globe (e.g., CO2)

The previous implementation achieved GPU compatibility by moving
everything to the GPU. This is not a great idea when the operation being
performed is some variation of linear interpolation in one
dimension (time) and for just one data point, as there is nothing really
to be parallelized. This choice was made because initially this feature
was only used in single-site ClimaLand runs, where all we cared about
was to be able to run on GPU. The other day, I realized that I could
have GPU compatibility in a much simpler and more robust way by
leveraging the `fill!` function. With this commit, 0D interpolation (1D
in time, 0D spatially) is changed to be always on the CPU, and the
result is written to the Field (or destination in general) using
`fill!`.

As a result, the CUDA extension is no longer needed.
Sbozzolo added a commit to CliMA/ClimaUtilities.jl that referenced this pull request Jan 21, 2025
Recent PRs in `ClimaCore` and
`ClimaComms` (CliMA/ClimaCore.jl#2114 and
CliMA/ClimaComms.jl#103) changed how contexts
are adapted to GPUs. This, coupled with
CliMA/ClimaAtmos.jl#3522, prompted me to look
again at the `TimeVaryingInputs0D` struct.

This struct is used in two main ways:
- to set site-level forcings/parameters (in ClimaLand)
- to set fields that have constant value on the globe (e.g., CO2)

The previous implementation achieved GPU compatibility by moving
everything to the GPU. This is not a great idea when the operation being
performed is some variation of linear interpolation in one
dimension (time) and for just one data point, as there is nothing really
to be parallelized. This choice was made because initially this feature
was only used in single-site ClimaLand runs, where all we cared about
was to be able to run on GPU. The other day, I realized that I could
have GPU compatibility in a much simpler and more robust way by
leveraging the `fill!` function. With this commit, 0D interpolation (1D
in time, 0D spatially) is changed to be always on the CPU, and the
result is written to the Field (or destination in general) using
`fill!`.

As a result, the CUDA extension is no longer needed.
Sbozzolo added a commit to CliMA/ClimaUtilities.jl that referenced this pull request Jan 21, 2025
Recent PRs in `ClimaCore` and
`ClimaComms` (CliMA/ClimaCore.jl#2114 and
CliMA/ClimaComms.jl#103) changed how contexts
are adapted to GPUs. This, coupled with
CliMA/ClimaAtmos.jl#3522, prompted me to look
again at the `TimeVaryingInputs0D` struct.

This struct is used in two main ways:
- to set site-level forcings/parameters (in ClimaLand)
- to set fields that have constant value on the globe (e.g., CO2)

The previous implementation achieved GPU compatibility by moving
everything to the GPU. This is not a great idea when the operation being
performed is some variation of linear interpolation in one
dimension (time) and for just one data point, as there is nothing really
to be parallelized. This choice was made because initially this feature
was only used in single-site ClimaLand runs, where all we cared about
was to be able to run on GPU. The other day, I realized that I could
have GPU compatibility in a much simpler and more robust way by
leveraging the `fill!` function. With this commit, 0D interpolation (1D
in time, 0D spatially) is changed to be always on the CPU, and the
result is written to the Field (or destination in general) using
`fill!`.

As a result, the CUDA extension is no longer needed.
Sbozzolo added a commit to CliMA/ClimaUtilities.jl that referenced this pull request Jan 21, 2025
Recent PRs in `ClimaCore` and
`ClimaComms` (CliMA/ClimaCore.jl#2114 and
CliMA/ClimaComms.jl#103) changed how contexts
are adapted to GPUs. This, coupled with
CliMA/ClimaAtmos.jl#3522, prompted me to look
again at the `TimeVaryingInputs0D` struct.

This struct is used in two main ways:
- to set site-level forcings/parameters (in ClimaLand)
- to set fields that have constant value on the globe (e.g., CO2)

The previous implementation achieved GPU compatibility by moving
everything to the GPU. This is not a great idea when the operation being
performed is some variation of linear interpolation in one
dimension (time) and for just one data point, as there is nothing really
to be parallelized. This choice was made because initially this feature
was only used in single-site ClimaLand runs, where all we cared about
was to be able to run on GPU. The other day, I realized that I could
have GPU compatibility in a much simpler and more robust way by
leveraging the `fill!` function. With this commit, 0D interpolation (1D
in time, 0D spatially) is changed to be always on the CPU, and the
result is written to the Field (or destination in general) using
`fill!`.

As a result, the CUDA extension is no longer needed.
Sbozzolo added a commit to CliMA/ClimaUtilities.jl that referenced this pull request Jan 21, 2025
Recent PRs in `ClimaCore` and
`ClimaComms` (CliMA/ClimaCore.jl#2114 and
CliMA/ClimaComms.jl#103) changed how contexts
are adapted to GPUs. This, coupled with
CliMA/ClimaAtmos.jl#3522, prompted me to look
again at the `TimeVaryingInputs0D` struct.

This struct is used in two main ways:
- to set site-level forcings/parameters (in ClimaLand)
- to set fields that have constant value on the globe (e.g., CO2)

The previous implementation achieved GPU compatibility by moving
everything to the GPU. This is not a great idea when the operation being
performed is some variation of linear interpolation in one
dimension (time) and for just one data point, as there is nothing really
to be parallelized. This choice was made because initially this feature
was only used in single-site ClimaLand runs, where all we cared about
was to be able to run on GPU. The other day, I realized that I could
have GPU compatibility in a much simpler and more robust way by
leveraging the `fill!` function. With this commit, 0D interpolation (1D
in time, 0D spatially) is changed to be always on the CPU, and the
result is written to the Field (or destination in general) using
`fill!`.

As a result, the CUDA extension is no longer needed.
@Sbozzolo Sbozzolo added this pull request to the merge queue Jan 22, 2025
Merged via the queue into main with commit efd45e1 Jan 22, 2025
19 of 22 checks passed
@Sbozzolo Sbozzolo deleted the gb/co2 branch January 22, 2025 01:17
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.

2 participants