ESCOMP / ESCOMP/CAM-SIMA

{bulk,modal}_aerosol_{properties,state}_mod.F90: spectype matching case sensitivity discussion

Open
#539 0 comments 0 reactions 0 assignees View on GitHub
code clean-up
Dominant language
No language data
Stars
9
Forks
22
Avg merge
8d 5h
Merged PRs (30d)
4

Description

### Issue Type

Code Clean-up

### Issue Description

During the review of #504, @nusbaume wrote:
> Should we apply to_lower to the input species_type variable here? This same question holds for the other case-select and if-statement blocks using species_type below as well.

The original code block that prompted the discussion was
```fortran
wght = 0._r8

call rad_aer_get_info(0, bin_ndx, mode_type=modetype)

select case ( trim(species_type) )
case('dust')
if (modetype=='coarse' .or. modetype=='coarse_dust') then
wght = 1._r8
end if
case('sulfate')
if (modetype=='aitken') then
...
```
in `src/aerosol/modal_aerosol_state_mod.F90`.

@jimmielin wrote:
> I think it's all internally consistent since the call into `%icenuc_size_wght` uses the `spectype` returned from
> ```fortran
> call aero_props%species_type(ibin, ispc, spectype)
> ```
> which in turn gets the string from `phys_prop` and `radiative_aerosol_definitions`, which enumerates everything in lowercase.
>
> I contemplated an alternative fix (not involving an extra to_lower call every time to catch a corner case), which also makes the code more robust, is adding `default` cases to these `select` to `endrun` if the species is unmatched. However, it seems like `wght = 0._r8` returning for an unmatched is intentional since `nucleate_ice` loops over all possible `spectype`s.

In the long run we might want to discuss if we want to do case-insensitive string comparisons for `spectype` and `modetype` or we are satisfied with the robustness as it is now.

Tagging @nusbaume @fvitt

### Will this change answers?

No

### Will you be implementing this yourself?

Any Software Engineer can do this

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading src/aerosol/modal_aerosol_state_mod.F90 and tracing the species_type value through aero_props%species_type, phys_prop, and radiative_aerosol_definitions. Review the related case-select and if-statement blocks, then clarify whether the project wants case-insensitive matching or explicit handling of unmatched species before defining done.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.