Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
22 Views

Select type problems using it in a class allocatable variable

Hi

I'm having problem during compilation process  and I don't understand why ...(from my logic!).

I'm including and example and only you need to do ifort /c example.f90.

I have define a type variable (atlist_type) containing a class vector called atom. It is an allocatable vector. 

In this module, I have a procedure to print the information about this list of atoms (atlas_type). But the information is highly depending of the type of atom when it be called.

The problem appears when I try to use

select type (A%atom)

     type is ....

end select

Why I have a compilation error?

Any suggestion?

Thanks in advance

 

Javier

 

0 Kudos
2 Replies
Highlighted
22 Views

Hi!

I have resolved the problem!

I had to use associate ....Something as

Select type (pp => A%atom)

....

End Select

Incredible! I don't understand why is not possible use directly A%atom.

Thanks in any case.

Javier

0 Kudos
Highlighted
Honored Contributor I
22 Views

.. I don't understand why is not possible use directly A%atom. ..

Refer to Intel Fortran documentation for SELECT TYPE: https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-select-type

Note the Fortran standard extends the facility to users to be able to use SELECT TYPE in the context of dynamic (run-time) polymorphism and this block construct provides the selection "based on the dynamic type of a specified expression."  A Fortran processor can generally achieve this with named variables in code or with expressions.  Toward the second option, Fortran provides the ASSOCIATE construct facility and includes the constraint, "If selector is not a named variable, associate-name => shall appear"  

 

 

0 Kudos