P32.F90

Relational IF


!
! =====> Program - P32.F90
!
!
!     Simple loop in FORTRAN 90
!
!
      PRINT *, 'This is Program >> P32  - Relational IF'
!
!
!     Tell program where data for  READ *  is coming from
      OPEN(UNIT=5, FILE='P32.DAT')      ! UNIT=5 is the default input
!
      DO
           READ * ,SUM ,COUNT
           IF(COUNT == 0.0)STOP  ! or EXIT
           AVE=SUM/COUNT
           PRINT * ,'SUM=', SUM
           PRINT * ,'COUNT=', COUNT
           PRINT * ,'AVERAGE=', AVE
      END DO
      END

DATA:
120.0   10.0
100.0    0.0

OUTPUT:
Program entered
 This is Program >> P32  - Relational IF
 SUM=   1.2000000E+02
 COUNT=  10.0000000
 AVERAGE=  12.0000000
Fortran-90 STOP

Come back to the previous page

Page builder: Charles Boivin

Last modified: 11/07/95