ESCOMP / ESCOMP/CTSM

[Low priority] Clean up associate-names

Open
#3,726 0 comments 0 reactions 0 assignees View on GitHub
code health priority: low size: large
Dominant language
Fortran
Stars
352
Forks
361
Avg merge
6d 6h
Merged PRs (30d)
8

Description

There are many `associate` statements in our code:

```fortran
associate( &
var1 => class1%var1, &
var2 => class2%var2_grc, &
var3 => class3%var3_lun, &
var5 => class5%var5_col, &
var6 => class6%var6_patch &
)
```

The thing to the left of `=>` is the "associate-name," and the thing to the right is the "selector."

It'd be for us to be as consistent as reasonably possible in how we set our associate-names. The rule I'm imagining is, "The associate-name should be identical to the last word of the selector, optionally excluding certain suffixes." So all of the above would be fine, but, e.g.:
```fortran
associate( &
ag => photosyns_inst%ag_phs_patch &
)
```
wouldn't be: the associate-name would need to be either `ag_phs_patch` or `ag_phs`.

There are also many places where we add a `13` or `14` suffix to the associate-name to indicate which C isotope object is being accessed, which I think is also fine, as long as it's actually necessary. E.g., this would be okay if both are needed:
```fortran
associate( &
matrix_Cinput13 => c13_soilbiogeochem_carbonflux_inst%matrix_Cinput, &
matrix_Cinput14 => c14_soilbiogeochem_carbonflux_inst%matrix_Cinput &
)
```

I don't think I care whether the case matches, since Fortran is case-insensitive anyway.

[Here](https://gist.github.com/samsrabin/5c87f571baf006f232c9c133c33aa4a1) is a Python script that I think gets us close to identifying the problematic `associate`s. It searches all .F90 files in `src/` excluding `src/fates/`. Note that it just looks for lines with `=>`, so it will hit on pointer assignments too. However, it only includes selectors with a `%`, so it's probably conservative.

The last line of each "paragraph" is what you can paste into VSCode's search, with regex on, to find matches. E.g.:
```
m: a10tmin=>temperature_inst%t_a10min_patch
w1b: a10tmin
w2b: t_a10min
\ba10tmin\b\s*=>.*t_a10min_patch\b
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.