Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Allocating using CLASS(*) as MOLD

$
0
0

Hello there!

Is there any smart and elegant way to allocate a variable to have the same dimensions as polymorphic class?

Example:

SUBROUTINE Allocate_Thing(icls,ocls)
  CLASS(*), DIMENSION(:,:), INTENT(IN) :: icls
  INTEGER,  DIMENSION(:,:), POINTER    :: ocls

  ALLOCATE(ocls, MOLD=icls)
  (...)
END SUBROUTINE

The above snippet doesn't work, obviously, because MOLD does not take polymorphic classes as argument. In this particular case I could use ALLOCATE(ocls(SIZE(icls,1), SIZE(icls,2))), but I would like to have a generic expression, if there is any trick to do so. The reason is that I'm using preprocessor tricks to get this done for many ranks.

Also, when is it planned for Intel Fortran to support assumed rank polymorphic classes?

Thanks in advance!


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>