P34.F90

Reading and testing LOGICAL variables


!
! =====> Program - P34.F90
!
!
!     Reading and testing LOGICAL variables
!
!
      LOGICAL SINGLE
      CHARACTER (LEN=15) :: NAME
!
      PRINT *, 'This is Program >> P34  - Testing with LOGICAL data'
!
!
!     Tell program where data for  READ *  is coming from
      OPEN(UNIT=5, FILE='P34.DAT')      ! UNIT=5 is the default input
!
L1:   DO
          READ * ,NAME,SINGLE
          IF(NAME  ==  'DONE')EXIT  ! leave the DO loop
          IF(SINGLE)THEN
             PRINT * ,NAME,'IS SINGLE'
          ELSE
             READ * ,MARRGS
             PRINT * ,NAME,'WAS MARRIED',  &
                MARRGS,'TIMES'  ! a continued line
          ENDIF
      END DO L1   ! the EXIT brings control to next statement
      END         ! this terminates execution phase

DATA:
'Jane Simpson'       T
'Mary Morrison'      F
3
'DONE'               T

OUTPUT:
Program entered
 This is Program >> P34  - Testing with LOGICAL data
 Jane Simpson   IS SINGLE
 Mary Morrison  WAS MARRIED 3 TIMES

Come back to the previous page

Page builder: Charles Boivin

Last modified: 11/07/95