>
> I have a set of output subroutines in a F90 program.
> At the moment they are called like this:
>
> call Output_Str( "My name is Reynold" )
> call Output_StrInt( "My age is", 21 )
> call Output_StrReal( "My shoe size is",9.5 )
>
> They cry out for a common interface such as:
>
> interface Output
> module procedure Output_Str
> module procedure Output_StrInt
> module procedure Output_StrReal
> end interface
>
> but this can't be done because the length of the string arguments to my
> output subroutines are known only at run-time
>
This does not matter. A valid Fortran 90 code is appended. It
produces the output:
Hello
First integer: 5
Now second integer: 15
John Reid.
.......................
module outp
interface Output
module procedure Output_Str
module procedure Output_StrInt
end interface
contains
subroutine Output_Str(txt)
character(len=*) :: txt
write(6,'(a)') txt
end subroutine Output_Str
subroutine Output_StrInt(txt,i)
character(len=*) :: txt
integer :: i
write(6,'(a,i5)') txt,i
end subroutine Output_StrInt
end module outp
program main
use outp
call Output('Hello')
call Output('First integer:',5)
call Output('Now second integer:',15)
end program main
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|