Installing BERNESE 5.0 on Mac OS X

Introduction

This is a quick guide on how to install BERNESE 5.0 GPS Software on:

  • Mac OS X 10.5 Leopard with Power PC & INTEL processor, and
  • Mac OS X 10.6 Snow Leopard (which runs on INTEL processor only)
  • Mac OS X 10.7 Lion (which runs on INTEL processor only)
Last updated on:

Jan 9th, 2012: – Updated gfortran compiler flags to be the same as LINUX (this allows bugfix B195 for ORBGEN to run again).
Jan 6th, 2012: – Updated for Mac OS X 10.7 Lion
July 13th, 2011: – Added gfortran version which was used to compile
July 5th, 2011: – Updated compilation options the same as “LINUX + GNU FORTRAN”, with same optimization. Tested results between LINUX (Fedora 14) and Mac OS X 10.6.8 are exactly the same.

The following guide was done with BERNESE 5.0 and all patches til “11-May-2011”.

1. Prerequirements

Note: All new Macs (since 2010 and later) have Mac OS X 10.6.x Snow Leopard and INTEL processors. Recent Mac Models come with Mac OS X 10.7 preinstalled.

2. Installing QT3 libraries

For BERNESE Menu Graphical User Interface (GUI) we need to install the QT3 libraries.
This is easily done by launching “Macports” port command from “Terminal.app” and copy/pasting the following command:

#sudo port selfupdate
#sudo port install qt3

It will take a while to download and install all the QT3 port. As every Macport it will be installed in the directory /opt/local/

So the qt3 library is installed in /opt/local/lib/qt3 which is the QTDIR used in BERNESE setup script.

3. Create the directory BERN50 and BERNESE-GPS directory

The directory BERN50 is the directory where all your executable files will be copied.
The directory BERNESE-GPS is the directory where all the GPSDATA / GPSTEMP / GPSUSER will go.

I prefer to have GPSDATA, GPSTEMP and GPSUSER to be in one place (and not spread in the HOME directory), which makes it easier to backup:

#mkdir ~/BERN50
#mkdir ~/BERNESE-GPS/
#mkdir ~/BERNESE-GPS/GPSDATA
#mkdir ~/BERNESE-GPS/GPSTEMP
#mkdir ~/BERNESE-GPS/GPSUSER

4. Launch BERNESE “setup.sh” script from the Installer dir

After you have downloaded the BERNESE UNIX version you must launch the “setup.sh” script from the installer directory (e.g. my installer dir is called “BERNESE-Installer”).

IMPORTANT: Before invoking the “setup.sh” command you must tell where the QTDIR is located, this is done by entering the command, or else you will get the error:The QT library seems not to be installed correctly.

#export QTDIR=/opt/local/lib/qt3
#cd ~/Downloads/BERNESE-Installer/UNIX/
#./setup.sh

The setup script will ask you the location of the installation directory:

Input the Installation Directory [ /Users/gilles/BERN50 ] :

Just type RETURN it should extract all the files in your $HOME/BERN50 directory (mine is /Users/gilles 🙂 )

For PERL just type RETURN since PERL was also installed with Macports in /opt/local/bin/perl and by default PERL comes on Mac OS X in /usr/bin/perl.

Perl program used [ /opt/local/bin/perl ] :

After that it will give you CONFIGURATION MENU:

=====================================
CONFIGURATION OF THE BERNESE SOFTWARE
=====================================
 0 ... Complete Installation (Steps 1 to 4)
 1 ... Update LOADGPS.setvar
 2 ... Add a new user
 3 ... Compile Bernese menu
 4 ... Compile Fortran programs
 5 ... Install Example Campaigns

 X ... Exit
 Enter option:

Enter “X” to exit the Configuration menu. We need to setup some config file to allow the installer to finish without errors.

5. Exit the CONFIGURATION and edit the config file LOADGPS.setvar

By default the file LOADGPS.setvar is loaded by the setup.sh file to include the various installation variables like Installation Dir, Operating System etc.

We create a new one and edit it:

#touch ~/BERN50/GPS/EXE/LOADGPS.setvar
#edit ~/BERN50/GPS/EXE/LOADGPS.setvar

You can copy/paste the following text:

# ~/BERN50/GPS/EXE/LOADGPS.setvar
# Function to add path to $PATH only once   
# ---------------------------------------   
addtopath () {                              
  if [ "`echo $PATH | grep $1`" != "$PATH" ]
  then                                      
    export PATH="$PATH:$1"                  
  fi                                        
}                                           

# Version of Bernese GPS software
# -------------------------------
export VERSION="50"

# Path to the Bernese software
# ----------------------------
export C="${HOME}/BERN50"

# Path to Bernese GPS data files
# ------------------------------
export X="${C}/GPS"

# Fortran source of subroutines
# -----------------------------
export LG="${C}/LIB/FOR"

# Fortran source of include and modules
# -------------------------------------
export I="${C}/INC/FOR"

# Fortran source of programs
# --------------------------
export FG="${C}/PGM/FOR"

# Executables of Bernese fortran programs
# ---------------------------------------
export XG="${C}/PGM/EXE"

# Executable and source of Bernese menu
# -------------------------------------
export XQ="${C}/MENU"

# Scripts for the BPE
# -------------------
export BPE="${C}/BPE"

# Host of the BPE server
# ----------------------
#change to "localhost" if running on your computer
export BPE_SERVER_HOST="localhost"

# Path to campaign directory
# --------------------------
export P="${HOME}/BERNESE-GPS/GPSDATA"

# Path to temp. user environment
# ------------------------------
export T="${HOME}/BERNESE-GPS/GPSTEMP"

# Path to user environment
# ------------------------
export U="${HOME}/BERNESE-GPS/GPSUSER"

# Fortran soure of user programs
# ------------------------------
export FU="${HOME}/BERN50/PGM/FOR"

# Executables of user programs
# ----------------------------
export XU="${HOME}/BERN50/PGM/EXE"

# Path to QT-lib for Bernese
# --------------------------
export QTBERN="/opt/local/lib/qt3"

# Operating system group
# ----------------------
export OS="UNIX"

# Name of the operating system
# ----------------------------
export OS_NAME="DARWIN"

# Fortran compiler name
# ---------------------
export F_VERS="GNU"

# Memory model for compilation
# ----------------------------
export MEMSIZE="LARGE"

# Add Bernese paths to $PATH
# --------------------------
addtopath "$X/EXE"
addtopath "$XG"
addtopath "$XQ"

Now that we have created the LOADGPS.setvar file we want to load the whole kaboonga variables by sourcing it out:

#source ~/BERN50/GPS/EXE/LOADGPS.setvar

This command loads the various variables to the BASH shell.

6. Exit the CONFIG Menu and edit CMOPT.pl in ~/BERN50/GPS/EXE

Since the installer has extracted the tar gzipped files we need to edit some config files or else we will compile errors.

Edit the config file “~/BERN50/GPS/EXE/CMPOPT.pl” to accept “DARWIN” as UNIX platform and add this code at line 461 for example:

#edit ~/BERN50/GPS/EXE/CMPOPT.pl
# Darwin Mac OS X + GFORTRAN (gfortran)
# --------------------------------------------------
   if($OS_NAME eq "DARWIN" && $F_VERS eq "GNU") {
    if($ext eq "f90" || $ext eq "f") {
      $cppCmd = "cpp -traditional-cpp ";
      $cppCmd.= "-DOS_UNIX -DCMP_GNU -DDIM_${MEMSIZE}";
      $cmpCmd = "gfortran";
      if($ENV{F_DEBUG} && $ENV{F_DEBUG} eq "YES") {
        $optOpt = "-O0 -g -Wextra -fbounds-check";
      } else {
        $optOpt = "-O";
      }
      $genOpt = "-Wall -fbacktrace ".
                "-I. -I$C/LIB/OBJ -I$I";
    }
    $genOpt .= " -fno-automatic" if($ext eq "f");
  }

IMPORTANT: Don’t launch setup.sh again or else it will erase the newly modified LOADGPS.setvar with the older one.

We need to modify just one more file to compile the BERNESE MENU correctly.

7. BERNESE MENU Configuration

After trying to launch the compilation of the MENU in the setup installation of BERNESE, an error message appeared of “undefined symbols” in menuutils.cpp > compress etc.

Just go in the directory and invoke the qmake command and edit the “Makefile”

#cd ~/BERN50/MENU/
#qmake
#edit Makefile

Edit the “Makefile” in the directory ~/BERN50/MENU/ and add -lz at the end of the “LIBS” line:

LIBS     = $(SUBLIBS) -L/opt/local/lib -L$(QTDIR)/lib -L/opt/local/lib -lICE -lSM -ldl -lqt-mt -lXext -lX11 -lm -lz

or else you will get error about undefined symbols “compress” if you want to compile the BERNESE-Menu. I’ve found out the zLib library was missing in the LFLAGS for compilation (this may be a bug of Macports qt3-qmake command, not sure).

8. Update your .bash login config

Now edit your “.bash_profile” or your “.bashrc” and add these lines:

# For BERNESE 5.0
export QTDIR=/opt/local/lib/qt3
source ~/BERN50/GPS/EXE/LOADGPS.setvar

9. Edit “configure.pm” script

Before launching the “configure.pm” script in ~/BERN50/GPS/EXE there are two issues which needs to be fixed:
An error message will appear with ‘qmake.cache’ not found etc. Just edit:

#edit ~/BERN50/GPS/EXE/configure.pm

and comment out the lines: 933-937 the one with qmake.cache. It should look like this:

#  my $cashFile = "$ENV{QTDIR}/.qmake.cache";
#  if (! -f $cashFile) {
#    die "File $cashFile not found\n".
#        "Please make sure that the QT library has been installed correctly.\n";
#  }

Then edit line 956 to read like from:

system("$qmake -cache $cashFile menu.pro");

to:

 system("$qmake menu.pro");

10. Launch “configure.pm” to compile the Menu and the Fortran programs

IMPORTANT: Don’t launch setup.sh again or else it will erase the newly modified LOADGPS.setvar and other files with the one from the .tar.gz archives.

Launch the configure.pm script from your Home directories BERN50 folder:

#source ~/.bash_profile
#cd ~/BERN50/GPS/EXE/
#configure.pm

Choose option “3 … Compile BERNESE Menu” or option “4 … Compile Fortran programs”.

It should hopefully compile correctly the menu and the fortran programs! Hurray!!!

If it fails to compile the menu one trick is to go directly to the directory ~/BERN50/MENU and invoke the commands:

#cd ~/BERN50/MENU/
#make clean
#make mocclean
#make

if you get the error:

Undefined symbols:
  "_compress", referenced from:
      compress(QString const&)in menutils.o
  "_uncompress", referenced from:
      uncompress(QMemArray const&)in menutils.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [menu] Error 1

then you need to edit the “~/BERN50/MENU/Makefile” and add “-lz” to the LIBS flags (see BERNESE Menu Configuration)

After succesful compilation:

11. Launch BERNESE MENU

Launch BERNESE 5.0 by typing the following command in the “Terminal.app”:

#G

An X11 Window opens and the BERNESE Menu appears. Enjoy!

Comments are closed.