| 1906 |
jroman |
1 |
/*
|
|
|
2 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
3 |
SLEPc - Scalable Library for Eigenvalue Problem Computations
|
| 2116 |
eromero |
4 |
Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
|
| 1906 |
jroman |
5 |
|
|
|
6 |
This file is part of SLEPc.
|
|
|
7 |
|
|
|
8 |
SLEPc is free software: you can redistribute it and/or modify it under the
|
|
|
9 |
terms of version 3 of the GNU Lesser General Public License as published by
|
|
|
10 |
the Free Software Foundation.
|
|
|
11 |
|
|
|
12 |
SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
14 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
|
15 |
more details.
|
|
|
16 |
|
|
|
17 |
You should have received a copy of the GNU Lesser General Public License
|
|
|
18 |
along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
|
|
|
19 |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
#include "private/fortranimpl.h"
|
|
|
23 |
#include "slepcqep.h"
|
|
|
24 |
#include "private/qepimpl.h"
|
|
|
25 |
|
|
|
26 |
#ifdef PETSC_HAVE_FORTRAN_CAPS
|
|
|
27 |
#define qepview_ QEPVIEW
|
|
|
28 |
#define qepsetoptionsprefix_ QEPSETOPTIONSPREFIX
|
|
|
29 |
#define qepappendoptionsprefix_ QEPAPPENDOPTIONSPREFIX
|
|
|
30 |
#define qepgetoptionsprefix_ QEPGETOPTIONSPREFIX
|
|
|
31 |
#define qepcreate_ QEPCREATE
|
|
|
32 |
#define qepsettype_ QEPSETTYPE
|
|
|
33 |
#define qepgettype_ QEPGETTYPE
|
| 2054 |
eromero |
34 |
#define qepmonitorall_ QEPMONITORALL
|
| 1906 |
jroman |
35 |
#define qepmonitorlg_ QEPMONITORLG
|
| 2054 |
eromero |
36 |
#define qepmonitorlgall_ QEPMONITORLGALL
|
| 1906 |
jroman |
37 |
#define qepmonitorset_ QEPMONITORSET
|
|
|
38 |
#define qepmonitorconverged_ QEPMONITORCONVERGED
|
|
|
39 |
#define qepmonitorfirst_ QEPMONITORFIRST
|
|
|
40 |
#define qepgetip_ QEPGETIP
|
|
|
41 |
#define qepgetwhicheigenpairs_ QEPGETWHICHEIGENPAIRS
|
|
|
42 |
#define qepgetproblemtype_ QEPGETPROBLEMTYPE
|
|
|
43 |
#define qepgetconvergedreason_ QEPGETCONVERGEDREASON
|
|
|
44 |
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
|
|
|
45 |
#define qepview_ qepview
|
|
|
46 |
#define qepsetoptionsprefix_ qepsetoptionsprefix
|
|
|
47 |
#define qepappendoptionsprefix_ qepappendoptionsprefix
|
|
|
48 |
#define qepgetoptionsprefix_ qepgetoptionsprefix
|
|
|
49 |
#define qepcreate_ qepcreate
|
|
|
50 |
#define qepsettype_ qepsettype
|
|
|
51 |
#define qepgettype_ qepgettype
|
| 2054 |
eromero |
52 |
#define qepmonitorall_ qepmonitorall
|
|
|
53 |
#define qepmonitorlg_ qepmonitorlg
|
|
|
54 |
#define qepmonitorlgall_ qepmonitorlgall
|
| 1906 |
jroman |
55 |
#define qepmonitorset_ qepmonitorset
|
|
|
56 |
#define qepmonitorconverged_ qepmonitorconverged
|
|
|
57 |
#define qepmonitorfirst_ qepmonitorfirst
|
|
|
58 |
#define qepgetip_ qepgetip
|
|
|
59 |
#define qepgetwhicheigenpairs_ qepgetwhicheigenpairs
|
|
|
60 |
#define qepgetproblemtype_ qepgetproblemtype
|
|
|
61 |
#define qepgetconvergedreason_ qepgetconvergedreason
|
|
|
62 |
#endif
|
|
|
63 |
|
|
|
64 |
EXTERN_C_BEGIN
|
|
|
65 |
|
|
|
66 |
/*
|
|
|
67 |
These are not usually called from Fortran but allow Fortran users
|
|
|
68 |
to transparently set these monitors from .F code, hence no STDCALL
|
|
|
69 |
*/
|
| 2054 |
eromero |
70 |
void qepmonitorall_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)
|
| 1906 |
jroman |
71 |
{
|
| 2054 |
eromero |
72 |
*ierr = QEPMonitorAll(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
| 1906 |
jroman |
73 |
}
|
|
|
74 |
|
|
|
75 |
void qepmonitorlg_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)
|
|
|
76 |
{
|
|
|
77 |
*ierr = QEPMonitorLG(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
|
|
78 |
}
|
|
|
79 |
|
| 2054 |
eromero |
80 |
void qepmonitorlgall_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)
|
|
|
81 |
{
|
|
|
82 |
*ierr = QEPMonitorLGAll(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
|
|
83 |
}
|
|
|
84 |
|
| 1906 |
jroman |
85 |
void qepmonitorconverged_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)
|
|
|
86 |
{
|
|
|
87 |
*ierr = QEPMonitorConverged(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
void qepmonitorfirst_(QEP *qep,PetscInt *it,PetscInt *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,PetscInt *nest,void *ctx,PetscErrorCode *ierr)
|
|
|
91 |
{
|
|
|
92 |
*ierr = QEPMonitorFirst(*qep,*it,*nconv,eigr,eigi,errest,*nest,ctx);
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
EXTERN_C_END
|
|
|
96 |
|
|
|
97 |
/* These are not extern C because they are passed into non-extern C user level functions */
|
|
|
98 |
static PetscErrorCode ourmonitor(QEP qep,PetscInt i,PetscInt nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,PetscInt l,void* ctx)
|
|
|
99 |
{
|
|
|
100 |
PetscErrorCode ierr = 0;
|
|
|
101 |
void *mctx = (void*) ((PetscObject)qep)->fortran_func_pointers[1];
|
|
|
102 |
(*(void (PETSC_STDCALL *)(QEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*))
|
|
|
103 |
(((PetscObject)qep)->fortran_func_pointers[0]))(&qep,&i,&nc,er,ei,d,&l,mctx,&ierr);CHKERRQ(ierr);
|
|
|
104 |
return 0;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
static PetscErrorCode ourdestroy(void* ctx)
|
|
|
108 |
{
|
|
|
109 |
PetscErrorCode ierr = 0;
|
|
|
110 |
QEP qep = (QEP)ctx;
|
|
|
111 |
void *mctx = (void*) ((PetscObject)qep)->fortran_func_pointers[1];
|
|
|
112 |
(*(void (PETSC_STDCALL *)(void*,PetscErrorCode*))(((PetscObject)qep)->fortran_func_pointers[2]))(mctx,&ierr);CHKERRQ(ierr);
|
|
|
113 |
return 0;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
EXTERN_C_BEGIN
|
|
|
117 |
|
|
|
118 |
void PETSC_STDCALL qepview_(QEP *qep,PetscViewer *viewer, PetscErrorCode *ierr)
|
|
|
119 |
{
|
|
|
120 |
PetscViewer v;
|
|
|
121 |
PetscPatchDefaultViewers_Fortran(viewer,v);
|
|
|
122 |
*ierr = QEPView(*qep,v);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
void PETSC_STDCALL qepsettype_(QEP *qep,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
126 |
{
|
|
|
127 |
char *t;
|
|
|
128 |
|
|
|
129 |
FIXCHAR(type,len,t);
|
|
|
130 |
*ierr = QEPSetType(*qep,t);
|
|
|
131 |
FREECHAR(type,t);
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
void PETSC_STDCALL qepgettype_(QEP *qep,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
135 |
{
|
|
|
136 |
const QEPType tname;
|
|
|
137 |
|
|
|
138 |
*ierr = QEPGetType(*qep,&tname);if (*ierr) return;
|
|
|
139 |
*ierr = PetscStrncpy(name,tname,len);
|
|
|
140 |
FIXRETURNCHAR(PETSC_TRUE,name,len);
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
void PETSC_STDCALL qepsetoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
144 |
{
|
|
|
145 |
char *t;
|
|
|
146 |
|
|
|
147 |
FIXCHAR(prefix,len,t);
|
|
|
148 |
*ierr = QEPSetOptionsPrefix(*qep,t);
|
|
|
149 |
FREECHAR(prefix,t);
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
void PETSC_STDCALL qepappendoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
153 |
{
|
|
|
154 |
char *t;
|
|
|
155 |
|
|
|
156 |
FIXCHAR(prefix,len,t);
|
|
|
157 |
*ierr = QEPAppendOptionsPrefix(*qep,t);
|
|
|
158 |
FREECHAR(prefix,t);
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
void PETSC_STDCALL qepcreate_(MPI_Fint *comm,QEP *qep,PetscErrorCode *ierr)
|
|
|
162 |
{
|
|
|
163 |
*ierr = QEPCreate(MPI_Comm_f2c(*(comm)),qep);
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
void PETSC_STDCALL qepmonitorset_(QEP *qep,void (PETSC_STDCALL *monitor)(QEP*,PetscInt*,PetscInt*,PetscScalar*,PetscScalar*,PetscReal*,PetscInt*,void*,PetscErrorCode*),
|
|
|
167 |
void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode *),PetscErrorCode *ierr)
|
|
|
168 |
{
|
|
|
169 |
CHKFORTRANNULLFUNCTION(monitordestroy);
|
|
|
170 |
PetscObjectAllocateFortranPointers(*qep,3);
|
| 2054 |
eromero |
171 |
if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorall_) {
|
|
|
172 |
*ierr = QEPMonitorSet(*qep,QEPMonitorAll,0,0);
|
| 1906 |
jroman |
173 |
} else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorlg_) {
|
|
|
174 |
*ierr = QEPMonitorSet(*qep,QEPMonitorLG,0,0);
|
| 2054 |
eromero |
175 |
} else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorlgall_) {
|
|
|
176 |
*ierr = QEPMonitorSet(*qep,QEPMonitorLGAll,0,0);
|
| 1906 |
jroman |
177 |
} else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorconverged_) {
|
|
|
178 |
*ierr = QEPMonitorSet(*qep,QEPMonitorConverged,0,0);
|
|
|
179 |
} else if ((PetscVoidFunction)monitor == (PetscVoidFunction)qepmonitorfirst_) {
|
|
|
180 |
*ierr = QEPMonitorSet(*qep,QEPMonitorFirst,0,0);
|
|
|
181 |
} else {
|
|
|
182 |
((PetscObject)*qep)->fortran_func_pointers[0] = (PetscVoidFunction)monitor;
|
|
|
183 |
((PetscObject)*qep)->fortran_func_pointers[1] = (PetscVoidFunction)mctx;
|
|
|
184 |
if (FORTRANNULLFUNCTION(monitordestroy)) {
|
|
|
185 |
*ierr = QEPMonitorSet(*qep,ourmonitor,*qep,0);
|
|
|
186 |
} else {
|
|
|
187 |
((PetscObject)*qep)->fortran_func_pointers[2] = (PetscVoidFunction)monitordestroy;
|
|
|
188 |
*ierr = QEPMonitorSet(*qep,ourmonitor,*qep,ourdestroy);
|
|
|
189 |
}
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
void PETSC_STDCALL qepgetoptionsprefix_(QEP *qep,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
|
|
|
194 |
{
|
|
|
195 |
const char *tname;
|
|
|
196 |
|
|
|
197 |
*ierr = QEPGetOptionsPrefix(*qep,&tname); if (*ierr) return;
|
|
|
198 |
*ierr = PetscStrncpy(prefix,tname,len);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
void PETSC_STDCALL qepgetip_(QEP *qep,IP *ip,PetscErrorCode *ierr)
|
|
|
202 |
{
|
|
|
203 |
*ierr = QEPGetIP(*qep,ip);
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
void PETSC_STDCALL qepgetwhicheigenpairs_(QEP *qep,QEPWhich *which,PetscErrorCode *ierr)
|
|
|
207 |
{
|
|
|
208 |
*ierr = QEPGetWhichEigenpairs(*qep,which);
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
void PETSC_STDCALL qepgetproblemtype_(QEP *qep,QEPProblemType *type,PetscErrorCode *ierr)
|
|
|
212 |
{
|
|
|
213 |
*ierr = QEPGetProblemType(*qep,type);
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
void PETSC_STDCALL qepgetconvergedreason_(QEP *qep,QEPConvergedReason *reason,PetscErrorCode *ierr)
|
|
|
217 |
{
|
|
|
218 |
*ierr = QEPGetConvergedReason(*qep,reason);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
EXTERN_C_END
|
|
|
222 |
|