Re: Find the size of variables in Fortran



Tom Micevski wrote:
> new_to_fortran wrote:
> > Hello All,
> >
> > Is there any library function call similar to C sizeof or strlen to
> > find the size of the values assigned to variables in Fortran 77.
> >
> > For example,
> >
> > CHARACTER*20 greetings
> >
> > greetings = 'Hello World'
> >
> > How do I find the size of the value assigned to character string
> > variable greetings? By declaration, it allocates 20 bytes, but the
> > size(length) of the value assigned to greetings is less than 20
bytes.
> > I'm needing to pass on the size of the variable and the variable
itself
> > as arguments to a C function that I'd like to use from Fortran
program.
>
> len(greetings) = 20
> len_trim(greetings) = 11
>
> but these might be f90 features?

LEN and INDEX were in Fortran 77, but LEN_TRIM was introduced in
Fortran 90 . A list of Fortran 77 intrinsic functions is at Table 5 at
http://www.fortran.com/F77_std/rjcnf-15.html#sh-15 . G77 has LEN_TRIM
as an extension, and some other F77 compilers have similarly-named
extensions. A recent thread here "Little question about FORTRAN
programming" discussed these issues.

.



Relevant Pages

  • Find the size of variables in Fortran
    ... Is there any library function call similar to C sizeof or strlen to ... as arguments to a C function that I'd like to use from Fortran program. ... Prev by Date: ...
    (comp.lang.fortran)
  • Re: Find the size of variables in Fortran
    ... Is there any library function call similar to C sizeof or strlen to ... as arguments to a C function that I'd like to use from Fortran program. ... but these might be f90 features? ...
    (comp.lang.fortran)
  • Re: reporting default integer size
    ... I don't know of anything in the standard that I can even come ... C defines the result of the sizeof operator to be in units ... subtracting two (unsigned char*) pointers to the same object. ... There are a few places Fortran makes requirements on sizes. ...
    (comp.lang.fortran)
  • Re: finding available kind values, precisions and exponent ranges
    ... If my intention was to write a Fortran 95 ... conforming source file, then i add .f95. ... In general, however, most codes written utilize some extension or OS ... If I wan't to put free form F2k8 code in a file ...
    (comp.lang.fortran)
  • Re: finding available kind values, precisions and exponent ranges
    ... If my intention was to write a Fortran 95 ... depend on file extension to determine the processing to perform in any ... If I wan't to put free form F2k8 code in a file ...
    (comp.lang.fortran)