×
Search

 

    Manual compilation of Tephra2

    TephraProb compiles Tephra2 through a bit of Matlab hocus pocus to facilitate problems of OS dependancy, but the mighty Matlab can sometime fail us. In this case, it becomes necessary to manually compile Tephra2 from the command line to see what the error message is. I spent a fair amount of time writing this procedure in emails to people who encountered problems and I thought I would write it down here.

    Just to clarify things, compiling is the process of transforming files containing lines of code into a program that can be executed by the user. The whole compilation process depends on such aspects as the computer’s architecture or OS, so it needs to be performed on each computer separately. Again, most of the time everything should be taken care of smoothly within TephraProb, but just in case…

    Unix for non-nerds

    This process requires to access Tephra2 through the command line (Terminal on Unix, Cygwin Terminal on Windows). Here are some tips on how to use it.

    The main command to navigate through folders is cd:

    cd folder 	# Enter the directory called folder
    cd .. 		# Go back to the parent directory

    Where to go?

    Another useful command is ls, which lists the content of the current directory. When navigating directories with cd, note that the tab key auto-completes commands. Taking the example above, typing cd fold and hitting tab is likely to complete the command to cd folder/.

    Locating Tephra2

    The Tephra2 executable (tephra2-2012 on Unix, tephra2-2012.exe on Windows) should be located in the tephraProb/MODEL/ folder. Open the terminal and navigate to this location. If you are unsure in which directory you are when starting the Terminal, the command pwd will help. On Unix, it usually starts in your home folder (/home/username/ on Linux, /Users/username/ on Mac).

    On Windows/Cygwin, things are slightly different. Let’s assume that TephraProb is located in E:/TephraProb/, the right way to navigate to this location on the Cygwin terminal is:

    cd /cygdrive/e/TephraProb

    Manual compilation

    Once in the MODEL/ folder, enter the forward_src folder and type:

    make

    Hopefully, that should result in the last line printed to the command line being:

    mv tephra2-2012 ../tephra2-2012

    There might be warnings, but these should be ok.

    Common errors

    Here, I will try and list common errors that have been encountered.

    File format not recognised

    This error was encountered on Cygwin:

    make[1]: Entering directory '/cygdrive/e/Seb/Documents/CODES/TephraProb/MODEL/forward_src'
    `which gcc` -Wall -g -idirafter ../include -o tephra2-2012 new_tephra.o tephra2_calc.o -lm /libcygwin64/libgc.a -ldl
    new_tephra.o: file not recognized: File format not recognized

    This was solved by entering in the forward_src, removing the *.o files and recompiling:

    cd forward_src
    rm *.o 	# Remove *.o files
    make

    Manual Tephra2 run

    If the compilation worked, the Tephra2 executable should now be located in the folder MODEL/. To start the command, type ./tephra2-2012 on Unix or ./tephra2-2012.exe on Windows, which will result in:

    Missing comand line arguments,
    USAGE: <program name> <config file> <points file> <wind file> <file of grain sizes>

    You now have to specify all input files including:

    1. A configuration file, typically a .conf file located somewhere in TephraProb/RUNS/runName/runNumber/CONF/
    2. A grid file, typically a .utm file located in TephraProb/GRID/gridName/
    3. A wind file, typically a .gen file located in TephraProb/WIND/windName/
    4. A grain-size distribution file, typically a .gsd file located somewhere in TephraProb/RUNS/runName/runNumber/GS/

    You can either specify the full path to these files or copy them in the same folder as the Tephra2 executable, in which case Tephra2 can be run by typing:

    ./tephra2 conf.conf grid.utm wind.gen tgsd.gsd > test.out # Unix
    ./tephra2.exe conf.conf grid.utm wind.gen tgsd.gsd > test.out # Windows

    Note that the last argument > test.out specifies the output file to Tephra2.

    Common errors

    Permission denied

    If a Permission denied error is returned upon using the ./tephra2-2012 command, try changing the access permissions:

    chmod 755 tephra2-2012

    Other problems

    I am trying to build a database of common problems faced by TephraProb / Tephra2 users. Contact me (if you haven’t already done it) and we will post the answer here for other people.