(j3.2006) Irksome not to be able to invoke type-bound function on an expression
Van Snyder
Van.Snyder
Mon Sep 26 21:31:53 EDT 2016
I have a type ECR_t that represents Earth-centered-rotating Cartesian
coordinates as 3-vectors. It has type-bound functions and operators to
add, subtract, scale, compute 2-norm, and other stuff.
I'd like to compute
s = ( ( myP + myH * myP%grad_geoid() - line(1) )%norm2()
but this is prohibited, so I need either to export norm2() as an
ordinary (not type-bound) function and use
s = norm2( myP + myH * myP%grad_geoid() - line(1) )
or
temp = ( ( myP + myH * myP%grad_geoid() - line(1) )
s = temp%norm2()
One particularly important case is function composition. I'd like to
use something like
s = a%f1()%f2()
Is there a good reason we can't eventually allow to invoke a type-bound
function using an expression, and in particular using the result of
another type-bound function?
A related question is whether we can eventually select components from a
function result (or more general expression). I have a function Geod()
bound to ECR_t that computes 3-dimensional geodetic coordinates
(longitude, geodetic latitude, and geodetic height), from
Earth-centered-rotating Cartesian coordinates. The iteration (Either
Bowring's or Fukushima's) that does this necessarily computes both
geodetic latitude and geodetic height. But sometimes all I want is
geodetic latitude. My type H_V_Geod that represents 3-dimensional
geodetic coordinates is an extension of the one H_Geod that represents
only longitude and geodetic latitude.
If I have
type(ECR_t) :: V
type(H_Geod) :: Geod
I can't get the geodetic surface components (longitude and geodetic
latitude) of V using
geod = v%geod()%h_geod
I need something like
type(H_V_Geod) :: Temp
temp = v%geod()
geod = temp%h_geod
Is there a good reason we can't eventually allow to select a component
of an expression?
More information about the J3
mailing list