Sie sind auf Seite 1von 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.

Derivadas.

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.
Nombradas
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

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

Operaciones aritmticas
**
*
+
/
Divisin entera

Operadores lgicos
not.
.and.
.or.
.eqv.
.neqv.

Operadores relacionales
<
<=
>
>=
==
/=

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

Close(Unidad)
READ(UNIT,*)
WRITE(UNIT,*)

OPEN (7, FILE = 'DATA01.TXT', ACCESS = 'APPEND',STATUS = 'NEW')


DO 10 I=1,100
WRITE(7,*) I
10 CONTINUE
GO TO 50
CLOSE(7)
50 CONTINUE
STOP
END

Das könnte Ihnen auch gefallen