Skip to content
 
O conteúdo desse portal pode ser acessível em Libras usando o VLibras

Professor Diomar Cesar Lobao

Universidade Federal Fluminense-Volta Redonda, RJ, Brasil

Diomar Cesar


Dept. Ciências Exatas - Exact Science Dept.

Search

module.f

c<html>
c<body>
c<pre>
      module assign
c    Modules, unlike COMMON may contain allocatable arrays
c
c<a name="alable"><font color="FF0000">
         real, allocatable :: a(:)
c</font></a>
         integer :: isize=5
      end module
c
      program testmod
      use assign
c
c    By using MODULE to pass information about allocatable arrays
c    we can duck the earlier prohibition against allocating
c    space in a subroutine for use in the main program or
c    other subprograms called by the main program.
c
c      John Mahaffy    4/13/96
c
c
      call sub1
      print *,' Main: Array A is still defined, with values:'
      print *, a
      call sub2
      stop
      end
      subroutine sub1
      use assign
c
c     This subroutine allocates space in array "a" and
c     loads some values
c
c      John Mahaffy    4/13/96
c<a name="all"><font color="FF0000">
      allocate(a(isize))
c</font></a>
      a=(/(i,i=1,isize)/)
      return
      end
      subroutine sub2
      use assign
c
c     This subroutine prints values in array "a" and
c     deallocates space
c
c      John Mahaffy    4/13/96
c
      print *,' Sub2: Array A is still defined, with values:'
      print *, a
c<a name="deall"><font color="FF0000">
      deallocate(a)
c</font></a>
c
c    I can actually get away with the following print, but
c    results are strange.
c
      print *,' After Dealloation of A "print *, a " gives:'
      print *, a
      return
      end
c</pre>
c</body>
c</html>
Conteúdo acessível em Libras usando o VLibras Widget com opções dos Avatares Ícaro, Hosana ou Guga. Conteúdo acessível em Libras usando o VLibras Widget com opções dos Avatares Ícaro, Hosana ou Guga.