Wednesday, October 28, 2009

Snow Leopard transition: Fortran

Just an informational item regarding Snow Leopard's treatment of Fortran. The first comment is that programmers need to install XCode from the Snow Leapard install DVD. I bulled ahead without checking this and ran into a roadblock in trying to compile a Fortran program -- the computer could not find the unix command "as" which assembles object files. Once I loaded the XCodes package from the Install disk, this problem went away, and others cropped up.

The innovation of Snow Leopard (and Leopard, I think, Im not exactly sure when the transition occurred relative to Tiger (MacOS 10.4)) is the full utilization of 64-bit chip architecture. The Snow Leopard gcc compiler creates object files that are 64bit, but the Fortran compiler g77 does not. If you try to assemble Fortran and C routines into one archive or a single program, the computer balks. You can tell the nature of the object file with the command "file *.o". I sampled the internets for hints on solving this problem. The simplest solution, and the one Im adopting for now, is to force the gcc compiler to generate a 32-bit object file, rather than a 64bit version, with the "-m32" runtime option. Less powerful than 64bit, and Im still getting warnings from the compiler when I create large codes, but the executables seem to work OK.

The "gfortran" option, rather than "g77" for the Fortran compiler, might work with the 64bit option, but the internets are not unanimous on its success. There are compilers available for download from the HPC site (http://hpc.sourceforge.net/) that claim to vectorize gcc (version 4.4) in Snow Leopard. I read comments from programmers that full-optimization of the compiler has bugs, so buyer beware. I might try it later, though.

NOTE: In 2012-2013 I switched to compile codes with gfortran compiler.

No comments:

 
Link