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 9322639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:08:36+00:00 2026-06-19T04:08:36+00:00

I have a derived type: module foo type bar integer, allocatable, dimension(:) :: data

  • 0

I have a derived type:

module foo
  type bar
      integer, allocatable, dimension(:) :: data
  end type bar
end module foo

Now I would like to allocate bar‘s data within a subroutine without an explicit interface:

program main
  use foo
  type(bar) :: mybar
  call alloc_my_bar(10,mybar)
  print*, mybar
end program

subroutine alloc_my_bar(n,mybar)
  use foo
  type(bar) :: mybar
  integer :: n
  allocate(mybar%data(n))
  mybar%data = 42
end subroutine alloc_my_bar

This seems to work just fine with ifort, but I know that if mybar wasn’t part of a user defined type, I would need an explicit interface … Does putting the allocatable array into a user defined type remove the need for an explicit interface? What version of the fortran standard is this code compatible with (F90, F95, F2003 … ) if any?

  • 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-19T04:08:38+00:00Added an answer on June 19, 2026 at 4:08 am

    Allocatable components are defined in TR15581 to F95 that was incorporated to the Fortran 2003 standard. You should not need explicit interface for this, just the use association for the type definition should be fine. You are not passing the array, but the structure around it.

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

Sidebar

Related Questions

I have a Show table, and I would like to have a derived type
I have a Fortran derived type T that contains data arrays of (many) different
I have a derived type t_file with a finalization routine close which simply writes
Let's say I have type A, and a derived type B. When I perform
I have an abstract type A , and two derived types A1 and A2
In a Data Flow, I have an Derived Column task. In the expression for
Using table per type inheritance is it possible to have the same data with
I have an XML document that looks like this <Elements> <Element> <DisplayName /> <Type
I have two classes: a base class, Foo::Base and a derived class, Foo::Base::Sub .
I have derived a class from Exception , basically like so: class MyException extends

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.