[net.lang.f77] constant expressions in f77

sundman@ttds.UUCP (Bo Sundman) (12/13/84)

I am trying to convert a large (30000 lines) fortran-77 program to
UNIX environment. To start I have some problems about declarations:
(1)     PARAMETER (K1=10,K2=2*K1) is not accepted.
(2)     PARAMETER (KZ=2**K1)      is not accepted.
(3)     CHARACTER LINE*(2*K1)     is not accepted.
The error message from the compiler indicates that f77 do not
accept these as contant expressions.
It thus seems that constant expressions is very restricted. 
These constructions works on all other f77 compilers I have tried and
I am very dependent upon them (there are a few 1000 places to change
othrewise because I use this to dimension arrays etc.)
I there any way to solve this problem?

-- 
        Bo Sundman                      (..mcvax!enea!ttds!sundman)
        Thermo-Calc group, Division of Physical Metallurgy
        Royal Institute of Technology, Stockholm, Sweden

west@sdcsla.UUCP (Larry West) (12/21/84)

In article <758@ttds.UUCP> sundman@ttds.UUCP (Bo Sundman) writes:
>I am trying to convert a large (30000 lines) fortran-77 program to
>UNIX environment. To start I have some problems about declarations:
>(1)     PARAMETER (K1=10,K2=2*K1) is not accepted.
>(2)     PARAMETER (KZ=2**K1)      is not accepted.
>(3)     CHARACTER LINE*(2*K1)     is not accepted.
>The error message from the compiler indicates that f77 do not
>accept these as contant expressions.
>It thus seems that constant expressions is very restricted. 
> {...}

Strange.   I tried the following file on both Sun and Vax, each
with (pretty much identical) 4.2bsd "f77".   As poor as that compiler
may be, the only complaint it gives me is:
	Warning on line 8 of foo.f: local variable line never used

Here's the file:
	PARAMETER ( FOO = 7 )
	parameter ( FOOD = FOO+5 )
	parameter ( K1 = 10, K2 = 2*K1 )
	parameter ( KZ = 2**K1 )
	character line*(2*K1)

	stop
	end
Can't imagine why your "f77" complains... what UNIX are you running?

-- 

--|  Larry West, UC San Diego, Institute for Cognitive Science
--|  UUCP:	{decvax!ucbvax,ihnp4}!sdcsvax!sdcsla!west
--|  ARPA:	west@NPRDC	{ NOT: <sdcsla!west@NPRDC> }

pmontgom@sdcrdcf.UUCP (Peter Montgomery) (01/06/85)

> I am trying to convert a large (30000 lines) fortran-77 program to
> .UNIX environment. To start I have some problems about declarations:
> (1)     PARAMETER (K1=10,K2=2*K1) is not accepted.
> (2)     PARAMETER (KZ=2**K1)      is not accepted.
> (3)     CHARACTER LINE*(2*K1)     is not accepted.
> The error message from the compiler indicates that f77 do not
> accept these as contant expressions.
> It thus seems that constant expressions is very restricted.
> These constructions works on all other f77 compilers I have tried and
> I am very dependent upon them (there are a few 1000 places to change
> othrewise because I use this to dimension arrays etc.)
> I there any way to solve this problem?

I had this trouble too.  It occurred only when using the optimizer.
I am told the problem is fixed in the latest version of f77.
-- 
			Peter Montgomery

	{aero,allegra,bmcg,burdvax,hplabs,
	 ihnp4,psivax,randvax,sdcsvax,trwrb}!sdcrdcf!pmontgom

Don't blame me for the crowded freeways - I don't drive.