Astronomy Stack Exchange is a question and answer site for astronomers and astrophysicists. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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! – veda905 Mar 7 at 15:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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