BUG: FOR3294 Error Using Module Inside Module Procedure

Last reviewed: April 12, 1996
Article ID: Q149751
The information in this article applies to:
  • Microsoft Fortran PowerStation for Windows 95 and Windows NT, version 4.0

SYMPTOMS

Referencing a user-defined data type, defined in one module, at another module's internal procedure level causes the compiler to fail to recognize the user-defined data type. Specifically, this occurs when the module and main program sources are contained in different files. The following compiler error is generated under these circumstances:

   error FOR3294: derived type referenced but not declared

RESOLUTION

Do one of the following:

  • Use the module containing the user-defined data type at the module level, not at the module's internal procedure level.

    -or-

  • Combine the module and program source code into one source file.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

  1. Using the sample code provided, create a module and program file.

  2. Compile and link the module and program files together.

Sample Code to Illustrate Problem and Workaround

! Compile options needed: none

! --- mods.for ---

      module types
        type my_type
            real :: x
        end type my_type
      end module types

      module funcs
!     use types               ! uncomment this line for first workaround
      contains
        function my_func(z1) result(z2)
            use types         ! comment this line for first workaround
            implicit none
            real z1
            type(my_type) z2
            z2 % x = z1
        end function my_func
      end module funcs

! --- prog.for ---

      program test
        use types
        use funcs
        implicit none
        real a
        type (my_type) :: b

        a = 1.0
        b = my_func(a)
      end program test


Additional reference words: 4.00
KBCategory: kbprg kbbuglist
KBSubcategory: FORTLngIss



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.