Question anout intent(out)
Steve Kargl
sgk@troutmask.apl.washington.edu
Mon Jun 9 18:05:00 GMT 2014
On Mon, Jun 09, 2014 at 07:41:18PM +0200, Dominique Dhumieres wrote:
> Hi all,
>
> Compiling the following code (extracted from SMOKE v3.5) with gfortran
>
> SUBROUTINE RDDATAORLFR( LINE, READDATA, READPOL, NDATPERLN,
> & IYEAR, DESC, SIC, MACT, CTYPE,
> & LAT, LON, HDRFLAG, EFLAG )
>
> integer, parameter :: IOVLEN3 = 3
> CHARACTER(2) CRLF
> INTEGER FINDC
>
> EXTERNAL CRLF, FINDC
> CHARACTER(*), INTENT (IN) :: LINE ! input line
> CHARACTER(*), INTENT (OUT) :: READDATA( NDATPERLN,NPTPPOL3 )! array of data values
> CHARACTER(IOVLEN3), INTENT (OUT) :: READPOL( NDATPERLN ) ! array of pollutant names
> INTEGER, INTENT (OUT) :: NDATPERLN ! number of data values per line
> end
>
> gives the following errors (twice, a bug in itself)
>
> rddatantifr.f:11.51:
>
> CHARACTER(*), INTENT (OUT) :: READDATA( NDATPERLN,NPTPPOL3 )
> 1
> Error: Dummy argument 'ndatperln' at (1) cannot be INTENT(OUT)
> rddatantifr.f:12.52:
>
> CHARACTER(IOVLEN3), INTENT (OUT) :: READPOL( NDATPERLN )
> 1
> Error: Dummy argument 'ndatperln' at (1) cannot be INTENT(OUT)
>
> g95 gives a similar error, but not pgf. AFAIU intent(out) NDATPERLN is
> undefined when entering the subroutine, thus cannot be used as a dimension
> for READDATA and READPOL. Is this correct?
>
>From F2003, 12.4.1.2, p270.
If a nonpointer dummy argument has INTENT (OUT) or INTENT (INOUT),
the actual argument shall be definable. If a dummy argument has
INTENT (OUT), the corresponding actual argument becomes undefined
at the time the association is established, except for components
of an object of derived type for which default initialization has
been specified.
--
steve
More information about the Fortran
mailing list