FORTRAN vector example

C Typical FORTRAN program demonstrating vector manipulation
C Uses the KERNLIB vector addition subroutine VADD()

C First we declare some arrays to represent vectors

      REAL C1(2), C2(2), C3(2), C4(2)

C Now initialise C1 and C2

      DATA C1/0.5,-1.5/
      DATA C2/-3.0,2.5/

C Use a library call to compute C1+C2 and store result in C3

      CALL VADD( C1, C2, C3, 2 )

C Print the answer

      PRINT*,'(',C1(1),',',C1(2),') + (',C2(1),',',C2(2),
     1          ') = (',C3(1),',',C3(2),')'

C The following line is meaningless drivel which is
C not trapped by the compiler and may not even
C crash the program

      CALL VADD( C1, 'OUCH!!!', C4, 2 )


Output (after fixing bug):

 ( 0.5000000 ,  -1.500000 ) + ( -3.000000 , 2.500000 ) = (
  -2.500000 , 1.000000 )