P81.F90

COMMON statement


!
! =====> Program - P81.F90
!
!     Shows use of passing data via COMMON
!
      REAL Y(10)
      COMMON K,X,Y
!
      PRINT *, 'This is Program >> P81  - Common example'
!
      START=0.0
      STEP=0.1
      X=START
!
      PRINT 16,START,STEP
16    FORMAT(' INITIAL VALUE =',F5.2/  &
             ' INCREMENT     =',F5.2/)
!
L1:   DO K=1,11
         CALL CALC
         PRINT 17,X,Y(K)  ! Y values are stored and
         X=X+STEP
      END DO L1           ! could be used again
17    FORMAT(2F10.4)
      STOP
      END
!
      SUBROUTINE CALC   ! No parameters - data passed in COMMON
      COMMON I,X,Z(10)  ! correspond to K, X and Y in main
      COMMON /PARMS/ PI,U,SD
      C=1.0/(SD*SQRT(2.0*PI))
      GAUSS=C*EXP(-(X-U)**2/(2.0*SD**2))
      Z(I)=GAUSS
      RETURN
      END
!
      BLOCK DATA
      COMMON /PARMS/ PIE,U,S
      DATA PIE,U,S/3.14159,0.0,1.0/
      END

DATA:
0.0   0.1

OUTPUT:
Program entered
 This is Program >> P81  - Common example
 INITIAL VALUE = 0.00
 INCREMENT     = 0.10

    0.0000    0.3989
    0.1000    0.3969
    0.2000    0.3910
    0.3000    0.3813
    0.4000    0.3682
    0.5000    0.3520
    0.6000    0.3332
    0.7000    0.3122
    0.8000    0.2896
    0.9000    0.2660
    1.0000    0.2419
Fortran-90 STOP

Come back to the previous page

Page builder: Charles Boivin

Last modified: 11/07/95