Advertisement
Guest User

Untitled

a guest
May 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module sistemaEc
  2.     contains
  3.  
  4.     subroutine resolverSistema(sigmaA, muA)
  5.  
  6.         integer :: i, n, nmax, m
  7.         real(8) :: errf, errx, eps
  8.         real(8), dimension(2) :: x, y
  9.         real(8), dimension(2,2) :: A
  10.         real(8), intent(inout) :: sigmaA, muA
  11.  
  12.         !ITERACIONES MÁXIMAS, TOLERANCIA, Nº ECUACIONES
  13.         nmax = 10
  14.         eps = 1d-6
  15.         m = 2
  16.  
  17.         !INICIALIZAMOS EL VECTOR SOLUCIÓN INICIAL, tal que x(:)=(/muA, sigmaA/)
  18.         x = (2d0,6d0)
  19.  
  20.         !BUCLE PARA REALIZAR LAS APROXIMACIONES A LA SOLUCIÓN BUSCADA
  21.         do n=1, nmax
  22.             call f(x,y,m)
  23.             call jacob_f(x,a,m)
  24.             call factorizar (a,m)
  25.             call sustituir (a,y,m)
  26.  
  27.             x = x + y
  28.  
  29.             errx = norma_2(y,m)/(max(eps,norma_2(x,m)))
  30.             errf = norma_2(y,m)
  31.  
  32.             write(*,*) "ITERACION: ", n
  33.             write(*,*) "sigmaA, muA: ", x(2), x(1)
  34.             write(*,*)
  35.  
  36.             if (max(errx,errf) .lt. eps) then
  37.                 !GUARDAMOS LOS VALORES DE muA, sigmaA
  38.                 muA = x(1)
  39.                 sigmaA = x(2)
  40.                 write(*,*) "--------------"
  41.                 exit
  42.             end if
  43.         end do
  44.  
  45.  
  46.         !SI NO CONVERGE, PARAMOS EL PROGRAMA
  47.         if (n .gt. nmax) then
  48.             write(*,'("numero maximo de iter.")')
  49.             stop
  50.         end if
  51.  
  52.         50 format (i2,4(1x,d13.7))
  53.  
  54.     end subroutine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement