21.06.2013 Views

Introducción a FORTRAN

Introducción a FORTRAN

Introducción a FORTRAN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

eal radio,x,y<br />

! Calcular distancia al origen.<br />

radio = sqrt(x**2 + y**2)<br />

! Terminar funcion.<br />

return<br />

end function radio<br />

! Subrutina "escribir".<br />

subroutine escribir(N,r,x,y)<br />

! Declarar variables y arreglos.<br />

implicit none<br />

integer i,j,N<br />

real, dimension(N,N) :: r,x,y<br />

! Abrir archivo.<br />

open(10,file=’distancia2.dat’)<br />

! Loop de dos dimensiones para escribir a archivo.<br />

do i=1,N<br />

do j=1,N<br />

write(10,’(3f10.3)’) x(i,j),y(i,j),r(i,j)<br />

end do<br />

end do<br />

! Cerrar archivo.<br />

32

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!