Fortran 90 creating an array of unknown size

  • Context: Fortran 
  • Thread starter Thread starter max2112
  • Start date Start date
  • Tags Tags
    Array Fortran
Click For Summary

Discussion Overview

The discussion revolves around creating a Fortran 90 program to solve the Josephus Problem, specifically focusing on the implementation of a subroutine that allows for dynamic array creation based on user input. The scope includes programming challenges and technical explanations related to array handling in Fortran.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant shares their attempt to create a subroutine that initializes an array of size n, as specified by user input, but expresses confusion about why it isn't functioning as expected.
  • Another participant suggests that the original poster should format their code with appropriate tags for better readability, and provides a link to an article about arrays in Fortran 90, highlighting the section on dynamic arrays.
  • A third participant proposes a structure for a subroutine using allocatable arrays, indicating the need to allocate and deallocate memory dynamically.
  • Another participant questions why the program is not working, pointing out that the original poster did not include any print statements after the user inputs the value of n.

Areas of Agreement / Disagreement

Participants express various approaches to the problem, with no consensus on a single solution or understanding of the original poster's issue. Multiple views on how to handle dynamic arrays and program output remain evident.

Contextual Notes

There is an implicit assumption that the array size must be determined at runtime, and the discussion includes references to dynamic memory allocation, which may not be fully resolved in the original poster's code.

Technology news on Phys.org
Summit like this:

Code:
subroutine(/arguments/)

real,allocatable :: array(:)

/code/

allocate ( array(x) )

/code/

deallocate ( array )

return
 

Similar threads

  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K