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

ASSOCIATE within Module

jimdempseyatthecove
Honored Contributor III
490 Views
This may be a feature request (or it may work now - haven't tried it).

Often in converting a legacy program from using COMMON blocks to using MODULES, it is often desirable to add flexability by using user defined types, pointers and allocatable arrays. The new data layout is contained within Modules. The legacy code, formerly using COMMONs now needs to deal with something like

YourObject%Position(1)

Where formerly in the code you may have POSX

My current work around is to use FPP with

#define POSX YourObject%Position(1)

The problem with using #define is it makes debugging difficult (macros are not expanded by the debugger).

With permitting ASSOCIATE inside the data portion of a module, you could then have an analog of:

EQUIVILANCE
and
C++-like member functions that return references and/or values

---------------------------

The documentation of ASSOCIATE describes it as using as having a paired block:

[name:] ASSOCIATE asso-entity[, asso-entity]...
block
END ASSOCIATE [name]

What would be nice to permit is for a FORTRAN include file to contain open ended ASSOCIATEs without the corisponding END ASSOCIATE, and then have an implicit end ASSOCIATE at the end of scope of the subroutine/function, or as an alternative, requiring "END ASSOCIATE
  • " to indicate end of all ASSOCIATE blocks.

    Jim Dempsey
  • 0 Kudos
    1 Reply
    Steven_L_Intel1
    Employee
    490 Views
    No, there is no such feature like that.
    0 Kudos
    Reply