PCL and Customization > Accessing the Patran Database > Examples of Translation
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Examples of Translation
The following PCL programs are examples of how to extract data from or add data to a Patran database.
Results Reader
The following PCL program shows an example of how to import results into the database from an external source. This example creates a simple form for user inputs. The “Apply” button will initiate the results loading. This example shows how to read from an ASCII formatted PATRAN 2.5 nodal results file as the external source. (Capabilities for reading PATRAN 2.5 results are provided in Patran using File->Import->Results). The source for this example can be found in the $P3_HOME/customization directory under the name “result_reader.pcl.”
/*$$ Results Reader Example PCL Form 
* 
* Purpose: 
*    Show an example of a Reading Results into P3 
* 
* Input: 
*    <None> 
* 
* Output: 
*    <None> 
* 
* Log: 
* 
* Notes: 
* 
*/ 
#include “appforms.p” 
CLASS result_reader 
CLASSWIDE WIDGET column_dbx, lc_label_dbx, lc_desc_dbx, res_label_dbx, @ 
res_desc_dbx, res_type_sw, num_type_sw, @ 
file_dbx, file_type_sw 
/*$$ FUNCTION 
* 
* Purpose: 
*    Initialize the Results Reader form. 
* 
* Input: 
*    <None> 
* 
* Output: 
*    <None> 
* 
* Log: 
* 
* 
* Notes: 
* 
* 
*/ 
FUNCTION init 
#       include “uistrings.p” 
WIDGET   form_id,                                             @ 
apply_button,                                        @ 
cancel_button, wid_id 
REAL     unframed_l_margin,                                   @ 
form_wid_med,                                        @ 
inter_widget_space,                                  @ 
y_loc 
/* 
* Initialize constants 
*/ 
unframed_l_margin  = UNFRAMED_L_MARGIN 
form_wid_med       = FORM_WID_MED 
inter_widget_space = INTER_WIDGET_SPACE 
/* 
* Create the form 
*/ 
form_id = ui_form_create(                                     @ 
/* callback */ “”,                              @ 
/*    x     */  FORM_X_LOC_MED_NX2_SML,         @ 
/*    y     */  FORM_Y_LOC,                     @ 
/* position */ “UL”,                            @ 
/*  width   */  form_wid_med,                   @ 
/*  height  */  0.0,                            @ 
/*  label   */ “Example Results Reader”,        @ 
/* iconname */ “” ) 
y_loc = FORM_T_MARGIN 
/* 
* Create the “Result file” databox 
*/ 
file_dbx = ui_databox_create(                                 @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Results File”,              @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
/* 
* Create the “File Type” switch 
*/ 
file_type_sw = ui_switch_create(                              @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* num_columns  */  2,                          @ 
/*    label     */ “File Type”,                 @ 
/* always_one   */  TRUE                        ) 
wid_id = ui_item_create( file_type_sw, “1”, “Nodal(.nod)”, FALSE ) 
ui_wid_set( wid_id, “VALUE”, TRUE ) 
ui_item_create( file_type_sw, “2”, “Element(.els)”, FALSE ) 
y_loc += SWITCH_1R_HGT_LABEL + inter_widget_space 
/* 
* Create the “Load Case Label” databox 
*/ 
lc_label_dbx = ui_databox_create(                             @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Load Case Label”,           @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
/* 
* Create the “Load Case Description” databox 
*/ 
lc_desc_dbx = ui_databox_create(                              @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Load Case Description”,     @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
/* 
* Create the “Result Label” databox 
*/ 
res_label_dbx = ui_databox_create(                            @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Result Label”,              @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
/* 
* Create the “Result description” databox 
*/ 
res_desc_dbx = ui_databox_create(                             @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Result Description”,        @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
/* 
* Create the “Result Type” switch 
*/ 
res_type_sw = ui_switch_create(                               @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* num_columns  */  3,                          @ 
/*    label     */ “Result Type”,               @ 
/* always_one   */  TRUE                        ) 
wid_id = ui_item_create( res_type_sw, “1”, “Scalar”, FALSE ) 
ui_wid_set( wid_id, “VALUE”, TRUE ) 
ui_item_create( res_type_sw, “2”, “Vector”, FALSE ) 
ui_item_create( res_type_sw, “3”, “Tensor”, FALSE ) 
y_loc += SWITCH_2R_HGT_LABEL + inter_widget_space 
/* 
* Create the “Numeric Type “ switch 
*/ 
num_type_sw = ui_switch_create(                               @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* num_columns  */  3,                          @ 
/*    label     */ “Numeric Type”,             @ 
/* always_one   */  TRUE                        ) 
wid_id = ui_item_create( num_type_sw, “1”, “Real”, FALSE ) 
ui_wid_set( wid_id, “VALUE”, TRUE ) 
ui_item_create( num_type_sw, “2”, “Imaginary”, FALSE ) 
ui_item_create( num_type_sw, “3”, “Complex Mag.”, FALSE ) 
ui_item_create( num_type_sw, “4”, “Complex Phase”, FALSE ) 
y_loc += SWITCH_2R_HGT_LABEL + inter_widget_space 
/* 
* Create the “Result Columns” databox 
*/ 
column_dbx = ui_databox_create(                               @ 
/*    parent    */  form_id,                    @ 
/*   callback   */ “”,                          @ 
/*      x       */  unframed_l_margin,          @ 
/*      y       */  y_loc,                      @ 
/* label_length */  0.0,                        @ 
/*  box_length  */  DBOX_WID_DOUBLE,            @ 
/*    label     */ “Result Column(s)”,          @ 
/*    value     */  “ ”,                        @ 
/* label_above  */  TRUE,                       @ 
/*   datatype   */ “STRING”,                    @ 
/*   num_vals   */  1                           ) 
y_loc += DBOX_HGT_LABOVE + inter_widget_space 
ui_separator_create(                                          @ 
/*   parent   */  form_id, @ 
/*  callback  */ “”,                            @ 
/*     x      */  0.0,                          @ 
/*     y      */  y_loc,                        @ 
/*   length   */  form_wid_med,                 @ 
/* horizontal */  TRUE              ) 
y_loc += LINE_THICKNESS + inter_widget_space 
/* 
* Create the “Apply” button 
*/ 
apply_button = ui_button_create(                              @ 
/*    parent   */  form_id,                     @ 
/*   callback  */ “apply_cb”,                   @ 
/*      x      */  BUTTON_HALF_X_LOC1,          @ 
/*      y      */  y_loc,                       @ 
/*    width    */  BUTTON_WID_HALF,             @ 
/*    height   */  0.0,                         @ 
/*    label    */  APPLY_UD,                    @ 
/* labelinside */  TRUE,                        @ 
/*  highlight  */  TRUE                         ) 
/* 
* Create the “Cancel” button 
*/ 
cancel_button = ui_button_create(                             @ 
/*    parent   */  form_id,                     @ 
/*   callback  */ “cancel_cb”,                  @ 
/*      x      */  BUTTON_HALF_X_LOC2,        @ 
/*      y      */  y_loc,                     @ 
/*    width    */  BUTTON_WID_HALF,           @ 
/*    height   */  0.0,                       @ 
/*    label    */  CANCEL,                    @ 
/* labelinside */  TRUE,                      @ 
/*  highlight  */  FALSE            ) 
y_loc += BUTTON_DEFAULT_HGT + FORM_B_MARGIN 
/* 
* Adjust form height 
*/ 
ui_wid_set( form_id, “HEIGHT”, y_loc ) 
END FUNCTION   /* init */ 
/*$$ FUNCTION 
* 
* Purpose: 
*    Display the Example Results Reader form. 
* 
* Input: 
*    <None> 
* 
* Output: 
*    <None> 
* 
* Log: 
* 
* 
* Notes: 
* 
* 
*/ 
FUNCTION display 
/* 
* Display the form 
*/ 
ui_form_display( “result_reader” ) 
END FUNCTION   /* display */ 
/*$$ FUNCTION 
* 
* Purpose: 
* 
* 
* Input: 
*    <None> 
* 
* Output: 
*    <None> 
* 
* Log: 
* 
* 
* Notes: 
* 
* 
*/ 
FUNCTION apply_cb 
INTEGER cols(6), ncols, restype, numtype, i 
STRING file_name[VIRTUAL], lc_label[VIRTUAL], lc_desc[VIRTUAL], @ 
res_label[VIRTUAL], res_desc[VIRTUAL], res_type[1], @ 
file_type[1], num_type[1], column_str[VIRTUAL] 
/* obtain the filename and type from the databox widgets */ 
ui_wid_get_vstring(file_dbx,“VALUE”,file_name) 
file_name = str_strip_lead(file_name) 
ui_wid_get( file_type_sw, “VALUE”, file_type ) 
/* Get the loadcase labels from the databoxes */ 
ui_wid_get_vstring( lc_label_dbx, “VALUE”, lc_label ) 
lc_label = str_strip_lead(lc_label) 
ui_wid_get_vstring( lc_desc_dbx, “VALUE”, lc_desc ) 
lc_desc =str_strip_lead(lc_desc) 
/* Get the Result labels */ 
ui_wid_get_vstring( res_label_dbx, “VALUE”, res_label ) 
res_desc = str_strip_lead(res_label) 
ui_wid_get_vstring( res_desc_dbx, “VALUE”, res_desc ) 
res_desc = str_strip_lead(res_desc) 
/* Get the result type and numeric type */ 
ui_wid_get( res_type_sw, “VALUE”, res_type ) 
restype = str_to_integer( res_type ) 
ui_wid_get( num_type_sw, “VALUE”, num_type ) 
numtype = str_to_integer( num_type ) 
/* Get the string containing the column numbers from the databox */ 
ui_wid_get_vstring( column_dbx, “VALUE”, column_str ) 
column_str = str_strip_lead(column_str) 
/* extract the column integers from the string */ 
SWITCH ( restype ) 
CASE( 1 ) /* scalar */ 
cols(1) = str_to_integer(column_str) 
ncols = 1 
CASE( 2 ) /* vector */ 
FOR( i=1 TO 3 ) 
cols(i) = str_to_integer( str_token( column_str, “ ”, i ) ) 
END FOR 
ncols = 3 
CASE( 3 ) /* tensor */ 
FOR( i=1 TO 6 ) 
cols(i) = str_to_integer( str_token( column_str, “ ”, i ) ) 
END FOR 
ncols = 6 
END SWITCH 
/* Read in the results and load to the Db */ 
IF( file_type == “1” ) THEN /* nodal results */ 
result_reader.input_nodal_result( file_name, lc_label, lc_desc, @ 
res_label, res_desc, restype, numtype, ncols, cols ) 
ELSE 
xf_error_start( “Not yet implemented... Stay tuned” ) 
xf_error_end() 
END IF 
END FUNCTION   /* apply_cb */ 
/*$$ FUNCTION 
* 
* Purpose: 
* 
* 
* Input: 
*    <None> 
* 
* Output: 
*    <None> 
* 
* Log: 
* 
* 
* Notes: 
* 
* 
*/ 
FUNCTION cancel_cb 
/* 
* End form and ignore changes. 
*/ 
ui_form_hide( “results_reader” ) 
END FUNCTION   /* cancel_cb */ 
FUNCTION input_nodal_result( file_name, lc_label, lc_desc, res_label, @ 
res_desc, restype, numtype, ncols, cols ) 
INTEGER chan, lcid, rcid, scid, rtid, secid, lyid, i, cols(), @ 
ncols, restype, numtype, len, fil_attrs(4), nids(VIRTUAL), @ 
lyids(VIRTUAL), j, c_types(VIRTUAL), cids(VIRTUAL) 
REAL   maxval(1), col_vals(VIRTUAL), res_vals(VIRTUAL) 
STRING file_name[], lc_label[], lc_desc[], res_label[], res_desc[], @ 
title[80], chars[1](1), line[80], col_format[15] 
/* test for the existance of the file with a version extension */ 
IF( ! file_exists( file_name, “V”) ) THEN 
xf_error_start( “File does not exist” ) 
xf_error_end() 
RETURN( 1 ) 
END IF 
/* Open the text results file */ 
text_open(file_name, “ORV”,0,0,chan) 
/* Read the header information from the nodal results file */ 
text_read_string(chan, title, len) 
text_read(chan, “%2I9% %E15.6% %2I9%”, fil_attrs, maxval, chars ) 
text_read_string(chan, line, len) 
text_read_string(chan, line, len) 
/* Allocate result arrays */ 
sys_allocate_array(col_vals, 1, fil_attrs(4) ) 
sys_allocate_array(nids, 1, fil_attrs(1)+1 ) 
sys_allocate_array( lyids, 1, fil_attrs(1) ) 
IF( ncols > 1 ) THEN 
sys_allocate_array( res_vals, 1, fil_attrs(1), 1, ncols ) 
sys_allocate_array( c_types, 1, fil_attrs(1) ) 
sys_allocate_array( cids, 1, fil_attrs(1) ) 
ELSE 
sys_allocate_array( res_vals, 1, fil_attrs(1) ) 
END IF 
/* Create or if exists use the Loadcase */ 
dbt_find_load_case_id(“res_reader”,1,lc_label,1,lc_desc,lcid) 
/* Create a subcase for this result */ 
db_create_sub_case(lcid, title, scid, rcid ) 
/* Drop the Db indices while creating results */ 
db_drop_res_index() 
/* Create the result for this loadcase/subcase */ 
dbt_create_res_types(1, res_label, res_desc, restype, numtype, @ 
“RES_READER”, 0, rtid ) 
/* Create a section position id */ 
dbt_create_sect_pos( 1, “”, 0, [0., 0.], secid ) 
/* Create a layer position id */ 
dbt_create_layers(1, 0, secid, lyid ) 
/* Load the Results from the file into a result array */ 
/* create format string for formatted read from ascii results file */ 
col_format = “%I8% %”//str_from_integer(fil_attrs(4))//”E13.7%” 
IF( ncols == 1 ) THEN /* Read scalar results from file */ 
FOR( i = 1 TO fil_attrs(1) ) 
lyids(i) = lyid 
text_read(chan,col_format,nids(i:i+1),col_vals,chars) 
res_vals(i) = col_vals(cols(1)) 
END FOR 
ELSE    /* Read vector or tensor results from file */ 
FOR( i = 1 TO fil_attrs(1) ) 
lyids(i) = lyid 
c_types(i) = 1 
cids(i) = 0 
text_read(chan,col_format,nids(i:i+1),col_vals,chars) 
FOR( j = 1 TO ncols ) 
res_vals(i,j) = col_vals(cols(j)) 
END FOR 
END FOR 
END IF 
/* Load the result into the database */ 
SWITCH( ncols ) 
CASE( 1 ) /* Scalar */ 
db_add_s_nod_res_by_type( fil_attrs(1), rtid, rcid, lyids, @ 
nids, res_vals ) 
CASE( 3 ) /* Vector */ 
db_add_v_nod_res_by_type( fil_attrs(1), rtid, rcid, lyids, @ 
nids, c_types, cids, res_vals ) 
CASE( 6 ) /* Tensor */ 
db_add_t_nod_res_by_type( fil_attrs(1), rtid, rcid, lyids, @ 
nids, c_types, cids, res_vals ) 
END SWITCH 
/* Post Results in Database */ 
db_post_results_load() 
/* Close Text File */ 
text_close(chan, “”) 
RETURN( 0 ) 
END FUNCTION   /* input_nodal_result */ 
END CLASS   /* uil_imaging_geom */ 
Extracting Temperature Dependent and/or Non-Linear Material Data
The following PCL function writes temperature dependent and/or non-linear material definitions to a PATRAN 2.5 P/FEA auxiliary data file. The source for this example can be found in the $P3_HOME/customization directory under the name “pfea_mat_aux_file.pcl”.
FUNCTION pfea_mat_aux_file ( original_channel, file_name ) 
/* 
* Purpose: Extracts all material records referenced by element property 
*          regions in the database and then writes all the temperature 
*          dependent and/or non-linear material records to a PATRAN 
*          2.5 P/FEA auxilary input file. 
* 
* Input: original_channel  integer           the channel of the auxilary 
*                                            file. Zero if not yet opened. 
*        file_name         character string  the name of the auxilary file. 
*/ 
/* 
* There are 19 material properties which can exist in the auxilary file: 
* E11, E22, E33, Nu12, Nu13, Nu23, G12, G13, G23, a11, a22, a33, rho, 
* sig11, sig22, sig33, sig12, sig23, sig31. The “mat_types” array contains 
* the type of property word: 0 ( not found ), 1 ( real constant ), 2 
* ( temp. depend. real ), 3 ( constant stress/strain curve ) and 4 ( temp. 
*  depend. stress/strain curve ). The “mat_values” array contains the 
* constant real values of the property words. The “mat_fields” array 
* contains the field references for all the property words. 
* The “temp_values_#” arrays contain all the temperature values for 
* property word #. The “strain_values_#” arrays contain all the strain 
* values for the property word #. 
*/ 
INTEGER original_channel, file_channel, mat_types(19), mat_fields(19) 
INTEGER tot_num_temps, num_regions, region_ids(VIRTUAL), mats_written 
INTEGER status, prop_set_id, dof_set_flag, condense_flag, geom_flag, form_flag 
INTEGER lam_flag, layer_count, material_id, material_lin, material_dir 
INTEGER category_id, material_type, data_exists, num_words, max_num_words 
INTEGER word_ids(VIRTUAL), field_ids(VIRTUAL), i, j, k, l, max_num_temps 
INTEGER num_temp_values(19), num_strain_values(6), max_mat_data, num_mat_data 
INTEGER field_var, field_dim, geom_type, geom_id, extrap_opt, data_type, coord_id 
INTEGER field_type, num_vars, var_type_1, var_type_2, var_type_3, func_1_size 
INTEGER func_2_size, func_3_size, num_var_1, num_var_2, num_var_3, position 
INTEGER num_loops 
REAL mat_values(19), var_2_value(1), var_3_value(1), temp_value, tolerance 
REAL temp_1_values(VIRTUAL), temp_2_values(VIRTUAL), temp_3_values(VIRTUAL) 
REAL temp_4_values(VIRTUAL), temp_5_values(VIRTUAL), temp_6_values(VIRTUAL) 
REAL temp_7_values(VIRTUAL), temp_8_values(VIRTUAL), temp_9_values(VIRTUAL) 
REAL temp_10_values(VIRTUAL), temp_11_values(VIRTUAL), temp_12_values(VIRTUAL) 
REAL temp_13_values(VIRTUAL), temp_14_values(VIRTUAL), temp_15_values(VIRTUAL) 
REAL temp_16_values(VIRTUAL), temp_17_values(VIRTUAL), temp_18_values(VIRTUAL) 
REAL temp_19_values(VIRTUAL), strain_1_values(VIRTUAL), strain_2_values(VIRTUAL) 
REAL strain_3_values(VIRTUAL), strain_4_values(VIRTUAL), strain_5_values(VIRTUAL) 
REAL strain_6_values(VIRTUAL), material_1_values(VIRTUAL), material_2_values(VIRTUAL) 
REAL material_3_values(VIRTUAL), material_4_values(VIRTUAL), material_5_values(VIRTUAL) 
REAL material_6_values(VIRTUAL), material_7_values(VIRTUAL), material_8_values(VIRTUAL) 
REAL material_9_values(VIRTUAL), material_10_values(VIRTUAL), material_11_values(VIRTUAL) 
REAL material_12_values(VIRTUAL), material_13_values(VIRTUAL), material_14_values(VIRTUAL) 
REAL material_15_values(VIRTUAL), material_16_values(VIRTUAL), material_17_values(VIRTUAL) 
REAL material_18_values(VIRTUAL), material_19_values(VIRTUAL), input_values(VIRTUAL) 
REAL tot_temp_values(VIRTUAL), word_values(VIRTUAL), mat_data(VIRTUAL), real_array(2) 
STRING file_name[], prop_set_name[31], material_name[31], material_description[2500] 
STRING name[20], field_name[31], title[20] 
LOGICAL temp_depend, non_linear, lin_def, found 
/* initialize variables */ 
mats_written = 0 
file_channel = original_channel 
max_num_words = 0 
max_num_temps = 0 
max_mat_data = 0 
tolerance = 0.001 
/* determine the number of element property regions in the database and extract 
* their ids */ 
status = db_count_region_ids ( num_regions ) 
IF ( num_regions == 0 ) THEN 
RETURN 
END IF 
status = sys_allocate_array ( region_ids, 1, num_regions ) 
status = db_get_all_region_ids ( num_regions, region_ids ) 
/* loop through the number of regions determining whether the referenced 
* material record needs to be written to the aux. file or not */ 
FOR ( i = 1 TO num_regions ) 
status = db_get_region_definition ( region_ids(i), prop_set_name, prop_set_id, @ 
dof_set_flag, condense_flag, geom_flag, form_flag, lam_flag, @ 
layer_count, material_id, material_lin, material_dir ) 
IF ( material_id == 0 ) THEN 
CONTINUE 
END IF 
status = db_get_material ( material_id, material_name, category_id, material_lin, @ 
material_dir, material_description, material_type, @ 
data_exists ) 
IF ( data_exists == 0 ) THEN 
CONTINUE 
END IF 
status = db_get_matl_prop_value_count ( material_id, num_words ) 
IF ( num_words == 0 ) THEN 
CONTINUE 
END IF 
IF ( num_words > max_num_words ) THEN 
max_num_words = num_words 
status = sys_allocate_array ( word_ids, 1, num_words ) 
status = sys_allocate_array ( field_ids, 1, num_words ) 
status = sys_allocate_array ( word_values, 1, num_words ) 
END IF 
status = db_get_matl_prop_value ( material_id, word_ids, field_ids, word_values ) 
/* loop through all the material words, storing all the recognized words and 
* keeping tract of the variability ( temperature variance or nonlinearity ) of 
* the material records */ 
temp_depend = FALSE 
non_linear = FALSE 
tot_num_temps = 0 
mat_types(1) = 0 
mat_types(2) = 0 
mat_types(3) = 0 
mat_types(4) = 0 
mat_types(5) = 0 
mat_types(6) = 0 
mat_types(7) = 0 
mat_types(8) = 0 
mat_types(9) = 0 
mat_types(10) = 0 
mat_types(11) = 0 
mat_types(12) = 0 
mat_types(13) = 0 
mat_types(14) = 0 
mat_types(15) = 0 
mat_types(16) = 0 
mat_types(17) = 0 
mat_types(18) = 0 
mat_types(19) = 0 
num_temp_values(1) = 0 
num_temp_values(2) = 0 
num_temp_values(3) = 0 
num_temp_values(4) = 0 
num_temp_values(5) = 0 
num_temp_values(6) = 0 
num_temp_values(7) = 0 
num_temp_values(8) = 0 
num_temp_values(9) = 0 
num_temp_values(10) = 0 
num_temp_values(11) = 0 
num_temp_values(12) = 0 
num_temp_values(13) = 0 
num_temp_values(14) = 0 
num_temp_values(15) = 0 
num_temp_values(16) = 0 
num_temp_values(17) = 0 
num_temp_values(18) = 0 
num_temp_values(19) = 0 
num_strain_values(1) = 0 
num_strain_values(2) = 0 
num_strain_values(3) = 0 
num_strain_values(4) = 0 
num_strain_values(5) = 0 
num_strain_values(6) = 0 
FOR ( j = 1 TO num_words ) 
/* E11 */ 
IF ( word_ids(j) == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(1) = 2 
mat_fields(1) = field_ids(j) 
ELSE 
mat_types(1) = 1 
mat_values(1) = word_values(j) 
END IF 
END IF 
/* E22 */ 
IF ( word_ids(j) == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(2) = 2 
mat_fields(2) = field_ids(j) 
ELSE 
mat_types(2) = 1 
mat_values(2) = word_values(j) 
END IF 
END IF 
/* E33 */ 
IF ( word_ids(j) == 4 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(3) = 2 
mat_fields(3) = field_ids(j) 
ELSE 
mat_types(3) = 1 
mat_values(3) = word_values(j) 
END IF 
END IF 
/* Nu12 */ 
IF ( word_ids(j) == 5 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(4) = 2 
mat_fields(4) = field_ids(j) 
ELSE 
mat_types(4) = 1 
mat_values(4) = word_values(j) 
END IF 
END IF 
/* Nu13 */ 
IF ( word_ids(j) == 13 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(5) = 2 
mat_fields(5) = field_ids(j) 
ELSE 
mat_types(5) = 1 
mat_values(5) = word_values(j) 
END IF 
END IF 
/* Nu23 */ 
IF ( word_ids(j) == 6 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(6) = 2 
mat_fields(6) = field_ids(j) 
ELSE 
mat_types(6) = 1 
mat_values(6) = word_values(j) 
END IF 
END IF 
/* G12 */ 
IF ( word_ids(j) == 8 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(7) = 2 
mat_fields(7) = field_ids(j) 
ELSE 
mat_types(7) = 1 
mat_values(7) = word_values(j) 
END IF 
END IF 
/* G13 */ 
IF ( word_ids(j) == 9 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(8) = 2 
mat_fields(8) = field_ids(j) 
ELSE 
mat_types(8) = 1 
mat_values(8) = word_values(j) 
END IF 
END IF 
/* G23 */ 
IF ( word_ids(j) == 10 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(9) = 2 
mat_fields(9) = field_ids(j) 
ELSE 
mat_types(9) = 1 
mat_values(9) = word_values(j) 
END IF 
END IF 
/* Alpha11 */ 
IF ( word_ids(j) == 24 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(10) = 2 
mat_fields(10) = field_ids(j) 
ELSE 
mat_types(10) = 1 
mat_values(10) = word_values(j) 
END IF 
END IF 
/* Alpha22 */ 
IF ( word_ids(j) == 25 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(11) = 2 
mat_fields(11) = field_ids(j) 
ELSE 
mat_types(11) = 1 
mat_values(11) = word_values(j) 
END IF 
END IF 
/* Alpha33 */ 
IF ( word_ids(j) == 26 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(12) = 2 
mat_fields(12) = field_ids(j) 
ELSE 
mat_types(12) = 1 
mat_values(12) = word_values(j) 
END IF 
END IF 
/* Density ( rho ) */ 
IF ( word_ids(j) == 16 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
temp_depend = TRUE 
mat_types(13) = 2 
mat_fields(13) = field_ids(j) 
ELSE 
mat_types(13) = 1 
mat_values(13) = word_values(j) 
END IF 
END IF 
/* Sig11 vs. Eps11 */ 
IF ( word_ids(j) == 503 && material_lin == 3 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(14) = 3 
mat_fields(14) = field_ids(j) 
END IF 
END IF 
/* Sig22 vs. Eps11 */ 
IF ( word_ids(j) == 2002 && material_lin == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(15) = 3 
mat_fields(15) = field_ids(j) 
END IF 
END IF 
/* Sig33 vs. Eps11 */ 
IF ( word_ids(j) == 2003 && material_lin == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(16) = 3 
mat_fields(16) = field_ids(j) 
END IF 
END IF 
/* Sig12 vs. Eps11 */ 
IF ( word_ids(j) == 2004 && material_lin == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(17) = 3 
mat_fields(17) = field_ids(j) 
END IF 
END IF 
/* Sig23 vs. Eps11 */ 
IF ( word_ids(j) == 2005 && material_lin == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(18) = 3 
mat_fields(18) = field_ids(j) 
END IF 
END IF 
/* Sig31 vs. Eps11 */ 
IF ( word_ids(j) == 2006 && material_lin == 3 && material_dir == 2 ) THEN 
IF ( field_ids(j) > 0 ) THEN 
non_linear = TRUE 
mat_types(19) = 3 
mat_fields(19) = field_ids(j) 
END IF 
END IF 
END FOR 
/* if this is a constant linear material record, skip to the next element property region */ 
IF ( !temp_depend && !non_linear ) THEN 
CONTINUE 
END IF 
/* determine a valid temperature list for all the temp. depend. material data given */ 
FOR ( j = 1 TO 19 ) 
IF ( mat_types(j) == 2 || mat_types(j) == 3 ) THEN 
status = db_get_field ( mat_fields(j), field_name, field_var, field_dim, @ 
geom_type, geom_id, extrap_opt, data_type, coord_id, field_type, @ 
num_vars, var_type_1, var_type_2, var_type_3, func_1_size, @ 
func_2_size, func_3_size, lin_def, num_var_1, num_var_2, @ 
num_var_3 ) 
IF ( field_dim == 0 && field_type == 1 ) THEN 
IF ( mat_types(j) == 2 && num_vars == 1 && num_var_1 > 0 && @ 
var_type_1 == 10 ) THEN 
num_temp_values(j) = num_var_1 
IF ( j == 1 ) THEN 
status = sys_allocate_array( temp_1_values, 1, num_var_1 ) 
ELSE IF ( j == 2 ) THEN 
status = sys_allocate_array( temp_2_values, 1, num_var_1 ) 
ELSE IF ( j == 3 ) THEN 
status = sys_allocate_array( temp_3_values, 1, num_var_1 ) 
ELSE IF ( j == 4 ) THEN 
status = sys_allocate_array( temp_4_values, 1, num_var_1 ) 
ELSE IF ( j == 5 ) THEN 
status = sys_allocate_array( temp_5_values, 1, num_var_1 ) 
ELSE IF ( j == 6 ) THEN 
status = sys_allocate_array( temp_6_values, 1, num_var_1 ) 
ELSE IF ( j == 7 ) THEN 
status = sys_allocate_array( temp_7_values, 1, num_var_1 ) 
ELSE IF ( j == 8 ) THEN 
status = sys_allocate_array( temp_8_values, 1, num_var_1 ) 
ELSE IF ( j == 9 ) THEN 
status = sys_allocate_array( temp_9_values, 1, num_var_1 ) 
ELSE IF ( j == 10 ) THEN 
status = sys_allocate_array( temp_10_values, 1, num_var_1 ) 
ELSE IF ( j == 11 ) THEN 
status = sys_allocate_array( temp_11_values, 1, num_var_1 ) 
ELSE IF ( j == 12 ) THEN 
status = sys_allocate_array( temp_12_values, 1, num_var_1 ) 
ELSE IF ( j == 13 ) THEN 
status = sys_allocate_array( temp_13_values, 1, num_var_1 ) 
END IF 
num_mat_data = num_var_1 
IF ( num_mat_data > max_mat_data ) THEN 
max_mat_data = num_mat_data 
status = sys_allocate_array( mat_data, 1, max_mat_data ) 
END IF 
IF ( j == 1 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_1_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 2 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_2_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 3 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_3_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 4 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_4_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 5 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_5_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 6 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_6_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 7 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_7_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 8 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_8_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 9 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_9_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 10 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_10_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 11 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_11_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 12 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_12_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 13 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_13_values, @ 
var_2_value, var_3_value, mat_data ) 
END IF 
ELSE IF ( mat_types(j) == 3 && num_vars == 2 && num_var_1 > 0 && @ 
num_var_2 > 0 && var_type_1 == 10 && var_type_2 == 11 ) THEN 
temp_depend = TRUE 
mat_types(j) = 4 
num_temp_values(j) = num_var_1 
num_strain_values(j-13) = num_var_2 
IF ( j == 14 ) THEN 
status = sys_allocate_array( temp_14_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_1_values, 1, num_var_2 ) 
ELSE IF ( j == 15 ) THEN 
status = sys_allocate_array( temp_15_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_2_values, 1, num_var_2 ) 
ELSE IF ( j == 16 ) THEN 
status = sys_allocate_array( temp_16_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_3_values, 1, num_var_2 ) 
ELSE IF ( j == 17 ) THEN 
status = sys_allocate_array( temp_17_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_4_values, 1, num_var_2 ) 
ELSE IF ( j == 18 ) THEN 
status = sys_allocate_array( temp_18_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_5_values, 1, num_var_2 ) 
ELSE IF ( j == 19 ) THEN 
status = sys_allocate_array( temp_19_values, 1, num_var_1 ) 
status = sys_allocate_array( strain_6_values, 1, num_var_2 ) 
END IF 
num_mat_data = num_var_1*num_var_2 
IF ( num_mat_data > max_mat_data ) THEN 
max_mat_data = num_mat_data 
status = sys_allocate_array( mat_data, 1, max_mat_data ) 
END IF 
IF ( j == 14 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_14_values, @ 
strain_1_values, var_3_value, mat_data ) 
ELSE IF ( j == 15 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_15_values, @ 
strain_2_values, var_3_value, mat_data ) 
ELSE IF ( j == 16 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_16_values, @ 
strain_3_values, var_3_value, mat_data ) 
ELSE IF ( j == 17 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_17_values, @ 
strain_4_values, var_3_value, mat_data ) 
ELSE IF ( j == 18 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_18_values, @ 
strain_5_values, var_3_value, mat_data ) 
ELSE IF ( j == 19 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, temp_19_values, @ 
strain_6_values, var_3_value, mat_data ) 
END IF 
ELSE IF ( mat_types(j) == 3 && num_vars == 1 && num_var_1 > 0 && @ 
var_type_1 == 11 ) THEN 
num_strain_values(j-13) = num_var_1 
IF ( j == 14 ) THEN 
status = sys_allocate_array( strain_1_values, 1, num_var_1 ) 
ELSE IF ( j == 15 ) THEN 
status = sys_allocate_array( strain_2_values, 1, num_var_1 ) 
ELSE IF ( j == 16 ) THEN 
status = sys_allocate_array( strain_3_values, 1, num_var_1 ) 
ELSE IF ( j == 17 ) THEN 
status = sys_allocate_array( strain_4_values, 1, num_var_1 ) 
ELSE IF ( j == 18 ) THEN 
status = sys_allocate_array( strain_5_values, 1, num_var_1 ) 
ELSE IF ( j == 19 ) THEN 
status = sys_allocate_array( strain_6_values, 1, num_var_1 ) 
END IF 
num_mat_data = num_var_1 
IF ( num_mat_data > max_mat_data ) THEN 
max_mat_data = num_mat_data 
status = sys_allocate_array( mat_data, 1, max_mat_data ) 
END IF 
IF ( j == 14 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_1_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 15 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_2_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 16 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_3_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 17 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_4_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 18 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_5_values, @ 
var_2_value, var_3_value, mat_data ) 
ELSE IF ( j == 19 ) THEN 
status = db_get_field_table ( mat_fields(j), num_vars, num_var_1, @ 
num_var_2, num_var_3, strain_6_values, @ 
var_2_value, var_3_value, mat_data ) 
END IF 
END IF 
END IF 
END IF 
END FOR 
/* loop through all the temperature lists creating one super-set list */ 
FOR ( j = 1 TO 19 ) 
IF ( num_temp_values(j) > 0 && tot_num_temps == 0 ) THEN 
tot_num_temps = num_temp_values(j) 
IF ( tot_num_temps > max_num_temps ) THEN 
max_num_temps = tot_num_temps + 100 
status = sys_allocate_array ( tot_temp_values, 1, max_num_temps ) 
END IF 
FOR ( k = 1 TO tot_num_temps ) 
IF ( j == 1 ) THEN 
tot_temp_values(k) = temp_1_values(k) 
ELSE IF ( j == 2 ) THEN 
tot_temp_values(k) = temp_2_values(k) 
ELSE IF ( j == 3 ) THEN 
tot_temp_values(k) = temp_3_values(k) 
ELSE IF ( j == 4 ) THEN 
tot_temp_values(k) = temp_4_values(k) 
ELSE IF ( j == 5 ) THEN 
tot_temp_values(k) = temp_5_values(k) 
ELSE IF ( j == 6 ) THEN 
tot_temp_values(k) = temp_6_values(k) 
ELSE IF ( j == 7 ) THEN 
tot_temp_values(k) = temp_7_values(k) 
ELSE IF ( j == 8 ) THEN 
tot_temp_values(k) = temp_8_values(k) 
ELSE IF ( j == 9 ) THEN 
tot_temp_values(k) = temp_9_values(k) 
ELSE IF ( j == 10 ) THEN 
tot_temp_values(k) = temp_10_values(k) 
ELSE IF ( j == 11 ) THEN 
tot_temp_values(k) = temp_11_values(k) 
ELSE IF ( j == 12 ) THEN 
tot_temp_values(k) = temp_12_values(k) 
ELSE IF ( j == 13 ) THEN 
tot_temp_values(k) = temp_13_values(k) 
ELSE IF ( j == 14 ) THEN 
tot_temp_values(k) = temp_14_values(k) 
ELSE IF ( j == 15 ) THEN 
tot_temp_values(k) = temp_15_values(k) 
ELSE IF ( j == 16 ) THEN 
tot_temp_values(k) = temp_16_values(k) 
ELSE IF ( j == 17 ) THEN 
tot_temp_values(k) = temp_17_values(k) 
ELSE IF ( j == 18 ) THEN 
tot_temp_values(k) = temp_18_values(k) 
ELSE IF ( j == 19 ) THEN 
tot_temp_values(k) = temp_19_values(k) 
END IF 
END FOR 
ELSE IF ( num_temp_values(j) > 0 ) THEN 
FOR ( k = 1 TO num_temp_values(j) ) 
found = FALSE 
position = 0 
IF ( j == 1 ) THEN 
temp_value = temp_1_values(k) 
ELSE IF ( j == 2 ) THEN 
temp_value = temp_2_values(k) 
ELSE IF ( j == 3 ) THEN 
temp_value = temp_3_values(k) 
ELSE IF ( j == 4 ) THEN 
temp_value = temp_4_values(k) 
ELSE IF ( j == 5 ) THEN 
temp_value = temp_5_values(k) 
ELSE IF ( j == 6 ) THEN 
temp_value = temp_6_values(k) 
ELSE IF ( j == 7 ) THEN 
temp_value = temp_7_values(k) 
ELSE IF ( j == 8 ) THEN 
temp_value = temp_8_values(k) 
ELSE IF ( j == 9 ) THEN 
temp_value = temp_9_values(k) 
ELSE IF ( j == 10 ) THEN 
temp_value = temp_10_values(k) 
ELSE IF ( j == 11 ) THEN 
temp_value = temp_11_values(k) 
ELSE IF ( j == 12 ) THEN 
temp_value = temp_12_values(k) 
ELSE IF ( j == 13 ) THEN 
temp_value = temp_13_values(k) 
ELSE IF ( j == 14 ) THEN 
temp_value = temp_14_values(k) 
ELSE IF ( j == 15 ) THEN 
temp_value = temp_15_values(k) 
ELSE IF ( j == 16 ) THEN 
temp_value = temp_16_values(k) 
ELSE IF ( j == 17 ) THEN 
temp_value = temp_17_values(k) 
ELSE IF ( j == 18 ) THEN 
temp_value = temp_18_values(k) 
ELSE IF ( j == 19 ) THEN 
temp_value = temp_19_values(k) 
END IF 
IF ( temp_value < ( tot_temp_values(1) - tolerance ) ) THEN 
position = 1 
ELSE IF ( temp_value >= ( tot_temp_values(1) - tolerance ) && @ 
temp_value <= ( tot_temp_values(1) + tolerance ) ) THEN 
position = 1 
found = TRUE 
ELSE IF ( temp_value > ( tot_temp_values(tot_num_temps) @ 
+ tolerance ) ) THEN 
position = tot_num_temps + 1 
ELSE IF ( temp_value >= ( tot_temp_values(tot_num_temps) @ 
- tolerance ) && temp_value <= ( @ 
tot_temp_values(tot_num_temps) + tolerance ) ) THEN 
position = tot_num_temps 
found = TRUE 
ELSE IF ( tot_num_temps > 1 ) THEN 
FOR ( l = 1 TO ( tot_num_temps - 1 ) ) 
IF ( temp_value >= ( tot_temp_values(l) - tolerance ) && @ 
temp_value <= ( tot_temp_values(l) + tolerance ) ) THEN 
position = l 
found = TRUE 
BREAK 
ELSE IF ( temp_value > ( tot_temp_values(l) + tolerance ) && @ 
temp_value < ( tot_temp_values(l+1) - tolerance ) ) THEN 
position = l+1 
BREAK 
END IF 
END FOR 
END IF 
IF ( found || position <= 0 ) THEN 
CONTINUE 
END IF 
tot_num_temps = tot_num_temps + 1 
IF ( tot_num_temps > max_num_temps ) THEN 
max_num_temps = tot_num_temps + 100 
status = sys_reallocate_array ( tot_temp_values, 1, max_num_temps ) 
END IF 
IF ( position < tot_num_temps ) THEN 
FOR ( l = ( tot_num_temps - 1 ) TO position BY -1 ) 
tot_temp_values(l+1) = tot_temp_values(l) 
END FOR 
END IF 
tot_temp_values(position) = temp_value 
END FOR 
END IF 
END FOR 
/* evaluate each and every field at the super-set list of temperatures */ 
FOR ( j = 1 TO 19 ) 
IF ( mat_types(j) == 2 ) THEN 
IF ( j == 1 ) THEN 
status = sys_allocate_array( material_1_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_1_values ) 
ELSE IF ( j == 2 ) THEN 
status = sys_allocate_array( material_2_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_2_values ) 
ELSE IF ( j == 3 ) THEN 
status = sys_allocate_array( material_3_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_3_values ) 
ELSE IF ( j == 4 ) THEN 
status = sys_allocate_array( material_4_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_4_values ) 
ELSE IF ( j == 5 ) THEN 
status = sys_allocate_array( material_5_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_5_values ) 
ELSE IF ( j == 6 ) THEN 
status = sys_allocate_array( material_6_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_6_values ) 
ELSE IF ( j == 7 ) THEN 
status = sys_allocate_array( material_7_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_7_values ) 
ELSE IF ( j == 8 ) THEN 
status = sys_allocate_array( material_8_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_8_values ) 
ELSE IF ( j == 9 ) THEN 
status = sys_allocate_array( material_9_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_9_values ) 
ELSE IF ( j == 10 ) THEN 
status = sys_allocate_array( material_10_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_10_values ) 
ELSE IF ( j == 11 ) THEN 
status = sys_allocate_array( material_11_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_11_values ) 
ELSE IF ( j == 12 ) THEN 
status = sys_allocate_array( material_12_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_12_values ) 
ELSE IF ( j == 13 ) THEN 
status = sys_allocate_array( material_13_values, 1, tot_num_temps ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 1, 1, @ 
tot_temp_values, material_13_values ) 
END IF 
ELSE IF ( mat_types(j) == 3 ) THEN 
IF ( j == 14 ) THEN 
status = sys_allocate_array( material_14_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_1_values, material_14_values ) 
ELSE IF ( j == 15 ) THEN 
status = sys_allocate_array( material_15_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_2_values, material_15_values ) 
ELSE IF ( j == 16 ) THEN 
status = sys_allocate_array( material_16_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_3_values, material_16_values ) 
ELSE IF ( j == 17 ) THEN 
status = sys_allocate_array( material_17_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_4_values, material_17_values ) 
ELSE IF ( j == 18 ) THEN 
status = sys_allocate_array( material_18_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_5_values, material_18_values ) 
ELSE IF ( j == 19 ) THEN 
status = sys_allocate_array( material_19_values, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), num_strain_values(j-13), 1, 1, @ 
strain_6_values, material_19_values ) 
END IF 
ELSE IF ( mat_types(j) == 4 ) THEN 
status = sys_allocate_array( input_values, 1, @ 
tot_num_temps*num_strain_values(j-13), 1, 2 ) 
FOR ( k = 1 TO tot_num_temps ) 
FOR ( l = 1 TO num_strain_values(j-13) ) 
input_values(((k-1)*num_strain_values(j-13)+l),1) = tot_temp_values(k) 
IF ( j == 14 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_1_values(l) 
ELSE IF ( j == 15 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_2_values(l) 
ELSE IF ( j == 16 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_3_values(l) 
ELSE IF ( j == 17 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_4_values(l) 
ELSE IF ( j == 18 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_5_values(l) 
ELSE IF ( j == 19 ) THEN 
input_values(((k-1)*num_strain_values(j-13)+l),2) = strain_6_values(l) 
END IF 
END FOR 
END FOR 
IF ( j == 14 ) THEN 
status = sys_allocate_array( material_14_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_14_values ) 
ELSE IF ( j == 15 ) THEN 
status = sys_allocate_array( material_15_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_15_values ) 
ELSE IF ( j == 16 ) THEN 
status = sys_allocate_array( material_16_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_16_values ) 
ELSE IF ( j == 17 ) THEN 
status = sys_allocate_array( material_17_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_17_values ) 
ELSE IF ( j == 18 ) THEN 
status = sys_allocate_array( material_18_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_18_values ) 
ELSE IF ( j == 19 ) THEN 
status = sys_allocate_array( material_19_values, 1, tot_num_temps, 1, @ 
num_strain_values(j-13) ) 
status = get_field_values ( mat_fields(j), tot_num_temps, 2, 1, @ 
input_values, material_19_values ) 
END IF 
END IF 
END FOR 
/* write out the material record */ 
IF ( file_channel == 0 ) THEN 
status = text_open ( file_name, “NW”, 0, 0, file_channel ) 
status = text_write_string ( file_channel, @
 “$ PATRAN 2.5 P/FEA auxilary data file created by PCL “”pfea_xxx_aux_file” “functions” ) 
status = text_write_string ( file_channel, @
 “” ) 
END IF 
mats_written = mats_written + 1 
IF ( mats_written == 1 ) THEN 
status = text_write_string ( file_channel, @
“$ Nonlinear and/or temperature dependent material records” ) 
status = text_write_string ( file_channel, @ 
“” ) 
END IF 
status = text_write_string ( file_channel, “$ Material: “//material_name ) 
status = text_write_string ( file_channel, “$ Description: “//material_description ) 
status = text_write ( file_channel, “*MID = %I%”, material_id, 0.0, “” ) 
IF ( material_dir == 2 ) THEN 
status = text_write_string( file_channel, “ORTHOTROPIC” ) 
ELSE 
status = text_write_string( file_channel, “ISOTROPIC” ) 
END IF 
IF ( tot_num_temps == 0 ) THEN 
num_loops = 1 
ELSE 
num_loops = tot_num_temps 
END IF 
FOR ( j = 1 TO num_loops ) 
IF ( tot_num_temps > 0 ) THEN 
status = text_write ( file_channel, “TEMPERATURE = %G%”, 0, tot_temp_values(j), “” ) 
END IF 
FOR ( k = 1 TO 19 ) 
IF ( k == 1 && material_dir == 1 ) THEN 
name = “E” 
ELSE IF ( k == 1 ) THEN 
name = “E11” 
ELSE IF ( k == 2 ) THEN 
name = “E22” 
ELSE IF ( k == 3 ) THEN 
name = “E33” 
ELSE IF ( k == 4 && material_dir == 1 ) THEN 
name = “NU” 
ELSE IF ( k == 4 ) THEN 
name = “NU12” 
ELSE IF ( k == 5 ) THEN 
name = “NU13” 
ELSE IF ( k == 6 ) THEN 
name = “NU23” 
ELSE IF ( k == 7 ) THEN 
name = “G12” 
ELSE IF ( k == 8 ) THEN 
name = “G13” 
ELSE IF ( k == 9 ) THEN 
name = “G23” 
ELSE IF ( k == 10 && material_dir == 1 ) THEN 
name = “ALPHA” 
ELSE IF ( k == 10 ) THEN 
name = “ALPHA11” 
ELSE IF ( k == 11 ) THEN 
name = “ALPHA22” 
ELSE IF ( k == 12 ) THEN 
name = “ALPHA33” 
ELSE IF ( k == 13 ) THEN 
name = “DENSITY” 
ELSE IF ( k == 14 && material_dir == 1 ) THEN 
title = “STRESS VS. STRAIN” 
name = “STRESS(“ 
ELSE IF ( k == 14 ) THEN 
title = “SXX VS. STRAIN” 
name = “SXX(“ 
ELSE IF ( k == 15 ) THEN 
title = “SYY VS. STRAIN” 
name = “SYY(“ 
ELSE IF ( k == 16 ) THEN 
title = “SZZ VS. STRAIN” 
name = “SZZ(“ 
ELSE IF ( k == 17 ) THEN 
title = “SXY VS. STRAIN” 
name = “SXY(“ 
ELSE IF ( k == 18 ) THEN 
title = “SYZ VS. STRAIN” 
name = “SYZ(“ 
ELSE IF ( k == 19 ) THEN 
title = “SZX VS. STRAIN” 
name = “SZX(“ 
END IF 
IF ( mat_types(k) == 1 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, mat_values(k), name ) 
ELSE IF ( mat_types(k) == 2 ) THEN 
IF ( k == 1 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_1_values(j), name ) 
ELSE IF ( k == 2 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_2_values(j), name ) 
ELSE IF ( k == 3 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_3_values(j), name ) 
ELSE IF ( k == 4 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_4_values(j), name ) 
ELSE IF ( k == 5 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_5_values(j), name ) 
ELSE IF ( k == 6 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_6_values(j), name ) 
ELSE IF ( k == 7 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_7_values(j), name ) 
ELSE IF ( k == 8 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_8_values(j), name ) 
ELSE IF ( k == 9 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_9_values(j), name ) 
ELSE IF ( k == 10 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_10_values(j), name ) 
ELSE IF ( k == 11 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_11_values(j), name ) 
ELSE IF ( k == 12 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_12_values(j), name ) 
ELSE IF ( k == 13 ) THEN 
status = text_write ( file_channel, “%A% = %G%”, 0, @ 
material_13_values(j), name ) 
END IF 
ELSE IF ( mat_types(k) == 3 ) THEN 
status = text_write_string ( file_channel, title ) 
FOR ( l = 1 TO num_strain_values(k-13) ) 
IF ( k == 14 ) THEN 
real_array(1) = strain_1_values(l) 
real_array(2) = material_14_values(l) 
ELSE IF ( k == 15 ) THEN 
real_array(1) = strain_2_values(l) 
real_array(2) = material_15_values(l) 
ELSE IF ( k == 16 ) THEN 
real_array(1) = strain_3_values(l) 
real_array(2) = material_16_values(l) 
ELSE IF ( k == 17 ) THEN 
real_array(1) = strain_4_values(l) 
real_array(2) = material_17_values(l) 
ELSE IF ( k == 18 ) THEN 
real_array(1) = strain_5_values(l) 
real_array(2) = material_18_values(l) 
ELSE IF ( k == 19 ) THEN 
real_array(1) = strain_6_values(l) 
real_array(2) = material_19_values(l) 
END IF 
status = text_write ( file_channel, “%A%%G%) = %G%”, 0, real_array, name ) 
END FOR 
ELSE IF ( mat_types(k) == 4 ) THEN 
status = text_write_string ( file_channel, title ) 
FOR ( l = 1 TO num_strain_values(k-13) ) 
IF ( k == 14 ) THEN 
real_array(1) = strain_1_values(l) 
real_array(2) = material_14_values(j,l) 
ELSE IF ( k == 15 ) THEN 
real_array(1) = strain_2_values(l) 
real_array(2) = material_15_values(j,l) 
ELSE IF ( k == 16 ) THEN 
real_array(1) = strain_3_values(l) 
real_array(2) = material_16_values(j,l) 
ELSE IF ( k == 17 ) THEN 
real_array(1) = strain_4_values(l) 
real_array(2) = material_17_values(j,l) 
ELSE IF ( k == 18 ) THEN 
real_array(1) = strain_5_values(l) 
real_array(2) = material_18_values(j,l) 
ELSE IF ( k == 19 ) THEN 
real_array(1) = strain_6_values(l) 
real_array(2) = material_19_values(j,l) 
END IF 
status = text_write ( file_channel, “%A%%G%) = %G%”, 0, real_array, name ) 
END FOR 
END IF 
END FOR 
END FOR 
END FOR 
/* close the auxilary file if necessary */ 
IF ( original_channel == 0 && file_channel > 0 ) THEN 
text_close ( file_channel, “” ) 
END IF 
IF ( num_regions > 0 ) THEN 
sys_free_array ( region_ids ) 
END IF 
IF ( max_num_words > 0 ) THEN 
sys_free_array ( word_ids ) 
sys_free_array ( field_ids ) 
sys_free_array ( word_values ) 
END IF 
RETURN 
END FUNCTION 
Extracting Transient Load Histories
The following PCL function writes the time histories for transient loads to a PATRAN 2.5 FEA auxiliary data file. The source for this example can be found in the $P3_HOME/customization directory under the name “pfea_trans_aux_file.pcl”.
FUNCTION pfea_trans_aux_file ( original_channel, file_name, original_case_name ) 
/* 
* Purpose: Extracts the loads associated with the specified transient load case 
*          and writes their time histories to a PATRAN 2.5 P/FEA auxilary 
*          data file. 
* 
* Input: original_channel    integer             the channel of the auxilary 
*                                                data file. Zero if not yet opened. 
*        file_name           character string    the name of the auxilary data file. 
*        original_case_name  character string    the name of the transient load 
*                                                case whose transient loads’ time 
*                                                histories should be written to 
*                                                the P/FEA auxilary file. If the 
*                                                load_case_name is blank (“ ”) or 
*                                                null (“”), the default load case 
*                                                will be interrogated. 
*/ 
INTEGER original_channel, file_channel, length, load_ids(VIRTUAL), load_case_id 
INTEGER load_priorities(VIRTUAL), load_case_type, status, load_type, application_type 
INTEGER elem_dimension, coord_id, dynamic_flag, load_var_id, entity_type, entity_id 
INTEGER sub_entity_id, dynamic_field, node_position, region_type, field_id 
INTEGER dynamic_field_array(3), null_vector_array(3), position, i, j 
INTEGER num_histories, max_histories, history_ids(VIRTUAL), field_var, field_dim 
INTEGER geom_type, geom_id, extrap_opt, data_type, field_type, num_vars 
INTEGER var_type_1, var_type_2, var_type_3, func_1_size, func_2_size, func_3_size 
INTEGER num_var_1, num_var_2, num_var_3, max_times, num_loads 
REAL evaluation_point, load_value, load_value_array(3), scale_factor, real_array(2) 
REAL var_2_values(1), var_3_values(1), time_values(VIRTUAL), field_values(VIRTUAL) 
STRING file_name[], original_case_name[], load_case_name[80], type_name[20] 
STRING dynamic_case_name[80], load_case_description[256], load_name[31] 
STRING field_name[31] 
LOGICAL use_default, scalar, lin_def, found 
file_channel = original_channel 
max_times = 0 
/* check for a blank or null input load case name */ 
use_default = TRUE 
length = str_length ( original_case_name ) 
IF ( length > 0 ) THEN 
FOR ( i = 1 TO length ) 
IF ( str_substr( original_case_name, i, 1 ) != “” ) THEN 
use_default = FALSE 
END IF 
END FOR 
END IF 
/* if a blank or null load case name was input, fetch the default load case */ 
IF ( use_default ) THEN 
status = db_get_active_load_case ( load_case_name ) 
ELSE 
load_case_name = original_case_name 
END IF 
/* allocate memory for load ids belonging to this load case and fetch those ids */ 
status = db_count_lbc_by_load_case ( load_case_name, num_loads ) 
IF ( num_loads == 0 ) THEN 
RETURN 
END IF 
status = sys_allocate_array ( load_ids, 1, num_loads ) 
status = sys_allocate_array ( load_priorities, 1, num_loads ) 
status = db_get_load_case ( load_case_name, load_case_id, load_case_type, @ 
load_case_description, num_loads, load_ids, dynamic_case_name, @ 
evaluation_point, load_priorities ) 
IF ( load_case_type != 2 ) THEN 
RETURN 
END IF 
/* ensure that the loads of this load case are evaluated upon the finite 
* element entities */ 
status = lbc_eval_fem_by_lc ( load_case_name ) 
num_histories = 0 
max_histories = 0 
/* loop through the loads writing any time histories to the auxilary file */ 
FOR ( i = 1 TO num_loads ) 
status = db_get_lbc ( load_ids(i), load_name, load_type, application_type, @ 
elem_dimension, coord_id, dynamic_flag ) 
IF ( dynamic_flag == 0 ) THEN 
CONTINUE 
END IF 
/* check that the load is of one of the proper types: force, pressure or temperature */ 
IF ( load_type == 7 ) THEN 
type_name = “FORCE” 
ELSE IF ( load_type == 8 ) THEN 
type_name = “PRESSURE” 
ELSE IF ( load_type == 9 ) THEN 
type_name = “TEMPERATURE” 
ELSE 
CONTINUE 
END IF 
/* determine the data type of the load: scalar or vector */ 
IF ( load_type == 7 ) THEN 
scalar = FALSE 
ELSE 
scalar = TRUE 
END IF 
/* fetch all the load values */ 
field_id = 0 
IF ( scalar ) THEN 
status = db_get_all_fem_ds_by_id ( load_ids(i) ) 
WHILE ( db_get_next_fem_ds_by_id( load_var_id, entity_type, entity_id, @ 
sub_entity_id, load_value, dynamic_field, scale_factor, @ 
node_position, region_type ) == 0 ) 
IF ( dynamic_field > field_id ) THEN 
field_id = dynamic_field 
END IF 
END WHILE 
ELSE 
status = db_get_all_fem_dv_by_id ( load_ids(i) ) 
WHILE ( db_get_next_fem_dv_by_id( load_var_id, entity_type, entity_id, @ 
sub_entity_id, load_value_array, dynamic_field_array, @ 
null_vector_array, scale_factor, @ 
node_position, region_type ) == 0 ) 
FOR ( j = 1 TO 3 ) 
IF ( dynamic_field_array(j) > field_id ) THEN 
field_id = dynamic_field_array(j) 
END IF 
END FOR 
END WHILE 
END IF 
IF ( field_id <= 0 ) THEN 
CONTINUE 
END IF 
/* link the load set id with the proper time history table */ 
found = FALSE 
position = 0 
IF ( num_histories > 0 ) THEN 
FOR ( j = 1 TO num_histories ) 
IF ( field_id == history_ids(j) ) THEN 
found = TRUE 
position = j 
END IF 
END FOR 
END IF 
/* open the auxilary data file, if necessary */ 
IF ( file_channel == 0 ) THEN 
status = text_open ( file_name, “NW”, 0, 0, file_channel ) 
status = text_write_string ( file_channel, @ 
“$ PATRAN 2.5 P/FEA auxilary data file created by PCL” “pfea_xxx_aux_file” “functions” ) 
status = text_write_string ( file_channel, @ 
“ ”) 
END IF 
/* write out the load case name and description */ 
IF ( num_histories == 0 ) THEN 
status = text_write_string ( file_channel, @ 
“$ Transient loads for load case: “//load_case_name ) 
status = text_write_string ( file_channel, @ 
“$ Load case description: “//load_case_description ) 
status = text_write_string ( file_channel, @ 
“ “ ) 
END IF 
/* if a new transient data field, add it to the list of time history fields */ 
IF ( !found ) THEN 
num_histories = num_histories + 1 
position = num_histories 
IF ( max_histories == 0 ) THEN 
max_histories = max_histories + 100 
status = sys_allocate_array ( history_ids, 1, max_histories ) 
ELSE IF ( num_histories > max_histories ) THEN 
max_histories = max_histories + 100 
status = sys_reallocate_array ( history_ids, 1, max_histories ) 
END IF 
history_ids(position) = field_id 
END IF 
/* write out the dynamic command */ 
status = text_write_string ( file_channel, “$ Dynamic load: “//load_name ) 
status = text_write ( file_channel, “*DYNAMIC_LOAD = %I%”, load_ids(i), 0.0, “ “ ) 
status = text_write ( file_channel, “TYPE = %A%”, 0, 0.0, type_name ) 
status = text_write ( file_channel, “TIME_HISTORY = %I%”, position, 0.0, “ “ ) 
status = text_write_string ( file_channel, “ “ ) 
END FOR 
/* loop through the number of transient data fields referenced, writing 
* each one out */ 
IF ( num_histories > 0 ) THEN 
FOR ( i = 1 TO num_histories ) 
/* write out the load case name and description */ 
IF ( i == 1 ) THEN 
status = text_write_string ( file_channel, @ 
“$ Time histories for load case: “//load_case_name ) 
status = text_write_string ( file_channel, @ 
“$ Load case description: “//load_case_description ) 
status = text_write_string ( file_channel, @ 
“ “ ) 
END IF 
/* get information about the referenced data field */ 
status = db_get_field ( history_ids(i), field_name, field_var, field_dim, geom_type, @ 
geom_id, extrap_opt, data_type, coord_id, field_type, num_vars, @ 
var_type_1, var_type_2, var_type_3, func_1_size, func_2_size, @ 
func_3_size, lin_def, num_var_1, num_var_2, num_var_3 ) 
IF ( field_dim == 0 && field_type == 1 && @ 
num_vars == 1 && var_type_1 == 13 && num_var_1 > 0 ) THEN 
IF ( num_var_1 > max_times ) THEN 
max_times = num_var_1 + 100 
status = sys_allocate_array ( time_values, 1, max_times ) 
status = sys_allocate_array ( field_values, 1, max_times ) 
END IF 
/* get the field time and magnitude values */ 
status = db_get_field_table ( history_ids(i), num_vars, num_var_1, num_var_2, @ 
num_var_3, time_values, var_2_values, var_3_values, field_values ) 
/* write out the transient data field */ 
status = text_write_string ( file_channel, @
“$ Time dependent data field: “//field_name ) 
status = text_write ( file_channel, “*TIME_HISTORY = %I%”, i, 0.0, “ “ ) 
FOR ( j = 1 TO num_var_1 ) 
real_array(1) = time_values(j) 
real_array(2) = field_values(j) 
status = text_write ( file_channel, “LOAD(%G%) = %G%”, 0, real_array, “ “ ) 
END FOR 
status = text_write_string ( file_channel, @
“ “ ) 
END IF 
END FOR 
END IF 
/* close the auxilary file if necessary */ 
IF ( original_channel == 0 && file_channel > 0 ) THEN 
text_close ( file_channel, “ “ ) 
END IF 
IF ( max_times > 0 ) THEN 
sys_free_array ( time_values ) 
sys_free_array ( field_values ) 
END IF 
IF ( max_histories > 0 ) THEN 
sys_free_array ( history_ids ) 
END IF 
IF ( num_loads > 0 ) THEN 
sys_free_array ( load_ids ) 
sys_free_array ( load_priorities ) 
END IF 
END FUNCTION 
Forward Moldflow Translator
The following PCL function writes model information to Moldflow input files. This function is supplied only as an illustrative example. It is not a fully-functional Moldflow translator. The source for this example can be found in the $P3_HOME/customization directory under the name “trans_mold_flow.pcl”.
/* $Header: /madrid/users9/pflib/pcl/custom/RCS/trans_mold_flow.pcl,v 1.1 92/09/01 17:53:38 sprack Exp $ */ 
FUNCTION trans_mold_flow ( base_file_name, analysis_title, length_scale_factor, @ 
trans_method, group_name ) 
/* 
* Purpose: Translate the Patran model data into MOLD FLOW style input files. 
* 
* Input: base_file_name        character string    the base name to be used for all the 
*                                                  input files. 
*        analysis_title        character string    the title used to describe the analysis 
*                                                  and the model. 
*        length_scale_factor   real                conversion factor from the model length 
*                                                  units to millimeters. 
*        trans_method          integer             a flag indicating whether the entire 
*                                                  model should be translated ( 0 ), only 
*                                                  the currently active group should be 
*                                                  translated ( 1 ), or only the group 
*                                                  specified by group_name should be 
*                                                  translated ( 2 ). 
*        group_name            character string    the name of the group to be translated. 
*                                                  Only applicable if trans_method = 2. 
*/ 
INTEGER trans_method, file_channel, int_array(4), group_id, num_nodes 
INTEGER node_ids(VIRTUAL), ref_coords(VIRTUAL), analy_coords(VIRTUAL), i, j 
INTEGER num_elems, elem_ids(VIRTUAL), region_ids(VIRTUAL), elem_topo_codes(VIRTUAL) 
INTEGER elem_nodes(VIRTUAL), actual_num_elems, current_topo_code 
INTEGER shape_code(2), nodes_per_elem(2), current_region, thick_field 
INTEGER num_words, max_num_words, word_ids(VIRTUAL), material_id, data_type 
INTEGER integer_scalar, field_id, node_id, frame_id, temp_ref_coords(3) 
INTEGER temp_analy_coords(3), status, num_codes 
REAL length_scale_factor, real_array(3), glob_xyz(VIRTUAL), thickness 
REAL average_thick(1), real_vector(3), node_xyzs(3,3), cent_xyz(3) 
STRING base_file_name[], analysis_title[], group_name[], char_string[31] 
logical tri_3_noded 
/* initialize variables */ 
max_num_words = 0 
/* open the control file */ 
status = text_open ( base_file_name//“.mfl”, “NW”, 0, 0, file_channel ) 
/* write out analysis title, scale factors and base filename */ 
status = text_write_string ( file_channel, analysis_title ) 
real_array(1) = length_scale_factor 
real_array(2) = length_scale_factor 
status = text_write ( file_channel, “%G% %G%”, 0, real_array,“ ” ) 
status = text_write_string ( file_channel, base_file_name ) 
/* close the control file */ 
status = text_close ( file_channel, “ ” ) 
/* open the node data file */ 
status = text_open ( base_file_name//“.nod”, “NW”, 0, 0, file_channel ) 
/* determine the id of the group to translate, zero if the entire model */ 
group_id = 0 
IF ( trans_method == 1 ) THEN 
status = db_get_current_group_id ( group_id ) 
ELSE IF ( trans_method == 2 ) THEN 
status = db_get_group_id ( group_name, group_id ) 
END IF 
/* count the number of nodes */ 
IF ( group_id == 0 ) THEN 
db_count_nodes ( num_nodes ) 
ELSE 
db_count_nodes_in_group ( group_id, num_nodes ) 
END IF 
IF ( num_nodes == 0 ) THEN 
RETURN 
END IF 
/* allocate memory for storage of the node ids and coordinates */ 
status = sys_allocate_array ( node_ids, 1, num_nodes ) 
status = sys_allocate_array ( ref_coords, 1, num_nodes ) 
status = sys_allocate_array ( analy_coords, 1, num_nodes ) 
status = sys_allocate_array ( glob_xyz, 1, num_nodes, 1, 3 ) 
/* fetch all the node ids */ 
IF ( group_id == 0 ) THEN 
status = db_get_node_ids ( num_nodes, node_ids ) 
ELSE 
status = db_get_all_node_ids_in_group ( num_nodes, group_id, node_ids ) 
END IF 
/* extract the node coordinates */ 
status = db_get_nodes ( num_nodes, node_ids, ref_coords, analy_coords, glob_xyz ) 
/* write the nodes to the node data file */ 
FOR ( i = 1 TO num_nodes ) 
real_array(1) = glob_xyz(i,1) 
real_array(2) = glob_xyz(i,2) 
real_array(3) = glob_xyz(i,3) 
status = text_write ( file_channel, “%I% %G% %G% %G%”, node_ids(i), real_array, “ ” ) 
END FOR 
/* close the node data file */ 
status = text_close ( file_channel, “ ” ) 
/* open the element data file */ 
status = text_open ( base_file_name//“.tri”, “NW”, 0, 0, file_channel ) 
/* count the number of elements */ 
IF ( group_id == 0 ) THEN 
status = db_count_elems ( num_elems ) 
ELSE 
status = db_count_elems_in_group ( group_id, num_elems ) 
END IF 
IF ( num_elems <= 0 ) THEN RETURN 
status = sys_allocate_array ( elem_ids, 1, num_elems ) 
status = sys_allocate_array ( region_ids, 1, num_elems ) 
status = sys_allocate_array ( elem_topo_codes, 1, num_elems ) 
status = sys_allocate_array ( elem_nodes, 1, num_elems, 1, 3 ) 
actual_num_elems = num_elems 
current_topo_code = 0 
tri_3_noded = FALSE 
/* fetch all the element ids */ 
IF ( group_id == 0 ) THEN 
status = db_get_elem_ids ( num_elems, elem_ids ) 
ELSE 
status = db_get_elem_ids_in_group ( num_elems, group_id, elem_ids ) 
END IF 
/* fetch the element topology codes */ 
status = db_get_elem_etop ( num_elems, elem_ids, elem_topo_codes ) 
FOR ( i = 1 TO num_elems ) 
IF ( current_topo_code != elem_topo_codes(i) ) THEN 
num_codes = 1 
int_array(1) = elem_topo_codes(i) 
int_array(2) = 1 
status = db_get_elem_topology_data ( 2, int_array, @ 
shape_code, nodes_per_elem ) 
IF ( shape_code(1) == 3 && nodes_per_elem(1) == 3 ) THEN 
tri_3_noded = TRUE 
ELSE 
tri_3_noded = FALSE 
END IF 
current_topo_code = elem_topo_codes(i) 
END IF 
IF ( !tri_3_noded ) THEN 
FOR ( j = i TO ( num_elems - 1 ) ) 
elem_ids(i) = elem_ids(i+1) 
END FOR 
actual_num_elems = actual_num_elems - 1 
END IF 
END FOR 
IF ( actual_num_elems == 0 ) THEN RETURN 
/* fetch the element connectivity */ 
status = db_get_nodes_for_elems ( actual_num_elems, 3, elem_ids, elem_nodes ) 
/* fetch the region ids for all the elements */ 
status = db_get_region_for_elements ( actual_num_elems, elem_ids, region_ids ) 
current_region = 0 
thick_field = 0 
thickness = 0.0 
FOR ( i = 1 TO actual_num_elems ) 
/* determine the thickness value for the current element */ 
IF ( region_ids(i) <= 0 ) THEN 
thick_field = 0 
thickness = 0.0 
current_region = 0 
ELSE IF ( current_region != region_ids(i) ) THEN 
/* fetch the element property record */ 
status = db_count_props ( region_ids(i), num_words ) 
IF ( num_words > 0 ) THEN 
IF ( num_words > max_num_words ) THEN 
max_num_words = num_words + 100 
status = sys_allocate_array ( word_ids, 1, max_num_words ) 
END IF 
status = db_get_props_by_region ( num_words, region_ids(i), word_ids ) 
thick_field = 0 
thickness = 0.0 
/* loop through all the property words searching for word 36: plate thickness */ 
FOR ( j = 1 TO num_words ) 
IF ( word_ids(j) == 36 ) THEN 
status = db_get_prop_value ( region_ids(i), word_ids(j), material_id, @ 
data_type, integer_scalar, real_vector, char_string, @ 
frame_id, node_id, field_id ) 
IF ( mth_abs( data_type ) == 1 || mth_abs( data_type ) == 7 ) THEN 
IF ( field_id > 0 ) THEN 
thick_field = field_id 
thickness = 0.0 
ELSE 
thick_field = 0 
thickness = real_vector(1) 
END IF 
END IF 
END IF 
END FOR 
ELSE 
thick_field = 0 
thickness = 0.0 
END IF 
current_region = region_ids(i) 
END IF 
/* if the plate thickness is a spatially varying field reference, evaluate the 
* field at the element centroid */ 
IF ( thick_field > 0 ) THEN 
/* get the coordinates of the nodes making up the element */ 
int_array(1) = elem_nodes(i,1) 
int_array(2) = elem_nodes(i,2) 
int_array(3) = elem_nodes(i,3) 
status = db_get_nodes ( 3, int_array, temp_ref_coords, @ 
temp_analy_coords, node_xyzs ) 
cent_xyz(1) = node_xyzs(1,1) + node_xyzs(2,1) + node_xyzs(3,1) 
cent_xyz(1) = cent_xyz(1) / 3.0 
cent_xyz(2) = node_xyzs(1,2) + node_xyzs(2,2) + node_xyzs(3,2) 
cent_xyz(2) = cent_xyz(2) / 3.0 
cent_xyz(3) = node_xyzs(1,3) + node_xyzs(2,3) + node_xyzs(3,3) 
cent_xyz(3) = cent_xyz(3) / 3.0 
status = get_field_values ( thick_field, 1, 3, 1, cent_xyz, average_thick ) 
ELSE 
average_thick(1) = thickness 
END IF 
/* write out the element record to the element file */ 
int_array(1) = elem_ids(i) 
int_array(2) = elem_nodes(i,1) 
int_array(3) = elem_nodes(i,2) 
int_array(4) = elem_nodes(i,3) 
status = text_write ( file_channel, “%I% %I% %I% %I% %G%”, int_array, @ 
average_thick, “ ” ) 
END FOR 
/* close the element data file */ 
status = text_close ( file_channel, “ ” ) 
END FUNCTION