Sei sulla pagina 1di 288

MSC.

Nastran
Toolkit User’s Guide
Version 200
Edited by Dale Layfield
March, 2002
Corporate
MSC.Software Corporation
2 MacArthur Place
Santa Ana, CA 92707 USA
Telephone: (800) 345-2078
Fax: (714) 784-4056

Europe
MSC.Software GmbH
Am Moosfeld 13
81829 Munich, Germany
Telephone: (49) (89) 43 19 87 0
Fax: (49) (89) 43 61 71 6

Asia Pacific
MSC.Software Japan Ltd.
Entsuji-Gadelius Building
2-39, Akasaka 5-chome
Minato-ku, Tokyo 107-0052, Japan
Telephone: (81) (3) 3505 0266
Fax: (81) (3) 3505 0914

Worldwide Web
www.mscsoftware.com

Disclaimer
MSC.Software Corporation reserves the right to make changes in specifications and other information
contained in this document without prior notice.
The concepts, methods, and examples presented in this text are for illustrative and educational purposes
only, and are not intended to be exhaustive or to apply to any particular engineering problem or design.
MSC.Software Corporation assumes no liability or responsibility to any person or company for direct or
indirect damages resulting from the use of any information contained herein.
User Documentation: Copyright 2002 MSC.Software Corporation. Printed in U.S.A. All Rights Reserved.
This notice shall be marked on any reproduction of this documentation, in whole or in part. Any
reproduction or distribution of this document, in whole or in part, without the prior written consent of
MSC.Software Corporation is prohibited.
MSC is a registered trademark of the MSC.Software Corporation. NASTRAN is a registered trademark of
the National Aeronautics and Space Administration. MSC.Nastran is an enhanced proprietary version
developed and maintained by MSC.Software Corporation. MSC. and MSC.Patran are trademarks of
MSC.Software Corporation.
All other trademarks are the property of their respective owners.
NATK*V2002*Z*Z*Z*DC-USR
C O N T E N T S
MSC.Nastran Toolkit User’s Guide

Preface ■ About this Book, vi


❑ Overview, vi

■ List of MSC.Nastran Books, vii


■ Technical Support, viii
■ Internet Resources, xi
■ Permission to Copy and Distribute MSC Documentation, xiii

1
Introduction ■ Features, 16
■ Applications, 18
■ Delivery Contents, 20

2
Using the ■ Frequently Asked Questions, 22
MSC.Nastran
■ Limitations, 27
Toolkit
■ References, 28
■ API Syntax, 29

3
Executive System ■ Starting the MSC.Nastran Server, 32
APIs ■ Stopping the MSC.Nastran Server, 33
■ Setting DMAP Breakpoints, 34
■ Submitting Additional MSC.Nastran Input Files, 35
■ Re-connecting a Child Process to a Parent's Client-server
Connection, 36
■ Setting Client and Server Timeout Limits, 37
■ Executive APIs, 38
4
Database Features ■ Retrieve Data From a Previous Run, 80
and APIs
■ Database Utilities, 84

5
File I/O APIs ■ GINO, 120
■ General I/O Utilities, 123

6
Table I/O APIs ■ Table APIs, 138

7
Matrix I/O APIs ■ Matrix APIs, 154

8
Direct Access I/O ■ Grid Direct Access API's, 176
APIs ■ Element Connectivity and Property Recovery API (IFP API's), 183
■ Summary of How to Use the IFP API's, 185
■ Data Recovery API's (OFP Type Datablocks), 191

A
MSC.Nastran ■ Datablock Information, 222
Datablocks ❑ Datablock Basics, 222
Tutorial ❑ Datablock Structure and Composition, 222
❑ Datablock Pseudonyms, 223
❑ Textural Descriptions, 223
❑ Inter-version Changes, 224
❑ Helpful Hints, 224

■ Output Style Blocks, 227


■ Approach Codes, 230
■ Stress Codes, 231
■ Did a Block Change?, 233
■ TABPRT, 234
■ SEDRCVR, 235
■ DBLOCATE and Restart, 237

B
MSC.Nastran
Database Features

C
Java Language ■ This Appendix Contains the Java Interface descriptions for the
Bindings MSC.Nastran Toolkit API., 246
■ Executive System, 247
■ Database, 251
■ File I/O:, 252
■ Table I/O:, 255
■ Matrix I/O:, 257
■ Direct Access I/O:, 259

D
List of API Error
Codes

E
Toolkit Compile ■ Makefiles, 268
and Link
Instructions

F
Utility Functions - GetArgument, 272
- OpenLogFile, 272
- PrintMessage, 272

G
Example Toolkit ■ Toolkit Code Librarian, 276
Client Applications
H
Subindex ■ Appendix H: Subindex Description, 278
Description
Preface

■ About this Book

■ List of MSC.Nastran Books


■ Technical Support

■ Internet Resources
■ Permission to Copy and Distribute MSC Documentation
vi

About this Book


The MSC.Nastran Toolkit User's Guide describes the function of each Toolkit
Application Programming Interface (API).

Overview
The MSC.Nastran Toolkit provides the necessary tools (Application Programming
Interfaces) to write customized stand-alone applications that can communicate with
the MSC.Nastran program using client-server technology. The Toolkit provides the
mechanism to create stand-alone applications that can access all of MSC.Nastran's
functionality/components (i.e., matrix operations, utilities, engineering (FE)
functions, and database management system) and incorporate these into a modern
software framework. This framework facilitates multi-tier architectures, Web-enabled
applications, and the distribution of MSC.Nastran's functionality across different host
computers.

User-Written MSC.Nastran
Client Program Executable

Database
API

API
MSC-Supplied
MSC.Nastran
Client Object
DMAP Library
Library
CHAPTER vii
Preface

List of MSC.Nastran Books


Below is a list of some of the MSC.Nastran documents. You may order any of these
documents from the MSC.Software BooksMart site at www.engineering-e.com.

Installation and Release Guides


❏ Installation and Operations Guide
❏ Release Guide

Reference Books
❏ Quick Reference Guide
❏ DMAP Programmer’s Guide
❏ Reference Manual

User’s Guides
❏ Getting Started
❏ Linear Static Analysis
❏ Basic Dynamic Analysis
❏ Advanced Dynamic Analysis
❏ Design Sensitivity and Optimization
❏ Thermal Analysis
❏ Numerical Methods
❏ Aeroelastic Analysis
❏ User Modifiable
❏ Toolkit
viii
CHAPTER ix
Preface

Technical Support
For help with installing or using an MSC.Software product, contact your local
technical support services. Our technical support provides the following services:
• Resolution of installation problems
• Advice on specific analysis capabilities
• Advice on modeling techniques
• Resolution of specific analysis problems (e.g., fatal messages)
• Verification of code error.
If you have concerns about an analysis, we suggest that you contact us at an early
stage.
You can reach technical support services on the web, by telephone, or e-mail:

Web Go to the MSC.Software website at www.mscsoftware.com, and click on Support.


Here, you can find a wide variety of support resources including application
examples, technical application notes, available training courses, and documentation
updates at the MSC.Software Training, Technical Support, and Documentation web
page.
Phone United States Frimley, Camberley
and Telephone: (800) 732-7284 Surrey, United Kingdom
Fax Fax: (714) 784-4343 Telephone: (44) (1276) 67 10 00
Fax: (44) (1276) 69 11 11

Munich, Germany Tokyo, Japan


Telephone: (49) (89) 43 19 87 0 Telephone: (81) (3) 3505 02 66
Fax: (49) (89) 43 61 71 6 Fax: (81) (3) 3505 09 14

Rome, Italy Paris, France


Telephone: (390) (6) 5 91 64 50 Telephone: (33) (1) 69 36 69 36
Fax: (390) (6) 5 91 25 05 Fax: (33) (1) 69 36 45 17

Moscow, Russia Gouda, The Netherlands


Telephone: (7) (095) 236 6177 Telephone: (31) (18) 2543700
Fax: (7) (095) 236 9762 Fax: (31) (18) 2543707

Madrid, Spain
Telephone: (34) (91) 5560919
Fax: (34) (91) 5567280

Email Send a detailed description of the problem to the email address below that
corresponds to the product you are using. You should receive an acknowledgement
x

that your message was received, followed by an email from one of our Technical
Support Engineers.

MSC.Patran Support mscpatran.support@mscsoftware.com


MSC.Nastran Support mscnastran.support@mscsoftware.com
MSC.Nastran for Windows Support vn4w.support@mscsoftware.com
MSC.visualNastran Desktop 2D Support vn2d.support@mscsoftware.com
MSC.visualNastran Desktop 4D Support vndesktop.support@mscsoftware.com
MSC.Abaqus Support mscabaqus.support@mscsoftware.com
MSC.Dytran Support mscdytran.support@mscsoftware.com
MSC.Fatigue Support mscfatigue.support@mscsoftware.com
MSC.Interactive Physics Support ip.support@mscsoftware.com
MSC.Marc Support mscmarc.support@mscsoftware.com
MSC.Mvision Support mscmvision.support@mscsoftware.com
MSC.SuperForge Support mscsuperforge.support@mscsoftware.com
MSC Institute Course Information msctraining.support@mscsoftware.com

Training
The MSC Institute of Technology is the world's largest global supplier of
CAD/CAM/CAE/PDM training products and services for the product design,
analysis and manufacturing market. We offer over 100 courses through a global
network of education centers. The Institute is uniquely positioned to optimize your
investment in design and simulation software tools.
Our industry experienced expert staff is available to customize our course offerings to
meet your unique training requirements. For the most effective training, The Institute
also offers many of our courses at our customer's facilities.
The MSC Institute of Technology is located at:
2 MacArthur Place
Santa Ana, CA 92707
Phone: (800) 732-7211
Fax: (714) 784-4028
The Institute maintains state-of-the-art classroom facilities and individual computer
graphics laboratories at training centers throughout the world. All of our courses
emphasize hands-on computer laboratory work to facility skills development.
We specialize in customized training based on our evaluation of your design and
simulation processes, which yields courses that are geared to your business.
In addition to traditional instructor-led classes, we also offer video and DVD courses,
interactive multimedia training, web-based training, and a specialized instructor's
program.
CHAPTER xi
Preface

Course Information and Registration. For detailed course descriptions, schedule


information, and registration call the Training Specialist at (800) 732-7211 or visit
www.mscsoftware.com.
xii

Internet Resources
MSC.Software (www.mscsoftware.com)
MSC.Software corporate site with information on the latest events, products and
services for the CAD/CAE/CAM marketplace.

Simulation Center (simulate.engineering-e.com)


Simulate Online. The Simulation Center provides all your simulation, FEA, and other
engineering tools over the Internet.

Engineering-e.com (www.engineering-e.com)
Engineering-e.com is the first virtual marketplace where clients can find engineering
expertise, and engineers can find the goods and services they need to do their job

MSC.Linux (www.mscsoftware.com/hpc)
Now with almost 40-years of unparalleled experience in scientific and technical
computing, MSC.Software is leveraging this knowledge to deliver its customers state-
of-the-art, high performance computing solutions based on clustered computing for
running engineering and life sciences applications.

CATIASOURCE (plm.mscsoftware.com)
Your SOURCE for Total Product Lifecycle Management Solutions.

Process Architecture Lab (PAL) (pal.mscsoftware.com/services/pal)


PAL is a virtual product development environment that enables PAL participants and
customers to define, validate, and demonstrate advanced tools, processes, and e-
business solutions.
CHAPTER xiii
Preface
xiv
CHAPTER xv
Preface

Permission to Copy and Distribute MSC Documentation


If you wish to make copies of this documentation for distribution to co-workers,
complete this form and send it to MSC.Software Corporation. MSC will grant written
permission if the following conditions are met:
• All copyright notices must be included on all copies.
• Copies may be made only for fellow employees.
• No copies of this manual, or excerpts thereof, will be given to anyone who is
not an employee of the requesting company.

Please complete and mail to MSC for approval:


MSC.Software Corporation
Attention: Legal Department
2 MacArthur Place
Santa Ana, CA 92707

Name: ____________________________________________________________

Title: ______________________________________________________________

Company: _________________________________________________________
Address: __________________________________________________________

__________________________________________________________________
Telephone:_________________Email: __________________________________

Signature:______________________________ Date:______________________

Please do not write below this line.

APPROVED: MSC.Software Corporation

Name: ____________________________________________________________

Title: ______________________________________________________________

Signature:______________________________ Date:______________________
xvi

Fold here

_______________________
_______________________ Place
Stamp
_______________________ Here

MSC.Software Corporation
Attention: Legal Department
2 MacArthur Place
Santa Ana, CA 92707

Fold here
MSC.Nastran Toolkit User’s Guide

CHAPTER
Introduction
1
■ Features

■ Applications
■ Delivery Contents
16

1.1 Features
The MSC.Nastran Toolkit provides the following capabilities.
• Programmatic interface to MSC.Nastran using client-server technology.
• The ability to invoke any MSC.Nastran Module using standard DMAP
and/or MSC.Nastran Solution Sequences.
• A dynamic link option when remote node and/or multiple server access is
not required.
• Full access to the MSC.Nastran database (e.g., queries, datablock creation,
including read/write/pack/unpack access for both MSC.Nastran tables and
matrices).
• C, FORTRAN and Java language bindings.
• A single MSC.Nastran executable that can be invoked by either the
traditional batch method (i.e., command line invocation) or by the new
client-server connection.
• The ability to link client created programs and the Toolkit.
• Communication between a single client program and multiple MSC.Nastran
analysis runs and their databases.
• The ability to communicate across heterogeneous (nonbinary compatible)
platforms.
• Full client-side access to MSC.Nastran error messages.
• Element/grid level direct (keyed) access to datebooks (e.g., property data,
connectivity data, stress, strain, force, displacements, etc.).
• A select API, similar to a database ‘projection’ and ‘where’ capability
(e.g., select (ekey, sx1 ) where (ekey=10 and sx1<1.0E03) relation(
record=‘quad4’)).
• A specialized client-server API that allows client-server communication and
data transfer at any point within a DMAP Solution Sequence (comparable to
an interactive language debugger).
Based on the above features, the Toolkit can now serve as a replacement or better
alternative for prior MSC.Nastran data access methods, such as xdb, Input2/Output4,
the ISHELL module, and even User-Modifiable MSC.Nastran.
CHAPTER 1 17
Introduction

Toolkit
MSC.Nastran
(Communicates at 3 Levels)

Exec Control

User DMAP 1. Input Data

Bulk Data

2. DMAP – Level Communication


DMAP (e.g., insert DMAP breakpoints)

3. Direct Database Access


(e.g., read/write/update, dynamic datablock
creation, query database schema API’s,
Database sequential I/O or direct access I/O using
indexes, automatic binary-to-neutral I/O
conversions using XDR functions)

Figure 1-1 MSC.Nastran Toolkit Interfaces


18

1.2 Applications
The Toolkit is currently being used with various MSC.Software products, including
MSC.FlightLoads and MSC.Ultima. It has changed the way new products are being
designed within MSC.Software by providing developers with new robust
development tools that provide direct client-server access to MSC.Nastran.

The Toolkit is the enabling technology behind the new MSC.Nastran Java-based data
browser; an application that demonstrates the Toolkit’s ability to provide the
necessary framework for architecting multi-tier applications.

T ypical U sageScenario
Typical Usage Scenario (3-tier
(3-tier Architecture)

Tier-3

M SC.P atran

W eb Toolkit Toolkit M SC.N astran


Interface Interfaces
(W rappers)

Or Others…

CORBA/RM I M SC’s M iddlew are


or others.. (pipes,sockets-rsh… )

The Toolkit makes it possible to construct client applications that perform calculation-
on-the-fly. This is possible through the Toolkit’s ability to interact with MSC.Nastran
at both the input file level as well as the database/executive system level. Multiple
input files (bdf’s) and their associated DMAP sequences can be submitted
interactively during one client session with the resultant module output (datablocks)
being immediately accessible for reading by the client application. In addition, a
Toolkit-enabled client program can interact with multiple servers (MSC.Nastran) that
can reside on the same or different machines.
CHAPTER 1 19
Introduction

A single Toolkit client program controlling multiple servers/machines with each


server receiving multiple input files (bdf’s)

MSC.Nastran Servers
Case Control SET+....
FMS DBLOCATE

API
Toolkit Client Program
DMAP IFP1
BDF SDR2
User-Written Stress data
Client Program
Case Control SET+....
Begin loop: BDF Stress data
FMS DBLOCATE

API
API

...Send BDF with


DMAP IFP1
new Case Control
SDR2
element stress BDF
requests... Stress data
Loop back: Case Control SET+....
FMS DBLOCATE

API
DMAP IFP1
TCP/IP SDR2
protocol
(pipes/sockets)

Figure 1-2 Example of “On-the-fly” Data Recovery


20

1.3 Delivery Contents


The following items are included in the delivery content of the MSC.Nastran Toolkit.
• libclient
The client object library containing the MSC.Nastran Toolkit API's defined in
this document and the associated Inter Process Communication (IPC)
middleware that provides the client-server connection to the MSC.Nastran
program.
• makefile
The makefile for compiling/linking client applications. Examples of Toolkit
makefiles for various platforms is listed in Toolkit Compile and Link
Instructions (App. E). See also Note 1 below.
• Example client programs
Example client programs that demonstrate the use of the various
MSC.Nastran Toolkit API's. (See Note 2 below.)

Notes: 1. As part of a Toolkit training class offered by MSC.Software students are taught
how to build Toolkit client programs using various build environments,
including Microsoft's Visual C++ and Compaq's Visual Fortran development
environments. For more details on the MSC.Nastran Toolkit Training Class
contact MSC.Software.
2. The Toolkit Code Librarian (a Toolkit code-example help system) described in
Chapter 2, Section 2.3 is included as part of the MSC.Nastran Toolkit delivery.
3. In addition to the above Toolkit related components the standard MSC.Nastran
system must be available for access by the Toolkit client program.
MSC.Nastran Toolkit User’s Guide

CHAPTER
Using the MSC.Nastran Toolkit
2
■ Frequently Asked Questions

■ Limitations
■ References

■ API Syntax
22

2.1 Frequently Asked Questions


Is it difficult to write applications with the Toolkit?
It depends on what you are trying to accomplish, but basically there are three ways to
compare the difficulty of using the Toolkit:
• The first is to liken it to writing new modules within MSC.Nastran (i.e., for
certain Toolkit applications you will need to understand MSC.Nastran in
order to write your code since you will be utilizing DMAP modules,
datablocks, and the MSC.Nastran database).
• The second, preferred way, is to take advantage of our plan to develop
libraries of reusable Toolkit components that become available to every
Toolkit developer—this library of reusable components would be analogous
to MSC.Nastran's DMAP solution sequences.
Note that the Toolkit Code librarian Help System discussed earlier is one
example of providing reusable components.
• And finally, another perspective on the issue of relative complexity is that
there are applications you could not develop before the Toolkit became
available (e.g., Web-based interactive data recovery applications that require
JAVA or some other Web-based interface that employs the latest distributed
component technology).

What’s the history of the Toolkit?


The development of MSC.Nastran’s Client-Server Technology began in 1992:
• 1992 – INAST68 Interactive Database Debugging Tool (an initial
demonstration of a client-server connection to MSC.Nastran).
Followed by:
• External Geometry Evaluator, which used an expanded and
enhanced version of the prior debugging tool.
• The External Beam Library.
• The NIF-reader, which uses a variation of the present Toolkit
technology for the Patran-Nastran client-server bulk data reader.
• 1997 – Current general purpose Toolkit developed.
Does the Toolkit use CORBA?
Not directly. However, the typical three-tier architecture diagram at the beginning of
this guide shows how CORBA, COM, RMI or any other distributed object technology
can be utilized within the current Toolkit architecture. In fact, MSC.Nastran's Java-
based Toolkit Data Browser Application demonstrates this capability by being RMI-
enabled.
CHAPTER 2 23
Using the MSC.Nastran Toolkit

How does the Toolkit compare with MSC.Nastran’s various data access
mechanisms?
(NASTPAT3, the NIF-Reader, MSC.Patran’s Direct Results Access that uses .xdb files,
Input2/Output4, the ISHELL module and User-Modifiable MSC.Nastran)
This is perhaps one of the most important questions about the Toolkit. The short
answer is that the Toolkit can now serve as a replacement or better alternative for all
these mechanisms. The reason why this is so important is because we now have a tool
that can reduce the proliferation of these various data access mechanisms and their
high-support costs. Note that the support/maintenance costs are high, not due to
deficiencies in the design of these programs, but rather because of the inherent
complexity of the data they are required to process.
To better understand the goal of using the Toolkit to replace these mechanisms here is
a brief description of each of them in relationship to the Toolkit:
• NASTPAT3
Description: Reads MSC.Nastran data (via Output2 files) and then maps this
into the MSC.Patran database.
Toolkit Usage: The Toolkit replaces the need for duplication of data through
intermediate Output2 files—with the Toolkit, the same data can be read
directly from the MSC.Nastran database.
• NIF-Reader
Description: Uses a "pre-Toolkit" client-server mechanism to allow M
submit bulk data files to MSC.Nastran for processing. The resultant
processed and verified "input file" is then read back into MSC.Patran from
the MSC.Nastran database.
Toolkit Usage: This represents an example of older "pre-Toolkit" technology
that can now be replaced with the MSC.Nastran Toolkit and its efficient,
standardized, and "easier-to-use" mechanism for directly accessing the
MSC.Nastran database.
• MSC.Patran’s DRA (that uses .xdb files)
Description: Currently the DRA accesses .xdb files created by a special
module within MSC.Nastran. These files are created by converting existing
MSC.Nastran datablocks into special direct access files (.xdb files).
Toolkit Usage: The DRA data access engine can now be replaced with an
approach that provides the benefit of direct MSC.Nastran database access,
the elimination of duplicate data (i.e., no xdb files), and the elimination of
additional maintenance support for the database management system that
supports the .xdb file format.
• Output2/Output4 files
Description: An unformatted or formatted file (sequential access only) that
provides a FORTRAN readable copy of data on the MSC.Nastran database.
24

Toolkit Usage: The Toolkit provides an obvious alternative to these


FORTRAN files by allowing direct access to the same data, without copies,
using the MSC.Nastran database. It has the additional advantage of retaining
the database qualification (keys) associated with the data.
• ISHELL module
Description: ISHELL allows execution of an external program from within
the MSC.Nastran environment. MSC.Nastran remains in a wait state until
the external program has completed. Note that unlike the Toolkit, the
external program started by the ISHELL module cannot access the
MSC.Nastran database or communicate directly with the MSC.Nastran
program.
An example of its usage might go as follows: The user applies a DMAP Alter
to have ISHELL execute within a DMAP sequence—upon executing the
ISHELL module it would then spawn a user-supplied external program
who’s function could be to read an output2 or output4 formatted FORTRAN
file created in the current run. It could then use this data to write another
output2 or output4 formatted file and then return to the main MSC.Nastran
execution sequence. The DMAP can now access the newly created output2
or output4 file just created by the external program.
Toolkit Usage: Using the above example, the Toolkit can provide the same
function using the following Toolkit API features:
1. The setting of a breakpoint at any DMAP statement.
2. The ability to read or write datablocks at this breakpoint.
3. The ability to allow the DMAP to continue to completion.
4. Or repeat the process by starting again at step 1.
• User-Modifiable MSC.Nastran:
Description: User-Modifiable MSC.Nastran allows user's to add their own
features or modifications to MSC.Nastran. This capability is possible for
those users who have requested the user modifiable version of MSC.Nastran.
User Modifiable MSC.Nastran is intended for those users who have a good
working knowledge of FORTRAN and have experience in programming on
large-scale systems. (For more details you can request a copy of the User
Modifiable MSC.Nastran User's Guide).
Toolkit Usage: The Toolkit provides an alternative approach to using User
Modifiable MSC.Nastran. In certain applications the developer might find it
easier to create a Toolkit application that interacts with the MSC.Nastran
program. For example, the application developer might need to 1) Read
existing tables and/or matrices, 2) Perform specific numerical calculations
on this data, and 3) conclude by writing new or updating existing tables
and/or matrices onto the MSC.Nastran database. Steps 1 through 3 might
be repeated at selected points during the MSC.Nastran execution sequence.
CHAPTER 2 25
Using the MSC.Nastran Toolkit

All these operations are similar to the functions of a typical DMAP module.
With the Toolkit they can now also be done with the added convenience of
not having to modify the MSC.Nastran program. The current limitation is
that not all MSC.Nastran utility routines (e.g., memory management
utilities, finite element utilities, and other useful functions for the
implementation of structural element code) are available to the Toolkit
client program.

What is the size of the Toolkit client object library?


Approximately 400k. This is the current NT object library size.

Does the Toolkit work with scripting languages like perl or phyton?
Although the first release of the Toolkit product will limit the supported language
bindings to FORTRAN, C and Java we have found that adding additional languages
bindings is a relatively straightforward process. In fact, we currently have a beta-
version of a Perl language interface to the Toolkit and we are considering adding
additional language bindings in the future. If you are interested in Perl or some other
language binding please contact MSC.Software.

What future enhancements are planned for the Toolkit?


Enhancements are ongoing and are driven by both customer feedback and a
continuing emphasis on ease-of-use improvements.

What kind of database functionality does the Toolkit provide?


Since the Toolkit provides full-access to all the capabilities of the MSC.Nastran
database, the following list describes some of the important MSC.Nastran database
features. (See MSC.Nastran Database Features (App. B) for more detailed
descriptions.)
• Optimized (Machine specific) file access techniques.
• Qualified Datablocks ("keys" can be characters integers, or real values).
• SQL-like data retrieval using the above keys.
• Datablock equivalencing (ie., alias names).
• Data Definition’s for datablocks
(Referred to as the NDDL—MSC.Nastran’s Data Definition Language)
• Flexible I/O utilities, such as the ZREAD API (a utility that returns value(s),
data types and labels for all data described on the database).
• Each Database consists of DBSETS. A DBSET is a logical user-definable
grouping of physical files that allows for large file allocation as well as
flexible distribution of allocated space across separate physical storage
units—datablocks can span physical files within a DBSET (see diagram in
MSC.Nastran Database Features (App. B)).
26

• RAM DISK (available on Scratch DBSET).


• Buffer cache (used by all DBSETs).
• DBSETs can be off-line (if not referenced).
• Automatic checkpointing of DBSET changes.
• Datablocks can be located on any DBSET.
• The database reuses released blocks to reduce high-water mark.
• Database is expandable on restarts.
• Automatic physical file tracking provides automated file attachments, and
Database vs. physical file verification.
• Efficient and flexible I/O utilities:
• Read/write of partial records within a datablock (table or matrix)
• Access of data, its type and its label.
• Indexed matrices using optimized storage techniques.
• “Direct Access” positioning within datablocks (64 bit addressing).
• Utilities for accessing our new indexed (keyed) IFP and OFP data
blocks (eg., geom1,geom2... and stress, strain, force, displacement
datablocks).
CHAPTER 2 27
Using the MSC.Nastran Toolkit

2.2 Limitations
The client program may “hang” and not return from the NServer_Start API if there are
certain basic errors related to the MSC.Nastran installation. You can verify if you will
encounter any of these errors by running a simple standalone MSC.Nastran job, such
as <install-dir>/msc2001/nast/instest. The error messages generated from this test
run will also be generated when using the MSC.Nastran Toolkit.
28

2.3 References
The following reference material is suggested for the developer responsible for
writing code that will use the API described in this document.
1. User Modifiable MSC.Nastran User's Guide
Many of the I/O API’s dealing with access to MSC.Nastran datablocks
(tables/matrices) are modeled after those already used within the
MSC.Nastran application modules. Thus, API's dealing with open, read,
write trailers, etc. can be better understood by studying the corresponding
I/O utility subroutines described in the User Modifiable MSC.Nastran User's
Guide.
2. MSC.Nastran Datablocks and DMAP Modules
This is an essential document for understanding MSC.Nastran data (tables
and matrices) and the DMAP modules that generate them.
3. Example Toolkit Client Programs
Since examples are often the best way to understand an API, MSC.Software
provides a series of example client programs as part of a Toolkit Code
Librarian Help System.

Figure 2-1 MSC.Nastran Toolkit Code Librarian


CHAPTER 2 29
Using the MSC.Nastran Toolkit

2.4 API Syntax


The format of an API function is:
For C:

int NServer_xxxx

( char *GrpName , arguments ,


INTEGER *Error );

For Fortran:
Call NSxxxx (GrpName, ...arguments..., Error)
For Java:

xxxxReturns yyy = NServer_xxxx (GrpName, ...input arguments only...) See


Appendix C for details.

The GrpName argument:


All API’s have as their first argument “GrpName.” This is a user-defined handle used
to associate the API call with a specific server. It can be any string value. For example,
if the API NServer_Start is called to make a server connection and uses
“GrpName=my_server” then all subsequent API calls that will be communicating with
this server should also use this name “my_server.” Since multiple server connections
can be established within one Toolkit application (i.e., via multiple calls to the
NServer_Start API) the Toolkit application can switch between these servers by
simply referring to the appropriate GrpName value when calling an API.
Error Return:
The Error return value for all MSC.Nastran Toolkit functions is the value returned in
the Error parameter. This value is also the function return value for C. This method of
providing access to the Error flag from both the function parameters or from the
function return value provides two advantages:
• The FORTRAN and C calling sequences are similar and thus easier to
document and describe.
• The C programmer has more coding style flexibility in handling Error return
values.
Note: Appendix D has a list of possible API error codes.
The following is an example of how the first API, NServer_Start, can be called from
FORTRAN or C.
From FORTRAN:
30

CHARACTER*255 COMLINE,GRPNAME,NASTPTH
INTEGER Error
GRPNAME = `ServerName`
COMLINE = ‘my_job.dat scr=yes mem=8mb`
NASTPTH = `nastran`
CALL NSSTART(GRPNAME,COMLINE,NASTPTH,ERROR)

From C:
int error; /* function return value */
INTEGER Error; /* same as function return value but as an argument */
char GrpName[] ={"ServerName"}; /* Define a name for the Server */
/* MSC.Nastran command line arguments */
char CommandLine[] ={"my_job.dat scr=yes mem=8mb"};
char NastPath[] ={"nastran"}; /* MSC.Nastran executable*/
error = NServer_Start(GrpName,CommandLine,NastPath,&Error);
MSC.Nastran Toolkit User’s Guide

CHAPTER
Executive System APIs
3
■ Starting the MSC.Nastran Server

■ Stopping the MSC.Nastran Server


■ Setting DMAP Breakpoints

■ Submitting Additional MSC.Nastran Input Files


■ Re-connecting a Child Process to a Parent's Client-server
Connection
■ Setting Client and Server Timeout Limits

■ Executive APIs

This section describes the Toolkit API's necessary for handling executive system
operations. This class of API's provides the functions necessary to: 1) start the
MSC.Nastran executable and execute DMAP Solution sequences, 2) set DMAP
breakpoints, 3) read Toolkit error messages generated by the Toolkit middleware
and/or by the MSC.Nastran program, 4) set time-out limits for the client and server
processes, 5) submit additional MSC.Nastran input files (bdf's), and 6) provide the
option of allowing a separate process to connect to an existing client-server connection
to the MSC.Nastran server.
32

3.1 Starting the MSC.Nastran Server


One of the first tasks of any Toolkit Client program is to establish a connection with
MSC.Nastran. Unlike the traditional batch invocation of MSC.Nastran, a Toolkit
Client program controls the execution using three API functions.
• The first API, NServer_Start, invokes the MSC.Nastran program similar to
the standard batch command line method. It differs from the batch method
in that the Toolkit invoked MSC.Nastran waits for a signal from the client
program before beginning the actual execution of the DMAP solutions
sequence.
• The second API, NServer_SolExeN, sends a signal to MSC.Nastran telling
it to start the execution (i.e., start the DMAP compile/link operation
followed by execution of the DMAP Solution Sequence).
• The third API, NServer_ExeStatus, can be called at any time in the client
program after NServer_SolExeN in order to check if the currently executing
DMAP solution sequence has completed—this API provides the option of
either waiting until the server completes (i.e., client program goes into a wait
state) or returning control to the client program (i.e., the client program can
call NServer_ExeStatus again at a later time while it continues client-side
only processing).
Note that the client program can start multiple MSC.Nastran servers by calling the
above series of API's for each required connection. These servers can reside on the
same or different machines than the client program.
CHAPTER 3 33
Executive System APIs

3.2 Stopping the MSC.Nastran Server


Once the Toolkit Client program is done interfacing with the MSC.Nastran server it
can call NServer_Exit to request that the client be disconnected from the server and
that the server perform the standard MSC.Nastran database shutdown and exit
process (i.e., the same exit process used by the standard batch version of
MSC.Nastran).
34

3.3 Setting DMAP Breakpoints


A specialized set of Toolkit APIs provide client-server communication and data
transfer at any point within a DMAP Solution Sequence. This feature is comparable to
an interactive language debugger. One or more DMAP breakpoints can be set prior to
starting the DMAP execution (i.e., before NServer_SolExeN). The SetExeBreak API
has options for requesting a breakpoint at every DMAP statement or only at those
statements specifically referenced by Subdmap name and/or DMAP name and/or
DMAP line number. An alternate method to using SetExeBreak for setting
breakpoints is to include special HALT //$ statements at the desired breakpoint
location in the DMAP solution sequence.
CHAPTER 3 35
Executive System APIs

3.4 Submitting Additional MSC.Nastran Input Files


The Toolkit provides an API for submitting multiple input files, including DMAP
solution sequences, during one invocation of the client-server Toolkit program. In
other words, you can submit an initial input file via the NServer_Start API and then
when this analysis run is complete you can submit additional input files via the
Toolkit API NServer_Input. These additional input files will run within the same
database as established by the initial NServer_Start call.
36

3.5 Re-connecting a Child Process to a Parent's Client-


server Connection
A typical Toolkit client program is structured such that the client-server connection is
established in the main process (i.e., a call to NServer_Start). After this, a client
program may wish to start a separate child process to perform some part of the
processing using a separate program. Typically, since this is a separate process it
would not be able to utilize the parent's client-server connection previously
established by NServer_Start. However, the Toolkit provides a set of re-connection
API's that allows this connection to be re-established by a separate child process. The
child process can then continue communicating with the server using all the standard
Toolkit API's. Upon returning from the child process the parent process continues to
retain its previous client-server connection(s).
CHAPTER 3 37
Executive System APIs

3.6 Setting Client and Server Timeout Limits


The Toolkit provides two functions for setting limits on the amount of time the client
and/or server should wait for a response before returning from an API call. For
example, if the client program makes an API call which waits for a server response
(e.g., reading data (using NServer_ReadRecord) from a server-side datablock) and the
server crashes during the process of reading the data then the NServer_ReadRecord
will return control to the calling program after a specified default client timeout
period--Note: On certain platforms control may return immediately upon a crash,
independent of any timeouts settings made by these API calls. This also applies to the
server in the case where the client crashes while the server is waiting for a response.
If these default wait times set for the client and server are not sufficient for a particular
application then the client program has the ability to set these limits using
NServer_SetServerTimeout and NServer_SetClientTimeout.
38

3.7 Executive APIs


NServer_Start – Start the MSC.Nastran Server
From FORTRAN:
CALL NSSTART (...)
From C:
int NServer_Start
( char *GrpName , char *CommandLine , char *NastPath,
INTEGER *Error );

Purpose. Interface call to start the MSC.Nastran Server. This will invoke the
MSC.Nastran command program to perform the required start-up procedures
necessary for the server (MSC.Nastran) invocation.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


This identifier must be provided in subsequent API calls in
order to communicate to a desired server. (Max. 256 chars.)
CommandLine INPUT MSC.Nastran Command Line. (Max 1025)
NastPath INPUT Full path name to the executable shell script. (Max. 1025)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Notes.
1. Other than the client-server communication required in this environment,
the command program will perform the same function as it does for the
batch (non-client-server) invocation of MSC.Nastran (e.g., input file
verification, control file creation, and file cleanup upon MSC.Nastran job
completion).
2. All subsequent communications between the client and the command
program and/or the MSC.Nastran program will be through the established
Inter-Process Communication (IPC) connection (i.e., sockets/rsh, or pipes).
3. The Command Line accepts the same keywords that MSC.Nastran allows for
the batch (non-client-server) invocation method (see MSC.Nastran’s Quick
Reference Guide (QRG) for a description of these keywords).
CHAPTER 3 39
Executive System APIs

Examples. These examples demonstrate how to invoke the MSC.Nastran server.

/*
* Program Example1c.c
*
* Purpose:
*
* Demonstrates how to:
* (1) start MSC.Nastran
* (2) execute a DMAP solution sequence
* (3) stop Msc.Nastran
*
* Usage:
* ./Example1c <nastran command program> <nastran command keywords>
* e.g., ./Example1c `which nastran` example1 scr=mini mem=10m out=example1c
*
* Method:
* * The necessary Toolkit startup information is passed as
* program arguments to example1c.
*
* It uses/generates the following files:
* example1.dat: input to NASTRAN server :
* example1c.prt: output from this program
* example1c.f04, example1c.f06: output from NASTRAN server
*
* Toolit API's Called:
*
* NServer_Start
* NServer_SolExeN
* NServer_ExeStatus
* NServer_Exit
*
* Utility functions Called:
*
* GetArgument
* OpenLogFile
* PrintMessage
*
*
*/

#include <stdio.h>
#include <string.h>
#include "nsapilib.h"

static FILE *LOGFILE = stderr;

void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);

void OpenLogFile( char *CommandLine );

void PrintMessage (char *GrpName, FILE *fp, char *ApiName);

main(int argc, char *argv[])


{
char GrpName[257];
char NastPath[1025];
char CommandLine[1025];
40

INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;
INTEGER Filept=0,Nmatch=0,Trailer[7];

char SubDmap[9], Dmap[9];


INTEGER Dmpseqnum=0, Nbreak=0, ibreak;
INTEGER InitFlag, WaitMode=0, ExeStatus=0, Ndatablk=0, Nparam=0;
INTEGER GEOM1Filept;

char ApiName[82]= {"main_program_at_exit" };

int i=0;

/************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
************************************************************************
*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);

(void) OpenLogFile( CommandLine );

/************************************************************************
*
* Step 2: Initilize the server
*
************************************************************************
*/
(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);

(void) fprintf(LOGFILE," >>> NServer_Start GrpName=%s\n"


" CommandLine=%s\n"
" NastPath=%s\n"
" Error=%d\n",
GrpName,CommandLine,NastPath,Error);

if( Error ) {
strcpy( ApiName,"Nserver_Start");
goto EXIT;
}

/***********************************************************************
*
* Step 3: Start Execution of solution (non-wait mode)
*
***********************************************************************
*/

(void) NServer_SolExeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolExeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolExeN");
goto EXIT;
}
CHAPTER 3 41
Executive System APIs

/********************************************************************
*
* Step 4: Wait for the DMAP solution sequence to complete and
* then print return values(i.e., last Subdmap/DMAP/line#)
********************************************************************
*/
(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,
&Dmpseqnum, &Ndatablk,&Nparam, &Error);

(void) fprintf(LOGFILE, " >>> NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Error);
if( Error ) {
strcpy( ApiName,"NServer_ExeStatus");
goto EXIT;
}

/**********************************************************************
*
* Step 5: EXIT and terminate the server
*
**********************************************************************
*/

EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );

(void) NServer_Exit( GrpName , &Error );

(void) fprintf(LOGFILE," >>> NServer_Exit Error=%d\n",Error);

if( LOGFILE != stderr )


fclose (LOGFILE );
}
42

NServer_SolExeN – Execute the Current Solution Sequence


From FORTRAN:
CALL NSSOLEX (...)
From C:
int NServer_SolExeN
( char *GrpName , INTEGER *Error );

Purpose. Interface call to execute a Dmap Solution from the data input file.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Notes.
1. This function submit's a service call to the server to request the execution of
MSC.Nastran with the input deck which has been previously supplied by
either NServer_Start or NServer_ReadInput.
2. NServer_SolExeN will be executed by the Server in a non-blocking status
after the service request has been received by the server.
3. Because of this API non-blocking feature the call to this API returns
immediately back to the client's application. In order to check for the
successful execution of this data file the client program must subsequently
call NServer_ColNStat. Note: This check can be at any time after the
NServer_SolExeN call.

Example. See the NServer_Start example on page 39.


CHAPTER 3 43
Executive System APIs

NServer_ColNStat – Wait for the Completion of a Prior


NServer_SolExeN call
From FORTRAN:
CALL NSNSTAT (...)
From C:
int NServer_ColNStat
( char *GrpName , INTEGER *Error );

Purpose. Interface call to collect the error status from the NServer_SolExeN function.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Notes.
1. This function "waits" until the NServer_SolExeN function has completed
execution of the input data file and its associated DMAP/Solution sequence.
2. Receives (reads) the error flag from the server after execution of
DMAP/Solution sequence.
3. This function can only be called after the NServer_SolExeN function.

Example. See NServer_Start example on page 39.


44

NServer_Evals -- Evaluates a MSC.Nastran Module Command


From FORTRAN:
CALL NSEVALS(...)
From C:

int NServer_Evals

( char *GrpName, char *EvalString, INTEGER EvalOpt,


INTEGER *Status, INTEGER *Error );

Purpose. Interface call to evaluate a MSC.Nastran module command.


Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max.


256 chars.)
EvalString INPUT String to evaluate
EvalOpt INPUT Eval option, a combination of Qualifier and Dbview flag.
Qualifier flag:
= 0 : Qualifier values not to be saved after NServer_Evals
is executed.

= 1 : Qualifier values will be saved.

Dbview flag:
= 0 : Dbview will not be inherited from previous execution
state.

= 2 : Dbview will be inherited from previous execution


state.
Status OUTPUT Returns evaluation status.
Error OUTPUT Server return error flag.

Application Notes.
This API evaluates a string of command, such as DMAP.
One or more sub-strings can be packed in to a string, using a semi-colon as the
delimiter.
CHAPTER 3 45
Executive System APIs

Example of C-program Application Usage:


(void) NServer_Evals ( "Linux_Server", "PARTN PG,
COL,/,,PG1,/1 $loads", EvalOpt, &Status, &Error );

NServer_Exit – Exit and Terminate the Server


From FORTRAN:
CALL NSSEXIT(...)
From C:
int NServer_Exit
( char *GrpName , INTEGER *Error );

Purpose. Interface call to exit and terminate the server

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example. See NServer_Start example on page 39.


46

NServer_SetExeBreak – Set a Break Point in the DMAP Sequence


From FORTRAN:
CALL NSBREAK(...)
From C:
int NServer_SetExeBreak
( char *GrpName, char *SubDmap, char *Dmap,
INTEGER Dmpseqnum, INTEGER InitFlag, INTEGER *Nbreak,
INTEGER *Error );

Function Description. Sets a break point in the Execution of DMAP Sequence

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
Subdmp INPUT (Max Length = 8)
SubDmap name where the Server should break
Dmap INPUT (Max Length = 8)
Dmap name where the Server should break. Note that the Dmap
name can be the name of a Subdmap being called.
Dmpseqnum INPUT Dmap sequence number where the Server should break
InitFlag INPUT A control flag to set break
= 0 : remove all the breaks set previously
= 1 : when setting a break point
= 2 : reserved (don’t use)
= -1: Remove an entry in the break point list, using the Subdmp,
Dmap and Dmpseqnum as currently defined
Nbreak OUTPUT Number of current entry in the break list which has a maximum
of 100 entries
= -1 if the list overflows.
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag.

Application Notes.
This API should be called before DMAP execution (e.g., before calling to
NServer_SolExeN or NServer_SolResumeN).
CHAPTER 3 47
Executive System APIs

Examples.
1. This first breakpoint example, Example2c, sets a breakpoint using the API
NServer_SetExeBreak. The second example uses the alternate method of a
HALT $ DMAP statement to set breakpoints.
48

Program Example2c
*
* Purpose:
*
* Demonstrates how to:
* (1) start MSC.Nastran
* (2) set a DMAP breakpoint
* (3) execute the DMAP solution sequence
* (4) check for Breakpoint to be reached and then continue execution
* (3) stop MSC.Nastran
*
* Usage:
* ./Example2c <nastran command program> <nastran command keywords>
* e.g., ./Example2c `which nastran` example1 scr=mini mem=10m out=example1c
*
* Method:
* * The necessary Toolkit startup information is passed as
* program arguments to example2c.
*
* It uses/generates the following files:
* example2.dat: input to NASTRAN server :
* example2c.prt: output from this program
* example2c.f04, example2c.f06: output from NASTRAN server
*
* Toolit API's Called:
*
* NServer_Start
* NServer_SetExeBreak
* NServer_SolExeN
* NServer_ExeStatus
* NServer_SolResumeN
* NServer_Exit
*
* Utility functions Called:
*
* GetArgument
* OpenLogFile
* PrintMessage
*
*
*/
#include <stdio.h>
#include <string.h>
#include "nsapilib.h"

static FILE *LOGFILE = stderr;

void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);

void OpenLogFile( char *CommandLine );

void PrintMessage (char *GrpName, FILE *fp, char *ApiName);

main(int argc, char *argv[])


{
char GrpName[257];
char NastPath[1025];
char CommandLine[1025];
CHAPTER 3 49
Executive System APIs

char *DbdictString ={"DBDICT DATABLK(GEOM1) SELECT(NAME,DBSET,VERSON,SIZE,KEY)"};

char DbdictOut[40000];

INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;
INTEGER Filept=0,Nmatch=0,Trailer[7];

char SubDmap[9], Dmap[9];


INTEGER Dmpseqnum=0, Nbreak=0, ibreak;
INTEGER InitFlag, WaitMode=0, ExeStatus=0, Ndatablk=0, Nparam=0;
INTEGER GEOM1Filept;

char ApiName[82]= {"main_program_at_exit" };

int i=0;

/*******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
* *******************************************************************************
*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);

(void) OpenLogFile( CommandLine );

/*********************************************************************
*
* Step 2: Initialize the server
*
*********************************************************************
*/
(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);

(void) fprintf(LOGFILE," >>> NServer_Start GrpName=%s\n"


" CommandLine=%s\n"
" NastPath=%s\n"
" Error=%d\n",
GrpName,CommandLine,NastPath,Error);

if( Error ) {
strcpy( ApiName,"NServer_Start");
goto EXIT;
}
/**********************************************************
*
* Step 3: Set up a break point after CALL IFPL subdmap
*
**********************************************************
*/
strcpy( SubDmap, "DESOPT" );
strcpy( Dmap, "IFPL" );
Dmpseqnum = 0 ; /* no need for specific line number */
InitFlag = 1;
50

(void) NServer_SetExeBreak( GrpName , SubDmap , Dmap , Dmpseqnum ,


InitFlag , &Nbreak , &Error );
(void) fprintf(LOGFILE," >>> NServer_SetExeBreak: SubDmap=%s\n"
" Dmap=%s\n"
" Dmpseqnum=%d\n"
" InitFlag=%d\n"
" Nbreak=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,InitFlag,Nbreak,Error);

if( Error ) {
strcpy( ApiName,"NServer_SetExeBreak");
goto EXIT;
}
/*********************************************************
*
* Step 4: Execution of solution in non-blocking mode
*
*********************************************************
*/

(void) NServer_SolExeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolExeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolExeN");
goto EXIT;
}
/*************************************************************
*
* Step 5: Check for DMAP breakpoints or until DMAP EXIT
*
*************************************************************
*/

WaitMode = 0;

for (ibreak=0 ; ibreak<Nbreak ; ibreak++ ) {

/*****************************************************************
*
* Step 5.a: Get the Dmap Execution status after the breakpoint
*
*****************************************************************
*/
(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,
&Dmpseqnum, &Ndatablk,&Nparam, &Error);

(void) fprintf(LOGFILE, " >>> NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Error);
if( Error ) {
strcpy( ApiName,"NServer_ExeStatus");
goto EXIT;
}
CHAPTER 3 51
Executive System APIs

/**************************************************************
*
* Step 5.b: Get out of "for loop" at the "EXIT" DMAP statement
*
**************************************************************
*/
if( !strncmp(Dmap,"EXIT",4) || Error ) break;

if( !strncmp(Dmap, "IFPL",4) ) {


/*
* At Break point IFPL
*/

(void) fprintf(LOGFILE," >>> Breakpoint IFPL\n");

/******************************************************************************
*
* Step 5c: Resume DMAP execution after the breakpoint and loop back for the *
next break point (note: breakpoint after "IFPL" will be "EXIT").
*****************************************************************************
/

(void) NServer_SolResumeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolResumeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolResumeN");
goto EXIT;
}

} /* end of for loop */

/******************************************
*
* Step 6: EXIT and terminate the server
*
*****************************************
*/

EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );

(void) NServer_Exit( GrpName , &Error );

(void) fprintf(LOGFILE," >>> NServer_Exit Error=%d\n",Error);

if( LOGFILE != stderr )


fclose (LOGFILE );
}
52

2. This example sets Breakpoints using the HALT $ DMAP Statement:

HALT $
This DMAP statement defines a breakpoint in the DMAP sequence. DMAP execution will stop
when the breakpoint is reached. The client program can check for a breakpoint by a call to
NSEXSTA. DMAP execution is resumed by a call to NSRESUM. This is a more convenient way
to define breakpoints when by using NSBREAK.

Example.
sol prtmat
compile prtmat list
subdmap prtmat $
$
type db, zuzr01 $
$
halt $
matprn zuzr01 // $
$
end $
diag 8
cend
begin bulk
enddata
______________________________________________________________________________
DMAP execution will be stopped when the HALT statement is reached. Now the client
program will place datablock ZUZR01 into the database. Subsequently, DMAP execution is
resumed, and the MATPRN module will print datablock ZUZR01.
CHAPTER 3 53
Executive System APIs

NServer_ExeStatus – Return the status of the Executing Dmap


Sequence
From FORTRAN:
CALL NSEXSTA(...)
From C:
int NServer_ExeStatus
( char *GrpName, INTEGER WaitMode, INTEGER *ExeStatus,
char *SubDmap, char *Dmap, INTEGER *Dmpseqnum,
INTEGER *Ndatablk, INTEGER *Nparam, INTEGER *Error );

Function Description. Status of the DMAP Sequence Execution.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
WaitMode INPUT Waiting mode flag
=> 0 : value of timeout in second to wait for the Server's response.
If a zero value is set, it will wait forever.
= -1 : return right back to caller if server is busy
ExeStatus OUTPUT Execution status
= 0 : The Server is at a DMAP break point / EXIT
= 1 : The Server is busy and not responding
Subdmp OUTPUT (Max Length = 8)
SubDmap name if the Server at a break point / EXIT
Dmap OUTPUT (Max Length = 8)
Dmap name if the Server at a break point / EXIT
Dmpseqnum OUTPUT Dmap sequence number if the Server at a break point / EXIT
Ndatablk OUTPUT Number of input, output datablocks at a break point / EXIT
Nparam OUTPUT Number of parameters available at a break point / EXIT
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.
54

Application Notes.
Since the server executes the DMAP solution sequence ( see NServer_SolExeN ) in a
non-blocking mode, this API outputs the status of the execution after calls to
NServer_SolExeN or NServer_SolResumeN. If there was no breakpoint set, or if a
breakpoint has been set but for some reason the DMAP breakpoint was not executed,
then the NASTRAN server will eventually encounter an automatic breakpoint at the
DMAP EXIT $ statement.
**This NServer_ExeStatus API can replace the NServer_ColNStat which has limited
functionality.

Example. See NServer_Start example on page 39.


CHAPTER 3 55
Executive System APIs

NServer_SolResumeN – Resume DMAP Execution After Stopping


by Nserver_SetExeBreak
From FORTRAN:
NSRESUM(...)
From C:
int NServer_SolResumeN
( char *GrpName, INTEGER *Error );

Function Description. Resume the DMAP Execution after stopping at a DMAP


break point.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.

Fortran Interface.
CALL NSRESUM ( GrpName, Error )

Application Note.
This API should be called to continue the DMAP execution after a break point has
been invoked. However, the application program can exit (NServer_Exit) or input
another bulk data file (NServer_Input) to continue the execution.
NServer_SolResumeN is a non-blocking call.

Example. See NServer_SetExeBreak example on page 47.


56

NServer_Input – Prepares a New Input File for Execution by the


Server
From FORTRAN:
CALL NSINPUT(...)
From C:
int NServer_Input
( char *GrpName , char *DeckName , INTEGER *Error );

Purpose. Interface call to input a new data file to the server.


Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
DeckName INPUT Full path name of Input file to run MSC.Nastran. (Max. 256 chars.)
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Note. This prepares for the execution of a new input data file and its associated
DMAP Solution sequence. A subsequent call to NServer_SolExe will begin the
execution of this input data file.
Example.
CHAPTER 3 57
Executive System APIs

/*

* Program Example4c.c

* Purpose:
*
* Demonstrates how to:
* (1) start MSC.Nastran
* (2) execute an initial DMAP solution sequence
* (3) and then submit two additional input files and associated DMAP solution
* sequences for execution by the MSC.Nastran server
* (4) stop Msc.Nastran
*
* Usage:
* ./Example4c <nastran command program> <nastran command keywords>
* e.g., ./Example4c `which nastran` example1 scr=mini mem=10m out=example4c
*
* Method:
* * The necessary Toolkit startup information is passed as
* program arguments to example1c.
*
* It uses/generates the following files:
* example4.dat: input to NASTRAN server :
* example4c.prt: output from this program
* example4c.f04, example1c.f06: output from NASTRAN server
58

*
* Toolit API's Called:
*
* NServer_Start
* NServer_SolExeN
* NServer_ExeStatus
* NServer_Input
* NServer_Exit
*
* Utility functions Called:
*
* GetArgument
* OpenLogFile
* PrintMessage
*
*
*/

#include <stdio.h>

#include "nsapilib.h"

main(int argc, char *argv[])

char GrpName[32];

char NastPath[1024];

char CommandLine[1024];

char DeckName[][128]={ "api2.dat","api3.dat" };

int i,nloop, loop, Error=0,coldstart=0;

/************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
************************************************************************
*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);


(void) OpenLogFile( CommandLine );
nloop = sizeof(DeckName)/128;

nloop++;

for( loop=0 ; loop<nloop ; loop++ ) {


CHAPTER 3 59
Executive System APIs

/************************************************************************
*
* Step 2: Initilize the server
*
************************************************************************
*/

if( loop == 0) {

(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);


(void) fprintf(LOGFILE," >>> NServer_Start GrpName=%s\n"
" CommandLine=%s\n"
" NastPath=%s\n"
" Error=%d\n",
GrpName,CommandLine,NastPath,Error);

if( Error ) {
strcpy( ApiName,"Nserver_Start");
goto EXIT;

} else {

/************************************************************************
*
* Step 3: Submit the next input file to be executed by MSC.Nastran
*
************************************************************************
*/

(void) fprintf(stderr,"\n\n **********"

"\n **********"

"\n **********"

" Hit RETURN to execute next data deck %s "

"\n **********"

"\n **********\n",

DeckName[loop-1]);

fgetc(stdin);

(void) fprintf(stderr, " Call NServer_Input for Group %s


Deckname=%s\n",GrpName,DeckName[loop-1]);
(void) NServer_Input ( GrpName , DeckName[loop-1] , &Error );

/***********************************************************************
*
* Step 4: Start Execution of solution (non-wait mode)
*
***********************************************************************
*/
60

(void) NServer_SolExeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolExeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolExeN");
goto EXIT;
}

/********************************************************************
*
* Step 5: Wait for the DMAP solution sequence to complete and
* then print return values(i.e., last Subdmap/DMAP/line#)
* Since no DMAP breakpoints are set it should return Dmap="EXIT".
********************************************************************
*/
(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,
&Dmpseqnum, &Ndatablk,&Nparam, &Error);

(void) fprintf(LOGFILE, " >>> NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Error);
if( Error ) {
strcpy( ApiName,"NServer_ExeStatus");
goto EXIT;
}

} /* end of for loop */

/**********************************************************************
*
* Step 6: EXIT and terminate the server
*
**********************************************************************
*/

EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );

(void) NServer_Exit( GrpName , &Error );

(void) fprintf(LOGFILE," >>> NServer_Exit Error=%d\n",Error);

if( LOGFILE != stderr )


fclose (LOGFILE );
}
CHAPTER 3 61
Executive System APIs

NServer_GetMessage – Get Error Messages Generated by the


MSC.Nastran Server
From FORTRAN:
CALL NSGETMS(...)
From C:
int NServer_GetMessage
(char *GrpName, INTEGER *lenmsg, char *fmsg,
INTEGER *Message_Status)

Purpose. Interface call to retrieve messages generated by the MSC.Nastran server


program.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
lenmsg INPUT The number of characters available for storage in the fmsg character
string.
fmsg OUTPUT Server error message. Note that each message output line (as
normally appears in an MSC.Nastran F06 output listing) is returned
as one string with end of line delimeters (e.g., “\n”) every 80
characters
Message_ OUTPUT Message Status and Server return error flag
Status 0= More Messages Remain
1= No More Messages
2= Message is Truncated

Func. Ret. OUTPUT Same as Message Status argument

Example. See the PrintMessage function in Utility Functions (App. F).


62

NServer_GetAllMessages – Retrieve All Error Messages Generated


by MSC.Nastran Server
From FORTRAN:
CALL NSGMSGS ( … )
From C:

int Nserver_GetAllMessages

( char* GrpName, INTEGER* max_ length, char*


all_messages, INTEGER* messages_length, INTEGER* iret
)

Purpose. Retrieve all messages generated by the MSC.Nastran server program and
concatenate them into one string.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
max_length INPUT The maximum number of characters available for storage in the
all_messages character string.
messages_len OUTPUT The total number of 81 characters strings in all_messages. Note
gth that the actual number of characters (including the “\n” at the
end of each line) in all_messages is messages_length*81
all_messages OUTPUT Server error messages. Note that each message output line (as
normally appears in an MSC.Nastran F06 output listing) is
returned as one string with end of line delimiters (e.g.,”\n”)
every 80 characters
iret OUTPUT Error return code.
0 = no error.
Func. Ret. OUTPUT Same as iret.
CHAPTER 3 63
Executive System APIs

NServer_MessageFilter – Filter Error Messages out of the Error


Messages generated by MSC.Nastran Server
From FORTRAN:
CALL NSMSGF ( … )
From C:

int Nserver_MessageFilter

( char* all_messages, INTEGER messages_in, INTEGER


pattern_length, INTEGER pattern_case_flag, char*
pattern, char* messages_found, INTEGER* message_out,
INTEGER* iret )

Purpose. Routine to filter (using Unix Regular Expression pattern matching


capability) messages generated by the concatenation of returned messages from
MSC.Nastran server program (see also NServer_GetAllMessages).

Arguments.

all_messages INPUT Server error messages. Note that each message output line (as
normally appears in an MSC.Nastran F06 output listing) is
returned as one string with end of line delimiters (e.g.,”\n”)
every 80 characters
messages_in INPUT The total number of 81 characters strings in all_messages. Note
that the actual number of characters (including the “\n” at the
end of each line) in all_messages is messages_in*81
pattern_length INPUT The character string length specification.
A non-negative integer value containing the actual length of the
character data associated with pattern string. Note that this
length must not include any terminating null characters. A
length of 0 indicates that the pattern string is empty.
An integer –1 value (or any negative value) if the length is
implicit within the pattern string itself. For the FORTRAN
callable entries, the implicit string length value will be used. For
the “C” callable entries, the pattern string must be a standard
null-terminated string.
pattern_case_fl INPUT Specify what case conversion, if any, is to be performed on the
ag pattern.
0 = no case conversion is to be done.
1 = all characters are to be converted to upper case.
2 = all characters are to be converted to lower case.
64

pattern INPUT The pattern string of regular expression.


(Also see more detail description of regular expression)
message_found OUTPUT Filtered messages return.
message_out OUTPUT The total number of 81 characters strings in message_found.
Note not all strings contain the pattern given since a server error
message may contains more then one string.
iret OUTPUT Error return code.
0 = no error.
Func. Ret. OUTPUT Same as iret.
CHAPTER 3 65
Executive System APIs

NServer_SetServerTimeout – Set a Time Limit that the Server Will


Wait in a "blocking" Mode for a Client Response
From FORTRAN:
CALL NSSRTMO(...)
From C:
int NServer_SetServerTimeout
((char *GrpName, INTEGER *timeout, INTEGER *Error)

Purpose. Interface call to set a time-out on the server to avoid any possible cases of
inifinte blocking in the case of client failure.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
Timeout INPUT Timout value in seconds (default is 10,000)
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Example. See NServer_SetClientTimeout on page 66.


66

NServer_SetClientTimeout – Set a Time Limit that the Client Will


Wait in a "blocking" Mode for a Server Response
From FORTRAN:
CALL NSCLTMO(...)
From C:
int NServer_SetClientTimeout
(char * GrpName, INTEGER *timeout, INTEGER *Error)

Purpose. Interface call to set a timeout on the client to avoid any possible cases of
infinite blocking in the case of server failure.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
Timeout INPUT Timeout value in seconds (default is 10,000)
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Example. Code snippet illustrating use of the …SetClientTimeout


API/…SetServerTimeout (to increase the default wait time from the current default of
10,000 seconds).
CHAPTER 3 67
Executive System APIs

/* Note: This is only a code "snippet"--the complete source can be found in the
MSC.Nastran Code Librarian Help System. */

/* INIT THE SERVER */

Nserver_Start ( GrpName , CommandLine , NastCommand , &Error);

If( Error ){
(void) fprintf(fp, "Error in NServer_Start error = %d\n", Error);
goto exit;
}
/* SET THE CLIENT WAIT TIMEOUT for 20000 seconds
Note: All subsequent NServer_xxxx calls will wait 20000 seconds for
A server response--if the wait is longer then the waiting API will
disconnect the client from the server and return with an Error--
*/
(void) NServer_SetClientTimeout ( GrpName, 20000 , &Error);

/* SET THE SERVER WAIT TIMEOUT for 50000 seconds


Note: The Server will wait for 50000 seconds for a response from this
Client program--if the wait is longer then the Server will
disconnect from the Client--the next client API call will then return with an error
message (depending on the platform the client API will either immediately return with a
"Server has crashed" error message (NT platforms) or return with a "Client Timeout" error
message after the NServer_SetClientTimeout limit has been reached (UNIX platforms)
*/

(void) fprintf(fp, " Call NServer_SetServerTimeout %d\n", 50000 );


(void) NServer_SetServerTimeout ( GrpName, 50000 , &Error);

/* EXECUTION OF SOLUTION IN NON-BLOCKING MODE */

(void) NServer_SolExeN( GrpName , &Error );

if( Error ){
(void) fprintf(fp, "Error in NServer_SolExeN error = %d\n", Error);

goto exit;
}

/* COLLECT NON-BLOCKING STATUS ("waits" for DMAP Solution to complete)


Note: Due to previous SetClientTimeout call NServer_ColNStat will wait 20000 seconds for
a response from the Server--if no response during that time than the client will be
disconnected from the Server and a Fatal Error message will be issued by NServer_ColNStat.
*/

(void) NServer_ColNStat( GrpName, &Error );

if( Error ) {

(void) fprintf(fp, "Error in NServer_ColNStat error = %d\n", Error);

goto exit;
}
exit:

/* Note: This is only a code "snippet"--the complete source can be found in the
MSC.Nastran Code Librarian Help System. */
68

NServer_SavEnv – Save the Server’s IPC Environmental Table for a


Later Reconnection from Another Client Program
From FORTRAN:
CALL NSSAVEN(...)
From C:
int NServer_SavEnv
( char *GrpName, char *EnvName, INTEGER *Error);

Function Description. Save client-server environment necessary for a child process


re-connection.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
EnvName INPUT Name of the Environment (Max. 1025)
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.

Fortran Interface. Not yet available.


CALL NSSAVEN ( GrpName, EnvName, Error )

Application Note.
This API must be called after the connection to the server has been established. This
API saves the system information that is needed for a child process to re-connect to
the parent’s client-server connection--the child process performs the re-connection by
calling NServer_Restart with the EnvName used by the prior call to NServer_GetEnv.
Example. See the example provided for NServer_Restart page 69.
CHAPTER 3 69
Executive System APIs

NServer_Restart – Restart the Server from Another Client Program


From FORTRAN:
CALL NSRESTA(...)
From C:
int NServer_Restart
( char *GrpName, char *EnvName, INTEGER *Error );

Function Description. Start the NASTRAN Server.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
EnvName INPUT (Max Length = 1024)
Env name
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag.

Fortran Interface. Not yet available.


CALL NSRTART ( GrpName, EnvName, Error )

Application Notes.
This API must only be used in a child process after NServer_SavEnv (NSSAVEN) has
been called in the parent process.

Example. This following example demonstrates how to reconnect a child process to


a parent process's existing client-server connection.
70

/*
* Program Nshalt.c
*
* Purpose: To Demonstrate how to:
* (1) Set a DMAP "breakpoint" using NServer_SetExeBreak,
* (2) followed by starting a child process, Nsrecon.
* (3) Then this example shows how the child process
* can re-establish the parent’s client-server connection
*
*
* Usage: NShalt <nastran command program> <nastran command keywords>
* e.g., ./NShalt `which nastran` d200c01 scr=mini mem=10m
*
* Demonstrates how to:
* (1) set a DMAP "breakpoint,
* (2) and then after stopping at this breakpoint,
* (3) start another process that re-connects to the server.
*
*
* Method:
* * The necessary Toolkit startup information is passed as
* program arguments to Nshalt.
*
* It uses/generates the following files:
* NShalt.dat: input to NASTRAN server :
* NShalt.prt: output from this program
* NShalt.f04, NShalt.f06: output from NASTRAN server
*
* Toolit API's Called:
*
* NServer_Start
* NServer_SetExeBreak
* NServer_SolExeN
* NServer_SavEnv
* NServer_Restart
* NServer_ExeStatus
* NServer_SolResumeN
* NServer_Exit

*
* Utility functions Called:
*
* GetArgument
* OpenLogFile
* PrintMessage
*
*
*/

#include <stdio.h>
#include "nsapilib.h"

void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);
int Fetch_Messages (char *GrpName, FILE *fp);

main(int argc, char *argv[])


{
CHAPTER 3 71
Executive System APIs

char GrpName[257];
char NastPath[1025];
char CommandLine[1025];
char *EnvName;

char SubDmap[9], Dmap[9];


INTEGER Dmpseqnum, Nbreak, InitFlag;
INTEGER WaitMode, ExeStatus, Ndatablk, Nparam, Error;

/*******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
* *******************************************************************************
*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);

(void) OpenLogFile( CommandLine );

/*********************************************************************
*
* Step 2: Initialize the server
*
*********************************************************************
*/

(void) fprintf(LOGFILE," Call Nserver_Start for Group=%s\n"


" CommandLine=%s\n"
" NastPath=%s\n",
GrpName,CommandLine,NastPath);

(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);

if( Error ) {
strcpy( ApiName,"Start");
goto EXIT;
}

/*
* (2a) Set the solution breakpoints prior to executing DMAP
*/

strcpy( SubDmap, "DESOPT" );

Dmap[0] = '\0';

Dmpseqnum = 52; /* a call subdmap */

InitFlag = 1;

(void) fprintf(LOGFILE, " Input to NServer_SetExeBreak: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" InitFlag=%d\n",
SubDmap,Dmap,Dmpseqnum,InitFlag);
72

(void) fprintf(LOGFILE, " Call Nserver_SetExeBreak to set 1st DMAP breakpoint\n");

(void) NServer_SetExeBreak( GrpName , SubDmap , Dmap , Dmpseqnum ,


InitFlag , &Nbreak , &Error );

(void) fprintf(LOGFILE, " Return from NServer_SetExeBreak: Nbreak=%d\n"


" Error=%d\n",
Nbreak,Error);
If( Error ) {
strcpy( ApiName,"SetExeBreak");
goto EXIT;
}
/*

* (3) Execution of solution in non-blocking mode


*/

(void) fprintf(LOGFILE, " Call NServer_SolExeN to execute the DMAP solution\n");

(void) NServer_SolExeN( GrpName , &Error );


If( Error ) {
strcpy( ApiName,"SolExeN");
goto EXIT;
}

/*
* (4) Prepare for for the execution of the second Client program NSrecon
*/

EnvName = GrpName;

(void) NServer_SavEnv ( GrpName, EnvName, &Error);


If( Error ) {
strcpy( ApiName,"SavEnv");
goto EXIT;
}

sprintf (CommandLine, "./NSrecon %s\n ",EnvName) ;

/*
* (5) Loop over the breakpoints, either a breakpoint Dmap or an EXIT Dmap has been hit
*/

WaitMode = 0;

for ( ; ; ) {

/*
* (5a) Get the Dmap Execution status after the breakpoint
*
* Note:
*
* There are is one break point.
* Once the Dmap execution hits this breakpoint,
* it returns control to the client program.
* The Dmap Sequenvce Number Dmpseqnum is output here to
* show the location of the breakpoint in the dmap sequence.
CHAPTER 3 73
Executive System APIs

*
* In this example, at the breakpoint, another task NSrecon
* NSrecon will be submitted. This new task re-connects
* to the server and requests "DBDICT" output.
*/
(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,
&Dmpseqnum, &Ndatablk,&Nparam, &Error);

(void) fprintf(LOGFILE, " Return from NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Ndatablk=%d\n"
" Nparam=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Ndatablk,Nparam,Error);

if( !strncmp(Dmap,"EXIT",4) || Error ) {


Strcpy( ApiName,"COMMANDLine");
goto EXIT;
}

/*
* (5b) Submit the second program NSrecon to reconnect the NASTRAN server
*/

Error = system( CommandLine );


If( Error ) {
Strcpy( ApiName,"COMMANDLine");
Goto EXIT;
}
/*
* (5c) Resume the Dmap execution after the breakpoint
*/

(void) NServer_SolResumeN( GrpName , &Error );

if( Error ) {
strcpy( ApiName,"NServer_SolResumeN");
goto EXIT;
}
}

/*
* (6) Retrieve Error message (if any) and
* Close the Server
*/

/******************************************
*
* Step 6: EXIT and terminate the server
*
*****************************************
*/

EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );

(void) NServer_Exit( GrpName , &Error );


74

(void) fprintf(LOGFILE," >>> NServer_Exit Error=%d\n",Error);

if( LOGFILE != stderr )


fclose (LOGFILE );
}

}
/* end of Nshalt.c */
/*****************************************************************************/
/*****************************************************************************/
/*
* File: Nsrecon.c
*
* Purpose: To reconnect NASTRAN server
*
* This program is executed by another program NShalt
*

*/

#include <stdio.h>
#include "nsapilib.h"

int main (int argc, char *argv[])


{
char GrpName[257];
char *EnvName;
/*

* The following DbdictString allows the same format as that used for
* MSC.Nastran DBDICT module
*/
char *DbdictString =
{"DBDICT DATABLK(EPT,GEOM2,OES1,OUGV1,DVPTAB,DESTAB,PROPO)"};
char DbdictOut[40000];
int OutLen,MaxLen=40000;

INTEGER Error;

/*
* (1) Parse the program arguments in to GrpName, NastPath and CommandLine
*/

strcpy( GrpName, argv[1] );


EnvName = GrpName;

/*
* (2) Re-connect to the NASTRAN server
*/
(void) fprintf(stderr," Call NServer_Restart for Group=%s\n"
" EnvName=%s\n",
GrpName,EnvName);

(void) NServer_Restart ( GrpName , EnvName , &Error);

if ( Error ) goto EXIT;

/*
CHAPTER 3 75
Executive System APIs

* (3) DBDICT
* (output from DBDICT function the same as standard MSC.Nastran DBDICT output)
*/

(void) NServer_Dbdict ( GrpName , DbdictString , DbdictOut ,


MaxLen, &OutLen , &Error ) ;

if ( Error ) goto EXIT;

(void) fprintf(stderr, " Call NServer_Dbdict Return OutLen=%d DbdictOut=\n%s",


OutLen,DbdictOut);

EXIT:
Return (int) Error;

}
76

NServer_GetEnv – Get MSC.Nastran Execution Environment


Resources
From FORTRAN:
CALL NSENV (...)
From C:
int NServer_GetEnv
(char *NastPath , const char *Attributes ,
INTEGER *Num_Attributes, CHARCTER *Att_Names,
CHARCTER *Att_Values, CHARACTER *Att_Source, INTEGER *Error );

Purpose. Returns MSC.Nastran environment information.

Arguments.

NastPath INPUT MSC.Nastran Command Line


Attributes INPUT A string containing comma separated list of attributes to fetch
information on. For example, the user may pass in mem, scr,
dbs, sdir, ver to inquire about five MSC.Nastran execution
environment.
Num_Attributes OUTPUT Number of attributes found in the input string. This variable
assumes that some of the attribute names may be valid and as
such one may get less attributes than asked for. For example,
if the user passes the following string under Attribute
parameter scr, bad_att, then Num_attributes will be set to 1.
Att_Names OUTPUT Names of valid Attributes found in the Attributes parameter.
The size of the array shall be [ 80 X * Num_attributes ]. This
array must be sized by the calling routine based on the
number of parameters passed in the Attributes input string.
Att_Values OUTPUT Values of valid Attributes found in the Attributes parameter.
The size of the array shall be [ 80 X * Num_attributes ]. This
array must be sized by the calling routine based on the
number of parameters passed in the Attributes input string.
Att_Source OUTPUT Source of valid Attributes found in the Attributes parameter.
This variable will contain information about which rc file was
used to extract the instance value for the Attribute. The size of
the array shall be [ 80 X * Num_Attributes ]. This array must
be sized by the calling routine based on the number of
parameters passed in the Attributes input string.
Error OUTPUT Server return error flag
CHAPTER 3 77
Executive System APIs

Func. Ret. OUTPUT Server return error flag

Note.
This function interacts with the MSC.Nastran command program only and as such
does not invoke the MSC.Nastran solver. As a result, it can be invoked numerous
times without incurring any significant performance penalty.
This function is similar to the Nastran command program’s “whence” keyword. The
returned attribute values from the “whence” keyword only reflect the values set by
the Nastran command program and the Nastran “RC File”. Note: If an attribute is not
set by one of these methods it will be returned as a NULL string.

Example. Code snippet demonstrating the NServer_GetEnv API.

INTEGER Error = 0;
INTEGER num = 0;
int i = 0;
char key[ 800 ], value[ 800 ], src[ 800 ];

NServer_GetEnv("nastran", "scr,mem,sdir" , &Num_Attributes, Att_Names, Att_Values,


Att_Source, &Error);

for( i = 0; i< Num_Attributes; i++ )


printf("Att_Names=%s Att_Values=%s Att_Source=%s\n",
&Att_Names[i*80],
&Att_Values[i*80],
&Att_Source[i*80] );
:::::::::::::::
Output
:::::::::::::::
Att_Names=scratch Att_Values=no Att_Source=program default
Att_Names=memory Att_Values= Att_Source=program default
Att_Names=sdirectory Att_Values=/scratch src=/nast/conf/nast2001t1rc[2]
78

NServer_CheckToolkit – Check the Compatibility of the Toolkit


Client and MSC.Nastran Server
From FORTRAN:
CALL NSCHKTK (...)
From C:
int NServer_CheckToolkit
( char *GrpName , INTEGER *Compatible, INTEGER *Error );

Purpose. Interface call to Interrogate whether the release version of the Toolkit client
API is compatible with the MSC.Nastran server pointed to by the “GrpName” group.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Compatible OUTPUT Server return error flag ( 0 – compatible, nonzero value –
noncompatible)
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Notes.
1. If it is found that the client and server are not compatible the error flag will be set
accordingly and a message will be written to the API’s error stack. The specific
changes causing the incompatibility between the client and server will be documented
on each release of the Toolkit in the nsapilib.h file contained on the Toolkit delivery
CD.
Example message output:
*** SYSTEM INFORMATION MESSAGE 6498 (NASAPI, SendCheckTool)
API MESSAGE FOLLOWS.
USER INFORMATION: No Error Encountered.

The Toolkit client and the server are *not* compatible.

Server::major=2001.0.0,minor= Tier 1 ,special=


,rounds=Tier 1
Client::major=2001.0.0,minor= ,special= ,rounds=0,1,2,3,4
MSC.Nastran Toolkit User’s Guide

CHAPTER
Database Features and APIs
4
■ Retrieve Data From a Previous Run

■ Database Utilities

This section describes the MSC.Nastran database API's necessary for 1) determining
the contents of an existing database, 2) creating new datablocks (tables/matrices), and
3) retrieving/accessing existing datablocks from a database.
There are many ways to interface your client program with an existing database or
solution sequence. Merits and difficulties of this connection depend on just what your
client program needs to do. It can range from the relatively simple retrieval of
permanently stored data on a MSC.Nastran database to the more complex halting of
a running solution sequence to read, update, or add datablocks. The solution sequence
could be your own instead of one supplied by MSC.Software. Here we will outline
several methods that you might employ to connect with the database.
80

4.1 Retrieve Data From a Previous Run


Often client programs wish to retrieve data from a job that was submitted previously.
Here there is no need to interactively monitor or to update data as the job runs. A good
example is you wish to retrieve stored stress, force, displacement, etc. results.
Make sure that the information you want to retrieve is being permanently stored. The
job must have been submitted with scr=no or scr=mini and the solution sequences
must be defined (or altered) to store this data. Typical results output from MSC’s
solution sequences are indexed and permanently stored if scr=no or scr=mini and
sys316=3 is used when submitting the job.
The client program should connect with this database using a small deck that attaches
and points to the permanent data by DBLOCATE FMS statement. Although the
current job which is run by the client program is a scratch run, it can access all the
projects, versions, and datablocks that have been stored on the previous run’s
database. The previous run’s database will not be altered by anything that is done
during this client job. Indeed, you can simultaneously run several client jobs that point
to the same database using this method.
ACQUIRE NDDL
INIT MASTER(S)
ASSIGN DB1='\your_master_dbset_name'
DBLOCATE DATABLK=*,LOGICAL=DB1, WHERE(VERSION>0 AND,
PROJECT=*),CONVERT(PROJECT=PROJECT;VERSION=VERSION)
SOL LOADNDDL
CEND
BEGIN BULK
ENDDATA

Use the NServer_Dbdict API to determine available datablocks on the database,


choose the qualified datablock you wish to read, and use one of the various read
access toolkit API’s. It is also possible to write to the current database but because it is
defined as a scratch run nothing will be saved once the client job finishes.
This basic method can be modified in minor ways. If you remove the init master(s)
statement from the deck above and you submit the client job as scr=no, then the
database created by the client job will be made permanent and you will be able to store
datablocks permanently. Still, the DBLOCATE’d database information will remain
separate and read-only.
You could provide your own solution sequence instead of the LOADNDDL. Then the
DBLOCATE’d job becomes a source for some information which your client program
could manipulate in some way, write back to the current database, and
MSC.Nastran’s methods available through DMAP could further process. Some client
programs need to be set up so they can modify or process data while a solution
sequence is running. The needs of the client program are slightly different that in the
CHAPTER 4 81
Database Features and APIs

case specified above in that the client needs to somehow affect the data or the control
of a solution sequence (interactively or batch) while it is running. You could do the
same process using case 1, but it would have to be done in (perhaps) many stages as
several separate jobs. This technique allow the client code to do it as one job.
A good conceptual example might be what would be required to build you own
optimizer outside MSC.Nastran. Here you would want to input the model and come
up with an initial solution within the existing solution sequences, then have your
client code stop the run, check for convergence, and if not converged modify (perhaps)
properties information on the database, and loop back through the solution sequence
with the modified properties. Here you are interfacing with the data model that is
used by MSC. While the Toolkit calls are simple, the details of getting and modifying
existing datablocks can be difficult. Client programs need to find the proper position
to “Halt”, to find out which datablock qualifiers are important so you can allocate a
datablock, and you must know how to read and write the datablock in the MSC
defined form.
Assume that the client program needs to write a new datablock to the database and
that datablock will be used in subsequent DMAP statement in the solution sequence.
The easiest method of adding a new permanent datablock to a solution sequence is to
use the zuzr11-zuzr20 set of predefined datablock names. These names are available
for use in all the solution sequences 100+. In fact, the zuzr11 datablocks are also used
by the SUBDMAPS DBSTORE and DBFETCH for the users use in alters. The toolkit
can also interface through zuzr11 datablocks but instead of altering use the toolkit
NServer allocation and write commands. The client program needs to determine the
set of qualifiers that are present with a particular datablock name. This list is necessary
when a datablock is allocated for write (or read).
Going to the NDDL description you see that:
DATABLK ZUZR11 TYPE=MATRIX PATH=ZNAME LOCATION=DBZUZR
and
PATH ZNAME ZNAME,ZUZR1,ZUZR2,ZUZR3
and
QUAL(CHAR8) ZNAME=' '
QUAL(I) ZUZR1=0,ZUZR2=0,ZUZR3=0
Thus, the qualifiers for zuzr11 are zname which a character string (used by dbstore as
a datablock name), and three integer qualifiers. The client program then could allocate
a zuzr11 datablock with appropriate NServer_CreateDatablk of:
char *Create={"DATABLK=ZUZR11 QUALS(ZNAME='MYDB'; ZUZR1=1)"};
NServer_CreateDatablk(GrpName,Create,&Filept,&FileStat,&Error);

Then open this datablock for write, write to the datablock, close it, and write its trailer.
After these operations are done, the DMAP can access the new datablock created by
your client code by various methods:
82

The easiest is to use the CALL DBFETCH statement.


call dbfetch /mydb/1/0/ .....
tabpt mydb,,,,// $
This does the work to equivalence zuzr11 with zname=’mydb’, zuzr1=1 to the
datablock callex mydb. Using this method the datablock mydb is available to this
subdmap and can be passed to subsequent ones.
Or, you can dbview this datablock in a particular subdmap by:
dbview mydb=zuzr11 where(zname='MYDB' and zuzr1=1 and wildcard)
tabpt mydb,,,,// $

With the dbview statement you can refer to mydb anywhere within the current
subdmap, but cannot be passed to another. Another dbview must be set up in each
subdmap you wish to use this datablock.
Finally, you can explicitly set the qualifiers in the dmap and the datablock created by
the client can be read by its zuzr11 name.
type parm,i,nddl,n,zuzr1,zuzr2,zuzr3
type parm,char8,nddl,n,zname
zname='MYDB'
zuzr1=1
zuzr2=0
zuzr3=0
tabpt zuzr11,,,,,// $
Of course you are not restricted by the Toolkit to just using the zuzr11 names. You can
use the normal solution sequence names. Using these names is appropriate when you
wish to modify some of the contents of these datablocks or wish to create them outside
the normal solution sequences. All datablock names that are contained in the NDDL
are available for use.
The only complicating factors in use of these names are the appropriate integration of
the datablock and its qualifiers with their use in the existing solution sequence
structure. It is probably much easier to modify the EPT (Element Property Table) for
optimization using this name than to try using zuzr11 and equivalencing. If you use
an existing name you must:
• Look up the list of qualifiers which go with the datablock.
• Make sure that they are set to the proper values for a solution sequence
where you have halted or to the values to the location you wish these
datablocks should be used.
If you are creating a datablock (or a family of datablocks) that is to be used in a
solution sequence your client code needs to:
• NServer_CreateDatablk
• NServer_OpenDatablk
CHAPTER 4 83
Database Features and APIs

• NServer_Write
• NServer_Close
• NServer_WriteTrailer
The logic of the qualifier setting that is in the DMAP already will make the appropriate
datablock available in the solution sequence as it executes without further altering.
Finally, you can create your own Delivery Database, with Datablock names and
qualifiers that you feel appropriate to your client code. With this method you have the
full range of functionality available to you.
84

4.2 Database Utilities


NServer_AllocDatablk – Allocate an Existing MSC.Nastran
Datablock
From FORTRAN:
CALL NSALLDB(...)
From C:
int NServer_AllocDatablk
( char *GrpName , char *AllocString , INTEGER *Filept ,
INTEGER *Nmatch , INTEGER *Error );

Purpose. Interface call to locate existing datablock(s) (using the specified AllocString
(where clause)) in the MSC.Nastran database and then to create the necessary internal
data structures needed for a subsequent call to the NServer_OpenDatablk function.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max.


256 chars.)
AllocString INPUT A string with a WHERE clause describing the path of the
datablocks. Note: The WHERE clause is the same as MSC.Nastran’s
DMAP statement DBVIEW.
Example of an AllocString to allocate datablock ZUZR11:
"DATABLK=ZUZR11 WHERE(ZNAME='MYDB'AND ZUZR1=1)"

Filept OUTPUT Return File Handle for future reference to the allocated datablock.
Nmatch OUTPUT Return number of matching datablocks. Only the first Filept is
returned.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Notes. that if the where clause/expression does not contain a specification for all
qualifiers then "WILDCARD=TRUE" should be specified.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 85
Database Features and APIs

NServer_CreateDatablk – Create a New Datablock (table or matrix)


From FORTRAN:
CALL NSCRTDB(...)
From C:
int NServer_CreateDatablk
( char *GrpName , char *CreateString , INTEGER *Filept ,
INTEGER *FileStat , INTEGER *Error );

Purpose. Interface call to create a new database entry for a datablock in the
MSC.Nastran database (using the specified CreateString (where clause), to set the
datablocks qualifier values), and to also create the necessary internal data structures
needed for the subsequent call to the NServer_OpenDatablk function.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max.


256 chars.)
CreateString INPUT A string used to describe the path (NDDL defined “key” values) of
the datablock to be created on the database.
Example of a CreateString to create datablock ZUZR11:
"DATABLK=ZUZR11 QUALS(ZNAME='MYDB'; ZUZR1=1)"
(Max. 1025 chars.)
Filept OUTPUT Return File Handle for future reference of the allocated datablock.
FileStat OUTPUT Return File Status:
0 for creating new datablock.
1 for overwriting existing datablock.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
86

NServer_Dbdict – Find One or More Datablocks and/or Parameters


Based on Key Values
(Functionally this is the same as the MSC.Nastran DBDICT command.)
From FORTRAN:
CALL NSDBDIC(...)
From C:
int NServer_Dbdict
( char *GrpName , char *DbdictString ,char*DbdictOut ,
int MaxLen, int *OutLeng , int *Error )

Purpose. To find one or more datablocks and/or parameters based on Key values—
functionally the same as the FMS statement DBDICT.

Arguments. Note that reference to DBDICT will be used in the following


descriptions since this API is the functional equivalent of that command.

GrpName INPUT An unique identifier for the Client/Server communication.


DbdicString INPUT String containing the input request to DBDI (Max 1025)
DbdictOut OUTPUT String containing the output from the DBDICT function.
MaxLen INPUT Max. length available for dbdictout string.
Note that if MaxLen is insufficient to hold the returning value to be
stored in DbdictOut then nothing will be returned in DbdictOut.
However, in this case OutLeng will contain the required length so
that a subsequent call can be made to NServer_Dbdict with
sufficient space allocated for DbDictOut
OutLeng OUTPUT actual length needed for DbdictOut string.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

See the MSC.Nastran Quick Reference Guide for a detailed description of the DBDICT
capabilities and the various output options.
CHAPTER 4 87
Database Features and APIs

NServer_FreeDbdictHandle – Disassociates a File Handle from the


Output from a DBDICT statement
From FORTRAN:
CALL NSFDHDL( . . . )
From C:

int NServer_FreeDbdictHandle

( INTEGER* Handle, INTEGER *ReturnCode, INTEGER *Error )

Purpose. Disassociates a file handle with the output from a DBDICT request
initially associated by Nserver_GetDbdictHandle..

Arguments. .
Handle OUTPUT A unique identifier for the associated DBDICT processing
space
ReturnCode OUTPUT Return Code
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. All malloc’ed space associated with the supplied handle will be freed.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
88

NServer_FMSCommand - Invoke the ASSIGN and DBLOCATE FMS


commands
From FORTRAN:
CALL NSFMSCM (...)
From C:

int NServer_FMSCommand

( char* GrpName, char *FMSCommand , INTEGER Status,


INTEGER *Error );

Purpose: To invoke the FMS commands "ASSIGN" and "DBLOCATE" after the
initial DMAP invocation (i.e., at a "breakpoint" after return from the NServer_Start
call).

Arguments:

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
FMSCommand INPUT The FMS commands (ASSIGN, DBLOCATE)
See the MSC.Nastran User Reference Guide for description of
these commannds)
Status OUTPUT API's execution status
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Notes: You may specify new ASSIGN and/or DBLOCATE commands after a
DMAP breakpoint has been reached. Note that one of more DMAP breakpoints is
always set within a Toolkit application, either explicitly by specification of a
breakpoint using the breakpoint API (NServer_SetExeBreak) or by taking the default
(i.e., "EXIT" DMAP).

Examples: (void) NServer_FMSCommand( "Linux_Server",


"ASSIGN EXT1='./mydb.MASTER'",
&Status, &Error);

(void) NServer_FMSCommand( "Linux_Server",


"DBLOCATE LOGICAL=EXT1 DATABLK=(GEOM1,GEOM2)",
&Status, &Error);
CHAPTER 4 89
Database Features and APIs

NServer_GetDatablock – retrieves the Datablocks stored on the


Database
From FORTRAN:
CALL NSDBFDB( . . . )
From C:
int NServer_GetDatablock
( char *GrpName, char * Option, char *DatablockList,
INTEGER DatablockListMax, INTEGER * DatablockListLen,
INTEGER * NumberOfDatablocks, INTEGER *Iret, INTEGER *Error )

Purpose. To return all datablocks defined by the supplied Option.

Arguments

GrpName INPUT A unique identifier for Client/Server


Communication
Option INPUT Datablock selection option
‘LOCAL’, ‘NDDL’, ‘BOTH’
DatablockList OUTPUT String containing a list of datablocks defined by the
given OPTION
DatablockListMax INPUT Available character length of DatablockList
DatablockListLen OUTPUT Character length used of DatablockList
NumberOfDatablocks OUTPUT Number of Datablocks in DatablockList
Iret OUTPUT Server function return code
0 = OK
1 = Insufficient Opencore to store requested Names
(NumberOfDatablocks set to -(additional opencore
needed))
2 = Insufficient String Length of DatablockList
(DatablockListLen set to -(additional characters
required))
3=1+2
4 = Invalid Option (immediate return)
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag
90

Notes. The string DatablockList is returned as a comma-delimited list with


extraneous blanks removed.
If the value for DatablockListMax is insufficient to return the requested information,
an Error Code is set and DatablockListLen is set to the negative of the additional space
required.
The NDDL type datablocks are prefaced by (NDDL).
The LOCAL type datablocks are prefaced by (SUBDMAP_name).

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 91
Database Features and APIs

NServer_GetDatablockForKey – retrieves the Datablocks defined by


a given KEY
From FORTRAN:
CALL NSDBFKY( . . . )
From C:
int NServer_GetDatablockForKey
( char *GrpName, INTEGER KeyNumber, char *DatablockList,
INTEGER * DatablockListMax, INTEGER * DatablockListLen,
INTEGER * NumberOfDatablocks, INTEGER *Iret, INTEGER *Error )

Purpose. To return all datablocks defined given the supplied KEY

Arguments

GrpName INPUT A unique identifier for Client/Server communication


KeyNumber INPUT Integer KEY value
DatablockList OUTPUT String containing a list of datablocks defined by the
given KeyNumber
DatablockListMax INPUT Maximum available character length of DatablockList
DatablockListLen OUTPUT Actual character length required by DatablockList
NumberOfDatablocks OUTPUT Number of Datablocks returned
Iret OUTPUT Server function return code
0 = OK
1 = Requested KEY not found (immediate return)
2 = Insufficient Opencore to store requested Names
(NumberOfDatablocks set to -(additional opencore
needed))
4 = Insufficient String Length of DatablockList
(DatablockListLen set to -(additional characters
required))
6=2+4
There are no return codes 3, 5 or 7
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. DatablockList is returned as a comma-delimited list with extraneous blanks


removed.
92

If the KeyNumber is undefined, then DatablockList and DatablockListLen are set to


blanks and zero, respectively.
If the value for DatablockListMax provides insufficient space to return the requested
information, an Error Code is set and DatablockListLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 93
Database Features and APIs

NServer_GetDatablockForPathName – retrieves the Datablocks


defined by a given Path Name
From FORTRAN:
CALL NSDBFPN( . . . )
From C:
int NServer_GetDatablockForPathName
(char *GrpName, char *PathName, char *DatablockList,
INTEGER DatablockListMax, INTEGER * DatablockListLen,
INTEGER * NumberOfDatablocks, INTEGER *Iret, INTEGER *Error)

Purpose. To return all datablocks defined given the supplied Path Name

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


PathName INPUT String containing the name of an NDDL-defined path
DatablockList OUTPUT String containing a list of datablocks defined by the
given Path Name
DatablockListMax INPUT Available character length of DatablockList string
DatablockListLen OUTPUT Actual character length of returned DatablockList
string
NumberOfDatablocks OUTPUT Number of datablocks listed in DatablockList
Iret OUTPUT Server function return code
0 = OK
1 = Equivalent PathPointer not found (immediate
return)
2 = Insufficient Opencore to store requested Names
(NumberOfDatablocks set to -(additional opencore
needed))
4 = Insufficient String Length of DatablockList
(DatablockListLen set to -(additional characters
required))
6=2+4
8 = PathName not found (immediate return)
There are no return codes 3, 5, 7, or 9-15
Error OUTPUT Server return error flag
94

Function return OUTPUT Server return error flag

Notes. DatablockList is returned as a comma-delimited list with extraneous blanks


removed.
If the PathName is undefined, then the DatablockList and DatablockListLen are set to
blanks and zero, respectively.
If the value for DatablockListMax provides insufficient space to return the requested
information, an Error Code is set and DatablockListLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 95
Database Features and APIs

NServer_GetDatablockForPathPtr – retrieves the Datablocks


defined by a given Path Pointer
From FORTRAN:
CALL NSDBFPP( . . . )
From C:
int NServer_GetDatablockForPathName
( char *GrpName, INTEGER PathPtr, char *DatablockList,
INTEGER DatablockListMax, INTEGER * DatablockListLen,
INTEGER * NumberOfDatablocks, INTEGER *Iret, INTEGER *Error )

Purpose. To return all datablocks defined given the supplied Path Name

Arguments

GrpName INPUT A unique identifier for Client/Server Communication


PathPtr INPUT Integer Path Pointer of an NDDL-defined path
DatablockList OUTPUT String containing a list of datablocks defined by the
given Path Name
DatablockListMax INPUT Available character length of DatablockList string
DatablockListLen OUTPUT Actual character length of returned DatablockList string
NumberOfDatablocks OUTPUT Number of datablocks listed in DatablockList
Iret OUTPUT Server function return code
0 = OK
1 = PathPtr not found (immediate return)
2 = Insufficient Opencore to store requested Names
(NumberOfDatablocks set to -(additional opencore
needed))
4 = Insufficient String Length of DatablockList
(DatablockListLen set to -(additional characters
required))
6=2+4
There are no return codes 3, 5, or 7
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. DatablockList is returned as a comma-delimited list with extraneous blanks


removed.
96

If the PathName is undefined, then the DatablockList and DatablockListLen are set to
blanks and zero, respectively.
If the value for DatablockListMax provides insufficient space to return the requested
information, an Error Code is set and DatablockListLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 97
Database Features and APIs

NServer_GetDatablockKeys – retrieves the KEYS associated with a


given Datablock
From FORTRAN:
CALL NSDBKEY( . . . )
From C:
int NServer_GetDatablockKeys
( char *GrpName, char *DatablockName, INTEGER array *KeyNumbers,
INTEGER MaxKeys, INTEGER *NumKeys, INTEGER *Iret,INTEGER *Error )

Purpose. To return the KEY values associated with the requested datablock family.

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


DatablockName INPUT String containing the name of a datablock
KeyNumbers OUTPUT Integer array of KEYs associated with the supplied
Datablock Name
MaxKeys INPUT Maximum length of KeyNumbers
NumKeys OUTPUT Number of KEYs returned
Iret OUTPUT Server function return code
0 = OK
1 = Requested Datablock not found (immediate return)
2 = Insufficient Opencore to store requested Keys
(NumKeys set to -(additional opencore needed))
4 = Insufficient Integer Array Declaration for KeyNumbers
(NumKeys set to -(additional wordss required))
6 = 2 + 4 (NumKeys set as in 4)
There are no return codes 3, 5 or 7
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If a datablock has more keys associated with it then MaxKeys, then MaxKeys
number of keys will be returned in KeyNumbers and NumKeys will be set to
(MaxKeys - actual number of keys).
If the datablock does not exist, the first element of KeyNumbers and NumKeys are set
to zero.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
98

NServer_GetDatablockPathName – retrieves the Path Name for a


given Datablock
From FORTRAN:
CALL NSDBPNM( . . . )
From C:
int NServer_GetDatablockPathName
( char *GrpName, char *DatablockName, char *PathName,
INTEGER *Iret, INTEGER *Error )

Purpose. To return the Path Name of the requested datablock.

Arguments.
GrpName INPUT A unique identifier for Client/Server Communication
DatablockName INPUT String containing the name of a datablock
PathName OUTPUT String containing the Path Name of the supplied
Datablock Name
Iret OUTPUT Server function return code
0 = OK
1 = Requested Datablock not found (immediate return)
2 = PathName not found
In both cases, PathName is set to "N/A".
Note: return 2 may indicate that the PathName Table
does not exist on the current database.
There is no return code 3.
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the DatablockName is undefined, then the PathName and


PathNameLen are set to “N/A” and zero, respectively.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 99
Database Features and APIs

NServer_GetDatablockPathPtr – retrieves the Path Pointer for a


given Datablock
From FORTRAN:
CALL NSDBPPT( . . . )
From C:
int NServer_GetDatablockPathPtr
( char *GrpName, char *DatablockName, INTEGER PathPtr,
INTEGER *Iret, INTEGER *Error )

Purpose. To return the Path Pointer of the requested datablock.

Arguments

GrpName INPUT A unique identifier for Client/Server Communication


DatablockName INPUT String containing the name of a Datablock
PathPtr OUTPUT Integer Path Pointer of the supplied Datablock Name
Iret OUTPUT Server function return code
0 = OK
1 = Requested Datablock not found (immediate return)
PathPtr is set to zero.
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the DatablockName is undefined, then the PathPtr and PathNameLen are
set to zero.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
100

NServer_GetDbdictHandle – Associates a File Handle with the


Output from a DBDICT statement
From FORTRAN:
CALL NSGDHDL( . . . )
From C:

int NServer_GetDbdictHandle

( char *GrpName, INTEGER* Handle, char


*DbdictInputString, INTEGER *ReturnCode, INTEGER *Error
)

Purpose. Associates a file handle with the output from the input DBDICT request.

Arguments.
GrpName INPUT A unique identifier for Client/Server communication
Handle OUTPUT A unique identifier for the associated DBDICT
processing space
DbdictInputString INPUT String containing the DBDICT input request. Max size =
1025 characters.
ReturnCode OUTPUT Return Code
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. The DBDICT FORMAT clause specification ‘COLSPACE=c’ as described in


the Quick Reference Guide should not be used in the DbdictInputString.
The DBDICT FORMAT clause specifications TYPEINFO and either or both of
COLDELIM[=column_delimiter] and LINDELIM[=line_delimiter] should be used in
the DbdictInputString.
If there is no FORMAT clause in the DbdictInputString, then the FORMAT clause
FORMAT(TYPEINFO,COLDELIM) is appended to the DbdictInputString.
If a FORMAT clause already exists, then the TYPEINFO and COLDELIM keywords
are added, if necessary.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 101
Database Features and APIs

NServer_GetDbdictLabel – Retrieves the Line Headers from the


DBDICT statement
From FORTRAN:
CALL NCDBLAB( . . . )
From C:
int NServer_GetDbdictLabel
( int *Handle, char *DbdictLabelString, int MaxLblLen,
int *LblLen, int *Error )

Purpose. To return the line header labels of the associated DBDICT statement.

Arguments.

Handle INPUT Handle used to identify current DBDICT output work area
DbdictLabelString OUTPUT String containing the label information returned from the
DBDICT function
MaxLblLen INPUT Maximum length available for DbdictLabelString
LblLen OUTPUT Actual length required for DbdictLabelString
Error OUTPUT Return error flag
Function return OUTPUT Return error flag

Notes. This function assumes that the Nserver_Dbdict API has been previously run
to generate DBDICT output and that output has been previously returned to the client
program, which identifies that output with the Handle previously defined.
The definition of the Handle must contain the relevant pointers used to access the
stored DbdictLabelString.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
102

NServer_GetDbdictTypes – Retrieves the data type information for


the line items of a logical DBDICT output line
From FORTRAN:
CALL NCDBTYP( . . . )
From C:
int NServer_GetDbdictTypes
( int * Handle, string *DbdictTypes, int MaxTypLen,int *TypLen,
int *Error )

Purpose. To return an array of data type information for the line items of a logical
DBDICT output line.

Arguments.

Handle INPUT Handle used to identify current DBDICT output work area
DbdictTypesArray OUTPUT An integer array containing the NASTRAN-defined data
types for each item returned in the DBDICT output
string.label information
MaxTypLen INPUT Maximum size of the array supplied for DbdictTypesArray
TypLen OUTPUT Actual length required for DbdictTypesArray
Error OUTPUT Return error flag
Function return OUTPUT Return error flag

Notes. This function assumes that the Nserver_Dbdict API has been previously run
to generate DBDICT output and that output has been previously returned to the client
program, which identifies that output with the Handle previously defined.
The definition of the Handle must contain the relevant pointers used to access the
stored DbdictTypesArray.
The DbdictTypes values are:
I - Integer
RS - Real single precision
CH - Character
RD - Real double precision
CS - Complex single precision
CD - Complex double precision
L - Logical

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 103
Database Features and APIs

NServer_GetDbdictValues – Retrieves the next value token from a


logical DBDICT output line and FREEDBDICT (NANO)
From FORTRAN:
CALL NSDBVAL( . . . )
From C:
int NServer_GetDbdictValues
( int * Handle, string * DbdictValue, int * DbdictValueType,
int *DbdictValueLength, int *Error )

Purpose. To return the next logical value, its type, and length, as delimited by
Delimiter.

Arguments.

Handle INPUT Handle used to identify current DBDICT output work


area.
DbdictValue OUTPUT The value of the associated DBDICT entry between
consecutive Delimiters
DbdictValueType OUTPUT Type of DbdictValue returned
DbdictValueLength OUTPUT Length of DbdictValue returned
Error OUTPUT Return error flag
Function return OUTPUT Return error flag

Notes. This function assumes that the Nserver_Dbdict API has been previously run
to generate DBDICT output and that output has been returned to the client program,
which identifies the output with the Handle previously defined.
The definition of the Handle must contain the relevant pointers to the output Dbdict
String, the Dbdict Labels, the Dbdict Types, and all information related to maintaining
current positions within any of the associated strings and arrays.
The DbdictValue is always returned as a character string.
The DbdictValueType is the standard MSC.Nastran values 1-7.
The DbdictValueLength is always returned as the length in characters of the
DbdictValue sring.
The Delimiter value ‘,’ returns a field within a logical record.
The Delimiter value ‘;’ returns a logical record.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
104

NServer_GetKeyPathName – retrieves the Path Name associated


with a given KEY
From FORTRAN:
CALL NSKYPTH( . . . )
From C:
int NServer_GetKeyPathName
( char *GrpName, INTEGER KeyNumber, char * PathName,
INTEGER * Iret, INTEGER *Error )

Purpose. To return the general Path Name associated with a specific KEY.

Arguments.
GrpName INPUT A unique identifier for Client/Server communication
KeyNumber INPUT Integer KEY value
PathName OUTPUT String containing an NDDL-defined Path Name
Iret OUTPUT Server function return code
0 = OK
1 = Requested Key not found (immediate return)
2 = PathName not found
In both cases, PathName is set to "N/A".
Note: return 2 may indicate that the PathName Table does
not exist on the current database
There is no return code 3.
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the KeyNumber is undefined, then PathName and


PathNameLen are set to “N/A” and zero, respectively.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 105
Database Features and APIs

NServer_GetKeyPathPtr – retrieves the Path Pointer associated


with a given KEY
From FORTRAN:
CALL NSKYPTP( . . . )
From C:
int NServer_GetKeyPathPtr
( char *GrpName, INTEGER KeyNumber, INTEGER * PathName,
INTEGER * Iret, INTEGER *Error )

Purpose. To return the general Path Pointer associated with a specific KEY.

Arguments.
GrpName INPUT A unique identifier for Client/Server communication
KeyNumber INPUT Integer KEY value
PathPtr OUTPUT Integer containing an NDDL-defined equivalent Path
Pointer
Iret OUTPUT Server function return code
0 = OK
1 = Requested Key not found (immediate return) PathPtr is
set to zero.
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the KeyNumber is undefined, then PathName and


PathNameLen are set to “N/A” and zero, respectively.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
106

NServer_GetKeyQualifiers – retrieves the Qualifier information


pertaining to the given Key
From FORTRAN:
CALL NSKEYQU( . . . )
From C:
int NServer_GetKeyQualifiers
( char *GrpName, INTEGER KeyNumber, char * QualifierTable,
INTEGER QualifierTableMax, INTEGER * QualifierTableLen,
INTEGER * NumberOfQualifiers, INTEGER * Iret, INTEGER *Error )

Purpose. To return the qualifier information for any given KEY value.

Arguments.
GrpName INPUT A unique identifier for Client/Server Communication
KeyNumber INPUT Integer KEY number
QualifierTable OUTPUT String containing a comma-delimited list of the qualifier
information defining the given KEY
QualifierTableMax INPUT Maximum available character length of QualifierTable
string
QualifierTableLen OUTPUT Actual character length of returned QualifierTable string
NumberOfQualifiers OUTPUT Number of Qualifiers defined in the string QualifierTable.
Iret OUTPUT Server function return code
0 = OK
1 = Requested KEY not found (immediate return)
2 = Insufficient Opencore to store requested Keys
(NumberOfQualifiers set to -(additional opencore
needed)) SFM 1139 generated by QUASEA subroutine
(immediate return)
4 = Insufficient String Length of QualifierTable
(QualifierTableLen set to -(additional characters
required))
There are no return codes 3 or 5-7.
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag
CHAPTER 4 107
Database Features and APIs

Notes. Under the current implementation, the maximum character


length of a Qualifier Name is eight characters.
QualifierTable is returned as a comma- and semicolon-delimited list with extraneous
blanks removed of the form: QualiferName,QualifierType,QualifierValue;
QualifierType is returned as one of 1 (integer), 2 (real single precision), or 3
(character).
Character values are returned enclosed in single quotes
The NumberOfQualifiers is always the actual number of Qualifiers defining the
specified KEY.
If the KeyNumber is undefined, then QualifierTable is set to blanks, and
QualifierTableLen and NumberOfQualifiers are set to zero.
If the value for QualifierTableMax provides insufficient space to return the requested
information, an Error Code is set and QualifierTableLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
108

NServer_GetPathNameKeys – retrieves the Key Values associated


with a given Path Name
From FORTRAN:
CALL NSPTHKY( . . . )
From C:
int NServer_GetPathNameKeys
( char *GrpName, char *PathName, INTEGER array * KeyList,
INTEGER MaxKeys, INTEGER * NumKeys, INTEGER *Iret,
INTEGER *Error )

Purpose. To return all specific KEY values associated with a given Path Name.

Arguments.

GrpName INPUT A unique identifier for Client/Server communication


PathName INPUT String containing an NDDL-defined Path Name
KeyList OUTPUT Integer array of KEYS associated with the supplied Path
Name
MaxKeys INPUT Maximum size of KeyList array
NumKeys OUTPUT Number of KEYS returned in KeyList
Iret OUTPUT Server function return code
0 = OK
1 = Equivalent PathPointer not found (immediate return)
2 = Insufficient Opencore to store requested Keys
(NumKeys set to -(additional opencore needed))
4 = Insufficient Integer Array Declaration for KeyList
(NumKeys to -(additional words required))
6=2+4 (NumKeys set as in 4)
8 = PathName not found (immediate return)
There are no return codes 3, 5, 7, or 9-15
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the PathName requested is undefined, then the first element of KeyList and
NumKeys are both set to zero.
If the PathName requested is defined, but has no specific Keys associated with it, then
the first element of KeyList is set to zero and NumKeys is set to zero.
CHAPTER 4 109
Database Features and APIs

NServer_GetPathPtrKeys – retrieves the Key Values associated


with a given Path Pointer
From FORTRAN:
CALL NSPTPKY( . . . )
From C:
int NServer_GetPathPtrKeys
( char *GrpName, INTEGER PathPtr, INTEGER array * KeyList,
INTEGER MaxKeys, INTEGER * NumKeys, INTEGER *Iret,
INTEGER *Error )

Purpose. To return all specific KEY values associated with a given Path Pointer.

Arguments.

GrpName INPUT A unique identifier for Client/Server communication


PathPtr INPUT Integer Path Pointer of an NDDL-defined Path
KeyList OUTPUT Integer array of KEYS associated with the supplied Path
Name
MaxKeys INPUT Maximum size of KeyList array
NumKeys OUTPUT Number of KEYS returned in KeyList
Iret OUTPUT Server function return code
0 = OK
1 = PathPointer not found (immediate return)
2 = Insufficient Opencore to store requested Keys
(NumKeys set to -(additional opencore needed))
4 = Insufficient Integer Array Declaration for KeyList
(NumKeys to -(additional words required))
6 = 2 + 4 (NumKeys set as in 4)
There are no return codes 3, 5, or 7
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. If the PathPtr requested is undefined, then the first element of KeyList and
NumKeys are both set to zero.
If the PathPtr requested is defined, but has no specific Keys associated with it, then the
first element of KeyList is set to zero and NumKeys is set to zero.
110

NServer_GetPathNameQualifiers – retrieves the Qualifier names


defining a given Path Name
From FORTRAN:
CALL NSPTHQU( . . . )
From C:
int NServer_GetPathNameQualifiers
( char *GrpName, char *PathName, char * QualifierList,
INTEGER QualifierListMax, INTEGER *QualifierListLen,
INTEGER * NumberOfQualifiers, INTEGER *Iret, INTEGER *Error )

Purpose. To return the qualifier names associated with a given Path Name.

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


PathName INPUT String containing the name of an NDDL-defined path
QualifierList OUTPUT String containing a list of the qualifier names defining
the given Path Name
QualifierListMax INPUT Maximum available character-length of QualifierList
string
QualifierListLen OUTPUT Used character-length of QualifierList string
NumberOfQualifiers OUTPUT Number of Qualifiers defined in the QualifierList
Iret OUTPUT Server function return code
0 = OK
1 = Equivalent PathPointer not found (immediate
return)
2 = Insufficient Opencore to store requested Qualifier
Table (NumberOfQualifiers set to -(additional opencore
needed)) SFM 1139 generated by QUANAM subroutine
(immediate return)
4 = Insufficient String Length of QualifierList
(QualifierListLen set to -(additional characters
required))
8 = PathName not found (immediate return)
There are no return codes 3, 5, 6, 7, or 9-15
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag
CHAPTER 4 111
Database Features and APIs

Notes. QualifierList is a comma-delimited list with extraneous blanks removed.


The NumberOfQualifiers is always the actual number of Qualifiers defining the
specified KEY.
If the PathName is undefined, then QualifierList is set to blanks, and QualifierListLen
and NumberOfQualifiers are set to zero.
If the value for QualifierListMax provides insufficient space to return the requested
information, an Error Code is set and QualifierListLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
112

NServer_GetPathPtrQualifiers – retrieves the Qualifier names


defining a given Path Pointer
From FORTRAN:
CALL NSPTPQU( . . . )
From C:
int NServer_GetPathPtrQualifiers
( char *GrpName, INTEGER PathPtr, char * QualifierList,
INTEGER QualifierListMax, INTEGER *QualifierListLen,
INTEGER * NumberOfQualifiers, INTEGER *Iret, INTEGER *Error )

Purpose. To return the qualifier names associated with a given Path Pointer.

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


PathPtr INPUT Integer Path Pointer of an NDDL-defined path
QualifierList OUTPUT String containing a list of the qualifier names defining the
given Path Name
QualifierListMax INPUT Maximum available character-length of QualifierList
string
QualifierListLen OUTPUT Used character-length of QualifierList string
NumberOfQualifiers OUTPUT Number of Qualifiers defined in the QualifierList
Iret OUTPUT Server function return code
0 = OK
1 = PathPointer not found (immediate return)
2 = Insufficient Opencore to store requested Qualifier
Table (NumberOfQualifiers set to -(additional opencore
needed)) SFM 1139 generated by QUANAM subroutine
(immediate return)
4 = Insufficient String Length of QualifierList
(QualifierListLen set to -(additional characters required))
There are no return codes 3, 5, 6, or 7
Error OUTPUT Server return error flag
Function return OUTPUT Server return error flag

Notes. QualifierList is a comma-delimited list with extraneous blanks removed.


CHAPTER 4 113
Database Features and APIs

The NumberOfQualifiers is always the actual number of Qualifiers defining the


specified KEY.
If the PathPtr is undefined, then QualifierList is set to blanks, and QualifierListLen
and NumberOfQualifiers are set to zero.
If the value for QualifierListMax provides insufficient space to return the requested
information, an Error Code is set and QualifierListLen is set to the negative of the
additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
114

NServer_GetPathNameQualifierDefaults – retrieves the default


Qualifier information defining a given Path Name
From FORTRAN:
CALL NSPTHQD( . . . )
From C:
int NServer_GetPathNameQualifierDefaults
( char *GrpName, char *PathName, char * QualifierDefTable,
INTEGER QualifierDefTableMax, INTEGER * QualifierDefTableLen,
INTEGER * NumberOfQualifiers, INTEGER * Return Code,
INTEGER *Error )

Purpose. To return the qualifier names associated with a given Path Name.

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


PathName INPUT String containing the name of an NDDL-defined path
QualifierDefTable OUTPUT String containing a list of the qualifier default
information defining the given Path Name
QualifierDefTableMax INPUT Maximum available character-length of
QualifierDefTable string
QualifierDefTableLen OUTPUT Used character-length of QualifierDefTable string
NumberOfQualifiers OUTPUT Number of Qualifiers defined in the QualifierDefTable
string
Iret OUTPUT Server function return code
0 = OK
1 = Equivalent PathPointer not found (immediate
return)
2 = Insufficient Opencore to store requested Qualifier
Table (NumberOfQualifiers set to -(additional
opencore needed)) SFM 1139 generated by QUADFT
subroutine (immediate return)
4 = Insufficient String Length of QualifierDefTable
(QualifierDefTableLen set to -(additional characters
required))
8 = PathName not found (immediate return)
There are no return codes 3, 5, 6, 7, or 9-15
CHAPTER 4 115
Database Features and APIs

Error OUTPUT Server return error flag


Function return OUTPUT Server return error flag

Notes. QualifierDefTable is returned as a comma- and semicolon-delimited list with


extraneous blanks removed of the form:
QualiferName,QualifierType,QualifierDefValue;
QualifierType is returned as one of 1 (integer), 2 (real single precision), or 3
(character).
Character values are returned enclosed in single quotes
The NumberOfQualifiers is always the actual number of Qualifiers defining the
specified PathName.
If the KeyNumber is undefined, then QualifierDefTable is set to blanks, and
QualifierDefTableLen and NumberOfQualifiers are set to zero.
If the value for QualifierDefTableMax provides insufficient space to return the
requested information, an Error Code is set and QualifierDefTableLen is set to the
negative of the additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
116

NServer_GetPathPtrQualifierDefaults – retrieves the default


Qualifier information defining a given Path Pointer
From FORTRAN:
CALL NSPTPQD( . . . )
From C:
int NServer_GetPathPtrQualifierDefaults
( char *GrpName, INTEGER PathPtr, char * QualifierDefTable,
INTEGER QualifierDefTableMax, INTEGER * QualifierDefTableLen,
INTEGER * NumberOfQualifiers, INTEGER * Return Code,
INTEGER *Error )

Purpose. To return the qualifier names associated with a given Path Pointer.

Arguments.

GrpName INPUT A unique identifier for Client/Server Communication


PathPtr INPUT Integer value of the Path Pointer of an NDDL-defined
path
QualifierDefTable OUTPUT String containing a list of the qualifier default
information defining the given Path Name
QualifierDefTableMax INPUT Maximum available character-length of
QualifierDefTable string
QualifierDefTableLen OUTPUT Used character-length of QualifierDefTable string
NumberOfQualifiers OUTPUT Number of Qualifiers defined in the QualifierDefTable
string
Iret OUTPUT Server function return code
0 = OK
1 = PathPointer not found (immediate return)
2 = Insufficient Opencore to store requested Qualifier
Table (NumberOfQualifiers set to -(additional
opencore needed)) SFM 1139 generated by QUADFT
subroutine (immediate return)
4 = Insufficient String Length of QualifierDefTable
(QualifierDefTableLen set to -(additional characters
required))
There are no return codes 3, 5, 6, or 7
Error OUTPUT Server return error flag
CHAPTER 4 117
Database Features and APIs

Function return OUTPUT Server return error flag

Notes. QualifierDefTable is returned as a comma- and semicolon-delimited list with


extraneous blanks removed of the form:
QualiferName,QualifierType,QualifierDefValue;
QualifierType is returned as one of 1 (integer), 2 (real single precision), or 3
(character).
Character values are returned enclosed in single quotes
The NumberOfQualifiers is always the actual number of Qualifiers defining the
specified PathName.
If the KeyNumber is undefined, then QualifierDefTable is set to blanks, and
QualifierDefTableLen and NumberOfQualifiers are set to zero.
If the value for QualifierDefTableMax provides insufficient space to return the
requested information, an Error Code is set and QualifierDefTableLen is set to the
negative of the additional space required.

Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
118
MSC.Nastran Toolkit User’s Guide

CHAPTER
File I/O APIs
5
■ GINO

■ General I/O Utilities

The following GINO description is an excerpt from the User Modifiable MSC.Nastran
User's Guide. It is included here since many of the basic Toolkit File I/O API's
described in this section perform the same General Input/Output (GINO) functions
as the corresponding I/O utilities used within MSC.Nastran—the primary difference
being that the Toolkit API's interface with Gino from an external client program
physically located outside the MSC.Nastran program.
120

5.1 GINO
GINO is a collection of Executive System subroutines that provides for all input and
output operations within MSC.Nastran, except reading data from the resident system
input file, writing data on the resident system output and punch files, writing plotter
output, and transferring data to and from foreign programs. These latter operations
are accomplished through FORTRAN formatted and unformatted read/write
statements.
GINO acts as a buffer between the MSC.Nastran functional modules and the
operating system of the computer. This design feature eliminates
computer-dependent code from the functional modules which are, consequently,
written mostly in FORTRAN. The use of computer-dependent code for the selection
of the operating system routines to accomplish the actual input/output functions is
isolated to a single routine within GINO.
All MSC.Nastran routines must use GINO. They are thus isolated from the actual
physical hardware and such concerns as blocking factors and device characteristics. In
turn, the data written by GINO is readable by any MSC.Nastran routine. GINO
enhances normal FORTRAN binary I/O by providing for end-of-file and
end-of-record returns as well as partial record reads and writes.

GINO Calls
All GINO physical records are blocked to a constant size with a potential for multiple
records per block or multiple blocks per record. Data blocks are written sequentially
but read both sequentially (forward and backward) and with a keyed form of direct
access. Since main memory is used as a scratch pad (no module may leave values in
main memory), GINO-formatted data blocks form the bulk of the intermodule
communications. MSC.Nastran performs input/output operations by making the
following calls to GINO entry points.

OPEN Initiates activity for a file unless the data block assigned to the file is purged, in
which case an alternate return is given. A working storage area, for use by GINO
(GINO buffer), is assigned (allocated) by the calling program, thus providing
optimum allocation or storage by the calling program. This working storage area
is reserved for use by GINO until activity on the file is terminated by a call to
CLOSE (see CLOSE, below). See NServer_OpenDatablk page 123.
WRITE Writes a specified (by the calling program) number of words on a file. The block of
words to be written may comprise an entire logical record or portion of a logical
record. See NServer_WriteRecord page 140.
READ Returns to the calling program a number of words from the logical record at
which the file is currently positioned as specified. READ may be used to transmit
an entire logical record or portion of a logical record as specified by the calling
program. See NServer_ReadRecord page 138.
CHAPTER 5 121
File I/O APIs

CLOSE CLOSE terminates activity for a file. The file is repositioned to the load point if
requested. See NServer_CloseDatablk page 125.
SKPREC Repositions the requested file one logical record forward or backward. See
NServer_SkipRecord page 130.

Logical Records
The basic unit of I/O in MSC.Nastran is a logical record. The length of a logical record
is completely variable and may range from zero words to an arbitrarily large number
of words. For matrix data blocks, the convention was adopted that each column of the
matrix would comprise one logical record. For data blocks containing tables, no rigid
convention exists. Typically each logical record contains one table of a specific type.
Since logical record lengths are variable, but the length of records physically read or
written is fixed, logic must be provided to accommodate this situation. This logic is
provided in the GINO routine, which allows for the following cases:
• Multiple logical records per block
• Multiple blocks per logical record
The method by which physical input and output of blocks is accomplished by GINO
is machine dependent. These implementation differences are transparent to the
MSC.Nastran applications programmer (functional module writer).
GINO files are always written sequentially and generally read sequentially, although
direct access reads are used in several key areas (EMA, DBMGR, and MPYAD).

GINO File Names


Internal GINO file numbers use the following conventions:
• input data blocks: 100 + position in the OSCAR entry (compiled DMAP).
• output data blocks: 200 + position in the OSCAR entry.
• scratch data blocks: 301 through 300 + n where n = number of scratch data
blocks as defined in an internal table called the Module Properties List
(MPL). (The position in the OSCAR entry is the position in the DMAP
instruction.)
For example, consider the following DMAP calling sequence for functional module
XYZ:

XYZ A,B,C/D,E,F,G/$
122

The data blocks input to the module are A, B and C; the data blocks output from the
module are D, E, F, and G. Note that internal scratch files are not mentioned in the
DMAP calling sequence. The number of scratch files for a module is defined in the
Module Property List (MPL) Executive table and is communicated to the Executive
System through the OSCAR.
In order to read the input data block B, the GINO file number internal to XYZ is 102;
in order to write data block D, the GINO file number is 201. The third of, say, five
scratch data blocks is referenced by XYZ through the GINO file number 303.
CHAPTER 5 123
File I/O APIs

5.2 General I/O Utilities


NServer_OpenDatablk – Open a Datablock (matrix or table)
From FORTRAN:
CALL NSOPNDB(...)
From C:
int NServer_OpenDatablk
( char *GrpName , INTEGER Filept, char R_or_W, char REW_NOREW,
INTERGER Iret ,INTEGER *Error );

Purpose. Interface call to open a Datablock File from MSC.Nastran database, for
read or write.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation API
calls (see NServer_AllocDatablk and NServer_CreateDatablk).
R_or_W INPUT 'R' for Read or 'W' for Write Option
REW_NOREW INPUT 'Y' for Rewind or 'N' for No-Rewind option
Iret OUTPUT Non-Zero value indicates that file does not exist.
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag
124

NServer_GOpenDatablk – Open a Datablock (table or matrix)


Differs from NServer_OpenDatablk in the way it handles the header record (record 0)
From FORTRAN:
CALL NSGPNDB(...)
From C:
int NServer_GOpenDatablk
( char *GrpName , INTEGER Filept , char R_or_W ,
char REW_NOREW ,INTEGER *Error );

Purpose. Interface call to open a Datablock File from MSC.Nastran database:


• For read option: skip the header record 0 and position at record 1.
• For write option: generate a header record 0 and position at record 1.
Arguments.

GrpName INPUT An unique identifier for the Client/Server communication.


(Max. 256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation
R_or_W INPUT 'R' for Read or 'W' for Write Option
REW_NOREW INPUT 'Y' for Rewind or 'N' for No-Rewind option
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag
CHAPTER 5 125
File I/O APIs

NServer_CloseDatablk – Close a Datablock (table or matrix)


From FORTRAN:
CALL NSCLSDB(...)
From C:
int NServer_CloseDatablk
( char *GrpName , INTEGER Filept , char REW_NOREW ,
INTEGER *Error );

Purpose. Interface call to close a Datablock previously open

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication.


(Max. 256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation
REW_NOREW INPUT 'Y' for Rewind or 'N' for No-Rewind option
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag
126

NServer_PrelocDatablk – Prepare a Datablock to be Accessed by


NServer_LocateRecord
From FORTRAN:
CALL NSPRELO(…)
From C:
int NServer_PrelocDatablk
( char *GrpName , INTEGER Filept , INTEGER *Retno ,
INTEGER *Error);

Purpose. Prepares a datablock for access by NServer_LocateRecord. It opens an IFP


file and positions to first data record.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
Filept INPUT File handle of the datablock
Retno OUTPUT Return code of the preloc function
Error OUTPUT Return error code
Func. Ret. OUTPUT Server return error flag.

Example. Demonstrates how to use …PrelocDatablk and…LocateDatablk to open a


datablock (Geom2) and then position that datablock for "read" access at the beginning
of the record PLOTEL.
CHAPTER 5 127
File I/O APIs

SUBROUTINE XDBGM2 (GRPNAM,LNBUF,IBUF, N P L T E L , I R C )


C
C This subroutine returns the number of PLOTEL entries found in GEOM2.
C
C Input GRPNAM ... Group Name of the Server
C LNBUF ... Length of Working Array
C IBUF(*) ... Working Array
C Output NPLTEL ... Number of PLOTEL entries in GEOM2
C IRC ... Return Code: 0 Normal End
C 1 Errors Encountered
C
C
C ----------------------------------------------------------------------
C
CHARACTER*(*) GRPNAM
LOGICAL XTLBIT
INTEGER IBUF(*)
INTEGER IPLTEL(2),ITRAIL(7)
C
C First 2 Header Words of PLOTEL Record
DATA IPLTEL /5201, 52/
C
C
IRC =0
NPLTEL=0
C Initialize local I/O for this subroutine (non-Toolkit related)
CALL QIOTRM ( I N , I O U T )
C
C Allocate GEOM2
C
CALL NSALLDB (GRPNAM,'DATABLK=GEOM2', I F I L P T ,
. N M A T C H , I E R A P I )
IF (IERAPI.NE.0) GO TO 910
IF (NMATCH.EQ.0) GO TO 999
C
C Check Trailer for Existence of PLOTEL Record
C
CALL NSRDTRL (GRPNAM,IFILPT, I T R A I L , I E R A P I )
IF (IERAPI.NE.0) GO TO 911
IF (.NOT.XTLBIT(IPLTEL(2),ITRAIL(2))) GO TO 999
C
C Open GEOM2 (contains PLOTELs)
C
CALL NSPRELO (GRPNAM,IFILPT, I R E T , I E R A P I )
IF (IERAPI.NE.0.OR.IRET.NE.0) GO TO 912
C
C Locate PLOTEL Record
C
CALL NSLOCAT (GRPNAM,IFILPT,IPLTEL,
. I F L A G , I R E T , I E R A P I )
IF (IERAPI.NE.0) GO TO 913
IF (IRET.NE.0) GO TO 920
128

C
C Get Number of PLOTELs
C
NWORDS=0
2 CONTINUE
CALL NSREADR (GRPNAM,IFILPT, I B U F ,LNBUF,0,
. I E O R , N W , I E R A P I )
IF (IERAPI.NE.0) GO TO 913
NWORDS=NWORDS+NW
IF (IEOR.EQ.0) GO TO 2
NPLTEL=NWORDS/3
C
C Close GEOM2
C
990 CALL NSCLSDB (GRPNAM,IFILPT,'N', I E R A P I )
IF (IERAPI.EQ.0) GO TO 999
C
WRITE(IOUT,9100) IERAPI,'NSCLSDB'
IRC=1
GO TO 999
C
C Error Branch
C
910 WRITE(IOUT,9100) IERAPI,'NSALLDB'
9100 FORMAT(2X,'*E* XDBGM2: API Error Code ',I10,' from ',A7)
IRC=1
GO TO 999
C
911 WRITE(IOUT,9100) IERAPI,'NSRDTRL'
IRC=1
GO TO 999
C
912 WRITE(IOUT,9120) IERAPI,IRET
9120 FORMAT(2X,'*E* XDBGM2: API Error Code ',I10,' from NSPRELO'/
. 2X,' Result Code is ',I10)
IRC=1
GO TO 990

C
913 WRITE(IOUT,9100) IERAPI,'NSLOCAT'
IRC=1
GO TO 990
C
914 WRITE(IOUT,9100) IERAPI,'NSREADR'
IRC=1
GO TO 990
C
920 WRITE(IOUT,9200)
9200 FORMAT(2X,'*E* XDBGM2: Datablock GEOM2 is corrupted')
IRC=1
GO TO 990
C
999 CONTINUE
RETURN
END
CHAPTER 5 129
File I/O APIs

NServer_LocateRecord – Position an IFP File to the Requested


Record
From FORTRAN:
CALL NSLOCAT(…)
From C:
int NServer_LocateRecord
(char *GrpName, INTEGER Filept , INTEGER *Id , INTEGER *Flag ,
INTEGER *Retno , INTEGER *Error );

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication.


(Max. 256 chars.)
Filept INPUT File Handle of the datablock.
Id INPUT 2-word IFP table locate-id of the record being requested.
Flag OUTPUT Return flag code of the locate function.
Retno OUTPUT Return code of the locate function.
Func. Ret. OUTPUT Server return error flag.

Example: See NServer_PrelocDatablk example on page 126.


130

NServer_SkipRecord – Skip a Record (Table or Matrix Column)


From FORTRAN:
CALL NSSKIPR(...)
From C:
int NServer_SkipRecord
( char *GrpName , INTEGER Filept , INTEGER Nrec,
INTEGER *Error );

Purpose. Interface call to skip records (table) or Column (matrix) of a datablock.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
Nrec INPUT Number of Records to be skipped
> 0 for forwards
< 0 for backwards
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 5 131
File I/O APIs

NServer_ReadTrailer – Read a Datablock Trailer Record


From FORTRAN:
CALL NSRDTRL(...)
From C:
int NServer_ReadTrailer
( char *GrpNamerpName , INTEGER Filept , INTEGER *Trailer ,
INTEGER *Error );

Purpose. Interface call to Read the Trailer of a datablock.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
Trailer OUTPUT The return trailer (7 words).
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example: See NServer_PrelocDatablk example on page 126.


132

NServer_ReadTrailerX – Read the Extended Trailer of a Datablock


From FORTRAN:
CALL NSRDTRX(...)
From C:
int NServer_ReadTrailerX
( char *GrpName , INTEGER Filept , INTEGER *TrailerX ,
INTEGER *Error );

Purpose. Interface call that will return both the standard 7 word matrix trailer (see
NServer_ReadTrailer) and the 7 word matrix trailer extension.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
TrailerX OUTPUT The return trailer (14 words).
(See the document "MSC.Nastran Datablocks and Dmap Modules"
for a description of these trailer words.)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 5 133
File I/O APIs

NServer_MakeTrailer – Make a Trailer Control Block for a Matrix


Datablock
From FORTRAN:
CALL NSMKTRL(...)
From C:
int NServer_MakeTrailer
(char *GrpName , INTEGER *Trailer , INTEGER Filept ,
INTEGER NumRow , INTEGER MatForm , INTEGER MatType ,
INTEGER *Error );

Purpose. Interface call to make Trailer Control Block for a Matrix datablock.
Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Trailer OUTPUT The return trailer (7 words).
Filept INPUT Datablock File handle from previous allocation or creation.
NumRow INPUT Number of row.
MatForm INPUT Form of Matrix
1: Square Matrix
2: Rectangular Matrix
3: Diagonal Matrix
4: Lower Triangle Matrix
5: Upper Triangle Matrix
6: Symmetric Matrix
7: Row Vector Matrix
8: Identity Matrix
9: Transformation matrix
10: Cholesky Lower Triangle Factor
11: Partial Lower Triangle Factor
MatType INPUT Type of Matrix
1: Real Single Precision
2: Real Double Precision
3: Real Complex Single Precision
4: Real Complex Double Precision
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Note. Forms the 7-word trailer from the given information.


134

NServer_WriteTrailer – Write the Trailer of a Datablock


From FORTRAN:
CALL NSWRTRL(...)
From C:
int NServer_WriteTrailer
( char *GrpName , INTEGER Filept , INTEGER *Trailer ,
INTEGER *Error );

Purpose. Interface call to write the Trailer of a datablock (for both table and matrix).

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
Trailer OUTPUT The trailer (7 words)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 5 135
File I/O APIs

NServer_FilposRecord – Position the Record to a Given Direct


Access Index
From FORTRAN:
CALL NSFILPS
From C:
int NServer_FilposRecord
( char *GrpName, INTEGER Filept, INTEGER *Filpos,
INTEGER *Error );

Purpose. Position the record to a given direct access index.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT File handle of the datablock.
Pos INPUT 2-word integer of the index (output from NServer_SavposRecord).
Error INPUT Return error code.
Func. Ret. OUTPUT Server return error flag.
136

NServer_SavposRecord – Save Direct Access Index of the Current


Record
From FORTRAN:
CALL NSSVPOS
From C:
int NServer_SavposRecord
( char *GrpName, INTEGER Filept, INTEGER *Filpos,
INTEGER *Error );

Purpose. Save direct access index of the current record.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT The file handle for the datablock.
FilPos OUTPUT 2-word integer of the index.
Error OUTPUT Return error code.
Func. Ret. OUTPUT Server return error flag.
MSC.Nastran Toolkit User’s Guide

CHAPTER
Table I/O APIs
6
■ Table APIs
138

6.1 Table APIs


NServer_ReadRecord – Read a Record from a Datablock (table only)
From FORTRAN:
CALL NSREADR(...)
From C:

int NServer_ReadRecord

( char *GrpName , INTEGER *Filept ,


INTEGER *Record , INTEGER Nleng , INTEGER EOR,
INTEGER EORret, INTEGER *NWread , INTEGER *Error
);

Purpose. Interface call to read a Record of a Table datablock.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
Record OUTPUT A Buffer for data.
Nleng INPUT Requested Max size of INTEGER words to be read from Record.
EOR INPUT End of record control flag.
0 – No advance to next record after READ
1 – Advance to next record after READ
EORret OUTPUT 0 – Subsequent call to Nserver_ReadRecord for the logical record are
expected.
1 – End-of-file encountered.
2 – End-of-logical Record encountered. The Current Call is the last
call for the current record. The file will be positioned to the
beginning of the next logical record before returning.
NWread OUTPUT Actual size of INTEGER words that have been read.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 6 139
Table I/O APIs

Note. Reads the current record of a datablock. The returned data has mixed data
types (i.e., integer, reals, etc.). Thus, the client application has to know the format of
the data to unpack and correctly process it (see NServer_NDDLDesc).
Example . See NServer_PrelocDatablk example on page 126.
140

NServer_WriteRecord – Write a Record of a Table Datablock


From FORTRAN:
CALL NSWRITE(...)
From C:

int NServer_WriteRecord

( char *GrpName , INTEGER *Filept , INTEGER


*Record , INTEGER Nleng , INTEGER EOR , INTEGER
*Error );

Purpose. Write a Record of a table datablock.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication.


Filept INPUT Handle of the table datablock.
Record INPUT Contains the data to be written.
Nleng INPUT Number of words to be written.
EOR INPUT Write an End-Of-Record flag after this write operation.
0= Don’t write an EOR. Leave record at current position ready for
additional calls to NServer_WriteRecord.
1=Write an EOR.
Error INPUT Return Error Status.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 6 141
Table I/O APIs

Example. The following function shows an example of “writing” and “reading”


table datablocks.

void WriteTable ( char *GrpName )

char *CreateString={"DBCREATE DATABLK=ZUZR11 QUALS (ZNAME='AUPA') "};

int i,Filept,FileStat,Error;

int RecLen,EOR=1, EORret, RecNum;


int Record[RECSIZE], Array[RECSIZE];

/*
* Create a datablock to output data
*/
(void) NServer_CreateDatablk ( GrpName , CreateString , &Filept , &FileStat ,&Error
);

(void) fprintf(stderr, " NServer_CreateDatablk CreateString=%s\n",CreateString);


(void) fprintf(stderr, " Filept=%d FileStat=%d Error=%d\n",Filept,FileStat,Error);

if( !Filept || Error ) return;


/*
* Fill up record
*/
for (i=0 ; i<RECSIZE ; i++ )
Record[i]=i+1;

/*
* Open datablock to write
*/
(void) NServer_GOpenDatablk( GrpName , Filept , 'W' , 'Y' , &Error );
/*
* Write to datablock
*/

fprintf(stderr, " Call NServer_WriteRecord for Group %s


Filept=%d\n",GrpName,Filept);
for (RecNum=0 ; RecNum<MAXREC ; RecNum++ ) {
RecLen = RecNum+1;

(void) NServer_WriteRecord ( GrpName , Filept , Record , RecLen, EOR , &Error );


(void) fprintf( stderr," Write Record_Number %d Record_Length is
%d\n",RecNum,RecLen);
for( i=0,(void) fprintf( stderr," Write Data=") ;
i < RecLen ;
(void) fprintf( stderr," %d ",Record[i]) , i++ );
(void) fprintf( stderr,"\n");
}
142

/*
* Close datablock
*/
(void) NServer_CloseDatablk( GrpName , Filept , 'Y' , &Error );

/*
* Reopen datablock to read back record by record then close it
*/
(void) NServer_GOpenDatablk( GrpName , Filept , 'R' , 'Y' , &Error );

fprintf(stderr, " Call NServer_ReadRecord for Group %s Filept=%d\n",GrpName,Filept);

for (RecNum=0 ; RecNum<MAXREC ; RecNum++ ) {


(void) NServer_ReadRecord( GrpName , Filept , Array , RECSIZE , EOR ,&EORret,
&RecLen , &Error );
(void) fprintf( stderr," Read Record_Number %d Record_Length is
%d\n",RecNum,RecLen);

for( i=0,(void) fprintf( stderr," Read Data=") ;


i < RecLen ;
(void) fprintf( stderr," %d ",Array[i]) , i++ );
(void) fprintf( stderr,"\n");
}

(void) NServer_CloseDatablk( GrpName , Filept , 'Y' , &Error );

}
CHAPTER 6 143
Table I/O APIs

NServer_AddRecTerm – Add Term(s) of a Record to a Table


DataBlock
From FORTRAN:
CALL NSARTER (...)
From C:

int NServer_AddRecTerm

( char *GrpName , INTEGER Filept , char


*TermDescriptor , INTEGER NRepeat ,
INTEGER *TermData , INTEGER *NTermAdd , INTEGER
*NWordAdd , INTEGER EOR, INTEGER *Error );

Purpose. Add Term(s) of a Record to a Table DataBlock

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
Filept INPUT File Handler for reference of the DataBlock
TermDescriptor INPUT Buffer contains the description for term data
Types signature are identical to NDDL types:
I Integer
RSReal Single Precision
CHAR4Character 4
RDReal Double Precision
CSComplex Single Precision
CDComplex Double Precision
LOGICALLogical
RXReal Machine Precision
CXComplex Machine Precision
Comma or blank(s) can be used for delimiter.
NRepeat INPUT Number of repeated TermDescriptor
TermData INPUT Buffer contains the Record term data to add
NTermGet OUTPUT Number of Terms have been added in record
NWordGet OUTPUT Number of Words have been added in record
144

EOR INPUT End of Record control flag


= 0: No advance to next record after adding data terms
= 1: Advance to next record after adding data terms
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.

Application Notes.
1. DataBlock has to be pre-allocated via NServer_CreateDatablk.
2. DataBlock has to be open using option 'A' (Add) in
NServer_OpenDatablk or NServer_GOpenDatablk.
3. After adding all entries, DataBlock should be closed via
NServer_CloseDatablk and trailer should be written via
NServer_WriteTrailer.
4. DataBlock's data format is not limited to NDDL typed data, for example,
apply your own data description for ZUZR DataBlocks.

Example of C-program Application Usage.


A basic format descriptor for GRID cards of GEOM1 table:
"2I 3RX 3I", which applied to a data structure of 8 terms of 11 words on double
machine or 8 words on a single machine
To add 4 Grid cards to GEOM1 DataBlock:
NRepeat = 4;
(void) NServer_AddRecTerm( GrpName,
GEOM1Filept,
"2I,3RX,3I",
NRepeat,
(INTEGER *)GRIDdatainp,
&NTermAdd,
&NWordAdd,
EOR,
&Error );
CHAPTER 6 145
Table I/O APIs

Alternatively, it can be coded as:


NRepeat = 1;
(void) NServer_AddRecTerm( GrpName,
GEOM1Filept,
"4(2I,3RX,3I)",
NRepeat,
(INTEGER *)GRIDdatainp,
&NTermAdd,
&NWordAdd,
EOR,
&Error );
146

NServer_GetRecTerm – Get Terms of a Record from a Table


Datablock
From FORTRAN:
CALL NSGRTER (...)
From C:

int NServer_GetRecTerm

( char *GrpName, INTEGER Filept,


char *TermDescriptor, INTEGER NRepeat,
INTEGER *TermData, INTEGER *NTermGet,
INTEGER *NWordGet, INTEGER EOR, INTEGER *EORret,
INTEGER *Error );

Purpose. Get Term(s) of a Record from a Table DataBlock.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
Filept INPUT File Handle for reference of the DataBlock
TermDescriptor INPUT Buffer contains the description for term data
Types signature are identical to NDDL types :
I Integer
RSReal Single Precision
CHAR4Character 4
RDReal Double Precision
CSComplex Single Precision
CDComplex Double Precision
LOGICALLogical
RXReal Machine Precision
CXComplex Machine Precision
Comma or blank(s) can be used for delimiter.
NRepeat INPUT Number of repeated TermDescriptor
TermData INPUT Buffer contains the Record term data to get
NTermGet OUTPUT Number of Terms have been gotten in record
NWordGet OUTPUT Number of Words have been gotten in record
CHAPTER 6 147
Table I/O APIs

EOR INPUT End of Record control flag


= 0: No advance to next record after getting data terms
= 1: Advance to next record after getting data terms
EORret OUTPUT Return flag for EOR indicator
Error OUTPUT Server return status error
Func. Ret. OUTPUT Server return error flag.

Application Notes.
1. DataBlock has to be pre-allocated via NServer_AllocDatablk.
2. DataBlock has to be open using option 'G' (Get) in NServer_OpenDatablk or
NServer_GOpenDatablk.
3. After getting all entries, DataBlock should be closed via
NServer_CloseDatablk and trailer should be written via
NServer_WriteTrailer.
4. DataBlock's data format is not limited to NDDL typed data. For example,
you can apply your own data description for ZUZR DataBlocks.

Example of C-program Application Usage.


A basic format descriptor for GRID cards of GEOM1 table:
"2I 3RX 3I", which applied to a data structure of 8 terms of 11 words on double
machine or 8 words on a single machine
To get 4 GRID cards from GEOM1 DataBlock:
NRepeat = 4;
(void) NServer_GetRecTerm( GrpName,
GEOM1Filept,
"2I,3RX,3I",
NRepeat, (INTEGER *)GRIDdataout,
&NTermGet,
&NWordGet,
EOR,
&EORret,
&Error );
148

Alternatively, it can be coded as:


NRepeat = 1;
(void) NServer_GetRecTerm( GrpName,
GEOM1Filept,
"4(2I,3RX,3I)",
NRepeat,
(INTEGER *)GRIDdataout,
&NTermGet,
&NWordGet,
EOR,
&EORret,
&Error );
CHAPTER 6 149
Table I/O APIs

NServer_SizeofServerNDDLTerm – Get Size of NDDL Term (Server)


From FORTRAN:
CALL NSSZNDL (...)
From C:

int NServer_SizeofServerNDDLTerm

( char *GrpName, char *NDDLTerm,


INTEGER *NintegerWord, INTEGER *Error);

Purpose. Get the Server’s size in integer word of NDDL term(s)

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier
NDDLTerm INPUT String contains one or more NDDL term(s)
Types signature are identical to NDDL types:
I Integer
RSReal Single Precision
CHAR4Character 4
RDReal Double Precision
CSComplex Single Precision
CDComplex Double Precision
LOGICALLogical
RXReal Machine Precision
CXComplex Machine Precision
Comma or blank(s) can be used for delimiter.
NintegerWord OUTPUT Number of counted integer words in NDDLTerm
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.

NDDL Term Size on 32-Bit Machine Size on 64-Bit Machine


I 1 1
RS 1 1
CHAR4 1 1
150

NDDL Term Size on 32-Bit Machine Size on 64-Bit Machine


RD 2 2
CS 2 2
CD 4 4
LOGICAL 1 1
RX 2 1
CX 4 2
CHAPTER 6 151
Table I/O APIs

NServer_SizeofClientNDDLTerm – Get Size of NDDL Term (Client)


From FORTRAN:
CALL NSZCNDL (...)
From C:

int NServer_SizeofClientNDDLTerm

( char *NDDLTerm, INTEGER *NintegerWord,


INTEGER *Error);

Purpose. Get the Client’s size in integer word of NDDL term(s).

Arguments.

NDDLTerm INPUT String contains one or more NDDL term(s)


Types signature are identical to NDDL types:
I Integer
RS Real Single Precision
CHAR4 Character 4
RD Real Double Precision
CS Complex Single Precision
CD Complex Double Precision
LOGICAL Logical
RX Real Machine Precision
CX Complex Machine Precision
Comma or blank(s) can be used for delimiter.
NintegerWord OUTPUT Number of counted integer words in NDDLTerm
Error OUTPUT Return status error
Func. Ret. OUTPUT Server return error flag.
MSC.Nastran Toolkit User’s Guide

CHAPTER
Matrix I/O APIs
7
■ Matrix APIs

The following ...Pack and ...Unpack API’s provide a standard full column (with zero’s
expanded) capability as well as a “sparse” set of API’s (PackColumnI,
UnpackColumnI) that use only the non-zero terms and a corresponding array of
row#’s for these terms. All matrices within MSC.Nastran can be accessed using either
type of sparse or non-sparse Pack/UnPack API.
154

7.1 Matrix APIs


NServer_PackColumn – Pack out a Matrix Column
From FORTRAN:
CALL NSPAKCL(...)
From C:

int NServer_PackColumn

( char *GrpName , INTEGER Filept , INTEGER


*ColCntl , INTEGER *Trailer , MACHINEPRECISION
*Column , INTEGER *Error );

Purpose. Interface call to Pack a matrix's Column.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
ColCntl INPUT Column Control block: a 5-int-word array
Type of input data (Column)
Type of Output data
Begin Row number
End Row number
Row Increment
Column INPUT Column Data.
Trailer INPUT The trailer (7 words).
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Note: To make a null column, call NServer_PackNullColumn.

Examples. This first program (MATRIX) demonstrates how to write ("pack") data to
a matrix. The second program (Example3c) demonstrates how to write (“pack”) and
read(“unpack”) data from a matrix.
CHAPTER 7 155
Matrix I/O APIs

.
156

PROGRAM MATRIX
C
C Purpose: Small Test Program to put a matrix into a NASTRAN database.
C DMAP must contain HALT statement.
C
C ---------------------------------------------------------------------
C
PARAMETER (NROW=10,NCOL=5,MAXLEN=1000)
C
CHARACTER*8 SBDMAP,DMAP
CHARACTER*39 STRING
CHARACTER*(MAXLEN) DBLIST
C
INTEGER ITRAIL(7),ICCNTL(5)
C
C
C
C Start the NASTRAN Server
CALL NSSTART ('matrix',
. 'test_halt mem=4m scr=yes',
. 'nastran',
. I E R A P I)
IF (IERAPI .NE. 0) GO TO 999
C
C Execute Solution Sequence
CALL NSSOLEX('matrix' , I E R A P I )
IF (IERAPI .NE. 0) GO TO 990
C
C Wait for DMAP to reach Breakpoint (e.g., DMAP HALT $)
1 CONTINUE
IWAIT=0
CALL NSEXSTA ('matrix',IWAIT, I S T A T , S B D M A P ,
. D M A P , I S Q N , N D B , N P A R M ,
. I E R A P I )
WRITE(*,*) 'Waitmode = ',IWAIT
WRITE(*,*) 'ExeStatus = ',ISTAT
WRITE(*,*) 'SubDMAP = ',SBDMAP
WRITE(*,*) 'DMAP = ',DMAP
WRITE(*,*) 'DMAPSeqno = ',ISQN
WRITE(*,*) 'Ndatablk = ',NDB
WRITE(*,*) 'Nparam = ',NPARM
WRITE(*,*) 'Error = ',IERAPI
IF (IERAPI.NE.0) GO TO 990
IF (ISTAT.NE.0) GO TO 1
C
C Create Matrix Datablock ZUZR1
STRING='DBCREATE DATABLK=ZUZR01 QUALS (ZUZR1=0)'
CALL NSCRTDB ('matrix',STRING, I F I L P T , I S T A T ,
. I E R A P I )
WRITE(*,*) 'NSCRTDB ISTAT = ',ISTAT,' IERAPI = ',
. IERAPI,' IFILPT = ',IFILPT
IF (IERAPI.NE.0) GO TO 990
C
C Make a Trailer for a Rectangular Matrix
IFORM=2
ITYPE=2
CALL NSMKTRL ('matrix', I T R A I L ,IFILPT,
. NROW,IFORM,ITYPE, I E R A P I )
CHAPTER 7 157
Matrix I/O APIs

IF (IERAPI.NE.0) GO TO 990
C

C Open Datablock ZUZR01


CALL NSGPNDB ('matrix',IFILPT,'W','Y', I E R A P I )
WRITE(*,*) 'NSGPNDB IERAPI= ',IERAPI
IF (IERAPI.NE.0) GO TO 990
C
C Pack the terms in the Columns (“CALL NSACKCL”)
C
ICCNTL(1)=1
ICCNTL(2)=ITYPE
ICCNTL(5)=1
C
DO 20 J=1,NCOL
ICCNTL(3)=J
ICCNTL(4)=J
COLVAL=FLOAT(J)
CALL NSPAKCL ('matrix',IFILPT,ICCNTL, I T R A I L ,
. COLVAL, I E R A P I )
WRITE(*,*) 'J = ',J,' NSPAKCL IERAPI= ',IERAPI
IF (IERAPI.NE.0) GO TO 990
20 CONTINUE
C
C Close the Datablock
CALL NSCLSDB ('matrix',IFILPT,'Y', I E R A P I )
IF (IERAPI.NE.0) GO TO 990
C
C Write the MATRIX Trailer
CALL NSWRTRL ('matrix',IFILPT,ITRAIL, I E R A P I )
IF (IERAPI.NE.0) GO TO 990
C
C DBDICT
CALL NSDBDIC ('matrix','DBDICT DATABLK=ZUZR01',
. D B L I S T ,MAXLEN, L E N , I E R A P I )
WRITE(*,*) 'DBDICT LEN= ',LEN,' IERAPI= ',IERAPI
WRITE(*,*) DBLIST(1:LEN)
C
C Resume DMAP Execution
CALL NSRESUM ('matrix', I E R A P I )
IF (IERAPI.NE.0) GO TO 990
C
C Get Error Status from Solution Sequence
CALL NSNSTAT('matrix', I E R A P I )
IF (IERAPI .NE. 0) GO TO 990
C
GO TO 999
C
990 CONTINUE
WRITE(*,*) 'IERAPI=',IERAPI
C
C Exit and Close NASTRAN Server
999 CONTINUE
CALL NSSEXIT('matrix' , I E R A P I )
write(*,*) 'NSSEXIT IERAPI = ',IERAPI
C
STOP
END
158

/*
* Program Example3c.c
*
* Purpose:

* This program shows how to write (“Pack”) and read (“UNPACK”)


* a matrix type datablock.
*
* Note: This Example3c program’s input file (example3.dat) and its
* output files (.f04, .f06, .prt) can be found in
* the Toolkit Code Librarian “Help” system supplied
* on the Toolkit Delivery CD.
*
* How to invoke:
*
* After compile and link, execute the program Example3c:
*
* ./Example3c NASTRAN_Program_script list_of_NASTRAN_Program_script_args
*
* e.g ./Example3c `which nastran` example3 scr=yes mem=10m out=example3c
*
* input to NASTRAN server : example3.dat
* output from this Example3c program : example3c.prt
* output from NASTRAN server : example3c.f04, example3c.f06
*
*
*
* The following functions are used in this example:
* ==============================================
*
* 1) Supported Utility functions
*
* (void) DumpMatrix
* (void) GetArgument
* (void) OpenLogFile
* (void) PackMatrix
* (void) PrintMessage
*
* 2) MSC.Nastran API Toolkit Library functions
*
* Please consult nsapilib.h or other documents
* for the function description and calling sequence.
*
* (void) NServer_AllocDatablk
* (void) NServer_CloseDatablk
* (void) NServer_CreateDatablk
* (void) NServer_Dbdict
* (void) NServer_ExeStatus
* (void) NServer_Exit
* (void) NServer_GOpenDatablk
* (void) NServer_GetMessage
* (void) NServer_MakeTrailer
* (void) NServer_PackColumn
* (void) NServer_PackColumnI
* (void) NServer_PackNullColumn
* (void) NServer_ReadTrailer
* (void) NServer_SolExeN
* (void) NServer_SolResumeN
CHAPTER 7 159
Matrix I/O APIs

* (void) NServer_Start
* (void) NServer_UnpackColumn
* (void) NServer_WriteTrailer
*

* 3) A Client Main program to call the above functions


*
*/

#include <stdio.h>
#include <string.h>
#include "nsapilib.h"

static FILE *LOGFILE = NULL;

void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);

void OpenLogFile( char *CommandLine );

void PrintMessage (char *GrpName, FILE *fp, char *ApiName);

void DumpMatrix( char *GrpName, char *AllocStr , INTEGER *Filept, INTEGER *Error );

void PackMatrix( char *GrpName, char *CreateString, INTEGER *Filept, INTEGER PackOption,
INTEGER *Error );

main(int argc, char *argv[])


{
char GrpName[257];
char NastPath[1025];
char CommandLine[1025];

char *DbdictString ={"DBDICT DATABLK(ZUZR11) SELECT(NAME,DBSET,VERSON,KEY,ZNAME)"};

char DbdictOut[40000];

INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;

char SubDmap[9], Dmap[9];


INTEGER Dmpseqnum=0;
INTEGER InitFlag, WaitMode=0, ExeStatus=0, Ndatablk=0, Nparam=0;

char ApiName[82]= {"main_program_at_exit" };

char AllocStr[80];

INTEGER Filept1, Filept2, Filept3, PackOption;

int i=0;
LOGFILE = stderr;

/******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
*
******************************************************************************
160

*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);

(void) OpenLogFile( CommandLine );

/***************************************************************************
*
* Step 2: Initilize the MSC.Nastran server
*
**************************************************************************
*/
(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);

(void) fprintf(LOGFILE," >>> NServer_Start GrpName=%s\n"


" CommandLine=%s\n"
" NastPath=%s\n"
" Error=%d\n",
GrpName,CommandLine,NastPath,Error);

if( Error ) {
strcpy( ApiName,"NServer_Start");
goto EXIT;
}

/****************************************************************************
*
* Step 3: Execution of solution in non-blocking mode
*
****************************************************************************
*/

(void) NServer_SolExeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolExeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolExeN");
goto EXIT;
}

/****************************************************************************
*
* Step 4: Loop over the DMAP breakpoint or at DMAP EXIT
*
****************************************************************************
*/

WaitMode = 0;

for( ; ; ) {

/****************************************************************
*
* Step 4.a: Get the Dmap Execution status after the HALT DMAP
*
****************************************************************
*/
CHAPTER 7 161
Matrix I/O APIs

(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,


&Dmpseqnum, &Ndatablk,&Nparam, &Error);

(void) fprintf(LOGFILE, " >>> NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Error);
if( Error ) {
strcpy( ApiName,"NServer_ExeStatus");
goto EXIT;
}

/**************************************************************
*
* Step 4.b: Get out of for loop at the end of DMAP sequence
*
**************************************************************
*/
if( !strncmp(Dmap,"EXIT",4) || Error ) break;

if( !strncmp(Dmap, "HALT",4) ) {


/*
* At DMAP Breakpoint HALT $
*/
(void) NServer_Dbdict ( GrpName , DbdictString , DbdictOut , MaxLen, &OutLen
, &Error ) ;

(void) fprintf(LOGFILE," >>> NServer_Dbdict DbdictString=\n"


" %s\n"
" >>> NServer_Dbdict DbdictOut=\n%s",
DbdictString,DbdictOut);

/***********************************************************************
*
* Step 4.c : Unpack the ZUZR11 matrix, which has been created by DMAP
*
***********************************************************************
*/

sprintf(AllocStr,"DATABLK=ZUZR11 WHERE(ZNAME='DMAPGEN')");
Filept1 = 0;

(void) DumpMatrix ( GrpName, AllocStr , &Filept1, &Error );

/********************************************************************
*
* Step 4.d : Pack ZUZR11 matrix with qualifier ZNAME='API1GEN',
* using whole column
*
********************************************************************
*/

sprintf(AllocStr,"DATABLK=ZUZR11 QUALS(ZNAME='API1GEN')");
Filept2 = 0;
PackOption = 1;

(void) PackMatrix( GrpName, AllocStr, &Filept2, PackOption, &Error );


162

/******************************************************************
*
* Step 4.e : Pack ZUZR11 matrix with qualifier ZNAME='API2GEN',
* using non-zer terms with column index
*
******************************************************************
*/

sprintf(AllocStr,"DATABLK=ZUZR11 QUALS(ZNAME='API2GEN')");
Filept3 = 0;
PackOption = 2;

(void) PackMatrix( GrpName, AllocStr, &Filept3, PackOption , &Error);

(void) NServer_Dbdict ( GrpName , DbdictString , DbdictOut , MaxLen, &OutLen


, &Error ) ;
(void) fprintf(LOGFILE," >>> NServer_Dbdict DbdictString=\n"
" %s\n"
" >>> NServer_Dbdict DbdictOut=\n%s",
DbdictString,DbdictOut);

/*****************************************************************************
*
* Step 4.f : Read the ZUZR11 matrix, which has been created by this program
*
*****************************************************************************
*/
(void) DumpMatrix ( GrpName, NULL , &Filept2, &Error );

(void) DumpMatrix ( GrpName, NULL , &Filept3, &Error );

/******************************************************************************************
*****
*
* Step 5: Resume DMAP execution after the breakpoint and back to the loop for next break
point
*

*******************************************************************************************
****
*/

(void) NServer_SolResumeN( GrpName , &Error );

(void) fprintf(LOGFILE, " >>> NServer_SolResumeN Error=%d\n",Error);

if( Error ) {
strcpy( ApiName,"NServer_SolResumeN");
goto EXIT;
}

} /* end of for loop */

/*******************************************
*
CHAPTER 7 163
Matrix I/O APIs

* Step 6: EXIT and terminate the server


*
*******************************************
*/

EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );

(void) NServer_Exit( GrpName , &Error );

(void) fprintf(LOGFILE," >>> NServer_Exit Error=%d\n",Error);

if( LOGFILE != stderr )


fclose (LOGFILE );
}

#if(0)
#define REAL_SINGLE 1
#define REAL_DOUBLE 2
#define COMPLEX_SINGLE 3
#define COMPLEX_DOUBLE 4
#endif

void DumpMatrix ( char *GrpName, char *AllocStr , INTEGER *Filept, INTEGER *Error )

/**************************************************************************
* Purpose: Dump the content of the matrix datablock
*
* input:
* *GrpName - Group name
* *AllocStr - Allocation string of the matrix
* *Filept - File pointer
* *Error - Error return
*************************************************************************/

{
INTEGER Trailer[7];
INTEGER UnpkCntl[4];
INTEGER NCol,NRow,Type,ColStat,RowStat,n,Nmatch;
MACHINEPRECISION *Column=NULL;

int i;

if( !(*Filept) ) {

/*
* Allocate of datablock
*/
(void) NServer_AllocDatablk( GrpName, AllocStr, Filept, &Nmatch, Error );

fprintf(LOGFILE," >>> NServer_AllocDatablk AllocStr=%s\n Filept=%d Nmatch=%d\n",


AllocStr,*Filept,Nmatch);

}
164

if( !(*Filept) ) return;


/*
* Read table/matrix trailer
*/
(void) NServer_ReadTrailer( GrpName, *Filept , Trailer , Error );

fprintf(LOGFILE," >>> NServer_ReadTrailer\n");


for( i=0; i<7;i++)
fprintf(LOGFILE," Trailer[%d]= %12d\n",i+1,Trailer[i]);

/*
* Cols Rows F T NzWds Density BlockT StrL NbrStr BndAvg BndMax
NulCol
* 18 18 6 2 12 3.08600D-01 3 2 44 9 15
0
*/

if( !Trailer[0] ) {
fprintf(LOGFILE," >>> Matrix Filept=%d is purged\n",*Filept);
return;
}

NCol = Trailer[1];
NRow = Trailer[2];
Type = Trailer[4];

if ( Column ) free( Column );


/* to hold one column data */
Column = (MACHINEPRECISION *)malloc( NRow * sizeof(MACHINEPRECISION) );
if( !Column ) return;

/*
* GOpen the Matrix
*/
(void) NServer_GOpenDatablk( GrpName , *Filept , 'R' , 'Y' , Error );

fprintf(LOGFILE," >>> Matrix Filept=%d Dimension: %d Columns and %d Rows of


Type=%d\n",
*Filept,NCol,NRow,Type);

/*
* Loop thru columns and unpack
*/
for(n=0; n< NCol; n++) {
UnpkCntl[0] = Type ;
UnpkCntl[1] = 1;
UnpkCntl[2] = NRow;
UnpkCntl[3] = 1;

(void) NServer_UnpackColumn ( GrpName , *Filept , UnpkCntl ,


Column , &ColStat , Error );
CHAPTER 7 165
Matrix I/O APIs

if( !ColStat )
fprintf(LOGFILE," >>> Matrix Column(%3d) is a NULL Column\n",n+1);
else {
for(i=0; i<NRow ; i++)
if( Column[i] ) {
fprintf(LOGFILE," >>> Matrix Column(%3d) Row(%3d) = %2.4e \n",
n+1,i+1,Column[i]);
}
}

if ( Column ) free( Column );

/*
* CLose the Datablk
*/
(void) NServer_CloseDatablk( GrpName , *Filept , 'N' , Error );

#define ROWSIZE 5
#define RECTANGULAR 2
#define REALDOUBLE 2

void PackMatrix( char *GrpName, char *CreateString, INTEGER *Filept, INTEGER PackOption,
INTEGER *Error )

/**************************************************************************
* Purpose: Pack a matrix datablock
*
* input:
* *GrpName - Group name
* *CreateString - Creation String of the matrix
* *Filept - File pointer
* PackOption - Option selection to pack the matrix
* *Error - Error return
*************************************************************************/

INTEGER FileStat, NbrNull=1, Nzero=0;


int i;

MACHINEPRECISION Column1[ROWSIZE]={ 100. , 200., 300. , 0. , 0. };


INTEGER Colindex1[3] ={ 1, 2, 3 };
INTEGER Nindex1=3;

MACHINEPRECISION Column3[ROWSIZE]={ 0. , 200., 0. , 400. , 0. };


MACHINEPRECISION Column3X[2] ={ 200., 400. };
INTEGER Colindex3[2] ={ 2, 4 };
INTEGER Nindex3=2;

MACHINEPRECISION Column5[ROWSIZE]={ 0. , 0. , 300. , 400. , 500. };


MACHINEPRECISION Column5X[3] ={ 300. , 400. , 500. };
INTEGER Colindex5[3] ={ 3, 4, 5 };
166

INTEGER Nindex5=3;

INTEGER Trailer[7], PackCntl[5];

INTEGER NRow,MatType, MatForm;

NRow = ROWSIZE;
MatForm = RECTANGULAR;
MatType = REALDOUBLE;

if( !(*Filept) ) {
/*
* Create a datablock to output data
*/
(void) NServer_CreateDatablk ( GrpName , CreateString , Filept , &FileStat ,Error
);

(void) fprintf(LOGFILE, " >>> NServer_CreateDatablk


CreateString=%s\n",CreateString);
(void) fprintf(LOGFILE, " Filept=%d FileStat=%d
Error=%d\n",*Filept,FileStat,*Error);
}

if( !(*Filept) || *Error ) return;


/*
* Open datablock to write
*/
(void) NServer_GOpenDatablk( GrpName , *Filept , 'W' , 'Y' , Error );

(void )NServer_MakeTrailer ( GrpName , Trailer , *Filept , NRow , MatForm , MatType


,Error );

PackCntl[0] = MatType;
PackCntl[1] = MatType;
PackCntl[2] = 1;
PackCntl[3] = ROWSIZE;
PackCntl[4] = 1;

switch ( PackOption ) {

/*******************************
*
* USING PACK COLUMN
*
*******************************
*/
case 1 :

/*
*
* Pack columns 1,3, and 5.
* Column 2,4 are NULL
*
*/
(void) NServer_PackColumn ( GrpName , *Filept , PackCntl , Trailer , Column1
, Error ) ;
(void) NServer_PackNullColumn ( GrpName , *Filept , PackCntl , Trailer , NbrNull
, Error ) ;
CHAPTER 7 167
Matrix I/O APIs

(void) NServer_PackColumn ( GrpName , *Filept , PackCntl , Trailer , Column3


, Error ) ;
(void) NServer_PackNullColumn ( GrpName , *Filept , PackCntl , Trailer , NbrNull
, Error ) ;
(void) NServer_PackColumn ( GrpName , *Filept , PackCntl , Trailer , Column5
, Error ) ;

break;

/*************************************************
*
* USING PACK COLUMN WITH INDEX OF NON-ZERO TERM
*
*************************************************
*/
case 2 :

/*
*
* Pack columns 1,3, and 5.
* Column 2,4 and 6 are NULL
*
*/
PackCntl[3] = Nindex1;
(void) NServer_PackColumnI ( GrpName , *Filept , PackCntl , Trailer , Column1
, Colindex1 , Nindex1, Error );
(void) NServer_PackNullColumn ( GrpName , *Filept , PackCntl , Trailer , NbrNull
, Error ) ;
PackCntl[3] = Nindex3;
(void) NServer_PackColumnI ( GrpName , *Filept , PackCntl , Trailer , Column3X
, Colindex3 , Nindex3, Error );
(void) NServer_PackNullColumn ( GrpName , *Filept , PackCntl , Trailer , NbrNull
, Error ) ;
PackCntl[3] = Nindex5;
(void) NServer_PackColumnI ( GrpName , *Filept , PackCntl , Trailer , Column5X
, Colindex5 , Nindex5, Error );

break;
}

/*
* Close datalock and write trailer
*/
(void) NServer_CloseDatablk ( GrpName , *Filept , 'Y' , Error );
(void) NServer_WriteTrailer ( GrpName , *Filept , Trailer , Error );
}
168

NServer_PackColumnI – Pack a Column Using a Sparse Matrix


Format
From FORTRAN:
CALL NSPAKCI(...)
From C:

int NServer_PackColumnI

( char *GrpName , INTEGER Filept ,


INTEGER *ColCntl ,INTEGER *Trailer,
MACHINEPRECISION *Column , INTEGER *RowIdx ,
INTEGER *IdxLen ,INTEGER *Error );

Purpose. Interface call to Pack a sparse matrix's Column.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
ColCntl INPUT Column Control block: a 5-int-word array
Type of input data (Column)
Type of Output data
Begin Row number
Length of RowIdx (i.e., number of non-zero terms in column)
Row Increment
Trailer INPUT/ The datablock’s 7 word trailer.
OUPUT
Column INPUT Column Data.
RowIdx INPUT Index of the non-zero rows in Column.
IdxLen INPUT Length of RowIdx.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example. See NServer_PackColumn on page 154.


CHAPTER 7 169
Matrix I/O APIs

NServer_PackNullColumn – Pack out a Null Column


From FORTRAN:
CALL NSPCKNU(...)
From C:

int NServer_PackNullColumn
( char *GrpName, INTEGER Filept,
INTEGER *ColCntl, INTEGER *Trailer,
INTEGER NbrNull, INTEGER *Error );

Purpose. Pack a matrix's Null Column.

Arguments.

GrpName INPUT (Max. 256 chars.)


Groupd name, the Server’s unique identifier.
Filept INPUT File Handle for reference of the DataBlock
ColCntl INPUT A 5-word array of Column Control block
Word 1 – Type of input data (Column)
Word 2 – Type of output data (stored in matrix)
Word 3 – Begin row number
Word 4 – End Row number
Word 5 – Row Increment
Trailer INPUT/ The DataBlock’s 7-word Trailer.
OUTPUT
NbrNull INPUT Number of Null Columns.
Error OUTPUT Return Server’s status error.
Func. Ret. OUTPUT Return Server’s status error.

Example. See NServer_PackColumn on page 154.


170

NServer_UnpackColumn – Unpack a Matrix Column


From FORTRAN:
CALL NSUNPKC(...)
From C:

int NServer_UnpackColumn

( char *GrpName , INTEGER Filept ,


INTEGER *ColCntl , MACHINEPRECISION *Column ,
INTEGER *ColStat , INTEGER *Error);

Purpose. Interface call to Unpack a matrix's Column.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Filept INPUT Datablock file handle from previous allocation or creation.
ColCntl INPUT/ Column Control block: a 4-int-word array
OUTPUT Word 1 – Type of Output data
Word 2 – Begin Row number
Word 3 – End Row number
Word 4 – Row Increment
Column OUTPUT Column Data.
ColStat OUTPUT Status of the Column.
= 0 indicates a NULL Column. (Note that the output Column data
will be undefined in this case).
= nonzero indicates the number of words returned in Column data.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
CHAPTER 7 171
Matrix I/O APIs

Example. A subroutine that uses the " Unpack" API. See also NServer_PackColumn
example on page 154.

SUBROUTINE WRTMPC (GRPNAM,LNBUF,IBUF,IUNIT,NRGRID,INFRGD, I R C )


C
C This subroutine writes the MPC equations relating the physical
C degrees of freedom to the modal degrees of freedom to the file
C of the modal model.
C
C Input GRPNAM ... Group Name of the Server
C LNBUF ... Length of Working Array
C IBUF(*) ... Working Array
C IUNIT ... FORTRAN unit of output file
C NRGRID ... Number of Grids in Residual Model
C INFRGD(3,*) ... Residual Grid Information Table
C Output IRC ... Return Code: 0 = Normal End
C <>0 = Errors Found
C
C
C ----------------------------------------------------------------------
C
CHARACTER*(*) GRPNAM
CHARACTER*80 CVAL
C
INTEGER IBUF(*),INFRGD(3,*)
INTEGER ITRAIL(7),LISDOF(6),INFCOL(4)
C
DATA UNIT /-1./, ZERO /0./
C
...
C
C Allocate Datablock ZUZR01 (contains modal displacements)
C
CALL NSALLDB (GRPNAM,'DATABLK=ZUZR01 WHERE (ZUZR1=2)',
. I F I L P T , N M A T C H , I E R A P I )
IF (IERAPI.NE.0.OR.NMATCH.NE.1) GO TO 910
C
C Get Information from Trailer
C
CALL NSRDTRL (GRPNAM,IFILPT, I T R A I L , I E R A P I )
IF (IERAPI.NE.0) GO TO 920
NMODES=ITRAIL(3)
IPREC =ITRAIL(5)
LNNEED=IPREC*NMODES
IF (LNNEED.GT.LNBUF) GO TO 930
C
C Open ZUZR01
C
CALL NSGPNDB (GRPNAM,IFILPT,'R','Y', I E R A P I )
IF (IERAPI.NE.0) GO TO 921
C
C Loop over DOFS
C
INFCOL(1)=IPREC
INFCOL(2)=1
INFCOL(3)=NMODES
INFCOL(4)=1
172

C
DO 200 IGRID=1,NRGRID
C
IDOFS=INFRGD(3,IGRID)
C
IF (NDOFG.EQ.6.OR.IDOFS.EQ.0) THEN
C
DO 210 K=1,NDOFG
C
WRITE(IUNIT,2000) MPCID,INFRGD(1,IGRID),K,UNIT
C
C Unpack a column into IBUF
CALL NSUNPKC (GRPNAM,IFILPT,INFCOL, I B U F ,
. I C L S T , I E R A P I )
C
IF (IERAPI.NE.0) GO TO 922
C
IF (ICLST.EQ.0) THEN
WRITE(IUNIT,2100) IDSP1,ZERO
ELSE

C Note: SWRMPC/DWRMPC below are not Toolkit supplied utilities--they are shown here
C simply to demonstrate how a typical application might be structured to handle
C both double and single precision matrices.

IF (IPREC.EQ.1) THEN
C Write utility for matrix data that is single precision
CALL SWRMPC (IUNIT,NMODES,IBUF,IDSP1)
ELSE
C Write utility for matrix data that is double precision
CALL DWRMPC (IUNIT,NMODES,IBUF,IDSP1)
ENDIF
ENDIF
C
210 CONTINUE
C
ELSE
C
...
C
ENDIF
C
200 CONTINUE
C
C Close ZUZR01
C
990 CALL NSCLSDB (GRPNAM,IFILPT,'N', I E R A P I )
IF (IERAPI.EQ.0) GO TO 999
C
C Error Branch
C
...
C
999 CONTINUE
RETURN
END
CHAPTER 7 173
Matrix I/O APIs

NServer_UnpackColumnI – Unpack a Sparse Matrix Column


From FORTRAN:
CALL NSUNPKI(...)
From C:

int NServer_UnpackColumnI

( char *GrpName , INTEGER Filept , INTEGER *ColCntl ,


MACHINEPRECISION *Column , INTEGER *ColStat, INTEGER
*RowIdx , INTEGER *RowStat , INTEGER *Error );

Purpose. Interface call to Unpack a sparse matrix's Column.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max.


256 chars.)
Filept INPUT Datablock File handle from previous allocation or creation
ColCntl INPUT Column Control block: a 4-int-word array
Word 1 – Type of Output data
Word 2 – Begin Row number
Word 3 – End Row number
Word 4 – Row Increment
Column OUTPUT Column Data
ColStat OUTPUT Status of the Column (0 for NULL Column, nonzero for number of
words stored)
RowIdx OUTPUT Index of the non-zero rows in Column
RowStat OUTPUT Status of the RowIdx
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Example. An example is provided in the "Toolkit Code Librarian" help system


(Training Example 3).
174

NServer_UnpackRowIdx – Unpack a Matrix Row Index


From FORTRAN:
CALL NSUNPKX(...)
From C:

int NServer_UnpackRowIdx

( char *GrpName , INTEGER Filept ,


INTEGER *ColCntl , INTEGER *RowIdx ,
INTEGER *RowStat , INTEGER *Error );

Purpose. Interface call to Unpack the Row-Indices for Non-Zero Terms of a matrix's
column.

Arguments.

GrpName INPUT An unique identifier for the Client/Server communication. (Max. 256
chars.)
Filept INPUT Datablock File handle from previous allocation or creation.
ColCntl INPUT Column Control block: a 4-int-word array
Type of Output data
Begin Row number
End Row number
Row Increment
RowIdx OUTPUT Index of the nonzero rows in Column.
RowStat OUTPUT Status of the RowIdx.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example. An example is provided in the "Toolkit Code Librarian" help system


(Training Example 3).
MSC.Nastran Toolkit User’s Guide

CHAPTER
Direct Access I/O APIs
8
■ Grid Direct Access API's

■ Element Connectivity and Property Recovery API (IFP API's)


■ Summary of How to Use the IFP API's

■ Data Recovery API's (OFP Type Datablocks)


176

8.1 Grid Direct Access API's


Either of two methods may be used to read grid information from the database. With
the first method, the grid cards are read from BGPDT data block using
NServer_ReadXYZ. Reading from BGPDT with NServer_ReadXYZ has the advantage
that the x, y, z output is returned in the basic coordinate system. In the second
method, grid data is read from GEOM1 data block using NServer_ReadIndexedIFP.
In this method the data is close to form of the input bulk data deck but is in whatever
coordinate system the user input on their card. Reading from BGPDT is discussed in
this section, while reading from GEOM1 is discussed in the next section.
CHAPTER 8 177
Direct Access I/O APIs

NServer_ReadGID – Get Grid IDs


From FORTRAN:
CALL NSRGID(...)
From C:

int NServer_ReadGID

( char *GrpName, INTEGER Filept, INTEGER


BeginEntry, INTEGER *GIDRecord, INTEGER RecLeng,
INTEGER *GIDStat, INTEGER *MaxEntry, INTEGER *Error );

Purpose. Returns a list of all the grid ID's contained with the BGPDT file (referenced
by the file handle Filept).

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier.
Filept INPUT File Handle for BGPDT datablock.
BeginEntry INPUT Begin entry of the GID record to read.
GIDRecord OUTPUT Buffer to hold the GID record.
RecLeng INPUT Length of the Record in word.
GIDStat OUTPUT Return status of the read record
>= 0: Number of entries has been read
< 0: problem with index file
MaxEntry OUTPUT The maximum size in words (i.e., number of grids) of the GID
record.
Error OUTPUT Return Server’s status error.
Func. Ret. OUTPUT Server return error flag.

Example. See the NServer_ReadXYZ example on page 178.


178

NServer_ReadXYZ – Get Grid Coordinates


From FORTRAN:
CALL NSRXYZ(...)
From C:

int NServer_ReadXYZ

( char *GrpName, INTEGER Filept, INTEGER *GIDRecord,


MACHINEPRECISION *XYZRecord, INTEGER RecLeng, INTEGER
*OutLeng, INTEGER *XYZStat, INTEGER *Error );

Purpose. Returns requested grid data from BGPDT Filept given a list of grid ID’s.
The x,y,z coordinates are returned in the BASIC coordinate system for each of the
requested ids.

Arguments.

GrpName INPUT (Max Length = 256)


Group name, the Server's unique identifier.
Filept INPUT File Handler for BGPDT datablock.
GIDRecord INPUT Buffer to hold the GIDRecord.
XYZRecord OUTPUT Buffer to hold the XYZRecord with 3 MACHINEPRECISION data
terms per entry.
RecLeng INPUT Entry length of the input GIDRecord or Maximum Entry length for
the output XYZRecord.
OutLeng OUTPUT Return Entry length used to hold the output XYZRecord.
XYZStat OUTPUT Return status of the read record
= 0: read OK
> 0: number of bad entries in GIDRecords
< 0: problem with index table
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Example. The following examples demonstrates use of both the NServer_ReadXYZ


and the NServer_ReadGID API.
Note that some general guidelines apply to both these API's.
• Your DMAP must save BGPDT data block on one of the permanent DBSETs.
CHAPTER 8 179
Direct Access I/O APIs

• Assuming the client code has performed the normal startup api calls, the
client must allocate the saved BGPDT data block (see
NServer_AllocDatablk).
• NServer_ReadGID or NServer_ReadXYZ can be called one or more times. As
with all client/server API's efficiency is enhanced if multiple ID's are
processed in each call.
180

/*
* File: NSgetXYZ.c
*
* Purpose: to run a single nastran job via the toolkit
* and get GID, XYZ output
*
* How to run:
*
* ./NSnastran `which nastran` bcell2a scr=no mem=4m
*
* DMAP alter on bcell2.dat :
*
* compile PHASE0 $
* alter 'GP3 '
* exit
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <nsapilib.h>
#include "Utool.h"
#include <string.h>
#define LENG 8

main (int argc, char *argv[])


{
char GrpName[257];
char NastPath[1025];
char CommandLine[1025];
char Command[1025];

char SubDmap[9], Dmap[9];


INTEGER Dmpseqnum, Nbreak;
INTEGER WaitMode, ExeStatus, Ndatablk, Nparam, Error;

INTEGER i,j,Filept, BeginEntry, RecLeng, GIDStat, MaxEntry, OutLeng, XYZStat;


INTEGER GIDRecord[LENG];
MACHINEPRECISION XYZRecord[LENG*3];

/*
* (0) Parse the program arguments in to GrpName, NastPath and CommandLine
*/

(void) GetArgument( GrpName, NastPath, CommandLine, argc, argv);

/*
* (1) INIT THE SERVER
*/

(void) fprintf(stderr," Call NServer_Start for Group %s


NastPath=%s\n",GrpName,NastPath);
(void) fprintf(stderr," CommandLine is %s\n",CommandLine);

(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);


CHAPTER 8 181
Direct Access I/O APIs

if( Error ) {
(void) fprintf(stderr," An error code %d has been detected in NServer_Start and
run exits \n",Error);
(void) Fetch_Messages (GrpName, stdout );
goto EXIT;
}

/*
* (2) EXECUTION OF SOLUTION IN NON-BLOCKING MODE
*/

(void) fprintf(stderr, " Call NServer_SolExeN for Group %s\n",GrpName);

(void) NServer_SolExeN( GrpName , &Error );

WaitMode = 0;
/*
* (3) GET THE EXECUTION STATUS
*/

(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,


&Dmpseqnum, &Ndatablk,&Nparam, &Error);

/*
* DMAP alter has been made to exit after GP3 module, where
* BGPDT is available with the gino file number 102
*/

(void) fprintf(stderr, " Return from NServer_ExeStatus: SubDmap=%s\n"


" Dmap=%s\n"
" Dmpseqnum=%d\n"
" Ndatablk=%d\n"
" Nparam=%d\n"
" Error=%d\n",
SubDmap,Dmap,Dmpseqnum,Ndatablk,Nparam,Error);

if( Error ) goto EXIT;;

/*
* (4) GET GID and XYZ
*/

Filept=102;

GIDStat=0;
GIDStat=0;
RecLeng=LENG;

BeginEntry=1;

for ( ; ; ) {

(void) NServer_ReadGID (
GrpName,Filept,BeginEntry,GIDRecord,RecLeng,&GIDStat,&MaxEntry,&Error);

fprintf(stderr," NServer_ReadGID Filept=%d BeginEntry=%d RecLeng=%d GIDStat=%d


MaxEntry=%d Error=%d\n",
182

Filept,BeginEntry,RecLeng,GIDStat,MaxEntry,Error);

(void) NServer_ReadXYZ(
GrpName,Filept,GIDRecord,XYZRecord,RecLeng,&OutLeng,&XYZStat,&Error);

fprintf(stderr," NServer_ReadXYZ Filept=%d RecLeng=%d OutLeng=%d XYZStat=%d


Error=%d\n",
Filept,RecLeng,OutLeng,XYZStat,Error);

for (j=0,i=0 ; i < OutLeng*3; j++,i+=3)


fprintf(stderr,"G=%10d X=%10f Y=%10f Z=%10f\n",
GIDRecord[j],XYZRecord[i],XYZRecord[i+1],XYZRecord[i+2]);

if( GIDStat>0 ) BeginEntry+=GIDStat;


RecLeng = (BeginEntry+RecLeng > MaxEntry ? MaxEntry-BeginEntry+1 : RecLeng) ;

if( BeginEntry > MaxEntry ) break;

EXIT:

/*
* (5) EXIT THE SERVER
*/

(void) fprintf(stderr," Before NServer_Exit\n");


(void) NServer_Exit( GrpName , &Error );
CHAPTER 8 183
Direct Access I/O APIs

8.2 Element Connectivity and Property Recovery API


(IFP API's)
MSC.Nastran's data cards are placed in nearly raw form within the Input File
Processor (IFP) data blocks. The data contained in the IFP datablocks is similar to the
form used on the card but typically has flagging information and other "structure"
information modified to ease subsequent reading of the data.
The IFP module (and a few subsequent modules) output this class of data blocks at the
beginning of all MSC supplied solutions sequences after the bulk data has been read
and sorted. Direct access allows quick retrieval of the data cards by indexing this class
of data blocks.

How to Index IFP Data


Most IFP data is readily indexed. The data blocks have each card type separated on
record boundaries with a 3 word locate code (table, bit, card number) as the first three
words of the record. Most of the cards types also have a fixed number of attributes
with the card ID as the first word in the list of attributes. Because of this rather rigid
structure over 70 percent of the cards can be indexed.

Entries Not Indexed Due To


Indexed Percent
Var. Length No ID
103 38 333 70

It is expected the cards that are not currently indexed due to variable number of
attributes will be indexed in the future.1 The NDDL contains information necessary to
read the data, but unfortunately, not as a tuple.
The IFP data can be indexed in either the run that generates the IFP data blocks or
during subsequent runs. A new module IFPINDX takes one of the IFP data blocks and
appends an index file onto the base data. The index data is appended onto the base file
as an "associated file" and as such is invisible to other modules unless they need the
information. DMAP example of IFPINDX is
file geom2=append $
ifpindx /geom2 $
Indexing is available in MSC supplied solution sequences by either adding a
NASTRAN INDEX=IFP to your bulk data deck or by adding sys316=1 on the
submittal line. Note that setting sys316=2 is used to index OFP type datablocks
(discussed immediately after this section on IFP API's). Setting sys316=3 will index
both IFP and OFP datablocks.

1
The variable length PCOMP card is indexed currently.
184

Using the above indices there exists API's to read the keys from an IFP datablock
(NServer_ReadIFPKeys (c) or NSRIKYS (Fortran)) and a API to read the associated IFP
data for a given set of keys (NServer_ReadIndexedIFP (c) or NSRIIFP (Fortran)).
CHAPTER 8 185
Direct Access I/O APIs

8.3 Summary of How to Use the IFP API's


• The DMAP must have a call to module IFPINDEX for all the IFP datablocks
you will be calling with NServer_ReadIFPKeys or
NServer_ReadIndexedIFP. This module indexes the data block and stores
the index information for later use. Typically you will want to index GEOM2,
EPT, MPT data blocks. These datablocks must be stored permanently.
• Assuming the client code has performed the normal startup API calls, the
client will allocate the appropriate IFP data block (see
NServer_AllocDatablk).
• Open the datablock using NServer_OpenDatablk
• Call NServer_ReadIFPKeys or NServer_ReadIndexedIFP one or more times.
API efficiency is enhanced if multiple id's are being returned.

Note. Before calling the above API (ReadIndexedIFP) you have the option of
applying a filter to the data that will be returned (see NServer_Select).
For a detailed example that demonstrates the use of these direct access IFP API's see
the Nsbrowser.f example supplied in the Toolkit Code Librarian “Help” system.
The table below provides the type of data, its NDDL description name1 and the card
names for cards accessible with the IFP API.

Type of Data NDDL Name Entries


Conical shell, Hydroelastic AXIC CCONEAX CFLUID2 CFLUID3 CFLUID4
and acoustic FORCE FORCEAX FREEPT GRAV GRIDB
GRIDF GRIDS MOMAX MOMENT OMITAX
POINTAX PRESAX PRESPT RINGAX RINGFL
SECTAX SEQGP SPCAX SUPAX TEMPAX
TEMPD
Contact CONTACT BCONP BFRIC BNPEN
Dynamics' Related Data DYNAMIC ACSRCE DAREA DELAY DPHASE DYNRED
EIGB EIGP EIGR EIGRL EPOINT FREQ1
FREQ2 FREQ3 FREQ4 NOLIN1 NOLIN2
NOLIN3 NOLIN4 RANDPS RANDT1 RLOAD1
RLOAD2 SEQEP TIC TLOAD1 TLOAD2

1The
NDDL Name is the name given to the description. Often it is the same name as
the data block name, but not always. Other data blocks can also point a NDDL
Description with the DATABLK SAMEAS clause. For example, GEOM2 points to
ECT NDDL description name.
186

Type of Data NDDL Name Entries


Element Connectivity ECT,GEOM2 BEAMAERO CAABSF CAXIF2 CAXIF3
Table CAXIF4 CBAR CBARAO CBEAM CBEAMP
CBEND CBUSH CBUSH1D CCONE CDAMP1
CDAMP2 CDAMP3 CDAMP4 CDAMP5
CDUM1 CELAS1 CELAS2 CELAS3 CELAS4
CFLUID2 CFLUID3 CFLUID4 CINT CGAP
CHACAB CHACBR CHBDYE CHBDYG
CHBDYP CHEXA CHEXA20F CHEXAFD
CHEXAL CHEXP CHEXPR CMASS1 CMASS2
CMASS3 CMASS4 CMFREE CONM1 CONM2
CONROD CONV CONVM CPENP CPENTA
CPENPR CPENT15F CPENT6FD CQDX4FD
CQDX9FD CQUAD CQUAD4 CQUAD4FD
CQUAD8 CQUAD9FD CQUADP CQUADR
CQUADX CROD CSHEAR CSLOT3 CSLOT4
CTETP CTETRA CTETPR CTETR10F
CTETR4FD CTRIA3 CTRIA3FD CTRIA6
CTRIA6FD CTRIAP CTRIAR CTRIAX
CTRIAX6 CTRIX3FD CTRIX6FD CTUBE CVISC
GMINTC GMINTS PLOTEL Q4AERO RADBC
SINT SPOINT T3AERO VUHEXA VUPENTA
VUTETRA
Design Optimization IFP EDOM DSCONS DESVAR DCONSTR DOPTPRM
Data DOPTPRM2 DSCREEN DVGRID DVBSHAP
MODTRAK
Aero and Element EDT ACMODL AERO AEROS AESTAT AESURF
Deformations CAERO1 CAERO2 CAERO3 CAERO4
CAERO5 CSSCHD DEFORM MKAERO1
MKAERO2 PAERO1 PAERO2 SET2 SPLINE1
SPLINE2 SPLINE4 SPLINE5
Element Hierarchical Table EHT EHBEAMP EHCINT EHHEXP EHPENP
EHQUADP EHSINT EHTETP EHTRIAP
P-element volume and ELEMVOL HEXAP PENTAP TETRAP
P-value dependency data
Element Property Table EPT PACABS PAABSF PACBAR PBAR PBEAM
PBEND PBUSH PBUSH1D PBUSHT PCOMP
PCONEAX PCONV PCONVM PDAMP
PDAMPF PDAMP5 PELAS PELASF PGAP
PHBDY PINTC PINTS PLPLANE PLSOLID
PMASS PROD PSHEAR PSHELL PSOLID
PSOLIDL PTRIA6 PTUBE VIEW VIEW3D
CHAPTER 8 187
Direct Access I/O APIs

Type of Data NDDL Name Entries


Description of Grids GDNTAB GDNTAB
generated for p-elements
(GRIDN )
Grid Point Data GEOM1 CORD1C CORD1R CORD1S CORD2C
CORD2R CORD2S FEEDGE FEFACE POINT
GMCORD GRID* SEBULK SELABEL SELOC
SEMPLN SENQSET SEQGP SNORM
Load Data GEOM3 FORCE FORCE1 FORCE2 GMLOAD GRAV
LOADCYH LOADCYN LOADCYT LSEQ
MOMENT MOMENT1 MOMENT2 PLOAD
PLOAD1 PLOAD2 PLOAD3 PLOAD4
PLOADX PLOADX1 PRESAX QBDY1 QBDY2
QBDY3 QHBDY QVECT QVOL RFORCE
SLOAD TEMP TEMPD TEMPEST TEMPF
TEMPIC TEMPP1 TEMPP2 TEMPP3 TEMPRB
PFACE PEDGE
Constraints GEOM4 ASET BSET CSET CYSUP CYSYM EGENDT
FCENDT GMBC GMSPC OMIT QSET RBAR
RROD RSSCON RTRPLT SEBSET SECSET
SEQSET SESUP SEUSET SPC SPCD SPCDE
SPCDF SPCDG SPCE SPCEB SPCF SPCFB
SPCGB SPCGRID SPCOFF SUPORT TEMPBC
USET
DMIG, Fluid and Radiation MATPOOL MFLUID
Data
Material Property Table MPT CREEP MAT1 MAT2 MAT3 MAT4 MAT5
MAT8 MAT9 MAT10 MAT11 MATHP MATS1
MATT1 MATT2 MATT3 MATT4 MATT5
MATT8 MATT9 NLPARM NLPCI TSTEPNL
OUTPUT control for OINT OUTRCV
p-element analysis
Spline Data SPLINE SET2 SPLINE1 SPLINE2 SPLINE4 SPLINE5
Relates each p-element VIEWTB HEXAP PENTAP TETRAP
with its view elements

* Use NServer_ReadXYZ to obtain grid data in Basic coordinate system.


188

NServer_ReadIFPKeys – Get IFP Card IDs


From FORTRAN:
CALL NSRIKYS
From C:

Int NServer_ReadIFPKeys

( char *GrpName, INTEGER Filept, INTEGER Offset,


INTEGER *Record, INTEGER Reclen, INTEGER *NWread,
INTEGER *Iret, INTEGER *Error);

Purpose. Returns the IFP keys.

Arguments.

GrpName INPUT Group Name for the Server.


Filept INPUT FIST Number for the Data Block.
Offset INPUT/ Last offset for keys returned in Record. A subsequent call to this API
OUTPUT with a non-zero offset will return keys from this offset. Offset should
be set to zero for the initial call to this API.
Record OUTPUT Location to store values. Record contains the keys for the data block
you are requesting keys. Record contains two word keys for the data
as
Word 1 – ID
Word 2 – Card Number
RecLen INPUT Length of the Record array.
NWread OUTPUT Number of words return in Record.
Iret OUTPUT Error code returned from the Server
0 – OK
1 – Problem with the index files
2 – RecLen too small NWread contains size required
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 189
Direct Access I/O APIs

NServer_ReadIndexedIFP – Get IFP Data


From FORTRAN:
CALL NSRIIFP(...)
From C:

int NServer_ReadIndexedIFP

( char *GrpName, INTEGER Filept, INTEGER *Record,


INTEGER Reclen, INTEGER *Ids, INTEGER Idwds, INTEGER
*NWread, INTEGER *LastId, INTEGER *Iret, INTEGER OP,
INTEGER *Error );

Purpose. Returns indexed IFP data for a given list of IFP keys.

Arguments.

GrpName INPUT Group Name for the Server


Filept INPUT FIST Number for the Data Block
Record OUTPUT Location to store values. Record contains 4 words at the beginning of
each tuple returned defining the tuple, plus the tuple. This structure
repeats until all the IDs have been returned or Record does not
contain enough room to contain another entry. The entry words are:
Word 1 – Length of Tuple (L)
Word 2 – Card Number
Word 3 – Card Name 1
Word 4 – Card Name 2
Word 5 through (L+5) – Card Tuple
RecLen INPUT Length of the Record array
Ids INPUT Ids is a two word list of keys which you want returned. The first
word of each entry is the ID and the second is the card number. If the
card number is set < 0 then all with the given ID will be returned
regardless of the card number. The ID list can be in any order and
output will be returned in that order.
Idwds INPUT Length of the IDs array
Nwread OUTPUT Number of words returned in Record
190

LastId INPUT/ Array position within Ids of the last id completed in Record.
OUTPUT The initial call to this API should set LastId to zero.
Note: If all requested Ids cannot be returned because of insufficient
space in Record then a nonzero value is output in LastId containing
the last ID successfully processed. A subsequent call to this API with
this nonzero LastId value will repeat the process of returning values
where the previous call left off.
Iret OUTPUT return code
OP INPUT unused operation code
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 191
Direct Access I/O APIs

8.4 Data Recovery API's (OFP Type Datablocks)


The fundamental requirement of OFP Indexing is to provide the functions necessary
to directly access data recovery results from the MSC.NASTRAN database. The
function of this API's is to directly access results data (stress, force, strain,
displacement, etc.) from the MSC.NASTRAN database given a subcase-loading
condition and a set of ids (element, timestep or frequency). The set of ID's can be in
any order and can be a variety of different element types. All significant OFP files can
be indexed including sort1/sort2 types, the various approaches and the various forms
(real, complex, etc).
The NDDL label and type (integer, real, etc) information for the OFP data is also
accessible.

How to Index OFP Data


The OFPINDX DMAP module takes an OFP type datablock and creates two
associated index files, one associative file to index the OFP id record information and
one file to index the ID’s. Three API were written to access the data through these
index files, 1) NServer_ReadOFPSubindex, loads the OFP subcase ID information so
that a particular subcase-load case can be selected, 2) NServer_ReadOFPKeys, returns
OFP key data for a particular subcase, and 3) NServer_ReadIndexedOFP, which
returns the results data given the selected subcase and a list of ids. An example of the
DMAP call to the new module is shown below.
file oes=append $
ofpindx /oes $
The index data is appended onto the base file (e.g, oes) as an "associated file" and as
such is invisible to other DMAP modules unless they need the information.
OFPINDX module associates two index files with the OFP datablock (shown above as
oes). They are 1) subindex, an index of the subcase (OFP id record) information and
2) eleindex, an index keyed on the element (or frequency or timestep) information.
Information for the subindex file is taken from the ID record of the OFP file. It includes
information on the OFP file type, the subcase number/load/frequency/timestep, the
element type and the format of the data (sort1/sort2) for the next data record. The
subindex file condenses this information down to a few words necessary for indexing.
The subindex file (see Appendix H) allows a user to quickly find the subcase or load
step they are interested in. This subindex file consists of a single GINO record with
fixed length entries containing information necessary to select a particular result case.
There is a one-to-one correspondence with the OFP file id records and the subcase
index entries.
The eleindex file contains a list of element IDs with the pointers to the locations in the
OFP file that contains that element. There is a single element index record for a single
subcase or loading condition regardless of the element type. Different element types
192

have been merged into a single element index if the subcase/load combination is the
same. This eliminates Element type as a key and is modeled after MSC.Patran which
treats element type as an attribute of a particular ID's data.
This means that the IDs in MSC.Nastran model should be unique across all the
element types to provide direct access capability to the results data. However, if the
element IDs are not unique across the element types then ALL the elements with the
same ID are returned (sort 1 data only).
NDDL word type and label information can be accessed through
NServer_NDDLDesc. Datablock name, Element type, table code, approach code, from
information contained in the subindex table is passed to NServer_NDDLDesc.
NServer_NDDLDesc will read the NDDL descriptions and returns:
• Type of datablock, that is TABLE, VECTOR, MATRIX, IFP, OFP. (Currently
only OFP and IFP datablock types return word type and label information).
• comma delimited character string of labels.
• Integer array of typing information.
There is a one-to-one correspondence with the data returned from the
indexed OFP file, the label string and the type information.

Note. You can use an alternative function to NServer_NDDLDesc called API


NServer_OFPDesc. This one allows you to simply provide a pointer to the subindex
entry instead of explicitly providing the NDDL label and type information contained
in the subindex table.
This indexing structure works for sort1 or sort2 output. For sort 1 output the subindex
will contain subcase and load information and the eleindex file will have element IDs.
For sort2 data this is reversed, the subindex contains a particular element and the
eleindex ID is a particular frequency or timestep. The NDDL descriptions for the index
files include both forms (see subindex description in Appendix H).
Indexing is available in MSC supplied solution sequences by either adding a
NASTRAN INDEX=OFP to your bulk data deck or by adding sys316=2 on the
submittal line. Note: Setting sys316=1 is used to index IFP type datablocks (discussed
before section on OFP API's). Setting sys316=3 will index both IFP and OFP
datablocks.

Summary of How to Use the OFP API's


1. The DMAP must have a call to module OFPINDX for all the OFP datablocks
you will be calling with the OFP API. OFPINDX indexes the data block and
stores the index information for later use. Typically you will want to index
OES1 (stress), OEF1i (force), OESTR1 (strain) data blocks. These datablocks
must be stored permanently.
CHAPTER 8 193
Direct Access I/O APIs

2. Current solution sequences will make the indexes by placing a NASTRAN


INDEX=OFP card in input deck (or specifying sys316=2 as a keyword on the
Nastran command submittal) and running your jobs with scr=no or
scr=mini.
3. Assuming the client code has performed the normal startup API calls, the
client next allocates the appropriate OFP data block (see
NServer_AllocDatablk).
4. Call NServer_ReadOFPSubindex to return all the subcase/element type
combinations (see Appendix H for a description of the attributes). Choose
the subcase you are interested in from the subindex table (any entry with the
correct subcase even if you have multiple element types).
5. Pass the subindex entry number for this subcase into
NServer_ReadOFPKEYS to retrieve the key information for the subcase.
6. Open the data block with NServer_OpenDatablk.
7. Pass the subindex entry number for this subcase into
NServer_ReadIndexedOFP and a list of id's you want retrieved into
NServer_ReadIndexedOFP to extract the recovery results.

Note. Before calling the above API (...ReadIndexedOFP) you have the option of
applying a filter on the data that will be returned (see NServer_Select) prior to
performing I/O activities.
For each ID returned you can get the first word of the Record returned
This is the subindex entry number for the first ID. Use the subindex entry
number to find the element type and number of attributes (lrecl) for this ID.
Use lrecl to position to next ID within the data Record.
Use the subindex entry number to get the iapr, iform, table, etc. codes from the 16
words returned for this subindex entry. Pass this information with the data block
name to NServer_NDDLDesc to get the NDDL label and type information for this ID.
You can use an alternative function to NServer_NDDLDesc called API
NServer_OFPDesc. This one allows you to simply provide a pointer to the subindex
entry instead of explicitly providing the NDDL label and type information.
For a detailed example that demonstrates the use of these direct access OFP API's
see the NSbrowser.f example in the "Toolkit Code Librarian" Help system.
194

NServer_GetSelect - Get a NServer_Select statement given its


number.
From Fortran:
NSGETSL
From C:

int NServer_GetSelect

( char*GrpName, INTEGER selno, char* select, INTEGER


maxlen, INTEGER *lenout, INTEGER *iret, INTEGER *Error);

Purpose: Return a select for given select number.

Arguments.

GrpName INPUT Group Name for the Server.


Selno INPUT Select number
Select OUTPUT Select clause
Maxlen INPUT Maximum length given to select
Lenout OUTPUT Length of select clause. If iret=2 lenout is the length
required
Iret OUTPUT Return codes
0 = OK
1= problem reading selects
2 - did not fit, maxlen <estchr (see estchr for length
needed)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Notes: The output string "select" is not an exact replica of the string given when
adding the select clause with NServer_Select, but is a representation of the compiled
information. It differs from the original string in the placement and delimiters of the
"SELECT, RELATION, and WHERE" clause. In addition, the WHERE clause is
blanked to prevent repeated error messages if an error is found when it is first used.

Example: See nsbrowsr.


CHAPTER 8 195
Direct Access I/O APIs

NServer_NDDLDesc – Get NDDL Labels and Types


From FORTRAN:
CALL NSNDDLD(...)
From C:

int NServer_NDDLDesc

( char *GrpName, char *BlkName, INTEGER *blktype,


char *glbstr, INTEGER *glbnum, INTEGER lglbnum,
char *label, INTEGER llabel, INTEGER *nlabel,
INTEGER *type, INTEGER ltype, INTEGER *ntype,
INTEGER *iret, INTEGER *Error );

Purpose. Returns the type and label information for a NDDL described table.

Arguments.

GrpName INPUT Group name.


BlkName INPUT NDDL name of datablock you wish described.
Blktype OUTPUT Numeric NDDL datablock type
1 table
2 vector- not implemented
3 matrix
4 unstructured
5 IFP table
6 case control
7 KELEM and similar datablocks)
8 KKDICT and similar datablocks)
9 DMI datablocks
10 bulk data current TABL
11 PVT datablock
12 OFP table
13 unknown datablock
*Note that only type 5 and 12 datablocks currently supported by this
API. Support for others will be added in a future release.
Glbstr INPUT Comma/space delimited list of Global variable names (NDDL type 2
parameters).
Glbnum INPUT Values associated with each global Array variable name in GLBSTR.
Lglbnum INPUT Length of glbnum.
Label OUTPUT String of NDDL-defined labels (comma delimited, no delimiter
following last label).
196

Llabel INPUT Length of supplied LABEL string.


Nlabel OUTPUT Length of used LABEL string
<= LLABEL, number of characters returned
= 0, nothing returned
< 0, LLABEL words returned number of additional characters
required
Type OUTPUT Table of NDDL-defined types
Array (1 Integer word per entry)
Ltype INPUT Length of supplied TYPE array.
Ntype OUTPUT Returned words in TYPE array
<= LTYPE, number of words returned
= 0, nothing returned
< 0, LTYPE words returned number of additional words required
Iret OUTPUT Return Code.
The return codes 1-4, 101-102, and 208-209 are fatal flaws.
*0 okay
1 no NDDL description
2 unsupported NDDL type
3 no NDDL description
4 insufficient opencore for NDDL (need to increase mem=)
*5 Neither types nor labels requested
6 insufficient client-supplied space for LABELs
7 insufficient client-supplied space for TYPEs
8 insufficient client-supplied space for LABELs/TYPES
101 couldn’t locate ITENT record in NDDL
102 invalid NDDL code type in IDENT record
201-207 insufficient opencore (need to increase mem=)
208 couldn’t locate DATA record in NDDL
209 unmatched EITHER/OR condition in NDDL
300-308 insufficient client-supplied space for Label or Types
501-507 insufficient opencore (need to increase mem=)
Error OUTPUT Server return error flag.
CHAPTER 8 197
Direct Access I/O APIs

Func. Ret. OUTPUT Server return error flag.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
198

NServer_OFPDesc – Get NDDL Labels and Types


From FORTRAN:
CALL NSOFPDE(...)
From C:

int NServer_OFPDesc

( char *GrpName, char *BlkName, INTEGER *Blktype,


INTEGER *subIndex, char *label, INTEGER llabel,
INTEGER *nlabel, INTEGER *type, INTEGER ltype, INTEGER
*ntype, INTEGER *iret, INTEGER *Error );

Purpose. Returns the type and label information for an NDDL described table.

Note. NServer_OFPDesc is the same as NServer_NDDLDesc except that the three


arguments (char *glbstr, INTEGER *glbnum, INTEGER lglbnum) have been
replaced with a simplified calling method that only requires a pointer to the SubIndex
array (subIndex) for the datablock of interest.
CHAPTER 8 199
Direct Access I/O APIs

NServer_ReadIndexedOFP – Get Results


From FORTRAN:
CALL NSRIOFP(...)
From C:

int NServer_ReadIndexedOFP
(char *GrpName, INTEGER Filept, INTEGER *Record,
INTEGER Reclen, INTEGER SubId, INTEGER *Ids, INTEGER
Idwds, INTEGER *NWread, INTEGER *LastId, INTEGER
*Iret, INTEGER OP, INTEGER *Error );

Purpose. Returns the OFP results data given the selected subindex entry number
and a list of ids.

Arguments.

GrpName INPUT Group Name for the Server.


Filept INPUT FIST Number for the Data Block.
Record OUTPUT Location to store values.
RecLen INPUT Length of the Record array
SubId INPUT Subindex entry number of the subcase you wish to return.
Ids INPUT Array of ids you wish to return.
Idwds INPUT Length of the Ids array.
MWread OUTPUT Number of words return in Record.
LastId INPUT- Array position within IDs of the last ID completed in Record.
OUTPUT The initial call to this API should set LastId to zero.
Note: If all requested IDs cannot be returned because of insufficient
space in Record then a nonzero value is output in LastId containing
the last ID successfully processed. A subsequent call to this API with
this nonzero LastId value will repeat the process of returning values
where the previous call left off.
Iret OUTPUT Return code.
0 – OK
1 – Problem with the index files
2 – Could not complete request. Record is too small. Use last ID to fill
a new ID list for subsequent calls.
200

OP INPUT Unused operation code.


Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

NServer_ReadIndexedOFP returns in Record the list of requested ID's. If a requested


ID is not found in the indexed table it is ignored without comment. If an ID is not
unique in the indexed table then all of the data (multiple tuples) for this ID is returned.
Each of the recovery tuples is preceded with a single word giving the subindex entry
number that this recovered data is associated with. This subindex entry can then be
used to find the element type number, the length of the tuple and the NDDL
description attributes associated with this ID (see the data description for the
subindex in Appendix H).

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 201
Direct Access I/O APIs

NServer_ReadOFPKeys – Get OFP IDs


From FORTRAN:
CALL NSROKYS(...)
From C:

int NServer_ReadOFPKeys

( char *GrpName,INTEGER Filept, INTEGER Subc, INTEGER


Offset, INTEGER *Record, INTEGER Reclen, INTEGER *
NWread, INTEGER *Iret, INTEGER *Error);

Purpose. Returns OFP key data for a particular subindex entry.


Arguments.
GrpName INPUT Group Name for the Server.
Filept INPUT FIST Number for the Data Block.
Subc INPUT Subindex entry number of subcase of interest.
Offset INPUT Last offset for keys returned in Record. A subsequent call to this API
with a non-zero offset will return keys from this offset. Offset should
be set to zero for the initial call to this API.
Record OUTPUT Location to store values. NServer_ReadOFPKeys Record is list of the
keys. For sort 1 data blocks the keys are the element ids for stress,
strain and forces and grid points for the displacements. For sort 2
data blocks results are the transpose of the sort 1 form. In sort2 the
keys are the load case or time step or frequency. The element
numbers are contained in the subindex table in the subcase word
(see Appendix H: Subindex description). If Record is not big enough
to hold all the keys the call to the API returns with iret = 2. You then
can set Offset = Offset + RecLen and call the API again to retrieve the
next batch of keys.
RecLen INPUT Length of the Record array.
NWread OUTPUT Number of words returned in Record.
Iret OUTPUT Error code returned from the Server.
0 – OK
1 – Problem with the index files
2 – RecLen too small NWread contains size required
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.
202

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 203
Direct Access I/O APIs

NServer_ReadOFPLabel – Get Title, Subtitle, Label


From FORTRAN:
CALL NSROFPL(...)
From C:

int NServer_ReadOFPLabel

( char*GrpName, INTEGER Filept, char*Select,


INTEGER Subc, INTEGER * Record, INTEGER Reclen,
INTEGER * nwds, INTEGER * iret, INTEGER * Error);

Purpose. Extracts the title, subtitle or label information from the ID record of an OFP
datablock.

Arguments.

GrpName INPUT Group name, the Server's unique identifier.


Filept INPUT Gino file number.
Select INPUT Attribute to be returned.
Valid Attributes are: “title”,”subtitle”, or “label”
Subc INPUT Subindex record number of the idrecord selected.
Record OUTPUT Output Area.
Reclen INPUT Length given to Record.
Nwds OUTPUT Length used.
Iret OUTPUT Return code.
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

To Use.
• The DMAP must have a call to module OFPINDEX (see next section for a
description) for all the OFP datablocks you will be calling with
NServer_ReadOFPSubindex or NServer_ReadOFPLabel. This module
indexes the data block and stores the index information for later use.
Typically you will want to index OES1 (stress), OEF1i (force), OESTR1
(strain) data blocks. These datablocks must be stored permanently.
Current solution sequences will make the indexes by placing a NASTRAN
INDEX=OFP card in the data deck and running your jobs with scr=no or
scr=mini.
204

• Assuming the client code has performed the normal startup api calls, the
client will allocate the appropriate OFP data block (see
NServer_AllocDatablk).
• Call NServer_ReadOFPSubindex to return all the subcase/element type
combinations (see Appendix H: Subindex description) for a description of
the attributes). Choose the subcase you are interested in from the subindex
table (any entry with the correct subcase even if you have multiple element
types). Pass the subindex entry number for this subcase into
NServer_ReadOFPLabel to retrieve the title, subtitle, or label information for
the subcase.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 205
Direct Access I/O APIs

NServer_ReadOFPLabelC - Read title, subtitle, and label items from


the OFP ID record
From FORTRAN:
NSROLBL
From C:

int NServer_ReadOFPLabelC

( char *GrpName, INTEGER gfile, INTEGER Subc, char


*title, char *subtitle, char *label, INTEGER *iret,
INTEGER *Error);

Purpose: Read title, subtitle, and label items from the OFP ID record for a given
Subc index number.

Arguments:.

GrpName INPUT (Max Length = 256) Group name, the Server's unique
identifier gfile input integer gino file number
Subc INPUT Subindex record number of the idrecord selected.
Title OUTPUT Array of length 129
Subtitle OUTPUT Array of length 129
Label OUTPUT Array of length 129 iret output integer return code
0 = OK
1 = problem reading the index for this gfile
3 = subc not valid
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag
206

NServer_ReadOFPSubindex – Get OFP identification information


From FORTRAN:
CALL NSROSUB(...)
From C:

int NServer_ReadOFPSubindex

( char *GrpName, INTEGER Filept, INTEGER *Record,


INTEGER Reclen, INTEGER *NWread, INTEGER *Iret,
INTEGER *Error );

Purpose. Returns a condensed view of the OFP id record(s) with information that
includes subcase, element type and various flag words that define the associated data
record(s).

Arguments.

GrpName INPUT Server Group Name.


Filept INPUT Data Block File Number (see NServer_AllocDB).
Record OUTPUT Location to store values. One 16 word entry is returned for each OFP
id record. For statics sort1 data there is one entry for each element
type within a subcase times the number of subcases. (See description
for this entry (referred to as subindex) in Appendix H).
RecLen INPUT Length of the Record array.
NWread OUTPUT Number of words return in Record.
Iret OUTPUT Error code returned from the Server
0 – OK
1 – Problem with the subcase index file
2 – RecLen too small NWread contains size required
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag.

Application Note. OFP data blocks consist of a set of two records which group the
output data. The first of the two records is a 146 word OFP id record. It contains a
number of flag words that describes the data record and also contains subcase and
element type information. The second record contains the data. This two record group
is repeated until all the element types for each subcase has been written, then repeated
for all the subcases. In pseudo code it is
CHAPTER 8 207
Direct Access I/O APIs

Sort 1 Data
foreach subcase=1,nosubs {
foreach element_type=1,notypes { #for element data
write id record
write data record # all elements or grids
}
}
Sort 2 Data
foreach subcase=1,nosubs { # usually one subcase
foreach element_number=1,noelements { #selected elements
write id record
write data record #all output freq or timesteps
}
}

MSC.Nastran NServer_ReadOFPSubindex presents a condensed view of the OFP ID


record with information about the subcase, element type, and some important flag
words that define the data record. NServer_ReadOFPLabel API extracts the title,
subtitle or label information from the ID record.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
208

NServer_ReadOFPSubindexEntry - Get one OFP subindex entry.


From FORTRAN:
CALL NSRSUBE
From C:

int NServer_ReadOFPSubindexEntry

(char *GrpName, INTEGER Filept, INTEGER Subi, INTEGER *


Record, INTEGER * Iret, INTEGER * Error);

Purpose: Returns a single subindex entry given the Subi and Filept. The subindex
entry is a condensed view of one OFP id record with information on the subcase,
element type and other words which define the associated data record. This API
returns a single entry while Nserver_ReadOFPSubindex returns all entries for an OFP
datablock.

Arguments.

GrpName INPUT Group Name for the Server.


Filept INPUT FIST Number for the Data Block.
Subi INPUT Subindex entry number
Record OUTPUT Location to store values
Iret OUTPUT Return code from this API.
0 = OK
1 = Problem with the subcase index file
2 = RecLen too small - NWread contains size required
Error OUTPUT Server return error flag.
Func. Ret OUTPUT Server return error flag.

Notes: See NServer_ReadOFPSubindex for details on the contents of the subindex


entry.
It is more efficient to use NServer_ReadOFPSubindex instead of
NServer_ReadOFPSubindexEntry if a large number of
NServer_ReadOFPSubindexEntry calls are expected for a particular datablock.
CHAPTER 8 209
Direct Access I/O APIs

NServer_RemoveSelect – Remove a Filter Set by a Previous Call to


NServer_Select
From FORTRAN:
CALL NSRMSEL (...)
From C:

int NServer_RemoveSelect

( char* GrpName, INTEGER SelectId, INTERGER Iret,


INTEGER *Error );

Purpose. Removes a filter for a datablock set by a previous call to Nserver_Select.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
SelectId INPUT A unique identifier associated with a previous call to NserverSelect.
The select statement (filter) associated with this id will be removed.
If SelectId < 0 then all Nserver_Select are removed.
Iret OUTPUT Return Code. For Non-Zero values see output from
NServer_GetMessage (p. 61)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
210

NServer_Select – Define a Filter for Datablock Attributes Prior to


Performing I/O Activities
From FORTRAN:
CALL NSSELCT (...)
From C:

int NServer_Select

( char* GrpName, char *Select , INTEGER* SelectId,


INTEGER Tolerance, INTERGER Iret, INTEGER *Error )

Purpose. To define a filter for a datablock record prior to performing I/O activities.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max.


256 chars.)
Select INPUT A select statement with the following format:
"select(attribute_names...) [where(where expression) relation(
[fist='fistno'] [record='recordname'] [recordno=eltype or
cardno] [datablock='datablk_name'] [type='typename']
[typeno=type] [acode=acode] [tcode=tcode] [scode=scode]
[acflag=acflag])]"
where:
expression is a logical expression that specifies the desired values of
the attribute_names.
'fistno' is the integer GINO fist number for the datablock that the
Select statement filter will apply.
'recordname' is the character string name of the card/element type
(e.g., 'HEXA','CBAR','PBAR')
eltype is the integer internal element type for an OFP type datablock.
Specifically, it is the third word returned from a call to
Nserver_ReadSubindex.
cardno is the integer internal element number for an IFP type
datablock. Specifically, it is the word returned from a call to
Nserver_ReadIfpKeys.
datablock_name is the character string name of the datablock (e.g.,
'OES1', 'EPT')
CHAPTER 8 211
Direct Access I/O APIs

'typename' is the character string datablock type (e.g.,


'IFP','OFP','MATRIX',…)
type is the integer internal datablock type corresponding to the above
'typename' values. Specifically, it is the typeno value returned
from a call to Nserver_NDDLDesc.
Acode, tcode, scode, fcode, acflag are integer values representing the
analysis, table, sort, format, acoustic or thermal codes
respectively of the OFP relation. They are contained in the
NDDL description documentation for the OFP datablock and
are returned by NServer_ReadOFPSubindex (see Appendix H:
Subindex description).
SelectId OUTPUT A unique identifier associated with this Select statement
Tolerance INPUT The number of digits of accuracy.
Iret OUTPUT Return Code. For Non-Zero values see output from
NServer_GetMessage (p. 61)
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag.

Notes.
1. Schema definitions are described in MSC.Software's NDDL (Nastran Data
Definition Language).
2. NServer_OFPSubindex should be called after NServer_Select calls in order
to have the data returned from NServer_OFPSubindex reflect
changes/filtering that occur as a result of processing the NServer “Select
statement”.
3. The Select statement syntax is similar to the NServer_Dbdict input request
string (DBdicString). (see also the Quick Reference Guide description of
DBDICT). In the absence of a select clause all attributes are returned in
NDDL order.
4. An attribute name within the select clause is ignored if it does not match an
attribute name in the NDDL description.
5. You may specify each attribute in the schema in any order in the select
clause. The terms will be returned in that order. If the attribute name is not
unique within the NDDL (used in several fields of the same relation) then all
fields of that attribute name will be returned.
6. The filter set by each NServer_Select will be applied to any subsequent I/O
performed using either Nserver_ReadIndexedIFP or
Nserver_ReadIndexedOFP which match the relation terms.
212

7. If an attribute name in the where clause does not match one of the attributes
in the NDDL description, then this relation is not returned.
8. If an attribute name in the where clause is not unique then the where test is
done on the last field of that name in the NDDL.
9. If a where clause is not syntactically correct then the where clause is ignored.
Any select clause for this relation will still be processed.
10. A filter can be removed by NServer_RemoveSelect.
11. Nserver_Select are matched with relations are they are being read by
Nserver_ReadIndexedIFP or Nserver_ReadIndexedOFP. For
Nserver_ReadIndexedIFP FIST, DATABLK, TYPE, TYPENO, RECORDNO
or RECORD are used in the selection. For Nserver_ReadIndexedOFP FIST,
DATABLK, TYPE, TYPENO, RECORDNO or ELTYPE, ACODE, TCODE,
SCODE, FCODE, ACFLAG, NUMWDE are used in the selection. Bold-face
keywords are the minimum and are usually enough (but not always) to
uniquely specify a relation for a single MSC.Nastran Project/Version.
12. Items contained in the relation clause (datablk, tcode, etc.) are used to specify
the relation this select and where clause are to apply. Terms necessary to
fully select relation but are absent from the relation clause are assumed to be
wildcarded, that is, will match anything.
13. Only one Nserver_Select is allowed for a particular relation clause. If another
having the same set of relation keyword and values as a previously defined
one, then the old one is removed.

Example.
1. Set a filter so that only the attributes sx1, sx2 are returned when sx1 is less
than 1.0E03. This filter will apply to all subsequent calls to
Nserver_ReadIndexedOFP referencing QUAD4 element results from GINO
file 101.
‘select(sx1, sy1) where (sx1 < 1.0E03) relation(
FIST=101,eltype=33,datablk=’OES1’)’
Note that a subsequent call to Nserver_ReadIndexedOFP will return two
values (sx1 and sy1) for each referenced QUAD4 element having an sx1
values less than 1.0E03.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 213
Direct Access I/O APIs

NServer_SelectOFP – Select OFP Results


From FORTRAN:
CALL NSSLOFP(...)
From C:

int NServer_SelectOFP

( char *GrpName, INTEGER GrpNameLen, INTEGER


*FileptList, INTEGER FileptLen, INTEGER *SubIdList,
INTEGER SubIdwds, INTEGER *IdList, INTEGER Idwds,
INTEGER *SelectOFPId, char *SortOrder, INTEGER
AutoIndex, INTEGER *Iret, INTEGER *Error );

Purpose. To return a pointer (SelectdOFPId) that identifies a selection of OFP results


data across a set of databases and datablocks based on a list of requested subcase(s)
and ids (elements/grids). The SelectOFPId pointer is subsequently used by a set of
utility API's that return the data selected and associated descriptive information (see
note 3 for a description of these API's).

Notes. This API and its associated utility API's were designed as an alternative and
"easier to use" interface to the following five API's and as a way to eliminate much of
the coding required within a Toolkit application to use these earlier API's (e.g., the
application writer is no longer required to: (1) handle the various forms of OFP data
(i.e., Sort1/Sort2), (2) understand the differences between internal and external
Subcase specifications (user defined external Subcase specifications can be used), (3)
handle the processing of this data across multiple databases and multiple datablocks,
(4) handle the details of labeling and type definition of the returned data, (5) and
finally, handle the issues related to "opening" and "indexing" of the data prior to
access-- this is all handled automatically by this and its associated utility API's.
NServer_ReadOFPSubindex
NServer_ReadOFPKeys
NServer_ReadIndexedOFP
NServer_NDDLDesc
NServer_OFPDesc
The above five API's will continue to be available and supported within the Toolkit
product--in fact, this NServer_SelectOFP API and its associated utility API's described
below use these five API's as part of their underlying implementation code.
214

Arguments.

GrpNameList INPUT Array containing the list of databases (i.e., GrpName(s)) to


process, corresponding one-to-one with the following list of
datablocks in the FileptList array.
GrpNameLen INPUT LENGTH of the GrpNameList
FileptList INPUT Array containing the list of "file handles" (Filept) that
reference datablocks (e.g, stress, strain, displacement) to
process. (see note 6)
FileptLen INPUT LENGTH of the FileptList
SubIdList INPUT Array of Subcases to process (4 words/subcase)
Each 4 word entry specifies the external user specification for
the Subcase. The Subcase format/content and how many of
the 4 words is required to uniquely define a Subcase is
dependent on the particular type of analysis (see the
Subindex description in User's Guide Appendix, and see
note 3 below for description of a utility API that returns the
available "external" Subcase definitions that can then be used
as input for this SubIdList parameter)
SubIdwds INPUT Length (number of words) of SubIdList array
IdList INPUT Array of id(s) you wish to return
Note: This is the list of element ID's or grid ids. (see note 3
below for description of a utility API that can be used to
return the available id(s) that can be used as input for this
IdList parameter)
Idwds INPUT Length (number of words) of the IdList array.
SelectOFPId OUTPUT ID that identifies this specific SelectOFP request. (see note 7)
Used by subsequent utility API's to access the select data and associated
descriptive information. (see note 3)
SortOrder INPUT Sort order to return data:
"" = order as determined by file type (i.e., sort1 or sort2)
"sort1" = element order (sort 1)
"sort2" = subcase order (sort 2)
"order by …" = specification that allows order of the return
data based on a user defined criteria--similar to SQL "order
by" command.
CHAPTER 8 215
Direct Access I/O APIs

AutoIndex INPUT 1=Create and index any files in FileptList that aren't Indexed.
2=Create a new index for each file in FiletptList even if an
index already exists.
Error OUTPUT Return error flag (see notes for special error handling
function for this Error-Nserver_GetOFPMsg will process this
Error)
Function Return OUTPUT Return error flag (see notes for special error handling
function for this Error-Nserver_GetOFPMsg will process this
Error)

Notes:
1. NServer_SelectOFP returns a pointer (SelectOFPId) that can be used to
access the OFP data as specified within the supplied list of databases,
datablocks and requested Subcase(s) and Element/Grid id's. If a requested
Subcase and/or Element/Grid id is not found in the indexed table it is
ignored without comment. If an Element/Grid id is not unique in the
indexed table then all of the data (multiple tuples) for this id are processed.
If a requested database (GrpName) or file (in FileptList) is empty/purged it
is ignored and a warning message is issued.
2. NServer_SelectOFP will perform the following functions:
a. It will prepare ("open") all datablocks as specified in the FileptList for
I/O access (using NServer_OpenDatablk). Note: The datablock is
allowed to be already open prior to this API call--in that case this open
operation will be skipped.
b. It will Index the datablock if the AutoIndex flag=1 and the datablock is
not already indexed. Autoindex=2 will force a new index to be created
even if one already exists.
c. It will determine whether the requested datablock is formatted in SORT1
or SORT2 and then in conjunction with the order requested by the
SortOrder parameter it will traverse and return the data (see
NServer_GetNextEntry) in the requested order (e.g., a "SORT1" request
would return all requested elements for one Subcase at a time or a
"SORT2" request would return all requested Subcases for one
element/grid at a time).
216

3. Various support functions (API's) are listed below which are available to use
with this API--the first two groups of API's are designed to be used after
calling NServer_SelectOFP---they provide access to the data found within
the selected record entries and their associated descriptive information. The
last group of API's can be used to automate the preparation of the input
parameters used to specify the Subcase(s) and Element(s)/Grid(s) to be
processed by NServer_SelectOFP:

Basic Utility API's used to read the selected datablock entries:


1. NServer_GetNextEntry(SelcctOFPId, Datablockptr, Iret, Error)
--Advance pointer (Datablockptr) to next entry within the selected OFP
datablocks.
2. NServer_GetLen( Datablockptr, Nwds, NTerms, Error)
--Get the length of the current entry.
3. NServer_GetData(Datablockptr, Data, Iret, Error)
--Get the data (e.g., sx1, sy1…) within the current entry.
4. NServer_GetLabels(Datablockptr, Label, Iret, Error)
--Get the Labels (i.e., NDDL defined,e.g., "sx1","sx2") for the terms in the
current entry.
5. NServer_GetTypes(Datablockptr, Type, Iret, Error)
--Get the Types (i.e., integer, real, character…) for the current entry.
Calls to the above API's can be repeated until the end-of-data is reached
(i.e, NServer_GetNextEntry returns a Datablockptr = 0).

Utility API's that return information about the data being processed are:
1. NServer_GetDatablkType(Datablockptr, DatablkType, Iret, Error)
--Get the type of datablock where the current entry was found (i.e,
"table","OFP" ….)
2. NServer_GetSubcase(Datablockptr, Subcaseptr, Error)
--Get the pointer into the Subcase list ( SubIdList ) where the current
entry was found.
3. NServer_GetFilept(Datablockptr, Filept, Error)
--Get the datablock file pointer (Filept) where the current entry was
found.
4. NServer_GetGrpName(Datablockptr, GrpName, Error)
--Get the database (GrpName) where the current entry was found.
5. NServer_GetMsg(SelectOFPId, ErrorList, Error)
--Get the errors(s) corresponding to each datablock in FileptList.
CHAPTER 8 217
Direct Access I/O APIs

6. NServer_RemoveSelcctOFP(SelectOFPId, Error)
--Remove all internal data structures and close all files associated with
the specified NServer_SelectOFP call.

Prior to calling NServer SelectOFP the following utility API's can be used to
create the input parameters SubIdList and IdList used by Nserver_SelectOFP:
1. NServer_GetSubIdList(GrpNameList, GrpNameLen, FileptList,FileptLen,
SubIdList, SubIdLen, SubIdLenOut, Ierr, Error)
--Get a list of the 4 word/entry external Subcases (SubIdList) contained
within the requested database(s) (GrpNameList) and datablock(s)
(FileptList).
2. NServer_GetIdList(GrpNameList, GrpNameLen, FileptList, FileptLen,
SubIdList, SubIdLen, IdList, IdListLen, IdListLenOut, Ierr, Error)
--Get the list of Id's (element id's/grid id's) (IdList) contained within the
requested database(s)(GrpNameList), datablock(s)(FileptList) and
Subcases (SubIdlist).

Notes: The 1-4 words for the SubcaseID's (External Subcase Specification) is defined
based on the analysis type. They are defined as follows:
--see Subindex description in the appendix of the Toolkit User's Guide---
If the same GrpName applies to all the datablocks specified in the FileptList array then
only the first GrpNameList entry needs to be specified--i.e., in this case it will be
assumed that all datablocks specified in the associated FileptList can be found on the
same database as specified by the single GrpName value.
The Filept value is the file "handle" used to reference a specific datablock on the
MSC.Nastran database (see NServer_AllocDatablk).
The output from multiple NServer_SelectOFP calls can be processed concurrently, the
results for each call identified by its unique SelectOFPId value. To support this
functionality the Datablockptr value returned from a NServer_GetNextEntry call is
also unique within a Toolkit application.

Code Example: See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
218

NServer_SetSelectGroup - set or switch SelectGroup.


From FORTRAN:
NSSELGR
From C:

int NServer_SetSelectGroup

(char*GrpName, char*selgrp, INTEGER grpnum, INTEGER *


iret, INTEGER *Error) ;

Purpose: Activate a set of select clauses.

Arguments:

GrpName INPUT Sever handle


Selgrp INPUT Group name (max length 8 characters) grpnum int
input - group number
Iret OUTPUT Return code:
0 = OK
>0 = various codes from ldnssel (load selects) or from
wrnssel (write selects) iret = 100*iret wrnssel + iret
ldnssel
Error OUTPUT Server return error flag
Func. Ret. OUTPUT Server return error flag

Notes: Before a SelectGroup is changed the current group is written to NSSELEC


datablock.
After the current group has been written to the database, the NSSELEC datablock
(qualified with selgrp and grpnum) are loaded to be used. Any changes to the selects
will be made to this group.
Switching often between groups should be avoided. Each select which is referenced
during a indexed OFP or IFP Read will be recompiled after a change in groups.
Overhead in reading the NDDL Description information can add up if done a
significant number of times.
Default selgrp = ' ' (8 blank characters), grpnum=0.

Example: see nsbrowsr.


CHAPTER 8 219
Direct Access I/O APIs

NServer_SortSelect – Sort NServer_Select to User Input Order or to


Default Order
From FORTRAN:
CALL NSSOSEL (...)
From C:

int NServer_SortSelect

( char* GrpName, INTEGER SortCode, INTERGER Iret,


INTEGER *Error );

Purpose. Sort Nserver_Select to user input order.

Arguments.

GrpName INPUT A unique identifier for the Client/Server communication. (Max. 256
chars.)
SortCode INPUT SortCode=0. Use user input order of the Nserver_Select clauses.
SortCode=1, use default order.
Iret OUTPUT Return Code. For Non-Zero values see output from
NServer_GetMessage (p. 61)
Error OUTPUT Server return error flag.
Func. Ret. OUTPUT Server return error flag.

Note that Default ordering has relations which contain record type info (record,
recordno, eltype and all codes) at the top of the list following by those with datablk,
then type or typeno, then fist number.

Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
220
MSC.Nastran Toolkit User’s Guide

APPENDIX
MSC.Nastran Datablocks Tutorial
A
■ Datablock Information

■ Output Style Blocks


■ Approach Codes

■ Stress Codes
■ Did a Block Change?

■ TABPRT

■ SEDRCVR

■ DBLOCATE and Restart


222

A.1 Datablock Information


This is a tutorial to assist MSC.Nastran User's in obtaining information regarding
MSC.Nastran datablock tables.
The information is organized as follows.

1. Datablock Basics 2. Datablock structure and


composition
3. Datablock pseudonyms 4. Textural descriptions
5. Inter-version changes 6. Helpful hints
7. Datablock Names 8. Advanced Techniques

Datablock Basics
Datablocks are the mechanism for storing and passing most information in
MSC.Nastran. One may think of them as simply a file composed of many records.
Each record in turn is composed of many fields.
There are two fundamental forms for datablocks, matrices and tables.
• Matrices represent floating point quantities only. All matrices are described
by a consistent record structure. Each record contains a column of the matrix.
An example of this is KGG, which is the stiffness matrix.
• Tables represent mixed data type quantities. All tables may be different, both
in number of records, and the contents of each record. Tables are specific to
various applications, disciplines and module requirements. Some tables are
similar in composition, such as output tables, and share descriptions.

Datablock Structure and Composition


Matrices are composed of:

Record 0 This is the header. It echoes the name of the matrix (e.g. KGG)
Record 1-N Each record is a column of the matrix
Record Trailer Standardized matrix information

Tables are composed of:

Record 0 This is the header. It echoes the name of the table (e.g. OSTR1)
Record 1-N Application specific data
Record Trailer Application specific data
CHAPTER A 223
MSC.Nastran Datablocks Tutorial

Datablock Pseudonyms
The NDDL (Nastran Data Definition Language) is a compilation of the various tables
and matrices by name used in the various DMAP solution sequences. However, not
all names that appear in the DMAP will appear in the NDDL. This is because a
datablock is the "default" primitive of DMAP, and hence needs no "type" in DMAP.
For a detailed guide to understanding the language of the NDDL please refer to the
DMAP Module Dictionary.
To look at the NDDL for a particular release use the following data file.
$
acquire nddl=nddl
compile nddl=nddl souin=mscsou list
cend
begin bulk
enddata
If for instance,we want to find information about datablock OSTR1 we find the lines
in the NDDL referring to OSTR1.
DATABLK OSTR1 TYPE=TABLE(OFP),PATH=SEIDI LOCATION=OUTSCR,
SAMEAS,OES,EOF
We notice that is says OSTR1 is the same as OES or is a pseudonym of OES. We now
can look at the datablock OES for the appropriate description.
DATABLK OES TYPE=TABLE(OFP),PATH=SEIDI LOCATION=OUTSCR,
[ description omitted ]

Textural Descriptions
The schema or data definition or contents of the records for MSC.Nastran datablocks
is also contained in the NDDL. These contents are composed of simple field
descriptions, such as integer, real or character.
For version 69, meaningful text strings were added to many field description. You
may want to check the NDDL first if you are unsure about the composition of a block.
To see each field with labels and its associated values, use the TABPRT module. See
TABPRT (p. 234).
Record '0' can usually be ignored for a table. Typically this is simply the name,
although sometimes a date or other data is also contained.
Occasionally there may be a difference in the DMAP name and the name contained on
RECORD 0. Major differences can result from erroneous INPUT2/OUTPUT2
operations. Check carefully the messages when using these utilities.
224

Inter-version Changes
Beginning with V69 a simple diff of the NDDL files will provide information
regarding changes to datablocks. This can be important for third party applications
that read OUTPUT2 files. The current methods are somewhat more indirect.
Clients are presumed to have some familiarity with decoding the OUTPUT2
formatted files. Hence the following information reflects how to keep those existing
programs current, rather than providing a from scratch methodology.
Please refer to the DMAP Module Dictionary for more OUTPUT2 information.
The approaches described presume the availability of MSC.Nastran. Some clients
send their OUTPUT2 files to a third party. This information will not be particularly
helpful for the third party.
The DBC (.xdb ) interface is well documented, and uses procedural calls to extract
data, and is an alternative to the OUTPUT2. This information will not address DBC.

Caution: The format of DBC data does not necessarily reflect the NDDL data format.
OFP print (*.f06) may shuffle/ omit/ interpret various fields of data as they
actually appear on the datablock.

The MSC.Nastran Toolkit interface, as documented in this User’s Guide, provides a


more direct method than either OUTPUT2 or DBC (.xdb) for accessing the data
generated by MSC.Nastran. In addition, the affects on existing Toolkit applications
related to changes to the MSC.Nastran datablocks will be eliminated in most cases by
making use of the Toolkit’s ability to extract data from MSC.Nastran using NDDL
defined attribute labels (e.g., "EID, CID, SX") (see API NServer_Select for details).
Since attributes for existing datablocks rarely change this method shields the Toolkit
developer’s applications from changes/additions to the internal structure of the data.

Helpful Hints
Learn the NDDL language rules, and read the NDDL directly as a primary guide to
what the datablocks look like. Each release provides an NDDL that may be viewed.
Changes in blocks between releases are (mostly) reflected in the NDDL.
Matrix formats rarely change (new type added in V68). Table formats change
whenever a new element is added, as well as when an existing element is modified
(e.g., for V68 substantial changes to the optimization tables occurred, and many
elements were added to the stress and force tables).
Don't let similar names confuse you. Expect that OES1ZZM in DMAP is probably just
an OES style block, or that GEOM1S is simply GEOM1. Use the NDDL as a guide. If a
block is explicitly named in the NDDL, it will probably reference a SAMEAS block.
CHAPTER A 225
MSC.Nastran Datablocks Tutorial

If there is no indication in the NDDL, you may read the DMAP. If you see a block in a
similar position (e.g., third input), then the block is almost surely of the same root
family as other blocks appearing in that position.
226

Example
If one EMG reference has a block ABC as the fifth input, and another EMG reference
has a block GEOM2 as the third input, then presume ABC is of type GEOM2.

Caution: Some modules do allow peculiar variants on input.

Datablock Names
• Datablock table names follow a general pattern (though it is not a definite
rule).
• If the first character is 'O', then it is an output table (e.g., OES ).
• If the second character is 'E' then it refers to elements. If it is a 'U' then it refers
to displacement type data (e.g., OES vs OUG).
• If the table has a '1' or a '2', then it refers to SORT1 or SORT2 table order (e.g.,
OES1x, OES2x).
• The letter 'S' many times refers to Stress or Strain (e.g. OES). It may also refer
to a subset. This means application specific portions have been extracted.
(e.g., GEOM1 vs GEOM1s).
• The letter 'F' many times refers to Force.
• The letter 'G' many times refers to Grid.
• (e.g) So the OES1X table is OUTPUT ELEMENT STRESS (SORT1) table.
• The 'X' was just used by DMAP to make a different variable name.
Advanced Techniques
If you cannot find a block on the database, it may have been a temporary or scratch
block and was deleted. This is very typical of output blocks. In this case you will need
to print it during the data generation, or save scratch (output) datablocks.
For instance you may consider (for small jobs) adding the following parameter to your
bulk file.
param,scratch,'dball'
Then you will need to run a restart job to DBLOCATE the block of interest and
TABPRT the contents. See DBLOCATE and Restart (p. 237).
(Larger jobs will require a better DMAP change. This parameter will change the
location of all scratch blocks to be DBALL. this will increase the size of DBALL.)
Typically, the many useful blocks, such as the output (OFP blocks) are not saved on
the database. A good place to make alters for output datablocks is in SEDRCVR. See
SEDRCVR (p. 235).
CHAPTER A 227
MSC.Nastran Datablocks Tutorial

A.2 Output Style Blocks


Decoding the output block formats is tricky. One cause of difficulty is is a backwards
reference to a prior record. What that means is that a pattern is followed in output
blocks

Record 0 Header (ignore)


Record I Tells whats coming in the next data record
Record D The collected element/displacement data
Record I Tells whats coming in the next data record
Record D The collected element/displacement data
Record I ...
Record D ...

Certain fields within the output block record 'ID' tell what follows in the record
'DATA'. These fields within record 'ID' must be interpreted by certain algorithms.
Some are simple, others are not.
Note the values that result from interpretation do not in any way change the
underlying data. The results are only a mechanism for branching to correct forms in
the NDDL.
The fields are

ID Name Word Position


ACODE approach_code 1 See Approach Codes (p. 230)
TCODE table_code 2
FCODE format_code 9
SCODE stress_code 11

TCODE
Determines whether the data is real or real/imaginary and if the data is sort1 or sort2.
(Historically all tables had a unique id. That rule is not necessarily enforced.)
= 1 means sort1
= 2 means sort2
theory:
There are four major categories (defined by MAJOR).
For each category TCODE and TREAL are shown.
228

( TREAL is used by FCODE )


MAJOR = 1 SORT1 REAL;=2 SORT1 R/I ;=3 SORT2 REAL;=4 S2
R/I
TCODE = 1 ;=1 ;=2 ;=2
TREAL = 0 ;=1 ;=0 ;=1

method :
MAJOR = table_code / 1000
MINOR = table_code - 1000 * MAJOR
MAJOR = MAJOR+1
TCODE = 1
IF ( MAJOR .GE. 3 ) TCODE = 2

theory : ( For TREAL )


C TREAL =0 IF REAL ; =1 IF REAL/IMAGINARY
C SET TREAL
MOD = MAJOR / 2
MOD = MAJOR - 2 * MOD
IF ( MOD .EQ. 0 ) TREAL = 1
IF ( MOD .EQ. 1 ) TREAL = 0

FCODE
Determines whether the data is real/real-imaginary/magnitude-phase.
The format_code is unreliable. It represents a default or 'what the client asked for'.
Nastran uses the table_code to actually determine what to do. The format_code is
more of a relic to preserve 'client intent', but does distinguish complex forms.
= 0 means real
= 1 means real/imaginary
method :
if a table_code (as always) has been specified then
FCODE = TREAL
endif

if ( format_code .EQ. 3 ) then


if ( ACODE.EQ. 5 .or. ACODE .eq. 9 )
MAGPHASE=.true.
endif

ACODE
Determines field data type (Integer or Real)
method :
ACODE = approach_code / 10 [See Appendix B]
CHAPTER A 229
MSC.Nastran Datablocks Tutorial

SCODE
Determines whether its stress or strain. It also determines Hencky von Mises,
octahedral or curve (plate theory). See Appendix C.
= 0 means strain
= 1 means stress
method :
TEST = IAND ( stress_code,2 )
SCODE = 0
IF ( TEST .EQ. 0 ) SCODE = 1
230

A.3 Approach Codes


A list of the approach codes is shown below as they apply to datablock OES. The
approaches are in general the same across OFP type blocks, though not all blocks
allow all approaches.
1 Statics
2 Real Eigenvalues
3 Differential Stiffness 0
4 Differential Stiffness 1
5 Frequency
6 Transient
7 Pre Buckling (0)
8 Post Buckling (1)
9 Complex Eigenvalues
10 Nonlinear Statics (Sol 66 and Sol 106 )
11 Geometric Nonlinear Statics (Sol 64 ? )
12 ? May appear as approach code 6 ?
CHAPTER A 231
MSC.Nastran Datablocks Tutorial

A.4 Stress Codes


OFP (output) style datablocks MAY contain information concerning stress or strain
quantities.
By examining word 11 (stress_code) of the 'ID' record of an OFP block one may
determine several things.
• If quantities are stress or strain related.
• If the quantity is maximum shear* or Hencky-von Mises.
• If the strain is curvature or extreme fibre(plate). (*Interpret maximum
shear as octahedral if a 'solid' element. )
One may not, by examining the bits, determine if a given block has stress or strain
quantities. For instance a block may have displacement, velocity, or acceleration
components. In this case word 11 is not used, or has another definition.
For those blocks where stress or strain is pertinent, one may examine the bits of word
11 as follows
low bits Total Meaning of the bits 3,2,1
1 1 1 7 Not Curvature, Strain , von Mises
1 1 0 6 Not Curvature, Strain , max shear/Oct
0 1 1 3 Curvature, Strain , von Mises
0 1 0 2 Curvature, Strain , max shear/Oct
0 0 1 1 n/a , Stress , Von Mises
0 0 0 0 n/a , Stress , max shear/Oct

Invalid patterns are


1 0 0 4 ( curvature does not apply to stress )
1 0 1 5 ( curvature does not apply to stress )

In other words,
bit '1' toggles for von Mises or max shear/Octahedral
bit '2' toggles for stress or strain
bit '3' toggles for strain curvature
A way of testing in Fortran follows (ignoring error patterns)
C von Mises or maximum shear
IF ( IAND ( SCODE, 1 ) .EQ. 0 ) THEN
MISES = .FALSE.
ELSE
MISES = .TRUE.
ENDIF
C Stress or Strain ?
IF ( IAND ( SCODE, 2 ) .EQ. 0 ) THEN
STRAIN = .FALSE.
CURVE = .FALSE.
ELSE
STRAIN = .TRUE.
C Curvature or not ?
IF ( IAND ( SCODE, 4 ) .EQ. 0 ) THEN
232

CURVE = .TRUE.
ELSE
CURVE = .FALSE.
ENDIF
ENDIF
CHAPTER A 233
MSC.Nastran Datablocks Tutorial

A.5 Did a Block Change?


Provided are a few guidelines to help you check for Block changes.
1. Tabpt or Matprn or Tabprt the block you are interested in knowing about in
the "release A" (e.g., V69).
Do the same operation in "release B" (e.g., V68).
2. First compare the length of the records. If they are different, then you know
the form has changed.
3. If the record length is the same, then check the contents. A field may have
moved or replaced.
4. The Tabprt function (if available in the particular release) can be useful,
especially if the block is described in the NDDL. It can also be useful is the
block shares a description with another block. See TABPRT (p. 234).
234

A.6 TABPRT
To find what datablocks look like use the TABPT or TABPRT (better) module. The
TABPRT and TABPT modules are documented in the DMAP Module Dictionary.
TABPT (no 'R') is a more global printing module. It knows nothing of the datablocks'
format, and makes guesses as to the datatype (e.g. real,bcd, etc) using hueristic rules.
Some of the guesses may be wrong, but all fields are printed.
TABPRT instead uses the NDDL defined fields if available. The TABPRT module
prints descriptive labels over each field of the output. This can be of help in correlating
information found in the programmer's manual.
To look at a datablock with descriptive labels use the following DMAP alter
alter xxx
TABPRT BLOCK/////2 $ There are 5 slashes, and they must appear.
(e.g) TABPRT EDOM/////2 $

If the block is not coded in the NDDL, but is the same as another block, use the
following DMAP alter
alter xxx
TABPRT BLOCK//'GENERIC'/0//2 $ The zero is only necessary sometimes.
(e.g) TABPRT EDOMPQ//'EDOM'/0//2 $

In the above examples a '2' is coded as the last parameter.


A '2' indicates use the NDDL, and do some bounds checking.
Suspect values will be printed with ??? in their labels.
You may also specify a '1' or a '3'.
A '1' indicates do not do bounds checking, simply print.
A '3' indicates only print records that violate boundary checking rules.

First Mistake
If you get a message as the following. You have simply failed to specify a '1' '2' or '3'
as the last parameter. This means you inherited the default. The default means you
want a 'prettier' printout (hardcoded, does not use the NDDL) for 'a few' popular
blocks.
*** USER WARNING MESSAGE 2094 (TABFMT)
KEYNAME xxxxxx NOT IN LIST OF AVAILABLE KEYNAMES
*** LIST OF RECOGNIZED KEYNAMES..
BGPDT
[ etc ]
*** MODULE TABPRT ABANDONS PROCESSING.
CHAPTER A 235
MSC.Nastran Datablocks Tutorial

A.7 SEDRCVR
A brute force method to finding how any output is produced in MSC.Nastran follows.
1. Redirect all the print to a single file. This will allow you to see the DMAP
instruction that produced the output. This occurs because the F04 which logs
all the DMAP module usage, will be blended with the F06 print that resulted
from the module execution.
2. Add this card to the top of your execution file. This will make the F04 and the
F06 appear in the log file.
Nastran system(2) =0 system(86)=0
3. Run your problem as usual. Then look in the spot where the printed output
that you are interested in occurs.
4. Find the previous text string OFP. Make a note of the name of the SUBDMAP
and its line number of execution.
10:14:24 0:36 33.9 .0 14.1 .0 SEDRCVR 230 OFP BEGN
10:14:24 0:36 33.9 .0 14.1 .0 SEDRCVR 264 OFP BEGN
1 TEST OUT A UNIT LOAD ON A CANTILEVER BEAM OCTOBER 31,
1996 MSC.NASTRAN 10/30/96 PAGE 29
STATIC ANALYSIS OF A CANTILEVER BEAM
0 TRANSVERSE LOAD AT FREE END SUBCASE
1
LOAD STEP = 1.00000E-01
S T R E S S E S I N H E X A H E D R O N S O L I D E
L E M E N T S ( H E X A )
0 CORNER ------CENTER AND CORNER POINT
STRESSES--------- DIR. COSINES MEAN
ELEMENT-ID GRID-ID NORMAL SHEAR PRINCIPAL -A-
-B- -C- PRESSURE VON MISES
0 1 0GRID CS 8 GP
0 CENTER X -1.799994E-10 XY 5.925950E-13 A 9.999992E+02 LX .00
.00-1.00 5.111842E-04 1.732051E+03

In this case we want line 264 of SEDRCVR. To obtain this line, we add the following
card to our input file, just before CEND.
compile sedrcvr list noref
The version 69 output follows, for the range of lines near line 264.
263 IF ( S1 >= 0 ) STRSORT OES1X,INDTA/OES1X1/NUMOUT/BIGER/
SRTOPT/SRTELTYP $ ELEMENT STRESS SORTING
264 OFP OES1X1,,,,,,
CSTMS,EHT,BGPDTVU,ERROR1,DEQATN,DEQIND,DIT//
S,N,CARDNO//PVALID $
265 ENDIF $ STATICS OR APP='REIG ' OR APP='TRANRESP'
266 $
We now see that the only block with a label starting with O is OES1X1. We will
TABPRT this block to determine that it is actually the block of interest.
236

To obtain the TABPRT output we modify our compile as follows


compile sedrcvr list noref
alter 263
TABPRT OES1X1/////2 $
CHAPTER A 237
MSC.Nastran Datablocks Tutorial

A.8 DBLOCATE and Restart


$
$ Print a datablock from version=1 data run
$
acquire nddl
dblocate datablk=*,param=*,where ( version=1 AND project=* AND wildcard)
sol userdmap
compile userdmap souin=mscsou
alter 2
type db GEOM1Q
dbdir $ look to make sure
dbview myname=GEOM1Q(where wildcard=true) $ Get any family member
tabprt myname,,,/////2 $ Print it
end

Caution: USERDMAP passes blocks as arguments. Using a tybe db with a similar name
will cause problems. A separate solution sequence that simply prints blocks
can be used. Here is one.
$
$ Define our own solution sequence just to print blocks.
$ As a convenience, route the print to a separate file.
$
acquire nddl
dblocate datablk=*,param=*,where ( version=1 AND project=* AND
wildcard)
Sol printer
compile printer
subdmap printer
type parm,,i,,outunit $ Controls the print location
type db GEOM1Q $ The block we want
dbview any=GEOM1Q(where wildcard=true) $ Get any family member
outunit=getsys(outunit,2) $ Get & save the output file #
putsys(52,2) $ Change output file to 52
tabprt any,,,,/////2 $ print the block
putsys(outunit,2) $ restore the output file
message //' Processed GEOM1Q '/ $
end
cend
238
MSC.Nastran Toolkit User’s Guide

APPENDIX
MSC.Nastran Database Features
B
240

Database Performance
The file access techniques used to process the MSC.Nastran databases are optimized
for each supported platform and allow the use of the most efficient techniques
available for the platform. For example,
• File mapping is available on Windows NT and several UNIX systems. When
file mapping is used, normal file read/write operation are replaced with
system paging operations. For many system, especially those that are not
memory constrained, this replaces synchronous read/write operation with
asynchronous paging operations, which may provide considerable
performance improvement.
• The EAG FFI0 interface is available on Cray UNICOS and SGI systems. This
interface allows for read-ahead and I/O operations.
• The NEC HPIO interface is available on NEC SuperUX systems. Like the
Cray EAG FFIO interface, this interface allows for read-ahead and I/O
operations.
• Support for large file format, >2gb (all platforms as of V70.7).
Efficiently Stores Keyed "Blobs" of Data (Datablocks)
• Keys provide the mechanism for uniquely defining and retrieving
datablocks from the MSC.Nastran database.
• Datablocks can be extremely large and can span multiple physical files.
• Two basic datablock types exist—matrices and tables.
Keys are User Definable for Each Datablock Name or Group of Datablock
Names
• Datablocks with the same attributes are chained together for faster access.
• Datablock retrieval is through SQL-like WHERE clause.
• Datablocks can be qualified by a list of Keys (both character and numeric
values), definable by the user, for each datablock in the database.

Datablock Equivalence Possible (Alias Names)


• More than one datablock name can point at the same data. The database only
deletes the data when all names pointing to the data have been deleted.

Data Definitions Can be Given for Each Datablock


• Various database schema API's exist for retrieving such items as the NDDL
descriptions to associate fields in the datablock with the data definition. The
data definition supplies the type and name to be associated with each field—
currently used for machine independent data transfer. (See MSC.Software's
Java-based data browser Toolkit application for an example of this.)
CHAPTER B 241
MSC.Nastran Database Features

The Database Can Consist of a Number of Physical Files


(See "Space Management Overview" diagram at the end of this appendix)
• The database consists of physical files which can be grouped together (into
DBSETS) for efficient storage and data management. You can have 200
DBSETS.
• A DBSET can consist of up to 20 physical files.
• A special DBSET called SCRATCH exists to store temporary data. It consists
of a RAM disk area and has an efficient high-water physical file control
feature.

A Datablock Can Span Physical Files


• A datablock must be contained within a DBSET, but can span the physical
files within the DBSET. Total size of a single datablock is 20 * 2G. (Note that
a 2G limit removed on all platforms as of V70.7.
• A datablock is not forced to be contiguous, though datablocks stored on new
databases will be contiguous. Fragmentation occurs only after deletions.
• The smallest unit of storage is a block. This size is set by the user and is
allowed to be different for each DBSET.

A Datablock Can be Written to Any DBSET


• DBSETS may be "on-line" or "off-line (not attached)". Only those datablocks
in the on-line DBSETS are available. Operations can be done on all on-line
DBSETS. Deletions can be done on all on-line or off-line DBSETS.

The Database Automatically Reuses Space After Deletions


• Highwater mark of the database only increases when all deleted blocks have
been written over.

A RAM Disk Area Can be Set Up for the SCRATCH DBSET


• Provides improved read/write performance.
• Size of the area is specified by the user.
• The RAM disk is first come/first serve. It is logically treated like a physical
file but is a memory area. A file can span between RAM and physical
memory.

Bufferpooling (Cache Area) is Available


• Bufferpool is a memory area used as a cache. It is first-in, first out.
• It can speed re-reading of data. Writing is done to both the bufferpool area
and the DBSET area (physical files).
• Size is set by the user.
242

Database Is Expandable After Initialization


• The database can be expanded by adding either new physical files to an
existing DBSET or by adding new DBSETS.

MASTER DBSET Keeps Track of All the Physical File Information Associated
With the Database—Allows Automated Assignment
• Automatic database reassignment possible.
• Automatic reattachment to the correct DBSET even when files have been
renamed.
• Automatic checks made making sure that the correct assignments have been
done when the user does manual assignments.

Some Database Fixup Capability Exists (Rarely Used)


• In the event of an error in the database entries the DBFIX utility will attempt
to correct the error.

Various I/O Features


• Read or write a number of words or an entire record of a datablock.
• Read or write only the non-zero terms from a matrix. Read or write an entire
column of matrix (zeros automatically removed/added to a column).
• Matrices contain non-zero terms only to save space (numeric values and
index information (columns/rows, strings) are kept in separate files and can
be retrieved separately—using associative file capability).
• Can skip records or files.
• Have direct positioning (filpos/savpos) capability.
Recent additions (since V70.7)
• Both IFP(e.g., EPT) and OFP (e.g., OES1) type tables can be indexed, allowing
for direct access data retrieval (i.e., direct ("keyed") access possible for a
specific subcase/record and individual element id./grid id.). Eventually all
datablocks will be indexed. Note: the indexes use the datablock associative
file capability which allows for multiple indexes.
See the MSC.Software's new Java-based Data Browser Toolkit application for
an example that uses these new indexed datablocks.
• New NDDL description retrieval API's allow database schema access.
CHAPTER B 243
MSC.Nastran Database Features

SPACE MANAGEMENT OVERVIEW

OSCAR RECORDS COMPILED DMAP

DBNAME TABLES
DBENTRY TABLE
PATH QUALIFIER TABLES
DATA BLOCK DESCR. MASTER DIRECTORY FILES
DEPENDENCY TABLES
DBSPC TABLE, etc. ...

ETC. ...

DBSET 1 DBSET 2 DBSET 3


1 1 1

FILE DBMAP 1 DBMAP 2 FILE DBMAP 3

DATABLOCK A 3 FILE DATABLOCK D 3 DATABLOCK F 3

DATABLOCK A 4 DATABLOCK D 4 FREE CLUSTER

FILE DATABLOCK B 5 FREE CLUSTER DATABLOCK F 5

FREE CLUSTER DATABLOCK E 6 DATABLOCK F


FILE
DATABLOCK C 7 DATABLOCK E 7 DATABLOCK F 7
FILE
FILE DATABLOCK A 8 DATABLOCK D 8 DATABLOCK G 8

FREE FREE FREE

Figure B-1

Note. Time stamp block is first physical block on each physical file.
244
MSC.Nastran Toolkit User’s Guide

APPENDIX
Java Language Bindings
C
■ This Appendix Contains the Java Interface descriptions for the
MSC.Nastran Toolkit API.

■ Executive System

■ Database
■ File I/O:

■ Table I/O:
■ Matrix I/O:

■ Direct Access I/O:


246

C.1 This Appendix Contains the Java Interface


descriptions for the MSC.Nastran Toolkit API.
The ability to call the native "C" language Toolkit API's using Java was accomplished
by using the Java Native Interface Application Programming Interface (API)--
Additional details on this process can be found in the Toolkit Code Librarian Help
System--see Toolkit.java. For the most part the Java methods described in this
document correspond one-to-one with the native Toolkit API's described in Chapter
8. The main difference between the C/Fortran API descriptions is the argument
passing method used by the Java interfaces. For example, instead of passing all
arguments through the API's argument calling list each of the Java methods has
arguments containing only input values and arrays-- all return values (primitives
only) are returned through a return object. Since arrays are passed by reference they
are updated directly by the Java Native interface code (i.e., updated in place).
Example call:
int [] record = new int[10000];
xxxxReturns yy= NServer_xxxx(GrpName,...record, other input variables and
arrays...);
If the record array is changed by NServer_xxxx it will be updated in place.
The yy object only contains the primitive return values for NServer_xxxx
(e.g., error = yy.error;
nwds = yy.nwds; )

Member Descriptions:
Each of the following member descriptions contains the following fields:

Purpose: A brief description of the purpose of this member can be found in the Toolkit
User's Guide.
Syntax: The syntactic declaration of this member.
Returns: The values returned by this member.
Example Usage: A reference to example code found in the Toolkit Code Librarian.
CHAPTER C 247
Java Language Bindings

C.2 Executive System


NServer_Start
Purpose: A brief description of the purpose of this member can be found in the Toolkit
User's Guide, NServer_Start – Start the MSC.Nastran Server (p. 38).

Syntax: public startReturns NServer_Start (String GrpName, String CommandLine,


String EvalPath)

Returns: return new startReturns (Error)


Example usage: See Example1.java

NServer_StartNoWait
Purpose: As an alternative to running the three startup Api's you can use NServer
StartNoWait which combines these calls -- it runs:

1. NServer_Start,
2. NServer_SolExe and
3. NServer_ColNStat
This works if you do not need to set a breakpoint via the NServer_SetExeBreak API
which must be called after the NServer_Start and before the NServer_SolExeN call. As
an alternative you can set breakpoints via the DMAP stmt.--> Halt //$. See Toolkit
User's Guide, Executive System APIs (Ch. 3).

Syntax: public startNoWaitReturns NServer_StartNoWait (String GrpName, String


CommandLine, String EvalPath)

Returns: return new startNoWaitReturns (Error)


Example usage: See Example1.java

NServer_SolExeN
Purpose: See Toolkit User's Guide, NServer_SolExeN – Execute the Current Solution
Sequence (p. 42).
Syntax: public solExeNReturns NServer_SolExeN (String GrpName)
Returns: return new solExeNReturns (Error)
Example Usage: See Example1.java
248

NServer_ColNStat
Purpose: See Toolkit User's Guide, NServer_ColNStat – Wait for the Completion of
a Prior NServer_SolExeN call (p. 43).
Syntax: public colNStatReturns NServer_ColNStat (String GrpName)
Returns: return new colNStatReturns (Error)
Example usage: See Example1.java

NServer_Exit
Purpose: See Toolkit User's Guide, NServer_Exit – Exit and Terminate the Server
(p. 45).
Syntax: public exitReturns NServer_Exit (String GrpName)
Returns: return new exitReturns (Error)
Example usage: See Example1.java

NServer_SetExeBreak
Purpose: See Toolkit User's Guide, NServer_SetExeBreak – Set a Break Point in the
DMAP Sequence (p. 46).
Syntax: public SetExeBreakReturns NServer_SetExeBreak (String GrpName, String
SubDmap, String Dmap, int Dmpseqnum, int InitFlag)

Returns: return new SetExeBreakReturns (Nbreak, Error)


Example usage: See Example1.java

NServer_ExeStatus
Purpose: See Toolkit User's Guide, NServer_ExeStatus – Return the status of the
Executing Dmap Sequence (p. 53).
Syntax: public ExeStatusReturns NServer_ExeStatus (String GrpName, int
WaitMode)

Returns: return new ExeStatusReturns (ExeStatus, SubDmap, Dmap, Dmpseqnum,


Ndatablk, Nparam, Error);

Example usage: See Example1.java


CHAPTER C 249
Java Language Bindings

NServer_GetMessage
Purpose: See Toolkit User's Guide, NServer_GetMessage – Get Error Messages
Generated by the MSC.Nastran Server (p. 61).

Note: This version is a prototype of a getMessage design that will eventually have the feature
of allowing automatic filtering of the error messages based on their severity (input
argument TypeError will be used to specify type of error to return).

This current implementation simply returns all error messages (unfiltered)--see


Example1.java

Syntax: public messagesReturns NServer_GetMessage


(String GrpName, String TypeError)

Returns: return new messagesReturns (messages, numberMessages)


Example usage: See Example1.java

NServer_Resume
Purpose: See Toolkit User's Guide, NServer_SolResumeN – Resume DMAP
Execution After Stopping by Nserver_SetExeBreak (p. 55).

Syntax: public ResumeReturns NServer_Resume(String GrpName)

Returns: return new ResumeReturns(Error)


Example Usage: See Example1.java

NServer_Input
Purpose: See Toolkit User's Guide, NServer_Input – Prepares a New Input File for
Execution by the Server (p. 56).
Syntax: public InputReturns NServer_Input (String GrpName, String DeckName)

Returns: return new InputReturns(Error)


Example Usage: See Example1.java

NServer_SetServerTimeout
Purpose: See Toolkit User's Guide, NServer_SetServerTimeout – Set a Time Limit
that the Server Will Wait in a "blocking" Mode for a Client Response (p. 65).
Syntax: public SetServerTimeoutReturns NServer_SetServerTimeout (String
GrpName, int Timeout)
Returns: return new SetServerTimeoutReturns (Error)
Example Usage: See Example1.java
250

NServer_SetClientTimeout
Purpose: See Toolkit User's Guide, NServer_SetClientTimeout – Set a Time Limit
that the Client Will Wait in a "blocking" Mode for a Server Response (p. 66).

Syntax: public SetClientTimeoutReturns NServer_SetClientTimeout(int Timeout)

Returns: return new SetClientTimeoutReturns(Error)


Example Usage: See Example1.java

NServer_SavEnv
Purpose: See Toolkit User's Guide, NServer_SavEnv – Save the Server’s IPC
Environmental Table for a Later Reconnection from Another Client Program (p. 68).

Syntax: public SavEnvReturns NServer_SavEnv(String GrpName,String EnvName )

Returns: return new SavEnvReturns(Error )


Example Usage: See Example1.java

NServer_Restart
Purpose: See Toolkit User's Guide, NServer_Restart – Restart the Server from
Another Client Program (p. 69).

Syntax: public RestartReturns NServer_Restart(String GrpName,String EnvName )


Returns: return new RestartReturns(Error )
Example Usage: See Example1.java

NServer_GetEnv
Purpose: See Toolkit User's Guide, NServer_GetEnv – Get MSC.Nastran Execution
Environment Resources (p. 76).
Syntax: public GetEnvReturns NServer_GetEnv(String NastPath,String
Attributes,byte[] AttNames,byte[] AttValues,byte[] AttSource )
Returns: return new GetEnvReturns(NumAttributes,Error )
Example Usage: See Example1.java

NServer_CheckToolkit
Purpose: See Toolkit User's Guide, NServer_CheckToolkit – Check the
Compatibility of the Toolkit Client and MSC.Nastran Server (p. 78).
Syntax: public CheckToolkitReturns NServer_CheckToolkit(String GrpName )
Returns: return new CheckToolkitReturns(Compatible,Error )
Example Usage: See Example1.java
CHAPTER C 251
Java Language Bindings

C.3 Database
NServer_Dbdict
Purpose: See Toolkit User's Guide, NServer_Dbdict – Find One or More Datablocks
and/or Parameters Based on Key Values (p. 86).

Syntax: public dbdictReturns NServer_Dbdict (String GrpName, String DbdictString,


byte [] DbdictOut,int MaxLen )

Returns: return new dbdictReturns (OutLen, Error)


Example: See Example1.java

NServer_AllocDatablk
Purpose: See Toolkit User's Guide, NServer_AllocDatablk – Allocate an Existing
MSC.Nastran Datablock (p. 84).

Syntax: public AllocDatablkReturns NServer_AllocDatablk(String GrpName, String


AllocString)

Returns: return new AllocDatablkReturns( Filept, Nmatch, Error)

Example usage: See Datablock.java

NServer_CreateDatablk
Purpose: See Toolkit User's Guide, NServer_CreateDatablk – Create a New
Datablock (table or matrix) (p. 85).
Syntax: public CreateDatablkReturns NServer_CreateDatablk(String GrpName,
String createString)

Returns: return new CreateDatablkReturns (Filept, FileStat, Error)


Example Usage: See Example1.java
252

C.4 File I/O:


NServer_OpenDatablk
Purpose: See Toolkit User's Guide, NServer_OpenDatablk – Open a Datablock
(matrix or table) (p. 123).

Syntax: public OpenDatablkReturns NServer_OpenDatablk(String GrpName, int


Filept, char R_or_W, char REW_NOREW)

Returns: return new OpenDatablkReturns(Error)


Example Usage: See Example1.java

NServer_GOpenDatablk
Purpose: See Toolkit User's Guide, NServer_GOpenDatablk – Open a Datablock
(table or matrix) (p. 124).
Syntax: public GOpenDatablkReturns NServer_GOpenDatablk(String GrpName, int
Filept, char R_or_W, char REW_NOREW)
Returns: return new GOpenDatablkReturns(f.Error)
Example Usage: See Example1.java

NServer_CloseDatablk
Purpose: See Toolkit User's Guide, NServer_CloseDatablk – Close a Datablock
(table or matrix) (p. 125).

Syntax: public CloseDatablkReturns NServer_CloseDatablk(String GrpName, int


Filept, char REW_NOREW)

Returns: return new CloseDatablkReturns(Error)


Example Usage: See Example1.java

NServer_PrelocDatablk
Purpose: See Toolkit User's Guide, NServer_PrelocDatablk – Prepare a Datablock to
be Accessed by NServer_LocateRecord (p. 126).

Syntax: public PrelocDatablkReturns NServer_PrelocDatablk(String GrpName , int


Filept)

Returns: return new PrelocDatablkReturns(Error)


Example Usage: See Example1.java
CHAPTER C 253
Java Language Bindings

NServer_LocateRecord
Purpose: See Toolkit User's Guide, NServer_LocateRecord – Position an IFP File to
the Requested Record (p. 129).

Syntax: public LocateRecordReturns NServer_LocateRecord(String GrpName,int


Filept,int[] Id )

Returns: return new LocateRecordReturns(Flag,Retno,Error )


Example Usage: See Example1.java

NServer_SkipRecord
Purpose: See Toolkit User's Guide, NServer_SkipRecord – Skip a Record (Table or
Matrix Column) (p. 130).

Syntax: public SkipRecordReturns NServer_SkipRecord(String GrpName,int


Filept,int Nrec )

Returns: return new SkipRecordReturns(Error )


Example Usage: See Example1.java

NServer_ReadTrailer
Purpose: See Toolkit User's Guide, NServer_ReadTrailer – Read a Datablock Trailer
Record (p. 131).
Syntax: public ReadTrailerReturns NServer_ReadTrailer(String GrpName,int
Filept,int[] Trailer )

Returns: return new ReadTrailerReturns(Error )


Example Usage: See Example1.java

NServer_ReadTrailerX
Purpose: See Toolkit User's Guide, NServer_ReadTrailerX – Read the Extended
Trailer of a Datablock (p. 132).

Syntax: public ReadTrailerXReturns NServer_ReadTrailerX(String GrpName,int


Filept,int[] TrailerX )

Returns: return new ReadTrailerXReturns(Error )


Example Usage: See Example1.java
254

NServer_MakeTrailer
Purpose: See Toolkit User's Guide, NServer_MakeTrailer – Make a Trailer Control
Block for a Matrix Datablock (p. 133).

Syntax: public MakeTrailerReturns NServer_MakeTrailer(String GrpName,int[]


Trailer,int Filept,int NumRow,int MatForm,int MatType )

Returns: return new MakeTrailerReturns(Error )


Example Usage: See Example1.java

NServer_WriteTrailer
Purpose: See Toolkit User's Guide, NServer_WriteTrailer – Write the Trailer of a
Datablock (p. 134).

Syntax: public WriteTrailerReturns NServer_WriteTrailer(String GrpName,int


Filept,int[] Trailer )

Returns: return new WriteTrailerReturns(Error )


Example Usage: See Example1.java

NServer_FilposRecord
Purpose: See Toolkit User's Guide, NServer_FilposRecord – Position the Record to a
Given Direct Access Index (p. 135).
Syntax: public FilposRecordReturns NServer_FilposRecord(String GrpName,int
Filept,int[] Filpos )

Returns: return new FilposRecordReturns(Error )


Example Usage: See Example1.java

NServer_SavposRecord
Purpose: See Toolkit User's Guide, NServer_SavposRecord – Save Direct Access
Index of the Current Record (p. 136).

Syntax: public SavposRecordReturns NServer_SavposRecord(String GrpName,int


Filept, int[] Filpos )

Returns: return new SavposRecordReturns(Error )


Example Usage: See Example1.java
CHAPTER C 255
Java Language Bindings

C.5 Table I/O:


NServer_ReadRecord
Purpose: See Toolkit User's Guide, NServer_ReadRecord – Read a Record from a
Datablock (table only) (p. 138).

Syntax: public ReadRecordReturns NServer_ReadRecord(String GrpName,int


Filept,int[] Record,int Nleng,int EOR )

Returns: return new ReadRecordReturns(EORret,NWread,Error )


Example Usage: See Example1.java

NServer_WriteRecord
Purpose: See Toolkit User's Guide, NServer_WriteRecord – Write a Record of a Table
Datablock (p. 140).
Syntax: public WriteRecordReturns NServer_WriteRecord(String GrpName,int
Filept,int[] Record,int Nleng,int EOR )
Returns: return new WriteRecordReturns(Error )
Example Usage: See Example1.java

NServer_AddRecTerm
Purpose: See Toolkit User's Guide, NServer_AddRecTerm – Add Term(s) of a Record
to a Table DataBlock (p. 143).

Syntax: public AddRecTermReturns NServer_AddRecTerm(String GrpName,int


Filept,String TermDescriptor,int NRepeat,int[] TermData,int Eor )

Returns: return new AddRecTermReturns(NTermGet,NWordGet,Error )


Example Usage: See Example1.java

NServer_GetRecTerm
Purpose: See Toolkit User's Guide, NServer_GetRecTerm – Get Terms of a Record
from a Table Datablock (p. 146).

Syntax: public GetRecTermReturns NServer_GetRecTerm(String GrpName,int


Filept,String TermDescriptor,int NRepeat,int[] TermData,int Eor )

Returns: return new GetRecTermReturns(NTermGet,NWordGet,Error )


Example Usage: See Example1.java
256

NServer_SizeofServerNDDLTerm
Purpose: See Toolkit User's Guide, NServer_SizeofServerNDDLTerm – Get Size of
NDDL Term (Server) (p. 149).

Syntax: public SizeofServerNDDLTermReturns


NServer_SizeofServerNDDLTerm(String GrpName,String NDDLTerm )

Returns: return new SizeofServerNDDLTermReturns(NintegerWord,Error )


Example Usage: See Example1.java

NServer_SizeofClientNDDLTerm
Purpose: See Toolkit User's Guide, NServer_SizeofClientNDDLTerm – Get Size of
NDDL Term (Client) (p. 151).

Syntax: public SizeofClientNDDLTermReturns


NServer_SizeofClientNDDLTerm(String NDDLTerm )

Returns: return new SizeofClientNDDLTermReturns(NintegerWord,Error )


Example Usage: See Example1.java
CHAPTER C 257
Java Language Bindings

C.6 Matrix I/O:


NServer_PackColumn
Purpose: See Toolkit User's Guide, NServer_PackColumn – Pack out a Matrix
Column (p. 154).

Syntax: public PackColumnReturns NServer_PackColumn(String GrpName,int


Filept,int[] ColCntl,int[] Trailer,double[] Column )

Returns: return new PackColumnReturns(Error )


Example Usage: See Example1.java

NServer_PackColumnI
Purpose: See Toolkit User's Guide, NServer_PackColumnI – Pack a Column Using a
Sparse Matrix Format (p. 168).
Syntax: public PackColumnIReturns NServer_PackColumnI(String GrpName,int
Filept,int[] PackCntl,int[] Trailer,double[] Column,int[] RowIdx,int IdxLen )
Returns: return new PackColumnIReturns(Error )
Example Usage: See Example1.java

NServer_PackNullColumn
Purpose: See Toolkit User's Guide, NServer_PackNullColumn – Pack out a Null
Column (p. 169).

Syntax: public PackNullColumnReturns NServer_PackNullColumn(String


GrpName,int Filept,int[] PackCntl,int[] Trailer,int NbrNull )

Returns: return new PackNullColumnReturns(Error )


Example Usage: See Example1.java

NServer_UnpackColumn
Purpose: See Toolkit User's Guide, NServer_UnpackColumn – Unpack a Matrix
Column (p. 170).

Syntax: public UnpackColumnReturns NServer_UnpackColumn(String GrpName,int


Filept,int[] UnpackCntl,double[] Column )

Returns: return new UnpackColumnReturns(ColStat,Error )


Example Usage: See Example1.java
258

NServer_UnpackColumnI
Purpose: See Toolkit User's Guide, NServer_UnpackColumnI – Unpack a Sparse
Matrix Column (p. 173).

Syntax: public UnpackColumnIReturns NServer_UnpackColumnI(String


GrpName,int Filept,int[] UnpackCntl,double[] Column,int[] RowIdx )

Returns: return new UnpackColumnIReturns(ColStat,RowStat,Error )


Example Usage: See Example1.java

NServer_UnpackRowIdx
Purpose: See Toolkit User's Guide, NServer_UnpackRowIdx – Unpack a Matrix Row
Index (p. 174).

Syntax: public UnpackRowIdxReturns NServer_UnpackRowIdx(String GrpName,int


Filept,int[] UnpackCntl,int[] RowIdx )

Returns: return new UnpackRowIdxReturns(RowStat,Error )


Example Usage: See Example1.java
CHAPTER C 259
Java Language Bindings

C.7 Direct Access I/O:


NServer_ReadGID
Purpose: See Toolkit User's Guide, NServer_ReadGID – Get Grid IDs (p. 177).

Syntax: public ReadGIDReturns NServer_ReadGID(String GrpName,int Filept, int


BeginEntry, int [] GIDRecord, int RecLeng)
Returns: return new ReadGIDReturns(GIDStat,MaxEntry,Error)
Example Usage: See Example1.java

NServer_ReadXYZ
Purpose: See Toolkit User's Guide, NServer_ReadXYZ – Get Grid Coordinates
(p. 178).

Syntax:publicReadXYZReturnsNServer_ReadXYZ(StringGrpName,intFilept,int[]
GIDRecord,double[] XYZRecord, int RecLeng)

Returns: return new ReadXYZReturns(OutLeng,XYZStat,Error )


Example Usage: See Example1.java

NServer_ReadIndexedIFP
Purpose: See Toolkit User's Guide, NServer_ReadIndexedIFP – Get IFP Data (p. 189).
Syntax: public ReadIndexedIFPReturns NServer_ReadIndexedIFP(String GrpName,
int Filept,int[]Record, int Reclen, int[] Ids, int Idwds,int LastId, int OP)

Returns: return new ReadIndexedIFPReturns( NWread, LastId, Iret, Error)


Example usage: See IFP.java (to be added)

NServer_ReadOFPSubindex
Purpose: See Toolkit User's Guide, NServer_ReadOFPSubindex – Get OFP
identification information (p. 206).

Syntax: public ReadOFPSubindexReturns NServer_ReadOFPSubindex(String


GrpName, int Filept,int[] Record, int Reclen)

Returns: return new ReadOFPSubindexReturns( NWread, Iret, Error)


Example usage: See OFP.java

NServer_ReadOFPLabel
Purpose: See Toolkit User's Guide, NServer_ReadOFPLabel – Get Title, Subtitle,
Label (p. 203).
260

Syntax: public ReadOFPLabelReturns NServer_ReadOFPLabel(String GrpName,int


Filept,String Select,int Subc,int[] Record,int Reclen )

Returns: return new ReadOFPLabelReturns(Nwds,Iret,Error )


Example Usage: See Example1.java

NServer_Select
Purpose: See Toolkit User's Guide, NServer_Select – Define a Filter for Datablock
Attributes Prior to Performing I/O Activities (p. 210).

Syntax: public SelectReturns NServer_Select(String GrpName,String Select,int


Tolerance )
Returns: return new SelectReturns(SelectId,Error )
Example Usage: See Example1.java

NServer_RemoveSelect
Purpose: See Toolkit User's Guide, NServer_RemoveSelect – Remove a Filter Set by
a Previous Call to NServer_Select (p. 209).

Syntax: public RemoveSelectReturns NServer_RemoveSelect(String GrpName,int


SelectId)

Returns: return new RemoveSelectReturns(Error )


Example Usage: See Example1.java

NServer_SortSelect
Purpose: See Toolkit User's Guide, NServer_SortSelect – Sort NServer_Select to User
Input Order or to Default Order (p. 219).
Syntax: public SortSelectReturns NServer_SortSelect(String GrpName,int SortCode )
Returns: return new SortSelectReturns(Error )
Example Usage: See Example1.java

NServer_ReadIFPKeys
Purpose: See Toolkit User's Guide, NServer_ReadIFPKeys – Get IFP Card IDs
(p. 188).

Syntax: public ReadIFPKeysReturns NServer_ReadIFPKeys(String GrpName, int


Filept,int offset,int[] Record,int Reclen)

Returns: return new ReadIFPKeysReturns( NWread, Iret, Error)


Example usage: See IFP.java (to be added)
CHAPTER C 261
Java Language Bindings

NServer_ReadOFPKeys
Purpose: See Toolkit User's Guide, NServer_ReadOFPKeys – Get OFP IDs (p. 201).

Syntax: public ReadOFPKeysReturns NServer_ReadOFPKeys(String GrpName, int


Filept, int Subc, int offset, int[] Record, int Reclen)

Returns: return new ReadOFPKeysReturns( NWread, Iret, Error)


Example usage: See OFP.java

NServer_ReadIndexedOFP
Purpose: See Toolkit User's Guide, NServer_ReadIndexedOFP – Get Results (p. 199).
Syntax: public ReadIndexedOFPReturns NServer_ReadIndexedOFP(String
GrpName, int Filept, int[]Record,int Reclen, int SubId, int[] Ids, int Idwds, int
LastId, int OP)

Returns: return new ReadIndexedOFPReturns( NWread, LastId, Iret, Error)


Example usage: See OFP.java

NServer_NDDLDesc
Purpose: See Toolkit User's Guide, NServer_NDDLDesc – Get NDDL Labels and
Types (p. 195).

Syntax: public NDDLDescReturns NServer_NDDLDesc(String GrpName, String


BlkName, String glbstr, int [] glbnum, int lglbnum, byte[] DbdictOut, int llabel,
int [] type, int ltype)

Returns: return new NDDLDescReturns( Blktype, Nlabel, Ntype, Iret)


Example usage: See NDDLDesc.java--see also NServer_OFPDesc.

NServer_OFPDesc
Purpose: See Toolkit User's Guide, NServer_OFPDesc – Get NDDL Labels and
Types (p. 198).

Syntax: public NDDLDescReturns NServer_OFPDesc(String GrpName, String


BlkName, int [] subindex, byte[] DbdictOut,int llabel, int [] type, int ltype)

Returns: return new NDDLDescReturns( Blktype, Nlabel, Ntype, Iret)


Example usage: Currently only an example for NServer_NDDLDesc exists.
NServer_NDDLDesc returns data definition information (i.e., types and labels) for a
particular datablock entry for either OFP type tables (e.g., a hexa stress output entry
or for IFP type tables (e.g, grid card entry or property card entry). NServer_OFPDesc
was specifically designed for OFP type datablocks and simplifies the calling argument
compared to NServer_NDDLDesc by only requiring a "pointer" to the (subindex)
262

array. This (subindex) pointer is returned from the NServer_ReadIndexedOFP API


along with every results entry that is returned (i.e., if element 1001 (hexa) and 110011
(quad4) from subcase 1 are requested each of the returned results data for each
element will be preceded by a subindex "pointer" that can then be used by
NServer_OFPDesc to get the corresponding type (e.g., integer, real, character) and
label information (sx, sy, sxy...) for these two element's results data.
MSC.Nastran Toolkit User’s Guide

APPENDIX
List of API Error Codes
D
264

Error Number Description


0 No Error Encountered
1 Bad Parameter passed
2 Bad Data Record passed
3 Data Truncated
4 Memory Limit exceeded
5 Duplicate Definition
6 No Such Group defined
7 No Such Entity defined
8 No Such Evaluator Class
9 INTERNAL ERROR
10 Operating System Error
11 Error Message Unavailable
12 Too many Errors
13 Error Store Full
14 No Configuration Information
15 External IPC Communication
16 Numerical Error in Evaluator
17 Point not close enough
18 Ambiguous Variable Definition
19 Invalid Variable Definition
20 Evaluator Specific Error
21 Connect to External Evaluator
22 Connection Timed out
23 Server Probably Crashed
24 No bulk Data file found
25 MSC.Nastran Startup Script Message
26 Could not Start MSC.Nastran Server
CHAPTER D 265
List of API Error Codes

Error Number Description


27 Binary Incompatible Hosts
28 MSC.Nastran Server Message
266
MSC.Nastran Toolkit User’s Guide

APPENDIX
Toolkit Compile and Link Instructions
E
■ Makefiles
268

E.1 Makefiles
The following are some sample Makefiles.

Notes: 1. The CD containing the MSC.Nastran/Toolkit installation includes a Toolkit


Makefile that is configured to compile/link two example Toolkit programs
(C and FORTRAN).
2. The client program must be linked with MSC.Nastran's Toolkit libclient
object library.

HP
# Makefile for Nastran Toolkit Applications
# Replace "client" by the appropriate name
# ---------------------------------------------

# Compiler Definition

F77=f77 -c -a +U77 +ppu


LD =f77 +U77

# Path to libclient.a

toolkit = <user_defined_path>/libclient.a

# Makes

client: client.o $(toolkit)


$(LD) client.o $(toolkit) -o client

# Compilations

client.o : client.f ; $(F77) client.f


Make sure libU77.a exists in directory /usr/lib. This library can be found in directory
/opt/fortran/lib. and contains the Unix extensions of FORTRAN.
CHAPTER E 269
Toolkit Compile and Link Instructions

SGI
# Makefile for Nastran Toolkit Applications
# Replace "client" by the appropriate name
# ---------------------------------------------

# Compiler Definition

F77=f77 -c -O2 -mips2 -G0 -KPIC


LD =f77 -O2 -mips2 -G0 -KPIC

# Path to libclient.a

toolkit = <user_defined_path>/libclient.a

# Makes

client: client.o $(toolkit)


$(LD) client.o $(toolkit) -o client

# Compilations

client.o : client.f ; $(F77) client.f


270
MSC.Nastran Toolkit User’s Guide

APPENDIX
Utility Functions
F
272

The following utility functions were referenced by various code examples within this
User's Guide.

GetArgument
Purpose. A C function that will parse a programs argument list and return the three
required inputs to invoke the Nastran server:

Usage. Assume the example1c is invoked as follows:


./example1c nast707 test.dat scr=mini mem=10m out=example1c

A call to GetArgument within example1c.c will parse the above line and return the
following three character strings:
1. Group Name ("example1c"),
2. Nastran Command program location ("nast707"),
3. Nastran input file (bdf) and Nastran keywords ("test.dat
scr=mini,mem=10m out=example1c")

OpenLogFile
Purpose. A C function that will open a log file to write various information
generated by the Toolkit client program.

Usage. Assume the example1c is invoked as follows:


./example1c nast707 test.dat scr=mini mem=10m out=example1c

An output file will be opened for "write" access with the name
Example1c.prt

PrintMessage
Purpose. A C function that will call the Toolkit API Nserver_GetMessage to retrieve
all MSC.Nastran generated error/warning/information messages, including Toolkit
related client-server related errors. The output is formatted using 80 character output
lines. The client/server related error message numbers are described in List of API
Error Codes (App. D).
CHAPTER F 273
Utility Functions

Void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[])
{
int i;

if( argc == 2 ) {
(void) fprintf(LOGFILE," Run : %s NASTRAN_Program_script "
"list_of_NASTRAN_Program_script_args\n",argv[0]);
(void) fprintf(LOGFILE," Program exits due to missing argument(s).\n");
exit(1);
} else {
strcpy( GrpName, argv[0] );
strcpy( NastPath, argv[1] );
strcpy( CommandLine, argv[2] );
for( i=3 ; i < argc ; i++ ) {
strcat( CommandLine, " " );
strcat( CommandLine, argv[i] );
}
}
}

void OpenLogFile( char *CommandLine )


{

/*
* Purpose: Open the Client's log file
* The name of the log file will be jobid
* adds the suffix .prt
* Example job demo200g, logfile name will be demo200g.out
*/
int I;
char *p;
char logname[256];

if( (p = strstr( CommandLine ,"out=") ) ) {


p+=4;
}
else if( (p = strstr( CommandLine ,"OUT=") ) ) {
p+=4;
}
else if( (p = strstr( CommandLine ,"jid=") ) ) {
p+=4;
}
else if( (p = strstr( CommandLine ,"JID=") ) ) {
p+=4;
}
else {
p = CommandLine;
}

for( I=0 ; i< 256 && p ; i++ ) {


logname[i] = p[i];
if( logname[i] == ' ')
break;
}
274

logname[i] = '\0';
strcat( logname,".prt");
fprintf(LOGFILE," Toolkit Output file %s\n",logname);

LOGFILE = fopen ( logname, "w" );


if ( LOGFILE== NULL )
LOGFILE = stderr;

void PrintMessage (char *GrpName, FILE *fp, char *ApiName)


{

/*
* Purpose: Driver to call NServer_GetMessage
* and print out messages from the server
*/

INTEGER lenmsg = 801;


char fmsg[801];
INTEGER Status = 0;
int i;

if( fp == NULL )
return;

if( ApiName )
fprintf (fp, "\n\n >>> API Name: %s\n",ApiName);
fprintf (fp, " >>> Receiving Mesages from NASTRAN Server ...\n\n");

while (1) {
(void) NServer_GetMessage (GrpName, lenmsg, fmsg, &Status);

if (Status == NASAPI_ERROR_NO_MORE_MESSAGES )
break;

else if (Status == NASAPI_ERROR_MESSAGE_TRUNCATED) {


fprintf (fp, " >>> The Error Messages is Longer than \"lenmsg\"
Characters.\n",lenmsg);
fprintf (fp, " >>> The Error Message may be Truncated.\n");
}

for (i = 0; i < lenmsg/80; i++)


fprintf (fp, " %.80s\n", &fmsg[i * 80]);
fflush (fp);
}

}
MSC.Nastran Toolkit User’s Guide

APPENDIX
Example Toolkit Client Applications
G
■ Toolkit Code Librarian
276

7.1 Toolkit Code Librarian


The source code for a wide variety of Toolkit example programs is available in the
"Toolkit Code Librarian", a Help system that is provided on the Toolkit Delivery CD.
Example programs include complete C, Fortran and Java Toolkit applications
covering a wide range of Toolkit functionality.
MSC.Nastran Toolkit User’s Guide

APPENDIX
Subindex Description
H
■ Appendix H: Subindex Description
278

H.1 Appendix H: Subindex Description


The 16 word Subindx information returned by NServer_ReadOFPSubIndex() is
described in the following table. These descriptions apply for most OFP tables (see
Note 1).

Position
Subindex in the
Description Notes
Word OFP ID
Record
1-2 Filpos Pointer to the Id Direct Access pointer for future
Record use.
3 3 Element Type (e.g., See "MSC.Nastran Datablock
67=Hexa, 34=Bar) and DMAP Module's"
Document for description of all
Element Types
4 4 Subcase Number
5-7 5-7 The content of these 3 words This is additional Subcase
varies based on Word 9 of identification information.
the Subindx data (i.e, (see note 3)
Approach code)
8 10 Number or Words/Entry See Note 2.
9 1 Approach Code & Device See Toolkit User's Guide,
Code Appendix A
10 23 Thermal Code (1=thermal,
0= no thermal)
11 2 Table Code(stress, force...) & See Toolkit User's Guide,
Format Code (sort1 or sort2) Appendix A
12 11 SCODE (stress or strain…) See Toolkit User's Guide,
Appendix A
13 13 Acoustic Flag Acoustic
14 Number of Entries (Keys)
for this Subcase. (e.g., for
sort1 stress tables this is the
number of element ids in
this Subcase).
15-16 Filpos to the Element Index Direct Access pointer for future
for this Subcase. use.
CHAPTER H 279
Subindex Description

Notes:
1. The above descriptions apply to most OFP tables (e.g., Force, Stress, Strain,
Displacements, Accelerations, Velocity). However, there are exceptions to
the meaning of the above words (3, 4,5, 6 and 7) for some tables (e.g., element
strain energy). In these cases you should refer to the ID record descriptions
as documented the MSC.Nastran "MSC.Nastran Datablock and DMAP
Module's" document.
2. The number of words/entry will be modified based on use the
NServer_Select (i.e., if a subset of the results output is "selected" then this will
be reflected in Word 8 of the above Subindex information.
3. Utility, DSINDX.f, is available in the "Toolkit Code Librarian" help system
for parsing and labeling the above information. For example, sort2
Datablocks have the element ID stored in word 5 of the Subindex.
4. The above values are integer type values with the exception of words 5-7.
280
I N D E X
MSC.Nastran Toolkit User’s Guide

D Direct Access I/O


NServer_NDDLDesc, 195
Database NServer_NDDLDesc (Java), 261
NServer_AllocDatablk, 84 NServer_OFPDesc, 198
NServer_AllocDatablk (Java), 251 NServer_OFPDesc (Java), 261
NServer_CreateDatablk, 85 NServer_ReadGID, 177
NServer_CreateDatablk (Java), 251 NServer_ReadGID (Java), 259
NServer_Dbdict, 86 NServer_ReadIFPKeys, 188
NServer_Dbdict (Java), 251 NServer_ReadIFPKeys (Java), 260
NServer_FMSCommand, 88 NServer_ReadIndexedIFP, 189
NServer_FreeDbdictHandle, 87 NServer_ReadIndexedIFP (Java), 259
NServer_GetDatablock, 89 NServer_ReadIndexedOFP, 199
NServer_GetDatablockForKey, 91 NServer_ReadIndexedOFP (Java), 261
NServer_GetDatablockForPathName, 93 NServer_ReadOFPKeys, 201
NServer_GetDatablockForPathPtr, 95 NServer_ReadOFPKeys (Java), 261
NServer_GetDatablockKeys, 97 NServer_ReadOFPLabel, 203
NServer_GetDatablockPathName, 98 NServer_ReadOFPLabel (Java), 259
NServer_GetDatablockPathPtr, 99 NServer_ReadOFPSubindex, 206
NServer_GetDbdictHandle, 100 NServer_ReadOFPSubindex (Java), 259
NServer_GetDbdictLabel, 101 NServer_ReadXYZ, 178
NServer_GetDbdictTypes, 102 NServer_ReadXYZ (Java), 259
NServer_GetDbdictValues, 103 NServer_RemoveSelect, 209
NServer_GetKeyPathName, 104 NServer_RemoveSelect (Java), 260
NServer_GetKeyPathPtr, 105 NServer_Select, 210
NServer_GetKeyQualifiers, 106 NServer_Select (Java), 260
NServer_GetPathNameKeys, 108 NServer_SortSelect, 219
NServer_GetPathNameQualifierDefault NServer_SortSelect (Java), 260
s, 114
NServer_GetPathNameQualifiers, 110
NServer_GetPathPtrKeys, 109
NServer_GetPathPtrQualifierDefaults,
116
NServer_GetPathPtrQualifiers, 112
282 INDEX

E F
Executive system File I/O
NServer_CheckToolkit, 78 NServer_CloseDatablk, 125
NServer_CheckToolkit (Java), 250 NServer_CloseDatablk (Java), 252
NServer_ColNStat, 43 NServer_FilposRecord, 135
NServer_ColNStat (Java), 248 NServer_FilposRecord (Java), 254
NServer_Evals, 44 NServer_GOpenDatablk, 124
NServer_ExeStatus, 53 NServer_GOpenDatablk (Java), 252
NServer_ExeStatus (Java), 248 NServer_LocateRecord, 129
NServer_Exit, 45 NServer_LocateRecord (Java), 253
NServer_Exit (Java), 248 NServer_MakeTrailer, 133
NServer_GetEnv, 76 NServer_MakeTrailer (Java), 254
NServer_GetEnv (Java), 250 NServer_OpenDatablk, 123
NServer_GetMessage, 61 NServer_OpenDatablk (Java), 252
NServer_GetMessage (Java), 249 NServer_PrelocDatablk, 126
NServer_Input, 56 NServer_PrelocDatablk (Java), 252
NServer_Input (Java), 249 NServer_ReadTrailer, 131
NServer_Restart, 69 NServer_ReadTrailer (Java), 253
NServer_Restart (Java), 250 NServer_ReadTrailerX, 132
NServer_Resume (Java), 249 NServer_ReadTrailerX (Java), 253
NServer_SavEnv, 68 NServer_SavposRecord, 136
NServer_SavEnv (Java), 250 NServer_SavposRecord (Java), 254
NServer_SetClientTimeout, 66 NServer_SkipRecord, 130
NServer_SetClientTimeout (Java), 250 NServer_SkipRecord (Java), 253
NServer_SetExeBreak, 46 NServer_WriteTrailer, 134
NServer_SetExeBreak (Java), 248 NServer_WriteTrailer (Java), 254
NServer_SetServerTimeout, 65
NServer_SetServerTimeout (Java), 249
NServer_SolExeN, 42 M
NServer_SolExeN (Java), 247 Matrix I/O
NServer_SolResumeN, 55 NServer_PackColumn, 154
NServer_Start, 38 NServer_PackColumn (Java), 257
NServer_Start (Java), 247 NServer_PackColumnI, 168
NServer_StartNoWait (Java), 247 NServer_PackColumnI (Java), 257
NServer_PackNullColumn, 169
NServer_PackNullColumn (Java), 257
NServer_UnpackColumn, 170
NServer_UnpackColumn (Java), 257
NServer_UnpackColumnI, 173
NServer_UnpackColumnI (Java), 258
NServer_UnpackRowIdx, 174
NServer_UnpackRowIdx (Java), 258
INDEX 283

N NServer_MakeTrailer, 133
NServer_MakeTrailer (Java), 254
NSALLDB, 84 NServer_MessageFilter, 63
NSARTER, 143 NServer_NDDLDesc, 195
NSBREAK, 46 NServer_NDDLDesc (Java), 261
NSCHKTK, 78 NServer_OFPDesc, 198
NSCLSDB, 125 NServer_OFPDesc (Java), 261
NSCLTMO, 66 NServer_OpenDatablk, 123
NSCRTDB, 85 NServer_OpenDatablk (Java), 252
NSDBDIC, 86 NServer_PackColumn, 154
NSENV, 76 NServer_PackColumn (Java), 257
NServer_AddRecTerm, 143 NServer_PackColumnI, 168
NServer_AddRecTerm (Java), 255 NServer_PackColumnI (Java), 257
NServer_AllocDatablk, 84 NServer_PackNullColumn, 169
NServer_AllocDatablk (Java), 251 NServer_PackNullColumn (Java), 257
NServer_CheckToolkit, 78 NServer_PrelocDatablk, 126
NServer_CheckToolkit (Java), 250 NServer_PrelocDatablk (Java), 252
NServer_CloseDatablk, 125 NServer_ReadGID, 177
NServer_CloseDatablk (Java), 252 NServer_ReadGID (Java), 259
NServer_ColNStat, 43 NServer_ReadIFPKeys, 188
NServer_ColNStat (Java), 248 NServer_ReadIFPKeys (Java), 260
NServer_CreateDatablk, 85 NServer_ReadIndexedIFP, 189
NServer_CreateDatablk (Java), 251 NServer_ReadIndexedIFP (Java), 259
NServer_Dbdict, 86 NServer_ReadIndexedOFP, 199
NServer_Dbdict (Java), 251 NServer_ReadIndexedOFP (Java), 261
NServer_ExeStatus, 53 NServer_ReadOFPKeys, 201
NServer_ExeStatus (Java), 248 NServer_ReadOFPKeys (Java), 261
NServer_Exit, 45 NServer_ReadOFPLabel, 203
NServer_Exit (Java), 248 NServer_ReadOFPLabel (Java), 259
NServer_FilposRecord, 135 NServer_ReadOFPLabelC, 205
NServer_FilposRecord (Java), 254 NServer_ReadOFPSubindex, 206
NServer_GetAllMessages, 62 NServer_ReadOFPSubindex (Java), 259
NServer_GetDatablock, 89 NServer_ReadOFPSubindexEntry, 208
NServer_GetEnv, 76 NServer_ReadRecord, 138
NServer_GetEnv (Java), 250 NServer_ReadRecord (Java), 255
NServer_GetMessage, 61 NServer_ReadTrailer, 131
NServer_GetMessage (Java), 249 NServer_ReadTrailer (Java), 253
NServer_GetRecTerm, 146 NServer_ReadTrailerX, 132
NServer_GetRecTerm (Java), 255 NServer_ReadTrailerX (Java), 253
NServer_GetSelect, 194 NServer_ReadXYZ, 178
NServer_GOpenDatablk, 124 NServer_ReadXYZ (Java), 259
NServer_GOpenDatablk (Java), 252 NServer_RemoveSelect, 209
NServer_Input, 56 NServer_RemoveSelect (Java), 260
NServer_Input (Java), 249 NServer_Restart, 69
NServer_LocateRecord, 129 NServer_Restart (Java), 250
NServer_LocateRecord (Java), 253
284 INDEX

NServer_Resume (Java), 249 NSINPUT, 56


NServer_SavEnv, 68 NSLOCAT, 129
NServer_SavEnv (Java), 250 NSMKTRL, 133
NServer_SavposRecord, 136 NSNDDLD, 195
NServer_SavposRecord (Java), 254 NSNSTAT, 43
NServer_Select, 210 NSOFPDE, 198
NServer_Select (Java), 260 NSOPNDB, 123
NServer_SelectOFP, 213 NSPAKCI, 168
NServer_SetClientTimeout, 66 NSPAKCL, 154
NServer_SetClientTimeout (Java), 250 NSPCKNU, 169
NServer_SetExeBreak, 46 NSPRELO, 126
NServer_SetExeBreak (Java), 248 NSRDTRL, 131
NServer_SetSelectGroup, 218 NSRDTRX, 132
NServer_SetServerTimeout, 65 NSREADR, 138
NServer_SetServerTimeout (Java), 249 NSRESTA, 69
NServer_SizeofClientNDDLTerm, 151 NSRESUM, 55
NServer_SizeofClientNDDLTerm (Java), NSRGID, 177
256 NSRIIFP, 189
NServer_SizeofServerNDDLTerm, 149 NSRIKYS, 188
NServer_SizeofServerNDDLTerm (Java), NSRIOFP, 199
256 NSRMSEL, 209
NServer_SkipRecord, 130 NSROFPL, 203
NServer_SkipRecord (Java), 253 NSROKYS, 201
NServer_SolExeN, 42 NSROSUB, 206
NServer_SolExeN (Java), 247 NSRXYZ, 178
NServer_SolResumeN, 55 NSSAVEN, 68
NServer_SortSelect, 219 NSSELCT, 210
NServer_SortSelect (Java), 260 NSSEXIT, 45
NServer_Start, 38 NSSKIPR, 130
NServer_Start (Java), 247 NSSOLEX, 42
NServer_StartNoWait (Java), 247 NSSOSEL, 219
NServer_UnpackColumn, 170 NSSRTMO, 65
NServer_UnpackColumn (Java), 257 NSSTART, 38
NServer_UnpackColumnI, 173 NSSVPOS, 136
NServer_UnpackColumnI (Java), 258 NSSZNDL, 149
NServer_UnpackRowIdx, 174 NSUNPKC, 170
NServer_UnpackRowIdx (Java), 258 NSUNPKI, 173
NServer_WriteRecord, 140 NSUNPKX, 174
NServer_WriteRecord (Java), 255 NSWRITE, 140
NServer_WriteTrailer, 134 NSWRTRL, 134
NServer_WriteTrailer (Java), 254 NSZCNDL, 151
NSEXSTA, 53
NSFILPS, 135
NSGETMS, 61
NSGPNDB, 124
NSGRTER, 146
INDEX 285

T
Table I/O
NServer_AddRecTerm, 143
NServer_AddRecTerm (Java), 255
NServer_GetRecTerm, 146
NServer_GetRecTerm (Java), 255
NServer_ReadRecord, 138
NServer_ReadRecord (Java), 255
NServer_SizeofClientNDDLTerm, 151
NServer_SizeofClientNDDLTerm (Java),
256
NServer_SizeofServerNDDLTerm, 149
NServer_SizeofServerNDDLTerm
(Java), 256
NServer_WriteRecord, 140
NServer_WriteRecord (Java), 255

Potrebbero piacerti anche