I recently inherited some Fortran 77 code that calls the IMFORT interface to write data out to an imh and pix files. I could not get this to compile on a modern compiler and it is not supported. So I decided to set off on writing a Fits writer in Fortran. I was able to make one but is ugly and does not properly handle the end card. I tried googling for a Fortran Fits writer but came up empty. Is there a library for astronomical Frotran codes that contains Fits writer exist out there.

The code may be better suited for stack overflow, but this is specialized to astronomy since no other science seems to use fits, so I figured I would be better off starting here.


It looks like CFITSIO has an interface for F77.

I'm always thinking about programmer time vs. computation time in research settings. If your data is reasonably small and simple in structure, I'd be very tempted to have Fortran write to a text file, and then use something like astropy to turn the text file into a FITS file. It's slow and icky, but it takes fifteen minutes of thinking if you've used astropy before.

| improve this answer | |
  • $\begingroup$ Unfortunately this is not a small data structure, it is 4 extensions of 4K x 4K arrays, and due to the next step in processing (again more legacy code I inherited) requires a fits format file. Thank you for pointing me to that interface! $\endgroup$ – veda905 Mar 7 '16 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.