Task: Generate CLR Files

The CLR file format is designed to be human readable and human writeable (Just look into the .clr file for the IASP91 model to see that the file format is quite easy to understand). So there are two ways to generate a CLR file:

  1. Type it by hand
  2. write it using MKWRITECLR

Unless the model is machine generated and available in a MatLab-variable, it is probably easier to type .clr files by hand.

Type .clr File by Hand

The following description explains the typing of a .clr file step-by-step, what is a bit lenghty and looks more complicated than it actually is.

  1. Open a new ASCII file.
  2. Define the model's name.
    To do so, enter a new line
    !name YourModelName
    (You may use either Tab stops (ASCII9) or space (ASCII32) to separate keywords an parameters)
    This line defines that the Model is named "YourModelName".
  3. Define the model's publication year.
    To do so, enter a new line
    !year PublicationYear
    where "PublicationYear" is a number that denotes the year of publication, e.g. 1991.
  4. You may insert empty lines at any place to provide some optical structuring. Empty lines are ignored when reading the file.
  5. Define the planet, for which the model is valid. You have to specify both name and radius of the planet. Enter two lines:
    !planet !name PlanetName
    !planet !radius PlanetRadius
    here, PlanetName is a string specifying the name of the Planet, and PlanetRadius is a number (in fixpoint or as float) that gives the Planet's radius in km.
  6. Now enter the layer data.
    1. To start the description of a new layer, enter a new line
      !layer !start LayerName
      where LayerName is a string denoting the Layer's name. This string may be omitted.
    2. Specify the depth extent of the layer.
      You can specify this as depth in km measured from the surface by entering
      !layer !depth TopDepth BottomDepth
      where TopDepth and BoottomDepth are numbers denoting the depth of the top and the bottom of the layer.
      OR you can specify the radius in km, measured from the planet's center:
      !layer !radius BottomRadius TopRadius
      Where BootomRadius and TopRadius are the radius to the bottom and the top of the layer.
      NOTE that the first number is always the smaller one.
    3. To specify the coefficients of the P wave velocity, enter the coefficients of the Layer Polynomial in a new line:
      !layer !vp p1 p2 p3 pn
      The modifier "!vp" declares that this is the P wave velocity. The p1, p2, p3,...,pn are coefficients of a (n-1)-th degree polynomial, p1 being the constant term and pn being the coefficient of the highest power. (see section on Layer Polynomials in the CLR file format description)
    4. To specify other quantities, use the appropriate modifier:
      !vp
      P wave velocity
      !vs
      S wave velocity
      !rho
      Density
      !qp
      P wave Q-factor
      !qs
      S wave Q-factor
      The syntax is the same as for vp.
      If you wish to leave one or more of these quantities undefined, just do not enter a line with the respective modifier.
    5. To finish the layer, enter a new line
      !layer !end
  7. Finally, enter discontinuity data. A discontinuity is defined by depth and name
    !discon !depth DiscontinuityDepth DiscontinuityName
    where DiscontinuityDepth is a depth from the surface in km and DiscontinuityName is a string.
    A Discontinuity can also be defined by Radius and name
    !discon !radius DiscontinuityRadius DiscontinuityName
    where DiscontinuityRadius is the radius measured from the planet's center in km.

    There are several standard names for standard discontinuities like the Moho or the Core Mantle Boundary. A Table of these standard names is given in the General section of the tutorial.
  8. You can add comments at any place. A comment begins with "#", "//", or "/*" and ends at the end of the line.
Write .clr file using MKWRITECLR

If your velocity model is already stored in a CLR structure (see section on Data Structures for definition), you can write a .clr file using MKWRITECLR.

To do so, execute

  mkwriteclr(clr,path);
  

where clr is your data structure and path the path to store the file at.


eof.