What could be causing a dynamic space array error in a Fortran 77 program?

In summary, the code is written in Fortran 77 syntax, but the compiler refuses to compile it when I try to use dynamic arrays.
  • #1
jf22901
55
1
Hi all

I am trying to run an executable compiled from some Fortran files (not my own), which look like they are written in Fortran 77. One of these includes some dynamic space arrays, where the number of elements depends on an integer value passed to the subroutine, e.g.

Code:
      subroutine assim (plevels,qlevels,row,number)
      implicit none
      
      integer plevels, qlevels, row, number
      
C DYNAMIC SPACE ARRAYS:
      integer array1(number)
      integer array2(number)
      
      ...
      
      return
      end

When I try to run the executable, the program gives the error message below, which I have traced back to the dynamic space array declaration. However, when someone from a different department compiles the code it works on their machine.

I guess this is some sort of memory problem? I've tried using ulimit, but get the same error. Can anyone offer any further help or insight? The error message is:

Command terminated by signal 11
0.63user 0.00system 0:00.86elapsed 74%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+2482minor)pagefaults 0swaps

Many thanks
 
Technology news on Phys.org
  • #2
After doing a bit more work it seems that one of the arrays is defined to have 25 million elements, hence the reason my computer hasn't enough memory! Ah well, problem sorted I guess. :rolleyes:
 
  • #3
Hi jf22901. What version of Fortran are you using? I'm just trying to figure out when dynamic arrays entered into the language.
 
  • #4
Standard Fortran 77 did not have dynamically-allocated arrays. Some F77 compilers may have had them as a non-standard extension, although I don't remember using any such compilers myself.
 
  • #5
uart said:
Hi jf22901. What version of Fortran are you using? I'm just trying to figure out when dynamic arrays entered into the language.

It's a model that's been developed over the years, so there is some Fortran 77, and some 90. The code where the dynamic arrays are is definitely written in the syntax of Fortran 77. The compiler is ifort (which seems to allow non-standard extensions), but I know that whenever I've tried to use dynamic arrays with gfortran on my laptop it simply refuses!
 
  • #6
Ok thanks. I expect that iFort will support whatever the most recent Fortran specifications are and possibly some extensions.

BTW. I just now checked this with g95 (the gnu fortran 95 compiler) and it also supports arrays defined like this. This is interesting as I didn't expect that.
 

1. What are Fortran dynamic space arrays?

Fortran dynamic space arrays are a type of data structure that allows for the allocation of memory space at runtime. This means that the size of the array can be determined while the program is running, rather than being fixed at the beginning.

2. How do you declare a dynamic space array in Fortran?

To declare a dynamic space array in Fortran, you need to use the ALLOCATABLE keyword in the array declaration. This tells the compiler to allocate memory space for the array at runtime. For example: INTEGER, ALLOCATABLE :: myArray(:).

3. How do you assign values to a dynamic space array in Fortran?

You can assign values to a dynamic space array in Fortran using the ALLOCATE statement. This allows you to specify the size of the array and assign values to each element. For example: ALLOCATE(myArray(5)), myArray = [1, 2, 3, 4, 5].

4. How do you resize a dynamic space array in Fortran?

To resize a dynamic space array in Fortran, you can use the DEALLOCATE and ALLOCATE statements. First, you need to deallocate the current array using DEALLOCATE(myArray), then allocate a new array with the desired size using ALLOCATE(myArray(newSize)).

5. What are the advantages of using dynamic space arrays in Fortran?

Dynamic space arrays in Fortran offer several advantages, including flexibility in array size, efficient memory usage, and the ability to avoid runtime errors caused by fixed-size arrays. They also allow for more complex and dynamic programming logic, making it easier to handle large amounts of data.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
4
Views
15K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top