Re: character*1(28) and character*28



On Jun 25, 3:00 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
Lynn McGuire <nos...@xxxxxxxxxx> wrote:
Is there any difference between character*1(28) and character*28 ?

Yes. A huge difference. One is a character string. The other is an
array. I couldn't detail all the many differences that result from this
- there are far too many of them.

If I declare a variable character*28, data it as 'some long string', and
call a subroutine with the arg list declared to be character*1(*), is all OK ?

character*28 astr
data astr / 'some long string' /
call sub1 (astr)

subroutine sub1 (astr)
implicit none
character*1(*) astr

That particular case is ok by a special exception to the argument
passing rules. It did require a special exception. In fact, it is so
special that it applies only to default character kind (and, in f2003,
to the C character kind). Odds are that your compiler doesn't support
any character kinds other than default, so that's a bit of a side point.
I make the side point only to illustrate how special that particular
rule is. Do *NOT* try to generalize the principle to other situations,
because you'll draw the wrong conclusion. This case is an exception to
the usual rules, not an example of the usual rules.

Note, by the way, that your dmmy argument is an assumed-size array. That
has lots of consequences. Mostly the compiler does not know how long it
is. It does *NOT* pick up the dummy array size from the actual argument
length. The * in a dummy argument means different things for a character
string and an array. For a character string, it means assumed length,
which picks up the length from the actual argument. For an array, it
means assumed size, which does not pick up a size from the actual. (And
it is possible to have both at the same time with an assumed-size array
of assumed length string).

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain


Is that legal code? It doesn't compile in AIX. I accidently typed
code like that recently and it wouldn't compile.


.



Relevant Pages

  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • Re: PL/I string representations
    ... >> of the language, so it was interesting to me, hopefully it will be to ... I found a workable compiler for Fortran in 1971 (with a bug ... >> The specified length is the minimum, and each time a character ... >> string is assigned to E, the length is stored with it. ...
    (comp.programming)
  • Re: To "TAB" or not to "TAB"
    ... > negative I want etc. in character strings now in every compiler I'm ... If there is a graphic character in the string, ... that you are saying that the compiler should do no special processing, ...
    (comp.lang.fortran)
  • Re: Check for Common character sequence ( I will pay)?
    ... Do I need to return an array? ... You need to identify character sequences of 3 or more characters that appear ... in more than one string. ... and test each 3-character sequence that results. ...
    (microsoft.public.dotnet.framework)
  • Re: when substring equals string
    ... CHARACTER:: String ... The unit number is attached to a file via an OPEN statement. ... question is about a character variable, ... Like in the way the operator invoked the compiler. ...
    (comp.lang.fortran)