Mac F2C A FORTRAN-to-C translator for the Macintosh f2c kernel ©1989-1995 AT&T Bell Laboratories and Bellcore Macintosh Interface ©1994-1995 Igor Mikolic-Torreira This software is free: it may be used and distributed freely so long as the copyright notices and associated documentation remain attached. Mac F2C A FORTRAN-to-C translator for the Macintosh What is Mac F2C? Mac F2C is a FORTRAN-to-C translator. It will read a file of FORTRAN code and produce a file of C code. When compiled and linked with the special support libraries included with Mac F2C, this C code will work just like the original FORTRAN code. The Mac F2C package also includes F2C for MPW, which will let you compile, link, and execute FORTRAN code from within the MPW environment. Mac F2C is the Macintosh port of the UNIX program f2c developed at AT&T. AT&T permits the use of the f2c source code for non-profit purposes. You can get a copy of the f2c source code at netlib.att.com. Mac F2C is freeware. This means that AT&T and I maintain our copyrights on it, but allow you to use it freely. You may also distribute it freely so long as you distribute the whole package with all the documentation and supporting materials. Please do not post incomplete copies of Mac F2C on America On-Line, CompuServe, or other public bulletin boards. It’s very hard to use Mac F2C without the instructions and supporting files. It becomes a real headache for me when users of these incomplete packages send me nasty emails about my hard-to-use, poorly documented software. What do I need to run Mac F2C? The minimum requirements to run Mac F2C are: • a 68020 CPU or better • System 7.0 or later • At least 1 MB of available RAM (2 MB is preferred) Where do I go from here? The next step is to read the “Quick Start” instructions in the next chapter. Mac F2C is not ready to go out of the box, so please read those instructions to see how to set up the support libraries and use the C code produced by Mac F2C. You should also read the more detailed documentation on the FORTRAN-to-C compiler itself. Included with Mac F2C is the document AT&T Report 149.ps, a PostScript file which you can download to any PostScript printer. It will produce a copy of AT&T Computing Science Technical Report No. 149. This report provides very detailed documentation on f2c, the UNIX program which is the translator at the core of Mac F2C. Consider this report your compiler and language reference manual. I recommend all users print out and read this report. If you want to drive Mac F2C with AppleEvents, check out the chapter on “Scripting Mac F2C” and the sample Mac F2C AppleScripts in the Mac F2C Extras folder. The “Scripting Mac F2C” chapter contains detailed information on sending AppleEvents to Mac F2C. The Mac F2C Extras folder includes not only some sample AppleScripts but also a header file which you can use with your own code. Before sending a bug report please glance at the chapter “Known Bugs”. If you have trouble getting the C code produced by Mac F2C to run correctly, refer to the chapter “When Translated Code Won’t Run”. If floating point values do not appear to round correctly when output, read the information in the chapter “If Floating Point Numbers Don’t Display Right”. Finally, if you plan on moving code between a UNIX machine and a Macintosh and/or will be mixing code translated by f2c on a UNIX machine and Mac F2C on a Macintosh, please look at the chapter “Mac F2C vs. UNIX f2c”.Quick Start Setting Up Mac F2C Mac F2C is not ready to go out of the box. You must first build all of the required supporting libraries and install supporting files where your compiler can find them. If you have MacOS System 7.5 (or any version with a scriptable Finder), the installer script application included with Mac F2C will do all of this for you. Simply double click on the Mac F2C Installer and answer the questions it asks you. The installer will not only build all of the libraries and install supporting files, it will also build the test programs for you, leaving them in the folder Test Project ń. After the installer is finished, you should run these programs (by double-clicking on them) to verify the correct operation of Mac F2C. The installer supports CodeWarrior IDE v1.3.1, Symantec for PowerPC v8.0.3, and THINK (for 68K) v7.0.5. If you want to set-up the F2C for MPW package, a series of make files are provided to do this. Please refer to the chapter “Using F2C for MPW” for detailed instructions on setting-up and using this package. If you do not have a version of the MacOS with a scriptable Finder (or if you have earlier versions of THINK, Symantec, or CodeWarrior) then you must build all of the libraries and install supporting files manually. You should read the “Set Up” section of the chapter dedicated to the compiler you plan to use (these chapters are titled “Using Mac F2C With…”). I also strongly recommend using the included test program to verify correct operation of Mac F2C and the support libraries. Again, detailed information on how to do this is provided in the chapter of this documentation dedicated to the compiler you plan to use, in the section titled “Verifying Correct Operation of Mac F2C”. If you don’t have MacOS System 7.5, click on your compiler’s icon to go to the corresponding instructions for setting up Mac F2C manually… Translating with Mac F2C You can use Mac F2C to translate FORTRAN to C by any of four methods: • Start up Mac F2C and select the Translate command from the File menu. • Drag-&-drop a bunch of FORTRAN files onto Mac F2C. • Write an AppleScript to drive Mac F2C. Mac F2C is scriptable and conforms to the AppleEvents Object Model. • If you are using Mac F2C with CodeWarrior, you can also use the CodeWarrior MPW/ToolServer tools to drive integrated Mac F2C - CodeWarrior builds. FORTRAN files must be TEXT files and must end in .f or .F (sorry, but the ending is determined by the unix f2c kernel—it rejects files handed to it with any other endings). The output file is the same name with a .c extension if you selected C code for the output, or the same name with a .cp extension if you selected C++ code for the output. The Options menu items and dialogs are generally self-explanatory. If you don’t understand what an option means, or don’t understand why an option is dimmed, check the balloon help. If you check the Make these the new defaults box before clicking the OK button, your option selections will be saved in a preference file and used again the next time you start Mac F2C. Using Code Generated by Mac F2C After the translation, create a new project using one of the Mac F2C project models/stationary provided for your compiler. Add the C files generated by Mac F2C to this project. Bring everything up-to-date and you are ready to go. If you use MPW, just copy and modify one of the included makefiles.What’s New in Mac F2C v1.3 What’s New Version 1.3 is a major update to version 1.2. The most noteworthy new features and key differences are: • Includes Kris L. Jorgensen’s F2C for MPW package, which provides an MPW tool version of f2c and support for using the MPW versions of CodeWarrior’s compilers to create FORTRAN-based MPW tools. • Comes with an installer application that will build the required Mac F2C support libraries, install support files where your C/C++ compiler can find them, and build the appropriate test application. • Supports the AppleEvents Object Model, so you can use the get/set verbs in an AppleScript to control essentially all of Mac F2C’s options. • Can automatically drive C/C++ project builds using Symantec, THINK, and/or CodeWarrior, even adding generated C/C++ files to your project as required. • Revised support libraries feature improved run-time error trapping and provide built-in support for cooperative multi-tasking. Various bugs in the libraries have been fixed. • Support for the new CodeWarrior Integrated Development Enviornment (IDE, v1.3), including updated v1.3 project files. • Support for the new Symantec C/C++ (v8) for PPC code generation, including versions of the Mac F2C support libraries, model projects, and installation testing material. • Support for the version of THINK C/C++ (68K code generation) that is distributed with Symantec C/C++ v8. • Mac F2C is now even friendlier in the cooperative tasking arena. Numerous bugs have also been fixed. USERS UPGRADING FROM PRIOR VERSIONS: you need to re-install all libraries and project files, including main.c (now called F2Cmain.c) and f2c.h. What’s Included The Mac F2C 1.3 distribution set contains the following items: Mac F2C v1.3 Documentation -- This document. It is a stand-alone documentation file describing everything you need to know. Mac F2C -- the FORTRAN-to-C translator application, version 1.3. This is a fat binary containing both 68K and PowerPC native code. Mac F2C Installer -- an AppleScript application that will set-up Mac F2C for use with either Symantec, THINK, or CodeWarrior C/C++ compilers. Mac F2C Libraries -- a folder containing the libraries required to support programs translated by F2C. The libF77 library provides floating-point support; the libI77 library provides integer and I/O support. Symantec, THINK, and CodeWarrior project and library files, and MPW makefiles are provided, along with all the source code. These need to be built and installed in the right places. Test Project ń -- a folder containing a test FORTRAN program and the C output produced by Mac F2C. It also contains Symantec, THINK, and CodeWarrior projects and MPW makefiles to compile and run the test program. CodeWarrior Support -- a folder containing items specifically required to use Mac F2C with Metrowerk’s CodeWarrior C/C++ compiler. This folder contains the following items: • For '(Project Stationary)' -- a folder containing CodeWarrior project stationary files for using C and C++ code generated by Mac F2C. Two files are for producing 68K code, the other two for PPC code. • For 'Mac F2C Support' -- a folder containing files which are required to compile and link code translated by Mac F2C. • CW6 Project Files -- a folder containing CodeWarrior v1.2 (CW6) versions of all the CodeWarrior project files and stationary. • CW Install.Lib -- an AppleScript library used by the installer. Symantec/THINK Support -- a folder containing items specifically required to use Mac F2C with Symantec C/C++ (PPC) and THINK C/C++ (68K) compilers. This folder contains the following items: • SPM Support -- a folder containing support for the Symantec Project Manager (abbreviated SPM). It contains the following: (1) For '(Project Models)', a folder containing model SPM C and C++ projects for using code generated by Mac F2C; and (2) SPM Install.Lib, an AppleScript library used by the installer; and (3) SPM 8.0.4 Project Files, a folder containing SPM 8.0.4 versions of all the CodeWarrior project files and project models (see the SPM documentation for details on how to use these). • TPM Support -- a folder containing support for the THINK Project Manager (abbreviated TPM). It contains the following: (1) For '(Project Models)', a folder containing model TPM C and C++ projects for using code generated by Mac F2C; (2) For 'Standard Libraries', a folder containing versions of THINK’s ANSI, unix, CPlusLib, and IOStreams libraries suitable for use with Mac F2C; (3) TPM Install.Lib, an AppleScript library used by the installer. F2C for MPW -- a folder containing an MPW-tool version of f2c and support for developing FORTRAN-based tools in conjunction with Metrowerk’s CodeWarrior C/C++ tools for MPW. Mac F2C Extras -- a folder containing the following: • AT&T Report 149.ps -- a postscript file containing the AT&T report that serves as a compiler manual for Mac F2C. • F2C CW MPW/ToolServer Tools -- a folder containing tools that drive integrated CodeWarrior-Mac F2C operations from MPW or ToolServer. • Mac F2C AppleEvents -- a folder containing detailed information on how to drive Mac F2C using AppleEvents. This folder includes sample AppleScripts and F2cAETerms.h, a file (which you can include in your own code) that defines Mac F2C’s AE terminology. • Mac F2C and Alpha -- a folder containing Tool Command Language (Tcl) code intended for use the Pete Keleher’s “Alpha” text editor. When loaded into Alpha, this Tcl code will create a new Alpha menu that makes it very easy to manage FORTRAN-based projects using Mac F2C and CodeWarrior. • Fixing Floating Point Output -- a folder containing source files and instructions that you can use to fix errors in your ANSI library’s routines for converting floating point numbers to ASCII representations.Translating FORTRAN With Mac F2C Known User Interface Problems • The cursor flickers between an I-beam and an arrow while over an editable text field in a dialog box. This is due to an unwanted interaction with the SIOUX console window. I do not know when this will be fixed. • The Undo command does not work. It is not implemented at this time. • The Save command doesn’t exist (only Save As) and Mac F2C doesn’t remember what file it saved to after the first save. • The Close command does not work. It is not implemented at this time. There is no way to close the translation status window in this version of Mac F2C. • The translation status window is always saved as a CodeWarrior text file, regardless of the creator code specified in the Mac F2C Preferences dialog. Known Code Generation Problems <None> Known Support Library Problems <None>Contacting the Author My name is Igor Mikolic-Torreira and I can be reached at firstname.lastname@example.org. Mac F2C is freeware. This means that AT&T and I maintain our copyrights on it, but allow you to use it freely. You may also distribute it freely so long as you distribute the whole package with all the documentation and supporting materials. Please do not post incomplete copies of Mac F2C on public bulletin boards, AOL, etc. It’s very hard to use Mac F2C without the instructions and it becomes a real headache for me when users of these incomplete packages complain to me. If you find Mac F2C useful, please drop me a note. If you really think it is the most useful thing in the whole world and worth its weight in gold, please donate that amount of gold to your favorite charity. The latest version of Mac F2C (and betas of unreleased versions) can be obtained at ftp://alumni.caltech.edu/pub/Mac_F2C. A current bug list (with work arounds) is also kept in this directory. I have started to keep a mailing list which I will use to distribute Mac F2C related information such as bug alerts, patches, and new versions. If you wish to be added to this mailing list, please send me an email. Also let me know if you are interested in being a beta-tester for future versions of Mac F2C. The F2C for MPW package (which is integrated into Mac F2C v1.3) was developed by Kris L. Jorgensen. It is also distributed as freeware, although Kris and AT&T maintain their copyrights on it. You can contact Kris at email@example.com. Bug Reports If you find any bugs or would like to request a particular feature, let me know. I will try to fix interface bugs or at least provide work-arounds promptly. I will forward compiler bugs to AT&T. If you believe you have a code generation bug, please send me a sample of the FORTRAN code that produces the problem together with the C output and your Symantec, THINK, or CodeWarrior project file(s). If you can create a minimal example, that’s even better and you will earn my eternal gratitude. Before sending me a bug report, please read “Mac F2C Known Bugs” as Mac F2C has some problems that I am quite aware of. If your translated programs compile without errors but don’t run, take a look at the file “When Mac F2C Code Won’t Run…” for information on the most common problem with translated code and how to fix it. You can send comments and questions on any part of the Mac F2C package to me. I can provide CodeWarrior C/C++, Symantec C/C++, and THINK C/C++ support. However, Dirk Fröhling (who contributed all of the CodeWarrior support files used in this version of Mac F2C) has a lot more experience with CodeWarrior than I do. He has graciously allowed me to distribute his email address. You can send questions or comments on Mac F2C’s CodeWarrior support directly to Dirk at firstname.lastname@example.org. Please note that I do not use MPW. If you have any questions about the F2C for MPW package, you can ask me, but I'll just forward your questions to Kris L. Jorgensen (the creator of F2C for MPW). Feel free to contact Kris directly at email@example.com.Credits A lot of people have contributed to Mac F2C, either knowingly or unknowingly. Many thanks to.... AT&T and Bellcore for developing f2c and allowing others to make free use of the source code. Mac F2C v1.3 incorporates the f2c version of 13 Nov 1994. Dirk Fröhling of the University of Dortmund for figuring out how to make the support libraries compile under CodeWarrior and for providing CodeWarrior project files and libraries. A lot of the CodeWarrior support in v1.3 is due to Dirk. Dirk also suggested many of the features found in Mac F2C—including the interaction (via AppleEvents) with THINK and CodeWarrior. Additionally, because I don’t have regular access to a PowerPC, Dirk also did all the development testing of the PPC native versions. Needless to say, I could not have produced a PowerPC version without Dirk’s help. Dirk is also the creator of the ToolServer tools that let you easily drive integrated Mac F2C<->CodeWarrior builds from ToolServer. Kris L. Jorgensen of Purdue University for developing an MPW hosted version of f2c (complete with MPW-compatible f2c support libraries) and support for MPW tool generation using f2c. He has kindly allowed me to include his F2C for MPW package in the Mac F2C distribution. He also went through a lot of trouble to integrate his work with the Mac F2C package. Mel Martinez of Johns Hopkins University for developing code that adds cooperative multitasking to FORTRAN code ported to the Macintosh with Mac F2C. He has kindly allowed me to incorporate his ideas into Mac F2C v1.3. Klaus Thermann of the University of Dortmund for the Tcl code that integrates Mac F2C with Alpha. John Melby for lots of help making sure I got the THINK and Symantec support right. He also spent a lot of time testing the installers for both TPM and SPM. Tom Emerson of Symantec and Greg Galanos of Metrowerks for providing copies of their development systems and helping me integrate Mac F2C with them. Special thanks to Tom for allowing me to plagarize some of his AppleScripts. Jens Alfke of Apple Computer for AEBuild and related AppleEvent utilities. Mac F2C incorporates his AEGizmos v1.4.1 package (this includes AEBuild, AEPrint and other goodies). For anyone not familiar with AEBuild, it is by far the easiest way to build AppleEvent object descriptors. Hours of frustration are replaced by a few lines of easy to understand code. If you don’t have it, get it! Jim Luther of Apple Macintosh Developer Technical Support for the MoreFiles collection of FileManager Utilities. Mac F2C incorporates MoreFiles 1.3. Gary Woodcock of Apple Computer for the StdPrefsLib library of routines to handle preferences and preference files. Mac F2C incorporates a slight modification of version 1.0 of the Standard Prefs Library (as distributed on the "develop Bookmark" CD). And last—but certainly not least—to my wife Beth for patiently tolerating many late nights when I paid more attention to my computer than I did to her.License and Other Annoying Legal Stuff AT&T and Bellcore License The compiler engine of Mac F2C is based on the unix version of f2c and is Copyright ©1990-1995 by AT&T Bell Laboratories and Bellcore. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the names of AT&T Bell Laboratories or Bellcore or any of their entities not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. AT&T and Bellcore disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall AT&T or Bellcore be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software. My License The Macintosh interface portion of Mac F2C was written and is Copyright ©1994-1995 by Igor Mikolic-Torreira. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the name of Igor Mikolic-Torreira not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Igor Mikolic-Torreira disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall Igor Mikolic-Torreira be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.