Can I justify my PhD if I have mostly adapted existing code instead of writing it myself?
You weren’t earning a PhD in FORTRAN Coding (gasp – I shudder to think of it). You were working in continuum mechanics. That is where your contribution was, and is.
If I read it correctly, you took an existing tool and adapted it for a new purpose. I can’t find anything wrong with that, especially as you cited the creators of the original version. If you keep it up and continue to make contributions to continuum mechanics you will do fine. You didn’t screw up. You did what any sensible person should do. FORTRAN was my first computing language. I doubt that I would even recognize it anymore.
Relax, have a culturally appropriate beverage and celebrate your success.