Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > os > by-pkgid > 4b194777eaf705e440bb2ce282d32772 > files > 691

GMT-doc-4.5.3-3.fc14.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>P.1 Running GMT in isolation mode</TITLE>
<META NAME="description" CONTENT="P.1 Running GMT in isolation mode">
<META NAME="keywords" CONTENT="GMT_Docs">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="GMT_Docs.css">

<LINK REL="next" HREF="node255.html">
<LINK REL="previous" HREF="node253.html">
<LINK REL="up" HREF="node253.html">
<LINK REL="next" HREF="node255.html">
</HEAD>

<BODY  bgcolor="#ffffff">
<!--Navigation Panel-->
<A NAME="tex2html6288"
  HREF="node255.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html6282"
  HREF="node253.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html6276"
  HREF="node253.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html6284"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html6286"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html6289"
  HREF="node255.html">P.2 Using both GMT</A>
<B> Up:</B> <A NAME="tex2html6283"
  HREF="node253.html">P. Special Operations</A>
<B> Previous:</B> <A NAME="tex2html6277"
  HREF="node253.html">P. Special Operations</A>
 &nbsp; <B>  <A NAME="tex2html6285"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html6287"
  HREF="node256.html">Index</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION003310000000000000000"></A>
<A NAME="sec:isolationmode"></A><A NAME="34211"></A>
<BR>
P.1 Running <A NAME="tex2html1954"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> in <I>isolation mode</I>
</H1>
In Chapter&nbsp;<A HREF="node31.html#ch:4">4</A> it is described how <A NAME="tex2html1956"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> creates several (temporary) files to communicate between the different commands that make up the script that finally creates a plot. Among those files are:
<DL>
<DT><STRONG><U>.gmtdefaults4</U>.</STRONG></DT>
<DD>This file covers about 100 different settings that influence the layout of your plot, from font sizes to tick lengths and date formats (See Section&nbsp;<A HREF="node33.html#sec:gmtdefaults">4.2</A>). Those settings can be altered by editing the file, or by running the <A NAME="tex2html1957"
  HREF="../man/gmtset.html"><I><B>gmtset</B></I></A><A NAME="34281"></A> command. A problem may arise when those settings are changed half-way through the script: the next time you run the script it will start with the modified settings and hence might alter your scripts results. It is therefore often necessary to revert to the original <U>.gmtdefaults4</U> file. <I>Isolation mode</I> avoids that issue.
</DD>
<DT><STRONG><U>.gmtcommands4</U>.</STRONG></DT>
<DD>This file is created to communicate the command line history from one command to the next (Section&nbsp;<A HREF="node58.html#sec:gmtcommands">4.5</A>) so that shorthands like <B>-R</B> or <B>-J</B> can be used once it has been set in a previous <A NAME="tex2html1958"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> command.
The existence of this file makes if impossible to run two <A NAME="tex2html1959"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> scripts simultaneously in the same directory, since those <U>.gmtcommand4</U> files may clash (contain different histories) and adversely affect the results of both scripts.
</DD>
<DT><STRONG><U>.gmt_bb_info</U>.</STRONG></DT>
<DD>This file contains the information about the BoundingBox (Section&nbsp;<A HREF="node189.html#sec:eps">C.1</A>) of the <I>PostScript</I> output. This information too has to be transferred from one <A NAME="tex2html1960"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> command to the next in a script. Again, running two commands simultaneously in the same directory may have disastrous effects on that file.
</DD>
</DL>

<P>
A cure to all these woes is the <I>isolation mode</I> introduced in <A NAME="tex2html1961"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> version 4.2.2. This mode allows you to run a <A NAME="tex2html1962"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> script without leaving any traces other than the resulting <I>PostScript</I>  or data files, and not altering the <U>.gmtdefaults4</U> or <U>.gmtcommands4</U> files. Those files will be placed in a temporary directory instead. And if properly set up, this temporary directory will only be used by a single script, even if another <A NAME="tex2html1963"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> script is running simultaneously. This also provides the opportunity to create any other temporary files that the script might create in the same directory.

<P>
The example below shows how <I>isolation mode</I> works.

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#!/bin/sh
#               GMT Appendix P, example 1
#
# Purpose:      Illustrates the use of isolation mode
# GMT progs:    gmtset, grdimage, grdmath, makecpt, pscoast
# Unix progs:   mktemp, rm
#
ps=GMT_App_P_1.ps

# Create a temporary directory. $GMT_TMPDIR will be set to its pathname.
# XXXXXX is replaced by a unique random combination of characters.
export GMT_TMPDIR=`mktemp -d /tmp/gmt.XXXXXX`

# These settings will be local to this script only since it writes to
# $GMT_TMPDIR/.gmtdefaults4
gmtset COLOR_MODEL rgb ANNOT_FONT_SIZE_PRIMARY 14p

# Make grid file and color map in temporary directory
grdmath -Rd -I1 Y = $GMT_TMPDIR/lat.nc
makecpt -Crainbow -T-90/90/60 -Z &gt; $GMT_TMPDIR/lat.cpt

# The grdimage command creates the history file $GMT_TMPDIR/.gmtcommands4
grdimage $GMT_TMPDIR/lat.nc -Sl -JK6.5i -C$GMT_TMPDIR/lat.cpt -P -K &gt; $ps
pscoast -R -J -O -Dc -A5000 -Gwhite -B60g30/30g30 &gt;&gt; $ps

# Clean up all temporary files and the temporary directory
rm -rf $GMT_TMPDIR
</PRE>
<BR CLEAR="ALL">
<HR>
<P>

<DIV ALIGN="CENTER"><A NAME="fig:GMT_App_P_2"></A><A NAME="34234"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure P.1:</STRONG>
Example created in isolation mode</CAPTION>
<TR><TD>
<DIV ALIGN="CENTER"><IMG
 WIDTH="553" HEIGHT="298" ALIGN="BOTTOM" BORDER="0"
 SRC="img306.png"
 ALT="\includegraphics[width=\textwidth]{scripts/GMT_App_P_2}">
</DIV></TD></TR>
</TABLE>
</DIV>

<P>
The files <U>.gmtdefaults4</U> and <U>.gmtcommands4</U> are automatically created in the temporary directory <U>$GMT_TMPDIR</U>. The script is also adjusted such that the temporary grid file <U>lat.nc</U> and colormap <U>lat.cpt</U> are created in that directory as well. To make things even more easy, <A NAME="tex2html1964"
  HREF="http://gmt.soest.hawaii.edu"><B>GMT</B></A> now provides a set of handy shell functions in <A NAME="tex2html1965"
  HREF="../man/gmt_shell_functions.sh.html"><I><B>gmt_shell_functions.sh</B></I></A><A NAME="34323"></A>: simply include that file in the script and the creation and the removal of the temporary directory is reduced to a single command.

<P>
<BR CLEAR="ALL">
<HR>
<BR>
<PRE>#!/bin/sh
#               GMT Appendix P, example 2
#
# Purpose:      Illustrates the use of isolation mode
# GMT progs:    gmtset, grdimage, grdmath, makecpt, pscoast
# GMT funcs:    gmt_init_tmpdir, gmt_remove_tmpdir
#
ps=GMT_App_P_2.ps

# Make GMT shell functions accessible the the script
. gmt_shell_functions.sh

# Create a temporary directory. $GMT_TMPDIR will be set to its pathname.
gmt_init_tmpdir

# These settings will be local to this script only since it writes to
# $GMT_TMPDIR/.gmtdefaults4
gmtset COLOR_MODEL rgb ANNOT_FONT_SIZE_PRIMARY 14p

# Make grid file and color map in temporary directory
grdmath -Rd -I1 Y = $GMT_TMPDIR/lat.nc
makecpt -Crainbow -T-90/90/60 -Z &gt; $GMT_TMPDIR/lat.cpt

# The grdimage command creates the history file $GMT_TMPDIR/.gmtcommands4
grdimage $GMT_TMPDIR/lat.nc -Sl -JK6.5i -C$GMT_TMPDIR/lat.cpt -P -K &gt; $ps
pscoast -R -J -O -Dc -A5000 -Gwhite -B60g30/30g30 &gt;&gt; $ps

# Clean up all temporary files and the temporary directory
gmt_remove_tmpdir
</PRE>
<BR CLEAR="ALL">
<HR><A NAME="34244"></A>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html6288"
  HREF="node255.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html6282"
  HREF="node253.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html6276"
  HREF="node253.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html6284"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> 
<A NAME="tex2html6286"
  HREF="node256.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> 
<BR>
<B> Next:</B> <A NAME="tex2html6289"
  HREF="node255.html">P.2 Using both GMT</A>
<B> Up:</B> <A NAME="tex2html6283"
  HREF="node253.html">P. Special Operations</A>
<B> Previous:</B> <A NAME="tex2html6277"
  HREF="node253.html">P. Special Operations</A>
 &nbsp; <B>  <A NAME="tex2html6285"
  HREF="node1.html">Contents</A></B> 
 &nbsp; <B>  <A NAME="tex2html6287"
  HREF="node256.html">Index</A></B> 
<!--End of Navigation Panel-->
<ADDRESS>
Paul Wessel
2010-07-14
</ADDRESS>
</BODY>
</HTML>