Skip to content

write.config.RothC() ignores opt_SMDbare (reads opt_RMmoist for both options) #4217

Open

Description

@madhavzanwar

Summary

In models/rothc/R/write.config.RothC.R the bare-soil option is read from the wrong setting:

rmmoist <- settings$model$opt_RMmoist %||% 1
...
smdbare <- settings$model$opt_RMmoist %||% 1   # should be opt_SMDbare

The RothC book page (book_source/03_topical_pages/05_models/rothc.Rmd) and models/rothc/inst/workflow_example/template.xml both name the setting opt_SMDbare. As written, @OPT_SMDBARE@ in the input file always equals the opt_RMmoist value, and <opt_SMDbare> is silently ignored.

Reproduction

Run write.config.RothC() with <opt_RMmoist>1</opt_RMmoist> and <opt_SMDbare>2</opt_SMDbare>: the options line of RothC_input.dat is 1 1 instead of 1 2.

Proposed fix

Read settings$model$opt_SMDbare. I have a branch with a small test (it fails on current develop and passes with the fix); happy to send a PR if wanted.

I noticed model_depth_cm is computed but not passed to read_soil_physics(). There is a TODO: FIXME about soil depth there already, so I have left that alone.

Activity

  1. madhavzanwar commented on Nov 2, 2026

    @madhavzanwar
    ContributorAuthor

    @infotroph a one-word fix plus a test is ready: https://github.com/madhavzanwar/pecan/tree/GH-4217-rothc-opt-smdbare (the test fails on develop and passes with the fix; the RothC suite passes). Happy to open the PR whenever you’d like. I left the soil-depth item alone because of the existing TODO: FIXME.

  2. infotroph commented on Nov 2, 2026

    @infotroph
    Member

    @madhavzanwar Thanks for the report. Yes, PR welcome or I'll make a note to fix this in an upcoming refactor (new features coming, plus fixing how RothC currently expects to find options directly under settings$model rather than in settings$model$options as specified by the PEcAn documentation).

  3. madhavzanwar commented on Nov 3, 2026

    @madhavzanwar
    ContributorAuthor

    2. @madhavzanwar Thanks for the report. Yes, PR welcome or I'll make a note to fix this in an upcoming refactor (new features coming, plus fixing how RothC currently expects to find options directly under settings$model rather than in settings$model$options as specified by the PEcAn documentation).

    Thanks @infotroph! PR is up: #4222. I kept the options directly under settings$model (matching the current code and the example template), so this stays a one-word fix. Happy to follow up on settings$model$options separately if you’d like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions