Saving Data in FORTRAN Arrays: A Guide

In summary, the conversation is about a person asking for help on how to store data in an array in FORTRAN. They want to use only 60 elements of the array, but they are not sure how to do so and are asking for guidance.
  • #1
amitavorc2
1
0
Dear Sir,

I am using FORTRAN.
I have little experience and i am facing one problem.

I want to store data (i.e. X and Y values) in an array (A(900),B(900)) in such a way that at first I used only 30 elements of each array for storage 30 initial values of X and Y and then I have some scientific calculations to change the values of X and Y and then again want to store 30 modified values of X and Y in the same array from the 31th array element of both arrays. In this way I want to store my data and finally want to print these arrays.

Could you please help me out how I can write this algorithim I FORTRAN code…..

Please help me.

Please guide me

With best regards
 
Technology news on Phys.org
  • #2
amitavorc2 said:
Dear Sir,

I am using FORTRAN.
I have little experience and i am facing one problem.

I want to store data (i.e. X and Y values) in an array (A(900),B(900)) in such a way that at first I used only 30 elements of each array for storage 30 initial values of X and Y and then I have some scientific calculations to change the values of X and Y and then again want to store 30 modified values of X and Y in the same array from the 31th array element of both arrays. In this way I want to store my data and finally want to print these arrays.

Could you please help me out how I can write this algorithim I FORTRAN code…..

Please help me.

Please guide me

With best regards
Why do you need arrays with 900 elements if you're planning to use only 60 of them? Also, a web search on "fortran array" should yield plenty of examples of how to use arrays.
 

1. How do I declare and initialize an array in FORTRAN?

To declare and initialize an array in FORTRAN, you can use the DIMENSION statement followed by the array name and its dimensions. For example: DIMENSION A(10,10) will declare a two-dimensional array with 10 rows and 10 columns. You can then use the DATA statement to initialize the array with specific values.

2. What is the maximum number of elements that can be stored in a FORTRAN array?

The maximum number of elements that can be stored in a FORTRAN array depends on the implementation and the available memory on the system. The standard FORTRAN 77 allows a maximum of 2 billion elements, but newer versions of the language may have higher limits.

3. Can I resize an array in FORTRAN?

No, FORTRAN does not have built-in functions to resize an array. Once an array is declared, its size cannot be changed. However, you can create a new array with a different size and copy the elements from the original array to the new one.

4. How do I save data from an array into a file in FORTRAN?

To save data from an array into a file in FORTRAN, you can use the WRITE statement. First, open the file using the OPEN statement, then use the WRITE statement to write the array elements to the file. You can also specify the format in which the data should be written using the FORMAT statement.

5. How can I access and modify individual elements in a FORTRAN array?

You can access and modify individual elements in a FORTRAN array by using the array name followed by the indices of the element you want to access or modify. For example, A(2,5) will access the element in the second row and fifth column of the array A. You can then assign a new value to that element using the assignment statement (=).

Similar threads

  • Programming and Computer Science
Replies
20
Views
3K
  • Programming and Computer Science
Replies
17
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
7K
  • Programming and Computer Science
Replies
11
Views
993
  • Programming and Computer Science
Replies
4
Views
607
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
20
Views
1K
  • Programming and Computer Science
Replies
5
Views
3K
Back
Top