Вы находитесь на странице: 1из 17

# Lenguajes de Programacin

FORTRAN
M.C Said Zamora

Hola.f90
program hola
! Programa que imprime "hola" en al pantalla
implicit none
print*, "Hola"
end program hola

Variables
Objeto de datos cuyo valor puede definirse.
Intrnsecas:
Integer, Real, Complex, Logical y Character.

Variables
integer :: total
real :: prom1, prom2
complex :: cx
logical :: done
character(len=80) :: linea

Variables
total = 6.7
prom1 = prom2
done = .true.
linea = es una linea
cx = (1.0, 2.0) !

cx = 1.0 + 2.0i

## cx = cmplx (1.0/2.0, -3.0)

cx = cmplx (x, y)

! cx = 0.5 3.0i
! cx = x + yi

Constantes
Literales.
real, parameter :: pi = 3.1415927

Arreglos
real, dimension(5) :: vector
integer, dimension (3, 3) :: matriz
real, dimension (1:5) :: vector
real, dimension (-10:8) :: a1
integer, dimension (-3:3, -20:0, 1:2, 6, 2, 5:6, 2) :: grid1

Character
character (len=80) :: n

n(1:3)
n(2:2)
n (:3)
n (3:)
n (:)

Tan
a
Tan
nja
Tanja

n = Tanja

type :: atom
character (len=2) :: l
real :: x, y, z
end type atom
type(atom), dimension (10) :: molecula

Operaciones aritmticas
**
*
+
/
Divisin entera

not.
.and.
.or.
.eqv.
.neqv.

<
<=
>
>=
==
/=

Funciones intrinsecas
abs (x)
complx (x,y [, ikind])
floor (x)
int (x)
abs (x < 1), 0. abs (x) >= 1
real (x [, ikind])
mod (a,p)
a int (a/p) * p.
modulo (a,p)
a floor (a/p) * p

Estructuras de control
if () then

end if

Do
real, dimension (5) :: array1
real :: sum
integer :: i

sum = 0.0
do i = 1, 5
sum = sum + array1(i)
end do

enddo

Archivos
open (unit=10, file=ch1001.txt)
Access = append, direct, sequential
Status = New, Old, Scratch, Unknown