Convert data from F77 to F90

I am converting some F77 files to F90. However, there are some common blocks that have not been converted. I am new to F90 and have no experience in F77. Can someone show me how to hide the following code sample for F90?

  BLOCK DATA SETUP
  INTEGER A,B,C
  REAL    I,J,K,L
  COMMON  /AREA1/ A,B,C
  COMMON  /AREA2/ I,J,K,L
  DATA    A,B,C,I,J,K,L/0,1,2,10.0,-20.0,30.0,-40.0/
  END

My idea is to place arrays A, B and C in the module. The main thing that I do not get here is AREA1 and AREA2. How are they used in F77 and how to translate them? My first guess is to drop them and just define A, B and C in the module. However, are they type types containing A, B, and C?

+4
source share
1 answer

, Fortran 90 . , , .

COMMON - . , , 1 . - :

integer a, b
common /globals/ a, b

globals :

module globals
    implicit none
    integer a, b
end module globals

use a b

program main
    use globals
    implicit none
    a = 4
    b = 2
end program main

DATA , , , :

module AREA1
    implicit none
    integer :: a = 0
    integer :: b = 1
    integer :: c = 2
end module AREA1

module AREA2
    implicit none
    real :: i = 10.0
    real :: j = -20.0
    real :: k = 30.0
    real :: l = -40.0
end module AREA2

use AREA1 use AREA2 implicit none , .

:

1 , , . , COMMON, , .

- ( ), . ,

integer a, b
common /globals/ a, b

integer i, j
common /globals/ i, j

. , a b, :

use globals, only: i => a, j => b

( , only, , . - : only: a, i => b, a i.)

, globals , :

integer k(2)
common /globals/ k
+6

Source: https://habr.com/ru/post/1659490/


All Articles