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

Extending associate construct to improve readability in object oriented contexts #319

Open
francescosalvadore opened this issue Oct 31, 2023 · 1 comment

Comments

@francescosalvadore
Copy link

Extending associate construct for object oriented contexts would be very useful for readability and development in my opinion.

Instead of writing something like this:

associate(nx => self%nx, ny => self%ny, nz => self%nz, ng => self%ng, &
          dcsidx_gpu => self%base_gpu%dcsidx_gpu, detady_gpu => self%base_gpu%detady_gpu,   &
          dzitdz_gpu => self%base_gpu%dzitdz_gpu, dcsidxs_gpu => self%base_gpu%dcsidxs_gpu, &
          detadys_gpu => self%base_gpu%detadys_gpu, dzitdzs_gpu => self%base_gpu%dzitdzs_gpu, &
          indx_cp_l => self%equation_base%indx_cp_l, &
          indx_cp_r => self%equation_base%indx_cp_r, &
          cp => self%equation_base%calorically_perfect, &
          t0 => self%equation_base%t0, channel_case => self%equation_base%channel_case, &
          enable_ibm => self%equation_base%enable_ibm)

I would like to write:

associate(from self: nx, ny, nz, ng; &
          from self%base_gpu: dcsidx_gpu, detady_gpu, dzitdz_gpu, dcsidxs_gpu, detadys_gpu, dzitdzs_gpu; &
          from self%equation_base: indx_cp_l, indx_cp_r, cp => calorically_perfect, t0, enable_ibm)

Francesco

@PierUgit
Copy link
Contributor

PierUgit commented Dec 3, 2023

This use case is very similar to the one of the Pascal with statement.

To be even more compact, it could have a "all" specifier, saying the all the components shall be associated:

associate (from self:(all); from self%base_gpu:(all); from self%equation_base:(all))

To go further, it could be combined with #321 :

associate (from self:(all)) &
          (from base_gpu:(all); from equation_base:(all)) &
          (cp => calorically_perfect)

Additionnaly, a suffix specifier could solve the case where one wants to do that with several objects of the same type:

associate (from object1:(all); from object2:(all,suffix="2"))

would be equivalent to

associate (nx => object1%nx, [...,] nx2 => object2%nx )

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

2 participants