This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Question anout intent(out)
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Dominique Dhumieres <dominiq at lps dot ens dot fr>
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 9 Jun 2014 11:05:50 -0700
- Subject: Re: Question anout intent(out)
- Authentication-results: sourceware.org; auth=none
- References: <20140609174118 dot 2D049105 at mailhost dot lps dot ens dot fr>
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