Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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
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
■ Internet Resources
■ Permission to Copy and Distribute MSC Documentation
vi
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
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:
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.
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
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.
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.
Name: ____________________________________________________________
Title: ______________________________________________________________
Company: _________________________________________________________
Address: __________________________________________________________
__________________________________________________________________
Telephone:_________________Email: __________________________________
Signature:______________________________ Date:______________________
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
Bulk Data
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
Or Others…
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
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
API
DMAP IFP1
TCP/IP SDR2
protocol
(pipes/sockets)
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
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
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.
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.
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.
int NServer_xxxx
For Fortran:
Call NSxxxx (GrpName, ...arguments..., Error)
For Java:
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
■ 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
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.
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
/*
* 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"
void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);
INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;
INTEGER Filept=0,Nmatch=0,Trailer[7];
int i=0;
/************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
************************************************************************
*/
/************************************************************************
*
* Step 2: Initilize the server
*
************************************************************************
*/
(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);
if( Error ) {
strcpy( ApiName,"Nserver_Start");
goto EXIT;
}
/***********************************************************************
*
* Step 3: Start Execution of solution (non-wait mode)
*
***********************************************************************
*/
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);
/**********************************************************************
*
* Step 5: EXIT and terminate the server
*
**********************************************************************
*/
EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );
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.
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.
int NServer_Evals
Dbview flag:
= 0 : Dbview will not be inherited from previous execution
state.
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
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.
Arguments.
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"
void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);
char DbdictOut[40000];
INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;
INTEGER Filept=0,Nmatch=0,Trailer[7];
int i=0;
/*******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
* *******************************************************************************
*/
/*********************************************************************
*
* Step 2: Initialize the server
*
*********************************************************************
*/
(void) NServer_Start ( 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
if( Error ) {
strcpy( ApiName,"NServer_SetExeBreak");
goto EXIT;
}
/*********************************************************
*
* Step 4: Execution of solution in non-blocking mode
*
*********************************************************
*/
if( Error ) {
strcpy( ApiName,"NServer_SolExeN");
goto EXIT;
}
/*************************************************************
*
* Step 5: Check for DMAP breakpoints or until DMAP EXIT
*
*************************************************************
*/
WaitMode = 0;
/*****************************************************************
*
* Step 5.a: Get the Dmap Execution status after the breakpoint
*
*****************************************************************
*/
(void) NServer_ExeStatus(GrpName, WaitMode, &ExeStatus, SubDmap , Dmap,
&Dmpseqnum, &Ndatablk,&Nparam, &Error);
/**************************************************************
*
* Step 5.b: Get out of "for loop" at the "EXIT" DMAP statement
*
**************************************************************
*/
if( !strncmp(Dmap,"EXIT",4) || Error ) break;
/******************************************************************************
*
* Step 5c: Resume DMAP execution after the breakpoint and loop back for the *
next break point (note: breakpoint after "IFPL" will be "EXIT").
*****************************************************************************
/
if( Error ) {
strcpy( ApiName,"NServer_SolResumeN");
goto EXIT;
}
/******************************************
*
* Step 6: EXIT and terminate the server
*
*****************************************
*/
EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );
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
Arguments.
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.
Arguments.
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.
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"
char GrpName[32];
char NastPath[1024];
char CommandLine[1024];
/************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
************************************************************************
*/
nloop++;
/************************************************************************
*
* Step 2: Initilize the server
*
************************************************************************
*/
if( loop == 0) {
if( Error ) {
strcpy( ApiName,"Nserver_Start");
goto EXIT;
} else {
/************************************************************************
*
* Step 3: Submit the next input file to be executed by MSC.Nastran
*
************************************************************************
*/
"\n **********"
"\n **********"
"\n **********"
"\n **********\n",
DeckName[loop-1]);
fgetc(stdin);
/***********************************************************************
*
* Step 4: Start Execution of solution (non-wait mode)
*
***********************************************************************
*/
60
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);
/**********************************************************************
*
* Step 6: EXIT and terminate the server
*
**********************************************************************
*/
EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );
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
int Nserver_GetAllMessages
Purpose. Retrieve all messages generated by the MSC.Nastran server program and
concatenate them into one string.
Arguments.
int Nserver_MessageFilter
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
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.
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.
/* Note: This is only a code "snippet"--the complete source can be found in the
MSC.Nastran Code Librarian Help System. */
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);
if( Error ){
(void) fprintf(fp, "Error in NServer_SolExeN error = %d\n", Error);
goto exit;
}
if( 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
Arguments.
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
Arguments.
Application Notes.
This API must only be used in a child process after NServer_SavEnv (NSSAVEN) has
been called in the parent process.
/*
* 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);
char GrpName[257];
char NastPath[1025];
char CommandLine[1025];
char *EnvName;
/*******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
* and then open a LogFile to write example1c output.
*
* *******************************************************************************
*/
/*********************************************************************
*
* Step 2: Initialize the server
*
*********************************************************************
*/
if( Error ) {
strcpy( ApiName,"Start");
goto EXIT;
}
/*
* (2a) Set the solution breakpoints prior to executing DMAP
*/
Dmap[0] = '\0';
InitFlag = 1;
/*
* (4) Prepare for for the execution of the second Client program NSrecon
*/
EnvName = GrpName;
/*
* (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);
/*
* (5b) Submit the second program NSrecon to reconnect the NASTRAN server
*/
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 );
}
/* 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"
* 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
*/
/*
* (2) Re-connect to the NASTRAN server
*/
(void) fprintf(stderr," Call NServer_Restart for Group=%s\n"
" EnvName=%s\n",
GrpName,EnvName);
/*
CHAPTER 3 75
Executive System APIs
* (3) DBDICT
* (output from DBDICT function the same as standard MSC.Nastran DBDICT output)
*/
EXIT:
Return (int) Error;
}
76
Arguments.
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.
INTEGER Error = 0;
INTEGER num = 0;
int i = 0;
char key[ 800 ], value[ 800 ], src[ 800 ];
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.
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.
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
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
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
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.
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
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.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
86
Purpose. To find one or more datablocks and/or parameters based on Key values—
functionally the same as the FMS statement DBDICT.
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
int NServer_FreeDbdictHandle
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
int NServer_FMSCommand
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:
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).
Arguments
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 91
Database Features and APIs
Arguments
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 93
Database Features and APIs
Purpose. To return all datablocks defined given the supplied Path Name
Arguments.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 95
Database Features and APIs
Purpose. To return all datablocks defined given the supplied Path Name
Arguments
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
Purpose. To return the KEY values associated with the requested datablock family.
Arguments.
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
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
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 99
Database Features and APIs
Arguments
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
int NServer_GetDbdictHandle
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
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 101
Database Features and APIs
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
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
Purpose. To return the next logical value, its type, and length, as delimited by
Delimiter.
Arguments.
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
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
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
CHAPTER 4 105
Database Features and APIs
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
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
106
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
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
108
Purpose. To return all specific KEY values associated with a given Path Name.
Arguments.
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
Purpose. To return all specific KEY values associated with a given Path Pointer.
Arguments.
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
Purpose. To return the qualifier names associated with a given Path Name.
Arguments.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
112
Purpose. To return the qualifier names associated with a given Path Pointer.
Arguments.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
114
Purpose. To return the qualifier names associated with a given Path Name.
Arguments.
Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help system.
116
Purpose. To return the qualifier names associated with a given Path Pointer.
Arguments.
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
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).
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
Purpose. Interface call to open a Datablock File from MSC.Nastran database, for
read or write.
Arguments.
Arguments.
Arguments.
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
Arguments.
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
Arguments.
Purpose. Interface call that will return both the standard 7 word matrix trailer (see
NServer_ReadTrailer) and the 7 word matrix trailer extension.
Arguments.
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.
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
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
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
int NServer_ReadRecord
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
int NServer_WriteRecord
Arguments.
int i,Filept,FileStat,Error;
/*
* Create a datablock to output data
*/
(void) NServer_CreateDatablk ( GrpName , CreateString , &Filept , &FileStat ,&Error
);
/*
* Open datablock to write
*/
(void) NServer_GOpenDatablk( GrpName , Filept , 'W' , 'Y' , &Error );
/*
* Write to datablock
*/
/*
* 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 );
}
CHAPTER 6 143
Table I/O APIs
int NServer_AddRecTerm
Arguments.
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.
int NServer_GetRecTerm
Arguments.
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.
int NServer_SizeofServerNDDLTerm
Arguments.
int NServer_SizeofClientNDDLTerm
Arguments.
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
int NServer_PackColumn
Arguments.
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
/*
* Program Example3c.c
*
* Purpose:
* (void) NServer_Start
* (void) NServer_UnpackColumn
* (void) NServer_WriteTrailer
*
#include <stdio.h>
#include <string.h>
#include "nsapilib.h"
void GetArgument( char *GrpName, char *NastPath, char *CommandLine, int argc, char *argv[]);
void DumpMatrix( char *GrpName, char *AllocStr , INTEGER *Filept, INTEGER *Error );
void PackMatrix( char *GrpName, char *CreateString, INTEGER *Filept, INTEGER PackOption,
INTEGER *Error );
char DbdictOut[40000];
INTEGER Error=0;
INTEGER OutLen=0,MaxLen=40000;
char AllocStr[80];
int i=0;
LOGFILE = stderr;
/******************************************************************************
*
* Step 1: Parse the program arguments into GrpName, NastPath and CommandLine
*
******************************************************************************
160
*/
/***************************************************************************
*
* Step 2: Initilize the MSC.Nastran server
*
**************************************************************************
*/
(void) NServer_Start ( GrpName , CommandLine , NastPath , &Error);
if( Error ) {
strcpy( ApiName,"NServer_Start");
goto EXIT;
}
/****************************************************************************
*
* Step 3: Execution of solution in non-blocking mode
*
****************************************************************************
*/
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
/**************************************************************
*
* Step 4.b: Get out of for loop at the end of DMAP sequence
*
**************************************************************
*/
if( !strncmp(Dmap,"EXIT",4) || Error ) break;
/***********************************************************************
*
* Step 4.c : Unpack the ZUZR11 matrix, which has been created by DMAP
*
***********************************************************************
*/
sprintf(AllocStr,"DATABLK=ZUZR11 WHERE(ZNAME='DMAPGEN')");
Filept1 = 0;
/********************************************************************
*
* Step 4.d : Pack ZUZR11 matrix with qualifier ZNAME='API1GEN',
* using whole column
*
********************************************************************
*/
sprintf(AllocStr,"DATABLK=ZUZR11 QUALS(ZNAME='API1GEN')");
Filept2 = 0;
PackOption = 1;
/******************************************************************
*
* 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;
/*****************************************************************************
*
* Step 4.f : Read the ZUZR11 matrix, which has been created by this program
*
*****************************************************************************
*/
(void) DumpMatrix ( GrpName, NULL , &Filept2, &Error );
/******************************************************************************************
*****
*
* Step 5: Resume DMAP execution after the breakpoint and back to the loop for next break
point
*
*******************************************************************************************
****
*/
if( Error ) {
strcpy( ApiName,"NServer_SolResumeN");
goto EXIT;
}
/*******************************************
*
CHAPTER 7 163
Matrix I/O APIs
EXIT:
(void) PrintMessage (GrpName, LOGFILE, ApiName );
#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 );
}
164
/*
* 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];
/*
* GOpen the Matrix
*/
(void) NServer_GOpenDatablk( GrpName , *Filept , 'R' , 'Y' , Error );
/*
* Loop thru columns and unpack
*/
for(n=0; n< NCol; n++) {
UnpkCntl[0] = Type ;
UnpkCntl[1] = 1;
UnpkCntl[2] = NRow;
UnpkCntl[3] = 1;
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]);
}
}
/*
* 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 Nindex5=3;
NRow = ROWSIZE;
MatForm = RECTANGULAR;
MatType = REALDOUBLE;
if( !(*Filept) ) {
/*
* Create a datablock to output data
*/
(void) NServer_CreateDatablk ( GrpName , CreateString , Filept , &FileStat ,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
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
int NServer_PackColumnI
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.
int NServer_PackNullColumn
( char *GrpName, INTEGER Filept,
INTEGER *ColCntl, INTEGER *Trailer,
INTEGER NbrNull, INTEGER *Error );
Arguments.
int NServer_UnpackColumn
Arguments.
Example. A subroutine that uses the " Unpack" API. See also NServer_PackColumn
example on page 154.
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
int NServer_UnpackColumnI
Arguments.
int NServer_UnpackRowIdx
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.
CHAPTER
Direct Access I/O APIs
8
■ Grid Direct Access API's
int NServer_ReadGID
Purpose. Returns a list of all the grid ID's contained with the BGPDT file (referenced
by the file handle Filept).
Arguments.
int NServer_ReadXYZ
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.
• 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
/*
* (0) Parse the program arguments in to GrpName, NastPath and CommandLine
*/
/*
* (1) INIT THE SERVER
*/
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
*/
WaitMode = 0;
/*
* (3) GET THE EXECUTION STATUS
*/
/*
* DMAP alter has been made to exit after GP3 module, where
* BGPDT is available with the gino file number 102
*/
/*
* (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);
Filept,BeginEntry,RecLeng,GIDStat,MaxEntry,Error);
(void) NServer_ReadXYZ(
GrpName,Filept,GIDRecord,XYZRecord,RecLeng,&OutLeng,&XYZStat,&Error);
EXIT:
/*
* (5) EXIT THE SERVER
*/
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
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.
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
Int NServer_ReadIFPKeys
Arguments.
Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 189
Direct Access I/O APIs
int NServer_ReadIndexedIFP
Purpose. Returns indexed IFP data for a given list of IFP keys.
Arguments.
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
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. 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
int NServer_GetSelect
Arguments.
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.
int NServer_NDDLDesc
Purpose. Returns the type and label information for a NDDL described table.
Arguments.
Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
198
int NServer_OFPDesc
Purpose. Returns the type and label information for an NDDL described table.
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.
Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 201
Direct Access I/O APIs
int NServer_ReadOFPKeys
Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
CHAPTER 8 203
Direct Access I/O APIs
int NServer_ReadOFPLabel
Purpose. Extracts the title, subtitle or label information from the ID record of an OFP
datablock.
Arguments.
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
int NServer_ReadOFPLabelC
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
int NServer_ReadOFPSubindex
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.
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
}
}
Code Example. See the Nsbrowser.f example in the "Toolkit Code Librarian" Help
system.
208
int NServer_ReadOFPSubindexEntry
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.
int NServer_RemoveSelect
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
int NServer_Select
Purpose. To define a filter for a datablock record prior to performing I/O activities.
Arguments.
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
int NServer_SelectOFP
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.
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:
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
int NServer_SetSelectGroup
Arguments:
int NServer_SortSelect
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
■ Stress Codes
■ Did a Block Change?
■ TABPRT
■ SEDRCVR
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.
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
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.
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.
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
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
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
method :
MAJOR = table_code / 1000
MINOR = table_code - 1000 * MAJOR
MAJOR = MAJOR+1
TCODE = 1
IF ( MAJOR .GE. 3 ) TCODE = 2
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
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
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.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 $
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
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.
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.
DBNAME TABLES
DBENTRY TABLE
PATH QUALIFIER TABLES
DATA BLOCK DESCR. MASTER DIRECTORY FILES
DEPENDENCY TABLES
DBSPC TABLE, etc. ...
ETC. ...
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:
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
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).
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)
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)
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).
NServer_Resume
Purpose: See Toolkit User's Guide, NServer_SolResumeN – Resume DMAP
Execution After Stopping by Nserver_SetExeBreak (p. 55).
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)
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).
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).
NServer_Restart
Purpose: See Toolkit User's Guide, NServer_Restart – Restart the Server from
Another Client Program (p. 69).
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).
NServer_AllocDatablk
Purpose: See Toolkit User's Guide, NServer_AllocDatablk – Allocate an Existing
MSC.Nastran Datablock (p. 84).
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)
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).
NServer_PrelocDatablk
Purpose: See Toolkit User's Guide, NServer_PrelocDatablk – Prepare a Datablock to
be Accessed by NServer_LocateRecord (p. 126).
NServer_LocateRecord
Purpose: See Toolkit User's Guide, NServer_LocateRecord – Position an IFP File to
the Requested Record (p. 129).
NServer_SkipRecord
Purpose: See Toolkit User's Guide, NServer_SkipRecord – Skip a Record (Table or
Matrix Column) (p. 130).
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 )
NServer_ReadTrailerX
Purpose: See Toolkit User's Guide, NServer_ReadTrailerX – Read the Extended
Trailer of a Datablock (p. 132).
NServer_MakeTrailer
Purpose: See Toolkit User's Guide, NServer_MakeTrailer – Make a Trailer Control
Block for a Matrix Datablock (p. 133).
NServer_WriteTrailer
Purpose: See Toolkit User's Guide, NServer_WriteTrailer – Write the Trailer of a
Datablock (p. 134).
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 )
NServer_SavposRecord
Purpose: See Toolkit User's Guide, NServer_SavposRecord – Save Direct Access
Index of the Current Record (p. 136).
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).
NServer_GetRecTerm
Purpose: See Toolkit User's Guide, NServer_GetRecTerm – Get Terms of a Record
from a Table Datablock (p. 146).
NServer_SizeofServerNDDLTerm
Purpose: See Toolkit User's Guide, NServer_SizeofServerNDDLTerm – Get Size of
NDDL Term (Server) (p. 149).
NServer_SizeofClientNDDLTerm
Purpose: See Toolkit User's Guide, NServer_SizeofClientNDDLTerm – Get Size of
NDDL Term (Client) (p. 151).
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).
NServer_UnpackColumn
Purpose: See Toolkit User's Guide, NServer_UnpackColumn – Unpack a Matrix
Column (p. 170).
NServer_UnpackColumnI
Purpose: See Toolkit User's Guide, NServer_UnpackColumnI – Unpack a Sparse
Matrix Column (p. 173).
NServer_UnpackRowIdx
Purpose: See Toolkit User's Guide, NServer_UnpackRowIdx – Unpack a Matrix Row
Index (p. 174).
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)
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)
NServer_ReadOFPSubindex
Purpose: See Toolkit User's Guide, NServer_ReadOFPSubindex – Get OFP
identification information (p. 206).
NServer_ReadOFPLabel
Purpose: See Toolkit User's Guide, NServer_ReadOFPLabel – Get Title, Subtitle,
Label (p. 203).
260
NServer_Select
Purpose: See Toolkit User's Guide, NServer_Select – Define a Filter for Datablock
Attributes Prior to Performing I/O Activities (p. 210).
NServer_RemoveSelect
Purpose: See Toolkit User's Guide, NServer_RemoveSelect – Remove a Filter Set by
a Previous Call to NServer_Select (p. 209).
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).
NServer_ReadOFPKeys
Purpose: See Toolkit User's Guide, NServer_ReadOFPKeys – Get OFP IDs (p. 201).
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)
NServer_NDDLDesc
Purpose: See Toolkit User's Guide, NServer_NDDLDesc – Get NDDL Labels and
Types (p. 195).
NServer_OFPDesc
Purpose: See Toolkit User's Guide, NServer_OFPDesc – Get NDDL Labels and
Types (p. 198).
APPENDIX
List of API Error Codes
D
264
APPENDIX
Toolkit Compile and Link Instructions
E
■ Makefiles
268
E.1 Makefiles
The following are some sample Makefiles.
HP
# Makefile for Nastran Toolkit Applications
# Replace "client" by the appropriate name
# ---------------------------------------------
# Compiler Definition
# Path to libclient.a
toolkit = <user_defined_path>/libclient.a
# Makes
# Compilations
SGI
# Makefile for Nastran Toolkit Applications
# Replace "client" by the appropriate name
# ---------------------------------------------
# Compiler Definition
# Path to libclient.a
toolkit = <user_defined_path>/libclient.a
# Makes
# Compilations
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:
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.
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] );
}
}
}
/*
* 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];
logname[i] = '\0';
strcat( logname,".prt");
fprintf(LOGFILE," Toolkit Output file %s\n",logname);
/*
* Purpose: Driver to call NServer_GetMessage
* and print out messages from the server
*/
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;
}
MSC.Nastran Toolkit User’s Guide
APPENDIX
Example Toolkit Client Applications
G
■ Toolkit Code Librarian
276
APPENDIX
Subindex Description
H
■ Appendix H: Subindex Description
278
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
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
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