Re: Character strings and arrays



In article <3s3i0hFlua2fU1@xxxxxxxxxxxxxx>,
"Jugoslav Dujic" <jdujic@xxxxxxxxx> wrote:

> |
> | Given
> | real :: x
> | what is
> | x(1) ?
>
> A syntax error.
>
> However, as Giles pointed out, given character:: string, reference
> to string(1) is NOT a syntax error per se (without implicit none).

I still do not understand what you guys are talking about with
IMPLICIT NONE. The function type is declared explicitly, so
IMPLICIT NONE has no effect at all on the legality or the symantics.

function x(i)
real :: x
integer :: i
x = i*i
end function x
program xxx
implicit none
real :: x
write(*,*) x(1)
end program xxx

As far as I know, the above is a correct, legal, valid, program, and
it does not matter whether IMPLICIT NONE is included or not. If you
change the function to some character function,

function x(i)
character :: x
integer :: i
x = char(ichar('A')+i)
end function x
program xxx
implicit none
character :: x
write(*,*) x(1)
end program xxx

then I think it is still correct, legal, and valid either with or
without IMPLICIT NONE.

Since several posts have now been made with the idea that IMPLICIT
NONE changes the symantics, or makes something legal that would not
otherwise be legal (or visa versa), I conclude that there is simply
something that either my eye, or my compilers, is missing.

$.02 -Ron Shepard
.



Relevant Pages

  • Re: What is wrong with this search for the character PV/PQ
    ... I'd suggest getting rid of the implicit statement in favor of "implicit none" and explicit declarations of variables used in order to minimize accidental type errors and aid the compiler in its efforts to help you write correct code ... This specifies an array of single characters of size 80, not a character string of 80 character length. ... This does read the record into the array, but as you show, you then had to deal w/ each character individually. ...
    (comp.lang.fortran)
  • Re: How to detect NULL input?
    ... > implicit none ... >C CHARACTER(*) evaluateinput ... You need to replace the END program statement by a CONTAINS ...
    (comp.lang.fortran)
  • Re: Type casting of integer to character in fortran
    ... >>IMPLICIT NONE ... >>This outputs equivalent ASCII Character in place of 2. ... >>Whats the way to typecast integer to character? ... > representation of 2 as an integer to the ASCII representation of the ...
    (comp.lang.fortran)
  • Re: Character strings and arrays
    ... || to stringis NOT a syntax error per se (without implicit none). ... | change the function to some character function, ... to declare a "real external function". ...
    (comp.lang.fortran)
  • Re: Script to format file to character number locations?
    ... I'm getting a syntax error on this snippet... ... > I'm trying to write a vb script that will take each cell of an excel row ... > place its text to start at a pre-designated character location. ... > First name starts at char 1 ...
    (microsoft.public.scripting.vbscript)