C
C  program 24
C
C  illustrates passing arrays and dimensioning issues
C
C  CWJ SDSU 2/24/2005 
C
C
      program program24

      implicit none

      integer size
      parameter(size = 100)

      integer N

      real wfn(0:size)

      call do_wfn(n,size,wfn)

      call another_wfn(n,wfn)

      end


CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C  subroutine do_wfn(n,dimcheck,array)
C
C  this dummy routine illustrates one way to 
C  dimension arrays
C
C INPUT:
C  n = used dimension of array
C  dimcheck = the physical (declared) dimension of array
C  array = array itself

      subroutine do_wfn(n,dimcheck,array)

      implicit none

      integer mydim
      parameter(mydim=50)

      integer dimcheck   ! used to check consistency
      real array(0:mydim)
    
      integer n


C..........error trap on dimensions..........
C         check for consistency

      if(mydim.ne.dimcheck)then
         print*,' Oops! badly dimensioned '
         return
      endif

      return
      end

CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC        
C
C  subroutine another_wfn(n,dimcheck,array)
C
C  this dummy routine illustrates another way to 
C  dimension arrays
C
C INPUT:
C  n = used dimension of array
C  array = array itself

      subroutine another_wfn(n,array)

      implicit none

      integer n
      real array(0:n)
C  IMPORTANT: you can ONLY do the above IF array is dimensioned in some 
C  higher calling routine (such as the main program)
     


C..........you would do other stuff here

      return
      end

