Hello World Program, with Comments (Fortran in Bold)


      PROGRAM HelloWorld  !Name of main program
    
      !You can put comments in your code by having an ! or a C at the start of the line.
      !Make sure you have 6 spaces before each line.
      !Also, there is a maximum number of characters per line in F77 (74?).
      !To get around this, put any character in the 6th column (eg '&') - then you can just continue the code line. 
      !Fortran is *not* case sensitive (No difference between capitols & lower case).

      CHARACTER*30 message                !Makes variable 'message' a string (or word) 30 characters long.

      print*                                                  !Just prints a blank line, for neatness.
      print*,'Please enter your message: '  !This prints the question to screen. You can also use 'WRITE(6,*)'.
      read(5,*)message                              !When you type in the message, it will be stored in the variable 'message'.
                                                                 !(5,*) means read from the keyboard.  

      print*
      print*,'The message you typed in was:  ', message  !This prints a statement and the string that was stored in the variable 'message' earlier.

      END  !End the program.