Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. program main1
  2. use module1
  3. implicit none
  4. integer :: i
  5. real,allocatable :: a(:,:)
  6.  
  7. write(*,*)'Input the size of the square matrix'
  8. read(*,*)i
  9.  
  10. allocate(a(i,i))
  11. a = function1(i)
  12.  
  13. write(*,*) 'The square matrix a='
  14. write(*,*) a
  15.  
  16. deallocate(a)
  17. end program main1
  18.  
  19. module module1
  20.  
  21. contains
  22. function function1(i)
  23. real, allocatable,dimension(:,:) :: function1
  24. integer :: i
  25.  
  26. allocate(function1(i,i))
  27. function1 = 1.0
  28.  
  29. deallocate(function1)
  30. end function function1
  31. end module
  32.  
  33. do j=1,i
  34. write(*,*) a(:,j)
  35. enddo
  36.  
  37. 1.000 1.000 1.000
  38. 1.000 1.000 1.000
  39. 1.000 1.000 1.000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement