Re: pass several filenames to the subroutine




Hi Mike,

Mike wrote:

Hi,

program main

character*80,allocatable :: fname(:)

allocate(fname(3))
fname(1)="a1.dat"
fname(2)="a2.dat"
fname(3)="a3.dat"
print *,fname
call tt(fname)

stop
end

subroutine tt(fname)
character*(*) fname(:)

print *,fname

return
end

After compiled, it shows
"Warning: In the call to TT, actual argument #1 is character valued and
is being passed to a non-character dummy argument."


Well I can only see one thing wrong with this, but if it has triggered the above
error message its not the most helpful compiler to say the least.

To use the colon syntax for a dummy argument you need in interface in scope
at the calling point. So one of the following must hold, otherwise anything
can happen

1) tt is a module procedure ( i.e. in a module )
2) tt is a contained subprogram
3) In the (sub-)program that calls tt there should be in interface block for
tt

Ian

.



Relevant Pages

  • Re: pass several filenames to the subroutine
    ... print *,fname ... error message its not the most helpful compiler to say the least. ... After I put subroutine tt into the module, ... or tt subroutine allocates the same memory? ...
    (comp.lang.fortran)
  • Re: modifying constants
    ... In these expressions: ... and WIBBLE modifies its argument, AND there is no interface block ... to warn the compiler that it might. ...
    (comp.lang.fortran)
  • Re: gfortran bug?
    ... > the pointer attribute needs to be given to the actual argument too ... from the way that I declared it in my interface block. ... It seems that there should be some way to get Fortran ... and compile it with my GNU Fortran 95 compiler: ...
    (comp.lang.fortran)
  • Re: Whats the purpose of explicit interfaces? (Pun intended?)
    ... The declaration ... not the version of Fortran, ... interface block can contain arguments declared to be ... and the compiler knows ...
    (comp.lang.fortran)
  • Re: function as argument
    ... Just what the compiler is telling you -- you have an interface ... mismatch. ... Go back to the interface block for dummy argument f ... result variable f and dummy argument x from real to real. ...
    (comp.lang.fortran)