Skip to content

CABLE Library for AM3/ACCESS3#724

Open
Whyborn wants to merge 84 commits into
mainfrom
make-AM3-library
Open

CABLE Library for AM3/ACCESS3#724
Whyborn wants to merge 84 commits into
mainfrom
make-AM3-library

Conversation

@Whyborn

@Whyborn Whyborn commented May 22, 2026

Copy link
Copy Markdown
Contributor

CABLE

Thank you for submitting a pull request to the CABLE Project.

Description

This builds the library for AM3 and future ACCESS3 applications. It requires a rejig of the original library, taking some files out of the default library and including them only in ESM1.6. The intention was that the library would only be the science code, but this is not possible with the current setup.

A summary of things that the science directory depends on, that extends outside the science directory that I've identified:

  • The biogeophysics derived types are not defined within the science directory, as opposed to the CASA derived types which are defined within the science directory. Each of these have different definitions for each application (offline, ESM1.6, AM3). Logically, there should only be one definition, but I don't think this will happen any time soon. In the mean time, including the type modules in src/coupled/AM3/control/cable/CM3 in the library should be an acceptable solution.
  • The trickier problems are the namelists and surface types handling. These are related issues, as the cable_surface_types_mod module also reads the namelist that sets the CABLE surface types. Do the surface types need to be handled in this way? Is there any foreseeable situation where anyone would not use the standard CABLE PFT indexing? If we remove this, it makes things significantly easier. It also does the extra work of defining a bunch of required JULES variables. I think the best solution is go back to hard-coded CABLE PFT indices, see this JULES PR.

Testing

  • Are the changes bitwise-compatible with the main branch? If working on an optional feature, are the results bitwise-compatible when this feature is off? If yes, copy benchcab output showing successful completion of the bitwise compatibility tests or equivalent results below this line.

📚 Documentation preview 📚: https://cable--724.org.readthedocs.build/en/724/

@Whyborn Whyborn force-pushed the make-AM3-library branch from aaba5ca to 3ef0fed Compare June 24, 2026 01:38
@Whyborn

Whyborn commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

This now, along with JULES PR #346, access-spack-packages PR #455 and UM PR #148 successfully builds AM3 with CABLE as a library and achieves bitwise compatible results.

@Whyborn Whyborn requested a review from ccarouge July 3, 2026 07:05
@ccarouge

ccarouge commented Jul 6, 2026

Copy link
Copy Markdown
Member

@Whyborn Can you please add the benchcab results for bitwise reproducibility?

@ccarouge ccarouge left a comment

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.

A few requests for more explanation and some relatively minor changes.

Comment thread .github/workflows/ci.yml
spack-manifest-data-path: .github/build-ci/data/standard.json
# We need to install the compilers manually here because the upstream image is too large to run on GitHub-hosted runners
spack-compiler-manifest-path: .github/build-ci/compilers/spack.yaml
access-spack-packages-ref: 1d9acf45c39229ff4e90a9aa49922b1169305476

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.

What is this line doing? Why is it needed now and not before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's to make the CI use the correct version of the spack packages. I should get the spack packages PR merged in first, tag it, then refer to that tag here.

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.

Why is this file modified for the library work? I would guess we do not compile this for AM3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was intended to be a bit of future proofing, as Sean's MPI slightly modified the land use change code which was referred to by the AM3 code, even if not yet active. We came up with a better solution in this merged PR. I'll remove this change.

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.

Why are we adding this to science/ when it is only to be used in ESM1.5/1.6? Should the # define ESM15 YES be # define ESM15 NO in the offline repository? Or even, remove that line from the file and deal with it at compilation as usually done for pre-processor flags.

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 why is it part of the AM3 library work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately the land use code had moved in a bit from the form that is in AM3. The JULES src/science_cable/landuse/landuse3.F90 should be the same as src/science/landuse/landuse3, but it isn't, and the coupling code is written based on the JULES version. A few routine signatures have changed, and I was getting type mismatch errors when I tried to quickly fix it.

I should remove the #ifdef and #def. I think it's best to get this in first, then reconcile the differences between the way this routine is called in the coupling and then remove this file.

Comment thread CMakeLists.txt Outdated
Comment on lines 129 to 131
src/science/landuse/landuse3.F90
src/science/landuse/landuse_constant.F90
src/params/cable_phys_constants_mod.F90

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.

Could we put this back in alphabetical order? And with the correct indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, will fix that.

Comment thread CMakeLists.txt
Comment on lines -91 to -99
src/science/casa-cnp/casa_dimension.F90
src/science/casa-cnp/casa_feedback.F90
src/science/casa-cnp/casa_inout.F90
src/science/casa-cnp/casa_param.F90
src/science/casa-cnp/casa_phenology.F90
src/science/casa-cnp/casa_readbiome.F90
src/science/casa-cnp/casa_rplant.F90
src/science/casa-cnp/casa_sumcflux.F90
src/science/casa-cnp/casa_variable.F90

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.

What happens to all these CASA files for the ESM1.6 library? Were they added but are in fact not needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately these are bits that had been rewritten for AM3- the way the derived types are structured is different to offline, see this JULES issue. This is related to the duplicate ALLOCATABLE/POINTER type definitions that I wanted to unify some time back. The AM3 versions of these live in the JULES src/util/casa.

Comment thread CMakeLists.txt
Comment on lines +197 to +203
if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
add_compile_options(-r8 -i8)
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
add_compile_options(-fdefault-real-8 -fdefault-integer-8 -fdefault-double-8)
else()
message(STATUS "Cannot compile library with unknown compiler")
endif()

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.

These are the same options for ESM1.6 and ACCESS3. Are we doubling them in case we want to modify them for ACCESS3? I would prefer to put this block under the if(CABLE_LIBRARY) condition directly and have them appear only once. So that it's clearer the only difference between ESM1.6 and ACCESS3 libraries are the sources.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it makes more sense to declare them separately- it makes it clearer, and there may be instances where the flags are not the same and this preempts that.

@Whyborn

Whyborn commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Benchcab output:

2026-07-09 15:54:21,176 - INFO - benchcab.benchcab.py:391 - 0 failed, 168 passed

@Whyborn Whyborn requested a review from ccarouge July 9, 2026 06:25
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