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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:31:11+00:00 2026-05-27T18:31:11+00:00

Exactly the same questions as Create an array with elements of different types ,

  • 0

Exactly the same questions as Create an array with elements of different types, except how to do this in Fortran?

Say I want an array with the first dimension an integer type, the second real and the third character (string) type. Is it possible to create a “struct” in Fortran too?

Thanks.

  • 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-05-27T18:31:11+00:00Added an answer on May 27, 2026 at 6:31 pm

    Here is an example program of a derived type use:

    TYPE mytype
      INTEGER,DIMENSION(3)   :: ints
      REAL,DIMENSION(5)      :: floats
      CHARACTER,DIMENSION(3) :: chars
    ENDTYPE mytype
    
    TYPE(mytype) :: a
    
    a%ints=[1,2,3]
    a%floats=[1,2,3,4,5]
    a%chars=['a','b','c']
    
    WRITE(*,*)a
    
    END
    

    The output is:

            1            2            3    1.000000        2.000000     
    3.000000        4.000000        5.000000     abc
    

    EDIT: As per suggestion by Jonathan Dursi:

    In order to have an array where each element has a int, float and char element, you would do something like this:

    TYPE mytype
      INTEGER   :: ints
      REAL      :: floats
      CHARACTER :: chars
    ENDTYPE mytype
    
    TYPE(mytype),DIMENSION(:),ALLOCATABLE :: a
    
    ALLOCATE(a(10))
    

    You would then reference your elements as, e.g. a(i)%ints, a(i)%floats, a(i)%chars.
    Related answer is given in Allocate dynamic array with interdependent dimensions.

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

Sidebar

Related Questions

I want to do exactly the same as in this question : Windows file
I have four tables containing exactly the same columns, and want to create a
My question is not exactly the same as this one (it's not theoretical, there
I have classes that are named exactly the same across different plug-ins that I
I've seen certain questions knocking around which are similar, but not exactly the same
I found some questions that looked similar, but not exactly the same so I'll
I know there are multiple questions about this same question but I couldn't find
My question is almost exactly the same as this question , however the answer
The question I have is exactly same in requirement as How to pass mouse
vb.net windows forms question. I've got 3 forms that have exactly the same functions,

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.