C      MODULE POSTPROC
C      CONTAINS

      SUBROUTINE ESCVTK(NMNE,NUMNP,NUMPARA,NEQ,NDOFDIM,JJJ,COORD,
     1                  IELCON,IELT,ID,NUMEL,UTMAST)

      IMPLICIT REAL*8(A-H,O-Z)

      DIMENSION ID(NDOFDIM,NUMNP),COORD(NDOFDIM,NUMNP),
     1          IELCON(NMNE,NUMEL),UTMAST(NEQ)
      DIMENSION IELT(NUMEL)
      
      IF (NMNE==4) THEN
        CALL VTK_4NODES(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ,
     1                  COORD,IELCON(:,1:NUMPARA),ID,UTMAST)
      END IF

      IF (NMNE==8 .AND. NDOFDIM==2) THEN
        CALL VTK_8NODES(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ,
     1                  COORD,IELCON(:,1:NUMPARA),ID,UTMAST)
      END IF
      
      IF (NMNE==8 .AND. NDOFDIM==3) THEN
        CALL VTK_8NODES3D(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ,
     1                  COORD,IELCON(:,1:NUMPARA),ID,UTMAST)
      END IF

	  IMIN=MINVAL(IELT(1:NUMPARA))
	  IMAX=MAXVAL(IELT(1:NUMPARA))
	  
	  IF (IMIN==3 .AND. IMAX==6) THEN
C23456789012345678901234567890123456789012345678901234567890123456789012
	  	CALL VTK_6_9NODES(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ, COORD,
     1                  IELCON(:,1:NUMPARA),IELT(1:NUMPARA),ID,UTMAST)
C  	CALL VTK_6_9NODES(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ, COORD,
C 1                    IELCON(:,1:NUMPARA), IELT(1:NUMPARA),
C 2                    ID, UTMAST)
	  ELSE
     	IF (NMNE==9) THEN
        	CALL VTK_9NODES(NUMNP, NUMPARA, NEQ, NDOFDIM, JJJ,
     1                      COORD,IELCON(:,1:NUMPARA),ID,UTMAST)
      	END IF
     
      END IF

      RETURN
      
      END SUBROUTINE

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C              PROGRAMA PARA GENERAR ARCHIVOS PARA PARAVIEW                   C
C                      PARA ELEMENTOS DE 4 NODOS                              C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C
      SUBROUTINE VTK_4NODES(NP, NELE, NEQ, NDOFDIM, NTIEMPO, COORD,
     1                      MIE, ID, UTMASDT)
C
      IMPLICIT NONE
C
      CHARACTER (25) :: NOMBRE
      CHARACTER (13) :: NPOLY
C
      CHARACTER (4) :: EXTENSION=".vtk"
      CHARACTER (5) :: B
      CHARACTER (28) :: AA="# vtk DataFile Version 4.3.1"
      CHARACTER (59) :: CC
      CHARACTER (5) :: DD ="ASCII"
      CHARACTER (16) :: EE ="DATASET POLYDATA"
      CHARACTER (7) :: FF ="POINTS "
      CHARACTER (16) :: GG ="TRIANGLE_STRIPS "
      CHARACTER (50) :: HH
      CHARACTER (16) :: II
      CHARACTER (16) :: JJ
C
      CHARACTER (11) :: LL ="POINT_DATA "
      CHARACTER (30) :: MM ="SCALARS desplazamientoz double"
      CHARACTER (20) :: NN ="LOOKUP_TABLE default"
C
C
      INTEGER I, J, K, L, W, KK
C
      INTEGER, INTENT(IN):: NP
      INTEGER, INTENT(IN):: NELE
      INTEGER, INTENT(IN):: NEQ
      INTEGER, INTENT(IN):: NDOFDIM
      INTEGER, INTENT(IN):: NTIEMPO
C
      REAL*8 MAGNITUD
C
      INTEGER, DIMENSION(4,NELE), INTENT(IN):: MIE 
      CHARACTER*3 IMP
      REAL*8 juan
      REAL*8 DESPX, DESPY
      REAL*8, DIMENSION(NDOFDIM, NP), INTENT(IN):: COORD
      INTEGER, DIMENSION(NDOFDIM, NP), INTENT(IN):: ID
      REAL*8, DIMENSION(NEQ), INTENT(IN):: UTMASDT
      
      REAL*8, DIMENSION(NP, 2):: UT
C
C
      UT=0.0D0
C
      K=1
C
      DO I=1, NP
        DO J=1, 2
            IF (ID(J,I)>0) THEN
                UT(I,J)=UTMASDT(K)
                K=K+1
            END IF
        END DO
      END DO
C
      CC="this is a test file with scalar field defined at the points"
C
C   LEE LOS DATOS GENERALES DEL PROBLEMA
C
      NPOLY="vtk/Body_T"
C
      WRITE(B,'(I0)') NTIEMPO
C
      NOMBRE=TRIM(NPOLY)//TRIM(B)//TRIM(EXTENSION)
      OPEN(70,FILE=NOMBRE)
C
C     INICIA A LLENAR EL ARCHIVO
C
C     ESCRIBE LAS 1AS LINES DEL FORMATO VTK
C
      WRITE(70,'(A)') AA
      WRITE(70,'(A, /A)') CC
      WRITE(70,'(A)') DD
      WRITE(70,'(A)') EE
      WRITE(II,'(I0)') NP
C
      HH=FF//II//" DOUBLE"
C
      WRITE(70,'(A, /A)') HH
C
C
      DO J=1, NP
C
        DESPX=UT(J,1)
        DESPY=UT(J,2)
C
C    WRITE(70,'(3F10.6)') COORD(1, J)+DESPX/10.0D0, COORD(2, J)+DESPY/10.0D0, 0.0D0
        WRITE(70,'(3F11.6)') COORD(1, J), COORD(2, J), 0.0D0
C
      END DO
C
C
      WRITE(70,'(A)') ""
      WRITE(II,'(I0)') NELE
      WRITE(JJ,'(I0)') NELE*5
      HH=GG//TRIM(II)//" "//JJ
      WRITE(70,'(A)')TRIM(HH)
C
C
      DO J=1, NELE
C
        WRITE(70,'(1I2, 4I8)') 4, MIE(3,J)-1, MIE(4,J)-1, 
     1                             MIE(2,J)-1, MIE(1, J)-1
C
      END DO
C
C
      WRITE(70,'(A)')""
      WRITE(II,'(I0)') NP
      HH=LL//TRIM(II)
      WRITE(70,'(A)') TRIM(HH)
      WRITE(70,'(A)') MM
      WRITE(70,'(A)') NN
C
C
      DO J=1, NP
C
        DESPX=DSQRT(UT(J,1)**2+UT(J,2)**2)

        WRITE(70,'(1F11.6)') DESPX
C
      END DO
C
C
      CLOSE(70)
C
      RETURN
C
C
      END SUBROUTINE
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C              PROGRAMA PARA GENERAR ARCHIVOS PARA PARAVIEW                   C
C                      PARA ELEMENTOS DE 8 NODOS                              C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C
      SUBROUTINE VTK_8NODES(NP, NELE, NEQ, NDOFDIM, NTIEMPO, COORD,
     1                      MIE, ID, UTMASDT)
C
      IMPLICIT NONE
C
      CHARACTER (25) :: NOMBRE
      CHARACTER (13) :: NPOLY
C
      CHARACTER (4) :: EXTENSION=".vtk"
      CHARACTER (5) :: B

      INTEGER I, J, K, L, W, KK
C
      INTEGER, INTENT(IN):: NP
      INTEGER, INTENT(IN):: NELE
      INTEGER, INTENT(IN):: NEQ
      INTEGER, INTENT(IN):: NDOFDIM
      INTEGER, INTENT(IN):: NTIEMPO
C
      REAL*8 MAGNITUD
C
      INTEGER, DIMENSION(8,NELE), INTENT(IN):: MIE 
      CHARACTER*3 IMP
      REAL*8 juan
      REAL*8 DESPX, DESPY
      REAL*8, DIMENSION(NDOFDIM, NP), INTENT(IN):: COORD
      INTEGER, DIMENSION(NDOFDIM, NP), INTENT(IN):: ID
      REAL*8, DIMENSION(NEQ), INTENT(IN):: UTMASDT
      
      REAL*8, DIMENSION(NP, 2):: UT
C
C
      UT=0.0D0
C
      K=1
C
      DO I=1, NP
        DO J=1, 2
            IF (ID(J,I)>0) THEN
                UT(I,J)=UTMASDT(K)
                K=K+1
            END IF
        END DO
      END DO
C
C   LEE LOS DATOS GENERALES DEL PROBLEMA
C
      NPOLY="vtk/Body_T"
C
      WRITE(B,'(I0)') NTIEMPO
C
      NOMBRE=TRIM(NPOLY)//TRIM(B)//TRIM(EXTENSION)
      OPEN(70,FILE=NOMBRE)


      WRITE(70,'(A28)') "# vtk DataFile Version 4.3.1"
      WRITE(70,*) ""
      WRITE(70,'(A5)') "ASCII"
      WRITE(70,'(A25)') "DATASET UNSTRUCTURED_GRID"
      WRITE(70,*) "POINTS",NP,"float"
      WRITE(70,*) ""

      DO J=1, NP

        DESPX=UT(J,1)
        DESPY=UT(J,2)

c        WRITE(70,'(3F10.6)') COORD(1, J)+DESPX/10.0D0, 
c     1                       COORD(2, J)+DESPY/10.0D0, 0.0D0
        WRITE(70,'(3F11.6)') COORD(1, J), COORD(2, J), 0.0D0

      END DO

      WRITE(70,*) ""

      WRITE(70,*) "CELLS", NELE, NELE*9

      DO I=1,NELE
        WRITE(70,'(1I3,8I8)') 8, MIE(:,I)-1
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "CELL_TYPES",NELE
      DO I=1,NELE
        WRITE(70,'(I2.2)') 23
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "POINT_DATA",NP
cc      WRITE(70,'(A7,A6,A6)') "VECTORS","DESPL","float"

      WRITE(70,*) "SCALARS displacement double"
      WRITE(70,*) "LOOKUP_TABLE default"


cc      DO I=1,NP
cc        WRITE(70,'(3F12.8)') UT(I,1)/10.0D0, UT(I,2)/10.0D0, 0.0
cc      END DO

      DO J=1, NP
C
        DESPX=DSQRT(UT(J,1)**2+UT(J,2)**2)

        WRITE(70,'(1F11.6)') DESPX
C
      END DO


      CLOSE(70)
      
      RETURN
C
C
      END SUBROUTINE
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C              PROGRAMA PARA GENERAR ARCHIVOS PARA PARAVIEW                   C
C                      PARA ELEMENTOS DE 8 NODOS                              C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C
      SUBROUTINE VTK_9NODES(NP, NELE, NEQ, NDOFDIM, NTIEMPO, COORD,
     1                      MIE, ID, UTMASDT)
C
      IMPLICIT NONE
C
      CHARACTER (25) :: NOMBRE
      CHARACTER (13) :: NPOLY
C
      CHARACTER (4) :: EXTENSION=".vtk"
      CHARACTER (5) :: B

      INTEGER I, J, K, L, W, KK
C
      INTEGER, INTENT(IN):: NP
      INTEGER, INTENT(IN):: NELE
      INTEGER, INTENT(IN):: NEQ
      INTEGER, INTENT(IN):: NDOFDIM
      INTEGER, INTENT(IN):: NTIEMPO
C
      REAL*8 MAGNITUD
C
      INTEGER, DIMENSION(9,NELE), INTENT(IN):: MIE 
      CHARACTER*3 IMP
      REAL*8 juan
      REAL*8 DESPX, DESPY
      REAL*8, DIMENSION(NDOFDIM, NP), INTENT(IN):: COORD
      INTEGER, DIMENSION(NDOFDIM, NP), INTENT(IN):: ID
      REAL*8, DIMENSION(NEQ), INTENT(IN):: UTMASDT
      
      REAL*8, DIMENSION(NP, 2):: UT
C
C
      UT=0.0D0
C
      K=1
C
      DO I=1, NP
        DO J=1, 2
            IF (ID(J,I)>0) THEN
                UT(I,J)=UTMASDT(K)
                K=K+1
            END IF
        END DO
      END DO
C
C   LEE LOS DATOS GENERALES DEL PROBLEMA
C
      NPOLY="vtk/Body_T"
C
      WRITE(B,'(I0)') NTIEMPO
C
      NOMBRE=TRIM(NPOLY)//TRIM(B)//TRIM(EXTENSION)
      OPEN(70,FILE=NOMBRE)


      WRITE(70,'(A28)') "# vtk DataFile Version 4.3.1"
      WRITE(70,*) ""
      WRITE(70,'(A5)') "ASCII"
      WRITE(70,'(A25)') "DATASET UNSTRUCTURED_GRID"
      WRITE(70,*) "POINTS",NP,"float"
      WRITE(70,*) ""

      DO J=1, NP

        DESPX=UT(J,1)
        DESPY=UT(J,2)

c        WRITE(70,'(3F10.6)') COORD(1, J)+DESPX/10.0D0, 
c     1                       COORD(2, J)+DESPY/10.0D0, 0.0D0
        WRITE(70,'(3F11.6)') COORD(1, J), COORD(2, J), 0.0D0

      END DO

      WRITE(70,*) ""

      WRITE(70,*) "CELLS", NELE, NELE*10

      DO I=1,NELE
        WRITE(70,'(1I3,9I8)') 9, MIE(:,I)-1
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "CELL_TYPES",NELE
      DO I=1,NELE
        WRITE(70,'(I2.2)') 28
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "POINT_DATA",NP
cc      WRITE(70,'(A7,A6,A6)') "VECTORS","DESPL","float"

      WRITE(70,*) "SCALARS displacement double"
      WRITE(70,*) "LOOKUP_TABLE default"


cc      DO I=1,NP
cc        WRITE(70,'(3F12.8)') UT(I,1)/10.0D0, UT(I,2)/10.0D0, 0.0
cc      END DO

      DO J=1, NP
C
        DESPX=DSQRT(UT(J,1)**2+UT(J,2)**2)

        WRITE(70,'(1F11.6)') DESPX
C
      END DO


      CLOSE(70)
      
      RETURN
C
C
      END SUBROUTINE









C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C              PROGRAMA PARA GENERAR ARCHIVOS PARA PARAVIEW                   C
C                      PARA ELEMENTOS DE 8 NODOS                              C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C
      SUBROUTINE VTK_8NODES3D(NP, NELE, NEQ, NDOFDIM, NTIEMPO, COORD,
     1                      MIE, ID, UTMASDT)
C
      IMPLICIT NONE
C
      CHARACTER (25) :: NOMBRE
      CHARACTER (13) :: NPOLY
C
      CHARACTER (4) :: EXTENSION=".vtk"
      CHARACTER (5) :: B

      INTEGER I, J, K, L, W, KK
C
      INTEGER, INTENT(IN):: NP
      INTEGER, INTENT(IN):: NELE
      INTEGER, INTENT(IN):: NEQ
      INTEGER, INTENT(IN):: NDOFDIM
      INTEGER, INTENT(IN):: NTIEMPO
C
      REAL*8 MAGNITUD
C
      INTEGER, DIMENSION(8,NELE), INTENT(IN):: MIE 
      CHARACTER*3 IMP
      REAL*8 juan
      REAL*8 DESPX, DESPY, DESPZ
      REAL*8, DIMENSION(NDOFDIM, NP), INTENT(IN):: COORD
      INTEGER, DIMENSION(NDOFDIM, NP), INTENT(IN):: ID
      REAL*8, DIMENSION(NEQ), INTENT(IN):: UTMASDT
      
      REAL*8, DIMENSION(NP, 3):: UT
C
C
      UT=0.0D0
C
      K=1
C
      DO I=1, NP
        DO J=1, 3
            IF (ID(J,I)>0) THEN
                UT(I,J)=UTMASDT(K)
                K=K+1
            END IF
        END DO
      END DO
C
C   LEE LOS DATOS GENERALES DEL PROBLEMA
C
      NPOLY="vtk/Body_T"
C
      WRITE(B,'(I0)') NTIEMPO
C
      NOMBRE=TRIM(NPOLY)//TRIM(B)//TRIM(EXTENSION)
      OPEN(70,FILE=NOMBRE)


      WRITE(70,'(A28)') "# vtk DataFile Version 4.3.1"
      WRITE(70,*) ""
      WRITE(70,'(A5)') "ASCII"
      WRITE(70,'(A25)') "DATASET UNSTRUCTURED_GRID"
      WRITE(70,*) "POINTS",NP,"float"
      WRITE(70,*) ""

      DO J=1, NP

        DESPX=UT(J,1)
        DESPY=UT(J,2)
        DESPZ=UT(J,3)

c        WRITE(70,'(3F10.6)') COORD(1, J)+DESPX/10.0D0, 
c     1                       COORD(2, J)+DESPY/10.0D0, 0.0D0
        WRITE(70,'(3F11.6)') COORD(1, J), COORD(2, J), COORD(3, J)

      END DO

      WRITE(70,*) ""

      WRITE(70,*) "CELLS", NELE, NELE*9

      DO I=1,NELE
        WRITE(70,'(1I3,9I8)') 8, MIE(:,I)-1
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "CELL_TYPES",NELE
      DO I=1,NELE
        WRITE(70,'(I2.2)') 12
      END DO
      WRITE(70,*) ""

      WRITE(70,*) "POINT_DATA",NP
cc      WRITE(70,'(A7,A6,A6)') "VECTORS","DESPL","float"

      WRITE(70,*) "SCALARS displacement double"
      WRITE(70,*) "LOOKUP_TABLE default"


cc      DO I=1,NP
cc        WRITE(70,'(3F12.8)') UT(I,1)/10.0D0, UT(I,2)/10.0D0, 0.0
cc      END DO

      DO J=1, NP
C
        DESPX=DSQRT(UT(J,1)**2+UT(J,2)**2+UT(J,3)**2)

        WRITE(70,'(1F11.6)') DESPX
C
      END DO


      CLOSE(70)
      
      RETURN
C
C
      END SUBROUTINE


CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C              PROGRAMA PARA GENERAR ARCHIVOS PARA PARAVIEW                   C
C                      PARA ELEMENTOS DE 9 Y 6 NODOS                          C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C
C23456789012345678901234567890123456789012345678901234567890123456789012
C
      SUBROUTINE VTK_6_9NODES(NP, NELE, NEQ, NDOFDIM, NTIEMPO, COORD,
     1                      MIE, ELETYPE, ID, UTMASDT)
C
      IMPLICIT NONE
C
      CHARACTER (25) :: NOMBRE
      CHARACTER (13) :: NPOLY
C
      CHARACTER (4) :: EXTENSION=".vtk"
      CHARACTER (5) :: B

      INTEGER I, J, K, L, W, KK
      INTEGER NTR, NREC
C
      INTEGER, INTENT(IN):: NP
      INTEGER, INTENT(IN):: NELE
      INTEGER, INTENT(IN):: NEQ
      INTEGER, INTENT(IN):: NDOFDIM
      INTEGER, INTENT(IN):: NTIEMPO
C
      REAL*8 MAGNITUD
C
      INTEGER, DIMENSION(9,NELE), INTENT(IN):: MIE
      INTEGER, DIMENSION(NELE), INTENT(IN):: ELETYPE 
      CHARACTER*3 IMP
      REAL*8 juan
      REAL*8 DESPX, DESPY
      REAL*8, DIMENSION(NDOFDIM, NP), INTENT(IN):: COORD
      REAL*8, DIMENSION(NEQ), INTENT(IN):: UTMASDT
      INTEGER, DIMENSION(NDOFDIM, NP), INTENT(IN):: ID
      
      REAL*8, DIMENSION(NP, 2):: UT

	  NTR=0
	  NREC=0

	  DO I=1, NELE
	  	IF(ELETYPE(I)==6) THEN
	  		NTR=NTR+1
	  	ELSE
	  		NREC=NREC+1
	  	END IF
	  END DO

      UT=0.0D0

      K=1

      DO I=1, NP
        DO J=1, 2
            UT(I,J)=UTMASDT(K)
            K=K+1
        END DO
      END DO

C   LEE LOS DATOS GENERALES DEL PROBLEMA

      NPOLY="vtk/Body_T"

      WRITE(B,'(I0)') NTIEMPO

      NOMBRE=TRIM(NPOLY)//TRIM(B)//TRIM(EXTENSION)
      OPEN(70,FILE=NOMBRE)


      WRITE(70,'(A28)') "# vtk DataFile Version 4.3.1"
      WRITE(70,*) ""
      WRITE(70,'(A5)') "ASCII"
      WRITE(70,'(A25)') "DATASET UNSTRUCTURED_GRID"
      WRITE(70,*) "POINTS",NP,"float"
      WRITE(70,*) ""

      DO J=1, NP

        DESPX=UT(J,1)
        DESPY=UT(J,2)

c        WRITE(70,'(3F10.6)') COORD(1, J)+DESPX/10.0D0, 
c     1                       COORD(2, J)+DESPY/10.0D0, 0.0D0
        WRITE(70,'(3F12.8)') COORD(1, J), COORD(2, J), 0.0D0

      END DO

      WRITE(70,*) ""

      WRITE(70,*) "CELLS", NELE, NTR*7+NREC*10	!NELE*10

	  J=0
      DO I=1,NTR
      	J=J+1
        WRITE(70,'(1I2,6I7)') 6, MIE(1:6,I)-1
      END DO
      
      DO I=1,NREC
      	J=J+1
        WRITE(70,'(1I2,9I7)') 9, MIE(:,J)-1
      END DO
      
      WRITE(70,*) ""

      WRITE(70,*) "CELL_TYPES", NELE
      
      DO I=1,NTR
        WRITE(70,'(I2.2)') 22
      END DO
      
      DO I=1,NREC
        WRITE(70,'(I2.2)') 28
      END DO
      
      WRITE(70,*) ""

      WRITE(70,*) "POINT_DATA",NP
cc      WRITE(70,'(A7,A6,A6)') "VECTORS","DESPL","float"

      WRITE(70,*) "SCALARS displacement double"
      WRITE(70,*) "LOOKUP_TABLE default"


cc      DO I=1,NP
cc        WRITE(70,'(3F12.8)') UT(I,1)/10.0D0, UT(I,2)/10.0D0, 0.0
cc      END DO

      DO J=1, NP
C
        DESPX=DSQRT(UT(J,1)**2+UT(J,2)**2)

        WRITE(70,'(1F10.6)') DESPX
C
      END DO

      CLOSE(70)
      
      RETURN

      END SUBROUTINE

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

      SUBROUTINE IMPISTOUT3D(NIMP,ISTOUT,NEQ,NDOFDIM,NUMNP,ID,
     1						 UTMINT,UT,UTMAST,IDISP,IVEL,IACEL,DT)

      IMPLICIT REAL*8(A-H,O-Z)
      
      DIMENSION ID(NDOFDIM,NUMNP),ISTOUT(NIMP),UTMAST(NEQ),
     1			UTMINT(NEQ), UT(NEQ)


      UX=0.0D0
      UY=0.0D0
      UZ=0.0D0

	  UVELX=0.0D0
	  UVELY=0.0D0
	  UVELZ=0.0D0
	  
	  UACELX=0.0D0
	  UACELY=0.0D0
	  UACELZ=0.0D0

      DO I=1, NIMP
        J=ISTOUT(I)
        II=ID(1,J)
        JJ=ID(2,J)
        KK=ID(3,J)

        IF (II.NE.0) THEN
            UX=UTMAST(II)
            UVELX= 1.0D0/(2.0D0*DT)*(-UTMINT(II)+UTMAST(II))
            UACELX=1.0D0/(DT**2)*(UTMINT(II)-2.0D0*UT(II)+UTMAST(II))
        END IF

        IF (JJ.NE.0) THEN
            UY=UTMAST(JJ)
            UVELY= 1.0D0/(2.0D0*DT)*(-UTMINT(JJ)+UTMAST(JJ))
            UACELY=1.0D0/(DT**2)*(UTMINT(JJ)-2.0D0*UT(JJ)+UTMAST(JJ))
        END IF

        IF (KK.NE.0) THEN
            UZ=UTMAST(KK)
            UVELZ= 1.0D0/(2.0D0*DT)*(-UTMINT(KK)+UTMAST(KK))
            UACELZ=1.0D0/(DT**2)*(UTMINT(KK)-2.0D0*UT(KK)+UTMAST(KK))
        END IF

        WRITE(IDISP,'(3F12.6)') UX, UY, UZ
        WRITE(IVEL,'(3F12.6)') UVELX, UVELY, UVELZ
        WRITE(IACEL,'(3F12.6)') UACELX, UACELY, UACELZ

      UX=0.0D0
      UY=0.0D0
      UZ=0.0D0

	  UVELX=0.0D0
	  UVELY=0.0D0
	  UVELZ=0.0D0
	  
	  UACELX=0.0D0
	  UACELY=0.0D0
	  UACELZ=0.0D0

      END DO

      RETURN

      END SUBROUTINE



CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

      SUBROUTINE IMPISTOUT2D(NIMP,ISTOUT,NEQ,NDOFDIM,NUMNP,ID,
     1						 UTMINT,UT,UTMAST,IDISP,IVEL,IACEL,DT)

      IMPLICIT REAL*8(A-H,O-Z)
      
      DIMENSION ID(NDOFDIM,NUMNP),ISTOUT(NIMP),UTMAST(NEQ),
     1			UTMINT(NEQ), UT(NEQ)

C     OJO QUE ACÁ ESTÁ AMARRADO A 2 GRADOS DE LIBERTAD POR NODO

      UX=0.0D0
      UY=0.0D0

	  UVELX=0.0D0
	  UVELY=0.0D0
	  
	  UACELX=0.0D0
	  UACELY=0.0D0

      DO I=1, NIMP
        J=ISTOUT(I)
        II=ID(1,J)
        JJ=ID(2,J)

        IF (II.NE.0) THEN
            UX=UTMAST(II)
            UVELX= 1.0D0/(2.0D0*DT)*(-UTMINT(II)+UTMAST(II))
            UACELX=1.0D0/(DT**2)*(UTMINT(II)-2.0D0*UT(II)+UTMAST(II))
        END IF

        IF (JJ.NE.0) THEN
            UY=UTMAST(JJ)
            UVELY= 1.0D0/(2.0D0*DT)*(-UTMINT(JJ)+UTMAST(JJ))
            UACELY=1.0D0/(DT**2)*(UTMINT(JJ)-2.0D0*UT(JJ)+UTMAST(JJ))
        END IF

        WRITE(IDISP,'(2F12.6)') UX, UY
        WRITE(IVEL,'(2F12.6)') UVELX, UVELY
        WRITE(IACEL,'(2F12.6)') UACELX, UACELY

        UX=0.0D0
        UY=0.0D0

	  	UVELX=0.0D0
        UVELY=0.0D0

	  	UACELX=0.0D0
        UACELY=0.0D0

      END DO

      RETURN

      END SUBROUTINE



CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC

	  SUBROUTINE ELAPSED(T3, KINC)
	  
	  IMPLICIT REAL*8(A-H,O-Z)
	  
	  REAL*8  ELAPSED_TIME
      INTEGER T3, T4, CLOCK_RATE, KINC
      REAL*8 SEC, MINU, HOR
      INTEGER MINUI, HORI
      
      
	  CALL SYSTEM_CLOCK(T4, CLOCK_RATE)
   
      ELAPSED_TIME = FLOAT(T4 - T3) / FLOAT(CLOCK_RATE)
	  
	  HOR=  ELAPSED_TIME/3600.0D0
	  HORI= INT(HOR)
	  MINU= (HOR-HORI)*60.0D0
	  MINUI= INT(MINU)
	  SEC=  (MINU-MINUI)*60.D0
	  
      WRITE(*,'(1A12,1I16,1A16,1I5,1A7,1I3,1A8,1F6.2,1A9)') 
     1								'Increment: ', KINC, 
     2 								'Elapsed time: ', 
     3                              HORI, 'hours',
     4								MINUI, 'minutes',
     5								SEC, 'seconds'

	  RETURN
	  
	  END SUBROUTINE

















































c        END MODULE POSTPROC
