j3-fortran / generics

BSD 3-Clause "New" or "Revised" License
38 stars 8 forks source link

Automatic differentiation & generics #45

Open ivan-pi opened 2 years ago

ivan-pi commented 2 years ago

Has there been any discussion of the usage case of automatic differentiation (AD) in relation to generics?

Related issues:

Given how important AD is in the Julia ecosystem, I think a discussion of AD would also be warranted.

There are several (forward-mode) Fortran AD libraries relying upon derived types and operator/procedure overloading, which would be easier to develop if some smart generic features were available.

tclune commented 2 years ago

No - this has not been directly discussed in the generics subgroup. Clearly it is a very important application, and we would not want to miss the opportunity to ensure that whatever facility is deployed could address such use cases.

Could you possibly elaborate on what aspects of AD that you think may not derive naturally from other use cases? I know that is a possibly a very open ended question, but we need to start somewhere. I am only superficially aware of this topic, and have never done any direct work. E.g., my org has employed commercial AD software, but my understanding is that this package takes in source code as an input and generates source code as an output.

I glanced through the referenced threads, but don't have time at the moment for a deeper dive. The one bit I could more readily absorb (https://sourceforge.net/p/flibs/svncode/HEAD/tree/trunk/src/computing/automdiff.f90) is a bit easier to grok with a quick glance. I can easily imagine such an implementation becoming a template where rather than assuming REAL everywhere, would accept any TYPE that supports the necessary operators. To that extent, the existing plans for generics should be sufficient.

I can also offer you the opportunity to give a short presentation at one of our (mostly) weekly generics subgroup telecons. That could enable some back-and-forth and rapid capture.