User Programming
User Programming
Contents
User Programming
Introduction
What Is in This Manual? .................................................................................... 1
ModelBuilder
Whats in This Chapter? ................................................................................... 6
Overview ............................................................................................................. 7
R2003.12.1 Contents 6
Landmark Graphics Corporation User Programming
mb_html ................................................................................................... 30
mb_include .............................................................................................. 30
mb_lib ...................................................................................................... 30
mb_obj ..................................................................................................... 30
mb_pppdf ................................................................................................ 30
mb_src ..................................................................................................... 31
R2003.12.1 : 7
Landmark New Features For PetroWorks
Libraries ........................................................................................................ 79
Information ................................................................................................... 83
R2003.12.1 8
Landmark Graphics Corporation User Programming
R2003.12.1 : 9
Landmark New Features For PetroWorks
R2003.12.1 10
Landmark Graphics Corporation User Programming
R2003.12.1 : 11
Landmark New Features For PetroWorks
User Models
Introduction ........................................................................................................ 193
R2003.12.1 12
Landmark Graphics Corporation User Programming
Introduction
To access this manual online, select Help > Online Manual from the
PetroWorks Pro, PetroWorks Asset, or LogEdit Command Menu.
PetroWorks/LogEdit Documentation
The PetroWorks/LogEdit documentation manual set consists of the
following.
R2003.12.1 Introduction 8
Landmark Graphics Corporation User Programming
StratUtils Documentation
PetroWorks/LogEdit applications share a set of project management,
data management, visualization, and mapping utilities with StratWorks.
Documentation for these utilities appears in the following StratWorks
manuals:
OpenWorks Documentation
In addition to the PetroWorks/LogEdit and StratWorks manuals, you
may occasionally need to refer to several OpenWorks manuals to
perform certain tasks. These manuals include
Manual Conventions
This manual uses certain conventions to explain how to use various
features of the program:
R2003.12.1 Introduction 10
Landmark Graphics Corporation User Programming
ModelBuilder
If you are a model user (not a model writer) you can skip this chapter,
but be sure to read the introductory chapter of the PetroWorks Basic
Interpretive Applications manual.
As noted above, this chapter details the steps needed to develop or write
a model. The chapter User Models on page 193 contains instructions
for publishing a model, that is, placing the model in an area accessible
to other model users who you want to be able to use the model as well.
Overview (page 7)
Opening ModelBuilder (page 14)
Main Window Layout (page 15)
Getting Started (page 19)
Finding Your ModelBuilder Files (page 28)
Understanding the .mdl-.mds File Pair (page 32)
Designing Your Model (page 36)
Editing the .mdl File (page 38)
Editing the .mds File (page 72)
Configuring Your Model (page 75)
Building and Running a Model (page 84)
Model Data Specification Template with Keywords (page 87)
Example Models (page 98)
Recommended Reading (page 120)
Overview
user source code is interpreted at runtime user source code is compiled and a fully integrated application is
created
creates no permanent files creates an executable, allowing you to protect your intellectual
property while at the same time providing for distribution of that
application throughout your organization
Important Features
ModelBuilder creates interpretive applications that can
R2003.12.1 ModelBuilder 8
Landmark Graphics Corporation User Programming
Select to launch a
published model
Whether a model is run from the ModelBuilder menu or from the User
Models location, it runs like any other PetroWorks interpretive
application. As a model writer, you have control over the input and
output curves, depth framework, and parameters. Input and output
curve default names can be overwritten at runtime through the use of
Curve Aliases, Curve Names, or Curve Details with the Wellbore
Parameter Editor. As a model writer, you also determine the parameters
that users input, and you have the ability to specify default, maximum,
and minimum values.
In the simplest case, only two files are needed to create an interpretive
application from ModelBuilder.
The model algorithm code (.mdl) file is the algorithm code file that
contains the FORTRAN and C calls.
The general workflow for building and running models is shown below.
Start
Open ModelBuilder
Build model
Process model
End
R2003.12.1 ModelBuilder 10
Landmark Graphics Corporation User Programming
Also be aware that although you can link files from external FORTRAN libraries,
those libraries must be GNU FORTRAN complied. Do not mix libraries built
under GNU and other FORTRAN compilers.
You can compose an .mdl in any text editor. You can also open an
existing .mdl file in any text editor, modify it, and save it as a different
.mdl for a new model. You can even copy long, complex algorithms
from existing MathPack files and translate to FORTRAN syntax to
preserve the essential equations and related logic.
A sample .mds file format with examples of keywords and their usages
is provided at the end of this chapter in the section Model Data
Specification Template with Keywords on page 87.
Note
You can copy existing .mdl and .mds files directly into your new model source file
area when you create a new model. Doing so automatically generates the .mdl and
.mds files you need to build and run the copied model; however, ModelBuilder
uses the model name you selected for the new model. The Copy feature does NOT
copy optional source and object files associated with existing .mdl/.mds files.
R2003.12.1 ModelBuilder 12
Landmark Graphics Corporation User Programming
Sharing Models
When using ModelBuilder, your role may depart from traditional
interpretive or analytical workflows typical of the rest of PetroWorks.
As a model writer, you become, whatever your other duties, a software
developer. Consequently, you are affected by issues that may not be
obvious to a geoscientist, such as the creation and maintenance of
source text files within your project workspace.
Opening ModelBuilder
R2003.12.1 ModelBuilder 14
Landmark Graphics Corporation User Programming
Main
menu
fields
R2003.12.1 ModelBuilder 16
Landmark Graphics Corporation User Programming
New lets you create and name a new model within the current model
directory. This button opens the same window as File New Model
from the main menu.
Open lets you see a list of existing models within a particular directory.
This button opens the same window as File Open Model from the
main menu.
Configure opens the Configure window. From this window, you can
choose optional source files, object files, libraries, and compiler
switches for your model. You can also review or document information
on existing models by title and version.
Build Model lets you begin the model building process. This button is
grayed out (desensitized) if you are not the owner of the model.
Run lets you run your model after you have built it. This button is
grayed out (desensitized) until a model has been successfully built,
producing a viable model application executable.
Model Field
If you already know of an existing model that you want to use, you can
type the pathname followed by the filename in this field located at the
top of the ModelBuilder main window. After you create a new model,
the path and name appear in this field.
Model field
Model
contents
field
Status area
Status Area
ModelBuilder uses this area to keep you informed of the status of each
process.
R2003.12.1 ModelBuilder 18
Landmark Graphics Corporation User Programming
Getting Started
Before you begin using ModelBuilder, you must select a project from
OpenWorks and specify an interpreter and well listnormally done by
using the Project Status tool from the OpenWorks Command Menu.
You must then create and save your source priority preferences from
the Session menu on the PetroWorks Command Menu. (Refer to
PetroWorks/LogEdit Basics on page 24 in the Introduction to
PetroWorks Family of Products manual.)
1. From the menu bar, select File > Create Model Group Directory.
The following screen appears:
Note that the Model Group Directory name appears above the new
model name field. If this is not the directory in which you wish to
create your new model, do the following:
5. Type the name of the new model. (Your models name must
contain at least 4 characters and no more than 13 characters.) In
the sample window above, we named our model GOLD.
R2003.12.1 ModelBuilder 20
Landmark Graphics Corporation User Programming
7. If you choose to use the template files, click on OK and skip the
next section (Copying an Existing Model on page 23).
Below is a sample workflow for creating a new model and a new model
group directory:
Workflow to Create
a New Model and a
New Model Group
Directory
Optional
Select any optional source files,
object files, or libraries you want to
use in your model.
Configure
Set FORTRAN and C compiler
switches.
Supply information about your
model.
Yes
Build Errors?
Errors? Debug
No
Run
The diagram below shows a sample workflow for creating a new model
in an existing directory:
Workflow to Create
a New Model in an
Existing Directory
Optional
Yes
Yes
Build Errors? Debug
No
Run
R2003.12.1 ModelBuilder 22
Landmark Graphics Corporation User Programming
1. If you know the file and path name of the .mdl and .mds files you
want to use, you can type either one and click on OK. Both files
are copied into your workspace and given the model name you
chose.
2. If you do not know the file and path name of the .mdl and .mds
files you want to copy, click on the Select button to browse.
3. When you find the .mdl or .mds file you need, select it and click on
OK. Both files are copied into the .mdl and .mds files that appear
in the Model Contents Field (page 18) of the ModelBuilder main
window.
Workflow to Copy an
Existing Model and
Give It a new Name
OK
Yes
Build Errors? Debug
No
Run
R2003.12.1 ModelBuilder 24
Landmark Graphics Corporation User Programming
GOLD subdirectory
GOLD source files are in subdirectory src
src subdirectory
.mds file name = GOLD.mds
When copying an existing model, proceed from one screen to the next
using Filter. When you reach either the .mds or .mdl file, select it and
click on OK to copy it into your new model area. Both files are copied.
Deleting a Model
1. Select File > Delect Model.
R2003.12.1 ModelBuilder 26
Landmark Graphics Corporation User Programming
4. Select the Model Group Directory containing the model you wish
to delete. Press OK.
If by now you have created your model workspace and have created a
new model or copied an existing model as described in Getting
Started on page 19, ModelBuilder has generated many new files and
subdirectories associated with the model and workspace. You will to
need access and edit some of these files, such as the .mdl and .mds files.
Other files are for ModelBuilders use only.
Remember that ModelBuilder stores the .mds and .mdl files in the
<Model Group Dir>/<ModelName>/src subdirectory. See the
following diagrams.
home/workerbee/cmolaro/Arctic/GOLD/src/GOLD.mdl
Your home directory Model Model Model .mdl file
Group Directory Source
Directory Files
Directory
The diagram above shows the path to the .mdl file for the model GOLD
in the model group directory Arctic.
Once a model is built, you should protect the model files from being edited.
Automatic Files
When ModelBuilder builds a model, it creates various interdependent
source and include files in FORTRAN and C as well as necessary
system files for compiling and linking. These are all stored in this
subdirectory (as shown in the following diagram).
R2003.12.1 ModelBuilder 28
Landmark Graphics Corporation User Programming
mb_html
SUNSV
mb_include
bin***
mb_lib .exe
.exe
mb_pppdf
mb_src
include
Model**
lib
obj
.mdl
src
.mds
* The name you give your model group directory appears here in the hierarchy.
**The name you give your model appears here in the hierarchy.
*** An executable is created for the platform on which you create your model. SUNSV is the
platform for Solaris, and SGI is the platform for Silicon Graphics.
mb_html
When you create a model, ModelBuilder generates the mb_html
directory, which contains two files for each model. These files,
<modelname>.html and <modelname>_pl.html allow you to
open a page from your internet browser and view the .mdl and .mds
files as well as any information about the model that you entered the via
the Configure > Information feature of ModelBuilders main menu.
mb_include
This directory is created by ModelBuilder as a repository for include
files that you may want to share across multiple models. You can write
include files in FORTRAN or C.
mb_lib
This directory is created by ModelBuilder as a repository for library
files that you may want to share across multiple models.
mb_obj
This directory is created by ModelBuilder as a repository for object
files that you may want to share across multiple models.
mb_pppdf
This directory contains the petrophysical parameters definition files
created by ModelBuilder when you build a model.
mb_src
This directory is created by ModelBuilder as a repository for source
files that you may want to share across multiple models.
R2003.12.1 ModelBuilder 30
Landmark Graphics Corporation User Programming
Before delving into the details of editing .mdl and .mds files for
content, it is important to understand how these files work together to
build a model. As stated earlier, you may have other optional files
associated with your model, but ModelBuilder only requires the .mdl
and .mds files to build a model.
This section describes how the .mdl-.mds file pair works, ultimately to
generate an executable application with ModelBuilder. The .mdl-.mds
file pair shown below illustrates this process for a simple program
called GammaRays.
.mdl file
algorithm code file
comment
algorithm
.mds file
data specification file
comment
end of file
You will learn more about keywords in the section Editing the .mds
File on page 72.
When this model is built and run from the ModelBuilder main window,
a user interface identical to other PetroWorks applications is generated.
From the user interface, you can select wells and processing depths or
strat units, enter Wellbore Parameter Editor, and process your
ModelBuilder application. These processes are illustrated in the next
example.
R2003.12.1 ModelBuilder 32
Landmark Graphics Corporation User Programming
Note that more features are present in the PHID2RHOB .mds file than
in the GammaRays .mds file. Whereas the PHID2RHOB .mdl file
contains code familiar to a novice FORTRAN programmer, the .mds
file introduces the keywords unique to ModelBuilder:
TITL
VERS
GRPN
CNST
After you have finished creating and editing these two files, you can
click on the Build and Run buttons from the ModelBuilder main
window. If there are no errors, ModelBuilder builds an application user
interface with the name of your model such as the one shown on the
previous page. Clicking on the ModelBuilder Run button causes the
model interface to display; it does not process data. To process data,
you must use the Process button on the model interface. The following
diagram illustrates the workflow.
Enter
ModelBuilder Your Model
(user interface)
Select wells
Create or open models Select depth units
Create or modify .mds and .mdl Select processing depth intervals
files or zones
Debug model (at build time) Set processing direction
Process model
Edit
.mds file Parameters?
.mdl file
Process
Select parameters
Build Select input and output curves
Save parameters
Run
R2003.12.1 ModelBuilder 34
Landmark Graphics Corporation User Programming
It makes no difference whether you create the .mdl file or .mds file first.
Depending on how you think about your model when you are designing
it, you may prefer to create one or the other first.
Questions you might ask yourself when you are thinking about how
you want the model to work are
1. What is my goal? This may seem obvious, but there are at least
two reasons to specify the goal of your model in a somewhat
formal way:
2. What is my input?
Where does it come from? Does it come from a log curve? If so,
is it in an alias list? (Refer to the chapter Curve Alias List
Manager on page 6 of the PetroWorks/LogEdit Project
Management manual.) Do I have constants?
3. What is my output?
These questions and others are addressed in the next two sections,
Editing the .mdl File on page 38 and Editing the .mds File on
page 72. You should read and thoroughly understand these sections
before attempting to build a model.
CMNT+-------------------+----------------------+
CMNT|Option| Type | Attribute | Value |
CMNT+----------|-----------+-------------------+
IFRAMEWORK| ALL | USER | REFERENCE |reference curve |
IFRAMEWORK| ALL | USER | REFERENCE | NULL |
CMNT+-------------------------+----------------+
Actual code entries always contain the CMNT keyword before the field
delimiter descriptions and the dashed lines, but in the examples we
these have been removed.
In the example here, the top line contains field descriptions: Option,
Type, Attribute, and Value. The main keyword, here
IFRAMEWORK, appears to the left of the of the table. The other entries,
here ALL, USER, REFERENCE, reference curve, and null, consist of
allowed values that are described in this chapter.
R2003.12.1 ModelBuilder 36
Landmark Graphics Corporation User Programming
If you already have a FORTRAN file you want to use, you can copy the
necessary code into the .mdl file. Moreover, if you have code you want
to use in an existing FORTRAN or C file, it is best to make the code
into a subroutine to be called in the .mdl file.This way the algorithm
retains the original variable names, and the call to the subroutine uses
the log names and parameters to be specified in the .mds file.
After you have created a model group directory and a model, the model
name and path appear in the Model Contents field as previously
described. To edit the .mdl file, follow the instructions below:
1. Select File > Open Algorithm File (.mdl). The .mdl file shown on
the main ModelBuilder window opens in the NEDIT file editor.
3. Use the general rules, below, to continue editing the .mdl file.
4. When you are finished editing the .mdl file, select File Save.
General Rules
You must follow some specific rules when developing your .mdl file:
R2003.12.1 ModelBuilder 38
Landmark Graphics Corporation User Programming
In the .mdl file you can use virtually any legal FORTRAN syntax.
For example:
R2003.12.1 ModelBuilder 40
Landmark Graphics Corporation User Programming
For example, for the variable MD_PROC_UNIT, the value can be either
FEET or METERS. An example of code is:
CHARACTER*6 PROC_UNIT
In the table, numbers in parentheses refer to pages where you can find
more information on or an example of the variable.
R2003.12.1 ModelBuilder 42
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 44
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 46
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 48
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 50
Landmark Graphics Corporation User Programming
Processing Flags
You can use logical flags to determine the processing state at a
particular point in your model or to change the processing state. There
are two types of flags:
The flag MD_MDLINT is TRUE only for the first sample of the model.
The flag MD_WELLLINT is TRUE only for the first sample of the well.
MD_WELLINT=TRUE
MD_ZONINT=TRUE &
MD_LSTZON=FALSE
(All LST = FALSE)
A
At Depths Between
MD_WELLINT=FALSE
MD_LSTWELL=FALSE
At Depths Between
MD_WELLINT=FALSE
MD_LSTWELL=FALSE MD_ZONINT=FALSE &
MD_LSTZON=TRUE
MD_WELLINT=TRUE
7000 ft MD_ZONINT=TRUE
MD_ZONINT=TRUE &
MD_LSTZON=FALSE
MD_ZONINT=FALSE
8000 ft MD_LSTZON=TRUE 8000 ft MD_LSTZON=TRUE &
MD_LSTWELL=TRUE MD_LSTWEL=TRUE
R2003.12.1 ModelBuilder 52
Landmark Graphics Corporation User Programming
Some of the reserved variable names used in the sample above have not
yet been discussed. To look up a reserved variable name and its
definition, refer to the table The .mdl Reserved Variable Names and
Features on page 42.
If all input curves are resampleable, the model uses the curve with
the smallest increment as the reference curve
The actual processing interval depends on the set of input curves and
the user-selected type: Total Depth Range, Depth Interval, or Unit
Selection. The intervals top depth is the shallowest point of any input
curve. The bottom of the interval is the deepest point.
DEPTH_UOM=FEET
DEPTH_UOM=METERS
R2003.12.1 ModelBuilder 54
Landmark Graphics Corporation User Programming
RESPONSE=WEAK
Model reports incompatibility warning, but continues processing
(default).
RESPONSE=STRONG
Model reports incompatibility error and aborts processing well.
Multiple Passes
If you want your model to make multiple passes over a particular depth
interval (defined by total depth of the well, a specified top and bottom
depth, or by an interval previously defined as a strat unit), you must
include the following code:
MD_SETCUR_IN =.TRUE.
MD_NEWPAS =.TRUE.
IMPORTANT!
You must also add PASS=YES to the .mds file. See Editing the .mds File on
page 72.
Change Depths
A powerful feature of ModelBuilder gives you control over the depths
from which data is retrieved and the depths to which data is written.
(Be sure to read How ModelBuilder Uses the .mdl File on page 38
for basic information about depth control.)
In the model, you can change the input depth (MD_DEPTH) and output
depth (MD_XOTDEP). (Note that each time you set MD_DEPTH, you
must also set a corresponding MD_SETCUR_IN=.TRUE.; each time
you set MD_XOTDEP, you must also set a corresponding
MD_SETCUR_OUT =.TRUE.) If the model only needs to process and
output data, you must set the current depth to ABSENT with the
command MD_DEPTH=ABSENT. The model then resets MD_DEPTH
automatically for the next iteration. You must set the depth to ABSENT
each time you want to suppress an input or an output. At the end of a
zone or the end of processing, it resets with MD_ZONEND=.TRUE.,
MD_WELLEND, and MD_MDLEND=.TRUE., respectively. The variable
names described in last three sections are all used when making
multiple passes and changing or controlling depth.
R2003.12.1 ModelBuilder 56
Landmark Graphics Corporation User Programming
Perhaps you wish to average the two GR values and then output the
average to a depth half way between 1000 feet and 1010 feet. Initially,
MD_XOTDEP will be set to the initial depth, 1000 feet. If you do not
reset MD_XOTDEP, your answer (in this case, the average of the GR at
1000 feet and 1010 feet) will be written to the output curve at 1000 feet,
since this is the value of MD_XOTDEP set by ModelBuilder when your
model initially ran. You can, however, set MD_XOTDEP = 1005 feet,
which is half way between your depths. When you set MD_XOTDEP =
1005, this tells ModelBuilder to output your answer to 1005 feet and
not the current depth which is 1000 feet.
Let us say you are now finished with the all your calculations at the
current depth. You need to reset MD_XOTDEP = ABSENT so when the
depth is incremented and a new set of log curve values is passed to your
model, ModelBuilder will then resume control of the depth and begin
use using 1000.5 feet as its current depth. Likewise you must reset
MD_XOTDEP = ABSENT at the end of your model to allow outputting
of any new data to the next incremental depth.
Filtering
Most petrophysical applications process data at only one depth level at
a time. The simpler ModelBuilder applications do the same. However,
ModelBuilder can read in and process log curves over multiple depth
levels, as in, for example, when vertically filtering log curves. You can
specify how many depth levels to read in at a time by using the variable
NSMI in the .mds file. For example, to read in three depth levels at a
time and to assign that value to a variable (NumSamplesIn) used in
the .mdl file, you type the following line in your models .mds file:
NSMI| 3 | NumSamplesIn |
You can specify how many depth levels to write out by using the
variable NSMO in your .mds file. For example, even though you may
read in three samples, when you do a vertical filter operation, you only
want to write out one sample. The following line in a .mds file writes a
NSMO| 1 | NumSamplesOut |
Recall that the model user can specify the direction in which the model
processes data. Assume that the direction is set to Down, and you have
the following Depths and GR values:
ISMO| 2 | OutputIndex |
As you can see, ISMO is set to a value of 2, and given the name
OutputIndex. If you examine the depths and log values above, you
will see why it has been given the value of 2: to write out a data value at
a depth corresponding to the middle depth of the three log values that
were read in.
R2003.12.1 ModelBuilder 58
Landmark Graphics Corporation User Programming
At the next depth level the application processes, the data in the
program would look like this:
Depth GR OutputIndex
1000.0 75.2
Current Depth Level-->1000.5 82.5 | 1
1001.0 65.2 | 2 <-- Depth we want to write out
1001.5 55.6 | 3
1002.0 45.8
1002.5 34.2
1003.0 29.9
1004.5 21.1
1005.0 19.6
The output value of the GR_FILTER writes out at a depth index offset
one element (2) from the current input depth element (1).
+-------------------+----------------------+
|Option| Type | Attribute | Value |
+----------|-----------+-------------------+
IFRAMEWORK| ALL | USER | REFERENCE |reference curve |
IFRAMEWORK| ALL | USER | REFERENCE | NULL |
+------------------------+-----------------+
The former is used to specify a default reference curve name for the
parameter; the latter leaves the parameter value undefined (NULL).
R2003.12.1 ModelBuilder 60
Landmark Graphics Corporation User Programming
During processing, the .mds input mnemonics are searched for a match
to the predefined reference curve. If found, the input curve name
specified by the user in the Wellbore Parameter Editor for that .mds
curve mnemonic (as defined by a LOGS keyword entry) becomes the
working reference curve. If not found, then that mnemonic is assumed
to correspond to a curve existing in the well.
If the reference curve exists in the well, the model evaluates the
compatibility of the reference curve framework and the input curve
frameworks. If the frameworks are resampleable or are
nonresampleable but compatible, processing continues and the inputs
are resampled as necessary. If the frameworks are incompatible and
nonresampleable, processing continues on the basis of the value of the
RESPONSE keyword.
The .mds syntax options for this case are the IFRAMEWORK keyword
and the FIXED framework type.
+--------------------------------------------+
| Option | Type | Attribute | Value |
+-------------------+------------------------+
IFRAMEWORK| ALL | FIXED | REFERENCE | reference curve|
+-------------------+------------------------+
The model writer may also choose to let users enter a depth increment
value as a parameter. The model writer controls this behavior with the
IFRAMEWORK .mds keyword, the USER framework type, and the
INCREMENT attribute. The model writer can supply a default
increment value for the parameter.
+------|------------+------------------------+
|Option| Type | Attribute | Value |
+------|-------------------------------------+
IFRAMEWORK| ALL | USER | INCREMENT | parameter name |
+------|-----------+-------------------------+
The input curve frameworks are evaluated for compatibility with the
increment value during processing by determining resampleability of
each. If incompatibility is found (nonresampleable curve), processing
continues on the basis of the value of the RESPONSE keyword.
MD_FRAME_INCREMENT(1)
Set to 0 if non-resampleable; or to a specific value. Note that you
must have an index for all frame variables even if there is only one
framework (input and output).
Curve Attributes
Curve attributes are specified in the .mds file with the LOGS keyword
entries as well as with LATT entries. The attributes from LOGS are:
Name
Input/Output type
Unit of Measure
R2003.12.1 ModelBuilder 62
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 64
Landmark Graphics Corporation User Programming
MRIL echo trains n not applicable RAMP(i) MRIL data arrives as two multi-valued
curves, RAMP (raw amplitude) and RPHA
(raw phase). Data points can number from
3 to 1000, but are usually about 400.
Elements are at a uniform sample
increment, Te.G
Dipmeter m,n z,m,n dip(i,k) n pads by m buttons per pad: pads = 3,4,6;
buttons = 1,2
Multiple sample sets on z-index of pads x
buttons
Photographs (core, m,n z,m,n bmp(i,k) m by n rectangle of data. The data area
SEM, outcrop,) may be scaled to a depth range (as with a
bmp(j,i,k) core photo) or may be indexed to a single
depth (as an SEM photo)
multiple sample sets on z-index
Well test data 2,n z,m,n wtd(i,k) Usually pressure vs. time: pressure-time
pairs with time periodic or aperiodic.
wtd(j,i,k)
multiple samples on z-index
Dimension Metrics
The attribute DIMENSION2 refers to the n-dimension, and
DIMENSION3, to the m-dimension. It is important to note that the
actual number of curve data values would be the number of points for
DIMENSION2 multiplied by the number of points for DIMENSION3.
The keyword entries below describe evenly spaced points on the
dimension axes.
For input 2D/3D curves, the only required.mds file keyword entry for
defining dimension metrics is NPOINTS (number of points).
+--------------|------------|--------|------+
| Curve Name | Attribute | Type | Value|
+--------------|------------|--------|------+
LATT|array name | DIMENSION2 | NPOINTS| n |
+--------------|------------|--------|------+
LATT|array name | DIMENSION3 | NPOINTS| m |
+---------------|------------|--------|-------+
R2003.12.1 ModelBuilder 66
Landmark Graphics Corporation User Programming
Dimension MetricsExplicit
You can dynamically redefine the number points on a specific
dimensions axis at the beginning of the model runs where the
maximum number of points for that specific dimension has been
specified in the .mds file. Define these values using the model variables
MD_CURVE_2ND_NPOINTS and MD_CURVE_3RD_NPOINTS.
UNITS is the unit of measure for the point values along the specific
dimension axis. For example, a semblance plot might have ms
(milliseconds) for DIMENSION2 axis and ft/s (feet per second) for
the DIMENSION3 axis.
+--------------|------------|--------|------+
| Curve Name | Attribute | Type | Value|
+--------------|------------|--------|------+
LATT|array name | DIMENSION2 |DYNAMIC | |
LATT|array name | DIMENSION2 |UNITTYPE|time |
LATT|array name | DIMENSION2 | UNIT | ms |
LATT|array name | DIMENSION2 |NPOINTS | 512 |
LATT|array name | DIMENSION3 |DYNAMIC | |
LATT|array name | DIMENSION3 |UNITTYPE|time |
LATT|array name | DIMENSION3 | UNIT | ft/s |
LATT|array name | DIMENSION3 |NPOINTS | 512 |
+---------------|------------|--------|------+
PROGRAM DYNAMIC 2D
C
C Dynamically redefine size
C
INTEGER I,J,IER
character txt*80
C Initialize counter
if (MD_MDLINT) then
MD_CURVE_2ND_NPOINTS(LDX_LOG2X) = NINT(USER_DIM)
SET_CURVE_SECOND_NPTS(LDX_LOG2X,NINT(USER_DIM), IER)
MD_CURVE_2ND_NPOINTS(LDX_LOG2F) = NINT(USER_DIM)
SET_CURVE_SECOND_NPTS(LDX_LOG2F,NINT(USER_DIM), IER)
ENDIF
CHECK_SM = 0.0
LOG2X_1 = LOG2X(1)
C---- Set new value and increment counter
DO 10 J = 1,MD_CURVE_2ND_NPOINTS(LDX_LOG2F)
if (LOG2X(J).NE.ABSENT) THEN
R2003.12.1 ModelBuilder 68
Landmark Graphics Corporation User Programming
LOG2F(J) = LOG2X(J)
CHECK_SM = CHECK_SM + LOG2X(J)
ENDIF
10 CONTINUE
END
Parameter Data
MODELTYPE=ACQUISITION
The rules to be used for retrieving parameters from the database are as
follows.
Interpretive
Curves: projects
well
Parameters: project
well
zone
zone/well
Acquisition
Curves: project
well/service/run/pass
Parameters: project
well/service/run/pass
.mdl File
There is only one model variable array of interest when you program
the acquisition method for your model. These are the parameter names,
to be used in the model code for reporting purposes:
MD_PARNAM(CDX_parameter_name)
Array of parameter names passed from the database (1 MD_PARNUM)
CRX_parameter_name
Defines the index of the parameter_name in the array of names.
MD_PARNUM is the total number of parameters.
Processing Interval
The processing interval for an acquisition model is the intersection of
the input curves with details corresponding to the process control
values. If a required input curve is selected whose details are different
and does not intersect with the other curves, an error is reported and the
model aborts. If an optional input curve is selected whose details are
different and does not intersect with the other curves, a warning is
issued and the model continues. This is identical to the manner of
handling required versus optional curves in general.
Output Curves
If all acquisition input curves represent the same service, pass, and run,
then the output curves are considered a part of this set, and those details
are written to the output curve header. However, if the input curves
have mixed details, then the output curves are created as composite
curves.
R2003.12.1 ModelBuilder 70
Landmark Graphics Corporation User Programming
Note
Once you have a working model that runs, you can edit values set in the .mds file
by selecting Edit Parameters from the running model window. Doing so opens
the Wellbore Parameter Editor from the model and allows you to change
parameter values.
After you have created a model group directory and a new model, the
new model name and path appear in the Model Contents field as
described in Creating Your Model Workspace on page 19. To build a
new .mds file, follow the instructions below:
1. Double-click on the .mds file and path name shown in the Model
Contents field to select the file.
Double-click on
the .mds file line
to select the file.
2. Select Tools > File Editor. The .mds template file opens.
4. When you have finished editing this file, select File > Save.
General Rules
ModelBuilder interprets the .mds file using keywords separated by
delimiters. Therefore, the physical file format is just as critical in the
.mds file as it is in the .mdl (FORTRAN) file. The following are some
general rules for creating an .mds file:
The .mds file must have a .mds extension and have a filename that
is the same as the .mdl filename.
Begin each line in the .mds file with a keyword. (See the
discussion of keywords below.)
R2003.12.1 ModelBuilder 72
Landmark Graphics Corporation User Programming
The final steps before you build and run your model may be to provide
information related to your model and make selections from the
Configure window. From the Configuration window, you may:
R2003.12.1 ModelBuilder 74
Landmark Graphics Corporation User Programming
Source Files
Source files are ASCII text files written in C or FORTRAN and are
compiled to create object files. You can create your own source files in
any text editor that can save files as ASCII text. Follow the instructions
below to choose a source file to include in your model.
If you make changes to a source file, you can click on the Compile
button to make sure it compiles without error before you continue. (See
Compile Button on page 77.)
1. Click on the Source Files tab in the Configure window. Any source
files that exist in your path appear in the window.
6. Click on the Select button. The file or files you chose now appear
in the Model Contents window under Optional Source Files.
Compile Button
The Compile button is located at the bottom of the Source Files tab
panel. To be sure that your source files compile,
1. Select one or more source files from the Source Files tab panel.
Note
ModelBuilder automatically runs g77 with the option -fno-second-underscore.
This produces linking symbols that end in one underscore.
To build a library:
1. In the Source Files tab panel, select the source files you wish to
combine.
R2003.12.1 ModelBuilder 76
Landmark Graphics Corporation User Programming
Once you have built a library, it appears in the Libraries window. See
Libraries on page 79 for instructions on selecting a library.
Object Files
If you choose to include specific object files (compiled source files) in
your model, make your selection from the Object Files tab panel.
OR
Libraries
A library is a group of object files.
To select a library:
OR
R2003.12.1 ModelBuilder 78
Landmark Graphics Corporation User Programming
Compiler Switches
To configure the FORTRAN and C compiler switches:
4. Click on Close. The options you selected now appear on the main
window in the Model Contents field.manager.
5. For a list of options that you can enter in the Additional Options
field, refer to the GNU Debugger documentation discussed in the
next section.
To run your model using the GNU debugger, click on the Configure
button in the main ModelBuilder window, then choose the debug
options in the Compilers Switches tab to use the GNU g77 FORTRAN
debugger while your model is running. Then follow the instructions
below.
1. In the main ModelBuilder window, select Tools > Gnu > Gnu
Debugger. The DDD: The Data Display Debugger window
appears.
2. Select File > Open Program, then navigate to your models .exe
file and click on the Open button. The DDD: Run Program dialog
box appears.
R2003.12.1 ModelBuilder 80
Landmark Graphics Corporation User Programming
-fc PTWPRO -pppdf <full path and file name for the
pppdf file>.
6. For help on using the GNU debugger, click on the Help button on
the menu bar at the top of the DDD GNU debugger main window.
http://www/gnu.org/software/gcc/onlinedocs/
Information
To record information about the model you are writing as well as
contact information for any others who might copy or run your model,
This panel contains fields that allow you to enter the title, version,
and description of your model and model author contact
information.
R2003.12.1 ModelBuilder 82
Landmark Graphics Corporation User Programming
Once you have created or edited an .mdl-.mds file pair and have made
any other selections as described above, you are ready to build the
model. You must build a model before you can run it.
When you initiate the Build Model function, the files are compiled and
an executable file is generated. If any errors exist that cause the compile
to abort, you will see an error message in the status field of the
ModelBuilder main window that tells you which file to look in for more
details regarding the error. (See Debugging Your Model on page 80.)
Most status area messages, along with a great deal of other information
pertaining to how model processing progressed, are echoed to the
model_<model name>.log file (for example, model_DualWater.log), which is
stored in your run directory. Echoed messages are prefixed with ==Status:.
To see just these status messages in the log file, use the command:
Note that depth-by-depth messages are not logged unless you preset the
OpenWorks Command Menu System Error Logger Error Level to 0
(trace).
Your model window appears. If you have not yet selected a well,
you are prompted to do so before you can process the model.
R2003.12.1 ModelBuilder 84
Landmark Graphics Corporation User Programming
Boldface lines in this template indicate new keywords and fields for the
current PetroWorks Pro release.
CMNT--------------------------------------------------------------
CMNT template.mds
CMNT MODEL SPECIFICATION FILE - PETROWORKS VERSION 2.00 2003
CMNT
CMNT------------------------------------------------------------------
CMNT <<CMNT>> COMMENT LINES
CMNT
CMNT Comments can appear anywhere in the file.
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<TITL>> MODEL TITLE
CMNT
CMNT This is the title you want to appear at the top of the model screen
CMNT
CMNT Example:
TITL| Complex Lithology Analysis |
CMNT
CMNT------------------------------------------------------------------
CMNT
CMNT <<DEPTH_UOM>> MODEL DEPTH UNIT OF MEASURE
CMNT
CMNT If an algorithm will be using depth in calculations, these must be defined
CMNT as feet or meters, regardless of what is set in the session units.
CMNT
CMNT Example:
DEPTH_UOM=METERS
CMNT
CMNT------------------------------------------------------------------
CMNT
CMNT <<RESPONSE>> MODEL RESPONSE TO AUTOMATICALLY CALCULATED WORKING
CMNT FRAMEWORK
CMNT
CMNT As PetroWorks is now handling the concept of non-resampleability,
CMNT the set of depths over which a model processes (known as Input Working Sample
CMNT Framework, also referred to as IWSF), the model writer can control whether
CMNT the default will allow automatic determination of the IWSF. The default
CMNT is a weak response, which involves resampling non-compatible curves. The
CMNT model can be set to respond with a strong response.
CMNT
CMNT Example:
RESPONSE=STRONG
CMNT
CMNT------------------------------------------------------------------
CMNT
R2003.12.1 ModelBuilder 86
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 88
Landmark Graphics Corporation User Programming
R2003.12.1 ModelBuilder 90
Landmark Graphics Corporation User Programming
CMNT unit, the values will be converted to the units specified in the mds
CMNT file. All parameter units must conform to the OpenWorks database table.
CMNT See the pulldown menu in ModelBuilder. The maximum length of a unit
CMNT is 12 characters.
CMNT
CMNT Field 7 - DESCRIPTION:
CMNT Describes the parameter. More extensive descriptions can be defined
CMNT using CATT below.
CMNT
CMNT Field 8 - GROUP ID FIELD:
CMNT This field may be blank, or it may contain group-id numbers assigning
CMNT the parameter to the group identified by the integer. A field
CMNT may be assigned to any or all the defined groups. The numbers
CMNT must be separated by commas ",". If the field is left blank, the
CMNT parameter will be added to the DEFAULT_GROUP.
CMNT
CMNT For additional options, see keyword CATT below.
CMNT
CMNT Example:
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CMNT| NAME |DEFAULT|T| MIN| MAX |UNIT | DESCRIPTION |GROUP|
CMNT| | | | | | | |IDS |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----|
CNST|BITS |8.75 |I| 0.0| 60.0|inches |Bit size | 1 |
CNST|BHD |10000.0|I| 0.0|99999.0|feet |Bottom Hole Depth | 1 |
CNST|BHT |175.0 |I| 0.0| 600.0|degF |Bottom Hole Temp. | 1 |
CNST|TPclay | 12.0 |I| 0.0| 20.0|ns/m |Prop. Time, Clay | 2 |
CNST|TPsand | 7.2 |I| 0.0| 15.0|ns/m |Prop. Time, Sand | 3 |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<CREF>> DEFINITION OF SHARED CONSTANTS
CMNT
CMNT A "shared" parameter is a parameter defined in a common area that
CMNT can be used by any model. A list of available shared parameters
CMNT can be pulled down from the ModelBuilder, along with all the
CMNT definitions (default, minimum, maximum and units) for the particular
CMNT shared parameter.
CMNT
CMNT If you want to use the shared parameter but override the definition
CMNT (perhaps by limiting the minimum and maximum values, or changing the
CMNT default value for your particular model) the fields are exactly as
CMNT described above for a CNST, except that Field 8 is left blank.
CMNT The definition for the parameter is given the model name.
CMNT
CMNT However, if the shared definition is appropriate only the name of
CMNT the parameter is entered in Field 1 and the name of the definition
CMNT is entered in Field is entered in Field 9.
CMNT
CMNT Example:
CMNT|-------+-------+-+---+---+-----------+---------------------+------+-----------+
CMNT| NAME |DEFAULT|T|MIN|MAX|UNIT | DESCRIPTION |GROUP |DEFINITION |
CMNT| | | | | | | | IDS | |
CMNT|-------+-------+-+---+---+-----------+---------------------+------+-----------+
CREF|NeuSalt|-0.03|I| | | |v/v decimal|Salt Neutron Porosity| | |
CREF|RhoSalt| | | | | | | |COMMON_SALT|
CMNT|-------+-------+-+---+---+-----------+---------------------+------+-----------+
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<CATT>> ADDITIONAL PARAMETER ATTRIBUTES
CMNT
CMNT This keyword allows for additional information for a specific parameter.
CMNT This can be used for both CNST and CREF parameters.
CMNT
CMNT Field 1 - PARAMETER NAME:
CMNT
CMNT The parameter name must exactly match a parameter name defined with CNST.
CMNT
CMNT Field 2 - ATTRIBUTE TYPE:
CMNT
CMNT TITLE: The curve title which can be used for columnar headings
CMNT Linefeeds may be imbedded into the title.
CMNT
CMNT DESCRIPTION:
CMNT If a long description is desired, several of these lines
CMNT may be included.
CMNT
CMNT CHECK ACTION:
CMNT If during runtime, a parameter value is outside the range
CMNT of the definition, you may specify which action is to be taken
CMNT for this particular parameter. (See description of CHKA
CMNT above.) Available actions: ALLOW, CLIP, DEFAULT, NULL.
CMNT
CMNT TYPE: Type of parameter
CMNT
CMNT Field 3: Type
CMNT
CMNT REAL
CMNT
CMNT Field 4: UNITTYPE
CMNT
CMNT Field 5: Actual unit type as defined in modelbuilder
CMNT
CMNT ENUMERATED (1, 2, ...)
CMNT
CMNT Field 4: Default
CMNT
CMNT default (defaults to first)
CMNT
CMNT LOGICAL (yes or no, defaults to no)
CMNT
CMNT Field 4: Default
CMNT
CMNT yes (defaults to no)
CMNT
CMNT
CMNT
CMNT It is best to include these lines right after the CNST entry. An
CMNT example of using a combination of CNST and CATT is described below.
CMNT For readability purposes the fields are spaced out.
CMNT
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CMNT| NAME |DEFAULT|T| MIN| MAX |UNIT | DESCRIPTION |GROUP|
CMNT| | | | | | | |IDS |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----|
CNST|tpClay | 12.0 |I| 0.0| 20.0|ns/m |Prop. Time, Clay | 2 |
CATT|tpClay | TITLE | Propagation Time\n Clay |
CATT|tpClay | CHECK_ACTION | CLIP |
CATT|tpClay | DESCRIPTION | Propagation time of Clay. Needed if and only|
CATT|tpClay | DESCRIPTION | the TPL curve is used. If used, must be |
CATT|tpClay | DESCRIPTION | non-null and must be > 0.0. tpClay is used |
CATT|tpClay | DESCRIPTION | in the SX0 calculation. |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CNST|mType | | | | |unitless |Source of m value | 3 |
CATT|mType | TYPE |ENUM | This is choice one |
CATT|mType | TYPE |ENUM | This is choice two |
CATT|mType | TYPE |ENUM | This is choice three |default |
CATT|mType | TYPE |ENUM | This is choice four |
CATT|mType | TYPE |ENUM | This is choice five |
CATT|mType | TYPE |ENUM | This is choice six |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CNST|OilMud | |I| | | |Oil Mud | 2 |
CATT|OilMud | TYPE |LOGICAL| yes |
CATT|Oilmud | EFFECT| mudtype_function |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CNST|TEMP |70.0 | | | |degF |Base Temperature | |
CATT|TEMP | TYPE |R| UNITTYPE |temperature |
CMNT|-------------+-------+-+----+-------+---------+---------------------+-----+
CMNT
CMNT
R2003.12.1 ModelBuilder 92
Landmark Graphics Corporation User Programming
CMNT------------------------------------------------------------------
CMNT <<NSMP>> MULTIPLE VALUE SAMPLING
CMNT
CMNT Instead of getting one depth sample at a time, you can specify the
CMNT number of samples you wish to process. It is important to note
CMNT that arrays of log values will be delivered to the model and written
CMNT out to the database.
CMNT
CMNT First you can simply MD_NSMP to specify the number of samples
CMNT (for do-loops, etc.).
CMNT
CMNT Example:
NSMP=10
CMNT
CMNT However, you can use your own pre-defined variable name as follows:
CMNT
CMNT Example:
CMNT|---+----------------|
CMNT|NUM| NAME VARIABLE |
CMNT|---+----------------|
NSMP|10 | NUM_SAMPLES |
CMNT|---+----------------|
CMNT
CMNT Since filtering is considered the default process for multiple
CMNT sampling, the depth counter will only advance one step at a time,
CMNT each time bringing back the number of samples specified, starting
CMNT at that particular depth. In the above case, with a step of 0.25
CMNT starting at 7000 feet and processing down, ten samples will be
CMNT given to the model representing values from 7000 feet to 7002.25.
CMNT and values will be output over the same range. The next time,
CMNT 10 values will be given to the model from 7000.25 to 7002.5, etc.
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<NSMI,NSMO>> MULTIPLE VALUE SAMPLING (different input/output)
CMNT
CMNT Instead of getting one depth sample at a time, you can specify the
CMNT number of input/output samples you wish to process. It is important
CMNT to note that arrays of log values will be delivered to the model. If the
CMNT number of output samples is not specified, it will be the same
CMNT as the number of input samples. If they are different, only
CMNT the specified number of samples is output. Any other values
CMNT in the output curve array are lost.
CMNT
CMNT You can use MD_NSMI and MD_NSMO to specify total number of input
CMNT and output samples, or define your own variable names.
CMNT
CMNT Example:
NSMI=10
NSMO=5
CMNT
CMNT|---+-----------------|
CMNT|NUM| NAME VARIABLE |
CMNT|---+-----------------|
NSMI|10 | NUM_SAMPLES_IN |
NSMO| 5 | NUM_SAMPLES_OUT |
CMNT|---+-----------------|
CMNT
CMNT As above, depth processing advances one step at a time.
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<ISMO>> MULTIPLE SAMPLING OUTPUT INDEX
CMNT
CMNT Using the keywords defined above, you may also specify the output
CMNT index in the curve array. You can use MD_ISMO or define your own
CMNT index variable name.
CMNT
CMNT Example:
ISMO=3
CMNT
CMNT|---+-----------------|
CMNT|NUM| NAME VARIABLE |
CMNT|---+-----------------|
NSMI| 5 | NUM_SAMPLES_IN |
NSMO| 1 | NUM_SAMPLES_OUT |
ISMO| 3 | OUTPUT_INDEX |
CMNT|---+-----------------|
CMNT
CMNT In this example, five log values are given to the model for processing
CMNT but you would only output one value in your array(3).
CMNT
CMNT As above depth processing advances one step at a time.
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<NINC>> MULTIPLE SAMPLING INCREMENT
CMNT
CMNT Instead of advancing one step, at a time, you can specify how
CMNT depth processing advances. You can also use MD_INC_DEP_BY or
CMNT define your own variable name to identify this increment.
CMNT The increment cannot be larger than the maximum number of samples
CMNT
CMNT Example:
NINC=10
CMNT
CMNT|---+-----------------|
CMNT|NUM| NAME VARIABLE |
CMNT|---+-----------------|
NSMI|10 | NUM_SAMPLES_INC |
CMNT|---+-----------------|
CMNT
CMNT Using the example in NSMP above, the model would receive 10 samples
CMNT of each curve at 7000 feet, process these and then send output values
CMNT back to the database. The next set of 10 samples would represent
CMNT curve values for 7002.5 through 7004.75.
CMNT
CMNT------------------------------------------------------------------
CMNT <<PASS>> MULTIPLE PASS FLAG
CMNT
CMNT Defines if multiple passes are needed for the model (i.e., the
CMNT depth is to be set back to the beginning of the zone and
CMNT additional sequential runs are to be made. (See explanation
CMNT below for impact on .mdl file code.)
CMNT
PASS=YES
CMNT
CMNT
CMNT------------------------------------------------------------------
CMNT <<$EOF>> -The $EOF keyword must be at the end of each data spec
CMNT file.
CMNT------------------------------------------------------------------
$EOF
R2003.12.1 ModelBuilder 94
Landmark Graphics Corporation User Programming
Example Models
This section provides some useful sample model .mds-.mdl pairs. You
can use these as starting points for your own models. For your
convenience, the models are on the PetroWorks installation CD, under
$PWHOME/dat/src.
R2003.12.1 ModelBuilder 96
Landmark Graphics Corporation User Programming
PREV_INDEX = OUTPUT_INDEX - 1
C Below is the actual gradient calculation. Simply subtract the Cali curve at
C the previous (shallower) depth from the Cali curve at the current output
C depth:
C And we calculate the absolute value of the Gradient, which is really more
C useful as a bad hole indicator.
AbsGradient(OUTPUT_INDEX) = ABS(Gradient(OUTPUT_INDEX))
ELSE
C Of course, if either of the Cali values are NULL, we want the gradient to
C be NULL as well:
Gradient(OUTPUT_INDEX)= ABSENT
AbsGradient(OUTPUT_INDEX)= ABSENT
ENDIF
100 CONTINUE
END
R2003.12.1 ModelBuilder 98
Landmark Graphics Corporation User Programming
multiple depths
null handling
user parameters
Log curve data smoothed with an equally weighted (or box-car) filter
retains more high-frequency noise than a corresponding symmetrical
filter. Judicious selection of filter weights may be necessary for
different depositional environments.
As currently written, the user is not required to make the filter weights
symmetrical. However, the operation of asymmetrical filters depend
upon the processing direction, and the output may be totally erroneous
if processed in the wrong direction. Also, improperly selected filter
weights may actually skew a curve by one or more steps, depending
upon the filter weight.
CMNT
CMNT We read in three depth levels at time using NSMI = 3
NSMI| 3 | NumSamplesIn |
CMNT We will only write out one value for every three we read using NSMO = 1
NSMO| 1 | NumSamplesOut |
CMNT The depth we write out must be in the middle of the three samples we read
CMNT by setting ISMO = OutputIndex = 2.
ISMO| 2 | OutputIndex|
$EOF
C
C Check for NULL values at any of the depth levels
IF ((GR(1).EQ.ABSENT ) .OR.
; (GR(2).EQ.ABSENT ) .OR.
; (GR(3).EQ.ABSENT )) THEN
GR_FILTERED(OutputIndex) = ABSENT
ELSE
C Otherwise filter the curve, multiplying each level by C it's user set
C weight, add them up, and divide by the sum of the weights.
C ================ CAUTION!!! ===============
C If the sum of the weights is zero, division by zero will occur!!
ENDIF
END
C Initialize counter
txt = " "
if (md_mdlint) then
write (txt,'(a,i2)') "model initializing",MD_MDLINT
call model_message(txt)
endif
call model_message(txt)
endif
C last sample
LOGO = GR
END
CHARACTER*80 TXT
IF (MD_DEPTH.EQ.IDEPTH_OFF) THEN
MD_CURVE_IN_SELECTED(1) = 0
write(txt,'(A,f10.2)') "Setting input read off at",md_depth
call model_message(txt)
MD_NEWSEL = .TRUE.
ELSE IF (MD_DEPTH.EQ.IDEPTH_ON) THEN
MD_CURVE_IN_SELECTED(1) = 1
write(txt,'(A,f10.2)') "Setting input read on at",md_depth
call model_message(txt)
MD_NEWSEL = .TRUE.
ELSE IF (MD_DEPTH.EQ.ODEPTH_OFF) THEN
MD_CURVE_OUT_SELECTED(2) = 0
write(txt,'(A,f10.2)') "Setting output read off at",md_depth
call model_message(txt)
MD_NEWSEL = .TRUE.
ELSE IF (MD_DEPTH.EQ.ODEPTH_ON) THEN
MD_CURVE_OUT_SELECTED(2) = 1
write(txt,'(A,f10.2)') "Setting output read on at",md_depth
call model_message(txt)
MD_NEWSEL = .TRUE.
ENDIF
C Make sure that unreal values are set to ABSENT
LOG1 = ABSENT
END
C Initialize counter
IF (MD_MDLINT) THEN
I = 0
ENDIF
SAVE I
C Initialize counter
IF (MD_MDLINT) THEN
I = 1
TXT = " "
TXT = "Current Well "//MD_WELL_NAME
CALL MODEL_MESSAGE(TXT)
ENDIF
CHECK_SM = 0
LOG2X_1 = LOG2X(1)
C---- Set new value and increment counter
C---- This part demonstrates how data in 2nd Dimension can be accessed
DO 10 J = 1,MD_CURVE_2ND_NPOINTS(LDX_LOG2F)
IF (LOG2X(J).NE.ABSENT) THEN
LOG2F(J) = LOG2X(J)
CHECK_SM = CHECK_SM + LOG2X(J)
ENDIF
10 CONTINUE
INTEGER MAXDIM
PARAMETER (MAXDIM = 15)
CHARACTER MSG*50
DATA MSG/"USER_DIM must be assigned a value of 1 to 15"/
C Initialize counter
IF (MD_MDLINT) THEN
IF (USER_DIM.LT.0. OR. USER_DIM.GT.MAXDIM) THEN
CALL MODEL_MESSAGE(MSG)
MD_MDLEND = .TRUE.
GO TO 100
ENDIF
C INITIALIZE ARRAY
DO 5 I=1,MD_CURVE_2ND_NPOINTS(LDX_LOG2F)
5 LOG2F(I) = ABSENT
LOG2F_1 = LOG2X(1)
C---- Set new value and increment counter
DO 10 J = 1,NDIM
IF (LOG2X(J).NE.ABSENT) THEN
LOG2F(J) = LOG2X(J)
CHECK_SM = CHECK_SM + LOG2X(J)
ENDIF
10 CONTINUE
100 CONTINUE
END
A companion model creates 3-D rather than 2-D curves. The model
generates three 500 50 3-D curves (equivalent to 50 2-D curves, each
curve having 500 elements).
The values for FMVLC1 start at the value entered for AGAIN and
increase linearly to the maximum value (500 AGAIN). For the 3-D
model, the maximum value is 25,000 (50 500 AGAIN). The AGAIN
controls how quickly the curve increases.
The 3-D model uses the same parameters as the 2-D model. However,
because 50 2-D curves are created, the resulting data set is much larger,
and maximum values may be significantly greater than for the 2-D
model.
INTEGER i,j
REAL TPI, RADC, RFMVLC2
C ----- Beginning Program MVLC_2D -----
C This will create a set of 2-D Multi-Valued Log Curves
C that can be read by the PetroWorks 1998.5 Data Model.
C
j = 10
TPI = 2.*3.14156
RADC = TPI/360.
DO i=1,500
FMVLC1(i) = AGAIN*float(i)*float(j)
RFMVLC2 = float(i)/TC
FMVLC2(i) = 1./EXP(RFMVLC2)
FMVLC3(i) = SINE_MAX*float(j)*sin(RADC*float(i))
FI(i) = float(i)
CONTINUE
C ----- Ending PROGRAM MVLC_2D -----
END
LATT|MVL3D2|DIMENSION3| NPOINTS | 5 |
LATT|MVL3D3|DIMENSION3| NPOINTS | 5 |
LATT|FI |DIMENSION3| NPOINTS | 5 |
CMNT|------+----------+---------------+-----------+
CMNT
CMNT|---------+-------+-+----+-------+---------+---------------------+-----+
CMNT| NAME |DEFAULT|T| MIN| MAX |UNIT | DESCRIPTION |GROUP|
CMNT| | | | | | | |IDS |
CMNT|---------+-------+-+----+-------+---------+---------------------+-----|
CNST|AGAIN | 1. |I| 1.0| 1000.0| |Gain on Linear Curve | 1 |
CNST|TC | 5. |I| 0.1| 20.0| |Decay Time Constant | 1 |
CNST|SINE_MAX | 2. |I| 1.0| 1000.0| |Gain on Sine Wave | 1 |
CMNT|---------+-------+-+----+-------+---------+---------------------+-----|
$EOF
INTEGER i,j
REAL TPI, RADC, RFMVLC2
C ----- Beginning Program MVLC -----
C This will create a set of 3-D Multi-Valued Log Curves
C that can be read by the PetroWorks 1998.5 Data Model.
C
TPI = 2.*3.14156
RADC = TPI/360.
TC = 2.
DO j=1,5
DO i=1,50
MVL3D1(i,j) = AGAIN*float(i)*float(j)
RFMVLC2 = float(i)/TC
MVL3D2(i,j) = 1./EXP(RFMVLC2)
MVL3D3(i,j) = SINE_MAX*float(j)*sin(RADC*float(i))
FI(i,j) = float(i)
CONTINUE
CONTINUE
C ----- Ending PROGRAM MVLC -----
END
IF (INT(GR).NE.INT(ABSENT)) THEN
GR_OUT = GR+1.0
ELSE
GR_OUT = ABSENT
ENDIF
END
Recommended Reading
Metcalf, M., Effective FORTRAN 77, 256 pp., Oxford University Press,
1985 (out of print).
Overview
Using MathPack
PetroWorks comes with a wide range of algorithms; from simple data
conversion, to standard porosity and fluid saturation calculations, to
complex processes for the simultaneous estimation of lithology,
porosity, and fluid saturation. Those algorithms reside in a variety of
applications under the PetroWorks Command Menu items of Data
Prep, PreInterp, and Interpret. In some cases, however, those pre-
packaged algorithms may not meet your specific needs.
This documentation not only shows you how to use MathPack, but also
details all the features of the interface and the underlying functionality.
MathPack Features
MathPack allows you to write, execute, and save your own
multiple-line processing algorithms, with comments.
Algorithms can be applied to one or more wells in a single
processing instance; over the entire well interval, a common depth
range, or one or more named units (StratUnits).
Curves can be specified by Curve Alias, Curve Name, or Curve
Details. See more about the different methods of accessing curves
in the Petroworks/LogEdit Basics section of the Introduction to
the PetroWorks Family of Products manual.
Algorithmic parameters can be defined locally (specific to the
algorithm), or can be Global Parameters (shared by MathPack,
ModelBuilder, and the provided PetroWorks applications).
Algorithmic processing preserves/honors sample frameworks for
unevenly sampled and non-resampleable data (e.g., core data and
flag curves).
Processing parameters can be written to OpenWorks as curves,
creating a map of the parameter value over the processed
interval.
Equations (as from regression lines) which are determined in
Crossplot can be pasted into Mathpack algorithms.
MathPack Workflow
Open MathPack
Interpret > MathPack
Close MathPack
To Open MathPack
1. From the PetroWorks Command Menu, select
Interpret > MathPack.
To Close MathPack
1. On the MathPack main window, select File > Exit.
2. If you have not saved the algorithm that you created, a warning
window will appear which will allow you to Cancel the Exit
command (so you can save the algorithm, then exit) or continue
with the exit of MathPack (OK) without saving the algorithm.
This section will guide you through the steps of creating a simple
algorithm and running it. For information about how to create more
complex algorithms, see the Building Algorithms section of this
documentation.
Creating an Algorithm
You create an algorithm by typing in the curves, parameters, and
functions to create an equation. Some rules are:
The curve or parameter that you want to create is always on the left
side of the equal sign, which is interpreted as an assignment
statement.
Each equation in the algorithm always ends with a semi-colon (;).
The names of curves that you use are always enclosed in double
quotes ( ).
The names of parameters (Local Variables or Global Parameters)
or numbers are NOT enclosed in double-quotes.
In this example you want to create a sonic porosity (PHIsonic) from the
sonic log measurement (DT). The Raymer-Hunt-Gardner transform to
accomplish this is:
DT DT matrix
PH I sonic = 0.625 ------------------------------------
DT
You know that the formation in which you are interested is a sandstone,
and that the DTmatrix value for this sandstone is 56 us/ft.
In its simplest form, the equation above looks like this in MathPack:
SPHI = 0.625*(DT-56)/DT;
Once you have typed the equation into MathPack, click the Check
Syntax button below the Algorithm window. If you have typed the
algorithm correctly, >> Syntax check passed. will appear in the Status
Area. If you have made a mistake in your algorithm, the Status Area
will display an error message, and MathPack will highlight the part of
the algorithm that has the error.
Once you have passed the syntax check, you are ready to use the
algorithm for processing.
2. After you have selected all the wells that you want, click the
Apply Well Selections button. This causes MathPack to query the
OpenWorks database and (among other things) update the items in
the Unit Selections text field. This MUST be done before you
select the processing interval.
Process the wells over a common Depth Interval that you supply
by clicking the Depth Interval radio button and filling out the Top
Depth and Bottom Depth fields, or
4. You can Set Sample Increment, but leaving the choice defaulted
to Follow Framework Rules will ensure that MathPack honors
non-resampleable curves like core data.
The curves that you created during processing will be written to the
selected wells in the OpenWorks database, and are immediately
available for use and display.
Main Menu
Divider/ Sash
Algorithm Field Button
Status Area
Main Menu
The Main Menu consists of 5 items.
File
New Algorithm clears the Algorithm Field and then enters the
following text in that field, in preparation for creation of a new
algorithm.
--
-- PetroWorks MathPack algorithm
--
-- User : <user id>
-- Created : <date> <time>
--
New Algorithm... will clear the Algorithm Field WITHOUT asking if you want
to save the algorithm that is already there. There is no way to recover the text that
was in place before New Algorithm... is invoked.
Open Algorithm... pastes the entire contents of the selected algorithm into the
Algorithm Field beginning at the current location of the cursor. This command
DOES NOT over-write or erase the current contents of the Algorithm Field, but
adds to the contents.
Save Algorithm... allows you to save the algorithm that you created to
a file with your choice of name and location. The file will automatically
be appended with a suffix of .mathpack. See Save Algorithm
Window for details of the window and its use.
The first time you use this command after you have opened
MathPack, a window opens that allows you to set the name and
location of the file that you want to create.
Subsequent times that you use this command, the previously-
selected file is automatically updated with the contents of the
Algorithm Field. The window does not appear, but a message is
displayed in the Status Area.
To change the destination of subsequent changes in your algorithm, use Save As...
instead of Save Algorithm...
Save As... opens a window that allows you to save the algorithm that
you created to a file with your choice of name and location. The file
Use Save As... instead of Save Algorithm... when you have already saved an
algorithm file during the current session of MathPack, and you want to save your
current work to a different file name or location.
Exit closes the MathPack application. If you have not saved the
information in the Algorithm Field, a window will appear that allows
you to
Cancel the exit and return to MathPack, or
OK the exit, and exit MathPack WITHOUT saving your current
work.
Edit
Cut removes highlighted text from the Algorithm Field.
Paste pastes text that has been Cut or Copied in to a location in the
Algorithm Field starting at the current cursor location.
The three operations above can be accessed by clicking MB3 when the
cursor is in the Algorithm Field.
View
Clear Algorithm clears the entire contents of the Algorithm Field.
Once the field is cleared, you cannot recover the previous contents.
This feature can also be accessed by clicking MB3 when the cursor is
in the Algorithm Field.
Clear Status Area clears the entire contents of the Status Area. Once
the text field is cleared, you cannot recover the previous contents. This
feature can also be accessed by clicking MB3 when the cursor is in the
Status Area.
Options
The History Insertions feature ensures that a curve history is created
each of the output curves. That information will help you to understand
where the curve came from. The curve history is accessed in Curve
Utility.
None is available only if you have Project Manager status for the
project.
Tools
Select Log Curves... opens the Log Curve Selection window. You can
insert curves into your algorithm from this window (by Curve Alias,
Curve Name, or Curve Details) instead of typing directly in the
Algorithm Field. See the Log Curve Selection Window section of
this documentation for more details.
Global Parameters
You can use two types of parameters in MathPack. Local parameters are defined
in your algorithm and are not available to any other algorithmic processes. Global
Parameters are available to all algorithmic processes including the algorithms
that you write in MathPack. The value of the global parameter at the time that the
MathPack algorithm is executed is used by the algorithm. See the Local Variables
and Global (Wellbore) Parameters sections for more details.
Remarks... opens the Remarks window. You can add comments here
that will be included in the curve history of each curve created by your
algorithm. The remarks will come before information about how the
curve was created. See the Remarks Window section of this
documentation for more details.
Well Selection
The wells that appear in the list are from the Well List chosen in
OpenWorks Project Status Tool, or selected when you started
PetroWorks. The list responds to changes in the Well Format (in the
Project Status Tool) but does NOT respond to the Well Order.
Select All/Select None button toggles between the two shown settings
and allows you to select or deselect all the wells in the well list.
The Apply Well Selections button causes MathPack to read well data
from the project database.
Using MB3 over the Top Depth or Bottom Depth text fields will
invoke the menu shown at left. The Minimum and Maximum
depth values are fixed at 0.00 and 30,000.00 respectively.
Unit Selections processes the algorithms over one or more named units
(StratUnits) in each well that is selected. The units do NOT have to be
contiguous. The units are displayed in the format:
<Unit Name>:<geofeature>:<occurence#>
Algorithm Field
You can Output Petrophysical Parameters as Curves. This will
create curves with the parameter values over the interval which you
have processed the algorithm.
The text field is where you actually create the algorithm that you want
to use. Remember that the algorithm can have multiple lines, and can
The Check Syntax button causes MathPack to check the syntax of the
algorithms that you have written. It will identify any problem areas
directly in the algorithm text field, along with an error message in the
Status Area.
Invalid curve references cause processing of the current well to stop, and
processing to continue with the next well in the list.
The Process button causes MathPack to process the algorithms that you
have created over the interval (or intervals) and wells that you have
specified. Process checks the syntax and ensures that all referenced
curves exist before MathPack begins processing for each well. If an
error is found, an informational message informs you of the type of
error and processing is attempted on the next well. Otherwise, the
application continues to process the algorithm currently displayed in
the Algorithm field.
Using MB3 in the Algorithm Field will invoke the menu shown at
left. Clear Algorithm clears the entire algorithm field. There is no
recovery from this action.
Status Area
Results of the syntax check and processing are reported in the Status
Area, as are other messages that are broadcast to all open applications,
such as when wells or projects are changed.
Using MB3 in the Status Area allows you to clear the status area.
Divider/Sash Buttons
These two buttons, on the right side of the MathPack window, between
the Interval and Sample Framework Selection area and the Algorithm
Field, and between the Algorithm Field and the Status Area, allow you
to resize the three panes in the MathPack window. When you move
your cursor over the button, the cursor arrow turns to a plus (+). Hold
down MB1 and drag the cursor up or down to resize the pane. Each
pane has a minimum size.
Pointing Dispatcher
The OpenWorks PD (Pointing Dispatcher) allows you to import single
and multiple wells and curves from Curve Utility into MathPack. You
can PD OUT well names and PD IN well names and curve names.
Curve
Selection
Search/Filter
Curve List
Selection
Display
Action Buttons
Curve Selection
The illustration above shows the Log Curve Selection window in its
three display modes (as indicated by the red arrows): Curve Aliases,
Curve Names, and Curve Details. The Show Curve Details choice is
active when only one well has been selected.
Search/Filter
The text box provides for entry of a text string by which to search or
filter the items in the Curve List.
If you enter a character string, all curves having that character
string anywhere in their identifier will be found.
* can be used to indicate any character, and can be used as part
of a character string.
I*M will find ILM, TIDMR, and CALIMAX.
^ can be used to indicate that the following character string
must occur at the beginning of the entry.
Search/Find Next highlights the next table entry that matches the text
string, and moves the list so that the highlighted entry is at the top of
the list.
Filter causes the list to be reduced to only those entries which match
the text string.
Reset causes the curve list to be returned to its original contents, and
deletes the text string from the text box.
Curve List
The curve list shows the curves in alphabetical order, based on the
selections made in the Curve Selection area. The list cannot be
reordered.
Selection Display
Immediately below the Curve List, the Selection Display shows the
number of curves that:
Are in the original list (Total:)
Are currently displayed in the list, as a result of a filtering
operation (Displayed:)
Are currently selected (Selected:)
Action Buttons
Insert causes the selected curve to be inserted into the algorithm at the
location of the cursor in the Algorithm Field. Insert must be used to
insert the curve into the algorithm; double-clicking on the curve
identifier to insert it in the algorithm is not supported.
Close closes the Log Curve Selection window with no further action.
This window is for the selection of Global Parameters only. You can
add your own local parameters to your algorithms, instead of using
Global Parameters.
Search/Filter
Parameter List
Selection
Display
Action Buttons
Search/Filter
The text box provides for entry of a text string by which to search or
filter the items in the Parameter List.
If you enter a character string, all parameters having that character
string anywhere in their identifier will be found.
Search/Find Next highlights the next table entry that matches the text
string, and moves the list so that the highlighted entry is at the top of
the list.
Filter causes the list to be reduced to only those entries which match
the text string.
Reset causes the list to be returned to its original contents, and deletes
the text string from the text box.
Parameter List
The parameter list shows the Global Parameters in alphabetical order.
The left-hand column is the actual parameter name; the right-hand
column is the title of the parameter as it appears as a column heading in
the Wellbore Parameter Editor. The list cannot be reordered.
Selection Display
Immediately below the Parameter List, the Selection Display shows
the number of parameters that:
Are in the original list (Total:)
Are currently displayed in the list, as a result of a filtering
operation (Displayed:)
Are currently selected (Selected:)
Action Buttons
Insert causes the selected parameter to be inserted into the algorithm at
the location of the cursor in the Algorithm Field. Insert must be used
to insert the parameter into the algorithm; double-clicking on the
parameter to insert it in the algorithm is not supported.
Algorithm
Elements
Palette
Close button
Close button
The Close button closes the Algorithm Elements window with no
further action.
Main Menu
Equation
List
Equation Field
Equation
Name
Field
Action
Buttons
Main Menu
The menu has one option.
File
Save saves all the symbolic equations to a single file which resides in
$PWHOME/dat/mpkEquations.dat.
Equation List
The Equation List shows all the symbolic equations and their names.
The equations are listed in alphabetical order by name. The equations
are defined in Appendix 2: Pre-Defined Symbolic Equations.
Equation Field
The Equation Field shows the selected equation. If you create a new
Symbolic Equation, you type the entire equation here (information
from BOTH sides of the equal sign), or paste the equation here from the
MathPack Main Window Algorithm Area.
Action Buttons
Add/Update adds a new Symbolic Equation to the Equation List, or
updates an existing Symbolic Equation.
1. Enter a name for the equation in the Equation Name Field. Pick a
name that you can easily recognize at a later date.
4. Click File > Save to save the changes to the Symbolic Equations
file.
2. Click the Delete button to delete the equation from the list.
3. Click File > Save to save the changes to the Symbolic Equations
file.
To save multiple line algorithms, go to File > Save Algorithm on the MathPack
Main Window, and store the file in a directory of your choice.
Remarks Window
The Remarks window allows you to add remarks to the history file of
curves. The same remarks are added to the history files of all curves
generated during a single MathPack processing event. The Remarks
Window is accessed from the Main Menu via Tools > Remarks...
Text Window
OK button
Text Window
Type the remarks that you want to be added to the curve history of all
curves generated in a single MathPack processing instance. The text
does NOT wrap in the text field. You can use the Enter (Return)
keyboard button to start a new line.
OK Button
The OK button closes the window and saves the text that you have
written for inclusion in the curve histories of all the curves processed in
the next MathPack processing instance.
1. Go to File > Save Algorithm... or File > Save As... Either menu
item will open the Save Algorithm window shown above.
3. Type the file name that you want to use in the Selection Text Box
and click OK.
Algorithm Preview
4. If you are unsure of the contents of the file, you can click the
Preview button at the bottom of the window. The contents of the
file will be displayed in the Algorithm Preview window.
Building Algorithms
Introduction
Algorithms in MathPack are based on a simple language and grammar.
Algorithms can take on a free-form user-defined arrangement and may
be composed of any number of lines, including comments in separate
lines or in lines containing algorithms. Moreover, no limits are placed
on the number of lines or curves used, or the length of individual lines.
A simple example
This section illustrates the different ways in which a simple algorithm
can be written. The basic algorithm calculates a sonic porosity
(PHIsonic) from acoustic wave travel time (DT) using the Raymer-Hunt-
Gardner transform:
DT DT matrix
PH I sonic = 0.625 ------------------------------------
DT
This version of the equation substitutes the Curve Alias (Acoustic_Wave_Travel_Time) for
the Curve Name (DT), and substitutes the Global Parameter (TransitTimeMatrix) for the lo-
cally-defined variable (DTmatrix). The Curve Alias provides the means to process wells with
variations in the
name of the
sonic measure-
ment, and the
Global Parame-
ter provides the means to access a parameter which is shared by several applications, and
which is defined in the Wellbore Parameter Editor.
Note that the Global Parameter is NOT declared in the algorithm.
This version of the equation is in the same form as the two immediately above, and also includes an IF-
THEN-ELSE statement. In this form, SPHI is calculated by the Raymer-Hunt-Gardner transform when
Acoustic_Wave_Travel_Time (DT) is greater than TransitTimeMatrix (DTmatrix). If the log measurement
is less than or equal to the matrix value, SPHI is set to 0.001 (0.1 percent porosity).
Algorithmic Results
Some reasons that an expression cannot be computed:
Divide by zero;
The function call has an argument which is out of range;
One or more input curves does not exist.
Comments
Comments are preceded by a double-dash ( -- ) and extend to the end of
the line on which they begin. They may appear anywhere on a line or
anywhere in an algorithm. Comments are an optional part of an
algorithm, but are strongly suggested, especially when creating
complex algorithms, or algorithms that you will share with others.
Comments do not affect the meaning of the line on which they appear
and are ignored when the algorithm is processed.
Comment examples:
Variable Declarations
Local Variables must be declared at the beginning of an algorithm,
before they are used in any statement. Variables can be assigned
In the example above, Rw, m, and RHOB_calc are local variables. After
their declaration by the Variable statement, Rw is defined as a
constant while m and RHOB_calc are defined as expressions.
Statements
There are three types of statements:
Assignment Statements
IF Statements
LOOP Statements
Assignment Statements
Assignment statements evaluate an expression by computing a value,
and placing that value in the specified curve or variable at the given
depth for which the algorithm is being applied.
IF Statements
IF statements allow a MathPack user to define conditional processing
on enclosed algorithm statements.
IF statements come in two forms:
IF (expression) THEN
(expression);
END IF;
IF (expression) THEN
(expression);
ELSE
(expression);
END IF;
Examples of IF statements:
LOOP Statements
LOOP statements allow you to iteratively process data. By using a
LOOP statement you can converge on a value by using the previous
value determined by the expression in the same expression, and you can
also set a counter that will terminate a loop after a reasonable number
of iterations. The LOOP statement takes the form of the classic do-
while loop.
(expression);
(expressions to iterate values);
END LOOP;
Variable declarations
Variable initialization
LOOP body
Statement Elements
Curve Identifiers
Curve identifiers are the way that you specify curves as inputs to
algorithms, and as outputs; that is, as the results of algorithm
Because OpenWorks has an open namespace for curves; that is, curves
are not constrained to a limited set of names, you can give a new curve
any name, up to 25 characters in length
Case 1
Case 2
Case 3
Case 4
Case 1 shows the use of Curve Names as input and output curve
identifiers.
Case 3 shows the use of Curve Aliases as input and output curve
identifiers. This format is permissible, but the use of Curve Aliases
as output curve identifiers is discouraged.
Curve Identifiers:
Cannot contain quotes within the enclosing quotes. My new Curve is not a
valid curve name.
Are case sensitive. Sw SW and sw are interpreted as three different curves.
Are limited to 25 characters.
Can be Curve Names or Curve Aliases, or Curve Details. (See the table above for
identifier usage limitations.)
Numeric Literals
Numeric literals are numbers that are used in an algorithm. Numbers do
NOT have to contain a decimal point.
Local Variables
Local Variables are algorithm components that you have defined in the
algorithm. As described in the Variable Declarations section, they are
declared at the beginning of the algorithm by the word VARIABLE.
The value of a Local Variable can be set to a constant, or can be
determined by an expression.
Local Variable names are not limited in length, and the names are case
sensitive. Local Variable names are used in algorithms WITHOUT
quotation marks.
Global Parameters are used with the same format as Local Variables;
they are included in expressions without double quotation marks.
For example:
The algorithm
SPHI = 0.625*(DT-TransitTimeMatrix)/DT;
The algorithm
VARIABLE TransitTimeMatrix;
TransitTimeMatrix = 42.68;
SPHI = 0.625*(DT-TransitTimeMatrix)/DT;
will use the value 42.68, and will disregard the value of
TransitTimeMatrix which resides in OpenWorks.
Reserved Literals are case insensitive; IF, if, If, iF are all
interpreted as the same literal word.
Function Calls
Function calls are references to built-in arithmetic and trigonometric
functions. MathPack provides a varied selection of functions and
maintains their conventional meanings. All but one function (MOD) act
as operations on a simple expression. MOD is a binary operation that
requires two values.
Function calls are case insensitive; LN, Ln, ln, lN are considered
the same function.
Degrees
Radians = ---------------------- 2
360
Exponentiation
Exponentiation is represented by the carat symbol ( ^ ) or by the
Function Call EXP. The expressions are equivalent.
Appendices
Element Definition
Arithmetic Operations
+ addition
- subtraction
* multiplication
/ division
Relational Operations
= is equal to
!= is not equal to
Logical Operators
Function Calls
Element Definition
COS( ) Trigonometric cosine of the specified numeric expression. The
expression is assumed to be in radians.
LN( ) Natural logarithm (base e) of the specified numeric expression. The value
of the expression must be positive.
LOG( ) Logarithm (base 10) of the specified numeric expression. The value of
the expression must be positive.
SQRT( ) Square root of the specified numeric expression. The value of the
expression must be non-negative.
Statement Elements
= equal to
( open parenthesis
) close parenthesis
IF ( ) THEN IF statement
( );
END IF;
Element Definition
Value Literals
1
---
a Rmf n
Sw = ----------------------
-
m
Rxo
Undisturbed zone water
Sw = SW_ARCH (water saturation)
ARCHIE saturation from the Archie
a = TortuosityFactor
(clean formation) equation.
Rw = ResWater (formation water resistivity)
Rt = Deep_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent
1
---
a Rw n
Sxo = ------------------
m
Rt
Flushed zone water saturation
Sxo =SXO_ARCH (flushed zone water saturation
ARCHIE_SXO from the Archie (clean
a = TortuosityFactor
formation) equation.
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rxo = Flushed_Zone_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent
matrix b
DPHI = -----------------------------------
-
Converts bulk density to matrix fluid
DEN_to_POR density porosity, using matrix
DPHI = DPHI (density porosity)
density and fluid density.
b = Bulk_Density (the log measurement)
matrix = DensityMatrix
fluid = DensityFluid
Moveable hydrocarbon
saturation (also called
MOS = Sxo Sw
moveable oil saturation). The
MOVEABLE_SH
fraction of in-place
hydrocarbons that can be
moved or produced.
MOS = MOS
Sxo = Flushed_Zone_Water_Sat
Sw = Water_Saturation
b = ( 1 ) matrix + fluid
Bulk density calculated from
POR_to_DEN density porosity, using matrix b = RHOBC)
density and fluid density. = Density_Porosity
matrix = DensityMatrix
fluid = DensityFluid
Residual hydrocarbon
saturation (also called
residual oil saturation). The ROS = 1 Sxo
RESIDUAL_SH
fraction of in-place
hydrocarbons that cannot be
produced.
ROS = ROS
Sxo = Flushed_Zone_Water_Sat
m
Rxo
Apparent mud filtrate
Rmfa = -----------------------
a
resistivity, from flushed zone Rmfa = RMFA
RMFA
resistivity and porosity Rxo = Flushed_Zone_Resistivity
measurements. a = TortuosityFactor
= Porosity
m = CementationExponent
m
Rt
Apparent formation water Rwa = ------------------
a
resistivity, from true (deep)
RWA
resistivity and porosity
measurements.
Rwa = RWA
Rt = True_Resistivity
a = TortuosityFactor
= Porosity
m = CementationExponent
Rwa = RWA_RATIO
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rt = True_Resistivity
Rxo = Flushed_Zone_Resistivity
Information messages
Error messages
Information Messages
Information messages are generated for different reasons, but are
always preceded by the pattern
>> INFO:
Error Messages
Error messages are generated when the algorithm checker detects an
unresolved error in the specified algorithm. Error messages are always
preceded by the pattern
>> ERROR:
These messages state the nature of the error and attempt to provide the
lexical element (or part) of the algorithm causing the error. This
explanation generally consists of an element enclosed in quotes and the
line number of the offending occurrence in the algorithm. As in the
fragment:
at ")" on line 3
Note that the lines are not numbered as currently displayed in the
algorithm builder, but when possible, the offending element is
Syntax errors
Semantic errors
Syntax Errors
Syntax errors originate when a grammar rule for the correct
specification of an algorithm has been violated. Examples include:
mismatched parentheses
missing or misplaced commas
unterminated statements
missing or misspelled reserved words
improperly quoted curve ids
Semantic Errors
Semantic errors may occur in syntactically correct algorithms, but
violate some meaning of a construct. Examples include:
current dataset
depth and sampling parameters,
the algorithm specification
The parser has found reference to a curve that does not exist for the
given well.
Undefined zone(I)
The specified zone (or depth interval) is undefined for the given
curve in the well currently being processed.
The parser has found reference to a curve that does not exist for the
given well. The list of valid curves for that well should be verified.
The next several messages are related to the above message and will
appear in some combination, depending on the context.
Note that the case for if statements that are ALWAYS TRUE is
not explicitly announced. The condition of the if statement is not
considered during processing and the statements enclosed by the
if are always performed.
Example:
Curve Name Expression
The table beginning on the following page lists the syntax rules that
you must adhere to when you generate a MathPack algorithm.
Meta
Left Side Symbol Right Side
Meta
Left Side Symbol Right Side
primary ::= ID |
CURVE_ID |
REAL_LITERAL |
INTEGER_LITERAL |
BOOLEAN_LITERAL |
NULL_LITERAL |
function_call |
(expression)
Non-terminals
Non-terminals do not end an expression by themselves; they refer to
other grammar rules. Notice that this process may lead to recursive,
self-reference and allows the grammar to represent arbitrarily nested
constructs.
Meta-symbols
Colon, Colon, Equal Sign (::=) is placed between the left and the
right hand side of a rule, and stands for is represented by.
Terminals
Terminals are not defined in terms of further grammar rules and
therefore cannot be reduced further. Each terminal is composed of
unique patterns of characters that help distinguish it from another
terminal. The patterns for each terminal are shown in the following
table. The ellipsis (...) is used to indicate a range of possible values.
Terminals Representation
I alphanum{alphanum | otherchar}
D
C alphanum{otherchar}
U
R
V
E
_I
D
I digit{digit}
N
T
E
G
E
R
_
L
I
T
E
R
A
L
Terminals Representation
R {digit}.digit{digit}
E
A
L
_
L
I
T
E
R
A
L
B true | false
O
O
L
E
A
N
_
L
I
T
E
R
A
L
N null
U
L
L
_
L
I
T
E
R
A
L
Terminals Representation
Literals
Literals stand for themselves, that is, are to be interpreted literally, and
are, in fact, terminals. Some literals are special markers and are
reserved.
User Models
Introduction
To launch a model, select it from the Models window and press the
Launch button.
To publish your model under User Models, you must first locate two
files generated by ModelBuilder: the .exe file and the .pppdf file. (See
the diagram Hierarchy of ModelBuilder-generated Subdirectories and
Files on page 29 in the ModelBuilder chapter.) When you have
located these two files, you can edit the user_models.dat file to include
their location. PetroWorks uses the user_models.dat file to locate your
models executable and data files when you launch User Models from
the PetroWorks Command Menu.
Use a text editor such as nedit to open the user_models.dat file. The
first time this file is opened it appears as shown below.
-----------------------------------------------------------------------
-- User Models
--
-- Copyright (c) 1999, Landmark Graphics Corp.
--
-- Format: this file consists of entries for user models.
-- Models may be grouped for user convenience using group statements
Comments -- Statements must follow this syntax or they will be ignored:
--
-- Group Title||
-- Model Title|<fully declared model path>|<fully declared pppdf path>
--
-- Consult your PetroWorks documentation for further information.
Group Title -----------------------------------------------------------------------
place holder <Empty>||
-----------------------------------------------------------------------
IMPORTANT
You must be logged in as root in order to edit the user_models.dat file.
Otherwise you will not be able to make changes to this file.
Note that the first few lines in the user_models.dat file are comment
lines, which always begin with two hyphens, --. You can add
comments anywhere in the file.
Each model or group occupies a single line. Each line contains three
fields separated by the vertical bar (|) character as a delimiter:
Model Title
This is the title for your model. Please note that the title you choose
does not have to be identical to the actual model executable name. The
name you enter here is the name that is displayed in the Models field of
the User Models window. You can use spaces within the Model Title.
Application Path
This is the absolute path to the models executable, or .exe file. Do not
use relative path names, such as $PWHOME since doing so makes the
path dependent on system variables which can change over time,
causing your model to become invisible. This field MUST start with
a vertical bar (|) delimiter. Do not use any spaces between the bar
delimiters.
PPPDF Path
This is the absolute path to the models Petrophysical Parameter
Definition File. For the same reasons as described above, do not use
relative path names; Use the fully qualified path to the pppdf file. This
field also MUST start with a vertical bar (|) delimiter. Do not use any
spaces after the vertical bar delimiter. Also, be sure the line does not
end with a space.
Group Title
If you would like to visually separate your models into meaningful
groups, you can use Group Titles. Group titles do not correspond to any
other files and can therefore be arbitrary. Group Titles have the
following syntax:
Group Title||
Bedrock Analysis||
Pebbles|/home/dino/models/Pebbles/bin/SUNSV/Pebbles.exe|/home/dino/models/mb_pppdf/Pebbles.pppdf
Spaces and all other characters, except the backslash (\), forward slash
(/) and vertical bar (|), are allowed in the title. \, /, and | can cause erratic
behavior of the display. You cannot have spaces immediately following
a vertical bar.
-- User Models
--
-- Copyright (c) 1999, Landmark Graphics Corp.
--
-- Format: this file consists of entries for user models.
-- Models may be grouped for user convenience using group statements
-- Statements must follow this syntax or they will be ignored:
--
-- Group Title||
-- Model Title|<fully declared model path>|<fully declared pppdf path>
--
-- Consult your PetroWorks documentation for further information.
-----------------------------------------------------------------------
GOLD|/home/sebastian/Arctic/GOLD/bin/SUNSV/GOLD.exe|/home/sebastian/Arctic/mb_pppdf/GOLD.pppdf
Bedrock Analysis||
Pebbles|/home/dino/models/Pebbles/bin/SUNSV/Pebbles.exe|/home/dino/models/mb_pppdf/Pebbles.pppdf
Slate|/home/dino/models/Slate/bin/SUNSV/Slate.exe|/home/dino/models/mb_pppdf/Slate.pppdf
Rubble|/home/dino/models/mrian/bin/SUNSV/mrian.exe|/home/dino/models/mb_pppdf/mrian.pppdf
After you have edited and saved the user_modes.dat file, you can select
User Models from the PetroWorks Command Menu to view and launch
your model.When you select Interpret > User Models, PetroWorks
does the following:
Shown below is the User Models window displayed for the example
above:
Errors
Errors and status messages are sent to the status area at the bottom of
the User Models window. The status area will hold 100 messages.
To clear the status area select View > Clear Status or place the cursor
over the status area and press MB3 and Clear.
Each time you run User Models the program creates an error file in
$HOME/run/um.err. This file catches any error messages output by
User Models.
Index
User Programming
g
R2003.12.1 Index 6
Landmark Graphics Corporation User Programming
M P
MathPack pointing dispatcher
algorithms used in Model Builder 11 MathPack-specific instructions 134
MathPack error messages 176, 176-185 press and drag
information messages 176 defined 5
semantic errors 177 project workspace
syntax errors 177 maintenance of 13
MDL file 11 Model Builder 13
MDS file 11
MDS files S
editing 72
messages sample interval 133
model processing 85 shortcuts
meta-symbols 188 double-clicking to select data 5
grammar rules 188 triple-clicking to highlight 5
types of 188 status messages
Model Builder 7 model processing 85
delimiters 74
features of 8 T
files generated by 11
how it works 10 terminals 189
keywords 74 definition of 189
Main Menu 16
Model Group Directory 11 U
Opening, Launching 14 User Programming 121-185
variables by category 43 checklist 163
Model Workspace 11 error messages 176
models learning about MathPack syntax ??-192
debugging your 80 literals 192
sharing your 13 meta-symbols 188
mouse buttons non-terminals 188
selecting items with 5 pointing dispatcher 134
syntax rules 186-188
N terminals 189
non-terminals 188
O
object files
used in Model Builder 12
online documentation, accessing 1
OpenWorks
pointing dispatcher 134
R2003.12.1 Index 7