Skip to content

Allow for Variable expressions in Select Case #250

@Soulagenda

Description

@Soulagenda

Because I tried to do this and it didn't work, so I am making a request for it to work. I think it would be nice if it worked.
It went something like this


Integer :: iVar
Integer, Allocatable :: VA, VB, VC, VD(:), VE, VF, VG, VH, VI, VJ !They all will have a unique value
Real, Allocatable :: VarArray(:)

DoConcurrent (iVar:1, NVar)
Select Case (iVar)
Case (VA, VB, VD, VE)
...instruction1
Case (VG, VH)
.....instruction2
Case Default
End Select
End do


I am about to make myself dizzy attempting to create logic with if statements along with checking allocations and whatever else I'll have to do to make it work.
It would be nice for variables to be allowed in the Case() and those that are not allocated can be automatically ignored. I would use it for unique integers but in case some have equal value, select case will just choose the first case that has a match. For example, if iVar=VB=VG then the code will execute instructions for VB.
Though this may result in some unintended consequences in code behavior for developers who may not be initially careful in ensuring uniqueness of variable values or properly tracking allocations. Such potential mishaps can be highlighted with warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Clause 11Standard Clause 11: Execution control

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions