OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
VE_Metis_setdefaultoptions.c File Reference
#include <VE_Metis.h>

Go to the source code of this file.

Functions

int VE_Metis_setdefaultoptions (int *options)

Function Documentation

◆ VE_Metis_setdefaultoptions()

int VE_Metis_setdefaultoptions ( int * options)

Definition at line 15 of file VE_Metis_setdefaultoptions.c.

15 {
16 int ret=1;
17 int64_t symid;
18 vhcall_handle handle;
19 vhcall_args *ca;
20 uint64_t retval = -1;
21
22 char * env_metis_lib_name;
23 char metis_lib_name[ NECVH_MAX_LIBNAME ];
24
25 /*
26 * -----------------------------------------------------------------------
27 * Set the library name ( check environment )
28 * -----------------------------------------------------------------------
29 */
30
31 if ( env_metis_lib_name = getenv( "VH_MUMPS_LIBRARY" ) ) {
32 size_t lenv = strlen( env_metis_lib_name );
33 if ( strlen( env_metis_lib_name ) > (size_t)NECVH_MAX_LIBNAME ) {
34 fprintf( stdout , "%s @ %d failed : metis library name too long (%s)\n" , basename(__FILE__) , __LINE__ , env_metis_lib_name );
35 fflush( stdout );
36 (void) mumps_abort();
37 }
38 else {
39 memcpy( ( void * ) metis_lib_name , ( void * ) env_metis_lib_name , lenv * sizeof( char) );
40 metis_lib_name[ lenv ] = '\0';
41 fprintf( stdout , "%s @ %d input library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
42 fflush( stdout );
43 }
44 }
45 else {
46 strcpy( metis_lib_name , "libvh.so" );
47 }
48
49 /*
50 * -----------------------------------------------------------------------
51 * Load VH C library
52 * -----------------------------------------------------------------------
53 */
54
55 handle = vhcall_install( metis_lib_name );
56 if (handle == (vhcall_handle)-1) {
57 perror("vhcall_install");
58 fprintf( stdout , "%s @ %d failed : can't install library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
59 fprintf( stdout , "Please check your LD_LIBRARY_PATH variable\n");
60 fflush( stdout );
61 (void) mumps_abort();
62 }
63
64 /*
65 * -----------------------------------------------------------------------
66 * Find VH C library function
67 * -----------------------------------------------------------------------
68 */
69
70 symid = vhcall_find(handle, "METIS_SetDefaultOptions");
71 if ( symid == -1 ) {
72 fprintf( stdout , "%s @ %d failed : can't find symbol METIS_SetDefaultOptions\n" , basename(__FILE__) , __LINE__ );
73 perror("vhcall_find");
74 fflush( stdout );
75 (void) mumps_abort();
76 }
77
78 /*
79 * -----------------------------------------------------------------------
80 * Allocate arguments object for VH library function
81 * -----------------------------------------------------------------------
82 */
83
84 ca = vhcall_args_alloc();
85 if ( ! ca ) {
86 perror("vhcall_args_alloc");
87 fprintf( stdout , "%s @ %d failed : unable to allocate function's argument list\n" , basename(__FILE__) , __LINE__ );
88 fflush( stdout );
89 (void) mumps_abort();
90 }
91
92 /*
93 * -----------------------------------------------------------------------
94 * Set argument
95 * -----------------------------------------------------------------------
96 */
97
98 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_INOUT , 0 , options , METIS_NOPTIONS * sizeof( idx_t ) );
99 if ( ret ) {
100 perror("vhcall_args_set_pointer");
101 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
102 fflush( stdout );
103 (void) mumps_abort();
104 }
105
106 /*
107 * -----------------------------------------------------------------------
108 * Invoke VH C library function
109 * -----------------------------------------------------------------------
110 */
111
112 ret = vhcall_invoke_with_args( symid , ca , &retval );
113 if ( ret ) {
114 perror("vhcall_invoke_with_args");
115 fprintf( stdout , "%s @ %d failed : unable to invoke the symbol from library\n" , basename(__FILE__) , __LINE__ );
116 fflush( stdout );
117 (void) mumps_abort();
118 }
119
120 /*
121 * -----------------------------------------------------------------------
122 * Free args
123 * -----------------------------------------------------------------------
124 */
125
126 vhcall_args_free( ca );
127
128 /*
129 * -----------------------------------------------------------------------
130 * Uninstall the library
131 * -----------------------------------------------------------------------
132 */
133
134 if ( vhcall_uninstall( handle ) ) {
135 perror("vhcall_uninstall");
136 fprintf( stdout , "cvhmetis_nodend failed : unable to uninstall the library\n" , basename(__FILE__) , __LINE__ );
137 fflush( stdout );
138 (void) mumps_abort();
139 }
140
141 return( (int) retval );
142}
#define mumps_abort
Definition VE_Metis.h:25
#define NECVH_MAX_LIBNAME
Definition VE_Metis.h:23
void * handle