Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!lll-winken!ames!skipper!altair!maine From: maine@altair.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.fortran Subject: Re: A Q of constants Message-ID: Date: 24 May 91 14:48:18 GMT References: <1991May24.111123.8396@cc.curtin.edu.au> Sender: news@skipper.dfrf.nasa.gov Organization: NASA Dryden, Edwards, Cal. Lines: 48 In-reply-to: tlynchmj@cc.curtin.edu.au's message of 24 May 91 03:11:22 GMT On 24 May 91 03:11:22 GMT, tlynchmj@cc.curtin.edu.au said: tlynchmj> I have a problem initializing a constant array, can someone tell tlynchmj> me how to do it. tlynchmj> I want an array of characters to be initialiized as tlynchmj> constants at compile time and it has to be ANSI standard, tlynchmj> more specifically, it must compile under VAX-VMS F77 with tlynchmj> the /STANDARD option invoked. tlynchmj> I tried this... tlynchmj> CHARACTER SYMS(6) tlynchmj> PARAMETER (SYMS = 'abcdef') Alas, the ANSI standard does not allow constant arrays. This omission is rectified in Fortran 90, but you are out of luck looking for such in standard Fortran 77. I'm not even sure how common constant arrays are as vendor extensions. Possible workarounds: 1. Use variables initialized with either data statements or executable code. This is aesthetically unappealing (to me anyway), but it is the only workable choice for most cases where I find myself wanting constant arrays. 2. For the particular case of character arrays like the example you cite, you might be able to use a constant character string instead. I can't really tell without seeing how you want to use it. Character strings and character arrays share some simillar ideas, but there are important distinctions. One minor, but possibly relevant distinction is that the standard does allow you to define a constant character string as in CHARACTER SYMS*6 (or alternatively, CHARACTER SYMS*(*)) PARAMETER (SYMS = 'abcdef') Unfortunately, ANSI Fortran 77 does not allow substrings of constant strings (another omission rectified in F90), which may make things awkward, depending on how you want to use SYMS. 3. Nag DEC to get out an F90 compiler soon. -- -- Richard Maine maine@altair.dfrf.nasa.gov