15 {
16 int ret=1;
17 int64_t symid;
19 vhcall_args *ca;
20 uint64_t retval = -1;
21
22 char * env_metis_lib_name;
24
25
26
27
28
29
30
31 if ( env_metis_lib_name = getenv( "VH_MUMPS_LIBRARY" ) ) {
32 size_t lenv = strlen( env_metis_lib_name );
34 fprintf( stdout , "%s @ %d failed : metis library name too long (%s)\n" , basename(__FILE__) , __LINE__ , env_metis_lib_name );
35 fflush( stdout );
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
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 );
62 }
63
64
65
66
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 );
76 }
77
78
79
80
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 );
90 }
91
92
93
94
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 );
104 }
105
106
107
108
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 );
118 }
119
120
121
122
123
124
125
126 vhcall_args_free( ca );
127
128
129
130
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 );
139 }
140
141 return( (int) retval );
142}
#define NECVH_MAX_LIBNAME