<p>It looks like <a href="http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html" rel="nofollow">CFITSIO</a> has an <a href="http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/f_user/fitsio.html" rel="nofollow">interface for F77</a>. </p>

<p>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. </p>

CC BY-SA 3.0
2016-03-07T15:32:47.407Z
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
CC BY-SA 3.0
2016-03-04T20:44:35.727Z
2016-03-04T20:44:35.727Z
xzackli
<p>I recently inherited some Fortran 77 code that calls the <a href="http://stsdas.stsci.edu/documents/SUG/UG_49.html" rel="nofollow">IMFORT</a> 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.</p>

<p>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.</p>

<data-analysis>
Fortran Fits writer/reader
veda905
# Fortran Fits writer/reader

(Asked by: username_0 on 2016-03-03)

I recently inherited some Fortran 77 code that calls the [IMFORT](http://stsdas.stsci.edu/documents/SUG/UG_49.html) 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.

**Tags:** data-analysis

---

## 1 answers

### Answer by username_1 on 2016-03-04. Score: 2 | Accepted answer

It looks like [CFITSIO](http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html) has an [interface for F77](http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/f_user/fitsio.html).

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.

> **Comments:**
> **username_0**: 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!  

---

