Skip to content

read land ICs from a file #1318

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

read land ICs from a file #1318

wants to merge 1 commit into from

Conversation

juliasloan25
Copy link
Member

@juliasloan25 juliasloan25 commented Apr 30, 2025

Purpose

Read integrated land initial conditions from file

closes #1289

analogous to CliMA/ClimaLand.jl#1029

To Do

  • add an option to read from IC vs from some default values (e.g. for terraplanet)

Sorry, something went wrong.

Copy link

coderabbitai bot commented Apr 30, 2025

Walkthrough

The changes add a new optional Boolean argument land_spun_up_ic to the ClimaLandSimulation constructor, defaulting to true. When land_spun_up_ic is true, initial conditions for soil and snow states are loaded from external files using ClimaLand.set_snow_initial_conditions! and ClimaLand.set_soil_initial_conditions!. This replaces the previous approach of initializing soil and snow states with hardcoded default values and calculations. Soil CO₂ concentration and canopy hydraulics liquid water content initialization remain unchanged. The new flag is propagated through the command-line interface, configuration parsing, and the coupled simulation setup. Tests were updated to pass this flag explicitly. A comment was added in the surface flux computation code without functional changes. The NEWS file documents the new feature and its usage requirements.

Assessment against linked issues

Objective Addressed Explanation
Use improved initial conditions from file for integrated land (#1289)

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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.

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 (2)
experiments/ClimaEarth/components/land/climaland_integrated.jl (2)

152-154: Add error handling for file path retrieval.

The file path is obtained without error handling. Consider handling potential issues if the file doesn't exist.

-    ic_path = ClimaLand.Artifacts.soil_ic_2008_50m_path()
+    ic_path = try
+        ClimaLand.Artifacts.soil_ic_2008_50m_path()
+    catch e
+        @error "Failed to retrieve soil IC file path: $e"
+        rethrow(e)
+    end

154-156: Consider making the IC file path configurable.

Currently, the initial conditions path is hardcoded. Consider making it a constructor parameter for flexibility.

This would allow users to specify custom initial condition files rather than relying on the default.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8119899 and c9812e5.

📒 Files selected for processing (1)
  • experiments/ClimaEarth/components/land/climaland_integrated.jl (2 hunks)
⏰ 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: ci 1.10 - ubuntu-latest
  • GitHub Check: docbuild
  • GitHub Check: test (1.10)
🔇 Additional comments (2)
experiments/ClimaEarth/components/land/climaland_integrated.jl (2)

146-150: Nicely structured initialization for non-file parameters.

The code clearly separates initialization between hardcoded values and file-loaded values with a helpful comment.


561-561:

❓ Verification inconclusive

Address the TODO comment about snow temperature.

The TODO indicates the snow temperature is 0 at this point. Consider investigating why and whether this is expected behavior.


🏁 Script executed:

#!/bin/bash
# Look for information about snow temperature initialization
rg "set_snow_initial_conditions" -A 10 -B 10

Length of output: 2408


Verify snow temperature initialization

It looks like you’re reading snow and soil initial conditions via ClimaLand.set_snow_initial_conditions! but still see a computed snow temperature of 0 at the TODO. Please investigate:

• In experiments/ClimaEarth/components/land/climaland_integrated.jl (around the TODO at line 561), add a quick check or print of the snow temperature field right after set_snow_initial_conditions! to confirm its values.
• Inspect the IC file at ClimaLand.Artifacts.soil_ic_2008_50m_path() — does it include nonzero snow temperatures?
• Review the implementation of ClimaLand.set_snow_initial_conditions! in the ClimaLand package to ensure it correctly assigns snow temperature.
• If the IC or loader is missing snow-T data, decide whether to supply a default or fall back to canopy surface T.

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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c9812e5 and f0726a5.

📒 Files selected for processing (6)
  • NEWS.md (1 hunks)
  • experiments/ClimaEarth/cli_options.jl (1 hunks)
  • experiments/ClimaEarth/components/land/climaland_integrated.jl (3 hunks)
  • experiments/ClimaEarth/setup_run.jl (2 hunks)
  • experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl (1 hunks)
  • experiments/ClimaEarth/user_io/arg_parsing.jl (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • experiments/ClimaEarth/components/land/climaland_integrated.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
🪛 GitHub Actions: JuliaFormatter
experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl

[error] 66-67: Code formatting change detected in ClimaLandSimulation call. The line was split into multiple lines, causing a diff failure.

🪛 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 (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 (6)
NEWS.md (1)

9-14: New feature documentation looks good.

Clear explanation of the land_spun_up_ic flag and its requirements. Users will understand when to use this feature.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

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

(MD003, heading-style)

experiments/ClimaEarth/cli_options.jl (1)

150-153: CLI option added appropriately.

The land_spun_up_ic flag is well positioned in the ClimaLand-specific section with clear help text.

experiments/ClimaEarth/user_io/arg_parsing.jl (2)

117-119: Good extraction of the land_spun_up_ic parameter.

The parameter is correctly extracted from the config dictionary.


143-146: Parameter ordering in return tuple is logical.

Grouping land model parameters together makes sense - land_spun_up_ic near other land parameters and before the bucket-specific options.

experiments/ClimaEarth/setup_run.jl (2)

128-130: New parameter for land initial conditions added correctly.

The addition of the land_spun_up_ic parameter alongside other land-related parameters is well-placed, maintaining logical code organization.


294-295: Parameter correctly passed to integrated land model.

The new boolean flag is appropriately forwarded to the ClimaLandSimulation constructor, enabling the loading of soil and snow states from external files as described in the PR.

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: Ensure consistent heading style and line length
The new ATX-style heading (#### …) mixes with the file’s existing setext headings and exceeds the 78-character limit. To keep the style uniform and wrap long lines, convert it to setext style:

-#### Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)
+Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)
+-----------------------------------------------
🧰 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 f0726a5 and 961fb20.

📒 Files selected for processing (7)
  • NEWS.md (1 hunks)
  • experiments/ClimaEarth/cli_options.jl (1 hunks)
  • experiments/ClimaEarth/components/land/climaland_integrated.jl (3 hunks)
  • experiments/ClimaEarth/setup_run.jl (2 hunks)
  • experiments/ClimaEarth/test/amip_test.yml (1 hunks)
  • experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl (1 hunks)
  • experiments/ClimaEarth/user_io/arg_parsing.jl (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • experiments/ClimaEarth/test/amip_test.yml
🚧 Files skipped from review as they are similar to previous changes (5)
  • experiments/ClimaEarth/user_io/arg_parsing.jl
  • experiments/ClimaEarth/cli_options.jl
  • experiments/ClimaEarth/setup_run.jl
  • experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl
  • experiments/ClimaEarth/components/land/climaland_integrated.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: ci 1.10 - ubuntu-latest
  • GitHub Check: test (1.11)
  • GitHub Check: docbuild

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: 1

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

9-9: Inconsistent heading style
The top-level title uses Setext style (===== underlining) while this subheading uses ATX (####). For consistency, either switch this and other subheadings to Setext or convert the main title to ATX (e.g. # ClimaCoupler.jl Release Notes).

🧰 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 961fb20 and 9b3e118.

📒 Files selected for processing (7)
  • NEWS.md (1 hunks)
  • experiments/ClimaEarth/cli_options.jl (1 hunks)
  • experiments/ClimaEarth/components/land/climaland_integrated.jl (3 hunks)
  • experiments/ClimaEarth/setup_run.jl (2 hunks)
  • experiments/ClimaEarth/test/amip_test.yml (1 hunks)
  • experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl (1 hunks)
  • experiments/ClimaEarth/user_io/arg_parsing.jl (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • experiments/ClimaEarth/test/amip_test.yml
  • experiments/ClimaEarth/cli_options.jl
  • experiments/ClimaEarth/test/component_model_tests/climaland_tests.jl
  • experiments/ClimaEarth/setup_run.jl
  • experiments/ClimaEarth/user_io/arg_parsing.jl
  • experiments/ClimaEarth/components/land/climaland_integrated.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 (7)
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: ci 1.10 - macOS-latest
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: test (1.11)
  • GitHub Check: docbuild

Comment on lines +9 to +14
#### Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)

Adds a boolean flag `land_spun_up_ic` that allows the user to request reading
integrated land initial conditions from a saved simulation, rather than setting
them with default values. If this option is true, the land/sea mask must be used,
since the spun-up ICs are only defined over land.
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Clarify default behavior and usage
– Hyphenate and pluralize the heading for clarity:

-#### Add option for integrated land spun up IC. PR[#1318](...)
+#### Add option for integrated land spun-up ICs. PR[#1318](...)

– Document the default value (true) and how to disable it, for example:

The land_spun_up_ic flag (default: true) enables reading spun-up ICs from disk. To revert to defaults, pass --land_spun_up_ic=false.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#### Add option for integrated land spun up IC. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)
Adds a boolean flag `land_spun_up_ic` that allows the user to request reading
integrated land initial conditions from a saved simulation, rather than setting
them with default values. If this option is true, the land/sea mask must be used,
since the spun-up ICs are only defined over land.
#### Add option for integrated land spun-up ICs. PR[#1318](https://github.com/CliMA/ClimaCoupler.jl/pull/1318)
Adds a boolean flag `land_spun_up_ic` that allows the user to request reading
integrated land initial conditions from a saved simulation, rather than setting
them with default values. If this option is true, the land/sea mask must be used,
since the spun-up ICs are only defined over land.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

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

(MD003, heading-style)

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.

use improved IC for integrated land
1 participant