next up previous FTOOLS Home
Next: Appendix Up: Developer's Guide to FTOOLS Previous: A Few Specifics

Binding C and FORTRAN Source Code

There are several good reasons to develop software with the C language - portable dynamic memory allocation, structures and an increasing collection of useful pre-existing software. But several aspects of FTOOLS software development demand FORTRAN compatibility. Libraries like FITSIO and the IRAF F77/VOS were developed with FORTRAN in mind. Usually, a dedicated software developer can work around the differences between FORTRAN and C to make a hand crafted interface for one particular computer platform. This is not in the style of FTOOLS software and is unacceptable. This sounds like portable mixing of C and FORTRAN code is doomed. But relax, the cfortran.h header macros from CERN can fix all of this. One very simply creates wrapper macros in C that intercept the C calls FORTRAN or FORTRAN calls C lines of code and correctly handle the translation of all the common data types between the two languages on almost every computer. The cfortran.h package is available from by anonymous FTP from CERN at the host zebra.desy.de. Be sure to get the document and example files while you are FTP'ing. Or if you like you will find the cfortran.h header file and documentation in the FTOOLS distribution in the library subdirectory.

As is generally true, it is easiest to learn from example. There are several FTOOLS which use some C code to more efficiently manipulate the data. All of these FTOOLS use the CERN cfortran.h macros to bind C and FORTRAN. For examples, consider the faint FTOOL in the ASCA package or the fmemsort FTOOL in the FUTILS package. This will provide a more clear demonstration of the supplemental code needed than is found in the CERN document. However, the document is a must for understanding the capabilities of cfortran.h.



Web Page Maintained by: Dr. Lawrence E. Brown elwin@redshift.gsfc.nasa.gov

FTOOLS HELP DESK

If FTOOLS has been useful in your research, please reference this site (http://heasarc.gsfc.nasa.gov/ftools) and use the ASCL reference for HEASoft [ascl:1408.004] or the ASCL reference for the original FTOOLs paper [ascl:9912.002]:

Blackburn, J. K. 1995, in ASP Conf. Ser., Vol. 77, Astronomical Data Analysis Software and Systems IV, ed. R. A. Shaw, H. E. Payne, and J. J. E. Hayes (San Francisco: ASP), 367.

Web page maintained by: Bryan K. Irby