Vous êtes sur la page 1sur 204

Landmark Graphics Corporation

User Programming

Contents

User Programming
Introduction
What Is in This Manual? ....................................................................................

About This Manual Set ......................................................................................

PetroWorks/LogEdit Documentation .........................................................

StratUtils Documentation ............................................................................

OpenWorks Documentation ........................................................................

Manual Conventions ....................................................................................

ModelBuilder
Whats in This Chapter? ...................................................................................

Overview .............................................................................................................

Important Features .......................................................................................

How ModelBuilder Works ......................................................................

10

ModelBuilder Directories and Files .......................................................

11

Source Files, Objects, and Libraries .....................................................

12

Sharing Models .......................................................................................

13

Opening ModelBuilder ......................................................................................

14

Main Window Layout .........................................................................................

15

Main Menu Bar ..............................................................................................

16

Main Window Buttons ..................................................................................

17

Main Window Fields .....................................................................................

18

Model Field ..............................................................................................

18

Model Contents Field .............................................................................

18

R2003.12.1

Contents

Landmark Graphics Corporation

User Programming

Status Area ..............................................................................................

18

Getting Started ...................................................................................................

19

Creating Your Model Workspace ................................................................

19

Creating a New Model ..................................................................................

20

Copying an Existing Model .........................................................................

23

Deleting a Model ...........................................................................................

26

Finding Your ModelBuilder Files .....................................................................

28

Automatic Files ............................................................................................

28

More About Files ..........................................................................................

30

mb_html ...................................................................................................

30

mb_include ..............................................................................................

30

mb_lib ......................................................................................................

30

mb_obj .....................................................................................................

30

mb_pppdf ................................................................................................

30

mb_src .....................................................................................................

31

Understanding the .mdl-.mds File Pair ............................................................

32

Designing Your Model .......................................................................................

36

Editing the .mdl File ..........................................................................................

38

How ModelBuilder Uses the .mdl File ........................................................

38

Creating and Editing the .mdl File ..............................................................

38

General Rules ...............................................................................................

39

The .mdl Reserved Variable Names and Features ....................................

42

Processing Flags .........................................................................................

52

Flags for Checking .................................................................................

52

Flags to Be Set by Model .......................................................................

53

Defining Processing Criteria .......................................................................

55

Criteria for Automatic Determination of Model Processing ...............

55

R2003.12.1

Landmark

New Features For PetroWorks

Model Controls of Processing Criteria .................................................

55

Input Working Sample Framework .............................................................

60

User-Specified Reference Curve ...........................................................

61

Model Fixed Reference Curve ...............................................................

62

Model Variables in .mdl Code ................................................................

63

Runtime Curve Reselection ........................................................................

63

Curve Attributes ......................................................................................

63

Multi-valued (Multi-dimensional) Curve Data ............................................

65

Parameter Data .............................................................................................

70

Parameter Key Rules ..............................................................................

70

.mdl File ...................................................................................................

71

Processing Interval .................................................................................

71

Output Curves .........................................................................................

71

Editing the .mds File .........................................................................................

72

General Rules ..........................................................................................

73

.mds File Keywords and Delimiters ......................................................

74

Configuring Your Model ....................................................................................

75

Source Files ..................................................................................................

76

Compile Button .......................................................................................

77

Build Library Button ...............................................................................

77

Object Files ...................................................................................................

78

Libraries ........................................................................................................

79

Compiler Switches .......................................................................................

80

Debugging Your Model ..........................................................................

80

Information ...................................................................................................

83

Building and Running a Model .........................................................................

84

Model Data Specification Template with Keywords .......................................

87

R2003.12.1

Landmark Graphics Corporation

User Programming

Example Models ................................................................................................

98

Vertical Curve Gradient ...............................................................................

99

Gradient .mds File ..................................................................................

99

Gradient .mdl File ................................................................................... 100


Three-Point Filter with User Weights ......................................................... 102
Filter3Pt .mds File ................................................................................... 102
Filter3Pt .mdl File .................................................................................... 103
Check Processing Flags .............................................................................. 104
Check Any Depth Flag .mds File ........................................................... 104
Check Any Depth Flag .mdl File ............................................................ 104
Reconfiguring Curve Selection During Runtime ....................................... 106
Checking Curve Reconfiguration Flags .mds File ............................... 106
Checking Curve Reconfiguration Flags .mdl File ................................ 106
Create 2D Output Curve .............................................................................. 108
Create 2D Log .mds File ......................................................................... 108
Create 2D Log .mdl File .......................................................................... 108
Check 2D Log Curve .................................................................................... 109
Check 2D Log .mds File ......................................................................... 109
Check 2D Log .mdl File .......................................................................... 110
Dynamically Redefine Dimensions for Output Curves ............................. 111
Dynamic 2D Log .mds File ..................................................................... 111
Dynamic 2D Log .mdl File ...................................................................... 112
Multi-Valued Log Curves ............................................................................. 114
MVLC_2D .mds File ................................................................................ 115
MVLC_2D .mdl File ................................................................................. 116
MVLC_3D .mds File ................................................................................ 116
MVLC_3D .mdl File ................................................................................. 117
R2003.12.1

Landmark

New Features For PetroWorks

Explicit Input Framework Based on User-Specified Reference Curve ... 118


Check Input Framework - Reference Curve .mds File ......................... 118
Check Input Framework - Reference Curve .mdl File .......................... 118
Explicit Input Framework Based on User-Specified Increment ............... 119
Check Input Framework - Explicit Increment .mdsFile ....................... 119
Check Input Framework - Explicit Increment .mdl File ....................... 119
Recommended Reading .................................................................................... 120

Building Algorithms with MathPack


Overview ............................................................................................................. 121
Using MathPack ........................................................................................... 121
About this Version of MathPack ................................................................. 121
MathPack Features ...................................................................................... 122
MathPack Workflow ..................................................................................... 123
Opening and Closing MathPack ................................................................. 124
To Open MathPack ................................................................................. 124
To Close MathPack ................................................................................. 124
How Do I Use MathPack? .................................................................................. 125
Creating an Algorithm ............................................................................ 125
Running the Algorithm ........................................................................... 126
MathPack Window Descriptions ...................................................................... 127
MathPack Main Window .............................................................................. 127
MathPack Main Window Components .................................................. 127
Pointing Dispatcher ................................................................................ 134
Log Curve Selection Window ...................................................................... 135
Log Curve Selection Window Components ......................................... 135
Parameter Selection Window ...................................................................... 138

R2003.12.1

10

Landmark Graphics Corporation

User Programming

Parameter Selection Window Components ......................................... 138


Algorithm Elements Window ...................................................................... 141
Algorithm Elements Window Components .......................................... 141
Symbolic Equations Window ...................................................................... 143
Symbolic Equations Window components .......................................... 143
Adding an Equation to the Symbolic Equations List .......................... 144
Modifying an Existing Symbolic Equation ........................................... 145
Remarks Window ......................................................................................... 146
Remarks Window Components ............................................................. 146
Save Algorithm Window .............................................................................. 147
Saving a New Algorithm ......................................................................... 147
Saving a Previously-Saved Algorithm .................................................. 147
Open Algorithm window .............................................................................. 149
Opening an Existing Algorithm ............................................................. 149
Building Algorithms .......................................................................................... 151
Introduction .................................................................................................. 151
A simple example ......................................................................................... 151
Algorithmic Results ..................................................................................... 153
Algorithm Component Details .................................................................... 153
Comments ............................................................................................... 153
Variable Declarations ............................................................................. 153
Statements .............................................................................................. 155
Statement Elements ............................................................................... 157
Top Twelve Check List ................................................................................ 163
Appendices ........................................................................................................ 164
Appendix 1: Algorithm elements with definitions ..................................... 164
Appendix 2: Pre-Defined Symbolic Equations .......................................... 167
R2003.12.1

11

Landmark

New Features For PetroWorks

Appendix 3: Global (Wellbore) Parameters and Definitions .................... 170


Appendix 4: Understanding Error Messages ............................................ 176
Information Messages ............................................................................ 176
Error Messages ....................................................................................... 176
Syntax Errors .......................................................................................... 177
Semantic Errors ...................................................................................... 177
Explanation of Information and Error Messages ................................. 178
Appendix 5: MathPack Syntax .................................................................... 186
Non-terminals ......................................................................................... 188
Meta-symbols .......................................................................................... 188
Terminals ................................................................................................. 189
Literals ..................................................................................................... 192

User Models
Introduction ........................................................................................................ 193
Publishing Your Model ...................................................................................... 194
Model Title .................................................................................................... 195
Application Path ........................................................................................... 195
PPPDF Path .................................................................................................. 195
Group Title .................................................................................................... 195
Errors ............................................................................................................ 197

Index ....................................................................................................................

R2003.12.1

198

12

Landmark Graphics Corporation

User Programming

Introduction

What Is in This Manual?


This manual describes the following advanced programming tools
(available in LogEditLE; PetroWorks AssetPA;
PetroWorks ProPP):

LE

PP

ModelBuilder (page 6) is PetroWorks' rapid application


development environment, or advanced user programming
application. It contains instructions for developing models, or
interpretive applications, in ModelBuilder; that is, the emphasis is
on model writing rather than on using the created models.

PA

PP

MathPack (page 121) processes user-defined algorithms over


specified depth intervals to compute new log data. These
algorithms may be stored as text files and reused. You may use
MathPack to modify existing curve data or to generate synthetic
curves.

PA

PP

User Models (page 6) is a tool that allows everyone running


PetroWorks out of the PetroWorks home directory to see and run
published user-written models.

To access this manual online, select Help > Online Manual from the
PetroWorks Pro, PetroWorks Asset, or LogEdit Command Menu.

R2003.12.1

Introduction: What Is in This Manual?

Landmark Graphics Corporation

User Programming

About This Manual Set


PetroWorks/LogEdit Documentation
The PetroWorks/LogEdit documentation manual set consists of the
following.

PetroWorks/LogEdit Documentation Manual Set


Book
Introduction to PetroWorks
Family of Products

Chapters

Application

PetroWorks Basics
Glossary

Overview of PetroWorks Pro,


PetroWorks Asset, and LogEdit
applications and command menus
Cross-application concepts and
activities

PetroWorks/LogEdit Project
Management

Introduction
Curve Alias List Manager
PetroWorks Preferences

Curve Alias List Manager


Preferences

PetroWorks/Log Edit Data


Import, Export, and
Conversion

Introduction
Exporting Log Data
Converting Wellbore Data

Log Export
Wellbore Data Converter

PetroWorks Data
Preparation

Introduction
Environmental Corrections
Creating a Temperature Curve
Smoothing Curves

Environmental Corrections
Temperature Curve Creation
Curve Smoothing

PetroWorks/LogEdit Well
Data Management and
Editing

Introduction
Editing Curve Data in LogEdit
Editing Wellbore Parameters
Editing StratUnits, Surfaces, and Picks
Managing Curves with Curve Utility

LogEdit
Wellbore Parameter Editor
StratUnit Editor
Curve Utility

PetroWorks Basic
Interpretive Applications

Introduction
Preliminary Reconnaissance
Log Functions
QuickInterp

Preliminary Reconnaissance
Log Functions
QuickInterp

R2003.12.1

Introduction to PetroWorks Family of


Products

Introduction: About This Manual Set

Landmark

New Features For PetroWorks

PetroWorks/LogEdit Documentation Manual Set (Continued)


Book

Chapters

Application

PetroWorks Progressive
Interpretive Applications

Introduction
Shale Volume
Complex Lithology
OnePhiSw
Shaly Sand
Dual Water
MultiMineral
Pulsed Neutron
PreMRIAN
SwbMRIAN
MRIAN
Appendix A: Water Saturation Equations
Used in Shaly Formations

PetroWorks/LogEdit User
Programming

Introduction
ModelBuilder
Building Algorithms with Mathpack
User Models

ModelBuilder
MathPack
User Models

PetroWorks/LogEdit
Visualization

Introduction
Generating Crossplots
Tabular List
Viewing Reports with Report Viewer

CrossPlot
Tabular List
Report Viewer

PetroWorks Volumetrics

Introduction
Summation
Determining Sensitivity

Summation
Sensitivity

PetroWorks Parameters

R2003.12.1

Shale Volume
Complex Lithology
OnePhiSw
Shaly Sand
Dual Water
MultiMineral
Pulsed Neutron
PreMRIAN
SwbMRIAN
MRIAN

available online only; describes the


parameters required for all interpretive
applications.

Introduction

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:

StratWorks Documentation Manual Set


Book

Section

Introduction to StratWorks

Application

Using the Color Control Tools

Using the Marginalia Editor


Defining Headers and Trailers
Generating Lithology Log Curves

Color Control Seismic & Log


Variable Fills
Color Control Contour &
GeoCellular
Marginalia Editor
Header/Trailer Editor
Lithology Curve Generator

Setting Up StratWorks

Creating and Transferring Well Templates


Previewing Your Well Data
Creating Stratigraphic Columns

Well Template Editor


Single Well Viewer
Strat Column Editor

Mapping and Cross Sections

Creating Basemaps; Making Structure and


Isochore Maps

MapView

Wellbore Manager User


Guide

All

Wellbore Manager

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

R2003.12.1

Using OpenWorks. Refer to this manual for an explanation of the


OpenWorks environment .

OpenWorks Data Management. Refer to this manual for


instructions on creating and managing projects. You must create a
project with a Cartographic Reference System (described in the
Project Management and Map Projection Editor chapters)
before you can load data. This manual also provides instructions
for using some of the OpenWorks utilities like the Well Data
Manager and Well List Manager.

OpenWorks Data Import/Export. Refer to this manual for


instructions on how to load and transfer data between applications
running under the OpenWorks environment.
Introduction: About This Manual Set

Landmark

New Features For PetroWorks

Manual Conventions
This manual uses certain conventions to explain how to use various
features of the program:

R2003.12.1

Menu options

Menu options and button names are printed in


boldface, for example, Setup.

key

Press the indicated key on the keyboard, for


example, Return.

type startow

Text that you are required to type in is printed


in a different typeface (Courier).
Type exactly what you see.

type
projectname

A different typeface in italics (Courier


Italics) indicates that you are to supply
information. At projectname, for example,
you should enter the name of your project.

Click on

Move the cursor to the option or object


specified and quickly press and release the
mouse button. Unless otherwise specified,
use Button 1.

Press and drag

Press the mouse button and continue to hold it


down while moving the cursor to the option
you want or to a new location in the graphic
display area; then release the button.

Highlight

In a dialog box, move the cursor to the name of


the item you wish to use and select it with the
mouse.

Select

Move the cursor to the option or object you


want to select and click on it.

Double-click

Click the mouse button twice rapidly without


moving the mouse. The first click highlights
the option, object, or text beneath the cursor;
the second click is equivalent to pressing the
OK button to accept the selection.

Triple-click

Click the mouse button three times rapidly


without moving the mouse to highlight a string
of text (more than one word) beneath the
cursor.

Introduction

10

Landmark Graphics Corporation

User Programming

ModelBuilder

Whats in This Chapter?


This chapter describes ModelBuilder, PetroWorks advanced user
programming application, which you can think of as a rapid application
development environment. The chapter contains instructions for
developing models (better thought of as interpretive applications) in
ModelBuilder. The emphasis is on model writing rather than on using
created models. Using any interpretive application involves only
selecting the appropriate application from the PetroWorks launcher bar
and proceeding as with most other PetroWorks applicationsmany of
which have actually been created with 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.
This chapter consists of the following sections:

R2003.12.1

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)

ModelBuilder: Whats in This Chapter?

Landmark Graphics Corporation

User Programming

Overview
ModelBuilder allows you to design your own algorithmic petrophysical
model, a mathematical description of how you want to manipulate the
physical measurements taken from well curves. Then, from your own
specifications, ModelBuilder builds an executable PetroWorks
application, that you and others can run to analyze and interpret well
log data.
ModelBuilders must know FORTRAN or C.
A working knowledge of FORTRAN 77 or C is essential for designing models with
ModelBuilder. You should also be comfortable working within the UNIX operating
system environment for the purposes of locating files and using the GNU debugger
provided with ModelBuilder.

Like MathPack, ModelBuilder provides the capability for users to


create customized interpretation and processing. However, MathPack is
a user programming application; whereas ModelBuilder is a rapid
application development environment. The differences are detailed in
the following table.
MathPack Features

ModelBuilder Features

uses its own interpreted language

uses standard FORTRAN or C

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

Conceptually, applications implemented in ModelBuilder comprise two


basic parts:

R2003.12.1

model data specification (.mds file)


This is the declarative portion, in which input and output curves
and input petrophysical parameters are defined. This portion
contains sufficient information for ModelBuilder to create a
graphical interface for the application to communicate to end users
and to the OpenWorks database.

model algorithm code (.mdl file)


This is the procedural portion, where algorithms and/or procedures
act upon the data (curves and parameters) defined in the
declarative portion (.mds file) of the application.
ModelBuilder: Overview

Landmark

New Features For PetroWorks

Important Features
ModelBuilder creates interpretive applications that can

interact with multiple wells over multiple intervals

interface with the Wellbore Parameter Editor

define a specific depth framework for input curves.

simultaneously read and process multiple depth samples, as for


filtering

run multiple processing passes over particular depth ranges or


stratigraphic units

dynamically redefine input depths, and turn curves off or on

process data either up or down the borehole

handle multi-dimensional data

end processing if processing conditions so warrant

import data from unconventional files

export data to external files and create reports during processing

access libraries, objects, and subroutines during processing

Both interpretive (composite/processed) and acquisition models can be


created.
Special Procedure for User Created Acquisition Models
Acquisition models created by users in ModelBuilder will not process multiple
passes correctly unless a specific procedure is followed. For more information on
this procedure, contact Customer Support. The need for this procedure is
temporary and will be resolved in the next release of PetroWorks. At that time,
acquisition models created using this special procedure will need to be modified.

R2003.12.1

ModelBuilder

Landmark Graphics Corporation

User Programming

In addition, the interpretive applications created by ModelBuilder can


be published; that is, made available under the Interpret > User
Models location on the launcher bar so that you and other users can
have easy access to the applications.

Select to launch a
published model

Published user models


appear here

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.

R2003.12.1

ModelBuilder: Overview

Landmark

New Features For PetroWorks

How ModelBuilder Works


Before you begin using ModelBuilder, it is important to understand the
files that are needed and the structure of the project workspace that
ModelBuilder creates.
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 model data specification (.mds) file is the data specification


file that specifies how Wellbore Parameter Editor displays
information for this application and how it interacts with the user.

The general workflow for building and running models is shown below.

Start

Open ModelBuilder

Create or modify .mdl and .mds files

Build model

optional

Via model interface, edit parameters


in Wellbore Parameter Editor

Process model

End

ModelBuilder has been constructed to minimize the interaction that the


writer needs to have with underlying PetroWorks and OpenWorks
systems, to the point of automatically creating the necessary
development file structures when first starting. A text editor and various
GNU compilers and debuggers are also supplied so that a complete
development system is available. Your preferred editor, compiler, and
debuggers can be used if desired.

R2003.12.1

ModelBuilder

10

Landmark Graphics Corporation

User Programming

ModelBuilder Directories and Files


Your project workspace is defined by the Model Group Directories and
subdirectories in which you create, build, and run models. Each model
you create has its own structured subdirectory under the Model Group
Directory where your model source files are located. To create a new
model, you must first create or select a Model Group Directory. This
directory is an area in which you can create and store related models.
You can create as many model group directories as you need to contain
your related models.
When you create a Model Group Directory, ModelBuilder creates a
subdirectory in which to store your model source files. After you create
your model group directory and supply a name for your model,
ModelBuilder generates two essential files in the model subdirectory
the model algorithm code (.mdl) file and the model data specification
(.mds) file. (Refer to the diagrams in Finding Your ModelBuilder
Files on page 28 later in this chapter.) ModelBuilder must have a
minimum of one .mdl-.mds file pair before it can build a model.
Your model belongs to you.
The default permissions for accessing files in your model directories do not allow
others to make changes or to delete created objects or executables.

Model Algorithm Code File


The .mdl file is the file in which you write your algorithms in standard
FORTRAN (because of the use of the GNU products, it must be
FORTRAN 77). This is also referred to as the algorithm code file. Refer
to the section Editing the .mdl File on page 38 for details.
Must I code in FORTRAN?
Although you must use FORTRAN in the .mdl file, you can call C files of
FORTRAN files from the .mdl file. Thus, you can write your entire program in C
if you choose.
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.
R2003.12.1

ModelBuilder: Overview

11

Landmark

New Features For PetroWorks

Model Data Specification (.mds) File


The .mds file is the file in which you specify all parameters and curves
the .mdl file requires. In this file, you define log curves and their
attributes, parameters and their attributes, parameter groupings, and
several other model features using specific keywords. This file provides
information for the model interface within Wellbore Parameter Editor
(WPE). The ease of use of your application will depend to a great deal
on the effort you put into this file, as it will impact curve and parameter
names, titles, and the interaction of WPE with the Units of Measure
system. Refer to the section Editing the .mds File on page 72 for
details.
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.

Source Files, Objects, and Libraries


Although not required for an application, ModelBuilder increases your
development flexibility by allowing the inclusion of:

separate source files in FORTRAN or C (source files have an .F or


.c extension)

compiled source code modules, or objects (object files have an .o


extension)

a group of objects called a library (libraries have an .a extension)

FORTRAN include files (include files have an .inc extension)

C header files (header files have an .h extension)


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.

See Configuring Your Model on page 75 for more details on optional


additions to ModelBuilder models.

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.
A project workspace is meant to be used as a private area where a
model writer can safely develop models. To minimize confusion and
inadvertent overwriting of model files, do not share your project
workspace with other model writers. No two writers can predictably
build the same model within a project workspace any more than two
people can share the same spreadsheet file on a PC.
It is strongly recommended that model writers agree to a policy for how
work is to be done within a central or master workspace where
accepted versions of common models may be built and copied.

R2003.12.1

ModelBuilder: Overview

13

Landmark

New Features For PetroWorks

Opening ModelBuilder
To open ModelBuilder from the PetroWorks launcher bar, select
Interpret > ModelBuilder:

The ModelBuilder main window appears:

R2003.12.1

ModelBuilder

14

Landmark Graphics Corporation

User Programming

Main Window Layout


The main ModelBuilder window consists of the three major areas:

main menu bar


main window fields
main window buttons

These areas are described in detail on the following pages.

Main menu bar

Main
menu
fields

Main window buttons

R2003.12.1

ModelBuilder: Main Window Layout

15

Landmark

New Features For PetroWorks

Main Menu Bar


ModelBuilders main menu bar lies across the top of the screen. The
menu bar options are:
File, which lets you

create and name a new model


open a pre-existing model
delete a model
create a model group directory, a workspace in which to develop
your model
update/save configuration list of source files your model needs
open the specification file, (.mds extension)
open the algorithm file, (.mdl extension)
exit ModelBuilder

View, which lets you

clear the status area of messages that ModelBuilder generates

Options, which lets you

toggle the Create FORTRAN and Includes option on or off.


Turning this option on causes the previously generated model
FORTRAN source code (.F files) and include (.inc) file to be
recompiled and linked.

Tools, which lets you

R2003.12.1

enter the file editor, NEDIT, supplied with ModelBuilder


view the build messages screen
view units of measurement
view details of global parameters
run the GNU debugger and view the Man Pages, relevant pages
from the GNU users manual

ModelBuilder

16

Landmark Graphics Corporation

User Programming

Commands, which lets you

open the Configure window


build your model
unbuild your model (delete all but user-created files in the model
group directory)
run the current model

Main Window Buttons


The five buttons on the main window are described below. To choose a
button function, place the cursor on the button and click on MB1.
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.

R2003.12.1

ModelBuilder: Main Window Layout

17

Landmark

New Features For PetroWorks

Main Window Fields


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

Model Contents Field


This field shows you the path and filename of the current models .mdl
and .mds files, the path and filenames of any source files, object files,
and libraries, and the current compiler switch settings.

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.)
To begin working in ModelBuilder, select Interpret > ModelBuilder
from the PetroWorks Command Menu/

Creating Your Model Workspace


The first time you build a model, or the first time you create a model in
an area different from your current build location, you must create or
choose a model group directory for your files. This allows
ModelBuilder to find the files it needs when it tries to build and run
your model. To create a model group directory, follow these steps:

R2003.12.1

1.

From the menu bar, select File > Create Model Group Directory.
The following screen appears:

2.

Type a name and click on the OK button to accept the directory


name. In the sample above, we created the new model group
directory Arctic.

3.

Look in the status area at the bottom of the ModelBuilder screen.


A status message appears indicating that your model root directory
has been created:

ModelBuilder: Getting Started

19

Landmark

New Features For PetroWorks

Creating a New Model


1.

Click on the New button on the main window. The New Model
window 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:
1. Click on the Select button.
2. Select the proper directory.
3. Click on the Filter button.
4. Click on the OK button.
The correct model group directory name now appears in the
New Model window.
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.

6.

Choose one of the two options offered by toggling on the button


next to the option. When the button is green, the selection is turned
on. Options are
Use Specification/Algorithm Template Files to use template
files for the .mdl and .mds files. These files are very basic
models. (See Editing the .mdl File on page 38 and Editing
the .mds File on page 72.)

R2003.12.1

ModelBuilder

20

Landmark Graphics Corporation

User Programming

Use/Copy existing Specification/Algorithm Files

7.

If you choose to use the template files, click on OK and skip the
next section (Copying an Existing Model on page 23).

8.

If you choose to copy existing files, read 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
Select File Create Model Group Directory
and name the new directory.

Select File New Model and name


the new model.

Edit .mdl and .mds files


using Tools File Editor.

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.

Build

Errors?
Errors?

Yes

Debug

No
Run

R2003.12.1

ModelBuilder: Getting Started

21

Landmark

New Features For PetroWorks

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

Click on the New button.

Optional
Is this
the Model Group
Directory you want to
work in?

Find the directory you want

No
Select a different group directory.

Filter
OK

Yes

Name your model.

Edit .mdl/.mds files


using Tools File Editor.

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?

Debug

No
Run

R2003.12.1

ModelBuilder

22

Landmark Graphics Corporation

User Programming

Copying an Existing Model


If you chose to copy an existing Specification/Algorithm file, the
following screen appears:

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.

Copy command does not copy optional, associated source and


object files.
The copy feature does not copy optional source and object files associated with
existing .mdl and .mds files. To copy additional files, you must use a standard
UNIX command, such as cp, from an xterm window.

R2003.12.1

ModelBuilder: Getting Started

23

Landmark

New Features For PetroWorks

The diagram below describes a workflow for copying an existing model


into your own workspace and giving it new name.
Workflow to Copy an
Existing Model and
Give It a new Name

Click on the New button.

Optional

Select Use/Copy existing


Specification/Algorithm
Files.

Name your model.

Find the .mdl or .mds file you want to


copy in the [ModelName]_src subdirectory for that model.
Filter
OK

Edit .mdl/.mds files


using Tools File Editor.

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.

Build

Errors?

Yes

Debug

No
Run

R2003.12.1

ModelBuilder

24

Landmark Graphics Corporation

User Programming

Model Group Directory = Arctic


Model Name = GOLD

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.

R2003.12.1

ModelBuilder: Getting Started

25

Landmark

New Features For PetroWorks

Deleting a Model
1.

Select File > Delect Model.


The Delete Model dialog box appears, showing a list of available
models in the currently selected Model Group Directory:

2.

Choose one of the following:


If this is the correct Model Group Directory, go to step 5.
If you wish to select a new Model Group Directory, go to step 3.

3.

R2003.12.1

Choose a Model Group Directory by clicking the Select button.

ModelBuilder

26

Landmark Graphics Corporation

User Programming

The Select Model Group Directory dialog box appears:

4.

Select the Model Group Directory containing the model you wish
to delete. Press OK.
A list of available models appears in the Model List area.

R2003.12.1

5.

Click on the model you wish to delete.

6.

Press OK to delete the model.

ModelBuilder: Getting Started

27

Landmark

New Features For PetroWorks

Finding Your ModelBuilder Files


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.
The information in this section describes the files that ModelBuilder
creates and specifies the file locations with respect to your home
directory. The home directory in our example here is called
home/workerbee/cmolaro/.
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
Directory Source
Group
Directory
Files
Directory

.mdl file

The diagram above shows the path to the .mdl file for the model GOLD
in the model group directory Arctic.
Protect Built Models
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

The diagram below illustrates the hierarchy of ModelBuilder-generated


subdirectories and files:

Your Home Directory

Hierarchy of ModelBuilder-generated
Subdirectories and Files

Model Group Directory*

mb_html
SUNSV
mb_include

mb_lib
See More About Files
on page 30 for a
description of these files.

bin***

.exe

SGI

mb_obj

.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.

R2003.12.1

ModelBuilder: Finding Your ModelBuilder Files

29

Landmark

New Features For PetroWorks

More About Files


The following six subdirectories, located directly under Model Group
Directory, and shown in the diagram Hierarchy of ModelBuildergenerated Subdirectories and Files on page 29, are generated by
ModelBuilder when you create a model. The files these subdirectories
contain are available to all models in the Model Group Directory.
Below is a description of each subdirectory.

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

Understanding the .mdl-.mds File Pair


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.
The purpose of the GammaRays program is to read in a gamma ray log
curve named GR, add 1 to the value at each depth increment, then write
out a new log curve called GROUT.
.mdl file
algorithm code file

comment
algorithm

.mds file
data specification file
comment

input log curve


output log curve
end of file

The first window above, GammaRays.mdl, shows the .mdl file


containing the FORTRAN code for the model. The second window,
GammaRays.mds, shows the input and output log curves specified
using the keyword LOGS. Other keywords used above are CMNT and
$EOF, which indicate a comment and the end of the file, respectively.
R2003.12.1

ModelBuilder: Understanding the .mdl-.mds File Pair

31

Landmark

New Features For PetroWorks

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.
The model PHID2RHOB converts density porosity to bulk density
when given the input parameters of matrix density and fluid density.
The FORTRAN file, PHID2RHOB.mdl, and its corresponding .mds
file, PHID2RHOB.mds, are shown below followed by the user
interface and corresponding Wellbore Parameter windows.

R2003.12.1

ModelBuilder

32

Landmark Graphics Corporation

User Programming

When you click on the Edit


Parameters button on the
PHID2RHOB application
window, the Wellbore
Parameter Editor main
window appears. In the
example below, the density
parameters, as specified in
the .mdl and .mds files, are
Rho_fl and Rho_ma, the
input curve is PhiD, and
the output curve is RHOB.
After you have edited
parameters, you can click
on the Process button from
the PHID2RHOB
application window to run
the application.

R2003.12.1

ModelBuilder: Understanding the .mdl-.mds File Pair

33

Landmark

New Features For PetroWorks

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)

Create or open models


Create or modify .mds and .mdl
files
Debug model (at build time)
.mds file

.mdl file

Edit
Parameters?

Select wells
Select depth units
Select processing depth intervals
or zones
Set processing direction
Process model

Process

Write code for ModelBuilder


Define default input/output curves
and parameters
Define UOM
Define min and max (with error
handling)
Design the WPE model interface
(parameter grouping and handing)

Build

Wellbore Parameter Editor

Select parameters
Select input and output curves
Save parameters

Run

R2003.12.1

ModelBuilder

34

Landmark Graphics Corporation

User Programming

Designing Your Model


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:
to clarify it in your own mind as much as possible.
to communicate it to those who may use it after you have built it
(See the chapter User Models on page 193.)

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?
Are parameters shared or local? If parameters are shared, they
are visible to, and can be used by, other users.
What do I want the user to see in the Wellbore Parameter
Editor? You can control what the model user sees in the
Wellbore Parameter Editor with several keywords such as
LATT (log attributes) and CATT (curve attributes).

3.

What is my output?
What do I want to call it?
Do I want to write it out or use it in another calculation?
Does it need to be saved?

R2003.12.1

ModelBuilder: Designing Your Model

35

Landmark

New Features For PetroWorks

4.

How does my model process data?


What kind of depth frameworks do I want to use: one for all
curves, different frameworks of all inputs and outputs, multiple
frameworks for different sets of output curves?
What units of measurement do I want to use for depths,
individual curves, and parameters?
Do I need to read in data and process a set of sequential
multiple depths?
In which direction do I want the model to process data?

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.

Understanding Example File Syntax


In the following sections, .mdl and .mds file code examples are
provided. A code example might look like this:
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.
Pipe symbols (|) are field delimiters.
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

Editing the .mdl File


How ModelBuilder Uses the .mdl File
When you write a procedure in ModelBuilder, you are writing standard
FORTRAN (or standard C, accessed from a simple FORTRAN call).
When the model is compiled, ModelBuilder is wrapping your code into
a larger program. That larger program is the portal to the OpenWorks
database and provides the user interface, including connections to the
Wellbore Parameter Editor and parameter storage in the OpenWorks
database.
It is important, then, to think of your code as a subroutine running
inside a large DO loop. The loop gets the curve data and parameters
from the database, then calls your model. The data is passed to the
model, which processes it, then returns control to the loop. The process
continues from the first depth point until the last depth point.
Unless you use certain processing variables (specified below),
ModelBuilder will process one depth value at a time, using only the
curve and parameter values associated with that depth.

Creating and Editing the .mdl File


Read this entire section before attempting to build your model.
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.
Using Subroutines from External Libraries
Be aware that although you can link subroutines from external FORTRAN
libraries, those libraries must be GNU FORTRAN complied. Do not mix libraries
built under GNU and other FORTRAN compilers.

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:

R2003.12.1

ModelBuilder: Editing the .mdl File

37

Landmark

New Features For PetroWorks

1.

Select File > Open Algorithm File (.mdl). The .mdl file shown on
the main ModelBuilder window opens in the NEDIT file editor.
If this is a new model rather than a copy of an existing one (see
Copying an Existing Model on page 23), a file containing only
two lines of code opens:

When you entered a name for your model, ModelBuilder


generated this file from the template. The file editor recognizes the
name you assigned, but the file is empty except for the program
name MYMODEL and the last line of code, END.
2.

Change the program name MYMODEL to the name of your model.

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

You must use FORTRAN 77 syntax rather than later versions of


the language. ModelBuilder is compatible only with FORTRAN
77 syntax.

Code must start on the first line in column 7 with:


PROGRAM <MODEL_NAME>
(Note that PROGRAM must be all caps.)

Code must end in column 7 with: END


(Note that END must be all caps.)

All executable statements must start in column 7.

Continuation symbols must appear in column 6.

ModelBuilder

38

Landmark Graphics Corporation

User Programming

No line may exceed column 72.

In order to override the standard FORTRAN default for variable


definitions, IMPLICIT NONE is automatically added to the
generated FORTRAN source file.

You can use three types of variables in the .mdl file:


logs and parameters
These are automatically declared in the include file, which is
automatically added to the FORTRAN code. These are always
declared as REAL. The curves may be 2 -D or 3-D.
local working variables
Any additional variables used in the code must be declared in
the .mdl file, directly after the PROGRAM statements. As stated
previously, your model code is a subroutine running inside a
large DO loop. Therefore, FORTRAN does not save the values
of local variables from one iteration to the next unless you use
the SAVE statement. See the example below.
ModelBuilder reserved words
Reserved variable names are declared in the model include file
automatically generated by ModelBuilder when you build the
model. Do not use any reserved ModelBuilder variable names.
These include all names specified in the .mds file, processing
flags, depth and step variables, etc. (See The .mdl Reserved
Variable Names and Features on page 42.)
There are functions that can be called by the model to get or set
certain values in place of using model variables.

In the .mdl file you can use virtually any legal FORTRAN syntax.
For example:
Separate include files may also be included
Named COMMON blocks
PARAMETERS (FORTRAN constants).
DATA statements

R2003.12.1

ModelBuilder: Editing the .mdl File

39

Landmark

New Features For PetroWorks

The following sample of code illustrates how these features are


used:

R2003.12.1

ModelBuilder

40

Landmark Graphics Corporation

User Programming

The .mdl Reserved Variable Names and Features


The .mdl FORTRAN code has access to many reserved variable names
that you can use to perform various tasks. Some provide information to
the model and some are available for redefinition by the model. These
variables are listed below by category and alphabetically.
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
IF (MD_PROC_UNIT .EQ. 0) THEN
PROC_UNIT = "FEET"
ELSEIF (MD_PROC_UNIT .EQ. 1) THEN
PROC_UNIT = "METERS"
ENDIF

In the table, numbers in parentheses refer to pages where you can find
more information on or an example of the variable.

Important: Changing Model Variable Values


You should not change any variable value in the model unless it is specifically
identified as one that the model can modify (such as output depth or current
depth).

R2003.12.1

ModelBuilder: Editing the .mdl File

41

Landmark

New Features For PetroWorks

.mdl Reserved Variable Names by Category


Category
Variable Name

Value/Type

Model Can
Modify

Explanation

General Information
MODEL_NAME (39)

character string

FORTRAN constant containing name


of model

no

MD_TITLE (87)

character string

FORTRAN constant containing title


of model that appears at top of model
application

no

MD_MODELTYPE (70)

INTERP or
ACQUISITION
(see rows below)

FORTRAN constant indicating which


type of model

no

INTERP

100

curves are based on project and well;


parameters are based on project, well,
zone (strat unit), and zone/well

ACQUISITION

200

curves are based on project and well/


service/run/pass; parameters are based
on well/service/run/passused for,
e.g., Env Corr, MRIL models

MD_UNIT_NAME

character string

FORTRAN variable containing name


of current strat unit

no

MD_WELL_NAME

character string

FORTRAN variable containing name


of current well

no

MD_WELLBT

depth value

Bottom of well

no

MD_WELLTP

depth value

Top of well

no

R2003.12.1

ModelBuilder

42

Landmark Graphics Corporation

User Programming

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Explanation

Model Can
Modify

Processing Flags
MD_MDLINT (52)

TRUE or FALSE

Is this the first sample of the model?

no

MD_WELLINT (52)

TRUE or FALSE

Is this the first sample of the well?

no

MD_ZONINT (52)

TRUE or FALSE

Is this the first sample of the stratunit? no

MD_LSTMDL (52)

TRUE or FALSE

Is this the last sample of the model?

no

MD_LSTWELL (53)

TRUE or FALSE

Is this the last sample of the well?

no

MD_LSTZON (53)

TRUE or FALSE

Is this the last sample of the stratunit? no

MD_MDLEND (53)

TRUE or FALSE

Model sets to TRUE to cause the


model to end before completing
processing the well

yes

MD_WELLEND (57)

TRUE or FALSE

Model sets to TRUE to end well


processing

yes

MD_ZONEND (54)

TRUE or FALSE

Model sets to TRUE to cause the


model to end before completing
processing the unit

yes

MD_MDLABORT (105)

TRUE or FALSE

Model sets to TRUE to cause the


model to abort

yes

MD_DEPTH (57)

depth value

Current input depth; whenever you set


MD_DEPTH, you must also set
MD_SETCUR_IN=.TRUE.

yes

MD_SETCUR_IN

TRUE or FALSE

Model sets to TRUE every time model


wants to change input depth
(MD_DEPTH)

yes

MD_XOTDEP (57)

depth value

Current output depth; whenever you


set MD_XOTDEP, you must also set
MD_SETCUR_OUT=.TRUE.

yes

MD_SETCUR_OUT

TRUE or FALSE

Model sets to TRUE every time model


wants to change output depth
(MD_XOTDEP)

yes

Depth Control

R2003.12.1

ModelBuilder: Editing the .mdl File

43

Landmark

New Features For PetroWorks

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Model Can
Modify

Explanation

Input Sample Framework Depth Information


MD_DEPTH

depth value

Current input measured depth; same


as MD_XINDEP

MD_RESPONSE (87)

WEAK or
STRONG
(see rows below)

Response to automatically determined


input working sample framework

Automatic WEAK (default)


Framework
Response
(56) (87)

Constant used to determine that


no
incompatible, nonresampleable curves
within sample framework are
processed with warning message only

Constant used to determine that


no
incompatible, nonresampleable curves
within sample framework abort
processing at the current well

depth values

Array of increment values of working


sample frameworks; this is scalar.

STRONG

MD_FRAME_INCREMENT (63)

R2003.12.1

no

ModelBuilder

44

Landmark Graphics Corporation

User Programming

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Explanation

Model Can
Modify

Processing Direction
MD_PROC_DIRECT

+1 or -1
(see below)

Constant for processing direction; can


be used in calculations (+/- step
increment), e.g.,
+MD_PROC_DIRECT*MD_CURVE_
INCREMENT

no

Processing
Direction

IS_DOWN

+1

FORTRAN constant used to


no
determine that the model is processing
from the top of well to bottom

IS_UP

-1

FORTRAN constant used to


no
determine that the model is processing
from the bottom of well to top

MD_PROC_UNIT

FEET or METERS Processing unit; can be compared to


(see rows below)
FORTRAN constants FEET or
METERS

Measured
Depth

FEET

FORTRAN constant that can be used


to determine depth unit

no

METERS

FORTRAN constant that can be used


to determine depth unit

no

TRUE or FALSE

FORTRAN constant flag indicating


whether processing direction has been
fixed in model

no

MD_NSMP (95)

numeric value

FORTRAN constant: Maximum


number of input/output samples

no

MD_NSMI (95)

numeric value

Number of input samples when using


multiple sampling

no

MD_NSMO (95)

numeric value

Number of output samples when


using multiple sampling

no

MD_INC_DEP_BY (96)

numeric value

Number of input samples between


current set and next sample set

no

MD_ISMO (96)

numeric value

Index for first output sample when


using multiple sampling

no

MD_NEWPAS (56)

TRUE or FALSE

Model sets to TRUE to start a new


interpretive pass

yes

MD_PASS (97) (56)

numeric value

Number of current interpretive pass;


this is automatically incremented

no

MD_DIRECT_FIXED

no

Multiple Sampling

Multiple Passes

R2003.12.1

ModelBuilder: Editing the .mdl File

45

Landmark

New Features For PetroWorks

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Model Can
Modify

Explanation

Curve Reconfiguration
MD_NEWSEL (106)

TRUE or FALSE

Model sets to TRUE to indicate that


model has changed the curve
configuration

yes

MD_SETCUR_IN (56)

TRUE or FALSE

Indicates whether an input log is to be


read. The order is determined by the
order of the logs in the.mds file
(TRUE = yes; FALSE = no)

yes

MD_SETCUR_OUT

TRUE or FALSE

Indicates whether an output log is to


be written to the well. The order is
determined by the order of the logs in
the .mds file
(TRUE = yes; FALSE = no)

yes

MD_XLNUM

numeric value

FORTRAN constant: Total number of


logs needed by model

no

MD_CURVE_NAME

character strings

Array contains curve mnemonic name


from the.mds file for each log

no

MD_CURVE_INPUT_NAME

character strings

Array contains all actual well input


names for each log. If curve is not
input; value = ABSENT

no

MD_CURVE_OUTPUT_NAME

character strings

Array contains all actual well output


names of each log. If curve is not
output, value = ABSENT

no

MD_CURVE_IN_SELECTED (63) 1 or 0

Array of 1s or 0s indicating whether a


log is to be read (1 = yes, 0 = no)

yes

MD_CURVE_OUT_SELECTED
(63)

1 or 0

Array of 1s or 0s indicating whether a


log is to be output (1 = yes, 0 = no)

yes

MD_CURVE_INCREMENT

depth values

Array containing increments for each


log

yes
(for output logs
only)

MD_CURVE_SIZE

numeric value

Array containing number of samples


for all logs. If curve is scalar, value =
1; if curve is multi-dimensional,
value = 0

yes
(for output logs
only)

Curve Information General

R2003.12.1

ModelBuilder

46

Landmark Graphics Corporation

User Programming

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name
MD_CURVE_NUM_DIM

Value/Type
numeric value

MD_CURVE_2ND_NPOINTS (68) numeric value

Explanation

Model Can
Modify

Array contains number of dimensions


for each curve: 1, 2, or 3

no

Array contains size of curve second


dimension which is to actually read/
created

yes
(for output logs
only)

MD_CURVE_MDS_2ND_NPOINTS

numeric value

Array contains size of curve second


dimension as defined in.mds file (i.e.,
maximum size)

no

MD_CURVE_DB_2ND_NPOINTS

numeric value

Array contains size of curve second


dimension of input curve in database

no

Array contains size of curve third


dimension which is to be actually
created/read

yes (for output


logs only)

MD_CURVE_3RD_NPOINTS (68) numeric value

MD_CURVE_MDS_3RD_NPOINTS

numeric value

Array contains size of curve third


dimension as defined in.mds file (i.e.,
maximum size)

no

MD_CURVE_DB_3RD_NPOINTS

numeric value

Array contains size of curve third


dimension of input curve in database

no

R2003.12.1

ModelBuilder: Editing the .mdl File

47

Landmark

New Features For PetroWorks

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name
MD_CURVE_RESAMPLING_
SCHEME

Value/Type
enumerated
strings
(see rows below)

Model Can
Modify

Explanation

Array containing curve resampling


yes
schemes. Accepted values are given in (for output logs
rows below.
only)
For more information on these values,
see the table subsection Curve
Resampling Scheme below and the
section Data Framework on
page 46 of the Introduction to
PetroWorks Family of Products
manual.

Curve
CONTINUOUS_
Resampling FUNCTION
Scheme

Constant used to determine that the


resampling scheme of a curve is
continuous (i.e., resampling by
interpolation)

no

SINGLE_POINT

Constant used to determine that the


resampling scheme of a curve is not
resampleable

no

STEP_FUNCTION_
TOP

Constant used to determine that the


resampling scheme of a curve is
continuous (i.e., value is repeated for
z index point immediately above
current point)

no

STEP_FUNCTION_
BOTTOM

Constant used to determine that the


resampling scheme of a curve is
continuous (i.e., the value is repeated
for z index point below current point)

no

STEP_FUNCTION_
MIDPOINT

Constant used to determine that the


resampling scheme of a curve is
continuous (i.e., value is repeated for
z index point nearest current point)

no

REQUIRED

Constant used to determine if curve is


required

no

OPTIONAL

Constant used to determine if curve is


optional

no

MD_CURVE_OPT_REQ

R or O
(letter "oh")

Array containing letters indicating


whether logs are required (R) or
optional (O)

no

MD_CURVE_FRAME_ID

numeric value

Array containing framework IDs for


each log. Default sample input
framework = 1

yes
(for output logs
only)

MD_CURVE_UNIT

character strings

Array containing curve units of


measure for each log

no

R2003.12.1

ModelBuilder

48

Landmark Graphics Corporation

User Programming

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Explanation

Model Can
Modify

MD_CURVE_2ND_UNIT

character strings

Array contains units for 2nd


dimension component. If curve is not
multidimensional, value = ABSENT

no

MD_CURVE_3RD_UNIT

character strings

Array contains units for 3rd


dimension component. If curve is not
multidimensional, value = ABSENT

no

MD_NUMPAR

numeric value

FORTRAN constant: Total number of


parameters needed by model

no

CDX_ParameterMnemonic
(71)

numeric value

FORTRAN constant. Index of


ParameterMnemonic in parameter
arrays

no

MD_PARNAM (71)

character strings

FORTRAN array containing all the


parameter names in the same order as
defined in the .mds file

no

Parameter Information

FORTRAN, Constants and Temporary Variables


Nulls
ABSENT

-999.25

FORTRAN constant to indicate no or


invalid value

no

FILL

-999.25

FORTRAN constant to indicate no or


invalid value

no

NULL

-999.25

FORTRAN constant to indicate no or


invalid value

no

CANADIAN_METRIC

FORTRAN constant used to


determine that current measurement
system is Canadian Metric

no

SPE_METRIC

FORTRAN constant used to


determine that current measurement
system is SPE Metric

no

US_OIL_FIELD

FORTRAN constant used to


determine that current measurement
system is US Oil Field

no

US_OIL_FIELD_METRIC

FORTRAN constant used to


determine that current measurement
system is US Oil Field Metric

no

Measurement System

R2003.12.1

ModelBuilder: Editing the .mdl File

49

Landmark

New Features For PetroWorks

.mdl Reserved Variable Names by Category (Continued)


Category
Variable Name

Value/Type

Model Can
Modify

Explanation

FORTRAN File Units


TUNT1

File unit for FORTRAN file

no

TUNT2

File unit for FORTRAN file

no

TUNT3

File unit for FORTRAN file

no

character string

Temporary string a model writer can


use for any purpose to avoid having to
declare a local string (maximum
length is 80 characters)

yes

Miscellaneous
CSTRNG

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:

Flags for checking


Flags to be set by the model

Flags for Checking


The following flags are for information only. Do not change any of the
flags for checking.
Zone and model initialization flags are automatically set by
ModelBuilder to indicate when the first sample of any zone is being
processed and when the first sample of a well is being processed. These
are available only for checking by the model.
MD_MDLINTBeginning of model. At this point in the program, you
can open files, do a one-time initialization, save original curve
configurations, etc.
The flag MD_MDLINT is TRUE only for the first sample of the model.
MD_WELLINTBeginning of well. At this point in the program, you
can open files, do a one-time initialization, save original curve
configurations, etc.
The flag MD_WELLLINT is TRUE only for the first sample of the well.
MD_ZONINTThis section is good for initialization, setting local
variables to interval/unit start/ends, etc. At the beginning of each
processing zone the flag MD_ZONINT is set to TRUE. After the first
iteration through the model algorithm, this flag is reset to FALSE. It is
then reset to TRUE at the beginning of the next process zone.
MD_PASSINTThis section is good for initialization, setting local
variables to interval/unit start/ends, etc. for acquisition models. At the
beginning of each acquisition model the flag MD_ZONINT is set to
TRUE. After the first iteration through the model algorithm, this flag is
reset to FALSE. It is then reset to TRUE at the beginning of the next
model.
MD_LSTMDLLast sample in the units. Good time to close files.

R2003.12.1

ModelBuilder: Editing the .mdl File

51

Landmark

New Features For PetroWorks

MD_LSTWELLLast sample in well. Good time to close external wellbased files.


MD_LSTZONLast sample in the interval/unit. Good for determining,
for example, when it is time to go to the next pass.
The diagram below illustrates how these flags function during
processing. The following diagram illustrates the processing for a
single well.
User-SpecifiedDepth = 7000-8000 ft

Total Depth
Beginning of Model:
MD_WELLINT = TRUE
1000 ft

(or single unit)


1000 ft

Top Depth

Two Strat Units, A & =


B
1000 ft

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
7000 ft

MD_WELLINT=TRUE
MD_ZONINT=TRUE

At Depths Between
MD_ZONINT=FALSE
MD_LSTZON=FALSE

8000 ft

9000 ft

9000 ft

Bottom Depth

MD_LSTZON=TRUE
MD_LSTWELL=TRUE

MD_ZONINT=TRUE &
MD_LSTZON=FALSE

8000 ft

9000 ft

At Depths Between
MD_WELLINT=FALSE
MD_LSTWELL=FALSE
MD_ZONINT=FALSE
MD_LSTZON=TRUE &
MD_LSTWEL=TRUE

Bottom Depth

MD_LSTWELL=TRUE

Flags to Be Set by Model


MD_MDLENDGiven certain situations (errors found for example) you
may want to stop the model. At this point all samples, excluding the
current calculated values will be output to the database.
R2003.12.1

ModelBuilder

52

Landmark Graphics Corporation

User Programming

MD_ZONENDSame as above except model continues to the next unit.


Keep in mind that once MD_MDLEND or MD_ZONEND appear in the
model, any data created at the current depth is not output to the
database. If you want the model to output the current depth sample,
then quit, you must use a local flag, turn it on/off, check it on the next
iteration and then set MD_MDLEND or MD_ZONEND. The local variable
must also be declared with a FORTRAN SAVE statement, since local
variables may become reintialized at every depth increment. The
sample of code that follows illustrates how these flags can be used.
You must explicitly close output files.
Any output files opened in the model code must be closed explicitly before the
program or well end with the CLOSE command. Otherwise, your output may not
be written to the file.

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.
R2003.12.1

ModelBuilder: Editing the .mdl File

53

Landmark

New Features For PetroWorks

Defining Processing Criteria


Criteria for Automatic Determination of Model Processing
The user-selected set of input curves and the interval determines the set
of depths a model processes. The set of processing depth values
depends on the curves Resampleability and sample rates:

If all input curves are resampleable, the model uses the curve with
the smallest increment as the reference curve

If one or more curves are nonresampleable, the nonresampleable


curve with the most points becomes 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.

Model Controls of Processing Criteria


The model can control or define the following criteria:

Depth Unit of Measurement


Response to Automatically Determined Framework
Multiple Passes
Processing Direction
Change Depths
Filtering
Define Explicit Framework

Depth Unit of Measurement


The Feet/Meters button allows users to switch back and forth between
feet and meters. This function helps model writers who have different
data sources at different depth units.
You can specify the depth unit of measurement (UOM) to handle
depth-dependent calculations or read depths from external files. The
.mds keywords are:

R2003.12.1

DEPTH_UOM=FEET
DEPTH_UOM=METERS

ModelBuilder

54

Landmark Graphics Corporation

User Programming

Response to Automatically Determined Framework


If the set of input curves contains more than one nonresampleable,
incompatible (i.e., share the same framework as the other curves)
curve, the curve with the most depth points becomes the reference
curve (i.e., the curve that determines the output framework).
The models response to incompatible input curve framework is
controlled by the .mds keyword RESPONSE. This keyword can take
one of two values:

RESPONSE=WEAK
Model reports incompatibility warning, but continues processing
(default).

RESPONSE=STRONG
Model reports incompatibility error and aborts processing well.

The response applies to the input sample framework only.

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_DEPTH =(whatever local variable you have used to save
initial zone depth)
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.)

R2003.12.1

ModelBuilder: Editing the .mdl File

55

Landmark

New Features For PetroWorks

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

Change Depths Example


In this example the interval or strat unit starts at 1000 feet, the depth
increment is 0.5 feet, and processing is in a downward direction.
Initially, log curve data is sent to your model from 1000 feet. You want
to compare the GR value at the current depth, 1000 feet, to the value 10
feet deeper. When your model starts, MD_DEPTH will be 1000 feet.
Within your program, you can reset MD_DEPTH = 1010 feet and
then read in the GR value.
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
R2003.12.1

ModelBuilder: Editing the .mdl File

57

Landmark

New Features For PetroWorks

single sample, as well as assigns that value to a variable


(NumSamplesOut) accessible in the .mdl file:
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:
Depth
Current Depth Level-->1000.0
1000.5
1001.0
1001.5
1002.0
1002.5
1003.0
1004.5
1005.0

GR

Output Index

75.2
82.5
65.2
55.6
45.8
34.2
29.9
21.1
19.6

| 1
| 2
| 3

<-- Depth we want to write out

If the current depth level the application is processing is 1000.0 feet.,


the application will read in log values for the depths 1000.0, 1000.5,
and 1001.0. If we filter the log data vertically, we would average the
three log values over those three depths, but we would want to write out
the averaged (filtered) value at a depth in the middle of the three depths
we read in, for example, at 1000.5.
Do that by declaring another variable ISMO, the Multiple Sampling
Output Index, in our .mds file:
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
1000.0
Current Depth Level-->1000.5
1001.0
1001.5
1002.0
1002.5
1003.0
1004.5
1005.0

GR
75.2
82.5
65.2
55.6
45.8
34.2
29.9
21.1
19.6

OutputIndex

| 1
| 2 <-- Depth we want to write out
| 3

When processing multiple depth levels, ModelBuilder reads log values


into an array of size NSMI. We can refer to those log values in that
array by putting the number of the array element in parenthesis next to
the name of the input or output curve. Assuming that we have read the
input log in as GR, a simple equal weighted filter routine in the .mdl file
would look like this:
GR_FILTER(OutputIndex) = (GR(1) +GR(2) + GR(3))/3

The following would have the same effect:


GR_FILTER(2) = (GR(1) +GR(2) + GR(3))/3

The output value of the GR_FILTER writes out at a depth index offset
one element (2) from the current input depth element (1).

Input Working Sample Framework


For a complete discusion of sample frameworks, see Data
Framework on page 46 in the PetroWorks Basics chapter of the
Introduction to PetroWorks Family of Products manual.
The input working sample framework is usually set to the smallest
increment (sample rate) of the set of input curves. However, if the set
includes a nonresampleable curve, the working sample framework for
the set is based on the nonresampleable curve. If there is more than one
nonresampleable curve in the set, the working sample framework is
based on the curve with the greatest number of samples.
The only explicit option for an input framework is ALL.

R2003.12.1

ModelBuilder: Editing the .mdl File

59

Landmark

New Features For PetroWorks

User-Specified Reference Curve


You can allow users to specify a reference curve using an automatically
generated parameter in the Wellbore Parameter Editor. Reference
curves are included in the reference curve group. You can also provide
a default value for that parameter (i.e., the default reference curve
name) if you choose. If no default value is specified, the default
parameter value is <NULL>. It is important to note that the default
name, if specified, can be the same as one of the input curve
mnemonics in the.mds file (as defined by a LOGS keyword entry) or
any existing curve in the well. The input reference curve must exist in
the well.
During processing, if a user accepts the default reference curve name,
the .mds curve mnemonics are searched for a match. If found, the well
curve name selected by the user in the Wellbore Parameter Editor for
that .mds curve mnemonic becomes the working reference curve. If not
found, then that mnemonic is assumed to correspond to a curve existing
in the well.
During runtime, the model validates that the reference curve, as
resolved above, exists in the well. If it exists, its framework is evaluated
for compatibility with the input curve frameworks. If the input curve
frameworks are resampleable or compatible nonresampleable,
processing continues, and the inputs are resampled as necessary. If the
input curve frameworks are not compatible with the reference curve,
processing continues on the basis of the value of the RESPONSE
keyword.
If the value of the reference curve parameter is NULL, the working
sample framework is automatically determined.
These behaviors are controlled with the IFRAMEWORK .mds keyword
and the USER framework type:
+-------------------+----------------------+
|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

Model Fixed Reference Curve


You can define the reference curve in the .mds file and hide that curve
from the user. It is important to note the defined reference curve must
match an existing curve in the well. The reference curve mnemonic can
also match one of the input curve mnemonics in the .mds file.
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.
If the named reference curve cannot be resolved in the well, processing
is terminated for the well, and an appropriate error message is written
to the model status window.
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|
+-------------------+------------------------+
User Selected Increment

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
|
+------|-----------+-------------------------+

R2003.12.1

ModelBuilder: Editing the .mdl File

61

Landmark

New Features For PetroWorks

The parameter name refers to parameter specified by a CNST entry for


this purpose. It may belong to any parameter group defined in the .mds
file.
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.
ModelBuilder defaults to automatic determination.
In the absence of an IFRAMEWORK entry, the automatic process described
above in Criteria for Automatic Determination of Model Processing on page 55
determines the sample framework.

Model Variables in .mdl Code


There is one model variable that can be examined in the code in the
.mdl file to evaluate the working input sample framework:

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).

Runtime Curve Reselection


Curves can be turned on and off during runtime by resetting the
MD_CURVE_IN_SELECTED and MD_CURVE_OUT_SELECTED
arrays for input and output curves, respectively. The index is the order
that the curve is in under LOGS in the .mds file. Each time curves are
reselected, the selection flag should be turned on.
It is recommended that the original curve mapping configuration be
saved to local working arrays.

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:

R2003.12.1

Name
Input/Output type
Unit of Measure
ModelBuilder

62

Landmark Graphics Corporation

User Programming

Description (maximum is 40 characters, but can be added to with


LATT entries)
Why explicitly define units in ModelBuilder?
Like most applications, ModelBuilder results are greatly influenced by the units
of measurement issue: Unless explicitly stated otherwise in your .mds file,
ModelBuilder expects that curves are retrieved and manipulated using the units
defined for that curve in the session measurement system.

The attributes from LATT are:

R2003.12.1

Multiple description lines (to be concatenated together for a


possible maximum of 1K)
Title (for display in Wellbore Parameter Editor)
2nd and 3rd dimensions
Unit Type (UNIT) and Base Unit Type (UNITTYPE)

ModelBuilder: Editing the .mdl File

63

Landmark

New Features For PetroWorks

Multi-valued (Multi-dimensional) Curve Data


Models can process multi-dimensional data as long as that data is
stored in the OpenWorks log tables or read from an external file. You
can process data with two or three dimensions (2D or 3D).
For purposes of this discussion, a multi-valued array refers to a single
curve array (2D or DIMENSION2), and multi-dimensional curve
data refers to multiple arrays or matrix data (3D or DIMENSION3). A
curve with a second dimension (DIMENSION2) is defined by a set of
monotonic values along a single axis. Curves with a second and third
dimension (DIMENSION3) are defined with monotonic values along
two axes. These axes need not be orthogonal to the z-index axis or to
each other.

R2003.12.1

ModelBuilder

64

Landmark Graphics Corporation

User Programming

The following table lists curve types that can be processed by


ModelBuilder models. The example column shows how the curves are
referenced in the model code to designate a particular curve data
element. The indices are locally defined variables. For example,
(i, j, k), (M_INDEX, N_INDEX, Z_INDEX), or whatever the model
writer prefers. The table uses the following syntax: i = 1,n; j=1,m, and
k=1,z. Multi-sampling (multiple samples over a set of depths) is also
included.
Curve Types Processed by ModelBuilder Models
Data Type
Scalar curves

Size
1

Multi-sampling
z

Examples

Comments

gr

Any of the common single valued data

gr(k)

Multiple samples of scalar data on z-index

MRIL echo trains

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

Acoustic waveforms

m,n

z,m

wff1(i,j)

m receivers by n samples: receivers = 1 to


m, samples = 256, 512, 1024, (4096).

wffl(j,i,k)

Multiple sample sets on z-index. These are


normally defined as individual waveforms
in Halliburton models.

wffl(i)
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

Special core analysis

Photographs (core,
SEM, outcrop,)

2,n

m,n

z,2,n

z,m,n

dip(j,i,k)

Tadpoles: dip angle, dip magnitude,


quality

scd(i,k)

n number of pairs (m=2)

scd(j,i,k)

Multiple samples of special core analysis

bmp(i,k)

m by n rectangle of data. The data area


may be scaled to a depth range (as with a
core photo) or may be indexed to a single
depth (as an SEM photo)

bmp(j,i,k)

multiple sample sets on z-index


Well test data

2,n

z,m,n

wtd(i,k)
wtd(j,i,k)

Usually pressure vs. time: pressure-time


pairs with time periodic or aperiodic.
multiple samples on z-index

R2003.12.1

ModelBuilder: Editing the .mdl File

65

Landmark

New Features For PetroWorks

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
|
+---------------|------------|--------|-------+

NPOINTS is the actual number of elements required for the specific


dimension axis. It can also be the maximum number of elements that
can be defined dynamically for the specific dimension axis at the
beginning of model processing.

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 |
+---------------|------------|--------|------+

It is important to note that the actual size of the second or third


dimension can be different from the value specified in the .mds file if
any of the following are true:

R2003.12.1

The number of points for specific dimension of curve is defined


dynamically at the beginning of processing. The defined number of
points cannot exceed the .mds-specified number of points.

The number of points for actual dimension of the selected input


curve is greater than the .mds-specified number of points. In this
case, only the number of input curve elements specified in the .mds
file is passed to the model code.

The number of points for actual dimension of the selected input


curve is less than the .mds-specified number of points. In this case,
all the input curve element values are passed to the model code,
and the remaining values are filled with nulls.

ModelBuilder: Editing the .mdl File

67

Landmark

New Features For PetroWorks

Here is an example of the .mds file entry to dynamically redefine size.


TITL| Dynamic 2D log |
CMNT
CMNT
CMNT|-----------------+-+----------------------------+
CMNT|
| |
|T|
|
CMNT| CURVE|I|
|Y|
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
CMNT|------|-|--------|-|----------------------------|
LOGS|LOG2X |I|
|0| Input 2D log
|
LOGS|LOG2F |O|
|0| Output 2D log
|
LOGS|CHECK_SM |O|
|0| Check sum for LOG2D
|
LOGS|LOG2G |O|
|0| Output 2D log
|
LOGS|LOG2X_1|O|
|0| Check sum for LOG2D
|
CMNT|------+-+--------+-+----------------------------+
CMNT|------+------------+---------+------------------+
LATT|LOG2X | DIMENSION2 | NPOINTS |
20
|
LATT|LOG2F | DIMENSION2 | NPOINTS |
20
|
CMNT|------+------------+---------+------------------+
CMNT
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT| NAME |DEFAULT |T| MIN
| MAX
|UN|DESCRIPTION |GRP| DEFINITION|
CMNT|
|
|Y|
|
|IT|
|IDS|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------|
CNST|INCR | 1.0
|I| 1.0
|1000.0 | |Increment
|
|
|
CNST|USER_DIM |
|I|
|
| |User entered dimension | | |
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT
$EOF

The related .mdl file entry for this example is:


PROGRAM DYNAMIC 2D
C
C
C

Dynamically redefine size


INTEGER I,J,IER
character txt*80

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

10

User Programming

LOG2F(J) = LOG2X(J)
CHECK_SM = CHECK_SM + LOG2X(J)
ENDIF
CONTINUE
END

Parameter Data
Parameter Key Rules
Alternate set or sets of rules are required for interpretive and
acquisition models. These different rules determine which tabs appear
in Wellbore Parameter Editor.
The default type is an interpretive model. You can define an acquisition
model in the .mds file with the following syntax:
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

Process Selection:

model GUI

Acquisition

R2003.12.1

Curves:

project
well/service/run/pass

Parameters:

project
well/service/run/pass

Process Selection:

well/service/run/pass
ModelBuilder: Editing the .mdl File

69

Landmark

New Features For PetroWorks

.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

Editing the .mds File


The purpose of the .mds file is to specify, using keywords, all
parameters, input and output curves, variables, units of measurement,
and data structures required for your model.
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.

2.

Select Tools > File Editor. The .mds template file opens.

Double-click on
the .mds file line
to select the file.

R2003.12.1

ModelBuilder: Editing the .mds File

71

Landmark

New Features For PetroWorks

When you entered a name for your model, ModelBuilder


generated this file along with the .mdl file as previously described.
3.

Use the following general rules, keywords, and delimiters to


continue building the .mds file.

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:

R2003.12.1

The .mds file must have a .mds extension and have a filename that
is the same as the .mdl filename.

Files should follow the format of the example shown in the


Model Data Specification Template with Keywords on page 87.

Begin each line in the .mds file with a keyword. (See the
discussion of keywords below.)

ModelBuilder

72

Landmark Graphics Corporation

User Programming

Leave fields blank if they do not apply to your model.

Remember to start comment lines with the keyword CMNT.

End all .mds files with the keyword $EOF.

.mds File Keywords and Delimiters


The table below contains a list of keywords, their meanings, and the
delimiters you must use to separate them. A sample .mds file template
with keywords and their usage is provided at the end of this chapter
inModel Data Specification Template with Keywords on page 87.
Keyword

Delimiter

Meaning

CATT (94)

Constant attributes (parameters)

CHKA (91)

Check action for out-of-range parameter

CMNT (87)

no limiter

Comments (not read or used)

CNST (92)

Constants (Parameters)

CREF (93)

Shared Constants (Parameters)

GRPN (91)

Group names for parameters.


Note that names may include alphanumeric text, including underscores;
names cannot include reserved FORTRAN operators such as &, +, /,
and *. You can build models using these characters, but the models will
not run.

IFRAMEWORK (88)

Define input framework

ISMO (96)

Output index in multiple sampling

LATT (89)

Curve attributes

LOGS (88)

Curves

NINC (96)

Number of samples to increment in multiple sampling for next depth


iteration

NSMI (95)

Number of input samples in multiple sampling

NSMO (95)

Number of output samples in multiple sampling

NSMP (95)

Number of samples in multiple sampling

OPTNLIST (91)

List of optional curves

PASS (97)

Multiple pass indicator

TITL (87)

Model title (appears at top of model screen). The title is limited to 54


characters. If a title longer than 54 characters is used, the model will not
run.

R2003.12.1

ModelBuilder: Editing the .mds File

73

Landmark

New Features For PetroWorks

Configuring Your Model


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:

Select optional source files, object files, or libraries you wish to


use in your model

Set compiler switches

Supply information about your model


Configuration options are not required to build and run a model.
You do not need to use any of the configure options to create a model that
successfully builds and runs. The configuration selections are all optional.

To open the Configure window, click on the Configure button on the


ModelBuilder main window. The ModelBuilder Configure window
appears:

The following sections describe the tabbed configuration options in the


Configure window.

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.
Use only GNU compiled external library files.
When you link files from external FORTRAN libraries, those libraries must be
GNU FORTRAN complied. Do not mix libraries built under GNU and other
FORTRAN compilers.

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.)
To choose a source file:

R2003.12.1

1.

Click on the Source Files tab in the Configure window. Any source
files that exist in your path appear in the window.

2.

To select one or more files from the window, click on the


filename(s), and click on the Close button.

3.

To select a file from another directory, click on the Select button to


view a list of directories and files.

4.

Click on a directory to select it, then click on the Filter button if


you want to view only the source files listed in that directory.
Alternately, if you already know the directory path, type the
pathname in the Directory Path field and click on the Filter
button.

5.

Click on one or more source files in the right-hand column to


highlight the source files.

6.

Click on the Select button. The file or files you chose now appear
in the Model Contents window under Optional Source Files.

ModelBuilder: Configuring Your Model

75

Landmark

New Features For PetroWorks

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.

2.

Click on the Compile button. The Build Messages window


appears. When the file or files have finished compiling, or if errors
occur, status messages appear the Build Messages window.

3.

After the compile has successfully completed, click on the Cancel


button at the bottom of the Build Messages window.

4.

If a model fails to successfully compile, first look at the .err file


generated under the /run directory, a subdirectory of your root
directory. This file gives you information about problems that
occurred when the program attempted to compile your model.
Note
ModelBuilder automatically runs g77 with the option -fno-second-underscore.
This produces linking symbols that end in one underscore.

Build Library Button


If you have more than one source file, you may want to place the source
files together in a library to which you can assign a meaningful name.
The Build Library button is also located at the bottom of the Source
Files tab panel. Note that when you build a library, the source files you
select are automatically compiled.
To build a library:

R2003.12.1

1.

In the Source Files tab panel, select the source files you wish to
combine.

2.

Click on the Build Library button. The Build Library window


appears. If any libraries already exist in the directory in which
your source files reside, they are listed in the Library List window.

3.

Type a new library name in the New Library field.

4.

Click on the Build button. A message indicating that the library


has been built successfully appears in the Build Messages window.

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.
To choose an object file:
1.

Click on the Object Files tab in the Configure window.

2.

Click on the Select button to view a list of directories and files.

3.

Click on a directory to select it, then click on the Filter button if


you want to view only the object files listed in that directory.

4.

Click on an object file in the right-hand column to highlight the


object file.

5.

Click on the Select button.

OR
If you already know the directory path,

R2003.12.1

1.

Type the directory path.

2.

Click on the Select button.

3.

Click on an object file from the right-hand column to highlight the


object file.

4.

Click on the Select button.

ModelBuilder: Configuring Your Model

77

Landmark

New Features For PetroWorks

Libraries
A library is a group of object files.
Link to external libraries only if the libraries are compiled GNU.
When you link files from external FORTRAN libraries, those libraries must be
GNU FORTRAN complied. Do not mix libraries built under GNU and other
FORTRAN compilers.

To select a library:
1.

Click on the Libraries tab in the Configure window.

2.

Click on the Select button to view a list of directories and files.

3.

Click on a directory to select it, then click on the Filter button if


you want to view only the libraries listed in that directory.

4.

Click on a library file from the right-hand column to highlight the


library file.

5.

Click on the Select button.

OR
If you already know the directory path,

R2003.12.1

1.

Type the directory path in the field.

2.

Click on the Select button.

3.

Click on a library file in the right-hand column to highlight the


library file.

4.

Click on the Select button.

ModelBuilder

78

Landmark Graphics Corporation

User Programming

Compiler Switches
To configure the FORTRAN and C compiler switches:
1.

Click on the Compiler Switches tab in the Configure window. A


panel displaying FORTRAN compiler switches and C Compiler
Switches appears.

2.

To choose the default values, click on the Default button. The


default values are shown in the sample screen below.

3.

To choose other values, click on them to highlight them. Click on


highlighted items to unselect them.

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.

Debugging Your Model


If a models fails to successfully build (compile), first look at the .err file
generated under the /run directory. This file gives you information
about problems that occurred when the program attempted to compile
your model.

R2003.12.1

ModelBuilder: Configuring Your Model

79

Landmark

New Features For PetroWorks

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.

R2003.12.1

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.

ModelBuilder

80

Landmark Graphics Corporation

User Programming

3.

Click on the Run button. The following window appears with a


field for arguments.

4.

Type the arguments as follows:


-fc PTWPRO -pppdf <full path and file name for the
pppdf file>.

Below is an example for the model named Filter in the Arctic


directory.
-fc PTWPRO -pppdf /home/jeeves/rtekell50/Arctic/
mb_pppdf/Filter.pppdf

5.

Click on the Run button.

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.

You can view information on the GNU debugger (g++), C compiler


(gcc), and FORTRAN compiler (g77) by selecting Tools > Gnu > Gnu
Man Pages. For updated, detailed information about the g77 compiler,
refer to online documents at
http://www/gnu.org/software/gcc/onlinedocs/

Landmark does not support questions regarding the Gnu debugging


software; it is provided for your convenience.

R2003.12.1

ModelBuilder: Configuring Your Model

81

Landmark

New Features For PetroWorks

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,
1.

Select the Information tab in the Configure window.


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

2.

Type in the appropriate fields the information you wish to disclose.

3.

After you have entered information, click on Close.

ModelBuilder

82

Landmark Graphics Corporation

User Programming

Building and Running a Model


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.)
To initiate the build:
1.

Click on the Build Model button.


The Build Messages window appears and provides status
messages.

2.

R2003.12.1

Click on the Close button to close the Build Messages window.

ModelBuilder: Building and Running a Model

83

Landmark

New Features For PetroWorks

3.

In the main ModelBuilder window, click on the Run button.


How do I know what happens during processing?
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:
grep ==Status: model_<model name>.log | more
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

Before processing your model be sure you have read:

R2003.12.1

the section Understanding the Interface on page 16 of the


PetroWorks Basic Interpretive Applications manual. Your model
window interface has the same appearance and functionality as
any Landmark-supplied interpretive application.

the chapter Editing Wellbore Parameters on page 70 of the


PetroWorks/LogEdit Well Data Management and Editing manual.
You access Wellbore Parameter Editor via the Edit Parameters
button in your model window.

ModelBuilder: Building and Running a Model

85

Landmark

New Features For PetroWorks

Model Data Specification Template with Keywords


The following template describes the setup of the model specification
(.mds) file. The keywords appear in the first four spaces followed by
fields separated by delimiters (|, ,, =). This template can be
used as a basis for creating such a file by including the keywords and
fields needed for your particular model and then deleting any unneeded
or extraneous lines. Field widths are not fixed and can be widened if
needed, and, in many cases, left blank. The keyword is first introduced
in double angle brackets (<<KEYWORD>>), followed by a description
of its purpose and fields and then an example. Note that each keyword
must be immediately followed by the delimiter.
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

CMNT <<IFRAMEWORK>>
MODEL EXPLICIT DEFINITION OF INPUT WORKING SAMPLE FRAMEWORK
CMNT
CMNT The IWSF can be defined by the model for all the input curves. The two types
CMNT are either "FIXED" or "USER". The USER type sets up values in the Wellbore
CMNT parameter editor, which can be changed by the user. The two possible attributes
CMNT are either based on a reference curve framework or a specified increment.
CMNT
CMNT Field 1: OPTION
CMNT
ALL
This is used to be consistent with the entry for OFRAMEWORK
CMNT
below
CMNT Field 2: TYPE
CMNT
FIXED Fixed by the model, user cannot change
CMNT
USER
User can change in the Wellbore Parameter Editor
CMNT
CMNT Field 3: ATTRIBUTE
CMNT
REFERENCE
A curve existing in the well which will provide
CMNT
information to predefine the ISWF depth points
CMNT
INCREMENT
An increment selected by the user
CMNT
CMNT Field 4: Value
CMNT
NULL:
The model writer leaves it to the user to select
CMNT
a curve or not.
CMNT
Reference curve name:
CMNT
This can be one of the input curves defined in the
CMNT
model, or any existing curve in the database.
CMNT
Aliases can be used.
CMNT
Parameter name for increment:
CMNT
This is the parameter in the Wellbore Parameter
CMNT
Editor the user can use to enter an processing
CMNT
increment. This must be a parameter defined
CMNT
as one of the CNST entries for this model.
CMNT
CMNT Example: All possible valid definitions are listed below:
CMNT|-------------+---------+-------------+----------------+
CMNT|
OPTION | TYPE
| ATTRIBUTE |
Value
|
CMNT|-------------+---------+-------------+----------------+
IFRAMEWORK| ALL | FIXED | REFERENCE |
Depth
|
IFRAMEWORK| ALL | USER
| REFERENCE |
NULL
|
IFRAMEWORK| ALL | USER
| REFERENCE |
Depth
|
IFRAMEWORK| ALL | USER
| INCREMENT |
My_increment |
CMNT|-------------+---------+-------------+----------------+
CMNT
CMNT-----------------------------------------------------------------CMNT <<LOGS>>
DATABASE CURVE DEFINITIONS
CMNT
CMNT Field 1 - CURVE NAME:
CMNT Variable name used in the model (can be assigned to a database curve)
CMNT The maximum length of a curve is 28 characters. If a curve attribute
CMNT (see CATT below) for TITLE is not defined, the name will be
CMNT used for the title (column headings, etc.).
CMNT
CMNT Note: curve names ARE case-sensitive. However, the curve variable
CMNT names in Fortran are not. This means that you can specify a curve
CMNT "Log1" and the database will create a "Log1" which is different from
CMNT an existing curve "log1". However, because of the Fortran limitations,
CMNT you cannot specify two curves, "log1" and "Log1" in the same model.
CMNT
CMNT Field 2 - IO-INPUT/OUTPUT:
CMNT I/O type, can be I (input)or O (output).
CMNT
CMNT Note: If an input curve is required (i.e. not optional see OPTNLIST
CMNT below), and does not exist in the well, the program will abort.
CMNT
CMNT Field 3 - UNITS:
CMNT Curve units expected by the model. If the measurement system being
CMNT run is different from the measurement system containing the specified
CMNT unit, the values will be converted to the units specified in the mds
CMNT file. All curve units must conform to the OpenWorks database table. See
CMNT the pulldown menu in ModelBuilder. The maximum length of a unit
CMNT is 12 characters.
CMNT
CMNT Field 4 - TYPE: (obsolete)

R2003.12.1

ModelBuilder: Model Data Specification Template with Keywords

87

Landmark

New Features For PetroWorks

CMNT Not presently used


CMNT
CMNT All curve values are returned as floats.
CMNT
CMNT Field 5 - DESCRIPTION:
CMNT Curve description written to curve header in database for the curve.
CMNT If a longer description is required see LATT below.
CMNT
CMNT For additional options, see keyword LATT below.
CMNT
CMNT Example:
CMNT|-----------------+-+-----------+-+---------------------------+
CMNT|
| |
| |
|
CMNT|
|I|
| |
|
CMNT| CURVE NAME
|O|
UNITS
| |
DESCRIPTION
|
CMNT|-----------------+-+-----------+-+---------------------------+
LOGS|Neutron_Porosity |I|v/v decimal| |Limestone neutron porosity |
LOGS|RHOB
|I|g/cm3
| |Bulk density
|
LOGS|Temperature
|I|degF
| |Formation Temperature
|
LOGS|CDE
|O|g/cm3
| |Corrected Density Log
|
CMNT|-----------------+-+-----------+-+---------------------------+
CMNT
CMNT-----------------------------------------------------------------CMNT <<LATT>>
ADDITIONAL DATABASE CURVE ATTRIBUTES
CMNT
CMNT This keyword allows for additional information for a specific curve
CMNT
CMNT Field 1 - CURVE NAME:
CMNT
CMNT The curve name must exactly match a curve name defined with LOGS.
CMNT
CMNT Field 2 - ATTRIBUTE TYPE:
CMNT
CMNT TITLE:
The curve title which can be used for column 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
Note: You can have several entries for description to get a more
CMNT
detailed description.
CMNT
CMNT ************************************************************************
CMNT UNITTYPE:
CMNT
For output curves only, type of unit of measure. The types can
CMNT
be found on the ModelBuilder window on the pulldown menu under
CMNT
"Tools"
CMNT ************************************************************************
CMNT
CMNT FRAME ID:
CMNT
If output curve is to belong to a certain output working
CMNT
framework, that id is inserted in Field 3
CMNT
CMNT DIMENSION 2:
CMNT
CMNT
Field 3:
CMNT
2nd dimension attributes:
CMNT
CMNT
NPOINTS -- number of elements (size) in 2nd dimension
CMNT
UNITS
-- units of measure for 2nd dimension
CMNT
CMNT
Field 4: Value for the above attributes.
CMNT
CMNT DIMENSION 3:
CMNT
Field 3:
CMNT
3rd dimension attributes:
CMNT
CMNT
NPOINTS -- number of elements (size) in 3rd dimension
CMNT
UNITS
-- units of measure for 3rd dimension
CMNT

R2003.12.1

ModelBuilder

88

Landmark Graphics Corporation

User Programming

CMNT
Field 4: Value for the above attributes.
CMNT
CMNT It is best to include these lines right after the LOGS entry. An
CMNT example of using a combination of LOGS and LATT is described below.
CMNT For readability purposes the fields are spaced out.
CMNT
CMNT|-----------------+-+-----------+-+----------------------------------------+
CMNT|
| |
| |
|
CMNT|
|I|
| |
|
CMNT| CURVE NAME
|O|
UNITS
| |
DESCRIPTION
|
CMNT|
| |
| |
|
CMNT|-----------------+-+-----------+-+----------------------------------------+
LOGS|Neutron_Porosity |I|v/v decimal| |Limestone neutron porosity
|
LATT|Neutron_Porosity
| TITLE
|Limestone\n neutron\n porosity
|
LATT|Neutron_Porosity
| DESCRIPTION |Total porosity. Output is in decimal
|
CMNT|-----------------+-+-----------+-+----------------------------------------|
LOGS|FWA
|I|unitless
| |Full wave
|
LATT|FWA
| TITLE
|Full Wave
|
LATT|FWA
| DIMENSION2 |NPOINTS
| 1026
|
LATT|FWA
| DIMENSION2 |UNITS
| unitless
|
CMNT|-----------------+-+-----------+-+----------------------------------------|
LOGS|BITMAP
|O|unitless
| |a 200-400 bit map
|
LATT|BITMAP | TITLE
|Bit Map
|
LATT|BITMAP | DIMENSION2|NPOINTS
| 200
|
LATT|BITMAP | DIMENSION2 |UNITS
| unitless
|
LATT|BITMAP | DIMENSION3 |NPOINTS
| 400
|
LATT|BITMAP | DIMENSION3 |UNITS
| unitless
|
CMNT|-----------------+-+-----------+-+----------------------------------------|
LOGS|RHOB
|O|g/cm3
| |Bulk density
|
LATT|RHOB
| TITLE
|Bulk\n Density
|
LATT|RHOB
| OFRAMEWORK | 2
|
CMNT|-----------------+-+-----------+-+----------------------------------------+
CMNT
CMNT
CMNT <<OPTNLIST>> OPTIONAL CURVES
CMNT
CMNT OPTNLIST is the list of curves that are not required for running
CMNT the model.
CMNT
CMNT Example:
OPTNLIST,RHOB,CDE
CMNT
CMNT
CMNT-----------------------------------------------------------------CMNT <<GRPN>>
DEFINITION OF GROUP NAMES
CMNT
CMNT Group names are optional. If GRPN specification is omitted,
CMNT inclusion of group-id field in CNST definition is not required.
CMNT The parameter is included in the DEFAULT_GROUP. However, if a
CMNT group is defined, the group-id field must be included in the
CMNT definition of the pertinent parameters.
CMNT
CMNT If a group is not assigned to a particular parameter, it will not
CMNT be created in the database.
CMNT
CMNT Field 1 - NAME:
CMNT Descriptive names used by the database to group a set of parameters.
CMNT The maximum length of a group name is 40 characters. Group names
CMNT are case sensitive. Alphanumeric characters, including underscores
CMNT are permitted in names; reserved FORTRAN operators such as &, +,
CMNT /, and * are not permitted. You can build models with these
CMNT characters, but the models will not run.
CMNT
CMNT Field 2 - ID-CODE:
CMNT Code which is used by parameters for identifying groups to which
CMNT parameters will assigned. (See CNST below.)
CMNT
CMNT Field 3 - TITLE:
CMNT Descriptive text that can be used in reports and by the parameter
CMNT as column headers. Linefeeds ("\n") can be included in the text.
CMNT The maximum length of a title is 40 characters. If no title is

R2003.12.1

ModelBuilder: Model Data Specification Template with Keywords

89

Landmark

New Features For PetroWorks

CMNT specified, the name will be used.


CMNT
CMNT Example:
CMNT|---------+--+------------------+
CMNT| NAME
|ID| TITLE
|
CMNT|---------+--+------------------|
GRPN|SETUP
| 1| Initial\nSetup
|
GRPN|ClayShale| 2| Clay\nShale
|
GRPN|Minerals | 3| Minerals
|
CMNT|---------+--+------------------+
CMNT
CMNT
CMNT-----------------------------------------------------------------CMNT <<CHKA>>
CHECK ACTION
CMNT
CMNT If during runtime, a parameter value is outside the range of the
CMNT definition, you may specify which action is to be taken for this
CMNT particular parameter.
CMNT
CMNT Available actions:
CMNT
ALLOW
Allow the value to be used
CMNT
CLIP
Clip the value using minimum or maximum
CMNT
DEFAULT
Use the default value defined in the mds file
CMNT
NULL
Use a null value.
CMNT
CMNT If a check action is not defined, the default value as defined
CMNT in the mds file or shared definition is used.
CMNT
CMNT Example:
CHKA=ALLOW
CMNT
CMNT-----------------------------------------------------------------CMNT <<CNST>>
DEFINITION OF CONSTANTS (parameters)
CMNT
CMNT Field 1 - NAME:
CMNT Name used in the model for this parameter. The maximum length
CMNT of a parameter is 28 characters. A unique parameter name is
CMNT saved in the database, prefixed with the model name and an
CMNT underscore. This insures that a value for the same name used by
CMNT another model is not overridden. (Also see description of
CMNT SHARED PARAMETERS (CREF) below.) If a title is not specified using
CMNT parameter attributes (see CATT below), the name is used for
CMNT the title.
CMNT
CMNT Note: parameter names ARE case sensitive. However, the parameter
CMNT variable names in Fortran are not. This means that you can specify
CMNT a parameter "Parm1" and the database will create a "Parm1" which is
CMNT different from an existing parameter "parm1". However, because of the
CMNT Fortran limitations, you cannot specify two parameters, "parm1" and
CMNT "Parm1" in the same model.
CMNT
CMNT Field 2 - DEFAULT:
CMNT Original value of parameter when first created or if value in
CMNT database has gone out of range. If this field is left blank
CMNT it will be set to null.
CMNT
CMNT Field 3 - TYPE:
CMNT With this present implementation, only input parameters are
CMNT allowed.
CMNT
CMNT Field 4 - MINIMUM:
CMNT Minimum value of parameter allowed. If this field is left blank
CMNT it will be set to null, therefore no lower limit is checked.
CMNT
CMNT Field 5 - MAXIMUM:
CMNT Maximum value of parameter allowed. If this field is left blank
CMNT it will be set to null, therefore no upper limit is checked.
CMNT
CMNT Field 6 - UNIT:
CMNT Parameter unit expected by the model. If the measurement system being
CMNT run is different from the measurement system containing the specified

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:

R2003.12.1

ModelBuilder: Model Data Specification Template with Keywords

91

Landmark

New Features For PetroWorks

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

R2003.12.1

ModelBuilder: Model Data Specification Template with Keywords

93

Landmark

New Features For PetroWorks

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

Vertical Curve Gradient (page 99)

Three-Point Filter with User Weights (page 102)

Check Processing Flags (page 104)

Reconfiguring Curve Selection During Runtime (page 106)

Create 2D Output Curve (page 108)

Check 2D Log Curve (page 109)

Dynamically Redefine Dimensions for Output Curves (page 111)

Multi-Valued Log Curves (page 114)

Explicit Input Framework Based on User-Specified Reference


Curve (page 118)

Explicit Input Framework Based on User-Specified Increment


(page 119)

ModelBuilder: Example Models

95

Landmark

New Features For PetroWorks

Vertical Curve Gradient


Vertical Curve Gradient is a simple but useful model that uses

multiple depth levels


absent value handling
model defined processing direction control

Gradient .mds File


C ==========Gradient.mds==============
CMNT
CMNT
CMNT
CMNT
VERS=1.0
CMNT|--------+-+-----------+--+------------------------------------+
CMNT|
| |
|T |
|
CMNT|
| |
|Y |
|
CMNT| CURVE | |
|P |
|
CMNT| NAME |T|UNITS
|E |
DESCRIPTION
|
CMNT|--------+-+-----------+--+------------------------------------+
LOGS|Cali
|I|inches
| | Input Log
|
LOGS|Gradient|O|
| | Vertical Gradient of the IP Log
|
LOGS|AbsGradient|O|
| | Absolute Value of the Gradient
|
CMNT|--------+-+-----------+--+------------------------------------+
CMNT|
CMNT|--------------------CMNT|NUM| NAME VARIABLE |
CMNT|--------------------ISMO|2| OUTPUT_INDEX
|
NSMI|2| NUM_SAMPLES_IN |
CMNT|--------------------NSMO=1
CMNT
$EOF

R2003.12.1

ModelBuilder

96

Landmark Graphics Corporation

User Programming

Gradient .mdl File


C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C
C

PROGRAM Gradient
=========Gradient.mdl=========================
This program calculates a vertical gradient of a Log Curve (curve value
at a depth minus the curve value at the next deeper depth). The convention
is that a positive gradient means the log value got larger as the depth
decreased.
The most typical application of a vertical curve gradient is to use a
CALIPER gradient as a bad hole indicator, i.e. rapid changes in hole
diameter cannot be followed by pad devices as well as gradual changes
can.
We want to run the computation bottom up, since that is the same direction
the logging tool went. Therefore, we specified the direction in the .mds
by setting PZDR=UP.
We will be reading curve data two depth samples at a time as indicated
by NSMI = 2 in the .mds file.
We want to output our gradient at the upper depth of the two depths,
which we read two at a time. Therefore we define that array access in the
.mds file by setting ISMO = 2 to be the OUTPUT_INDEX.
The Variable PREV_INDEX is an integer which will refer to a curve value
at a deeper depth index than the calculation index.
INTEGER PREV_INDEX
PREV_INDEX = OUTPUT_INDEX - 1

C
C
C
C
C
C

!!!!! Very important - Handling ABSENT or NULL values !!!!!


We need to check both input curve values to see if they are absent (null)
values. If they are absent, we want the output curve to be absent.
If we omit this step, whatever value that is used as a NULL value will be
used in the calculation when a NULL value occurs in a log curve.
IF ((Cali(OUTPUT_INDEX) .NE. ABSENT) .AND.
; (Cali(PREV_INDEX) .NE. ABSENT)) THEN

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:
Gradient(OUTPUT_INDEX) = Cali(OUTPUT_INDEX) - Cali(PREV_INDEX)
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
R2003.12.1

ModelBuilder: Example Models

97

Landmark

100

New Features For PetroWorks

ENDIF
CONTINUE

END

R2003.12.1

ModelBuilder

98

Landmark Graphics Corporation

User Programming

Three-Point Filter with User Weights


This Three-Point Filter with User Weights model uses

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.

Filter3Pt .mds File


CMNT|=========Filter3Pt.mds=========================
VERS=1.0
CMNT|=======================================================================+
CMNT| ----- LOG CURVE DEFINITIONS ----CMNT|
CMNT|-------------------------+-+-----------+--+----------------------------+
CMNT|
| |
|T |
|
CMNT|
| |
|Y |
|
CMNT|
CURVE
| |
|P |
|
CMNT|
NAME
|T|
UNITS
|E |
DESCRIPTION
|
CMNT|-------------------------+-+-----------+--+----------------------------+
LOGS|GR
|I|
| |
|
LOGS|GR_FILTERED
|O|
| |
|
CMNT|
| |
| |
|
CMNT|-------------------------+-+-----------+--+----------------------------+
CMNT
CMNT|-------------------------+-+-------------+
CMNT|Name
|Group ID| Title
|
GRPN|Filter_Weights | 1
| Filter Weights |
CMNT|-------------------------+-+-------------+
CMNT
CMNT|------+---------+---+-----+-----+-----+------------+----------+
CMNT| Name | Default | T | Min | Max |Unit| Description | Group ID |
CMNT|------+---------+---+-----+-----+-----+------------+----------+
CNST|W_P1 | .5
| I | 0.0 | 1.0 | | Weight of Previous Depth Sample | 1 |
CNST|W__0 | 1.0 | I | 0.0 | 1.0 | | Weight of Middle Depth Sample | 1 |
CNST|W_N1 | .5 | I | 0.0 | 1.0 | | Weight of Next Depth Sample | 1 |
CMNT|------+---------+---+-----+-----+-----+------------+----------+
R2003.12.1

ModelBuilder: Example Models

99

Landmark

New Features For PetroWorks

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

Filter3Pt .mdl File


PROGRAM Filter3Pt
C =========Filter3Pt.mdl=========================
C Simple three point vertical averaging program that uses parameter values
C as weights for the vertical filter levels
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
C If any curve is NULL ( absent)
C

set the output to be NULL

GR_FILTERED(OutputIndex) = ABSENT
ELSE
C
C
C
C

Otherwise filter the curve, multiplying each level by C it's user set
weight, add them up, and divide by the sum of the weights.
================ CAUTION!!! ===============
If the sum of the weights is zero, division by zero will occur!!
GR_FILTERED(OutputIndex)=(GR(1)*W_P1
; /(W_P1 + W__0 + W_N1)

+ GR(2)*W__0

+ GR(3)*W_N1)

ENDIF
END

R2003.12.1

ModelBuilder

100

Landmark Graphics Corporation

User Programming

Check Processing Flags


This example checks and sets processing flags.

Check Any Depth Flag .mds File


TITL| Check any depth flag |
CMNT
CMNT
CMNT|-----------------+-+----------------------------+
CMNT|
| |
|T|
|
CMNT| CURVE|I|
|Y|
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
CMNT|------|-|--------|-|----------------------------|
LOGS|GR
|I|
|0| any input curve
|
LOGS|LOGO |O|
|0| calculate based on input
|
CMNT|------+-+--------+-+----------------------------+
CMNT|------+------------+---------+------------------+
CNST|ENDMDLDEP |11900.00 |I| 0.0
|12000.00 | |Depth to end model| |
CNST|ENDZONDEP |11700.00 |I| 0.0
|12000.00 | |Depth to end zone | |
CNST|ABTMDLDEP |11850.00 |I| 0.0
|12000.00 | |Depth to abort model| |
CMNT
CMNT
$EOF

Check Any Depth Flag .mdl File


PROGRAM Check_flags
C
C
Check an output 2D log
C
INTEGER I,J
character txt*80
C

Initialize counter
txt = " "
if (md_mdlint) then
write (txt,'(a,i2)') "model initializing",MD_MDLINT
call model_message(txt)
endif
txt = " "
if (md_wellint) then
write (txt,'(a,i2,2x,a)') "well initializing",MD_MDLINT,
&
MD_WELL_NAME(1:20)
call model_message(txt)
endif
txt = " "
if (md_zonint) then
write (txt,'(a,i2)') "zone initializing",MD_ZONINT

R2003.12.1

ModelBuilder: Example Models

101

Landmark

New Features For PetroWorks

call model_message(txt)
endif
C

last sample
txt = " "
if (md_lstmdl) then
write (txt,'(a,i2)') "last sample for model",MD_lstmdl
call model_message(txt)
endif
txt = " "
if (md_lstwell) then
write (txt,'(a,i2)') "last sample for well",MD_lstwell
call model_message(txt)
endif
txt = " "
if (md_lstzon) then
write (txt,'(a,i2)') "last sample for zone",MD_lstzon
call model_message(txt)
endif
txt = " "
if (md_depth.eq.endmdldep) then
write (txt,'(a,f10.2)') "ending model at ",md_depth
call model_message(txt)
MD_MDLEND = .TRUE.
endif
txt = " "
if (md_depth.eq.endzondep) then
write (txt,'(a,f10.2)') "ending zone at ",md_depth
MD_ZONEND = .TRUE.
call model_message(txt)
endif
txt = " "
if (md_depth.eq.abtmdldep) then
write (txt,'(a,f10.2)') "aborting model at ",md_depth
call model_message(txt)
MD_MDLABORT = .TRUE.
endif
LOGO = GR
END

R2003.12.1

ModelBuilder

102

Landmark Graphics Corporation

User Programming

Reconfiguring Curve Selection During Runtime


This example turns curves on and off during processing.

Checking Curve Reconfiguration Flags .mds File


TITL| Checking Curve Reconfiguration Flags |
CMNT
CMNT|-----------------+-+----------------------------+----------------+
CMNT|
| |
|T|
| SPECIAL
|
CMNT| CURVE|I|
|Y|
| PROCESS
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
FIELD
|
CMNT|------|-|--------|-|----------------------------|----------------|
LOGS|LOG1 |I|
|0| Input log
|
|
LOGS|LOGO |O|
|0| Output log
|
|
CMNT|------+-+--------+-+----------------------------+----------------+
CMNT
GRPN|TSTMDL| 1 | Depth Settings |
CMNT|------+---------+-+---------+--------+--+-------------+---+----------+
CMNT| NAME |DEFAULT |T| MIN
| MAX
|UN|DESCRIPTION |GRP|DEFINITION|
CMNT|
|
|Y|
|
|IT|
|IDS|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+----------|
CNST|IDEPTH_OFF| 11570.0 |I| 0.0 |20000.0 | |Input Depth | 1 |
|
CNST|IDEPTH_ON | 11574.0 |I| 0.0 |20000.0 | |Input Depth | 1 |
|
CNST|ODEPTH_OFF| 11582.0 |I| 0.0 |20000.0 | |Output Depth | 1 |
|
CNST|ODEPTH_ON | 11586.0 |I| 0.0 |20000.0 | |Output Depth | 1 |
|
CMNT|------+---------+-+---------+--------+--+-------------+---+----------+
CMNT
$EOF

Checking Curve Reconfiguration Flags .mdl File


PROGRAM Check_set_io
CHARACTER*80 TXT
C

Calculate LOGO before reconfiguring curve flags


IF (MD_XLSELI(1).EQ.0.OR.LOG1.EQ.ABSENT) THEN
LOGO = ABSENT
ELSE
LOGO= LOG1 + 1
ENDIF
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

R2003.12.1

ModelBuilder: Example Models

103

Landmark

New Features For PetroWorks

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
Make sure that unreal values are set to ABSENT
LOG1 = ABSENT
END

R2003.12.1

ModelBuilder

104

Landmark Graphics Corporation

User Programming

Create 2D Output Curve


This example illustrates how to create a two dimensional output curve.

Create 2D Log .mds File


TITL| Create 2D log |
CMNT
CMNT
CMNT|-----------------+-+----------------------------+
CMNT|
| |
|T|
|
CMNT| CURVE|I|
|Y|
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
CMNT|------|-|--------|-|----------------------------|
LOGS|GR
|I|
|0| Gamma ray
|
LOGS|LOG2X |O|
|0| Output 2D log
|
CMNT|------+-+--------+-+----------------------------+
CMNT|------+------------+---------+------------------+
LATT|LOG2X | DIMENSION2 | NPOINTS |
20
|
CMNT|------+------------+---------+------------------+
CMNT
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT| NAME |DEFAULT |T| MIN
| MAX
|UN|DESCRIPTION |GRP| DEFINITION|
CMNT|
|
|Y|
|
|IT|
|IDS|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------|
CNST|INCR | 1.0
|I| 1.0
|1000.0 | |Increment
|
|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT
$EOF

Create 2D Log .mdl File


C
C

PROGRAM CREATE_2D
Create 2D log
INTEGER I,J
SAVE I
character txt*80

Initialize counter
IF (MD_MDLINT) THEN
I = 0
ENDIF

C---- Set new value and increment counter


DO 10 J = 1,MD_CURVE_2ND_NPOINTS(2)
LOG2X(J) = I + INCR + J
10
CONTINUE
I=I+1
END
R2003.12.1

ModelBuilder: Example Models

105

Landmark

New Features For PetroWorks

Check 2D Log Curve


This example reads a 2D input curve and creates two output
dimensional curves.

Check 2D Log .mds File


TITL| Check 2D log |
CMNT
CMNT
CMNT|-------------------+-+----------------------------+
CMNT|
| |
|T|
|
CMNT| CURVE |I|
|Y|
|
CMNT| NAME
|O| UNITS |P|
DESCRIPTION
|
CMNT|--------|-|--------|-|----------------------------|
LOGS|LOG2X
|I|
|0| Input 2D log
|
LOGS|LOG2F
|O|
|0| Output 2D log
|
LOGS|CHECK_SM|O|
|0| Check sum for LOG2D
|
LOGS|LOG2G
|O|
|0| Output 2D log
|
LOGS|LOG2X_1 |O|
|0| Check sum for LOG2D
|
CMNT|--------+-+--------+-+----------------------------+
CMNT|------+------------+---------+------------------+
LATT|LOG2X | DIMENSION2 | NPOINTS |
20
|
LATT|LOG2F | DIMENSION2 | NPOINTS |
20
|
LATT|LOG2G | DIMENSION2 | NPOINTS |
35
|
CMNT|------+------------+---------+------------------+
CMNT
GRPN| INCREMENT | 1 | Add\n Increment |
CMNT|------+---------+-+---------+--------+--+-------------+---+
CMNT| NAME |DEFAULT |T| MIN
| MAX
|UN|DESCRIPTION |GRP|
CMNT|
|
|Y|
|
|IT|
|IDS|
CMNT|------+---------+-+---------+--------+--+-------------+---+
CNST|INCR | 1.0
|I| 1.0
|1000.0 | |Increment
|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+
CMNT
$EOF

R2003.12.1

ModelBuilder

106

Landmark Graphics Corporation

User Programming

Check 2D Log .mdl File


PROGRAM CHECK_2D
C
C
C

Check an output 2D log


INTEGER I,J
CHARACTER TXT*80

SAVE I
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
C---- This part demonstrates how a 2nd Dimension can be created
LOG2G(1) = I
DO 20 J = 2,MD_CURVE_2ND_NPOINTS(LDX_LOG2G)
LOG2G(J) = LOG2G(J-1) + J + INCR
20
CONTINUE
I = I+1
END

R2003.12.1

ModelBuilder: Example Models

107

Landmark

New Features For PetroWorks

Dynamically Redefine Dimensions for Output Curves


This example reads a file to determine the dimension of the new output
curve. A maximum size has to be specified in the.mds file.

Dynamic 2D Log .mds File


TITL| Dynamic 2D log |
CMNT
CMNT
CMNT|-----------------+-+----------------------------+
CMNT|
| |
|T|
|
CMNT| CURVE|I|
|Y|
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
CMNT|------|-|--------|-|----------------------------|
LOGS|LOG2X |I|
|0| Input 2D log
|
LOGS|LOG2F |O|
|0| Output 2D log
|
LOGS|LOG2F_1|O|
|0| SUM curve|
LOGS|CHECK_SM |O|
|0| Check sum for LOG2D
|
CMNT|------+-+--------+-+----------------------------+
CMNT|------+------------+---------+------------------+
LATT|LOG2X | DIMENSION2 | NPOINTS |
50
|
LATT|LOG2F | DIMENSION2 | NPOINTS |
20
|
CMNT|------+------------+---------+------------------+
CMNT
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT| NAME |DEFAULT |T| MIN
| MAX
|UN|DESCRIPTION |GRP| DEFINITION|
CMNT|
|
|Y|
|
|IT|
|IDS|
|
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------|
CNST|INCR | 1.0
|I| 1.0
|1000.0 | |Increment
|
|
|
CNST|USER_DIM | 20
|I| 1.0
| 20.0 | |User entered dimension | | |
CMNT|------+---------+-+---------+--------+--+-------------+---+-----------+
CMNT
$EOF

R2003.12.1

ModelBuilder

108

Landmark Graphics Corporation

User Programming

Dynamic 2D Log .mdl File


PROGRAM DYNAMIC_2D
C
C
C

Dynamically redefine size


INTEGER I,J,IER
INTEGER NDIM
CHARACTER TXT*80
INTEGER MAXDIM
PARAMETER (MAXDIM = 15)
CHARACTER MSG*50
DATA MSG/"USER_DIM must be assigned a value of 1 to 15"/

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

FIND MINIMUM NUMBER OF VALUES TO COPY


MD_CURVE_2ND_NPOINTS(LDX_LOG2F) = NINT(USER_DIM)
NDIM = MIN(MD_CURVE_2ND_NPOINTS(LDX_LOG2X),
MD_CURVE_2ND_DB_NPOINTS(LDX_LOG2X),
MD_CURVE_2ND_NPOINTS(LDX_LOG2F))

&
&
C

INITIALIZE ARRAY
DO 5 I=1,MD_CURVE_2ND_NPOINTS(LDX_LOG2F)
LOG2F(I) = ABSENT

&
&
&

TXT = " "


MD_CURVE_2ND_NPOINTS(LDX_LOG2X)
CALL MODEL_MESSAGE(TXT)
MD_CURVE_2ND_DB_NPOINTS(LDX_LOG2X)
CALL MODEL_MESSAGE(TXT)
MD_CURVE_2ND_NPOINTS(LDX_LOG2F)
CALL MODEL_MESSAGE(TXT)
ENDIF
CHECK_SM = 0.0

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

R2003.12.1

ModelBuilder: Example Models

109

Landmark

New Features For PetroWorks

END

R2003.12.1

ModelBuilder

110

Landmark Graphics Corporation

User Programming

Multi-Valued Log Curves


The following two examples create 2-D and 3-D output curves. Note
that you cannot verify the 3-D model output with any PetroWorks/
OpenWorks tools. Well Data Manager does show the minimum and
maximum values and whether the curve is properly dimensioned. You
can view the 2-D curve in both CrossPlot and Single Well Viewer by
setting up a Multi-Value Log Curve track in Well Template Editor.
The 2-D example creates three 2-D output curves, FMVLC1,
FMVLC2, FMVLC3, and one check curve, FI. Each curve has 500
array elements that are defined in the .mds file.
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 second curve, FMVLC2, decays exponentially from 1 with a time
constant assigned from TC. The default is 1. Modifying the TC
parameter affects how quickly this parameter decays. The larger the
number, the longer it takes the curve to decay to nearly zero. When
plotted on a logarithmic grid, this curve shows a linear decay.
The last curve, FMVLC3, has sinusoidal values from +/-SINE_MAX.
Modifying the SINE_MAX parameter directly controls the maximum
value of the curve.
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.

R2003.12.1

ModelBuilder: Example Models

111

Landmark

New Features For PetroWorks

MVLC_2D .mds File


CMNT-------------------------------------------------------------CMNT
CMNT MODEL SPECIFICATION FILE - 2-D Multi-Valued Log Curve Routine
CMNT
VERS=1.00
CMNT
CMNT|------+-+-----+--+---------------------------+
CMNT|
| |
|T |
|
CMNT|
| |
|Y |
|
CMNT| CURVE| |
|P |
|
CMNT| NAME|T|UNITS|E |
DESCRIPTION
|
CMNT|------+-+-----+--+---------------------------+
LOGS|GR
|I|
| 0|Input curve for Framework |
LOGS|FMVLC1|O|
| 0|Linear MVLC
|
LOGS|FMVLC2|O|
| 0|Linear MVLC
|
LOGS|FMVLC3|O|
| 0|Sinusoidal MVLC
|
LOGS|FI
|O|
| 0|Float(i)
|
CMNT|------+-+-----+--+---------------------------+
CMNT
CMNT|------+----------+---------------+-----------+
LATT|FMVLC1|DIMENSION2| NPOINTS
|
500
|
LATT|FMVLC2|DIMENSION2| NPOINTS
|
500
|
LATT|FMVLC3|DIMENSION2| NPOINTS
|
500
|
LATT|FI
|DIMENSION2| NPOINTS
|
500
|
CMNT|------+----------+---------------+-----------+
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

R2003.12.1

ModelBuilder

112

Landmark Graphics Corporation

User Programming

MVLC_2D .mdl File


PROGRAM MVLC_2D

C
C
C
C

INTEGER i,j
REAL TPI, RADC, RFMVLC2
----- Beginning Program MVLC_2D ----This will create a set of 2-D Multi-Valued Log Curves
that can be read by the PetroWorks 1998.5 Data Model.
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
----- Ending PROGRAM MVLC_2D ----END

MVLC_3D .mds File


CMNT-------------------------------------------------------------CMNT
CMNT MODEL SPECIFICATION FILE - 3-D MultiValue Log Curve Routine
CMNT
VERS=1.00
CMNT
CMNT|------+-+-----+--+---------------------------+
CMNT|
| |
|T |
|
CMNT|
| |
|Y |
|
CMNT| CURVE| |
|P |
|
CMNT| NAME|T|UNITS|E |
DESCRIPTION
|
CMNT|------+-+-----+--+---------------------------+
LOGS|GR
|I|
| 0|Reference Curve for Framework|
LOGS|MVL3D1|O|
| 0|Linear 3-D MVLC
|
LOGS|MVL3D2|O|
| 0|Exponential Decay 3-D MVLC |
LOGS|MVL3D3|O|
| 0|Sinusoidal 3-D MVLC
|
LOGS|FI
|O|
| 0|Float(i)
|
CMNT|------+-+-----+--+---------------------------+
CMNT
CMNT|------+----------+---------------+-----------+
LATT|MVL3D1|DIMENSION2| NPOINTS
|
50
|
LATT|MVL3D2|DIMENSION2| NPOINTS
|
50
|
LATT|MVL3D3|DIMENSION2| NPOINTS
|
50
|
LATT|FI
|DIMENSION2| NPOINTS
|
50
|
CMNT|------+----------+---------------+-----------+
CMNT
CMNT|------+----------+---------------+-----------+
LATT|MVL3D1|DIMENSION3| NPOINTS
|
5
|
R2003.12.1

ModelBuilder: Example Models

113

Landmark

New Features For PetroWorks

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

MVLC_3D .mdl File


PROGRAM MVLC_3D

C
C
C
C

INTEGER i,j
REAL TPI, RADC, RFMVLC2
----- Beginning Program MVLC ----This will create a set of 3-D Multi-Valued Log Curves
that can be read by the PetroWorks 1998.5 Data Model.
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
----- Ending PROGRAM MVLC
----END

R2003.12.1

ModelBuilder

114

Landmark Graphics Corporation

User Programming

Explicit Input Framework Based on User-Specified Reference Curve


Simple output curve calculations based on a user specified reference
curve framework:

Check Input Framework - Reference Curve .mds File


CMNT
TITL| Check Input Framework - Reference Curve
CMNT
CMNT|-----------------+-+----------------------------+----------------+
CMNT|
| |
|T|
| SPECIAL
|
CMNT| CURVE|I|
|Y|
| PROCESS
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
FIELD
|
CMNT|------|-|--------|-|----------------------------|----------------|
LOGS|GR
|I| API
|0| input curve
|
|
LOGS|GR_OUT |O| API
|0| output curve
|
|
CMNT|------|-|--------|-|----------------------------|----------------|
CMNT
IFRAMEWORK| ALL | USER | REFERENCE | LOG40 |
CMNT
CMNT
$EOF

Check Input Framework - Reference Curve .mdl File


PROGRAM CHECK_IFRAME_REFERENCE_CURVE
C

C
C

&

&

CHARACTER*80 TEXT
integer lastch
external lastch
Increment gamma ray by 1
IF (MD_MDLINT) THEN
TEXT = " "
'Model mds input framework reference curve',
&
MDS_REF_CURVE_NAME(1)(1:lastch(MDS_REF_CURVE_NAME(1)))
CALL MODEL_MESSAGE(TEXT)
MD_FRAME_REF_NAME(1)(1:lastch(MD_FRAME_REF_NAME(1))),
&
MD_FRAME_REQD_REF(1),MD_FRAME_REF_ID(1),
&
MD_FRAME_INCREMENT(1)
CALL MODEL_MESSAGE(TEXT)
ENDIF
IF (INT(GR).NE.INT(ABSENT)) THEN
GR_OUT = GR+1.0
ELSE
GR_OUT = ABSENT
ENDIF
END

R2003.12.1

ModelBuilder: Example Models

115

Landmark

New Features For PetroWorks

Explicit Input Framework Based on User-Specified Increment


Simple output curve calculations based on a user specified increment
framework:

Check Input Framework - Explicit Increment .mdsFile


CMNT
TITL| Check Input Framework - Explicit increment
GRPN|INCREMENT| 1 | Processing Sample Rate |
CMNT
CMNT|-----------------+-+----------------------------+----------------+
CMNT|
| |
|T|
| SPECIAL
|
CMNT| CURVE|I|
|Y|
| PROCESS
|
CMNT| NAME |O| UNITS |P|
DESCRIPTION
|
FIELD
|
CMNT|------|-|--------|-|----------------------------|----------------|
LOGS|GR
|I| API
|0| input curve
|
|
LOGS|GR_OUT|O| API
|0| output curve
|
|
CMNT|------|-|--------|-|----------------------------|----------------|
CMNT
CMNT|--------+----+-+---+---+------+----------------+---+-----------+
CMNT| NAME
|DEF |T|MIN|MAX|UNITS |DESCRIPTION
|GRP| DEFINITION|
CMNT|
|
|Y|
|
|
|
|IDS|
|
CMNT|--------+----+-+---+---+------+----------------+---+-----------+
CNST|PARM_INC|0.61|I|
|
|
|Frame Increment | 1 |
|
CMNT|--------+----+-+---+---+------+----------------+---+-----------+
CMNT
IFRAMEWORK| ALL | USER | INCREMENT | PARM_INC |
CMNT
CMNT
$EOF

Check Input Framework - Explicit Increment .mdl File


PROGRAM CHECK_IFRAME_INCREMENT
C
CHARACTER*80 TEXT
C
Increment gamma ray by 1
C
IF (INT(GR).NE.INT(ABSENT)) THEN
GR_OUT = GR+1.0
ELSE
GR_OUT = ABSENT
ENDIF
END

R2003.12.1

ModelBuilder

116

Landmark Graphics Corporation

User Programming

Recommended Reading
You may find the following resources helpful.
Metcalf, M., Effective FORTRAN 77, 256 pp., Oxford University Press,
1985 (out of print).
Press, W. H. , S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery,
Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd
ed., 963 pp., Cambridge University Press, 1992.

R2003.12.1

ModelBuilder: Recommended Reading

117

Landmark Graphics Corporation

User Programming

Building Algorithms with MathPack

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 prepackaged algorithms may not meet your specific needs.
MathPack provides an easy way for you to quickly create the
algorithms that will meet your needs in specific interpretive situations.
Remember that if you have very complex processing needs
(simultaneously accessing multiple depths, complex looping and
branching, or creating a process that can be securely distributed to
colleagues), you should also consider ModelBuilder as another
application in which to build your algorithms.

About this Version of MathPack


This version of PetroWorks introduces a MathPack which has been
extensively reworked. While the interface is almost identical to older
MathPack versions, the underlying implementation that processes your
algorithms is new. MathPacks purpose is still to provide you with an
easy method to enter and execute algorithms, but now it takes
advantage of the richness of the OpenWorks data model when
retrieving data and when writing new data back to OpenWorks.
This documentation not only shows you how to use MathPack, but also
details all the features of the interface and the underlying functionality.

R2003.12.1

Building Algorithms with MathPack: Overview

121

Reports and Utilities

Landmark

MathPack Features

122

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.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

MathPack Workflow

Open MathPack
Interpret > MathPack

Select one or more wells from the Wells list.


Press Apply Well Selections.

Select the interval(s) over which you want to process:


Total Depth Range, or Depth Interval, or Unit Selections.

Type your algorithm in the Algorthm text box, or


Open an existing algorithm (File > Open Algorithm...), or
Select a symbolic equation (Tools > Select Symbolic Equations...)

Optionally, you can Output Petrophysical Parameters as Curves.

Check Syntax and modify your algorithms as necessary.

If you have used any Global Parameters in your algorithms, go to


Utilities > Wellbore Parameter Editor, then chose
Applications: Global Parameters
to set or check the parameter values.

Click Process to process the chosen wells over the interval(s).

Close MathPack

R2003.12.1

Building Algorithms with MathPack: Overview

123

Reports and Utilities

Landmark

Opening and Closing MathPack


To Open MathPack
1.

From the PetroWorks Command Menu, select


Interpret > MathPack.

2.

The MathPack main window appears.

3.

Follow the workflow on the previous page, or the more detailed


instructions in the following sections of the documentation, to
create and execute an algorithm.

To Close MathPack

124

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.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

How Do I Use MathPack?


There are two parts to using MathPack:

Creating an algorithm (or restoring one from a .mathpack file or


from the Symbolic Equations list);
Running that algorithm against intervals in wells.

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.

Here is an example taken from the A simple example section. The


section shows several different ways to create the same equation, and
you might want to visit that section before continuing here.
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;

R2003.12.1

Building Algorithms with MathPack: How Do I Use MathPack?

125

Reports and Utilities

Landmark

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.

Running the Algorithm


1.

In the Well Selection window, pick the wells that you want to
process. You can use a combination of the Select All (Select None)
button and mouse clicks to select the wells.

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.

3.

Select the interval over which you want to process.


You can process the wells over the interval of valid data in each
well by clicking the Total Depth Range radio button, or
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
You can process over one or more named intervals (StratUnits) by
clicking on the Unit Selections radio button and selecting the
intervals that you want.

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.

5.

Press the Process button. MathPack re-evaluates the algorithm and


provides information about the processing via a pop-up window
and text in the Status Area.

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.
126

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

MathPack Window Descriptions


MathPack Main Window

Main Menu

Interval and
Sample Framework Selection

Well Selection

Divider/ Sash
Button

Algorithm Field

Status Area

MathPack Main Window Components

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.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

127

Reports and Utilities

Landmark

--- 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... opens a window that allows you to select and


existing algorithm file (<filename>.mathpack). See Open
Algorithm window for details of the window and its use.
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 previouslyselected 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

128

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

will automatically be appended with a suffix of .mathpack. See


Save Algorithm Window for details of the window and its use.
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.
Copy copies highlighted text in the Algorithm Field in preparation for
pasting the text in another part of the field or in the Symbolic
Equations window.
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.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

129

Reports and Utilities

Landmark

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.
Automatic is the default option for curve history.
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.
Select Wellbore Parameters... opens the Parameter Selection
window. You can insert Global Parameters into your algorithm from
this window instead of typing directly in the Algorithm Field. See the
Parameter 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.

Select Algorithmic Elements... opens the Algorithmic Elements


window. You can insert algorithmic elements into your algorithm from
this window instead of typing directly in the Algorithm Field. See the
Algorithm Elements Window section of this documentation for more
details.
Select Symbolic Equations... opens the Symbolic Equations window.
Symbolic equations are one-line algorithms that can be used exactly
like .mathpack files. These algorithms can be inserted directly into
the Algorithm Field at the current location of the cursor. See the
Symbolic Equations Window section of this documentation for more
details.
130

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

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.
There are several ways to select wells on the list:

You can single click on individual wells to select one or more.


You can click the Select All button to select all the wells in the list.
(The button then becomes Select None.) If you have selected all
the wells, you can then single click on individual selected wells to
de-select or re-select them.

You can click on the Select None button (which then becomes
Select All).
The display at the bottom of the well list shows how many wells have
been selected out of the total number of wells in the well list.

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.
Press the Apply Well Selections button
You MUST press the Apply Well Selections button AFTER you have selected the
wells that you want to process, and BEFORE you make any Unit Selections, for
the algorithms to process properly.

Interval and Sample Framework Selection


Total Depth Range processes the algorithms over the entire depth of
each well that is selected.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

131

Reports and Utilities

Landmark

Depth Interval processes the algorithms over a common depth range


for all wells that are selected, from Top Depth to Bottom Depth.
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#>
If no geofeature has been assigned, <geofeature> will be
shown as UNKNOWN.
<occurence#> will be blank unless there are multiple
occurences.
Set Sample Increment has two options:

Follow Framework Rules will create a common data framework


from the frameworks of the individual curves. This setting will
honor the frameworks of non-resampleable curves, such as core
data.
User-specified Increment will set the output curves to a fixed
sample increment which you can specify in the text box.
Using MB3 over the User-Specified Increment text field will
invoke the menu shown at left. The Minimum and Maximum
increment values are fixed at 0.0001 and 100.000 respectively.
The Default value changes with the measurement system:
0.5 for feet-based systems, like US Oil Field;
0.125 for metre-based systems, like Canadian Metric and
SPE Preferred.

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
132

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

contain comments. Details about creating algorithms are in the


Building Algorithms section of this documentation. The algorithm can
be saved to a file at any time.
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.
Check Syntax does not verify the existence of referenced curves.
Check Syntax only checks for errors in grammar or syntax; you must process the
algorithm to verify that referenced curves exist for the selected wells.
Syntax errors stop processing.
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
R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

133

Reports and Utilities

Landmark

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.
Press Ctrl-l to activate/deactivate the PD facility. When the PD border
is green, PD is listening for other curve/well data. When the border is
red, PD is deactivated for this application.
Iconified windows can receive information.
You can PD information to a window that is iconified as long as the border on the
icon is green. If the iconified window is a StratUtil application and the border is red,
you can use the key combination Ctrl+l (lowercase letter el) or click on the
iconified window and select PD Listen from the menu that appears to turn the
border green and to enable listening capability.

To receive a curve in MathPack:

134

1.

With the PD frame active (green), press MB1 in the Algorithm


Builder window.

2.

Go to another application and select a curve name.

3.

Press Shift-MB2. A flying box appears in the MathPack window,


and the current curve name appears at the insertion point in the
algorithm window. The curve name is enclosed in quotes,
according to MathPack syntax.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Log Curve Selection Window


The Log Curve Selection window provides an alternate method of
selecting curves to typing curve identifiers in the algorithms. The Log
Curve Selection Window is accessed from the Main Menu via
Tools > Select Log Curves...

Curve
Selection

Search/Filter

Curve List

Selection
Display
Action Buttons

Log Curve Selection Window Components


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.
When Curve Aliases or Curve Names is selected, you can choose
to have All Curves in Selected Wells displayed (the union of all
curve identifiers), or you can choose to have only Curves
R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

135

Reports and Utilities

Landmark

Common to Selected Wells displayed (the intersection of all


curve identifiers).

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:

136

Are in the original list (Total:)


Are currently displayed in the list, as a result of a filtering
operation (Displayed:)
Are currently selected (Selected:)

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

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.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

137

Reports and Utilities

Landmark

Parameter Selection Window


The Parameter Selection window provides a list of the 92 Global
Parameters and provides an alternate method of selecting those
parameters to typing global parameters in the algorithms. The
Parameter Selection Window is accessed from the Main Menu via
Tools > Select Wellbore Parameters...
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

Parameter Selection Window Components


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.

138

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

* 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 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.
More information about each Global Parameter is available in
Appendix 5: MathPack Syntax, and in the Wellbore Parameter
Editor documentation.
Appendix 5 shows the parameter Name, Title, Description,
Minimum and Maximum Values, optional Default Values, and the
Units of Measurement.
Wellbore Parameter Editor documentation contains the above
information, plus expanded default values for a small number of
parameters. To open Wellbore Parameter Editor:
Go to PetroWorks Command Menu > Utilities > Wellbore
Parameter Editor, make sure Applications is set to Global
Parameters and Columns (Parameter Group) is set to All.
Find the parameter that you want, then double-click on a cell in
that parameters column. The Cell/Parameter Detail window
will appear which provides details about the parameter and its
current value.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

139

Reports and Utilities

Landmark

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.
Close closes the Parameter Selection window with no further action.

140

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Algorithm Elements Window


The Algorithm Elements window provides an alternate method of
entering algorithm elements to typing the elements in the algorithms.
The Algorithm Elements Window is accessed from the Main Menu via
Tools > Select Algorithm Elements...

Algorithm
Elements
Palette

Close button

Algorithm Elements Window Components

Algorithm Elements Palette


This palette of algorithm elements can be used instead of typing the
elements directly in the Algorithm Field. To place an element in an
algorithm, position the cursor at the location that you want the element
placed (in the Algorithm Field of the MathPack Main window), then
MB1 on the element in the Algorithm Element Palette.
The algorithm elements are defined Appendix 1: Algorithm elements
with definitions.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

141

Reports and Utilities

Landmark

Close button
The Close button closes the Algorithm Elements window with no
further action.

142

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Symbolic Equations Window


The Symbolic Equations window provides an alternate method of
entering algorithms to typing the algorithms or loading a .mathpack
file. The Symbolic Equations Window is accessed from the Main Menu
via Tools > Select Symbolic Equations...
Symbolic Equations are useful as a quick way to save one-line
equations that you might want to use in several different algorithms, or
just use occasionally by themselves. Symbolic Equations allow you to
write an equation once, and verify its validity in an algorithm, then
quickly use it at another time.

Main Menu

Equation
List

Equation Field
Equation
Name
Field
Action
Buttons

The list of pre-defined symbolic equations is detailed in Appendix 2:


Pre-Defined Symbolic Equations.

Symbolic Equations Window components


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.
Close closes the window without further action.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

143

Reports and Utilities

Landmark

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 Name Field


The Equation Name Field shows the name of the selected equation. If
you create a new Symbolic Equation, you type the desired name here.

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.
Delete removes the Symbolic Equation in the Equation Name Field
from the list of equations.
Insert into Algorithm inserts the Symbolic Equation in the Equation
Field into the algorithm in the MathPack Main Window Algorithm
Area at the location of the cursor.
Close closes the Symbolic Equation window without further action.

Adding an Equation to the Symbolic Equations List


To add an equation to the list of Symbolic Equations:

144

1.

Enter a name for the equation in the Equation Name Field. Pick a
name that you can easily recognize at a later date.

2.

Type the equation in the Equation Field, or copy the equation


from the Algorithm Field on the MathPack main window and
paste it in the Equation Field.

3.

Click the Add/Update button to add the equation to the list.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Modifying an Existing Symbolic Equation


To update an existing equation:
1.

Click on the equation or the equation name in the Equation List to


bring the equation into the Equation Field.

2.

Modify the equation as needed.

3.

Click the Add/Update button to make the changes in the list.

4.

Click File > Save to save the changes to the Symbolic Equations
file.

To delete an existing equation:


1.

Click on the equation or the equation name in the Equation List to


bring the equation into the Equation Field.

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.

Storing multiple line equations in Symbolic Equations is NOT


recommended.
Although storing a multiple line equation in Symbolic Equations is possible, it is
strongly recommended that you DO NOT do so. When a multiple line equation is
stored in Symbolic Equations, all equations are reformatted to the same number of
lines as the multiple line equation, causing the list to expand. In addition, the lines
after the first line are left-justified to under the equation title.
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.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

145

Reports and Utilities

Landmark

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

Remarks Window Components


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.
Remarks are limited to a maximum of 80 characters per line.
Multiple lines of remarks may be used.

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.

146

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Save Algorithm Window


The Save Algorithm window provides the means to store the algorithm
that you have created in a directory of your choice with a name of your
choice. The Save Algorithm window is accessed from the Main Menu
via File > Save Algorithm... or File > Save As...

Filter Text Box

Directory and File Lists

Selection Text Box

Saving a New Algorithm


To save a new algorithm in MathPack:
1.

Go to File > Save Algorithm... or File > Save As... Either menu
item will open the Save Algorithm window shown above.

2.

Move to directory in which you want to store the algorithm by


double-clicking through the directory levels, or by typing the
directory path in the Filter Text Box and clicking the Filter
button.

3.

Type the file name that you want to use in the Selection Text Box
and click OK.

Saving a Previously-Saved Algorithm


To save an algorithm that was previously saved in the same MathPack
session, with the same file name, select File > Save Algorithm... The
Save Algorithm window will NOT appear. Instead, a note will appear
in the status area that the algorithm has been saved.

R2003.12.1

Building Algorithms with MathPack: MathPack Window Descriptions

147

Reports and Utilities

Landmark

To save an algorithm that was previously saved with a different file


name, select File > Save As... The Save Algorithm window will
appear. Follow the directions for saving an algorithm listed in the
Saving a New Algorithm section.

148

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Open Algorithm window


The Open Algorithm window provides the means to open an algorithm
that you have previously created. The Open Algorithm window is
accessed from the Main Menu via File > Open Algorithm...

Filter Text Box


Directory and File Lists

Algorithm Preview

Selection Text Box

Opening an Existing Algorithm


To open an existing algorithm in MathPack:

R2003.12.1

1.

Go to File > Open Algorithm... to open the Open Algorithm


window.

2.

Move to the directory in which the desired algorithm is located by


double-clicking through the directory levels, or by typing the
directory path in the Filter Text Box and clicking the Filter
button.

3.

Highlight the file that you want to load.

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.

5.

Click OK to load the contents of the file to the MathPack Main


Window Algorithm Field.

Building Algorithms with MathPack: MathPack Window Descriptions

149

Reports and Utilities

Landmark

Opening an Existing Algorithm


When you open an existing algorithm, the entire contents of the algorithm file is
loaded to the MathPack Main Window Algorithm Field, beginning at the location
of the cursor in the field. The contents of the file will be ADDED TO the current
contents of the Algorithm Field; it will NOT overwrite the contents.

150

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Building Algorithms
This section provides the details of creating algorithms, including the
grammar and syntax of the algorithms, and an explanation of error
messages when they appear.

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.
Arithmetic and logical (boolean) operators have their conventional
meanings and follow their conventional order of precedence. The order
of precedence (the order of evaluation) of the operators may be
modified by grouping expressions within parentheses. The groupings
may be of arbitrary complexity and may be repeated to any level.
Statements are processed sequentially in the algorithm from top to
bottom, for each valid sample point; i.e., the algorithms apply only to
the current depth; no access to depths other than the current depth is
possible.
The algorithm checker (parser) performs reasonable static checks on
the algorithm, searching for common errors in syntax and semantics.
When an error occurs, a message that indicates the nature of the error
(and where applicable, possible solutions to the problem) is generated
in the Status Area of the MathPack window. See Appendix 4:
Understanding Error Messages for more details.

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-HuntGardner transform:
DT DT matrix
PH I sonic = 0.625 -----------------------------------DT

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

151

Reports and Utilities

Landmark

PHIsonic = sonic porosity (= SPHI in the equations below);


DT = acoustic wave travel time (the log measurement);
DTmatrix = matrix (zero porosity) acoustic wave travel time.
Here, the equation is written in its simplest form. Although
DT matrix varies based on the porosity of the formation, it is
written here as a constant; 56 usec/ft, the sandstone value.

This version of the equation introduces DTmatrix as a variable,


which is defined as 56 usec/ft immediately below its declaration as a VARIABLE. In this form, the equation can easily be
used for matrix values other than 56, by changing the value in
one place.

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 locally-defined variable (DTmatrix). The Curve Alias provides the means to process wells with
variations in the
name of the
sonic measurement, and the
Global Parameter 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 exactly like
the version immediately above, except
that it has been written on several lines to
limit the width of the text.

This version of the equation is in the same form as the two immediately above, and also includes an IFTHEN-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).

152

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

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.

If an expression cannot be computed, it resolves to the NULL value.


Null values in input data or from incomputable expressions will cause
the affected output curve(s) to be NULL at that sample point.

Algorithm Component Details


Algorithms consist of three components:

Comments (optional)
Variable declarations (optional)
Statements

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
R2003.12.1

Building Algorithms with MathPack: Building Algorithms

153

Reports and Utilities

Landmark

numeric values or the value of computed expressions. Variables can be


parameters that are needed in the algorithm, or they can be intermediate
results in an algorithm.
Unlike curve references, Local Variable references appear without
quotation marks. They are initialized to NULL before processing at
each sample level.
Local Variables are declared by use of the statement:
VARIABLE <variable name>;
VARIABLE is insensitive to case.
Examples of Local Variable declarations:

Note the possible forms


of the word variable.
These are Global Parameters. They
have the same form (no quotation
marks) as Local Variables.
The Local Variable m is
used in the Rwa equation.

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.
The example above also contains two Global Parameters,
DensityFluid and DensityMatrix. They are used like Local Variables,
and have the same appearance (they are used in expressions without
quotation marks). They are not explicitly declared in the algorithm, but
they are implicitly declared, and as such are available to all
applications. See Global (Wellbore) Parameters for more details.

Using Global Parameter names as Local Variables


If a parameter with exactly the same name as a Global Parameter is declared as a
Local Variable in an algorithm (by the VARIABLE <parmname>; statement,
the value of the Global Variable is hidden in processing, and the declared or
calculated value in the algorithm is used.

154

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Statements
There are three types of statements:

Assignment Statements
IF Statements
LOOP Statements

Statements can consist of the following elements:

Curve Identifiers by Curve Alias, Curve Name, or Curve Details


Numeric Literals
Local Variables
Global (Wellbore) Parameters
Reserved Literals/Reserved Words
Function Calls

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.
Examples of assignment statements:

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 the expression immediately following IF is satisfied, the expression
immediately following THEN is evaluated. If the expression

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

155

Reports and Utilities

Landmark

immediately following IF is NOT satisfied, the expression immediately


following THEN is NOT evaluated, and is skipped.
IF (expression) THEN
(expression);
ELSE
(expression);
END IF;
If the expression immediately following IF is satisfied, the expression
immediately following THEN is evaluated, and the expression
immediately following ELSE is skipped. If the expression immediately
following IF is NOT satisfied, the expression immediately following
THEN is skipped, and the expression immediately following ELSE is
evaluated.
MathPack grammar recognizes equality, inequality, and relational
operators that can be combined with the logical operators AND, OR,
and NOT to create sophisticated conditional control.
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 dowhile loop.
The LOOP statement has the form:
(expressions setting initial conditions);
WHILE (expressions) LOOP

156

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

(expression);
(expressions to iterate values);
END LOOP;
The condition of each loop statement is evaluated once for each
iteration. If upon evaluation the condition is met, the loop body is
entered. Statements in the loop body are processed and control is
passed back to the top of the loop, where the condition of the loop body
is re-evaluated.
Static checks (via the Check Syntax button) are performed to
determine if the loop will be infinite or entered at all. If the loop is
determined to be infinite, the parser will produce an error message in
the Status Area. If the loop will never be entered, the parser will warn
the user and will remove all associated statements (including the
evaluation of the condition) from processing.
Loops are processed and must terminate or run to completion FOR
EACH DEPTH at which the algorithm is applied. Loops that require
large numbers of iterations to complete will greatly increase processing
time for an algorithm.
Example of a LOOP statement:

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

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

157

Reports and Utilities

Landmark

computations. Curve identifiers can be Curve Aliases, Curve Names, or


Curve Details, with limitations as shown in the table below.

Identifier

Input Curve

Output Curve

Curve Alias

Can be used. This is the preferred


format for input curves, as its use
will invoke the aliasing and autocompositing features of OpenWorks
and PetroWorks.

Can be used. (OpenWorks and the


applications will regard the Alias as a
Curve Name.)

Curve Name

Can be used. Useful if curve names


are consistent between wells.
Invokes the auto-compositing
features of OpenWorks and
PetroWorks.

Can be used. This is the preferred


format for output curves.

Curve Details

Can be used. This format is useful


ONLY if your algorithm is built for a
specific well, and/or you want to
process using a specific curve
instance.

Cannot be used as an output curve


format.

Curve identifiers must be enclosed in double quotation marks ( )


since they may be composed of printable characters that the algorithm
uses as operators and separators, and may contain embedded spaces.
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
Some examples of curve identifier usage:

Case 1
Case 2
Case 3
Case 4

Case 1 shows the use of Curve Names as input and output curve
identifiers.
158

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Case 2 shows the use of a Curve Name as an output curve


identifier, and Curve Aliases as input curve identifiers. This format
provides the most flexibility in processing, especially when
processing multiple wells.
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.
Case 4 shows the use of a Curve Name as an output curve
identifier, and Curve Details as input curve identifiers. This is most
useful for the processing of a specific individual well, when you
want to access a specific curve instance.

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.)

Output Curves and Curve Details


Curve references (Service, Run, and Pass) are automatically generated for all
output curves.
If all input curves used in the equation are specified by Curve Details, and all
curves used in the equation have the same Service, Run, and Pass, the output curve
will inherit those attributes.
If input curve attributes are different, the output curve attributes will be: Service
= PETROWORKS, Run = C, Pass = NONE.

Numeric Literals
Numeric literals are numbers that are used in an algorithm. Numbers do
NOT have to contain a decimal point.

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

159

Reports and Utilities

Landmark

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 (Wellbore) Parameters


Global Parameters, also known as Wellbore Parameters, are parameters
which are shared by many applications. Those applications include the
PetroWorks-supplied applications like those under
Interpret > Petrophysics on the PetroWorks Launcher Bar,
ModelBuilder applications, and now MathPack algorithms. The Global
Parameters are shared; that is, their values are set in Wellbore
Parameter Editor as part of processing a particular model, and those
values are used by all applications that reference particular parameters.
Global Parameters are described in Appendix 5: MathPack Syntax.
Global Parameter are NOT declared in MathPack (whereas Local
Variables must be declared to be recognized).
Global Parameters are used with the same format as Local Variables;
they are included in expressions without double quotation marks.
The value of a Global Parameter can be changed in Wellbore Parameter
Editor. The value of a Global Parameter CANNOT be changed in
MathPack. For that reason, Global Parameters are not allowed to be
used on the left side of statements in algorithms.
Global Parameters can be hidden if a Local Variable of exactly the
same name (including case) is declared in an algorithm. In this case, the
value of the parameter as declared or calculated in the algorithm will be
used, and the actual value of the Global Parameter will be ignored and
unchanged.
For example:
The algorithm
SPHI = 0.625*(DT-TransitTimeMatrix)/DT;
160

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

will use the value of the Global Parameter TransitTimeMatrix that


exists in the OpenWorks database.
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/Reserved Words


Reserved Literals (Words) are words which are interpreted literally by
the MathPack parser. They represent elements of an algorithm, or have
specific values. Reserved literals include IF, THEN, ELSE, OR,
TRUE, FALSE, NULL, END, LOOP, VARIABLE.
Reserved Literals are case insensitive; IF, if, If, iF are all
interpreted as the same literal word.
Reserved Literals/Reserved Words are defined in Appendix 1:
Algorithm elements with definitions, in the Logical Operators,
Statement Elements, and Value Literals sections.

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.
Trigonometric Function Calls expect Radians
The trigonometric Function Calls operate on a number or on a resolved expression
which are expected to be in RADIANS, NOT degrees.
The conversion from degrees to radians is:
Degrees
Radians = ---------------------- 2
360

R2003.12.1

Building Algorithms with MathPack: Building Algorithms

161

Reports and Utilities

Landmark

Some examples of the format of function calls are:

Function Calls are defined in Appendix 1: Algorithm elements with


definitions, in the Function Calls section.

Exponentiation
Exponentiation is represented by the carat symbol ( ^ ) or by the
Function Call EXP. The expressions are equivalent.
Roots may be calculated by using a fractional exponent.
Fractions may be calculated by using a negative exponent.
Roots of negative values cannot be calculated.
Some examples of exponentiation are shown here:

These two expressions are equivalent.


These three expressions are equivalent.

162

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Top Twelve Check List


The following table contains a list of tips for ensuring smooth
processing when using MathPack.
Before processing an algorithm, be sure to:

R2003.12.1

1.

Make sure that all curves used in calculations exist in the selected wells

2.

Check for a disk file of the algorithm youre interested in chances are it may
already have been written.

3.

Add any commonly-used constant (or equation) to the constant (equation) table. Edits
to that constant or equation then only need to be made once in the table.

4.

Terminate all statements with a semi-colon.

5.

Include both opening and closing parentheses.

6.

Check for typographical errors.

7.

Check for missing or misspelled reserved words such as thne for then.

8.

Enclose curve names in both opening and closing quotes.

9.

Check for quoted curve names that span multiple lines. Note that curve names should
not exceed 25 characters.

10.

Ensure that all curve i.d.s are in the proper case.

11.

Ensure that all comments are preceded by a double dash --.

12.

Use NEG (), not a minus sign (-) for negative values.

Building Algorithms with MathPack: Building Algorithms

163

Reports and Utilities

Landmark

Appendices
Appendix 1: Algorithm elements with definitions

Element

Definition

Arithmetic Operations
+

addition

subtraction

multiplication

division

exponentiation. See also EXP( )

Relational Operations
=

is equal to

!=

is not equal to

<

is less than

<=

is less than or equal to

>

is greater than

>=

is greater than or equal to

Logical Operators
AND

and, as <expression> AND <expression>

OR

or, as <expression> OR <expression>

Function Calls

164

ABS( )

Arithmetic absolute value of the specified numeric expression.

ACOS( )

Trigonometric arccosine (inverse cosine) of the specified numeric


expression. The expression is assumed to be in radians, and its value
must be in the range [-1, 1].

ASIN( )

Trigonometric arcsine (inverse sine) of the specified numeric expression.


The expression is assumed to be in radians, and its value must be in the
range [-1, 1].

ATAN( )

Trigonometric arctangent (inverse tangent) of the specified numeric


expression. The expression is assumed to be in radians.

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

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.

MOD( )

First expression modulo the second expression.

NEG( )

Negative value of the specified numeric expression.

SIN( )

Trigonometric sine of the specified numeric expression. The expression


is assumed to be in radians, and its value must be in the range [-1, 1].

SQRT( )

Square root of the specified numeric expression. The value of the


expression must be non-negative.

TAN( )

Trigonometric tangent of the specified numeric expression. The


expression is assumed to be in radians, and its value must be equal to+-/
2.

EXP( )

exponentiation. See also ^.

RANDOM( )

Supplies a random floating-point value between two numbers. This


function has the format RANDOM(min_value, max_value), where the
output ranges between the min_value and the max_value.

Statement Elements
VARIABLE

Reserved word for declaration of a Local Variable.

equal to

open parenthesis

close parenthesis

semi-colon. Ends algorithmic lines

IF ( ) THEN

IF statement

( );
END IF;
IF ( ) THEN

IF-THEN statement

ELSE ( );
END IF;
WHILE ( )
LOOP

LOOP statement

( );
END LOOP;
R2003.12.1

Building Algorithms with MathPack: Appendices

165

Reports and Utilities

Landmark

Element
--

Definition
Precedes comments, either at the beginning of a line, or at the end of a
line containing an expression, after the semi-colon.

Value Literals

166

TRUE

TRUE reserved literal

FALSE

FALSE reserved literal

NULL

NULL reserved literal

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 2: Pre-Defined Symbolic Equations


The pre-defined Symbolic Equations are accessed from the MathPack
Main Menu via Tools > Select Symbolic Equations... The Symbolic
Equations are written with curves represented by Curve Aliases, and
parameters represented by Global Parameters.

Equation Name

ARCHIE

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Definition

a Rmf
Sw = ---------------------m

Rxo

Undisturbed zone water


saturation from the Archie
(clean formation) equation.

1
--n

Sw = SW_ARCH (water saturation)


a = TortuosityFactor
Rw = ResWater (formation water resistivity)
Rt = Deep_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent
1
---

ARCHIE_SXO

Flushed zone water saturation


from the Archie (clean
formation) equation.

BVW

Bulk Volume Water: The


amount of water in the
formation as a fraction of the
total formation volume.

R2003.12.1

a Rw n
Sxo = -----------------m

Rt
Sxo =SXO_ARCH (flushed zone water saturation
a = TortuosityFactor
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rxo = Flushed_Zone_Resistivity
= Porosity
m = CementationExponent
n = SaturationExponent

BVW = S w
BVW = BVWC (bulk volume water)
Sw = Water_Saturation
= Effective_Porosity

Building Algorithms with MathPack: Appendices

167

Reports and Utilities

Equation Name

DEN_to_POR

Landmark

Definition

Converts bulk density to


density porosity, using matrix
density and fluid density.

DT_to_POR

Converts acoustic wave travel


time to acoustic (sonic)
porosity, using matrix travel
time and fluid travel time
using the Wyllie TimeAverage equation (no
compaction correction).

F_FACTOR

Formation Resistivity Factor.


Used to relate the bulk
resistivity of a rock to the
resistivity of the water with
which it is saturated.

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

matrix b
DPHI = ---------------------------------- matrix fluid
DPHI = DPHI (density porosity)

b = Bulk_Density (the log measurement)


matrix = DensityMatrix
fluid = DensityFluid
T T matrix
SPHI = -------------------------------------------T fluid T matrix
SPHI = DTPORC (sonic porosity)
T = Acoustic_Wave_Travel_Time (log measurement)
Tmatrix = TransitTimeMatrix
Tfluid = TransitTimeFluid

a
F = -----m

F = F (formation factor)
a = TortuosityFactor
= Porosity
m = CementationExponent

MOVEABLE_SH

168

Moveable hydrocarbon
saturation (also called
moveable oil saturation). The
fraction of in-place
hydrocarbons that can be
moved or produced.

MOS = Sxo Sw

MOS = MOS
Sxo = Flushed_Zone_Water_Sat
Sw = Water_Saturation

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Equation Name

Definition

POR_to_DEN

Bulk density calculated from


density porosity, using matrix
density and fluid density.

RESIDUAL_SH

Residual hydrocarbon
saturation (also called
residual oil saturation). The
fraction of in-place
hydrocarbons that cannot be
produced.

b = ( 1 ) matrix + fluid
b = RHOBC)

= Density_Porosity

matrix = DensityMatrix
fluid = DensityFluid

ROS = 1 Sxo

ROS = ROS
Sxo = Flushed_Zone_Water_Sat
m

RMFA

Apparent mud filtrate


resistivity, from flushed zone
resistivity and porosity
measurements.

Rxo
Rmfa = ----------------------a
Rmfa = RMFA
Rxo = Flushed_Zone_Resistivity
a = TortuosityFactor
= Porosity
m = CementationExponent

RWA

Apparent formation water


resistivity, from true (deep)
resistivity and porosity
measurements.

Rt
Rwa = -----------------a

Rwa = RWA
Rt = True_Resistivity
a = TortuosityFactor
= Porosity
m = CementationExponent

R2003.12.1

Building Algorithms with MathPack: Appendices

169

Reports and Utilities

Landmark

Equation Name

Definition

RWA_ARCH

Apparent formation water


resistivity, from true (deep)
resistivity and formation
factor. Requires the
F_FACTOR equation.

Equation in traditional format, with components defined


in terms of Curve Aliases and Global Parameters.

Rt
Rwa = ----F

Rwa = RWA_ARCH
Rt = True_Resistivity
F = F_Factor

RWA_RATIO

Rt
Rwa = Rmf ----------
Rxo

Apparent formation water


resistivity, from mud filtrate
resistivity and measured
resistivities.

Rwa = RWA_RATIO
Rmf = ResMudFiltrate (mud filtrate resistivity)
Rt = True_Resistivity
Rxo = Flushed_Zone_Resistivity

170

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 3: Global (Wellbore) Parameters and Definitions


The following table describes the Global Parameters that are available
in MathPack and ModelBuilder, and which appear in many of the
PetroWorks interpretive applications (which are built with
ModelBuilder).

Parameter Name is the actual name of the parameter, to be used


WITHOUT double-quotes in MathPack algorithms.
Parameter Title is the title of the parameter in Wellbore
Parameter Editor.
Description is an attempt to describe the parameter. The
description also appears if you double-click a cell in Wellbore
Parameter Editor.
Min. Value and Max. Value describe the valid range of the
parameter.
Default Value provides a reasonable value for the parameter, if the
parameter can support a general (default) value.
Units describes the units of measurement for each parameter.

Min. Max. Default


Value Value Value

Parameter Name

Parameter Title Description

BitSize

Bit Size

The size of the bit used to drill this 0


section of the wellbore.This is not
the size of the wellbore itself
because of factors such as
wellbore rugosity, mud cake,
shale sloughs and wellbore
collapse.

60

8.75

inches

BottomHoleDepth

Bottom Hole
Depth

The total depth to which the well 0


is drilled

50000

10000

feet

BottomHoleTemperature

Bottom Hole
Temperature

The temperature downhole at the 0


bottom of the well.

600

175

degF

CementationExponent

Cementation
Exponent (m)

Cementation exponent (m) for


the Archie equation.

0.1

unitless

ConcentrationKcl

Concentration
KCl

Concentration KCl

30

DensityAnhydrite

Anhydrite
Density

Bulk density for Anhydrite.

2.95

3.1

2.98

g/cm3

DensityCasing

Casing Density

Density of the casing

66.427

lbm/
galUS

DensityCoal

Coal Density

Bulk density for Coal.

1.4

g/cm3

DensityDolomite

Dolomite
Density

Bulk density for Dolomite.

2.82

2.92

2.87

g/cm3

DensityDryShale

Dry Shale
Density

Bulk density for Dry Shale.

2.65

g/cm3

DensityFluid

Fluid Density

Density of the reservoir fluids


(includes water, dissolved salts
and hydrocarbons)

g/cm3

DensityFormationWater

Formation Water Density of formation water


Density

g/cm3

R2003.12.1

Building Algorithms with MathPack: Appendices

Units

171

Reports and Utilities

Landmark

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

DensityHydrocarbon

Hydrocarbon
Density

Density of the hydrocarbon


present in the formation

g/cm3

DensityLimestone

Limestone
Density

Bulk density for Limestone

2.69

2.8

2.71

g/cm3

DensityMatrix

Matrix Density

Bulk density for the Matrix.

1.5

3.5

2.65

g/cm3

DensityMudFiltrate

Mud Filtrate
Density

Density of the drilling fluids which 0


have invaded the formation after
losing some of their solids as
mud cake on the walls of the
wellbore.

g/cm3

DensityPorosityCoal

Coal density
Porosity

density porosity for Coal.

0.65

v/v
decimal

DensityPorositySalt

Salt Density
Porosity

Density porosity for Salt .

-1

-0.03

v/v
decimal

DensityPorosityShale

Shale Density
Porosity

Density porosity for Shale.

0.2

v/v
decimal

DensitySalt

Salt Density

Bulk density for Salt.

2.1

g/cm3

DensitySandstone

Sandstone
Density

Bulk density for Sandstone.

2.62

2.68

2.65

g/cm3

DensityShale

Shale Density

Bulk density for Shale.

2.65

g/cm3

DensityWetShale

Wet Shale
Density

Bulk density for Wet Shale.

2.3

g/cm3

DiameterBorehole

Borehole
Diameter

Diameter of the borehole.

100

8.75

inches

DiameterCasing

Casing Diameter Diameter of the casing.

36

inches

DiameterOfInvasion

Diameter of
Invasion

100

inches

DiameterTubing

Tubing Diameter Diameter of the tubing.

inches

DielectricConstantHC

Hydrocarbon
Dielectric
Constant

2.2

fred

DielectricConstantMatrix

Matrix Dielectric Dielectric constant for the


Constant
formation matrix.

3.5

35

4.65

unitless

DielectricConstantShale

Shale Dielectric
Constant

Dielectric constant for Shale.

10

55

25

unitless

EmpiricalInvasionFactor

Invasion Factor
Sw Sxo

Empirical invasion factor based


on Sw and Sxo

0.5

unitless

EquivCationConductance

Equivalent
Equivalent cation conductance.
Cation
Conductance(B)

30

3.83

mho/m
per
meq/cc

GammaRayClean

Gamma Ray
Clean

Gamma Ray count rate for a


clean zone. Sensitized only if
shale volume is to be calculated
from gamma ray counts.

500

20

API

GammaRayShale

Gamma Ray
Shale

Gamma Ray count rate for a zone 0


that is completely shale.
Sensitized only if shale volume is
to be calculated from gamma ray
counts.

500

100

API

HydrogenIndexFluid

Hydrogen Index Hydrogen index of fluid


of Fluid

1.5

unitless

NeutronPorosityAnhydrite

Anhydrite
Neutron porosity for Anhydrite.
Neutron Porosity

-0.025 0.025

-0.015

v/v
decimal

172

0
Diameter of the invasion of
drilling fluids into the surrounding
reservoir rock.

Dielectric constant of the


reservoir hydrocarbons.

Shared Utilities: Building Algorithms with MathPack

Units

R2003.12.1

Landmark Graphics Corporation

User Programming

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

NeutronPorosityClean

Neutron Porosity Neutron porosity in a clean


Clean
formation

NeutronPorosityCoal

Coal Neutron
Porosity

0.38

v/v
decimal

NeutronPorosityDryShale

Neutron Porosity Neutron porosity for Dry Shale.


of Dry Shale

0.2

v/v
decimal

NeutronPorosityHM

Heavy Mineral
Neutron porosity for Heavy
Neutron Porosity Minerals.

0.6

0.03

v/v
decimal

NeutronPorositySalt

Salt Neutron
Porosity

-1

-0.03

v/v
decimal

NeutronPorosityShale

Neutron Porosity Neutron porosity for Shale.


of Shale

0.2

v/v
decimal

NeutronPorosityShale

Neutron Porosity Neutron porosity in a shaly


Shale
formation

0.4

v/v
decimal

NeutronPorosityWetShale

Neutron Porosity Neutron porosity for Wet Shale.


of Wet Shale

0.25

v/v
decimal

PermeabilityConstant

Permeability
Constant

Permeability constant (K)

10000

250

unitless

PhotoelecIndexWetShale

Wet Shale
Photoelectric
Factor

Photoelectric index in Wet Shale 0

100

b/elec

PhotoelecXsecShale

Photoelectric
Cross Section
Shale

Macroscopic Photoelectric Cross 1


Section.

10

b/cm3

PorosityShale

Shale Porosity

Shale porosity

0.4

v/v
decimal

PropagationTimeDolomite

Propagation
Time Dolomite

Travel time in Dolomite for high


frequency (microwave) waves.

15

8.7

ns/m

PropagationTimeHC

Propagation
Time
Hydrocarbons

Travel Time in Hydrocarbons for 0


High Frequency (microwave)
waves. The rate of travel is
determined almost entirely by the
dielectric (insulating) properties
of the formation which is largely
related to the water content of the
formation.

10

4.7

ns/m

PropagationTimeLimestone

Propagation
Travel time in Limestone for high 0
Time Limestone frequency (microwave) waves.

15

9.7

ns/m

PropagationTimeSand

Propagation
Travel time in Sandstone for high 0
Time Sandstone frequency (microwave) waves.

15

7.2

ns/m

PropagationTimeShale

Propagation
Time Shale

Travel time in Shale for high


frequency (microwave) waves.

20

12

ns/m

PropagationTimeWater

Propagation
Time Water

20
Travel Time in Water for High
Frequency (microwave) waves.
The rate of travel is determined
almost entirely by the dielectric
(insulating) properties of the
formation, which is largely related
to the water content of the
formation.

90

29.5

ns/m

ResBoundWater

Water Resistivity Resistivity of water bound to the


Bound
clay minerals in the formation.

0.01

100

0.04

ohm.m

ResBoundWaterInv

Mud Filtrate
Bound
Resistivity

0.01

0.2

0.04

ohm.m

R2003.12.1

Neutron porosity for Coal.

Neutron porosity for Salt .

Resistivity of water bound to the


minerals in the invaded zone.

Units
v/v
decimal

Building Algorithms with MathPack: Appendices

173

Reports and Utilities

Landmark
Min. Max. Default
Value Value Value

Parameter Name

Parameter Title Description

ResBoundWaterInvTemp

Mud Filtrate
Temperature which the resistivity 32
Bound
of the bound water in the invaded
Resistivity Temp zone was measured

500

75

degF

ResBoundWaterTemp

Water Resistivity Temperature of the bound water


Bound Temp
at the time resistivity was
measured.

32

500

75

degF

ResistivityCleanLimit

True Resistivty
Clean limit

10000

ResistivityFlushZoneShale

Resistivity Shale Resistivity of Shale in the


Flushed Zone
Flushed Zone.

20

12

ohm.m

ResistivityShale

Resistivity Shale Resistivity for Shale in the


Undisturbed
undisturbed zone.
Zone

0.001

2000

0.5

ohm.m

ResistivityShaleLimit

True Resistivity
Shale limit

True Resistivity (Rt) in a shaly


formation

10000

ohm.m

ResMud

Mud Resistivity

Resistivity of the mud.

0.005

10

ohm.m

ResMudcake

Mudcake
Resistivity

Resistivity of the mudcake.

0.005

10

ohm.m

ResMudcakeTemp

Mudcake
Temperature which the resistivity 32
Resistivity Temp of the mudcake was measured

500

degF

ResMudFiltrate

Mud Filtrate
Resistivity of the Mud Filtrate
Resistivity (Rmf) which is present in the invaded
zone.

10

ohm.m

ResMudFiltrateTemp

Mud Filtrate
Temperature which the resistivity 32
Resistivity Temp of the Mud Filtrate which is
(TRmf)
present in the invaded zone was
measured

500

degF

ResMudTemp

Mud Resistivity
Temp

Temperature which the resistivity 32


of the mudwas measured

500

degF

ResWater

Water Resistivity Resistivity of the formation water. 0.001 10


(Rw)

ohm.m

ResWaterTemp

Water Resistivity Temperature which the resistivity 32


Temp (TRw)
of the formation waters was
measured.

degF

RHGFactor

Raymer Hunt
Gardner Factor
(k)

SalinityBorehole

Borehole Salinity The salinity of the borehole fluids. 0.001 300000

True Resistivity (Rt) in a clean


formation

0.005

0.625

SalinityFormation

Formation Water Salinity of the formation Waters.


Salinity

0.001

SalinityMudFiltrate

Mud Filtrate
Salinity

Salinity of the Mud Filtrate.

0.001

300000

SaturationExponent

Saturation
Exponent (n)

Saturation exponent (n) for the


Archie equation

0.1

SigmaBoundWater

Bound Water
Sigma

Neutron Capture Cross Section 20


of the Bound Water in the
formation. This term
encapsulates the apparent
capture cross section of the shale
should it differ from the sigma
matrix. This value can be
determined from a Sigma Water
Apparent vs SWB crossplot.

174

Shared Utilities: Building Algorithms with MathPack

ohm.m

500

Raymer Hunt Gardner Factor (k) 0


used to calculate sonic porosityif
the Raymer-Hunt-Gardner
Equation is selected

Units

unitless

ppm

300000

ppm
ppm

150

unitless
cu

R2003.12.1

Landmark Graphics Corporation

User Programming
Min. Max. Default
Value Value Value

Parameter Name

Parameter Title Description

SigmaFreeWater

Free Water
Sigma

Neutron Capture Cross Section 20


of the free (i.e. contained in the
effective porosity) water in the
formation. This term can be
determined from a knowledge of
Rw, and Rw temperature, Fluid
Salinity, or from a Sigma Water
Apparent vs Swb crossplot.

150

cu

SigmaHydrocarbon

Hydrocarbon
Sigma

Neutron Capture Cross Section


of the Hydrocarbons in the
formation.

25

cu

SigmaMatrix

Matrix Sigma

The capture cross section of the 0


rock (mineral, non-porous)
fraction. Due to diffusion effects
on the TDT, intrinsic matrix sigma
values are rarely used, instead
apparent matrix values are
commonly used. Sigma Matrix
can be determined in a clean,
non-hydrocarbon (gas) interval
by examining a Sigma log vs.
Porosity crossplot or the following
values might be used initially in
conjunction with sigma curves
that are not diffusion-corrected
formation / apparent capture
cross section Orthoquartzitic
Sand / 8.0 c.u. Subarkosic sand /
10.0 c.u.

300

10

cu

SonicPorosityShale

Shale Sonic
Porosity

The sonic porosity for Shale

0.5

0.3

v/v
decimal

SpontaneousPotentialClean

Spontaneous
Potential Clean

Spontaneous Potential for a


clean zone. Sensitized only if
shale volume is to be calculate
from spontaneous potential.

-200

100

-100

mV

SpontaneousPotentialShale

Spontaneous
Potential Shale

Spontaneous Potential for a shaly -200


zone. Sensitized only if shale
volume is to be calculate from
spontaneous potential.

100

mV

ThicknessCasing

Casing
Thickness

Thickness of the casing

0.5

inches

TortuosityFactor

Tortuosity Factor Tortuosity factor (a) for the Archie 0.1


(a)
equation

unitless

TransitTimeCoal

Coal Transit
Time

Acoustic transit time (delta t) in


Coal.

150

120

us/ft

TransitTimeCp

Transit Time
Compaction
Correction

Acoustic Compaction Correction 1


Factor for Sonic Logs. Transit
Time (Delta t) shale /100.

10

unitless

TransitTimeDolomite

Dolomite Transit Acoustic transit time (delta t) in


Time
Dolomite.

38.5

43.5

41

us/ft

TransitTimeDryShale

Dry Shale
Transit Time

Acoustic transit time (delta t) in


Dry Shale.

20

150

50

us/ft

TransitTimeFluid

Fluid Transit
Time

Travel Time in the Reservoir


Fluids

100

500

189

us/ft

TransitTimeLimestone

Limestone
Transit Time

Acoustic transit time (delta t) in


Limestone.

43.5

47.6

46

us/ft

TransitTimeMatrix

Matrix Transit
Time

Acoustic transit time (delta t) in


Matrix.

20

150

50

us/ft

TransitTimeSalt

Salt Transit Time Acoustic transit time (delta t) in


Salt.

20

150

64.4

us/ft

R2003.12.1

20

Building Algorithms with MathPack: Appendices

Units

175

Reports and Utilities

Landmark

Parameter Name

Parameter Title Description

Min. Max. Default


Value Value Value

TransitTimeSandstone

Sandstone
Transit Time

Acoustic transit time (delta t) in


Sandstone.

51.3

55.5

53.4

us/ft

TransitTimeShale

Acoustic Transit
Time in Shale

Acoustic transit time (delta t) in


Dry Shale.

20

150

50

us/ft

TransitTimeWetShale

Wet Shale
Transit Time

Acoustic transit time (delta t) in


Wet Shale.

20

150

50

us/ft

WeightCasing

Casing Weight

Weight of the casing

120

30

lbm/ft

30

15

lbm/
galUS

28

11

lbm/
galUS

WeightCement

Cement Weight

Weight of the cement.

WeightMud

Mud weight

Weight of the drilling fluid

176

Shared Utilities: Building Algorithms with MathPack

Units

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 4: Understanding Error Messages


MathPack generates a set of messages as it processes an algorithm.
These messages are displayed in the Main MathPack window, in the
status area.
Common syntax errors include misspelled or misplaced reserved words
and missing or misplaced lexical elements like parentheses, commas,
etc. Common semantic errors include values inappropriate for their
context such as parameters known to be out of range for a given
function or operands whose type is invalid within a given
expression.These messages may be broadly classified into two groups:

Information messages
Error messages

Information Messages
Information messages are generated for different reasons, but are
always preceded by the pattern
>> INFO:
These messages may display the status of MathPack algorithm
processing or provide additional detail about a previous message. One
or more information messages often follow an error message. See the
discussion that follows.

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
R2003.12.1

Building Algorithms with MathPack: Appendices

177

Reports and Utilities

Landmark

highlighted in the text of the algorithm builder window. The detail is


appended to generalized message text. For example,
>> ERROR: Unexpected lexical element
encountered at ")" on line 3
Error messages may be followed by one or more information messages
that give more detail about an error or supply status information
resulting from the error. As in
>> ERROR: Incorrect assignment statement syntax
at ":=" on line 12
>> INFO: Assignment symbol "=" expected
>> INFO: Pass One failed
Errors in the source can be categorized into two general types:

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:

a divide by zero is attempted.


a curve does not exist for a given well.
parameters that are inappropriate for a function, if an expression is
outside a specified bound or is of the wrong type

The algorithm checker attempts to statically check the algorithm being


processed for syntax and semantic errors. If a syntax error is detected,
the algorithm checker will report an error message. While the detail
178

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

supplied in the message or in supporting information messages may not


accurately pinpoint the source of the error, the offending element is at
or near (usually before) the point reported by the message.
A list of all MathPack messages is given below. Note that Informational
Messages are marked with an (I) and Error Messages are marked with
an (E).

Explanation of Information and Error Messages


Parse completed (I)
The parser has completed processing of the current algorithm
specification.
Parse failed (I)
The parser failed during processing of the current algorithm
specification. This message would normally be preceded by more
explicit (error or) information messages.
Unknown error condition (I)
Internal status information about parser progress. An error of
unknown origin has occurred. This is a critical error and should be
reported to customer support. In order to reproduce the error,
Landmark Customer Service will need the following information:

current dataset
depth and sampling parameters,
the algorithm specification

Division by zero (E)


The parser has detected an attempt to evaluate a division by zero in
the current algorithm specification. Since the result of this
operation cannot be represented arithmetically, the parser will not
proceed.

R2003.12.1

Building Algorithms with MathPack: Appendices

179

Reports and Utilities

Landmark

Taking the root of a negative value (E)


The parser has statically detected an attempt to evaluate the root of
a negative value in the current algorithm specification. Since the
result of this operation cannot be represented arithmetically, the
parser cannot proceed.
Taking square root of a negative value (E)
A more specific version of the previous message, used in
conjunction with the predefined function SQRT.
Zero base with negative exponent (E)
The parser has statically detected an attempt to raise a base of zero
to a negative exponent.
Taking log of non-positive value (<= 0.0) (E)
The parser has statically detected an attempt to evaluate the log of
a non-positive value, i.e. a value that is less than or equal to zero.
Parameter not in required range (E)
The parser has statically detected a function parameter that is not
in the required range for the pre-defined function where the
parameter is used.
Must be in range [-1, 1] (I)
The function parameter must be in the inclusive range from -1 to 1.
Values outside this range are inapplicable for the specified predefined function.
Must be in range [-(/2), (/2)] (I)
The parameter must be in the inclusive range from -/2 to /2.
Values outside this range are inapplicable for the specified predefined function.
Must not be equal to 90 or -90 degrees (/2 or -

/2) (I)

The parameter must not be equal to 90 or -90 degrees, in a


trigonometric context. Parameters having these values are
inappropriate for the specified pre-defined function.

180

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Incorrect syntax (E)


The parser has detected incorrect syntax in the current algorithm
specification. This is a general syntax error used, when no other
(more specific) message is applicable.
Incorrect algorithm syntax (E)
The parser has detected incorrect syntax in the current algorithm
specification. This is a general syntax error used, when no other
(more specific) message is defined. This message is
interchangeable with the previous message.
Incorrect declaration syntax (E)
The parser has detected incorrect syntax for a variable declaration
in the current algorithm specification.
Incorrect statement syntax (E)
The parser has detected incorrect syntax for a statement in the
current algorithm specification.
Incorrect assignment statement syntax (E)
The parser has detected incorrect syntax for an assignment
statement in the current algorithm specification.
Incorrect if statement syntax (E)
The parser has detected incorrect syntax for an if statement in
the current algorithm specification.
Incorrect loop statement syntax (E)
The parser has detected incorrect syntax for a loop statement in
the current algorithm specification.
Invalid function parameter (E)
The parser has detected use of a invalid parameter to the specified
pre-defined function. The parameter is:

R2003.12.1

not in a required range


not of the required type, i.e. boolean instead of numeric
not static when required.

Building Algorithms with MathPack: Appendices

181

Reports and Utilities

Landmark

Unexpected lexical element encountered (E)


The parser has detected a lexical element that has no meaning or is
inappropriate for its position in the current algorithm specification.
Assignment symbol "=" expected (I)
The parser has encountered incorrect syntax in what it believes is
an assignment statement. Another (or no) lexical element was
found when expecting the assignment symbol =.
Semi-colon expected (I)
The parser has encountered incorrect syntax at what it believes
should be a statement termination. Another (or no) lexical element
was found when expecting the statement terminator, semi-colon
(;).
Valid statement expected (I)
The parser has encountered a pattern in the current algorithm that
cannot be interpreted as a statement.
Variable identifier expected (I)
The parser has encountered incorrect syntax in a variable
declaration, where a variable identifier was expected.
Reserved word then expected (I)
The parser has encountered incorrect syntax in an if statement,
where the reserved word then was expected.
Reserved words end if expected (I)
The parser has encountered incorrect syntax in an if statement,
where the reserved words end if were expected.
Reserved words end expected (I)
The parser has encountered incorrect syntax in a loop statement,
where the reserved words end was expected.
Nested if statement encountered (I)
The parser has encountered nested if statements. Current
restrictions prevent nesting of if statements.

182

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Mismatched parenthesis (I)


The parser has encountered incorrect syntax in an expression,
where the number of opening and closing parenthesis are not
equal.
Undefined curve (E)
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.
Unterminated curve name (I)
The parser has encountered incorrect syntax while processing a
curve name. An opening quote (indicating the beginning of a curve
id) was found and the end of a line was reached without finding the
corresponding closing quote.
Curve name exceeds allowable length(26chars) (E)
A quoted curve name was encountered that contained more than
the maximum allowable number of characters. Log curve names
may not be longer than 26 characters in length.
Shorten curve name (I)
Use a log curve name with fewer characters.
Undefined symbolic constant (I)
The parser cannot resolve reference to what it believes is a
symbolic constant. Beware to quote curve names. Some unquoted
curves names may appear in context to be symbolic constants.
Check curve selection for well (I)
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.

R2003.12.1

Building Algorithms with MathPack: Appendices

183

Reports and Utilities

Landmark

Check unit selection for well (I)


The parser has encountered a unit (or depth interval) that is
undefined for a curve in the current well. Valid units (or top and
bottom) should be checked for the well.
*Check for typographical spelling error(s) (I)
The parser has encountered a syntax or semantic error that might
classically arise through a typographical error. Where the error
message occurs, check that all symbolic constants exist as named.
Check that all curves exist in appropriate wells as named.
Check for closing quotation mark (I)
The parser has encountered what it believes is a curve name with
no closing quotation mark. Remember that quoted curve names
may not span multiple lines. Check that all curve names have
opening and closing quotes.
Undeclared temporary variable (E)
The parser has encountered what it believes is a variable name in
the context of an assignment statement, where no declaration has
been provided for the named variable.
Only declared variables and log curves may be
assigned values (I)
The parser has encountered an assignment to an unknown
identifier and suggests the proper use.
Temporary variable redeclared (E)
The parser has encountered a duplicate declaration for a temporary
variable in the current algorithm specification.
A variable may be declared only once (I)
The names of declared temporary variables must be unique. The
declaration for a variable with a given name may only appear once
in the current algorithm specification.

184

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Condition statically evaluated (I)


The parser has detected the condition of an if or loop
statement that was statically determined to be TRUE (or FALSE).
The appropriate parts of the algorithm will either be performed or
automatically removed, i.e are not considered during processing of
the algorithm.

The next several messages are related to the above message and will
appear in some combination, depending on the context.
Check terms and relations, if static condition
is not intended (I)
This message serves as an additional warning. Some static
conditions may be intentional.
Condition is always TRUE (I)
Condition is always FALSE (I)
The parser has detected a condition of an if or loop statement
that is statically determined to be TRUE (or FALSE).
If statement will never be performed (I)
The condition of an if statement (without an else part) was
statically determined to be FALSE. The condition is not
considered and the if statement (including all of its enclosed
statements) is effectively removed from processing.
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.
Else part will always be performed (I)
The condition of an if statement (with an else part) was
statically determined to be FALSE. The condition is not
considered during processing and the statements enclosed by the
else part are always performed.

R2003.12.1

Building Algorithms with MathPack: Appendices

185

Reports and Utilities

Landmark

Else part will never be performed (I)


The condition of an if statement (with an else part) was
statically determined to be TRUE. The condition is not considered
during processing and the statements enclosed by the if part are
always performed. Statements enclosed by the else part are
never performed and are effectively removed from the algorithm.
Loop wont terminate (E)
The parser has detected a loop condition that was statically
evaluated to be TRUE. Once entered, the loop will never terminate
nad cause an endless iteration over the enclosed statements. Note
that this case is considered to be an error and will prevent the
algorithm from being processed.
Loop will never be entered (I)
The parser has detected a loop condition that was statically
evaluated to be FALSE. The condition is not considered during
processing and the loop statement (including all of its enclosed
statements) is effectively removed from the algorithm. Note that
this case is not considered to be an error, as for non-terminating
loops.
Boolean expression expected (I)
The parser has encountered a numeric expression when expecting
a boolean expression. A boolean expression is one that, when
evaluated, yields a logical result of TRUE or FALSE.
Numeric expression expected (I)
The parser has encountered a boolean expression when expecting a
numeric expression.

186

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Appendix 5: MathPack Syntax


This appendix describes the grammar and syntax of MathPack in
formal mathematical notation and details. It is presented here for those
who have the background and interest to explore MathPack more
deeply. It is NOT necessary to understand (or even read) this section to
become proficient as a MathPack user.
The syntax for MathPack algorithms is expressed as a set of grammar
rules. For each rule, there is a left hand side, a special meta-symbol
::= (read is represented by), and a right hand side. The left hand
side of a rule is called a non-terminal, while the right hand side may be
a combination of non-terminals, terminals, and literals.
Example:
Curve Name

Expression

PHIE = PHI + Vsh*PHIsh;


Non-terminal

Non-terminals, Terminals, and/or Literals

The table beginning on the following page lists the syntax rules that
you must adhere to when you generate a MathPack algorithm.
For example, the first rule states that
An algorithm is represented as an optional
declaration_list followed by a statement_list.

The second rule states that:


A declaration_list is represented as a declaration
followed by an optional declaration list

The next rule states that:


a declaration is represented by the reserved literal,
VARIABLE, followed by a symbol name, followed by a
semi-colon.

R2003.12.1

Building Algorithms with MathPack: Appendices

187

Reports and Utilities

Landmark

The following table describes MathPack syntax rules in a formal


format; the Modified BNF Format

Left Side

Meta
Symbol

Right Side

algorithm

::=

{declaration_list}
statement_list

declaration_list

::=

declaration
{declaration_list}

declaration

::=

VARIABLE id;

statement_list

::=

statement
statement_list |
EMPTY

statement

::=

assignment_statement|
if_statement
loop_statement|

assignment_statement

::=

CURVE_ID = expression;

if_statement

::=

if (condition) then
statement
statement_list
[else
statement;
statement_list]
end if;

condition

::=

expression

expression

::=

relation
relation and relation
relation or relation

relation

::=

simple_expression
simple_expression =
simple_expression!=
simple_expression <
simple_expression<=
simple_expression >
simple_expression>=

simple_expression

::=

term
term + simple_expression
term - simple_expression

term

::=

factor
factor * term
factor / term

188

Shared Utilities: Building Algorithms with MathPack

|
|

|
simple_expression|
simple_expression|
simple_expression|
simple_expression|
simple_expression|
simple_expression
|
|

|
|

R2003.12.1

Landmark Graphics Corporation

User Programming

Meta
Symbol

Left Side

Right Side

factor

::=

primary |
primary ^ primary

primary

::=

ID
CURVE_ID
REAL_LITERAL
INTEGER_LITERAL
BOOLEAN_LITERAL
NULL_LITERAL
function_call
(expression)

function_call

::=

abs
aco
asin
atan
cos
exp
cot
log
ln
mod
neg
random
sin
sqrt
tan

|
|
|
|
|
|
|

(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)|
(simple_expression)
(simple_expression |
(simple_expression)|
(simple_expression |
(simple_expression,
simple expression)|
(simple_expression) |
(min_value, max_value)
(simple_expression) |
(simple_expression) |
(simple_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
Meta-symbols have no meaning except to help define the grammar
itself. As such, meta symbols do not become a part of the algorithm
specification.The following meta-symbols are used in the grammar
rules:

R2003.12.1

Colon, Colon, Equal Sign (::=) is placed between the left and the
right hand side of a rule, and stands for is represented by.
Building Algorithms with MathPack: Appendices

189

Reports and Utilities

Landmark

Vertical bar (|) denotes variations in the rule, essentially meaning


OR, i.e., one part of the rule OR another (not both) may be applied.

Curly braces ({ }) denote part of a rule that may appear 0 or more


times, i.e., the part is optional and may be used repeatedly for the
rule.

Square brackets ([ ]) denote part of a rule that may appear 0 or 1


times, i.e., the part is optional but may be used only once for the
rule.

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

190

Representation

I
D

alphanum{alphanum | otherchar}

C
U
R
V
E
_I
D

alphanum{otherchar}

I
N
T
E
G
E
R
_
L
I
T
E
R
A
L

digit{digit}

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

Terminals

R2003.12.1

Representation

R
E
A
L
_
L
I
T
E
R
A
L

{digit}.digit{digit}

B
O
O
L
E
A
N
_
L
I
T
E
R
A
L

true | false

N
U
L
L
_
L
I
T
E
R
A
L

null

Building Algorithms with MathPack: Appendices

191

Reports and Utilities

Landmark

Terminals

192

Representation

al
p
h
a
n
u
m

a...z | A...Z | 0 ... 9

di
gi
t

0 ... 9

ot
h
er
c
h
ar

<any printable non-alphanumeric character>

V
A
R
I
A
B
L
E

symbol name

E
M
P
T
Y

<nothing>

Shared Utilities: Building Algorithms with MathPack

R2003.12.1

Landmark Graphics Corporation

User Programming

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.
Following is a list of reserved literals:
if
then
else
or
true
false
null
end
loop
variable

Other literals may represent numbers. For example:


1
0
0.0
1.2345
.12345

R2003.12.1

Building Algorithms with MathPack: Appendices

193

Landmark

New Features For PetroWorks

User Models

Introduction
User Models is a tool that allows everyone running PetroWorks out of
the PetroWorks home directory to see and run published user-written
models. When you select Interpret > User Models from the
PetroWorks Command Menu, the following screen appears:

If no models have been published, the Models field is empty. In the


sample window above, four published models appear: GOLD, Pebbles,
Slate, and Rubble. Note that the last three models appear under the
Group Title Bedrock Analysis. Group titles are for convenience
only and cannot be launched.
To launch a model, select it from the Models window and press the
Launch button.
To exit User Models, select File > Exit.
R2003.12.1

User Models

Landmark Graphics Corporation

User Programming

Publishing Your Model


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.
To find the user_models.dat file, look in the PetroWorks/dat
subdirectory under your platform subdirectory.
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.

Comments

Group Title
place holder

------------------------------------------------------------------------ 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.
----------------------------------------------------------------------<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.

In the default user_models.dat file shipped with PetroWorks, shown


above, is a sample Group Title called <Empty>||. This is used as a
place holder to let you know that as yet no models have been published.
When you are ready to publish a model, replace this entry with your
own models and group titles. (Group titles are optional.)
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.
R2003.12.1

User Models: Publishing Your Model

Landmark

New Features For PetroWorks

Each model or group occupies a single line. Each line contains three
fields separated by the vertical bar (|) character as a delimiter:
Model Title | Application Path | PPPDF Path

These three fields together, including delimiters, cannot exceed 256


characters.

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||

R2003.12.1

User Models

Landmark Graphics Corporation

User Programming

Below is an example of a Group Title (first line), Model Title,


Application Path, and PPPDF Path (second line):
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.
The following is an example of the user_models.dat file and four
published user models. Three of these are in a Model Group called
Bedrock Analysis:
-- 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:

R2003.12.1

eliminates blank lines and comments


checks remaining lines for proper format
verifies that the executable and pppdf files exist in the path you
specified
formats group titles and model titles for the User Models window
display.
displays the User Models window with your published model
displayed for selection.

User Models: Publishing Your Model

Landmark

New Features For PetroWorks

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.

R2003.12.1

User Models

10

Landmark Graphics Corporation

User Programming

Index

User Programming
g
B
building algorithms with MathPack 121-185
buttons
mouse
Button 1
clicking 5
press and drag 5
C
conventions
reference list 5
copying files in Model Builder 12, 25

Model Algorithm Code (or .mdl) 11


Model Data Specification (or .mds) 12
object 12
filtering in Model Builder 58
G
GNU
model debugger, FORTRAN compiler, C
compiler 82
H
highlighting or selecting
one word or value 5

D
debugging models 80
delimiters
in Model Builder 74
documentation
for OpenWorks 4
dragging
defined 5
E
error messages, see MathPack error messages
external library files
using 11, 76, 79
F
File
Model Builder options 16
files
copying existing MDS/MDL 12
library 12
log file for model processing 85
mdl 11
MDS 11
R2003.12.1

I
information messages 176
Introduction
PetroWorks and LogEdit documentation 2
introduction
conventions used in this user guide 5
K
keywords
in Model Builder 74
L
libraries 12
library 12
list of terminals 189
literals 192
log curves 12
log file
for model processing 85
presetting for depth-by-depth messages 85

Index

Landmark Graphics Corporation

User Programming

MathPack
algorithms used in Model Builder 11
MathPack error messages 176, 176-185
information messages 176
semantic errors 177
syntax errors 177
MDL file 11
MDS file 11
MDS files
editing 72
messages
model processing 85
meta-symbols 188
grammar rules 188
types of 188
Model Builder 7
delimiters 74
features of 8
files generated by 11
how it works 10
keywords 74
Main Menu 16
Model Group Directory 11
Opening, Launching 14
variables by category 43
Model Workspace 11
models
debugging your 80
sharing your 13
mouse buttons
selecting items with 5

pointing dispatcher
MathPack-specific instructions 134
press and drag
defined 5
project workspace
maintenance of 13
Model Builder 13

S
sample interval 133
shortcuts
double-clicking to select data 5
triple-clicking to highlight 5
status messages
model processing 85
T
terminals 189
definition of 189
U
User Programming 121-185
checklist 163
error messages 176
learning about MathPack syntax ??-192
literals 192
meta-symbols 188
non-terminals 188
pointing dispatcher 134
syntax rules 186-188
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

Vous aimerez peut-être aussi