next up previous contents
Next: Area Of a Circle Up: Declaration Format Previous: Declaration Format

Solution

  1. INTERGER :: i -- Bad spelling of INTEGER
  2. ReAl x -- OK
  3. CHARACTER name -- OK, a 1 character name!
  4. CHARACTER(LEN=10) name -- OK, an array of single characters!
  5. REAL var-1 -- cannot have -1 in a declaration var_1 would be OK.
  6. INTEGER 1a -- Cannot start a variable with a number.
  7. BOOLEAN :: loji -- No BOOLEAN type, use LOGICAL.
  8. DOUBLE :: X -- No, the correct type is DOUBLE PRECISION.
  9. CHARACTER(LEN=5) :: town = "Glasgow" -- OK(ish), town is set to Glasg.
  10. CHARACTER(LEN=*) :: town = "Glasgow" -- Cannot have LEN=* for non-PARAMETER s (or dummy arguments)
  11. CHARACTER(LEN=*), PARAMETER :: city = "Glasgow" -- OK
  12. REAL :: pi = +22/7 -- OK, except the value of pi will be (about) 3 due to integer division.
  13. LOGICAL :: wibble = .TRUE. -- OK
  14. CHARACTER(LEN=*), PARAMETER :: "Bognor" -- Error, no variable name
  15. REAL, PARAMETER :: pye = 22.0/7.0 -- OK
  16. REAL :: two_pie = pye*2 -- OK if pye is a PARAMETER.
  17. REAL :: a = 1., b = 2 -- OK, the value 2 is promoted to be 2.0
  18. LOGICAL(LEN=12) frisnet -- Error cannot use LEN=12 with LOGICAL.
  19. CHARACTER(LEN=6) :: you_know = 'y'know" -- Unbalanced delimiters ' and ", the second ' will cause an error too.
  20. CHARACTER(LEN=6) :: you_know = "y'know" -- OK
  21. INTEGER ia ib ic id in free format source form -- In FIXED FORMAT this is OK, (INTEGER iaibicid) in FREE FORMAT the spaces are erroneous
  22. DOUBLE PRECISION pattie = +1.0D0 -- Need :: if the object is to be initialised. DOUBLE PRECISION :: pattie = +1.0D0 is correct.
  23. DOUBLE PRECISION :: pattie = -1.0E-0 -- OK
  24. LOGICAL, DIMENSION(2) bool -- If there is an attribute (eg, DIMENSION,) then there must be the :: separator.
  25. REAL :: poie = 4.*atan(1.) -- Cannot use atan( ) in initialisation.
  26. and

        INTEGER feet
        REAL :: miles
        CHARACTER(LEN=20) :: town
        CHARACTER(LEN=*), PARAMETER :: home_town = 'Hull'
        LOGICAL, PARAMETER :: in_uk = .TRUE.
        REAL, PARAMETER :: sin_half = 0.47942554


next up previous contents
Next: Area Of a Circle Up: Declaration Format Previous: Declaration Format

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 14:10:26 GMT 1996