Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Intel Customer Support will be observing the Martin Luther King holiday on Monday, Jan. 17, and will return on Tues. Jan. 18.
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

Select type problems using it in a class allocatable variable

Javier_Gonzalez-plat
103 Views

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
Javier_Gonzalez-plat
103 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

FortranFan
Honored Contributor II
103 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"  

 

 

Reply