MacOS

These notes apply to the installation of February 1, 2024 under MacOS Version Sonoma 14.3.1  The test machine was a MacBook Air with the M2 Apple Silicon chip.

These instructions should apply to other MacOS versions.

  1. Determine the version of the operating system: Top menu bar AppleLogo -> About This Mac will give the version, e.g., OSX Version 13.2.1It also gives processor.Note whether you have the older Intel system or the newer M1/M2 system.
  2. Install xcode on your Mac, since you will need command line tools. Click on AppStore and then search for Xcode. You will need your password to download from the Apple Store.
    When Xcode in installed, the Icon in AppStore will now exhibit
    1. "Open", so open it and
    2. Agree (password again).
  3. Install Xquartz to get X11 graphic support. You can get this at http://www.xquartz.org/ . This will also set up the links required to compile X11 programs. When the download is complete,
    1. Install
    2. Open
    3. Agree (enter password)
    4. Install
Next we need the compilers and other software. We will get these using both Homebrew and MacPorts
  1. Install MacPorts http://www.macports.org/install.php. Select the version for your operating system, e.g. if running Ventura 13.2.1, MacOS Ventura v13
    Clicking on the install will place a package in your downloads. Just click, icons will appear, and then click on the MacPorts...pkg icon. Answer the questions and enter your password.
    MacPorts gives libraries and LINUX like tools that will be useful for productivity. I have bzip2, gawk, ghostscript, gv, ImageMagick, ncurses, xfig and xv among others:
    sudo port install gv
    sudo port install xv
    sudo port install ImageMagick
                  
  2. Install homebrew brew.sh. The web page gives a command for installing homebrew. As of April 27, 2023, this command is
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    Refer to the HomeBrew website to ensure that this command line is uptodate. Now install the following packages:
    brew install wget
    brew install gcc
    brew install make                    This will give the GNU make         
    brew install xfig
    brew install gawk
    brew install ghostscript
    brew install ffmpeg
    brew install gmt
    brew install graphicsmagick
    brew install --cask mactex           This will give LaTex for document creation        
    

    The reason for downloading from the two sources is that a  package  missing from one may be in  the other. The other, less obvious reason, is that distribution may not work as desired. For example, I use the ImageMagick convert program to convert the Computer Programs in Seismology (CPS) EPS files to PNG for display on the weband inclusion in documenbts and presentations. The CPS program plotnps -EPS determines the boundingbox of  a figure, and uses it by placing the line %%BoundingBox: (atend) at the top of the EPS file and then placing at the second last line the exact dimensions, for example %%BoundingBox: 47 45 585 321. I found that the Imagemagick 7.1.1-8 downloaded from HomeBrew did not recognize this but that the ImageMagick 6.9.11-60 downloaded from MacPorts did recognize this. The effect was that the 7.1.1-8 version yielded a cropped bit graphic image, which was not desired. Note: HomeBrew does have a link to download a Version 6 of ImageMagick.

    Not all packages are required to compile CPS. I have selected the following  items in order to be productive:

    All of these installations will create an entry in the .zprofile in the login directory to point to the location of these executables

  3. Carefully enter the following command to point to the downloaded gcc instead of  the one installed. If the installed compiler is not Version 12, then ls /opt/homebrew/bin to see what has been installed. If the compiler was installed using HomeBrew
    sudo ln -s /opt/homebrew/bin/gcc-13 /opt/homebrew/bin/gcc
    
      If the compiler was installed  using MacPorts. You may have to do something like
    cd /usr/local/bin
    sudo ln -s /opt/local/bin/gcc-mp-11 gcc
    sudo ln -s /opt/local/bin/gfortran-mp-11 gfortran

    (The mp-11 means MacPorts gcc6 was installed. This how MacPorts  distinguishes the different versions)

  4. Since the default SHELLis zsh, Define the correct PATH so that the shell can find the sources. Carefully edit the .zprofile in your login directory to add lines at the end of the file such as
    OPATH=$PATH
    PATH=:.:$HOME/bin:$HOME/PROGRAMS.330/bin:$OPATH  
         (This assumes that you installed CPS in your login directory)
    
  5. You are now ready to compile CPS. If PROGRAMS.330 is in your login directory, then if you have an Intel Mac
    cd PROGRAMS.330
    ./Setup OSX40
    ./C 2>&1 C.txt
    
    If you have the newer Macs with the M1/M2 chip,
    cd PROGRAMS.330
    ./Setup OSXM
    ./C 2>&1 C.txt
    
  6. The file C.txt provides a record of the compile. To test the compile results, do
    ls bin/* | wc
    
    If you do not see on the order of 150 programs, then examine the C.txt to determine what failed. This is the file to send to the Email address  given on the main page if there are problems.