Libraries let you use your user-written subroutines and compiled functions. User-written subroutines and compiled functions let you tailor your template-based product to your needs and go beyond the functions you can define using macros. For more on compiled functions, see Compiled Functions in the guide,
Using the Adams/View Function Builder.
To use your custom subroutines and functions, you create an Adams/View library. An Adams/View library extends the functionality of your template-based product during the design phase and during plotting. Using an Adams/View library, you can create compiled functions in C and use them in an Adams/View expression just as you would use standard, built-in Adams/View functions.
You register the user-written functions by calling a subroutine built into Adams/View. You must place this subroutine call in the registration subroutine supplied in source-code form in Adams/View. To automate tasks, you can write a custom Adams/View library in C. As an example, you might want to create a wavefront file that given a number of macro parameters, such as road width, length, and color, can be used to define a road graphic. In such an example, you would create a C file that when combined with some macro-wrapping code can be set up to pass parameters from the macro to your custom C routine. The following example shows five parameters (road_width, road_length, color, shell_file, error_flag) being passed to a routine named create_a_road:
integer_value = (eval(create_a_road("$road_width", "road_length", "color", "shell_file", "error_flag" )))
In this case, you call a function (create_a_road) in your Adams/View library. You can set up this code to return a Boolean flag, such as 0 if it failed and 1 if it was successfully executed. You can check this flag to see if the operation was successful or not, and take action based on the result.
You can input C or FORTRAN source files to create Adams/Solver user libraries and only C source files to create Adams/View user libraries. You must compile these subroutines before linking them with an Adams product. See the hardware and software specifications that come with your Adams product for the type of compiler you need (
http://www.mscsoftware.com/support/prod_support/adams/?Q=135&Z=144&Y=174). Also refer to your compiler documentation for details.
You can find the file vc_init_usr.c in the distribution of Adams, under /aview/usersubs. This file provides an interface between Adams/View and user-defined functions. For this example, you'll assume that a user-defined function, named create_road, is going to be used. Following the instructions in vc_init_usr.c, you would do the following:
For the custom Adams/View library to be automatically loaded, see the notes for organizing your custom code. Once you've loaded the library into your template-based product, you should be able to reference your custom function. You can reference your function using the Function Builder or macro code.