Msc. Patran pcl handbook In a Nutshell 7


C Day 2 ompiling and Linking PCL Functions



Download 1.08 Mb.
Page8/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   4   5   6   7   8   9   10   11   ...   25

C
Day 2
ompiling and Linking PCL Functions


  • Compiling and “linking” is accomplished with PCL Directives. Directives begin with !! and are processed immediately. In addition to compiling, directives are used for debugging, library management, etc.

  • PCL is an interpretive language (a.k.a., BASIC). Compiling PCL functions is different than compiling C or FORTRAN. In PCL, compiling simply reformats the data into a more efficient binary form.

  • In C or FORTRAN, “linking” implies the process of linking your functions with pre-built libraries of standard functions, i.e., externally referenced functions are “resolved”. This is not true for PCL. For PCL, the term “linking” simply means that the functions are available for use within the current MSC.Patran session. No checking of any kind is performed.

Compiling and Linking PCL Functions

Primary PCL Directives


  • !
    Does not necessarily take place immediately. Only when the “heartbeat” turns green.
    !INPUT
    redirects input to come from a specified file instead of the keyboard.

    !!INPUT filename

  • If the file contains PCL CLASS and FUNCTION statements, these classes and functions are compiled and “linked”.

  • Functions compiled with !!INPUT only exist within memory during the current MSC.Patran session. If you want to access the functions in subsequent MSC.Patran sessions, you must recompile (!!INPUT) these functions during the session.

  • E
    !!INPUT was typed at the command line

    The file (test.pcl) contained a FUNCTION statement. Therefore, MSC.Patran compiled the statements between the FUNCTION statement and the END FUNCTION statement.
    $# Compiling: test Indicates that MSC.Patran is compiling the function, test

    $# Compiled: test Indicates that the function, test, has been successfully compiled
    Statements between Compiling/Compiled are compilation warnings. If the Compiled message is not present then the statements following the Compiling message are compilation errors. If the Compiled message is missing, then the PCL function did not compile and is not accessible.

    xample usage

Compiling and Linking PCL Functions

  • !!COMPILE (!!COMP) Reads a file containing PCL classes and/or functions and compiles these into a PCL library.

    !!COMPILE filename [INTO] PCL_library_file

  • Typically, the filename will have a .pcl extension and the PCL library file will have a .plb extension. If you do not specify a library file, MSC.Patran will compile the filename into a library file with the same name as the input file and a .plb extension.

  • E
    xample usage



Compiling and Linking PCL Functions

  • !!LIBRARY (!!LIB) directive “links” the PCL library with the current MSC.Patran session. Linking simply means that the functions in the library file are accessible from within MSC.Patran. No checking is performed.

  • In addition to “linking” PCL libraries to the current MSC.Patran session, the !!LIB directive is used for library management functions.



!!LIB ADD file

links” file with the current MSC.Patran session

!!LIB REMOVE file

unlinks” file from the current MSC.Patran session

!!LIB MERGE source_file dest_file

Merges functions from source_file into dest_file

!!LIB DELETE file function [function]

Deletes the specified functions from the file

!!LIB LIST file

Lists all functions in file

!!LIB

Lists all PCL libraries “linked” with the current MSC.Patran session

E
xample usage
Compiling and Linking PCL Functions

  • !!PATH Defines the order in which a set of directories is searched to find files needed by PCL. In other words, this is the path that MSC.Patran uses to search for PCL libraries and other files. The current directory is always searched first. Other directories to be searched are defined in the init.pcl file. The format of the PATH directive is:

    !!PATH [ADD] directory [directory …]

  • In addition to adding directories to the search path, the PATH directive can also be used to:

      !!PATH REMOVE directory [directory…]

      !!PATH NONE

      Removes all directories from the search path

      !!PATH

      Lists all directories currently in the search path

  • The last !!PATH statement is searched first. Within a !!PATH statement, the directories are searched first to last.

    !!PATH /abc /def /hij

    !!PATH /klm

In this example, /klm would be searched for files first, /abc next, /def next, and /hij last.

  • The !!PATH directive is typically included in either the p3midilog.pcl or p3epilog.pcl files startup files.

Compiling and Linking PCL Functions


Compiling PCL outside of MSC.Patran


  • PCL functions may be compiled into libraries outside of the MSC.Patran environment using the MSC.Patran PCL compiler, p3pclcomp. A sample session might look as follows:

    Unix prompt% p3pclcomp
    P3/PCL compiler Version 9.0
    Exit or ctrl-d to quit
    -> !!comp my_function.pcl my_library.plb
    Compiling: my_function
    Compiled: my_function
    -> exit
    Unix prompt%


  • p3pclcomp can also be used to check for syntax errors, compile functions into a library, or perform PCL library management operations.

Compiling and Linking PCL Functions

Linking Compiled Libraries


Once the PCL functions have been debugged, it is best to use MSC.Patran startup files (p3epilog.pcl) to automatically “link” your library each time you start MSC.Patran.!

$ Sample p3epilog.pcl file

!!PATH /msc/patran_common

!!PATH ~/patran_pcl, ~/patran_pcl/plb, ~/patran_pcl/icons

!!LIB MyFunctions.plb

!!LIB YourFunctions.plb

Compiling and Linking PCL Functions


Other PCL Directives


  • The !!DEBUG directive causes the compiler to save the line numbers with the compiled code.

  • Must be invoked prior to compiling.

  • Must use the !!TRACE LINES directive to see the line numbers as the PCL function executes.

    !!DEBUG [ON, OFF]

  • !!TRACE directive is often used for debugging

    !!TRACE [CALLS/NOCALLS, EXITS/NOEXITS, LINES/NOLINES, STDOUT/NOSTDOUT]

  • The LINES/NOLINES option is used in conjunction with the DEBUG directive. If set to LINES, will echo lines as they execute

    !!DEBUG ON
    !!INPUT write_number.pcl
    !!TRACE LINES
    write_number(5)
    [38:status = file_build_fname(“”, “records”, “out”, “NV”, fname)]
    [40:IF (status != 0) THEN RETURN status]


  • The CALLS/NOCALLS option causes MSC.Patran to write the function name to STDOUT each time it enters (calls) a function. This is often useful if MSC.Patran is crashing during the execution of your PCL. Thus, you will be able to know in which function the crash is occurring. !!TRACE CALLS enables this action whereas !!TRACE NOCALLS disables this feature.

  • The EXITS/NOEXITS option is similar to the CALLS/NOCALLS option. But instead of writing the function name each time it calls the function, it writes the function name each time it exits the function.

Compiling and Linking PCL Functions

Start Up Files


Once the PCL functions have been compiled, it is best to use MSC.Patran startup files (p3prolog.pcl, p3midilog.pcl, p3epilog.pcl) to automatically “link” your library each time you start MSC.Patran.!

  • They are all called by the “mother of all MSC.Patran startup files”, init.pcl which is called first during MSC.Patran startup.

  • The startup files are called in a specific order. Below is a simplified listing of the init.pcl showing how and when the startup files are called.

    /* simplified init.pcl example */
    !!INPUT p3prolog.pcl NOERROR

    $ define p3_home and default MSC.Patran paths…..
    $ define MSC.Patran and Insight libraries….

    !!INPUT p3midilog.pcl NOERROR

    $ bring up main MSC.Patran form…..

    !!INPUT p3patran.pcl NOERROR

    !!INPUT p3epilog.pcl NOERROR



  • The contents of these files are usually very simple and often just contain a few !!PATH and !!LIB directives.

$ Sample p3epilog.pcl file

!!PATH /msc/patran_common
!!PATH ~/patran_pcl, ~/patran_pcl/plb, ~/patran_pcl/icons



!!LIB MyFunctions.plb
!!LIB YourFunctions.plb




Download 1.08 Mb.

Share with your friends:
1   ...   4   5   6   7   8   9   10   11   ...   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page