PARAMETER statement

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Wed Jan 13 09:20:00 GMT 2010


On 2010-01-13 03:52, Jerry DeLisle wrote:
> On 01/12/2010 06:28 PM, Jerry DeLisle wrote:
>> On 01/12/2010 05:49 PM, David Carr wrote:
>>> I am new to gfortran (tho been programming in Fortran for 35 years on
> --- snip ---
>>
>> In the meantime. This works fine.
>>
>> integer, parameter :: isize=15
>> dimension i(isize)
>> i(1)=0
>> end
>>
>> I will report back after I review the standard on this.
>>
>
> The standards require the parenthesis as follows:
>
> parameter (isize=15)
> dimension i(isize)
> i(1)=0
> end
>
> Also kindly pointed out to me by Steve. :)

This is quite interesting (in the sense that a perverse interests in 
fixed form syntax can be interesting).  The original code given by David,
   parameter isize=15
will be parsed as
   parameterisize=15
according to the rules of fixed form syntax, where spaces are 
immaterial.  I.e. by the standard it's an assignment statement which 
assigns the value 15.0 to an implicitly typed real variable 
'parameterisize'.  This ambiguity is resolved by the requirement for 
parentheses.  There are a few places in Fortran where parentheses are 
needed for exactly this reason.

I'm surprised, the vax compiler would accept this, because this can 
create programs that must be interpreted differently from what the 
standard requires, e.g.

function f
   parameter isize = 5
   f = parameterisize  ! valid by the standard, undefined on vax
end

Regards,
- Tobi
>
> Regards,
>
> Jerry



More information about the Fortran mailing list