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

Offline driver initialisation refactor continued #472

Merged
merged 9 commits into from
Nov 25, 2024

Conversation

SeanBryan51
Copy link
Collaborator

@SeanBryan51 SeanBryan51 commented Nov 12, 2024

This change further consolidates the initialisation logic within the offline drivers to remove code duplication and improve code clarity across each of the drivers (see #425, #440 and #469).

As part of the refactoring changes, new optional namelist options (filename%new_sumbal and filename%trunk_sumbal) are introduced to replace hard coded filenames and optional namelist option CASAonly is restored for consistency with the documentation.

Type of change

  • Code refactor
  • New feature
  • New or updated documentation

Checklist

  • The new content is accessible and located in the appropriate section.
  • I have checked that links are valid and point to the intended content.
  • I have checked my code/text and corrected any misspellings

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

@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch 3 times, most recently from 8869691 to 03fc10d Compare November 15, 2024 02:37
@SeanBryan51
Copy link
Collaborator Author

Note: testing with cable_user%consistency_check = .TRUE. produces the expected behaviour.

@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch from 96bf22c to b38ae68 Compare November 18, 2024 04:49
@micaeljtoliveira
Copy link
Contributor

@SeanBryan51 Overall looks quite good! Very nice to see the code becoming simpler and easier to understand.

I'm afraid I had forgotten to merge #469, but that's now done. Would you mind rebasing your branch onto main so that it's a bit easier to review the detailed changes?

@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch 2 times, most recently from 93bad75 to e402038 Compare November 20, 2024 00:31
@SeanBryan51
Copy link
Collaborator Author

@micaeljtoliveira rebased off main

@micaeljtoliveira
Copy link
Contributor

@SeanBryan51 Thanks for rebasing. Not much else to say at this point, all looks quite good :)

Are you planning on doing more changes in this PR?

@SeanBryan51
Copy link
Collaborator Author

@micaeljtoliveira I have a couple small commits coming which refactor the initialisation of LALLOC and NRRRR variables in the driver. Once those are in and I've cleaned up the code, the PR should be in its final state to be merged.

@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch 2 times, most recently from 893d692 to 6a12e9d Compare November 21, 2024 04:52
@SeanBryan51 SeanBryan51 marked this pull request as ready for review November 21, 2024 05:53
@SeanBryan51
Copy link
Collaborator Author

@micaeljtoliveira no more changes from this point - ready for review

@SeanBryan51 SeanBryan51 requested a review from ccarouge November 21, 2024 05:56
@SeanBryan51
Copy link
Collaborator Author

I've tested these changes with benchcab run and bitwise comparison checks pass:

PBS log file:

2024-11-21 17:30:41,779 - INFO - benchcab.benchcab.py:380 - Running comparison tasks...
2024-11-21 17:30:41,808 - INFO - benchcab.benchcab.py:381 - tasks: 168 (models: 2, sites: 42, science configurations: 4)
2024-11-21 17:33:35,109 - INFO - benchcab.benchcab.py:391 - 0 failed, 168 passed

Benchcab version: 4.2.0

config.yaml:

realisations:
  - repo:
      git:
        branch: main
  - repo:
      git:
        branch: 425-offline-driver-initialisation-refactor-part-2

modules: [
  intel-compiler/2021.1.1,
  netcdf/4.7.4,
  openmpi/4.1.0
]

Spatial (MPI) runs all execute as expected (note outputs do not reproduce as per issue #463).

@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch from 6a12e9d to 6c0c386 Compare November 21, 2024 23:51
Copy link
Member

@ccarouge ccarouge left a comment

Choose a reason for hiding this comment

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

All good. A suggestion to improve the text for the documentation.

Comment on lines +168 to +172
l_casacnp = icycle > 0

IF (l_casacnp .AND. (icycle == 0 .OR. icycle > 3)) THEN
STOP 'icycle must be 1 to 3 when using casaCNP'
END IF
Copy link
Member

Choose a reason for hiding this comment

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

This block is highly dependent on the previous block copied below:

    IF (icycle > CASAONLY_ICYCLE_MIN) THEN
      icycle                     = icycle - CASAONLY_ICYCLE_MIN
      CASAONLY                   = .TRUE.
      CABLE_USER%CASA_DUMP_READ  = .TRUE.
      CABLE_USER%CASA_DUMP_WRITE = .FALSE.

happening so that if icycle=12 in the namelist for example, it still works and doesn't error.

But you are quite right that this l_casacnp and icycle stuff need a rethink.

documentation/docs/user_guide/inputs/cable_nml.md Outdated Show resolved Hide resolved
Add new namelist options: filename%new_sumbal filename%trunk_sumbal
The NEWUNIT specifier is introduced to remove magic numbers used for
file units.
The optional namelist parameter `CASAonly` is restored for consistency
with the documentation.
Note LALLOC is not added as a namelist switch for this change as this
should be acompanied with a description of the behaviour of LALLOC
(which I am not familiar with). However, LALLOC is declared as a module
variable so that it can be easily added as a namelist switch.
@SeanBryan51 SeanBryan51 force-pushed the 425-offline-driver-initialisation-refactor-part-2 branch from 6c0c386 to 7511139 Compare November 25, 2024 21:27
@SeanBryan51 SeanBryan51 merged commit 3e87bc3 into main Nov 25, 2024
7 checks passed
@SeanBryan51 SeanBryan51 deleted the 425-offline-driver-initialisation-refactor-part-2 branch November 25, 2024 22:18
SeanBryan51 added a commit that referenced this pull request Nov 29, 2024
…#498)

This change further consolidates the initialisation logic within the
offline drivers (in particular logic related to `cable_user%MetType`) to
remove code duplication and improve code clarity across each of the
drivers (see #425, #440, #469 and #472).

As part of the refactoring changes, the `cable_user%MetType = 'gpgs'`
namelist parameter is deprecated as it is equivalent to setting
`cable_user%MetType = 'gswp'` and `leaps = .TRUE.`.

## Type of change

- [x] Code refactor
- [x] New or updated documentation

## Checklist

- [x] The new content is accessible and located in the appropriate
section.
- [x] I have checked that links are valid and point to the intended
content.
- [x] I have checked my code/text and corrected any misspellings


<!-- readthedocs-preview cable start -->
----
📚 Documentation preview 📚:
https://cable--498.org.readthedocs.build/en/498/

<!-- readthedocs-preview cable end -->
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.

3 participants