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

Import statement needs new glasses

IanH
Honored Contributor III
339 Views

With the recent release I'm seeing an oddity with the import statement being unable to find things in the host scope, under certain specific conditions, that looks a bit dodgy. 

[fortran]MODULE StNodes
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: AddNode
  !-----------------------------------------------------------------------------
  TYPE, PUBLIC :: StNode      ! Type StNode is a public entity.
    CLASS(StNode), POINTER :: parent => NULL()
  END TYPE StNode
 
  TYPE, PUBLIC :: StNodeList
    CLASS(StNode), ALLOCATABLE :: item
  END TYPE StNodeList
  !-----------------------------------------------------------------------------
  INTERFACE AddNode
    MODULE PROCEDURE AddNode_
  END INTERFACE AddNode
CONTAINS
  SUBROUTINE AddNode_(list)
    TYPE(StNodeList), INTENT(INOUT), ALLOCATABLE :: list(:)
    !***************************************************************************
    IF (ALLOCATED(list)) CONTINUE     ! Avoid "not used" warning.
  END SUBROUTINE AddNode_
END MODULE StNodes

MODULE ExecStNodes
  USE StNodes       ! This makes all public entities of StNodes accessible.
                    ! (which should include StNode).
  IMPLICIT NONE
  PRIVATE
 
  TYPE, PUBLIC, ABSTRACT, EXTENDS(StNode) :: ExecStNode
    TYPE(StNodeList), ALLOCATABLE :: statements(:)
  END TYPE ExecStNode
 
  INTERFACE
    SUBROUTINE ExecStNodeFactory(ist, node)
      ! StNode should be accessible in host, but error #6483 here.
      IMPORT :: StNode
      IMPLICIT NONE
      !-------------------------------------------------------------------------
      INTEGER, INTENT(IN) :: ist
      CLASS(StNode), INTENT(OUT), ALLOCATABLE :: node
    END SUBROUTINE ExecStNodeFactory
  END INTERFACE
CONTAINS
  RECURSIVE SUBROUTINE exec_BuildTree
    CLASS(ExecStNode), ALLOCATABLE :: st
    !***************************************************************************
    CALL AddNode(st%statements)
  END SUBROUTINE exec_BuildTree
END MODULE ExecStNodes
[/fortran]

[plain]>ifort /c /check:all /warn:all /standard-semantics ExecStNodes.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.103 Build 20130728
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

ExecStNodes.f90(38): error #6483: IMPORT-name must be the name of an entity in the host scoping unit   [STNODE]
      IMPORT :: StNode
----------------^
ExecStNodes.f90(42): error #6457: This derived type name has not been declared.   [STNODE]
      CLASS(StNode), INTENT(OUT), ALLOCATABLE :: node
------------^
ExecStNodes.f90(36): error #6404: This name does not have a type, and must have an explicit type.   [NODE]
    SUBROUTINE ExecStNodeFactory(ist, node)
--------------------------------------^
compilation aborted for ExecStNodes.f90 (code 1)[/plain]

The workaround is simple enough - just USE the module.

The 14.0 release seems reasonably robust so far.  It looks like keeping my bedroom clean paid off!

0 Kudos
1 Reply
Steven_L_Intel1
Employee
339 Views

Escalated as DPD200247835. Thanks. The PRIVATE/PUBLIC doesn't matter here, I found.

0 Kudos
Reply