Roland Schilling writes:
> With interest I followed the discussion about Petros' problem, and
> in particular the tricky solution posted by Richard. Would it
> also be possible (and how?), if the length of the resulting
> character string is the outcome of a much more complex character
> function than len_trim? The reason I'm asking is that I've
> written a function to convert numbers into character strings,
> like the internal write, but for special formats, etc., and it
> keeps annoying me that I always have to use this function wrapped
> in a trim command, instead of having the trim integrated into
> the function.
The expression is required to be a specification expression. The
exact requirements for specification expressions are too long for me
to copy here. (And they are a bit hard to read and interpret anyway).
Most of the bits can be roughly summarized by saying that the
expression can only depend on things that will be known on entry to
the procedure - i.e. things like dummy arguments and variables from
COMMON, from USE statements, or from host association. The exact
requirements are fairly complicated.
Perhaps the most fundamental requirement is that you do need to be
able to write it as a single expression. No loops or other multi-line
computations. This can be pretty limiting, even without worrying
about the special requirements of specification expressions.
One of the new features of f95 is that user-written functions are
allowed in specification expressions. This opens up far more
possibities. It is new in f95 and will *NOT* work in f90 (much less
f77). In f90, only intrinsics (like len_trim) could be in
specification expressions (and not all intrinsics were allowed
either). F95 allows some user-written functions. There are pretty
strong restrictions on the kinds of things that can be specification
functions (otherwise it would be trivial to generate infinite
recursions where two specification functions recursively invoke each
other). The functions have to be PURE (which rules out I/O and a
bunch of other stuff. But you don't have to worry about fitting it
all into a single statement.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|