| Refresh | Home EGTry.com

variable and primitive types


variable.f

c23456
      program var1
      integer sum
      real rad,degree
      double precision d1,d2
      complex com
      logical f
      character c
      parameter(pi=3.14, half=180)
     
     
c integer type if a variable name start with character between i and n
      i=1
      j=2
      k=3
      l=4
      m=5
      n=6

      a=3.14 !otherwise it is  real 

      sum=i+j+k+l+m+n

      rad=a
      degree=half*rad/pi
      write(*,*) 'sum=',sum
      write(*,*) 'degree=',degree

      stop
      end



Output

 sum=          21
 degree=   180.00000    


a fortran variable name are not case sensitive. The first character must be a letter [a-z], and the following character could be letter or digit [a-z0-9]

if not explicitly declared, a variable name start with a character i,j,k,l,m,n are of integer type. If not started with those character, then the type is real