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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:38:24+00:00 2026-06-09T21:38:24+00:00

Is it possible in modern Fortran to use a vector to index a multidimensional

  • 0

Is it possible in modern Fortran to use a vector to index a multidimensional array? That is, given, say,

integer, dimension(3) :: index = [4,6,9]
double precision, dimension(10,10,10) :: data

is there a better (more general) way to access data(4,6,9) than writing data(index(1), index(2), index(3))? It would be good not to have to hard-code the rank of the data array.

(Naively I would like to write data(index) but of course this actually means something different – subset “gathering” – requiring data to be a rank-one array itself.)

For what it’s worth this is essentially the same question as multidimensional index by array of indices in JavaScript, but in Fortran instead. Unfortunately the clever answers there won’t work with predefined array ranks.

  • 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-09T21:38:25+00:00Added an answer on June 9, 2026 at 9:38 pm

    No. And all the workarounds I can think of are ghastly hacks, you’re better off writing a function to take data and index as arguments and spit out the element(s) you want.

    You might, however, be able to use modern Fortran’s capabilities for array rank remapping to do exactly the opposite, which might satisfy your wish to play fast-and-loose with array ranks.

    Given the declaration

    double precision, dimension(1000), target :: data
    

    you can define a rank-3 pointer

    double precision, pointer :: index_3d(:,:,:)
    

    and then set it like this:

    index_3d(1:10,1:10,1:10) => data
    

    and hey presto, you can now use both rank-3 and rank-1 indices into data, which is close to what you want to do. I’ve not used this in anger yet, but a couple of simple tests haven’t revealed any serious problems.

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

Sidebar

Related Questions

Possible Duplicate: Does it make sense to use the <table> tag on a “modern”
I realize that in the modern day, most people use CSS to perform styling,
In modern processors it is possible to load a register from memory and then
Is it possible in any of the modern SCMs to grab a complete list
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How to do the vector of sets in C++? I want to
Is it possible to control the bluetooth status light on modern laptops, and how
Assuming that it's even possible, what would be your recomendations to make a bundle
I've been asked to collate a list as possible of the modern uses for
Is it possible to replace Excel's built-in VBA Editor or IDE with a modern

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.