Subversion Repositories slepc-dev

Rev

Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1376 slepc 1
/*
2
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
      SLEPc - Scalable Library for Eigenvalue Problem Computations
4
      Copyright (c) 2002-2007, Universidad Politecnica de Valencia, Spain
986 slepc 5
 
1376 slepc 6
      This file is part of SLEPc. See the README file for conditions of use
7
      and additional information.
8
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9
*/
10
 
986 slepc 11
#include "zpetsc.h"
12
#include "slepceps.h"
13
#include "src/eps/epsimpl.h"
14
 
15
#ifdef PETSC_HAVE_FORTRAN_CAPS
16
#define epsview_                    EPSVIEW
17
#define epssetoptionsprefix_        EPSSETOPTIONSPREFIX
18
#define epsappendoptionsprefix_     EPSAPPENDOPTIONSPREFIX
19
#define epsgetoptionsprefix_        EPSGETOPTIONSPREFIX
20
#define epscreate_                  EPSCREATE
21
#define epssettype_                 EPSSETTYPE          
22
#define epsgettype_                 EPSGETTYPE
1331 slepc 23
#define epsmonitordefault_          EPSMONITORDEFAULT
24
#define epsmonitorlg_               EPSMONITORLG
25
#define epsmonitorset_              EPSMONITORSET
1021 slepc 26
#define epsgetst_                   EPSGETST
1345 slepc 27
#define epsgetip_                   EPSGETIP
986 slepc 28
#define epsgetwhicheigenpairs_      EPSGETWHICHEIGENPAIRS
29
#define epsgetproblemtype_          EPSGETPROBLEMTYPE
1021 slepc 30
#define epsgetclass_                EPSGETCLASS
31
#define epsgetconvergedreason_      EPSGETCONVERGEDREASON
986 slepc 32
#define epspowergetshifttype_       EPSPOWERGETSHIFTTYPE
1021 slepc 33
#define epslanczosgetreorthog_      EPSLANCZOSGETREORTHOG
986 slepc 34
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
35
#define epsview_                    epsview
36
#define epssetoptionsprefix_        epssetoptionsprefix
37
#define epsappendoptionsprefix_     epsappendoptionsprefix
38
#define epsgetoptionsprefix_        epsgetoptionsprefix
39
#define epscreate_                  epscreate
40
#define epssettype_                 epssettype          
41
#define epsgettype_                 epsgettype
1331 slepc 42
#define epsmonitordefault_          epsmonitordefault
43
#define epsmonitorlg_               epsmonitorlg
44
#define epsmonitorset_              epsmonitorset
1021 slepc 45
#define epsgetst_                   epsgetst
1345 slepc 46
#define epsgetip_                   epsgetip
986 slepc 47
#define epsgetwhicheigenpairs_      epsgetwhicheigenpairs
48
#define epsgetproblemtype_          epsgetproblemtype
1021 slepc 49
#define epsgetclass_                epsgetclass
50
#define epsgetconvergedreason_      epsgetconvergedreason
986 slepc 51
#define epspowergetshifttype_       epspowergetshifttype
52
#define epslanczosgetreorthog_      epslanczosgetreorthog
53
#endif
54
 
55
EXTERN_C_BEGIN
1287 slepc 56
static void (PETSC_STDCALL *f1)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,PetscErrorCode*);
57
static void (PETSC_STDCALL *f2)(void*,PetscErrorCode*);
58
 
1027 slepc 59
/*
60
   These are not usually called from Fortran but allow Fortran users
61
   to transparently set these monitors from .F code, hence no STDCALL
62
*/
1331 slepc 63
void epsmonitordefault_(EPS *eps,int *it,int *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,int *nest,void *ctx,PetscErrorCode *ierr)
1027 slepc 64
{
1331 slepc 65
  *ierr = EPSMonitorDefault(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx);
1027 slepc 66
}
1287 slepc 67
 
1331 slepc 68
void epsmonitorlg_(EPS *eps,int *it,int *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,int *nest,void *ctx,PetscErrorCode *ierr)
1287 slepc 69
{
1331 slepc 70
  *ierr = EPSMonitorLG(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx);
1287 slepc 71
}
1027 slepc 72
EXTERN_C_END
73
 
74
/* These are not extern C because they are passed into non-extern C user level functions */
75
static PetscErrorCode ourmonitor(EPS eps,int i,int nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,int l,void* ctx)
76
{
1287 slepc 77
  PetscErrorCode ierr = 0;
1027 slepc 78
  (*f1)(&eps,&i,&nc,er,ei,d,&l,ctx,&ierr);CHKERRQ(ierr);
79
  return 0;
80
}
986 slepc 81
 
1287 slepc 82
static PetscErrorCode ourdestroy(void* ctx)
83
{
84
  PetscErrorCode ierr = 0;
85
  (*f2)(ctx,&ierr);CHKERRQ(ierr);
86
  return 0;
87
}
88
 
1027 slepc 89
EXTERN_C_BEGIN
90
 
986 slepc 91
void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer, PetscErrorCode *ierr)
92
{
93
  PetscViewer v;
94
  PetscPatchDefaultViewers_Fortran(viewer,v);
95
  *ierr = EPSView(*eps,v);
96
}
97
 
98
void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
99
{
100
  char *t;
101
 
102
  FIXCHAR(type,len,t);
103
  *ierr = EPSSetType(*eps,t);
104
  FREECHAR(type,t);
105
}
106
 
107
void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
108
{
1004 slepc 109
  const char *tname;
986 slepc 110
 
111
  *ierr = EPSGetType(*eps,&tname);if (*ierr) return;
112
#if defined(PETSC_USES_CPTOFCD)
113
  {
114
    char *t = _fcdtocp(name); int len1 = _fcdlen(name);
115
    *ierr = PetscStrncpy(t,tname,len1);
116
  }
117
#else
118
  *ierr = PetscStrncpy(name,tname,len);
119
#endif
120
  FIXRETURNCHAR(name,len);
121
}
122
 
1027 slepc 123
void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 124
{
125
  char *t;
126
 
127
  FIXCHAR(prefix,len,t);
128
  *ierr = EPSSetOptionsPrefix(*eps,t);
129
  FREECHAR(prefix,t);
130
}
131
 
1027 slepc 132
void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 133
{
134
  char *t;
135
 
136
  FIXCHAR(prefix,len,t);
137
  *ierr = EPSAppendOptionsPrefix(*eps,t);
138
  FREECHAR(prefix,t);
139
}
140
 
1334 slepc 141
void PETSC_STDCALL epscreate_(MPI_Fint *comm,EPS *eps,PetscErrorCode *ierr)
142
{
143
  *ierr = EPSCreate(MPI_Comm_f2c(*(comm)),eps);
986 slepc 144
}
145
 
1331 slepc 146
void PETSC_STDCALL epsmonitorset_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,PetscErrorCode*),
1287 slepc 147
                                  void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode *),PetscErrorCode *ierr)
986 slepc 148
{
1331 slepc 149
  if ((void(*)())monitor == (void(*)())epsmonitordefault_) {
150
    *ierr = EPSMonitorSet(*eps,EPSMonitorDefault,0,0);
151
  } else if ((void(*)())monitor == (void(*)())epsmonitorlg_) {
152
    *ierr = EPSMonitorSet(*eps,EPSMonitorLG,0,0);
986 slepc 153
  } else {
154
    f1  = monitor;
155
    if (FORTRANNULLFUNCTION(monitordestroy)) {
1331 slepc 156
      *ierr = EPSMonitorSet(*eps,ourmonitor,mctx,0);
986 slepc 157
    } else {
1287 slepc 158
      f2 = monitordestroy;
1331 slepc 159
      *ierr = EPSMonitorSet(*eps,ourmonitor,mctx,ourdestroy);
986 slepc 160
    }
161
  }
162
}
163
 
164
void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
165
{
166
  const char *tname;
167
 
168
  *ierr = EPSGetOptionsPrefix(*eps,&tname);
169
#if defined(PETSC_USES_CPTOFCD)
170
  {
171
    char *t = _fcdtocp(prefix); int len1 = _fcdlen(prefix);
172
    *ierr = PetscStrncpy(t,tname,len1); if (*ierr) return;
173
  }
174
#else
175
  *ierr = PetscStrncpy(prefix,tname,len); if (*ierr) return;
176
#endif
177
  FIXRETURNCHAR(prefix,len);
178
}
179
 
180
void PETSC_STDCALL epsgetst_(EPS *eps,ST *st,int *ierr)
181
{
182
  *ierr = EPSGetST(*eps,st);
183
}
184
 
1345 slepc 185
void PETSC_STDCALL epsgetip_(EPS *eps,IP *ip,int *ierr)
186
{
187
  *ierr = EPSGetIP(*eps,ip);
188
}
189
 
986 slepc 190
void PETSC_STDCALL epsgetwhicheigenpairs_(EPS *eps,EPSWhich *which,int *ierr)
191
{
192
  *ierr = EPSGetWhichEigenpairs(*eps,which);
193
}
194
 
195
void PETSC_STDCALL epsgetproblemtype_(EPS *eps,EPSProblemType *type,int *ierr)
196
{
197
  *ierr = EPSGetProblemType(*eps,type);
198
}
199
 
1021 slepc 200
void PETSC_STDCALL epsgetclass_(EPS *eps,EPSClass *cl,int *ierr)
201
{
202
  *ierr = EPSGetClass(*eps,cl);
203
}
204
 
205
void PETSC_STDCALL epsgetconvergedreason_(EPS *eps,EPSConvergedReason *reason,int *ierr)
206
{
207
  *ierr = EPSGetConvergedReason(*eps,reason);
208
}
209
 
986 slepc 210
void PETSC_STDCALL epspowergetshifttype_(EPS *eps,EPSPowerShiftType *shift,int *ierr)
211
{
212
  *ierr = EPSPowerGetShiftType(*eps,shift);
213
}
214
 
215
void PETSC_STDCALL epslanczosgetreorthog_(EPS *eps,EPSLanczosReorthogType *reorthog,int *ierr)
216
{
217
  *ierr = EPSLanczosGetReorthog(*eps,reorthog);
218
}
219
EXTERN_C_END
220