Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:33:49+00:00 2026-06-08T01:33:49+00:00

Compiler: ifort version 12.1.5 I’m writing some Fortran code and I’d like to make

  • 0

Compiler: ifort version 12.1.5

I’m writing some Fortran code and I’d like to make use of some F2003 OOP features, but I’m hitting some stumbling blocks. Paring down the example, I wish to have two derived types A and B, each of which have a pointer to instances of the other. In Fortran, circular dependencies between modules are explicitly disallowed, so these two types would have to reside in the same module. This compiles:

module testModule
implicit none

type A
 type(B),pointer :: b1
end type A

type B
 type(A),pointer :: a1
end type B

contains
[some possibly type-bound procedures]
end module

Now, I want to implement some constructors for these types, and try this code:

module testModule
implicit none

type A
 type(B),pointer :: b1
end type A

interface A
 module procedure A_ctor
end interface

type B
 type(A),pointer :: a1
end type B

interface B
 module procedure B_ctor
end interface

contains
function A_ctor()
 type(A),target :: A_ctor
end function
function B_ctor()
 type(B),target :: B_ctor
end function
end module

Now, this doesn’t compile, throwing an error

This is not a derived type name. [B]

on line 5 above. Why does adding the interfaces throw an error? How does one handle circular dependencies in derived types in Fortran, as one would use a forward class declaration in C++?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:33:50+00:00Added an answer on June 8, 2026 at 1:33 am

    Your code is correct Fortran 2003. You are handling the circular type dependency in the correct way. The compiler is in error.

    I have experienced and seen others report issues with ifort 12.1.5 and programmer overrides of structure constructors (where there is a generic interface to a function that has a derived type result, with the interface having the same name as the derived type – as you have here). A workaround for this situation to rename the generic interface (and subsequent references) for the constructor function to a name different from the derived type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The compiler, given the following code, tells me Use of unassigned local variable 'x'.
I'm trying to port a program from gfortran to ifort (Intel Fortran Compiler 11).
The following program compiles with ifort (version 12) but not with GFortran (up to
Does compiler optimization cause a problem with code like this? Specifically, can the auto-increments
I would like to compile fortran code on mac such that it does not
i use ifort and gfortran to compile my Fortran program. However i also use
The compiler complains about this code: HashMap<String,int> userName2ind = new HashMap<String,int>(); for (int i=0;
I have a Fortran program, which I can compile using f77, f95 or ifort
Compiler: Visual C++ OS: Windows 7 Enterprise For some reason, Window::SetFramerateLimit isn't limiting the
The compiler doesn't seem to mind it so far but I just wanted to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.