integer array in fortran

In Fortran, an integer array is declared using the "integer" keyword followed by the desired dimensions of the array. Here is an example:

integer :: myArray(10)

This declares an integer array named "myArray" with a size of 10. Each element of the array can store an integer value. You can access and manipulate individual elements of the array using array indexing, starting from 1. For example:

myArray(1) = 5

This assigns the value 5 to the first element of the array. You can also initialize the entire array at once using an array constructor:

integer :: myArray(5) = [1, 2, 3, 4, 5]

This initializes the array "myArray" with the values 1, 2, 3, 4, and 5.

Arrays in Fortran are zero-indexed by default. If you want to change the default behavior and make arrays one-indexed, you can use the "default" keyword:

integer, dimension(1:5), default :: myArray

This declares an integer array named "myArray" with a size of 5, and it will be one-indexed.

It's important to note that Fortran arrays are fixed-size, meaning their dimensions cannot be changed once they are declared. If you need a dynamically resizable array, you can use allocatable arrays or dynamic memory allocation techniques.