xref: /petsc/src/tao/interface/ftn-custom/ztaosolverf.c (revision 609bdbee21ea3be08735c64dbe00a9ab27759925)
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     (*(void (PETSC_STDCALL *)(void*,PetscErrorCode*))(((PetscObject)tao)->fortran_func_pointers[MONDESTROY]))
165       ((void*)(PETSC_UINTPTR_T)((PetscObject)tao)->fortran_func_pointers[MONCTX],&ierr);
166     CHKERRQ(ierr);
167     return 0;
168 }
169 static PetscErrorCode ourtaoconvergencetest(Tao tao, void *ctx)
170 {
171     PetscErrorCode ierr = 0;
172     (*(void (PETSC_STDCALL *)(Tao *, void*, PetscErrorCode*))
173      (((PetscObject)tao)->fortran_func_pointers[CONVTEST]))(&tao,ctx,&ierr);
174     CHKERRQ(ierr);
175     return 0;
176 }
177 
178 
179 static PetscErrorCode ourtaoconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx)
180 {
181     PetscErrorCode ierr = 0;
182     (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*))
183        (((PetscObject)tao)->fortran_func_pointers[CONSTRAINTS]))(&tao,&x,&c,ctx,&ierr);
184     CHKERRQ(ierr);
185     return 0;
186 
187 }
188 
189 static PetscErrorCode ourtaojacobianinequalityroutine(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx)
190 {
191     PetscErrorCode ierr = 0;
192     (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*))
193      (((PetscObject)tao)->fortran_func_pointers[JACINEQ]))(&tao,&x,&J,&Jpre,ctx,&ierr); CHKERRQ(ierr);
194     return 0;
195 }
196 
197 static PetscErrorCode ourtaojacobianequalityroutine(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx)
198 {
199     PetscErrorCode ierr = 0;
200     (*(void (PETSC_STDCALL *)(Tao*,Vec*,Mat*,Mat*,void*,PetscErrorCode*))
201      (((PetscObject)tao)->fortran_func_pointers[JACEQ]))(&tao,&x,&J,&Jpre,ctx,&ierr); CHKERRQ(ierr);
202     return 0;
203 }
204 
205 static PetscErrorCode ourtaoinequalityconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx)
206 {
207     PetscErrorCode ierr = 0;
208     (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*))
209        (((PetscObject)tao)->fortran_func_pointers[CONINEQ]))(&tao,&x,&c,ctx,&ierr);
210     CHKERRQ(ierr);
211     return 0;
212 
213 }
214 
215 static PetscErrorCode ourtaoequalityconstraintsroutine(Tao tao, Vec x, Vec c, void *ctx)
216 {
217     PetscErrorCode ierr = 0;
218     (*(void (PETSC_STDCALL *)(Tao*,Vec*,Vec*,void*,PetscErrorCode*))
219        (((PetscObject)tao)->fortran_func_pointers[CONEQ]))(&tao,&x,&c,ctx,&ierr);
220     CHKERRQ(ierr);
221     return 0;
222 
223 }
224 
225 
226 EXTERN_C_BEGIN
227 
228 
229 PETSC_EXTERN void PETSC_STDCALL taosetobjectiveroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, PetscReal *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
230 {
231     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
232     if (!func) {
233         *ierr = TaoSetObjectiveRoutine(*tao,0,ctx);
234     } else {
235         ((PetscObject)*tao)->fortran_func_pointers[OBJ] = (PetscVoidFunction)func;
236         *ierr = TaoSetObjectiveRoutine(*tao, ourtaoobjectiveroutine,ctx);
237     }
238 }
239 
240 PETSC_EXTERN void PETSC_STDCALL taosetgradientroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
241 {
242     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
243     if (!func) {
244         *ierr = TaoSetGradientRoutine(*tao,0,ctx);
245     } else {
246         ((PetscObject)*tao)->fortran_func_pointers[GRAD] = (PetscVoidFunction)func;
247         *ierr = TaoSetGradientRoutine(*tao, ourtaogradientroutine,ctx);
248     }
249 }
250 
251 PETSC_EXTERN void PETSC_STDCALL taosetobjectiveandgradientroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*, Vec *, PetscReal *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
252 {
253     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
254     if (!func) {
255         *ierr = TaoSetObjectiveAndGradientRoutine(*tao,0,ctx);
256     } else {
257         ((PetscObject)*tao)->fortran_func_pointers[OBJGRAD] = (PetscVoidFunction)func;
258         *ierr = TaoSetObjectiveAndGradientRoutine(*tao, ourtaoobjectiveandgradientroutine,ctx);
259     }
260 }
261 
262 
263 
264 
265 PETSC_EXTERN void PETSC_STDCALL taosetseparableobjectiveroutine_(Tao *tao, Vec *F, void (PETSC_STDCALL *func)(Tao*, Vec *, Vec *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
266 {
267     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
268     if (!func) {
269         *ierr = TaoSetSeparableObjectiveRoutine(*tao,*F,0,ctx);
270     } else {
271         ((PetscObject)*tao)->fortran_func_pointers[SEPOBJ] = (PetscVoidFunction)func;
272         *ierr = TaoSetSeparableObjectiveRoutine(*tao,*F, ourtaoseparableobjectiveroutine,ctx);
273     }
274 }
275 
276 
277 
278 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)
279 {
280     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
281     if (!func) {
282         *ierr = TaoSetJacobianRoutine(*tao,*J,*Jp,0,ctx);
283     } else {
284         ((PetscObject)*tao)->fortran_func_pointers[JAC] = (PetscVoidFunction)func;
285         *ierr = TaoSetJacobianRoutine(*tao,*J, *Jp, ourtaojacobianroutine,ctx);
286     }
287 }
288 
289 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)
290 {
291     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
292     if (!func) {
293       *ierr = TaoSetJacobianStateRoutine(*tao,*J,*Jp,*Jinv,0,ctx);
294     } else {
295       ((PetscObject)*tao)->fortran_func_pointers[JACSTATE] = (PetscVoidFunction)func;
296       *ierr = TaoSetJacobianStateRoutine(*tao,*J, *Jp, *Jinv, ourtaojacobianstateroutine,ctx);
297     }
298 }
299 
300 PETSC_EXTERN void PETSC_STDCALL taosetjacobiandesignroutine_(Tao *tao, Mat *J, void (PETSC_STDCALL *func)(Tao*, Vec *, Mat *, void *, PetscErrorCode *), void *ctx, PetscErrorCode *ierr)
301 {
302     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
303     if (!func) {
304         *ierr = TaoSetJacobianDesignRoutine(*tao,*J,0,ctx);
305     } else {
306         ((PetscObject)*tao)->fortran_func_pointers[JACDESIGN] = (PetscVoidFunction)func;
307         *ierr = TaoSetJacobianDesignRoutine(*tao,*J, ourtaojacobiandesignroutine,ctx);
308     }
309 }
310 
311 
312 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)
313 {
314     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
315     if (!func) {
316         *ierr = TaoSetHessianRoutine(*tao,*J,*Jp,0,ctx);
317     } else {
318         ((PetscObject)*tao)->fortran_func_pointers[HESS] = (PetscVoidFunction)func;
319         *ierr = TaoSetHessianRoutine(*tao,*J, *Jp, ourtaohessianroutine,ctx);
320     }
321 }
322 
323 PETSC_EXTERN void PETSC_STDCALL taosetvariableboundsroutine_(Tao *tao, void (PETSC_STDCALL *func)(Tao*,Vec*,Vec*,void*,PetscErrorCode*),void *ctx, PetscErrorCode *ierr)
324 {
325     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
326     if (func) {
327         ((PetscObject)*tao)->fortran_func_pointers[BOUNDS] = (PetscVoidFunction)func;
328         *ierr = TaoSetVariableBoundsRoutine(*tao,ourtaoboundsroutine,ctx);
329     } else {
330         *ierr = TaoSetVariableBoundsRoutine(*tao,0,ctx);
331     }
332 
333 }
334 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)
335 {
336     PetscObjectAllocateFortranPointers(*tao,NFUNCS);
337     if (func) {
338         ((PetscObject)*tao)->fortran_func_pointers[MON] = (PetscVoidFunction)func;
339         if (FORTRANNULLFUNCTION(mondestroy)){
340           *ierr = TaoSetMonitor(*tao,ourtaomonitor,ctx,NULL);
341         } else {
342           *ierr = TaoSetMonitor(*tao,ourtaomonitor,ctx,ourtaomondestroy);
343         }
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