Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!samsung!spool.mu.edu!agate!stanford.edu!unixhub!slacvm!kencb From: KENCB@SLACVM.SLAC.STANFORD.EDU Newsgroups: comp.lang.fortran Subject: Re: A Q of constants Message-ID: <91143.213654KENCB@SLACVM.SLAC.STANFORD.EDU> Date: 24 May 91 05:36:54 GMT References: <1991May24.111123.8396@cc.curtin.edu.au> Organization: Stanford Linear Accelerator Center Lines: 50 In article <1991May24.111123.8396@cc.curtin.edu.au>, tlynchmj@cc.curtin.edu.au says: >I want an array of characters to be initialiized as constants at compile time >and it has to be ANSI standard, more specifically, it must compile under >VAX-VMS F77 with the /STANDARD option invoked. > >I tried this... > > CHARACTER SYMS(6) > PARAMETER (SYMS = 'abcdef') > >which gave me a 'symbol to big for constant' or something like that error. >Then I tried this... > > CHARACTER SYMS(6) > PARAMETER (SYMS(1) = 'a', > + SYMS(2) = 'b', > The trouble is you're trying to define an ARRAY as a PARAMETER. You can't in Fortran 77 (though I greatly wish one could :-). Here's a simple test program that compiles under VAX Fortran with the /STANDARD qualifier and gives you three alternatives for what it appears you want to do (excuse the non-standard mixed-case source ;-) -------------------------------------------------------------------------- Program Test Character c0(6) Character*6 c1 Character*6 c2 Parameter (c2 = 'abcdef') Data c1 /'abcdef'/ Data c0 /'a','b','c','d','e','f'/ Write (6,'(X,6A/X,A/X,A)') (c0(i),i=1,6),c1,c2 Stop End -------------------------------------------------------------------- Only the PARAMETER form gives you "an array of constants", and it's not strictly an array. However the standard Fortran 77 character handling allows indexing into character strings which is nearly the same, e.g. use C2(3:3) instead of C2(3). -Ken Dr. Kenneth H. Fairfield Internet: Fairfield@Tpc.Slac.Stanford.Edu SLAC, P.O.Box 4349, Bin 98 DECnet: 45047::FAIRFIELD (TPC::) Stanford, CA 94309 BITNET Fairfield@SlacTpc "These opinions are worth what you paid for 'em... ...and they are mine, not SLAC's, Stanford's, nor the DOE's..."