Benjamin Weiner, May 2012
Compiling PGPLOT on Mac OS X
a guide for the perplexedPGPLOT
Getting Started with Intel® Fortran Compiler for Mac OS. X (including Mac OS. X 10.6.x 'Snow Leopard') Disclaimer and Legal Information The information contained in this document is provided for informational purposes only. Intel also provides their compiler to OS X and linux users for free under a very specific non-commercial license. If you are going to be using Fortran in a way that is compliant with their licensing terms you can install it from them. They have a pretty good support forum for their OS X/Linux compiler.
Fortran Compiler Installation Instructions for OS X. The Mac OS X operating system is a variant of unix (called Darwin, which is a derivative of BSD unix). It is a versatile computing platform suitable both for computational chemistry calculations and for developing and compiling programs. The OS X Fortran compiler supports a full range of project targets including command line programs and GUI based applications. It provides a complete 64-bit macOS/OS X Fortran compiler solution and supports mixed language development by interfacing with Apple’s Xcode C/C compiler. Absoft Pro Fortran Is A Complete Package.
OS X issuesHistorically you typically installed PGPLOT by either compilingfrom source or installing a software package that includeda compiled library (libpgplot.a) and various other stuff likefonts. This used to be fairly easy on Linux or Mac, butstarting around OS X 10.6 and/or 64-bit CPU Macs, I and otherpeople had difficulty compiling PGPLOT on OS X. Typicallyone gets an error message like: /usr/bin/ranlib: archive member:libpgplot.a(grdate.o) cputype (16777223) does not match previousarchive members cputype (7) (all members must match).
If you googlearound you can find lots of puzzled people, and a number of webpages that suggest workarounds (not all of which are specificallyfor 10.6; none have solved theproblem for me). I've diagnosed the issue and provide herea couple of configuration files which you can add to a regularPGPLOT source distribution so it will compile correctly.
Instructions for fixing and installing PGPLOT
If you ran sudo make cpg you will also have libcpgplot.a.
Compiling and running programsTo compileprograms using it, link to /usr/local/lib/pgplot/libpgplot.a/usr/X11/lib/libX11.dylib
For example g77 -o myprog myprog.f /usr/local/lib/pgplot/libpgplot.a/usr/X11/lib/libX11.dylib
To run programs with PGPLOT, don't forget to set the environmentvariable PGPLOT_DIR to the library directory. Otherwise itcan't find the fonts at runtime. This is best done in a startup filelike .bash_profile or .cshrc, for example for bash: export PGPLOT_DIR=/usr/local/lib/pgplot ; and for csh: setenv PGPLOT_DIR /usr/local/lib/pgplot
You must use the same compiler foryour program that you used for the library: g77 OR gfortran. Youcould compile PGPLOT libraries with the two compilers in two differentdirectories and use one or the other as needed.
The /xs device should work when run from a mac Terminal, but /xtwon't. /xt will work when run from an xterm under X11.
If you want to get the /PNG driver to work, uncomment it indrivers.list, and after running makemake andbefore compiling, edit the makefile to comment out the following line:pndriv.o : ./png.h ./pngconf.h ./zlib.h ./zconf.h . This hasan incorrect location for the PNG library header files which causescompilation to fail.
If for some reason you need to make the libpgplot.so shared object (dynamically loaded) library, you should be able to do this by uncommentingthe lines in the .conf file (gfortran_gcc_32.conf or similar)that read SHARED_LIB='libpgplot.so' and SHARED_LD='gcc -shared -o $SHARED_LIB', before running the 'makemake' step.
Configuration files on githubThe new configuration files and these instructions are also availablefrom my github page for PGPLOT configuration. You can fork them or issue a pull request if you have modifications.Why this worksMac OS X for 64-bit machines allows you to run 32 or 64 bitbinaries. But the inexplicable error message from ranlib above iscomplaining that it can't mix object files compiled for 32 bit cputype(i386) and 64 bit (x86_64) into a single object library archive, thelibpgplot.a file.
The problem is that PGPLOT source is actually a mix of Fortran andC. The Fortran compilers compile into 32-bit by default (g77is only 32 bit capable) and the C compiler now compiles into 64 bit bydefault. So ranlib has to mix 32 and 64 bit object files and it can'tdo that. This is why it only became a problem with 64 bit Macs andOS X 10.6. The new config files force the C compiler to compile in 32bit with the '-m32' option. So then the files are all 32-bitand it compiles ok. For 64 bit the config file forces gfortran tocompile in 64 bit with '-m64'.With Apple's C compiler you can also use '-arch i386' and '-archx86_64' to force 32 or 64 bit. The '-m32' and '-m64' options shouldwork with a non-Apple gcc, although I have not tested them.
Other notes: I have not tested all the more exotic drivers and library locations, and if you do something arcane like use aPGPLOT-Tk interface, it may require adjustment.See above for how to get the PNG driver to work by editing the makefile.
I tested this on OS X 10.6 Snow Leopard, and have not tested PGPLOT on OS X 10.7 Lion myself, although users have reported it working on later OSes including Mavericks. I have a reportthat forcing the 64-bit option by using a configuration similar to'gfortran_gcc_64' will work, so try that.
Where to get compilersFortran Compiler For Mac Os X 10.6 10 6 Snow LeopardApple's gcc C compiler comes with Xcode, their development kit. Xcodewas on my OS X install CDs, but is not installed by default. You canalso download it from Apple.
Mac OS X versions of gfortran, g77, and non-Apple versions of gcc can be downloaded from http://hpc.sourceforge.net/.The HPC page does not have quick links to binaries of the compilersfor older versions of Mac OS X, but they are in the file tree athttp://sourceforge.net/projects/hpc/files/hpc/. Some other useful information about Fortran and Mac is listed here.
Contact:
My software page.
Back to my home page.
Benjamin Weiner, email bjw at as.arizona.edu
Fortran Compiler For Mac Os X 10.6 Browser For Mac Os X 10 6 8
29 May 2012, updated 6 June 2012, 10 April 2013, 18 Nov 2014
OS X Pro Fortran for 2020
Absoft Pro Fortran 2020 provides a complete 64-bit macOS and OS X Fortran compiler solution and supports mixed language development by interfacing with Apple’s Xcode C/C++ compiler.
New in Pro Fortran 2020
New in Pro Fortran 2019 and later
Key Features
Supported F2003/F2008 Features
Graphics Programming
The AWE Fortran application framework provides Fast Data Visualization to easily create a variety of plots and charts and also supports the AWE Canvas with graphics primitives such as lines, curves, and rectangles. OpenGL graphics programming is supported through included f90gl and f03gl interface packages. The Absoft Pro Fortran package also contains pre-built versions of a flexible graphics library called PLplot. PLplot can be called from Fortran as well as C/C++ and can create standard x-y plots, semilog plots, log-log plots, contour plots, 3D plots, mesh plots, bar charts, and pie charts.
OpenMP 3.1 Support
Absoft Pro Fortran provides complete Open MP 3.1 support in the compiler and debugger.
Apple Xcode C/C++ Compiler Support
The AbsoftTools integrated development supports mixed-language programming by integrating the C/C++ compilers included with Apple’s Xcode and Xcode command line tools packages. These compilers are available at no cost from Apple.
System Requirements
Documentation
Extensive product documentation is installed into the /Applications/Absoft20.0/documentaion folder and includes
Example Code
Numerous Pro Fortran examples are included and installed into the /Applications/Absoft20.0/examples folder.
Technical Support
Absoft branded products include Premier Technical Support and Initial Software Maintenance at no additional charge from the time of purchase for as long as the purchased version remains the current release version.
Initial Software Maintenance (ISM) includes free electronic downloads of all interim Service Packs and Quick Fixes from Absoft. Version upgrades require a separate purchase but at discounted prices for commercial/government users – Academic users already receive the lowest available price when making an academic purchase.
For further information on available support for current, registered users, see the support section on this site.
Continuing Software Maintenance
At the conclusion of the Initial Software Maintenance term (i.e. when a new version of the purchased product is released) customers may either purchase a Product Upgrade or within 30 days of the new product release, purchase Continuing Software Maintenance for an additional 12-month maintenance term.
Continuing Software Maintenance (CSM) includes all elements of Premier Technical support plus all Product Upgrades issued during the 12-month Continuing Software Maintenance term. Annual renewals of Software Maintenance will be made available at a low-cost to commercial/government customers who renew within their unexpired Maintenance term – Academic users already receive the lowest available price when making an academic purchase.
For users electing not to renew Continuing Software Maintenance and having expired maintenance terms but later wishing to rejoin CSM, Reinstatement Software Maintenance (RSM) terms may be purchased.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |