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

Use allocatable arrays in predictive_mixing #581

Open
evbauer opened this issue Aug 22, 2023 · 2 comments
Open

Use allocatable arrays in predictive_mixing #581

evbauer opened this issue Aug 22, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@evbauer
Copy link
Member

evbauer commented Aug 22, 2023

On the distillation branch, Rob pointed out to me that there's a risk of stack overflow when using explicit shape automatic arrays, for example to declare an extra array for saving the composition in case it needs to be reset. (See discussion at a31cb38#r117329563.)

This was a construction I had copied over from predictive mixing, which makes even more extensive use of such automatic arrays:

real(dp) :: lnd_save(s%nz)
real(dp) :: Cp_save(s%nz)
real(dp) :: Cv_save(s%nz)
real(dp) :: gamma1_save(s%nz)
real(dp) :: grada_save(s%nz)
real(dp) :: chiRho_save(s%nz)
real(dp) :: chiT_save(s%nz)
real(dp) :: lnfree_e_save(s%nz)
real(dp) :: d_eos_dlnd_save(num_eos_basic_results,s%nz)
real(dp) :: d_eos_dlnT_save(num_eos_basic_results,s%nz)
real(dp) :: xa_save(s%species,s%nz)
real(dp) :: zbar_save(s%nz)
integer :: k
real(dp) :: w
real(dp) :: rho_face_save(s%nz)
integer :: op_err
logical :: make_gradr_sticky_in_solver_iters

@rhdtownsend do you think it would be worthwhile to refactor this code to use something more like the saved_data construction with allocatable arrays like in conv_premix?

@evbauer evbauer added the enhancement New feature or request label Aug 22, 2023
@warrickball
Copy link
Contributor

warrickball commented Sep 14, 2023

Does it help, though? Are we not just delaying the inevitable until there's an assignment of allocate statement? Or does an array being allocatable mean that only parts of it will go on the stack when needed (in which case I agree with using allocatable arrays)? I do find the explicit shapes help readability, though that can also be achieved in a comment.

@rhdtownsend
Copy link
Contributor

rhdtownsend commented Sep 14, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants