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

calling transform intent(in)== intent(out) #818

Open
hkershaw-brown opened this issue Jan 30, 2025 · 1 comment
Open

calling transform intent(in)== intent(out) #818

hkershaw-brown opened this issue Jan 30, 2025 · 1 comment
Labels
fortran standards compiler issues and (non) standard-compliant code QCEFF quantile conserving filters

Comments

@hkershaw-brown
Copy link
Member

hkershaw-brown commented Jan 30, 2025

this is still dangerous since you have the same input for intent(in) and intent(out), but the original code does that so yippee ki yay I guess.

subroutine transform_from_probit(ens_size, probit_ens, p, state_ens)
integer, intent(in) :: ens_size
real(r8), intent(in) :: probit_ens(ens_size)
type(distribution_params_type), intent(inout) :: p
real(r8), intent(out) :: state_ens(ens_size)

Originally posted by @hkershaw-brown in #794 (comment)

@hkershaw-brown
Copy link
Member Author

nancycollins 3 weeks ago
i see that calling a routine with the same array with both an intent(in) and intent(out) goes several levels deep in this code so it would be pretty disruptive to change it. but in the future i'd avoid passing in the same array multiple times with different intents. it's leaving a trap for future code maintainers because someone looking only at the called subroutines could decide to set the outgoing state_ens(:) to 0 or MISSING_R8 as an initial value for debugging, which would result in the probit_ens(:) mysteriously getting overwritten without any protection from the intent(in). you're requiring some behavior in the called subroutine because of how the calling code is written.

Member
@hkershaw-brown hkershaw-brown 3 weeks ago
I don't think it is standard conforming to alias in this way so not just people changing the code, its undefined what the compiler will do.

@hkershaw-brown hkershaw-brown added fortran standards compiler issues and (non) standard-compliant code QCEFF quantile conserving filters labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fortran standards compiler issues and (non) standard-compliant code QCEFF quantile conserving filters
Projects
None yet
Development

No branches or pull requests

1 participant