next up previous contents
Next: Basic formulation Up: 3. Getting Started Previous: 3.13 Finding all differences

   
3.14 Applying bug fixes

In between releases of MOM, it is necessary to be able to correct bugs. If the number of lines of code needed to correct a bug is significantly smaller than the number of code lines in the file being corrected, then it is more efficient to supply the changes rather than the new file. For example, If file ``changes'' was constructed as


diff -e oldfile newfile > changes


then file ``newfile'' can be constructed from file ``oldfile'' using the following C shell script:


#! /bin/csh -f
# update script to build newfile from oldfile using changes which
# were generated by diff -e oldfile newfile > changes
if ($3 == "") then
  echo " "
  echo 'script "update" builds "newfile" from "oldfile" using "changes"'
  echo "which were generated by diff -e oldfile newfile > changes"
  echo "->usage: update oldfile changes newfile"
  exit
endif
set oldfile = $1
set chgs = $2
set newfile = $3
set work = .temp
cat $chgs > $work
echo "w $newfile" >> $work
echo "q $newfile" >> $work
ed $oldfile < $work
/bin/rm $work
echo "->Done building $newfile from $oldfile + $changes"


If the above script is saved as file ``update'', then the following one-liner will built the ``newfile'' from the ``oldfile'':


update oldfile changes newfile



  
Figure 3.1: Directory structure for MOM at GFDL
\begin{figure}
\begin{center}
\resizebox{15cm}{!}{\includegraphics{direct_1.ps}} \end{center}\end{figure}



RC Pacanowski and SM Griffies, GFDL, Jan 2000