# Julia autodiff result exporting to Fortran

**URL:** <https://discourse.julialang.org/t/julia-autodiff-result-exporting-to-fortran/87053>\
**Category:** General Usage\
**Created:** [September 10, 2022, 8:54pm UTC](https://discourse.julialang.org/t/julia-autodiff-result-exporting-to-fortran/87053 "2022-09-10T20:54:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![congUoM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/conguom/32/10413_2.png) [@congUoM](https://discourse.julialang.org/u/congUoM)\
**Post date:** [September 10, 2022, 8:54pm UTC](https://discourse.julialang.org/t/julia-autodiff-result-exporting-to-fortran/87053/1 "2022-09-10T20:54:00Z")

</div>

Hi all,

I am working on an optimization problem in Fortran and I need a gradient of a function. Fortran does not have a good autodiff library so I am thinking of writing the Fortran function in Julia, using Julia autodiff to generate the gradient and exporting the autodiff result back to Fortran to be used. Has anyone done something like this before? And willing to share your experience?

Thanks!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [September 10, 2022, 8:57pm UTC](https://discourse.julialang.org/t/julia-autodiff-result-exporting-to-fortran/87053/2 "2022-09-10T20:57:25Z")

</div>

This might work, but is there a good reason not to do the optimization in Julia as well? This would likely be a bunch easier.

---

<div class="post-metadata">

**Author:** ![congUoM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/conguom/32/10413_2.png) [@congUoM](https://discourse.julialang.org/u/congUoM)\
**Post date:** [September 10, 2022, 9:11pm UTC](https://discourse.julialang.org/t/julia-autodiff-result-exporting-to-fortran/87053/3 "2022-09-10T21:11:16Z")

</div>

I’d love to. Unfortunately, it’s part of a huge Fortran library/system which will be tough to be re-written in Julia, at least in the short term.
