| 986 |
slepc |
1 |
|
|
|
2 |
#include "zpetsc.h"
|
|
|
3 |
#include "slepceps.h"
|
|
|
4 |
#include "src/eps/epsimpl.h"
|
|
|
5 |
|
|
|
6 |
#ifdef PETSC_HAVE_FORTRAN_CAPS
|
|
|
7 |
#define epsview_ EPSVIEW
|
|
|
8 |
#define epssetoptionsprefix_ EPSSETOPTIONSPREFIX
|
|
|
9 |
#define epsappendoptionsprefix_ EPSAPPENDOPTIONSPREFIX
|
|
|
10 |
#define epsgetoptionsprefix_ EPSGETOPTIONSPREFIX
|
|
|
11 |
#define epscreate_ EPSCREATE
|
|
|
12 |
#define epssettype_ EPSSETTYPE
|
|
|
13 |
#define epsgettype_ EPSGETTYPE
|
| 1021 |
slepc |
14 |
#define epsdefaultmonitor_ EPSDEFAULTMONITOR
|
| 986 |
slepc |
15 |
#define epssetmonitor_ EPSSETMONITOR
|
| 1021 |
slepc |
16 |
#define epsgetst_ EPSGETST
|
| 986 |
slepc |
17 |
#define epsgetwhicheigenpairs_ EPSGETWHICHEIGENPAIRS
|
|
|
18 |
#define epsgetproblemtype_ EPSGETPROBLEMTYPE
|
| 1021 |
slepc |
19 |
#define epsgetclass_ EPSGETCLASS
|
|
|
20 |
#define epsgetconvergedreason_ EPSGETCONVERGEDREASON
|
| 986 |
slepc |
21 |
#define epsgetorthogonalization_ EPSGETORTHOGONALIZATION
|
|
|
22 |
#define epspowergetshifttype_ EPSPOWERGETSHIFTTYPE
|
| 1021 |
slepc |
23 |
#define epslanczosgetreorthog_ EPSLANCZOSGETREORTHOG
|
| 986 |
slepc |
24 |
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
|
|
|
25 |
#define epsview_ epsview
|
|
|
26 |
#define epssetoptionsprefix_ epssetoptionsprefix
|
|
|
27 |
#define epsappendoptionsprefix_ epsappendoptionsprefix
|
|
|
28 |
#define epsgetoptionsprefix_ epsgetoptionsprefix
|
|
|
29 |
#define epscreate_ epscreate
|
|
|
30 |
#define epssettype_ epssettype
|
|
|
31 |
#define epsgettype_ epsgettype
|
| 1021 |
slepc |
32 |
#define epsdefaultmonitor_ epsdefaultmonitor
|
| 986 |
slepc |
33 |
#define epssetmonitor_ epssetmonitor
|
| 1021 |
slepc |
34 |
#define epsgetst_ epsgetst
|
| 986 |
slepc |
35 |
#define epsgetwhicheigenpairs_ epsgetwhicheigenpairs
|
|
|
36 |
#define epsgetproblemtype_ epsgetproblemtype
|
| 1021 |
slepc |
37 |
#define epsgetclass_ epsgetclass
|
|
|
38 |
#define epsgetconvergedreason_ epsgetconvergedreason
|
| 986 |
slepc |
39 |
#define epsgetorthogonalization_ epsgetorthogonalization
|
|
|
40 |
#define epspowergetshifttype_ epspowergetshifttype
|
|
|
41 |
#define epslanczosgetreorthog_ epslanczosgetreorthog
|
|
|
42 |
#endif
|
|
|
43 |
|
|
|
44 |
EXTERN_C_BEGIN
|
| 1027 |
slepc |
45 |
static void (PETSC_STDCALL *f1)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,int*);
|
|
|
46 |
/*
|
|
|
47 |
These are not usually called from Fortran but allow Fortran users
|
|
|
48 |
to transparently set these monitors from .F code, hence no STDCALL
|
|
|
49 |
*/
|
|
|
50 |
void epsdefaultmonitor_(EPS *eps,int *it,int *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,int *nest,void *ctx,PetscErrorCode *ierr)
|
|
|
51 |
{
|
|
|
52 |
*ierr = EPSDefaultMonitor(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
|
|
53 |
}
|
|
|
54 |
EXTERN_C_END
|
|
|
55 |
|
|
|
56 |
/* These are not extern C because they are passed into non-extern C user level functions */
|
|
|
57 |
static PetscErrorCode ourmonitor(EPS eps,int i,int nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,int l,void* ctx)
|
|
|
58 |
{
|
|
|
59 |
int ierr = 0;
|
|
|
60 |
(*f1)(&eps,&i,&nc,er,ei,d,&l,ctx,&ierr);CHKERRQ(ierr);
|
|
|
61 |
return 0;
|
|
|
62 |
}
|
| 986 |
slepc |
63 |
|
| 1027 |
slepc |
64 |
EXTERN_C_BEGIN
|
|
|
65 |
|
| 986 |
slepc |
66 |
void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer, PetscErrorCode *ierr)
|
|
|
67 |
{
|
|
|
68 |
PetscViewer v;
|
|
|
69 |
PetscPatchDefaultViewers_Fortran(viewer,v);
|
|
|
70 |
*ierr = EPSView(*eps,v);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
74 |
{
|
|
|
75 |
char *t;
|
|
|
76 |
|
|
|
77 |
FIXCHAR(type,len,t);
|
|
|
78 |
*ierr = EPSSetType(*eps,t);
|
|
|
79 |
FREECHAR(type,t);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
83 |
{
|
| 1004 |
slepc |
84 |
const char *tname;
|
| 986 |
slepc |
85 |
|
|
|
86 |
*ierr = EPSGetType(*eps,&tname);if (*ierr) return;
|
|
|
87 |
#if defined(PETSC_USES_CPTOFCD)
|
|
|
88 |
{
|
|
|
89 |
char *t = _fcdtocp(name); int len1 = _fcdlen(name);
|
|
|
90 |
*ierr = PetscStrncpy(t,tname,len1);
|
|
|
91 |
}
|
|
|
92 |
#else
|
|
|
93 |
*ierr = PetscStrncpy(name,tname,len);
|
|
|
94 |
#endif
|
|
|
95 |
FIXRETURNCHAR(name,len);
|
|
|
96 |
}
|
|
|
97 |
|
| 1027 |
slepc |
98 |
void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
| 986 |
slepc |
99 |
{
|
|
|
100 |
char *t;
|
|
|
101 |
|
|
|
102 |
FIXCHAR(prefix,len,t);
|
|
|
103 |
*ierr = EPSSetOptionsPrefix(*eps,t);
|
|
|
104 |
FREECHAR(prefix,t);
|
|
|
105 |
}
|
|
|
106 |
|
| 1027 |
slepc |
107 |
void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
| 986 |
slepc |
108 |
{
|
|
|
109 |
char *t;
|
|
|
110 |
|
|
|
111 |
FIXCHAR(prefix,len,t);
|
|
|
112 |
*ierr = EPSAppendOptionsPrefix(*eps,t);
|
|
|
113 |
FREECHAR(prefix,t);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
void PETSC_STDCALL epscreate_(MPI_Comm *comm,EPS *eps,PetscErrorCode *ierr){
|
|
|
117 |
*ierr = EPSCreate((MPI_Comm)PetscToPointerComm(*comm),eps);
|
|
|
118 |
}
|
|
|
119 |
|
| 1027 |
slepc |
120 |
void PETSC_STDCALL epssetmonitor_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,int*),void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,int *),PetscErrorCode *ierr)
|
| 986 |
slepc |
121 |
{
|
|
|
122 |
if ((void(*)())monitor == (void(*)())epsdefaultmonitor_) {
|
|
|
123 |
*ierr = EPSSetMonitor(*eps,EPSDefaultMonitor,0);
|
|
|
124 |
} else {
|
|
|
125 |
f1 = monitor;
|
|
|
126 |
if (FORTRANNULLFUNCTION(monitordestroy)) {
|
|
|
127 |
*ierr = EPSSetMonitor(*eps,ourmonitor,mctx);
|
|
|
128 |
} else {
|
|
|
129 |
*ierr = EPSSetMonitor(*eps,ourmonitor,mctx);
|
|
|
130 |
}
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
135 |
{
|
|
|
136 |
const char *tname;
|
|
|
137 |
|
|
|
138 |
*ierr = EPSGetOptionsPrefix(*eps,&tname);
|
|
|
139 |
#if defined(PETSC_USES_CPTOFCD)
|
|
|
140 |
{
|
|
|
141 |
char *t = _fcdtocp(prefix); int len1 = _fcdlen(prefix);
|
|
|
142 |
*ierr = PetscStrncpy(t,tname,len1); if (*ierr) return;
|
|
|
143 |
}
|
|
|
144 |
#else
|
|
|
145 |
*ierr = PetscStrncpy(prefix,tname,len); if (*ierr) return;
|
|
|
146 |
#endif
|
|
|
147 |
FIXRETURNCHAR(prefix,len);
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
void PETSC_STDCALL epsgetst_(EPS *eps,ST *st,int *ierr)
|
|
|
151 |
{
|
|
|
152 |
*ierr = EPSGetST(*eps,st);
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
void PETSC_STDCALL epsgetwhicheigenpairs_(EPS *eps,EPSWhich *which,int *ierr)
|
|
|
156 |
{
|
|
|
157 |
*ierr = EPSGetWhichEigenpairs(*eps,which);
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
void PETSC_STDCALL epsgetproblemtype_(EPS *eps,EPSProblemType *type,int *ierr)
|
|
|
161 |
{
|
|
|
162 |
*ierr = EPSGetProblemType(*eps,type);
|
|
|
163 |
}
|
|
|
164 |
|
| 1021 |
slepc |
165 |
void PETSC_STDCALL epsgetclass_(EPS *eps,EPSClass *cl,int *ierr)
|
|
|
166 |
{
|
|
|
167 |
*ierr = EPSGetClass(*eps,cl);
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
void PETSC_STDCALL epsgetconvergedreason_(EPS *eps,EPSConvergedReason *reason,int *ierr)
|
|
|
171 |
{
|
|
|
172 |
*ierr = EPSGetConvergedReason(*eps,reason);
|
|
|
173 |
}
|
|
|
174 |
|
| 986 |
slepc |
175 |
void PETSC_STDCALL epsgetorthogonalization_(EPS *eps,EPSOrthogonalizationType *type,EPSOrthogonalizationRefinementType *refinement,PetscReal *eta,int *ierr)
|
|
|
176 |
{
|
|
|
177 |
*ierr = EPSGetOrthogonalization(*eps,type,refinement,eta);
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
void PETSC_STDCALL epspowergetshifttype_(EPS *eps,EPSPowerShiftType *shift,int *ierr)
|
|
|
181 |
{
|
|
|
182 |
*ierr = EPSPowerGetShiftType(*eps,shift);
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
void PETSC_STDCALL epslanczosgetreorthog_(EPS *eps,EPSLanczosReorthogType *reorthog,int *ierr)
|
|
|
186 |
{
|
|
|
187 |
*ierr = EPSLanczosGetReorthog(*eps,reorthog);
|
|
|
188 |
}
|
|
|
189 |
EXTERN_C_END
|
|
|
190 |
|