(j3.2006) Irksome not to be able to invoke type-bound function on an expression

Clune, Thomas L. GSFC-6101 thomas.l.clune
Tue Sep 27 08:11:58 EDT 2016


Damian and I have also expressed interest for capabilities along these lines.   Esp. function composition.

- Tom



> On Sep 26, 2016, at 9:31 PM, Van Snyder <Van.Snyder at jpl.nasa.gov> wrote:
> 
> 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?
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list