Monday, June 16, 2014

fortran-learning notes-1

1. BasicsFortran language key internal words.
PROGRAM: to start a program
End: end a program

integer, real, complex, logical, character, open, read, write, print, and, for, do, continue, ALLOCATABLE, dimension, etc. 

2. Punctuation
First, in Fortran you do not need any punctuation after each sentence.
!: followed by comments.
': single quote. 
": double quote.
: is used to operate the string (stringa(1:4)) or specify the elements in an array : array(3:8)
( ): parenthesis. Quite useful.
Examples:


: means the numbers of sentences. :4
; means multiple sentences together.

, means comma. It separate the type name or type values. or objects must be separated by commas in one sentence. Example:
 WRITE (*,*) "Hello World", variablename, "More text", anothervariable

.
?
:: means a double colon which is used to declaim a type (integer, real, character)

3. Symbols

> means more than.
< means more than.
& is used to connect two sentences in continuous lines.
*: multiply
+: adding
-: minus
/: division.
// means string operator. stringb//stringa=stringbstringa
**: power (3**2: 3 to the power of 2)
space: multiple spaces are equal to one space in Fortran.
= means equal sign
_ means a underscore, which can be used to make a name.
$: 
%:
 

4. Fortran variable types
character example: 
CHARACTER(LEN=4), PARAMETER :: Name = 'Smith'
                   CHARACTER(LEN=*), PARAMETER :: Name = 'Smith'
real example:
REAL :: Offset = 0.1, Length = 10.0, tolerance = 1.E-7


 

No comments:

Post a Comment