title: error #6451: A dummy argument name is required in this context
body: <p>I'm getting a weird error when compiling my simulation code written in Fortran 90, I was hoping to get some help by any chance. I'm using ifort version 18.0.3.</p>
  
  <p>Before telling the problem, here's what I have that are working properly:
  Below <code>module prng</code> is a pseudo-random number generator(it's in fortran 77 but I have tested it just in case any compatibility concerns, it works fine!):</p>
  
  <pre><code>  module prng
  
    implicit none
  
    contains
     real*8 function genrand_real( ir )
     implicit real*8 (a-h,o-z)
  
     integer, intent(inout) :: ir
     parameter(da=16807.d0,db=2147483647.d0,dc=2147483648.d0)
     ir = abs(mod(da*ir,db)+0.5d0)
     genrand_real = dfloat(ir)/dc
  
     return
     end function genrand_real
  
    end module prng
  </code></pre>
  
  <p>I also created a module in order to declare the seed:</p>
  
  <pre><code>  module seed
      implicit none
  
      type mod_seed
  
         integer :: seedvalue
  
      end type mod_seed
    end module seed
  </code></pre>
  
  <p>In order to use seedvalue, <code>type(mod_seed) :: seedval</code> needs to be declared first, then <code>genrand_real(seedval%seedvalue)</code> returns a real value in (0,1).</p>
  
  <p>So far above mentioned are all working fine! Below is what I'm trying to implement, basically I adopted a gaussian deviate function, <code>function gauss_dev() result(harvest)</code>, from Numerical recipes in Fortran (page 280), see the source code below:</p>
  
  <pre><code> module moves
  
    use prng
    use seed
  
    implicit none
  
    contains
  
    function gauss_dev() result(harvest)
  
      implicit none
      real(kind=8) :: harvest
      real(kind=8) :: rsq,v1,v2
      real(kind=8), save :: g
      logical, save :: gauss_stored = .false.
  
      if (gauss_stored) then
          harvest = g
          gauss_stored = .false.
      else
          do
              v1 = genrand_real(seedval%seedvalue)
              v2 = genrand_real(seedval%seedvalue)
              v1 = 2.0*v1-1.0
              v2 = 2.0*v2-1.0
              rsq = v1**2 + v2**2
             if (rsq &gt; 0.0 .and. rsq &lt; 1.0) exit
          enddo
  
          rsq = sqrt(-2.0*log(rsq)/rsq)
          harvest = v1*rsq
          g = v2*rsq
          gauss_stored = .true.
  
      endif
  end function gauss_dev
  
  ! also other subroutines that calls gauss_dev()
  end module moves    
  </code></pre>
  
  <p>The <code>seedval%seedvalue</code> is initialised by</p>
  
  <pre><code>   subroutine read_iseed(seedval,IN_ISEED)
      use prng
      use seed
  
      type (mod_seed), intent(inout) :: seedval
      character(len=80) :: IN_ISEED
      integer :: i
  
      call system('od -vAn -N4 -td4 &lt; /dev/urandom &gt; '//trim(IN_ISEED))
      open(unit=7,file=trim(IN_ISEED),status='old')
      read(7,*) i
      close(7)
      seedval%seedvalue = abs(i)
  
      return
     end
  </code></pre>
  
  <p>When I compile the code, I get an error message: <code>error #6404: This name does not have a type, and must have an explicit type.   [SEEDVAL]</code>, this is expected as the <code>seedvalue</code> must be declared before calling!</p>
  
  <p>Since the <code>seedvalue</code> gets reassigned in <code>prng</code>, intuitively I'd use <code>intent(inout)</code> option. And here's my fix:</p>
  
  <pre><code>  module moves
  
    use prng
    use seed
  
    implicit none
  
    contains
  
    function gauss_dev() result(harvest)
  
      implicit none
      type (mod_seed), intent(inout) :: seedval
      real(kind=8) :: harvest
      real(kind=8) :: rsq,v1,v2
      real(kind=8), save :: g
      logical, save :: gauss_stored = .false.
  
      if (gauss_stored) then
          harvest = g
          gauss_stored = .false.
      else
          do
              v1 = genrand_real(seedval%seedvalue)
              v2 = genrand_real(seedval%seedvalue)
              v1 = 2.0*v1-1.0
              v2 = 2.0*v2-1.0
              rsq = v1**2 + v2**2
             if (rsq &gt; 0.0 .and. rsq &lt; 1.0) exit
          enddo
  
          rsq = sqrt(-2.0*log(rsq)/rsq)
          harvest = v1*rsq
          g = v2*rsq
          gauss_stored = .true.
  
      endif
  end function gauss_dev
  
  ! also other subroutines that calls gauss_dev()
  end module moves    
  </code></pre>
  
  <p>However when I compile the code, I get error message:</p>
  
  <pre><code>  error #6451: A dummy argument name is required in this context.   [SEEDVAL]
      type (mod_seed), intent(inout) :: seedval
  </code></pre>
  
  <p>I'm not certain what caused the error. But as I was randomly trying with <code>intent()</code>options, I accidentally found out that without specifying <code>intent()</code>, the code gets compiled WITHOUT errors, which is weird because I thought without specifying <code>intent()</code>, fortran compiler takes <code>inout</code> as the default option? But as a result of NOT specifying <code>intent()</code>, the simulation gets stuck in the do-loop:</p>
  
  <pre><code>       do
              v1 = genrand_real(seedval%seedvalue)
              v2 = genrand_real(seedval%seedvalue)
              v1 = 2.0*v1-1.0
              v2 = 2.0*v2-1.0
              rsq = v1**2 + v2**2
             if (rsq &gt; 0.0 .and. rsq &lt; 1.0) exit
         enddo
  </code></pre>
  
  <p>because <code>seedval%seedvalue</code> returns 0, which causes <code>rsq</code> constantly failing <code>if (rsq &gt; 0.0 .and. rsq &lt; 1.0) exit</code> condition.</p>
  
  <p>Before posting this thread, I read <a href="https://stackoverflow.com/questions/2880537/fortran-intentinout-versus-omitting-intent">Fortran intent(inout) versus omitting intent</a>, I see the potential compatibility issue out there, but that's introduced since Fortran 2003 according to the thread. </p>
  
  <p>Coming to the end I bear two questions: 1. In fortran 90, is there a difference between specifying <code>intent(inout)</code> and not specifying at all? 
  2. In regard to the error message when specifying <code>intent(inout)</code>, what's the cause of it?  </p>
  
  <p>Any hint would be appreciated!</p>