Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Who can help this Fortran problem.

coolhow
Beginner
475 Views

I have a problem in my programing in Fortran:

First there are some variable pairs like: (a, aa) (b, bb) (c, cc)

and they have a relation like:

a=f(aa)

b=f(bb)

c=f(cc)

The question is: I have a large number of this variable pairs, so I do not want to write this every time.

Can Ihave somethinglike a name group: a, b, c-> group1

aa, bb, cc-> group2

then I only need to write:

group1=f(group2)

Thanks.

0 Kudos
2 Replies
chip_ray1
Beginner
475 Views

I think I would just have an array of pairs:

type Pair
integer :: x
integer :: y
end type Pair
type(Pair), dimension (1:number_of_pairs) :: pairs
!you would put all the pairs in the array somehow
!effectively putting them in a "group"
pairs(1)%x = a
pairs(1)%y = aa
etc...
do i=1, number_of_pairs
pairs(i)%x = f(pairs(i)%y)

Forgive me if they syntax isn't perfect, I'm very new to fortran

Chip

0 Kudos
coolhow
Beginner
475 Views

No, it's not so simple, because the variables a,b,c are variables used someplaceelse, and theyactualyare allocated arries with different shapes. The point is:these variableshave different names, but they all have very similar operation in someplace, (eg. deallocate them all), and I do not want to write every name of them, if they can be included in a name group and be treated together, that will be nice.

0 Kudos
Reply