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

Solution

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

©University of Liverpool, 1997
Thu May 29 10:11:26 BST 1997
Not for commercial use.