Compiling GAMIT & GLOBK 10.35 for Mac OS X 10.5-10.6

November 17th, 2009 Comments off

A post dedicated to help compiling GAMIT and GLOBK for Mac OS X 10.5 Leopard (PowerPC and INTEL) and 10.6 Snow Leopard (INTEL only).

GAMIT, GLOBK, and TRACK form a comprehensive suite of programs for analyzing GPS measurements primarily to study crustal deformation. The software has been developed by MIT, Scripps Institution of Oceanography, and Harvard University with support from the National Science Foundation (USA).

Pre-requirements

  • For Mac OS X 10.6.x: install Apple XCode Dev Tools 3.2.1 with X11 SDK
  • For Mac OS X 10.5.x: install Apple XCode Dev Tools 3.1.4 with X11 SDK
  • gfortran binaries

Download gfortran

Install the appropriate (INTEL or PowerPC) gfortran disk image for Mac OS X from:
http://gcc.gnu.org/wiki/GFortranBinaries

Download GAMIT/GLOBK

Download the source code of ‘GAMIT 10.35′ from MIT’s ftp-server with incremental updates (Registration required)

Change both install scripts to be executable


#chmod u+x install_software
#chmod u+x install_updates

Launch the install script ‘install_software’

This will decompress the *tar.gz files, with command:

# sudo install_software

You will get some errors with X11 missing etc. Don’t worry we will fix this right now.

Modify ‘libraries/Makefile.config’ for Mac OS X

Edit ‘libraries/Makefile.config’ with your favorite editor
Uncomment the topic specific to Mac OS X for X11LIBPATH and X11NCPATH to read:


# Specific for MacOSX
X11LIBPATH /usr/X11/lib
X11INCPATH /usr/X11/include/X11

Since Mac OS X 10.6 compiles by default in 64bit mode we need to add the “-m32″ CFLAGS option to keep 32bit mode compatibilty in Mac OS X 10.5 and 10.6, or else we get compiler errors.

We need also to update the OS_ID Darwin number to 1000 (for Snow Leopard compatibility):


#------ for Mac OSX 5.2-8.8.0 (10.4-10.6)
OS_ID Darwin 1000 9900
# ASSIGMENTS
### GCC V4 gfortran flags ###
FTN = gfortran
FFLAGS = -O3 -Wuninitialized -fno-f2c -ffast-math -fno-automatic -fno-backslash
CC = gcc
CFLAGS = -g -m32

# EXPLICIT_RULES
ranlib THELIB

# SUFFIX_RULES
.c.a:
$(CC) -c $(CFLAGS) -I$(II) $< ar rv $@ *.o
rm -f $*.o

.f.a:
$(FTN) -c $(FFLAGS) $<
ar rv $@ *.o
rm -f $*.o

# BLOCKEND

Relaunch the install script

Relaunching the install script will compile just fine GAMIT/GLOBK, with command:


# sudo install_software

Categories: Mac OS X Development Tags:

Install Tsoft for WINDOWS on your Mac with WINE via MacPorts Project

January 15th, 2009 Comments off

This page is an update to my previous post (Compile Wine for Mac OS X INTEL) and describes the easiest way to install the WINDOWS application Tsoft on INTEL Macs using the MacPorts Project.

To run WINDOWS applications we need WINE (WINE Is Not an Emulator), a fantastic open-source application first developped on LINUX and now ported to Mac OS X without needing to boot a virtual machine (like Parallels Desktop or vmWare Fusion) or Apple’s Bootcamp and the execution time is full speed! WINE’s compatibility is quite high and the development is top notch: from office to scientific apps and some older 3D-games are running flawlessly. Even printing works great!

Using MacPorts to install the latest WINE development binaries is much easier and faster than compiling from source code with all dependencies since it does not require any line of compilation from your part. MacPorts will manage everything for you!

After WINE is installed we can run the WINDOWS application “Tosft.exe”.

Pre-requirements

  • An INTEL based Macintosh computer (for WINE installation)
  • Apple XCode Development Tools 2.4 or higher for MacPorts required

Install MacPorts

From the MacPorts Project Official homepage:

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system. 

  • Download the disk image (dmg) of MacPorts for Mac OS X from the official website.
  • macports-mounted-dmg

  • Double-click the icon and follow the install instructions
  • macports-install-progress

  • After the installation the “/opt/local/” directory is created on your disc. The binary directory is for example installed in /opt/local/bin

Install Porticus (the easy way to manage Macports packages)

Porticus is a GUI (Graphical User Interface) for the MacPorts package manager, written by Richard Laing in Cocoa. Download and install it from it’s website.

porticus-gui

Before installing the development version of WINE you’d better update the packages of MacPorts:

  • Launch Porticus and choose “Ports > Selfupdate …”
  • In Porticus choose on the left pane the folder “All Ports” and search for “wine-devel” in the search bar and install via the menu command “Ports > Install Selected …”

porticus-selfupdate1

Installation and compilation can take some time, so be patient.

After WINE is installed, download the Tsoft installer called Tsoft_c.exe” to your “Downloads” folder or whatever you like.

Open “Terminal.app” and type the command to go to your Downloads folder:

cd Downloads
wine Tsoft_c.exe

This will open an “X11 Terminal” window opens called “EasyZip Self-Extractor” and prompts to extracts the files to “C:/”
Click “Start” and everything is installed in your “.wine” home folder.
In fact all the applications are installed in the hidden folder “.wine” inside your $HOME folder.
Check yourself by typing:
#ls -la /Users/gilles/.wine/

You should have something like:

[gilles@gilles-imac /Users/gilles]#ls -l .wine/
total 4864
drwxr-xr-x 5 gilles gilles 170 Jan 16 23:00 dosdevices
drwxr-xr-x 5 gilles gilles 170 Jan 16 22:47 drive_c
-rw-r--r-- 1 gilles gilles 2205555 Jan 16 23:43 system.reg
-rw-r--r-- 1 gilles gilles 276301 Jan 16 23:43 user.reg
-rw-r--r-- 1 gilles gilles 2384 Jan 16 23:43 userdef.reg

So “drive_c” is nothing else than “C:” in WINE.

if you look inside $HOME/.wine/drive_c it should look like:

[gilles@gilles-imac /Users/gilles]#ls -l .wine/drive_c/
total 0
drwxr-xr-x 4 gilles gilles 136 Jan 16 21:58 Program Files
drwxr-xr-x 11 gilles gilles 374 Jan 16 22:47 Tsoft
drwxr-xr-x 22 gilles gilles 748 Jan 16 22:04 windows

To run Tsoft just type the following command in Terminal.app:
#wine C:/Tsoft/tsoft.exe

You’re done! Tsoft opens in a X11 window thanks to WINE! It’s magic!

Running TSoft in WINE on Mac OS X Leopard

Running TSoft in WINE on Mac OS X Leopard

For fun: create a Tsoft launcher with Applescript

This is really easy:

  • Open “Script Editor” from “Applications” > “Applescript” and copy paste this lines of code:


-- Launch "Tsoft" using "wine" from MacPorts Project
tell application "Terminal"
do script "/opt/local/bin/wine C:/Tsoft/tsoft.exe &"
end tell

Save this script on your Desktop as an “Application” and for Options choose: “Run-Only”.
Voilà! you can now launch Tsoft without typing any command!

If you want more control of Macports use “Terminal.app”

This part is more for UNIX freaks, but it’s really not complicated to manage Macports via Terminal.

  • Open “Terminal.app” from “/Applications/Utilities/” and update the macports application and its database with command:
    #sudo port selfupdate
  • Now install the development version of WINE with command:
  • #sudo port install wine-devel
wine-install-progress
  • It will take some time, but after succesful compilation “wine” is installed in /opt/local/bin/
  • To run Tsoft just type the command:
    #wine C:\Tsoft\tsoft.exe
  • You’re done! Tsoft opens in a X11 window thanks to WINE! Enjoy!


Categories: MacPorts Tags: , , ,

Compile WINE for Mac OS X 10.5 INTEL

December 19th, 2008 Comments off

Note: A much easier and faster method to install Tsoft on INTEL Mac is here!

You wish to run a particular Windows application on your INTEL Mac without launching a virtual machine (VM) like Parallels Desktop, vMWare Fusion or Sun’s VirtualBox ? At full speed ? Then enter WINE (WINE Is Not an Emulator).
From the webpage:

Wine is a translation layer (a program loader) capable of running Windows applications on Linux and other POSIX compatible operating systems. Windows programs running in Wine act as native programs would, running without the performance or memory usage penalties of an emulator, with a similar look and feel to other applications on your desktop.

 

For example if you need to check or analyze tide data with the Windows application TSOFT (a software package for the analysis of Time Series and Earth Tides) without launching the VMs you should try to install WINE on your Mac!
 

Running TSoft in WINE on Mac OS X Leopard

Running TSoft in WINE on Mac OS X Leopard

There are WINE binaries for Mac OS X INTEL available (Darwine) but these aren’t up to date with the latest source code, but it should work though. Another possibility to run a Windows application is to buy the commercial derivative of WINE called “Crossover” from Codeweaver.

But if you wish and prefer to install WINE from the latest source code on OS X Intel, please follow my instructions:

Requirements

  • A Mac INTEL computer with Mac OS X Tiger (10.4.x) or Leopard (10.5.x). WINE will not work on Mac with a PowerPC processor!
  • XCode 3.1.2 Developer Tools for Leopard or 2.4.1 for Tiger and X11 SDK installed. Free download of XCode here

Build instructions

Install the source code in the following order:

  1. GNU’s libtool (To build “jpeglib6″ we need the latest ‘GNU libtool’ since ‘libtool’ from /usr/bin on Mac OS X breaks ‘jpeg’ lib build). Download from here
  2. #tar -zxvf libtool-2.2.6a.tar.gz
    #cd libtool-2.2.6
    #./configure
    #make ; sudo make install
    #make clean

  3. Fontforge libraries. Download here
  4. JPEG library “jpeg6lib”. Download from here
  5. PNG library “libpng”. Download here
  6. FreeType 2.3.8 from here
  7. And finally the latest WINE source files (I succesfuly compiled WINE development version 1.1.12)
Categories: Mac OS X Development Tags: , ,

How to compile “NLLOC 5.0″ on Mac OS X

December 1st, 2008 Comments off

The NonLinLoc (Non-Linear Location) package by Anthony Lomax, is a set of programs for velocity model construction, travel-time calculation and probabilistic, non-linear, global-search earthquake location in 3D structures, and for visualisation of 3D volume data and location results. Many of the programs operate with a 3D Grid structure which defines a specific, gridded, rectangular volume (Non-GLOBAL mdoe) or spherical section (GLOBAL mode).

More info on Anthony Lomax website

Compiled an tested on INTEL-Mac with Mac OS X 10.5.5 and Apple XCode 3.1.1 developer tools

Download the tar-gzipped (.tgz) NonLinLoc Software file on your Mac and decompress it with:


#mkdir NLLoc-5.0-MacOSX
#mv NLL5.00_src.tgz
#cd NLLoc-5.0-MacOSX
#tar -zxvf NLL5.00_src.tar.gz

The uncompressed file should create a “src” directory inside the “NLLoc-5.0-MacOSX” directory. Now we just need to get into the “src” directory and edit some files (Makefile, nrutil.c and Time_3d.c).

#cd src

Open up “TextEdit” or download the free and great “TextWrangler” and follow these steps:

  1. In “nrutil.c” remove line or comment #include <malloc.h>
  2. In “Time_3d.c” remove line or comment #include <malloc.h>
  3. In “Makefile” change “BINDIR=” to #BINDIR=. (or else we get errors “ld: in bin/Grid2GMT, can’t link with a main executable”)
  4. In “Makefile”: to avoid “open_memstream” errors, edit section “Custom Builds”:
    The line should look like “GNU_SOURCE=”  (and not “GNU_SOURCE=-D _GNU_SOURCE”)

  5. # Custom builds
    #
    # For GNU (LINUX) uncomment this line
    # GNU_SOURCE=-D _GNU_SOURCE
    #
    # For Mac OS X uncomment the next line or else you will get "open_memstream" errors:
    GNU_SOURCE=

  6. Then compile the whole stuff in ROOT mode:
  7. #sudo make all

  8. Copy all your files to “/usr/bin” or “/usr/local/bin” (as you whish but don’t forget to update your PATH in .bash_profile or .bashrc in your HOME directory)

Compiling GAMIT/GLOBK 10.33 on Mac OS X with gfortran

May 19th, 2008 1 comment

Here’s what I did to compile GAMIT/GLOBK 10.33 on Mac OS X 10.5.2 (INTEL) with gfortran 4.4.0 20080510

Pre-requirements (INTEL or Power-PC platform)

For Mac OS X 10.5.x: install Apple XCode Dev Tools 3.x with X11 SDK.
For Mac OS X 10.4.x: install Apple XCode Dev Tools 2.4.1 or later with X11 SDK.

Compilation

The compilation of GAMIT/GLOBK 10.3.x is pretty straightforward and easier with gfortran than g77!

1. Download and install the appropriate (INTEL or PowerPC) gfortran disk image for Mac OS X from:
http://gcc.gnu.org/wiki/GFortranBinaries

2. Download ‘GAMIT 10.33′ from MIT ftp server (registration required)

3. Edit ‘libraries/Makefile.config’

3a. Change libraries/Makefile.config to:

# Specific for MacOSX
X11LIBPATH /usr/X11/lib
X11INCPATH /usr/X11/include/X11

3b. To avoid compilation error ‘get_otl_grid.f:357: error: unrecognizable insn:’, change the optimization level to -O2 of ‘libraries/Makefile.config‘.
The default optimization of -O3 seems to be too aggressive.

Edit ‘libraries/Makefile.config‘ and change the line in the “Mac OS X section” from:

FFLAGS = -O3 -Wuninitialized -fno-f2c -ffast-math -fno-automatic -fno-backslash
to:
FFLAGS = -O2 -Wuninitialized -fno-f2c -ffast-math -fno-automatic -fno-backslash

4. Change ‘install_software‘ and ‘install_updates‘ to be executable:

#chmod ug+x install_*

5. Launch the installation in ‘sudo’ mode (as root)

#sudo ./install_software

Normally it should compile just fine….

 

Categories: GAMIT Tags:

How to compile GAMIT/GLOBK v10.21 on Mac OS X (PowerPC)

January 11th, 2006 Comments off

Note: Article to compile GAMIT/GLOBK v10.3.x on Mac PPC & Intel here. It’s much easier now to compile.

GAMIT and GLOBK are a comprehensive suite of programs for analyzing GPS measurements primarily to study crustal deformation.This page is a resource to compile and install GAMIT/GLOBK for Mac OS X.

Installation instructions for GAMIT/GLOBK 10.21 (PowerPC)

Software Requirements:

  • Apple XCode development environment (Xcode 2.4.1 for Mac OS X 10.4.x)
  • Apple X11 installed in /Applications/Utilites (from your Mac OSX Install DVD/CD)
  • A FORTRAN compiler customized GNU Fortran g77 (do not use Fink’s g77 in /sw/bin/)
  • A user with ‘Admin’ rights

We first need to install Apple’s XCode development environment, then build a customized GNU77 Fortran, edit some GAMIT/GLOBK config files to get a succesful compilation.

Apple XCode installation

  1. Download and install the latest Apple XCode development environment (free registration required) from Apple’s Developer Connection website.
  2. Open ‘Terminal’ (from /Applications/Utilities/)

Built a customized GNU77 FORTRAN compiler (for PowerPC Macs only !!!)

This process is necessary as the default version of gcc/g77 only allows a maximum unit number (MXUNIT) of 99, while GLOBK requires a MXUNIT of 9999.Create the installation directory for your FORTRAN compiler:

% mkdir /usr/local/g77

Download gcc version 3.4.6 (latest version in the 3.4 tree)

ftp://ftp.gnu.org/pub/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.gz

Unzip and untar the source in your download directory:

% tar -xvfz gcc-3.4.6.tar.gz

%cd gcc-3.4.6

Increase g77 MXUNIT to 10000

Modify libI77/fio.h fortran include file to allow access to 10000 unit numbers :

% vi libf2c/libI77/fio.h

Replace line:

#define MXUNIT 100

With line:

#define MXUNIT 10000

Make the build directory and run configure:

% mkdir objdir

% cd objdir

% ../configure –prefix=/usr/local/g77/

Build GCC/G77

% make

Install GCC/G77

% make install

The executables/binaries are now installed in the directory /usr/local/g77/bin/

Download and install GAMIT/GLOBK

Now that you have installed the FORTRAN compiler, download the source files, request your download form here.

Create a directory in /usr/local/gamit with:

%sudo mkdir /usr/local/gamit

%cd /usr/local/gamit

Download GAMIT sources via ftp. Ftp server address provided by the request form.Change ‘install_software’ and ‘install_updates’ as executables:

%chmod ug+rx /usr/local/gamit/install*

Launch ‘install_software’ to decompress all the *.tar files:
%./install_software

Just say “yes” to decompress com.10.21.tar.Z etc. and for X11 PATH.

Now that all the files are decompressed we can replace ‘com/unimake‘ and ‘libraries/Makefile.config‘ with the new ones.

Install updated ‘unimake’ & ‘Makefile.config’ for Mac OS X

    • Download unimake.gz
    • Decompress it with command:
    • #gunzip unimake.gz and move it to /usr/local/gamit/com/
    • Download Makefile.config.gz
    • Decompress it with command:
    • #gunzip Makefile.config and move it to /usr/local/gamit/libraries

    Restart ‘./install_software’ again, and it should compile and install fine.

    Stop here! If you want to get the big picture of what has been changed:

    Edit libraries/Makefile.config

    1. Change OS_ID number for Darwin

    If it stops after a few seconds with error message:

    OSID Darwin 8700 not found in Makefile.config – remove Makefile and STOP Failure in make_gamit — install_software terminated,

    then we need to edit libraries/Makefile.config and change the line 329 from:

    OS_ID Darwin 5200 8500

    to

    OS_ID Darwin 5200 9900

    so it will compile correctly for the next MacOSX versions up to OSX 10.5.9 :-)

    Note: You get the OS_ID number with command ‘uname -a’, e.g:Mac OS X version 10.4.7 is 8.7.0

    2. Remove optimization options -O3

    Remove the optimization options -O3 or else we will get errors compiling ‘glorg’ in directory ‘kf’.

    The section of ‘OS_ID Darwin’ should look like this:

    #—— for Mac OSX 10.2 til Mac OSX 10.5.9—–

    OS_ID Darwin 5200 9900

    # ASSIGMENTS — removed optimization “-O3 -Wuninitialized” or else problems compiling “kf/glorg”

    FFLAGS = -Wunused -Wimplicit -fno-f2c -fno-automatic -fno-backslash -Wno-globals -fno-globals

    # Fortran compiler it points to

    FTN = /usr/local/g77/bin/g77

    CFLAGS = -g

    CC = gcc

    # EXPLICIT_RULESranlib THELIB

    # SUFFIX_RULES.c.a:$(CC) -c $(CFLAGS) -I$(II) $< ar rv $@ *.orm -f $*.o.f.a:$(FTN) -c $(FFLAGS) $<ar rv $@ *.orm -f $*.o# BLOCKEND

    3. Change absolute PATH of your customized g77

    Change also the line 333 of FTN to have the absolute PATH for g77 binary (in section ‘OS_ID Darwin’)

    FTN = /usr/local/g77/bin/g77

    If you restart again ‘./install_software’, after a while you will get the following error message:

    /usr/bin/ld: Undefined symbols:_printf$LDBLStub_scanf

    $LDBLStubcollect2: ld returned 1 exit statusmake: *** [makex] Error 1

    Then we need to edit the file com/unimake

    Edit com/unimake

    To compile correctly we just need to append the ‘-lSystemStubs’ library to ‘com/unimake’.

    Change lines 342 to 345 from ‘com/unimake’ (after ‘if ( $mainext == ‘f’ ) then” to:

    if ( $os[1] == ‘Darwin’ ) then

    #echo “Darwin”

    echo ” #(FTN) #(FFLAGS) $mainfull $libnam #(SLIB) -L#(X11LIB) -lX11 -o $execs[$i]$ext -lSystemStubs” | tr ‘#’ ‘$’ >> Makefile

    else

    echo ” #(FTN) #(FFLAGS) $mainfull $libnam #(SLIB) -L#(X11LIB) -lX11 -o $execs[$i]$ext ” | tr ‘#’ ‘$’ >> Makefile

    endif # Darwin

    else if ( $mainext == ‘c’ ) then

    echo ” #(CC) #(CFLAGS) $mainfull -L#(X11LIB) -lX11 -o $execs[$i]$ext ” | tr ‘#’ ‘$’ >> Makefile

    endif

    elseif ( $mainext == ‘f’ ) then

    if ( $os[1] == ‘Darwin’ ) then #echo “Darwin2″

    echo ” #(FTN) #(FFLAGS) $mainfull $libnam #(SLIB) -o $execs[$i]$ext -lSystemStubs” | tr ‘#’ ‘$’ >> Makefile

    else

    echo ” #(FTN) #(FFLAGS) $mainfull $libnam #(SLIB) -o $execs[$i]$ext ” | tr ‘#’ ‘$’ >> Makefile

    endif # Darwin

    Relaunch install_software

    Launch install_software again, and it should compile fine.

    Categories: GAMIT Tags: