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

newunit specifier for opening files #455

Open
SeanBryan51 opened this issue Oct 31, 2024 · 8 comments
Open

newunit specifier for opening files #455

SeanBryan51 opened this issue Oct 31, 2024 · 8 comments

Comments

@SeanBryan51
Copy link
Collaborator

SeanBryan51 commented Oct 31, 2024

Maybe a good place to start introducing the newunit specifier?

OPEN(10, FILE=CABLE_NAMELIST, STATUS="OLD", ACTION="READ")
READ(10, NML=CABLE)
CLOSE(10)

Suggestion:

    OPEN(newunit=unit, FILE=CABLE_NAMELIST, STATUS="OLD", ACTION="READ")
    READ(unit, NML=CABLE)
    CLOSE(unit)

with unit being an integer to be declared above.

This is safer and easier to read (here, 10 is a magic number)

Originally posted by @micaeljtoliveira in #440 (comment)

@SeanBryan51
Copy link
Collaborator Author

@Whyborn may be relevant for #438?

@micaeljtoliveira
Copy link
Contributor

This is definitely F2008, so might not be acceptable, given the current coding standards.

@Whyborn
Copy link

Whyborn commented Oct 31, 2024

Yea I think it's a good idea to help bring CABLE into the 2010s, although I don't think it's that relevant to that PR. Could extend the scope of the PR to being a modernisation of reading namelists.

@Whyborn
Copy link

Whyborn commented Oct 31, 2024

I don't think we're meeting any standards at the moment, so I wouldn't worry about it being a F2008 addition.

@micaeljtoliveira
Copy link
Contributor

@ccarouge mentioned that we need to follow the JULES standards, and those say Fortran 95/2003 only 😢

@Whyborn
Copy link

Whyborn commented Nov 1, 2024

Are you sure? This conflicts with conversations we had in slack yesterday, where the LFRic Coding Standards were the standards we wanted to follow. Based off the comments and the crosstable linked in this forum post, I thought we came to the conclusion that standards/features up to F2008 were allowable.

@micaeljtoliveira
Copy link
Contributor

Okay, chatted with @ccarouge and LFRIc standards are the way to go 🎉

@Whyborn
Copy link

Whyborn commented Nov 4, 2024

I have made a start on this issue, including the NEWUNIT specifier for all namelist OPEN instances as part of improving namelist error handling #438. I can extend this to all occurrences where we open a new non-netCDF file? A bit out of scope of the original PR, but might be worth making these changes all in one go

Whyborn added a commit that referenced this issue Nov 25, 2024
# CABLE

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

## Description

Extend the use of the ```NEWUNIT=``` specifier for acquiring io units to
the rest of the active ```OPEN``` calls in the code. There is one
exception, in the calls found within
```core/biogeophys/cable_diag.F90```. The units are handled a bit
strangely here, with one being defined dependent on the other. Looks
like it might interact with the UM coupling in a specific way, so I've
left it as is at the moment.

Fixes #455 

## Type of change

- Fortran standards update

## 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
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

No branches or pull requests

3 participants