Skip to content

Conversation

juliasloan25
Copy link
Member

@juliasloan25 juliasloan25 commented Apr 25, 2025

Purpose

This PR does 2 things which depend on each other:

  • compute q_sfc from atmosphere state and surface temperature, rather than sometimes computing and sometimes storing/retrieving in surface model cache
  • simplifies the initial component model exchange, and reorders the step! function to align with it

tested longruns pipeline here
compare to previous longrun build here
Most of the longruns fail in both cases, but we see that GPU AMIP FINE: new target amip: topo reaches OOM shortly after day 20 in both cases, and GPU AMIP FINE: new target amip: topo + diagedmf is stable past 34 weeks 4 days in both cases.

closes #331

Content

  • add a function to compute q_sfc from the atmosphere thermo properties and surface temperature
  • simplify initial component model exchange (don't need a step to compute bucket q anymore; call radiation callback directly instead of reinit!)
  • reorder step! to align with initial exchange
  • remove surface model get_field(_, Val(:surface_humidity)) functions

Next steps (to be done in #1293)

  • store atmos T, q, rho in coupler fields so we can easily remap them
  • store surface T, q in coupler fields; compute rho as needed
  • remove surface_thermo_state function
  • create atmosphere, surface thermo states from the respective T, q, rho when computing fluxes

  • I have read and checked the items on the review checklist.

Copy link

coderabbitai bot commented Apr 25, 2025

Walkthrough

This change adds compute_surface_humidity! in FieldExchanger to explicitly compute surface humidity from atmospheric state and surface temperature. FluxCalculator.surface_thermo_state now takes an atmospheric simulation object and uses this function to compute q_sfc freshly during flux calculations. Multiple Interfacer.get_field methods for :surface_humidity are removed across various simulation types and interfaces. The CoupledSimulation initialization and stepping logic is reorganized to include a radiation flux step and reorder updates, removing redundant calls. Plotting functions and tests are updated to no longer reference :surface_humidity as a directly accessible field. Public API changes are limited to internal function argument updates.

Possibly related PRs


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@juliasloan25 juliasloan25 force-pushed the js/simplify-init-exchange branch from 1360f58 to 050a82c Compare April 25, 2025 18:37
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5604284 and 050a82c.

📒 Files selected for processing (4)
  • experiments/ClimaEarth/components/atmosphere/climaatmos.jl (2 hunks)
  • experiments/ClimaEarth/components/land/climaland_bucket.jl (1 hunks)
  • src/FluxCalculator.jl (3 hunks)
  • test/flux_calculator_tests.jl (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • experiments/ClimaEarth/components/land/climaland_bucket.jl
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: test (1.11)
  • GitHub Check: test (1.10)
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: docbuild
🔇 Additional comments (8)
src/FluxCalculator.jl (3)

130-141: Updated function signature for consistency with new surface humidity computation approach.

The function now accepts an atmospheric simulation object instead of a thermodynamic state, matching the PR's goal of consistently computing surface humidity from atmospheric state.


143-156: Improved field type and density calculation implementation.

Now retrieving element type from integrator and computing surface air density by fetching the thermodynamic state through the interface rather than using a passed parameter. This centralizes state retrieval and follows a more consistent pattern.


312-312: Updated call signature to pass atmospheric simulation instead of thermodynamic state.

This update properly aligns with the function signature change made earlier.

test/flux_calculator_tests.jl (3)

77-91: Updated TestOcean surface_thermo_state signature for consistency.

The function now correctly accepts an atmospheric simulation and retrieves the thermodynamic state from it, matching the changes in the main implementation.


111-122: Updated DummySurfaceSimulation3 implementation to use atmos_sim parameter.

Keeps the implementation consistent with the interface changes.


210-210: Updated function call to use new signature.

Fixed the call site to correctly pass the atmospheric simulation.

experiments/ClimaEarth/components/atmosphere/climaatmos.jl (2)

218-218: Improved zero initialization to match target shape.

Changed from a static vector to a zeros array matching the shape of the target field, which is more appropriate.


273-274: Enhanced specific_humidity calculation and added air_density getter.

The specific humidity calculation now directly uses the moisture model's ρq_tot and divides by air density instead of using cached fields. The new air_density getter provides explicit access to this field, supporting the PR's goal of making surface humidity computation more consistent.

Copy link
Member

@Sbozzolo Sbozzolo left a comment

Choose a reason for hiding this comment

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

Can you also add a NEWS entry?

@juliasloan25 juliasloan25 force-pushed the js/simplify-init-exchange branch from 3b1df0e to abe42bf Compare April 25, 2025 21:25
@juliasloan25 juliasloan25 force-pushed the js/simplify-init-exchange branch 2 times, most recently from ab0c060 to 3abcfe8 Compare April 30, 2025 04:46
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
NEWS.md (1)

11-12: Nitpick: wrap long lines. Lines 11–12 exceed the recommended 78-character limit. Consider breaking them into shorter lines for better readability in plain-text contexts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab0c060 and 3abcfe8.

📒 Files selected for processing (16)
  • NEWS.md (1 hunks)
  • config/ci_configs/amip_target_topo_diagedmf_shortrun.yml (1 hunks)
  • docs/src/interfacer.md (0 hunks)
  • experiments/ClimaEarth/components/atmosphere/climaatmos.jl (2 hunks)
  • experiments/ClimaEarth/components/land/climaland_bucket.jl (1 hunks)
  • experiments/ClimaEarth/components/ocean/prescr_seaice.jl (0 hunks)
  • experiments/ClimaEarth/components/ocean/slab_ocean.jl (0 hunks)
  • experiments/ClimaEarth/setup_run.jl (2 hunks)
  • experiments/ClimaEarth/user_io/debug_plots.jl (2 hunks)
  • src/FieldExchanger.jl (2 hunks)
  • src/FluxCalculator.jl (4 hunks)
  • src/Interfacer.jl (0 hunks)
  • src/surface_stub.jl (0 hunks)
  • test/field_exchanger_tests.jl (0 hunks)
  • test/flux_calculator_tests.jl (4 hunks)
  • test/interfacer_tests.jl (0 hunks)
💤 Files with no reviewable changes (7)
  • test/interfacer_tests.jl
  • experiments/ClimaEarth/components/ocean/prescr_seaice.jl
  • src/surface_stub.jl
  • docs/src/interfacer.md
  • test/field_exchanger_tests.jl
  • experiments/ClimaEarth/components/ocean/slab_ocean.jl
  • src/Interfacer.jl
🚧 Files skipped from review as they are similar to previous changes (8)
  • config/ci_configs/amip_target_topo_diagedmf_shortrun.yml
  • src/FluxCalculator.jl
  • experiments/ClimaEarth/setup_run.jl
  • experiments/ClimaEarth/user_io/debug_plots.jl
  • src/FieldExchanger.jl
  • experiments/ClimaEarth/components/land/climaland_bucket.jl
  • experiments/ClimaEarth/components/atmosphere/climaatmos.jl
  • test/flux_calculator_tests.jl
🧰 Additional context used
📓 Path-based instructions (1)
`*`: # CodeRabbit Style Guide (CliMA Inspired)

Leverage CodeRabbit for code reviews aligning with CliMA's practices.

I. Key Areas for CodeRabbit:

  • Style: Naming (Titl...

*: # CodeRabbit Style Guide (CliMA Inspired)

Leverage CodeRabbit for code reviews aligning with CliMA's practices.

I. Key Areas for CodeRabbit:

  • Style: Naming (TitleCase, lowercase_with_underscores), line length (<78), indentation (4 spaces), import order.
  • DRY: Flag duplicated code; encourage modularization.
  • Docstrings: Flag missing docstrings for modules, structs, functions.
  • Tests: Detect missing unit tests (if configured).
  • Complexity: Report on cyclomatic complexity.

II. Conventions (CodeRabbit Can Help):

  • Naming: Follow CliMA/CMIP conventions. Avoid l, O, I as single-char vars.
  • Unicode: Human review needed. Acceptable chars.

III. Documentation (CodeRabbit Flags Deficiencies):

  • Docstrings: Describe purpose, inputs, outputs, examples.

IV. Testing (CodeRabbit: Missing Tests):

  • Unit tests required for new/modified code.

V. CodeRabbit Config:

  • .coderabbit.yaml: Customize language, line length, tests.

VI. Workflow:

  • Review CodeRabbit's suggestions; investigate, provide context, address issues, improve config.

VII. Abandoned Code: Delete or clearly mark as deprecated.

VIII. Reviewer Responsibilities: Ensure adherence to best practices.

  • NEWS.md
🪛 markdownlint-cli2 (0.17.2)
NEWS.md

9-9: Heading style
Expected: setext; Actual: atx

(MD003, heading-style)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - macOS-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: ci 1.10 - macOS-latest
  • GitHub Check: test (1.11)
  • GitHub Check: docbuild
  • GitHub Check: test (1.10)
  • GitHub Check: ci 1.10 - ubuntu-latest
🔇 Additional comments (1)
NEWS.md (1)

9-15: Release note for PR#1305 is clear and correct. The new entry accurately summarizes the consistent computation of surface humidity from atmosphere state and surface temperature, and notes the removal of the initial step! and reinit! calls.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

9-9: Heading style
Expected: setext; Actual: atx

(MD003, heading-style)

@juliasloan25 juliasloan25 force-pushed the js/simplify-init-exchange branch from 3abcfe8 to 35e583a Compare April 30, 2025 06:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
NEWS.md (1)

9-15: Update documentation and ensure clarity

  • The entry notes removal of reinit!, but doesn’t mention that all Interfacer.get_field(_, Val(:surface_humidity)) methods were removed—consider adding a brief line to capture this code change.
  • Static analysis (MD003) flagged an inconsistent heading style here. If the mix of setext and atx is intentional, you can disable the rule for this block:
<!-- markdownlint-disable MD003 -->
#### Simplify initial component model exchange. PR[#1305](https://github.com/CliMA/ClimaCoupler.jl/pull/1305)
<!-- markdownlint-enable MD003 -->
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

9-9: Heading style
Expected: setext; Actual: atx

(MD003, heading-style)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3abcfe8 and 35e583a.

📒 Files selected for processing (16)
  • NEWS.md (1 hunks)
  • config/ci_configs/amip_target_topo_diagedmf_shortrun.yml (1 hunks)
  • docs/src/interfacer.md (0 hunks)
  • experiments/ClimaEarth/components/atmosphere/climaatmos.jl (2 hunks)
  • experiments/ClimaEarth/components/land/climaland_bucket.jl (1 hunks)
  • experiments/ClimaEarth/components/ocean/prescr_seaice.jl (0 hunks)
  • experiments/ClimaEarth/components/ocean/slab_ocean.jl (0 hunks)
  • experiments/ClimaEarth/setup_run.jl (2 hunks)
  • experiments/ClimaEarth/user_io/debug_plots.jl (2 hunks)
  • src/FieldExchanger.jl (2 hunks)
  • src/FluxCalculator.jl (4 hunks)
  • src/Interfacer.jl (0 hunks)
  • src/surface_stub.jl (0 hunks)
  • test/field_exchanger_tests.jl (0 hunks)
  • test/flux_calculator_tests.jl (4 hunks)
  • test/interfacer_tests.jl (0 hunks)
💤 Files with no reviewable changes (7)
  • test/interfacer_tests.jl
  • experiments/ClimaEarth/components/ocean/prescr_seaice.jl
  • src/Interfacer.jl
  • experiments/ClimaEarth/components/ocean/slab_ocean.jl
  • test/field_exchanger_tests.jl
  • src/surface_stub.jl
  • docs/src/interfacer.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • config/ci_configs/amip_target_topo_diagedmf_shortrun.yml
  • src/FieldExchanger.jl
  • experiments/ClimaEarth/user_io/debug_plots.jl
  • test/flux_calculator_tests.jl
  • src/FluxCalculator.jl
  • experiments/ClimaEarth/setup_run.jl
  • experiments/ClimaEarth/components/atmosphere/climaatmos.jl
  • experiments/ClimaEarth/components/land/climaland_bucket.jl
🧰 Additional context used
📓 Path-based instructions (1)
`*`: # CodeRabbit Style Guide (CliMA Inspired)

Leverage CodeRabbit for code reviews aligning with CliMA's practices.

I. Key Areas for CodeRabbit:

  • Style: Naming (Titl...

*: # CodeRabbit Style Guide (CliMA Inspired)

Leverage CodeRabbit for code reviews aligning with CliMA's practices.

I. Key Areas for CodeRabbit:

  • Style: Naming (TitleCase, lowercase_with_underscores), line length (<78), indentation (4 spaces), import order.
  • DRY: Flag duplicated code; encourage modularization.
  • Docstrings: Flag missing docstrings for modules, structs, functions.
  • Tests: Detect missing unit tests (if configured).
  • Complexity: Report on cyclomatic complexity.

II. Conventions (CodeRabbit Can Help):

  • Naming: Follow CliMA/CMIP conventions. Avoid l, O, I as single-char vars.
  • Unicode: Human review needed. Acceptable chars.

III. Documentation (CodeRabbit Flags Deficiencies):

  • Docstrings: Describe purpose, inputs, outputs, examples.

IV. Testing (CodeRabbit: Missing Tests):

  • Unit tests required for new/modified code.

V. CodeRabbit Config:

  • .coderabbit.yaml: Customize language, line length, tests.

VI. Workflow:

  • Review CodeRabbit's suggestions; investigate, provide context, address issues, improve config.

VII. Abandoned Code: Delete or clearly mark as deprecated.

VIII. Reviewer Responsibilities: Ensure adherence to best practices.

  • NEWS.md
🪛 markdownlint-cli2 (0.17.2)
NEWS.md

9-9: Heading style
Expected: setext; Actual: atx

(MD003, heading-style)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: test (1.11)
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: test (1.10)

@Sbozzolo
Copy link
Member

I guess we can also remove reinit once this is merged

@juliasloan25
Copy link
Member Author

This PR is behavior changing, but the longrun stability hasn't worsened, and the plots in regular CI look comparable to main, so I'll go ahead and merge

@juliasloan25 juliasloan25 merged commit 4a52d71 into main Apr 30, 2025
13 of 14 checks passed
@juliasloan25 juliasloan25 deleted the js/simplify-init-exchange branch April 30, 2025 17:31
@juliasloan25 juliasloan25 mentioned this pull request Apr 30, 2025
@juliasloan25
Copy link
Member Author

I guess we can also remove reinit once this is merged

Good point, I opened #1317 for that

@coderabbitai coderabbitai bot mentioned this pull request Apr 30, 2025
Sbozzolo added a commit that referenced this pull request May 1, 2025
Closes #1317

This was made unncessary by #1305
@Sbozzolo Sbozzolo mentioned this pull request May 1, 2025
Sbozzolo added a commit that referenced this pull request May 1, 2025
Closes #1317

This was made unncessary by #1305
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.

simplify initial component model exchange
2 participants