1 #include <petsc/private/fortranimpl.h> 2 #include <petsc/private/taoimpl.h> 3 4 5 #if defined(PETSC_HAVE_FORTRAN_CAPS) 6 #define taosetobjectiveroutine_ TAOSETOBJECTIVEROUTINE 7 #define taosetgradientroutine_ TAOSETGRADIENTROUTINE 8 #define taosetobjectiveandgradientroutine_ TAOSETOBJECTIVEANDGRADIENTROUTINE 9 #define taosethessianroutine_ TAOSETHESSIANROUTINE 10 #define taosetseparableobjectiveroutine_ TAOSETSEPARABLEOBJECTIVEROUTINE 11 #define taosetjacobianroutine_ TAOSETJACOBIANROUTINE 12 #define taosetjacobianstateroutine_ TAOSETJACOBIANSTATEROUTINE 13 #define taosetjacobiandesignroutine_ TAOSETJACOBIANDESIGNROUTINE 14 #define taosetjacobianinequalityroutine_ TAOSETJACOBIANINEQUALITYROUTINE 15 #define taosetjacobianequalityroutine_ TAOSETJACOBIANEQUALITYROUTINE 16 #define taosetinequalityconstraintsroutine_ TAOSETINEQUALITYCONSTRAINTSROUTINE 17 #define taosetequalityconstraintsroutine_ TAOSETEQUALITYCONSTRAINTSROUTINE 18 #define taosetvariableboundsroutine_ TAOSETVARIABLEBOUNDSROUTINE 19 #define taosetconstraintsroutine_ TAOSETCONSTRAINTSROUTINE 20 #define taosetmonitor_ TAOSETMONITOR 21 #define taosettype_ TAOSETTYPE 22 #define taoview_ TAOVIEW 23 #define taogetconvergencehistory_ TAOGETCONVERGENCEHISTORY 24 #define taosetconvergencetest_ TAOSETCONVERGENCETEST 25 #define taogetoptionsprefix_ TAOGETOPTIONSPREFIX 26 #define taosetoptionsprefix_ TAOSETOPTIONSPREFIX 27 #define taoappendoptionsprefix_ TAOAPPENDOPTIONSPREFIX 28 #define taogettype_ TAOGETTYPE 29 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 30 31 #define taosetobjectiveroutine_ taosetobjectiveroutine 32 #define taosetgradientroutine_ taosetgradientroutine 33 #define taosetobjectiveandgradientroutine_ taosetobjectiveandgradientroutine 34 #define taosethessianroutine_ taosethessianroutine 35 #define taosetseparableobjectiveroutine_ taosetseparableobjectiveroutine 36 #define taosetjacobianroutine_ taosetjacobianroutine 37 #define taosetjacobianstateroutine_ taosetjacobianstateroutine 38 #define taosetjacobiandesignroutine_ taosetjacobiandesignroutine 39 #define taosetjacobianinequalityroutine_ taosetjacobianinequalityroutine 40 #define taosetjacobianequalityroutine_ taosetjacobianequalityroutine 41 #define taosetinequalityconstraintsroutine_ taosetinequalityconstraintsroutine 42 #define taosetequalityconstraintsroutine_ taosetequalityconstraintsroutine 43 #define taosetvariableboundsroutine_ taosetvariableboundsroutine 44 #define taosetconstraintsroutine_ taosetconstraintsroutine 45 #define taosetmonitor_ taosetmonitor 46 #define taosettype_ taosettype 47 #define taoview_ taoview 48 #define taogetconvergencehistory_ taogetconvergencehistory 49 #define taosetconvergencetest_ taosetconvergencetest 50 #define taogetoptionsprefix_ taogetoptionsprefix 51 #define taosetoptionsprefix_ taosetoptionsprefix 52 #define taoappendoptionsprefix_ taoappendoptionsprefix 53 #define taogettype_ taogettype 54 #endif 55 56 static int OBJ=0; /* objective routine index */ 57 static int GRAD=1; /* gradient routine index */ 58 static int OBJGRAD=2; /* objective and gradient routine */ 59 static int HESS=3; /* hessian routine index */ 60 static int SEPOBJ=4; /* separable objective routine index */ 61 static int JAC=5; /* jacobian routine index */ 62 static int JACSTATE=6; /* jacobian state routine index */ 63 static int JACDESIGN=7; /* jacobian design routine index */ 64 static int BOUNDS=8; 65 static int MON=9; /* monitor routine index */ 66 static int MONCTX=10; /* monitor routine index */ 67 static int MONDESTROY=11; /* monitor destroy index */ 68 static int CONVTEST=12; /* */ 69 static int CONSTRAINTS=13; 70 static int JACINEQ=14; 71 static int JACEQ=15; 72 static int CONINEQ=16; 73 static int CONEQ=17; 74 static int NFUNCS=18; 75 76 static PetscErrorCode ourtaoobjectiveroutine(Tao tao, Vec x, PetscReal *f, void *ctx) 77 { 78 PetscErrorCode ierr = 0; 79 (*(void (PETSC_STDCALL *)(Tao*,Vec*,PetscReal*,void*,PetscErrorCode*)) 80 (((PetscObject)tao)->fortran_func_pointers[OBJ]))(&tao,&x,f,ctx,&ierr); 81 CHKERRQ(ierr); 82 return 0; 83 } 84 85 static PetscErrorCode ourtaogradientroutine(Tao tao, Vec x, Vec g, void *ctx) 86 { 87 PetscErrorCode ierr = 0; 88 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 89 (((PetscObject)tao)->fortran_func_pointers[GRAD]))(&tao,&x,&g,ctx,&ierr); 90 CHKERRQ(ierr); 91 return 0; 92 93 } 94 95 static PetscErrorCode ourtaoobjectiveandgradientroutine(Tao tao, Vec x, PetscReal *f, Vec g, void* ctx) 96 { 97 PetscErrorCode ierr = 0; 98 (*(void (PETSC_STDCALL *)(Tao*,Vec*,PetscReal*,Vec*,void*,PetscErrorCode*)) 99 (((PetscObject)tao)->fortran_func_pointers[OBJGRAD]))(&tao,&x,f,&g,ctx,&ierr); 100 CHKERRQ(ierr); 101 return 0; 102 } 103 104 static PetscErrorCode ourtaohessianroutine(Tao tao, Vec x, Mat H, Mat Hpre, void *ctx) 105 { 106 PetscErrorCode ierr = 0; 107 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*)) 108 (((PetscObject)tao)->fortran_func_pointers[HESS]))(&tao,&x,&H,&Hpre,ctx,&ierr); CHKERRQ(ierr); 109 return 0; 110 } 111 112 static PetscErrorCode ourtaojacobianroutine(Tao tao, Vec x, Mat H, Mat Hpre, void *ctx) 113 { 114 PetscErrorCode ierr = 0; 115 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*)) 116 (((PetscObject)tao)->fortran_func_pointers[JAC]))(&tao,&x,&H,&Hpre,ctx,&ierr); CHKERRQ(ierr); 117 return 0; 118 } 119 120 static PetscErrorCode ourtaojacobianstateroutine(Tao tao, Vec x, Mat H, Mat Hpre, Mat Hinv, void *ctx) 121 { 122 PetscErrorCode ierr = 0; 123 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,Mat*,void*,PetscErrorCode*)) 124 (((PetscObject)tao)->fortran_func_pointers[JACSTATE]))(&tao,&x,&H,&Hpre,&Hinv,ctx,&ierr); CHKERRQ(ierr); 125 return 0; 126 } 127 128 static PetscErrorCode ourtaojacobiandesignroutine(Tao tao, Vec x, Mat H, void *ctx) 129 { 130 PetscErrorCode ierr = 0; 131 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,void*,PetscErrorCode*)) 132 (((PetscObject)tao)->fortran_func_pointers[JACDESIGN]))(&tao,&x,&H,ctx,&ierr); CHKERRQ(ierr); 133 return 0; 134 } 135 136 static PetscErrorCode ourtaoboundsroutine(Tao tao, Vec xl, Vec xu, void *ctx) 137 { 138 PetscErrorCode ierr = 0; 139 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 140 (((PetscObject)tao)->fortran_func_pointers[BOUNDS]))(&tao,&xl,&xu,ctx,&ierr); CHKERRQ(ierr); 141 return 0; 142 } 143 static PetscErrorCode ourtaoseparableobjectiveroutine(Tao tao, Vec x, Vec f, void *ctx) 144 { 145 PetscErrorCode ierr = 0; 146 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 147 (((PetscObject)tao)->fortran_func_pointers[SEPOBJ]))(&tao,&x,&f,ctx,&ierr); 148 return 0; 149 } 150 151 static PetscErrorCode ourtaomonitor(Tao tao, void *ctx) 152 { 153 PetscErrorCode ierr = 0; 154 (*(void (PETSC_STDCALL *)(Tao *, void*, PetscErrorCode*)) 155 (((PetscObject)tao)->fortran_func_pointers[MON]))(&tao,ctx,&ierr); 156 CHKERRQ(ierr); 157 return 0; 158 } 159 160 static PetscErrorCode ourtaomondestroy(void **ctx) 161 { 162 PetscErrorCode ierr = 0; 163 Tao tao = *(Tao*)ctx; 164 if (((PetscObject)tao)->fortran_func_pointers[MONDESTROY]) { 165 (*(void (PETSC_STDCALL *)(void*,PetscErrorCode*))(((PetscObject)tao)->fortran_func_pointers[MONDESTROY])) 166 ((void*)(PETSC_UINTPTR_T)((PetscObject)tao)->fortran_func_pointers[MONCTX],&ierr); 167 CHKERRQ(ierr); 168 } 169 return 0; 170 } 171 static PetscErrorCode ourtaoconvergencetest(Tao tao, void *ctx) 172 { 173 PetscErrorCode ierr = 0; 174 (*(void (PETSC_STDCALL *)(Tao *, void*, PetscErrorCode*)) 175 (((PetscObject)tao)->fortran_func_pointers[CONVTEST]))(&tao,ctx,&ierr); 176 CHKERRQ(ierr); 177 return 0; 178 } 179 180 181 static PetscErrorCode ourtaoconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx) 182 { 183 PetscErrorCode ierr = 0; 184 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 185 (((PetscObject)tao)->fortran_func_pointers[CONSTRAINTS]))(&tao,&x,&c,ctx,&ierr); 186 CHKERRQ(ierr); 187 return 0; 188 189 } 190 191 static PetscErrorCode ourtaojacobianinequalityroutine(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx) 192 { 193 PetscErrorCode ierr = 0; 194 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*)) 195 (((PetscObject)tao)->fortran_func_pointers[JACINEQ]))(&tao,&x,&J,&Jpre,ctx,&ierr); CHKERRQ(ierr); 196 return 0; 197 } 198 199 static PetscErrorCode ourtaojacobianequalityroutine(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx) 200 { 201 PetscErrorCode ierr = 0; 202 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*)) 203 (((PetscObject)tao)->fortran_func_pointers[JACEQ]))(&tao,&x,&J,&Jpre,ctx,&ierr); CHKERRQ(ierr); 204 return 0; 205 } 206 207 static PetscErrorCode ourtaoinequalityconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx) 208 { 209 PetscErrorCode ierr = 0; 210 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 211 (((PetscObject)tao)->fortran_func_pointers[CONINEQ]))(&tao,&x,&c,ctx,&ierr); 212 CHKERRQ(ierr); 213 return 0; 214 215 } 216 217 static PetscErrorCode ourtaoequalityconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx) 218 { 219 PetscErrorCode ierr = 0; 220 (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*)) 221 (((PetscObject)tao)->fortran_func_pointers[CONEQ]))(&tao,&x,&c,ctx,&ierr); 222 CHKERRQ(ierr); 223 return 0; 224 225 } 226 227 228 EXTERN_C_BEGIN 229 230 231 PETSC_EXTERN void PETSC_STDCALL taosetobjectiveroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, PetscReal *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 232 { 233 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 234 if (!func) { 235 *ierr = TaoSetObjectiveRoutine(*tao,0,ctx); 236 } else { 237 ((PetscObject)*tao)->fortran_func_pointers[OBJ] = (PetscVoidFunction)func; 238 *ierr = TaoSetObjectiveRoutine(*tao, ourtaoobjectiveroutine,ctx); 239 } 240 } 241 242 PETSC_EXTERN void PETSC_STDCALL taosetgradientroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 243 { 244 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 245 if (!func) { 246 *ierr = TaoSetGradientRoutine(*tao,0,ctx); 247 } else { 248 ((PetscObject)*tao)->fortran_func_pointers[GRAD] = (PetscVoidFunction)func; 249 *ierr = TaoSetGradientRoutine(*tao, ourtaogradientroutine,ctx); 250 } 251 } 252 253 PETSC_EXTERN void PETSC_STDCALL taosetobjectiveandgradientroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, PetscReal *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 254 { 255 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 256 if (!func) { 257 *ierr = TaoSetObjectiveAndGradientRoutine(*tao,0,ctx); 258 } else { 259 ((PetscObject)*tao)->fortran_func_pointers[OBJGRAD] = (PetscVoidFunction)func; 260 *ierr = TaoSetObjectiveAndGradientRoutine(*tao, ourtaoobjectiveandgradientroutine,ctx); 261 } 262 } 263 264 265 266 267 PETSC_EXTERN void PETSC_STDCALL taosetseparableobjectiveroutine_(Tao *tao, Vec *F, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 268 { 269 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 270 if (!func) { 271 *ierr = TaoSetSeparableObjectiveRoutine(*tao,*F,0,ctx); 272 } else { 273 ((PetscObject)*tao)->fortran_func_pointers[SEPOBJ] = (PetscVoidFunction)func; 274 *ierr = TaoSetSeparableObjectiveRoutine(*tao,*F, ourtaoseparableobjectiveroutine,ctx); 275 } 276 } 277 278 279 280 PETSC_EXTERN void PETSC_STDCALL taosetjacobianroutine_(Tao *tao, Mat *J, Mat *Jp, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, Mat *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 281 { 282 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 283 if (!func) { 284 *ierr = TaoSetJacobianRoutine(*tao,*J,*Jp,0,ctx); 285 } else { 286 ((PetscObject)*tao)->fortran_func_pointers[JAC] = (PetscVoidFunction)func; 287 *ierr = TaoSetJacobianRoutine(*tao,*J, *Jp, ourtaojacobianroutine,ctx); 288 } 289 } 290 291 PETSC_EXTERN void PETSC_STDCALL taosetjacobianstateroutine_(Tao *tao, Mat *J, Mat *Jp, Mat*Jinv, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, Mat *, Mat*, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 292 { 293 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 294 if (!func) { 295 *ierr = TaoSetJacobianStateRoutine(*tao,*J,*Jp,*Jinv,0,ctx); 296 } else { 297 ((PetscObject)*tao)->fortran_func_pointers[JACSTATE] = (PetscVoidFunction)func; 298 *ierr = TaoSetJacobianStateRoutine(*tao,*J, *Jp, *Jinv, ourtaojacobianstateroutine,ctx); 299 } 300 } 301 302 PETSC_EXTERN void PETSC_STDCALL taosetjacobiandesignroutine_(Tao *tao, Mat *J, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 303 { 304 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 305 if (!func) { 306 *ierr = TaoSetJacobianDesignRoutine(*tao,*J,0,ctx); 307 } else { 308 ((PetscObject)*tao)->fortran_func_pointers[JACDESIGN] = (PetscVoidFunction)func; 309 *ierr = TaoSetJacobianDesignRoutine(*tao,*J, ourtaojacobiandesignroutine,ctx); 310 } 311 } 312 313 314 PETSC_EXTERN void PETSC_STDCALL taosethessianroutine_(Tao *tao, Mat *J, Mat *Jp, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, Mat *,void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 315 { 316 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 317 if (!func) { 318 *ierr = TaoSetHessianRoutine(*tao,*J,*Jp,0,ctx); 319 } else { 320 ((PetscObject)*tao)->fortran_func_pointers[HESS] = (PetscVoidFunction)func; 321 *ierr = TaoSetHessianRoutine(*tao,*J, *Jp, ourtaohessianroutine,ctx); 322 } 323 } 324 325 PETSC_EXTERN void PETSC_STDCALL taosetvariableboundsroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*,Vec*,Vec*,void*,PetscErrorCode*),void *ctx, PetscErrorCode *ierr) 326 { 327 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 328 if (func) { 329 ((PetscObject)*tao)->fortran_func_pointers[BOUNDS] = (PetscVoidFunction)func; 330 *ierr = TaoSetVariableBoundsRoutine(*tao,ourtaoboundsroutine,ctx); 331 } else { 332 *ierr = TaoSetVariableBoundsRoutine(*tao,0,ctx); 333 } 334 335 } 336 PETSC_EXTERN void PETSC_STDCALL taosetmonitor_(Tao *tao, void (PETSC_STDCALL *func)(Tao*,void*,PetscErrorCode*),void *ctx, void (PETSC_STDCALL *mondestroy)(void*,PetscErrorCode*),PetscErrorCode *ierr) 337 { 338 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 339 if (func) { 340 ((PetscObject)*tao)->fortran_func_pointers[MON] = (PetscVoidFunction)func; 341 CHKFORTRANNULLFUNCTION(mondestroy); 342 ((PetscObject)*tao)->fortran_func_pointers[MONDESTROY] = (PetscVoidFunction)mondestroy; 343 *ierr = TaoSetMonitor(*tao,ourtaomonitor,ctx,ourtaomondestroy); 344 } 345 } 346 347 PETSC_EXTERN void PETSC_STDCALL taosetconvergencetest_(Tao *tao, void (PETSC_STDCALL *func)(Tao*,void*,PetscErrorCode*),void *ctx, PetscErrorCode *ierr) 348 { 349 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 350 if (!func) { 351 *ierr = TaoSetConvergenceTest(*tao,0,ctx); 352 } else { 353 ((PetscObject)*tao)->fortran_func_pointers[CONVTEST] = (PetscVoidFunction)func; 354 *ierr = TaoSetConvergenceTest(*tao,ourtaoconvergencetest,ctx); 355 } 356 } 357 358 359 PETSC_EXTERN void PETSC_STDCALL taosetconstraintsroutine_(Tao *tao, Vec *C, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 360 { 361 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 362 if (!func) { 363 *ierr = TaoSetConstraintsRoutine(*tao,*C,0,ctx); 364 } else { 365 ((PetscObject)*tao)->fortran_func_pointers[CONSTRAINTS] = (PetscVoidFunction)func; 366 *ierr = TaoSetConstraintsRoutine(*tao, *C, ourtaoconstraintsroutine,ctx); 367 } 368 } 369 370 371 PETSC_EXTERN void PETSC_STDCALL taosettype_(Tao *tao, char* type_name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 372 373 { 374 char *t; 375 376 FIXCHAR(type_name,len,t); 377 *ierr = TaoSetType(*tao,t); 378 FREECHAR(type_name,t); 379 380 } 381 382 PETSC_EXTERN void PETSC_STDCALL taoview_(Tao *tao, PetscViewer *viewer, PetscErrorCode *ierr) 383 { 384 PetscViewer v; 385 PetscPatchDefaultViewers_Fortran(viewer,v); 386 *ierr = TaoView(*tao,v); 387 } 388 389 PETSC_EXTERN void PETSC_STDCALL taogetconvergencehistory_(Tao *tao, PetscInt *nhist, PetscErrorCode *ierr) 390 { 391 *ierr = TaoGetConvergenceHistory(*tao,NULL,NULL,NULL,NULL,nhist); 392 } 393 394 PETSC_EXTERN void PETSC_STDCALL taogetoptionsprefix_(Tao *tao, char* prefix PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 395 { 396 const char *name; 397 *ierr = TaoGetOptionsPrefix(*tao,&name); 398 *ierr = PetscStrncpy(prefix,name,len); if (*ierr) return; 399 FIXRETURNCHAR(PETSC_TRUE,prefix,len); 400 401 } 402 403 PETSC_EXTERN void PETSC_STDCALL taoappendoptionsprefix_(Tao *tao, char* prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 404 { 405 char *name; 406 FIXCHAR(prefix,len,name); 407 *ierr = TaoAppendOptionsPrefix(*tao,name); 408 FREECHAR(prefix,name); 409 } 410 411 PETSC_EXTERN void PETSC_STDCALL taosetoptionsprefix_(Tao *tao, char* prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 412 { 413 char *t; 414 FIXCHAR(prefix,len,t); 415 *ierr = TaoSetOptionsPrefix(*tao,t); 416 FREECHAR(prefix,t); 417 } 418 419 PETSC_EXTERN void PETSC_STDCALL taogettype_(Tao *tao, char* name PETSC_MIXED_LEN(len), PetscErrorCode *ierr PETSC_END_LEN(len)) 420 { 421 const char *tname; 422 *ierr = TaoGetType(*tao,&tname); 423 *ierr = PetscStrncpy(name,tname,len); if (*ierr) return; 424 FIXRETURNCHAR(PETSC_TRUE,name,len); 425 426 } 427 428 429 PETSC_EXTERN void PETSC_STDCALL taosetjacobianinequalityroutine_(Tao *tao, Mat *J, Mat *Jp, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, Mat *,void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 430 { 431 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 432 if (!func) { 433 *ierr = TaoSetJacobianInequalityRoutine(*tao,*J,*Jp,0,ctx); 434 } else { 435 ((PetscObject)*tao)->fortran_func_pointers[JACINEQ] = (PetscVoidFunction)func; 436 *ierr = TaoSetJacobianInequalityRoutine(*tao,*J, *Jp, ourtaojacobianinequalityroutine,ctx); 437 } 438 } 439 440 PETSC_EXTERN void PETSC_STDCALL taosetjacobianequalityroutine_(Tao *tao, Mat *J, Mat *Jp, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, Mat *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 441 { 442 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 443 if (!func) { 444 *ierr = TaoSetJacobianEqualityRoutine(*tao,*J,*Jp,0,ctx); 445 } else { 446 ((PetscObject)*tao)->fortran_func_pointers[JACEQ] = (PetscVoidFunction)func; 447 *ierr = TaoSetJacobianEqualityRoutine(*tao,*J, *Jp, ourtaojacobianequalityroutine,ctx); 448 } 449 } 450 451 452 PETSC_EXTERN void PETSC_STDCALL taosetinequalityconstraintsroutine_(Tao *tao, Vec *C, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 453 { 454 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 455 if (!func) { 456 *ierr = TaoSetInequalityConstraintsRoutine(*tao,*C,0,ctx); 457 } else { 458 ((PetscObject)*tao)->fortran_func_pointers[CONINEQ] = (PetscVoidFunction)func; 459 *ierr = TaoSetInequalityConstraintsRoutine(*tao, *C, ourtaoinequalityconstraintsroutine,ctx); 460 } 461 } 462 463 PETSC_EXTERN void PETSC_STDCALL taosetequalityconstraintsroutine_(Tao *tao, Vec *C, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr) 464 { 465 PetscObjectAllocateFortranPointers(*tao,NFUNCS); 466 if (!func) { 467 *ierr = TaoSetEqualityConstraintsRoutine(*tao,*C,0,ctx); 468 } else { 469 ((PetscObject)*tao)->fortran_func_pointers[CONEQ] = (PetscVoidFunction)func; 470 *ierr = TaoSetEqualityConstraintsRoutine(*tao, *C, ourtaoequalityconstraintsroutine,ctx); 471 } 472 } 473 474 475 EXTERN_C_END 476 477 478