This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Obsolescent character function (Cygwin)
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Angelo Graziosi <Angelo dot Graziosi at roma1 dot infn dot it>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 11 Sep 2006 16:11:35 -0700
- Subject: Re: Obsolescent character function (Cygwin)
- References: <Pine.OSF.4.21.0609120053390.2930-100000@ax0rm1.roma1.infn.it>
On Tue, Sep 12, 2006 at 01:03:15AM +0200, Angelo Graziosi wrote:
>
> When I build the following simple test case
>
> program prova
> implicit none
> character(len = 10) :: chfun
> write(*,*) chfun(5),chfun(25)
> end program prova
>
> function chfun(x)
> implicit none
> integer :: x
> character(len=*) :: chfun
> write(chfun,'(I10)') x
> end function chfun
>
> with
>
> gfc prova.F95 -o prova
>
> I have:
>
> In file prova.F95:8
>
> function chfun(x)
> 1
> Warning: CHARACTER(*) function 'chfun' at (1) is obsolescent in fortran 95
>
> Why is 'chfun' obsolescent ?
>
>From the Fortran 95 standard (whether gfortran gets this right I
have investigated.)
B.2.5 Assumed character length functions
Assumed character length for functions is an irregularity in the language
since elsewhere in Fortran the philosophy is that the attributes of a
function result depend only on the actual arguments of the invocation and
on any data accessible by the function through host or use association.
Some uses of this facility can be replaced with an automatic character
length function, where the length of the function result is declared in
a specification expression. Other uses can be replaced by the use of a
subroutine whose arguments correspond to the function result and the
function arguments.
Note that dummy arguments of a function may be assumed character length.
--
Steve