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
 
1469 slepc 11
#include "private/fortranimpl.h"
986 slepc 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
1426 slepc 30
#define epsgetprojection_           EPSGETPROJECTION
1021 slepc 31
#define epsgetclass_                EPSGETCLASS
32
#define epsgetconvergedreason_      EPSGETCONVERGEDREASON
986 slepc 33
#define epspowergetshifttype_       EPSPOWERGETSHIFTTYPE
1021 slepc 34
#define epslanczosgetreorthog_      EPSLANCZOSGETREORTHOG
986 slepc 35
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
36
#define epsview_                    epsview
37
#define epssetoptionsprefix_        epssetoptionsprefix
38
#define epsappendoptionsprefix_     epsappendoptionsprefix
39
#define epsgetoptionsprefix_        epsgetoptionsprefix
40
#define epscreate_                  epscreate
41
#define epssettype_                 epssettype          
42
#define epsgettype_                 epsgettype
1331 slepc 43
#define epsmonitordefault_          epsmonitordefault
44
#define epsmonitorlg_               epsmonitorlg
45
#define epsmonitorset_              epsmonitorset
1021 slepc 46
#define epsgetst_                   epsgetst
1345 slepc 47
#define epsgetip_                   epsgetip
986 slepc 48
#define epsgetwhicheigenpairs_      epsgetwhicheigenpairs
49
#define epsgetproblemtype_          epsgetproblemtype
1426 slepc 50
#define epsgetprojection_           epsgetprojection
1021 slepc 51
#define epsgetclass_                epsgetclass
52
#define epsgetconvergedreason_      epsgetconvergedreason
986 slepc 53
#define epspowergetshifttype_       epspowergetshifttype
54
#define epslanczosgetreorthog_      epslanczosgetreorthog
55
#endif
56
 
57
EXTERN_C_BEGIN
1287 slepc 58
static void (PETSC_STDCALL *f1)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,PetscErrorCode*);
59
static void (PETSC_STDCALL *f2)(void*,PetscErrorCode*);
60
 
1027 slepc 61
/*
62
   These are not usually called from Fortran but allow Fortran users
63
   to transparently set these monitors from .F code, hence no STDCALL
64
*/
1331 slepc 65
void epsmonitordefault_(EPS *eps,int *it,int *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,int *nest,void *ctx,PetscErrorCode *ierr)
1027 slepc 66
{
1331 slepc 67
  *ierr = EPSMonitorDefault(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx);
1027 slepc 68
}
1287 slepc 69
 
1331 slepc 70
void epsmonitorlg_(EPS *eps,int *it,int *nconv,PetscScalar *eigr,PetscScalar *eigi,PetscReal *errest,int *nest,void *ctx,PetscErrorCode *ierr)
1287 slepc 71
{
1331 slepc 72
  *ierr = EPSMonitorLG(*eps,*it,*nconv,eigr,eigi,errest,*nest,ctx);
1287 slepc 73
}
1027 slepc 74
EXTERN_C_END
75
 
76
/* These are not extern C because they are passed into non-extern C user level functions */
77
static PetscErrorCode ourmonitor(EPS eps,int i,int nc,PetscScalar *er,PetscScalar *ei,PetscReal *d,int l,void* ctx)
78
{
1287 slepc 79
  PetscErrorCode ierr = 0;
1027 slepc 80
  (*f1)(&eps,&i,&nc,er,ei,d,&l,ctx,&ierr);CHKERRQ(ierr);
81
  return 0;
82
}
986 slepc 83
 
1287 slepc 84
static PetscErrorCode ourdestroy(void* ctx)
85
{
86
  PetscErrorCode ierr = 0;
87
  (*f2)(ctx,&ierr);CHKERRQ(ierr);
88
  return 0;
89
}
90
 
1027 slepc 91
EXTERN_C_BEGIN
92
 
986 slepc 93
void PETSC_STDCALL epsview_(EPS *eps,PetscViewer *viewer, PetscErrorCode *ierr)
94
{
95
  PetscViewer v;
96
  PetscPatchDefaultViewers_Fortran(viewer,v);
97
  *ierr = EPSView(*eps,v);
98
}
99
 
100
void PETSC_STDCALL epssettype_(EPS *eps,CHAR type PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
101
{
102
  char *t;
103
 
104
  FIXCHAR(type,len,t);
105
  *ierr = EPSSetType(*eps,t);
106
  FREECHAR(type,t);
107
}
108
 
109
void PETSC_STDCALL epsgettype_(EPS *eps,CHAR name PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
110
{
1507 slepc 111
  const EPSType tname;
986 slepc 112
 
113
  *ierr = EPSGetType(*eps,&tname);if (*ierr) return;
114
#if defined(PETSC_USES_CPTOFCD)
115
  {
116
    char *t = _fcdtocp(name); int len1 = _fcdlen(name);
117
    *ierr = PetscStrncpy(t,tname,len1);
118
  }
119
#else
120
  *ierr = PetscStrncpy(name,tname,len);
121
#endif
1421 slepc 122
  FIXRETURNCHAR(PETSC_TRUE,name,len);
986 slepc 123
}
124
 
1027 slepc 125
void PETSC_STDCALL epssetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 126
{
127
  char *t;
128
 
129
  FIXCHAR(prefix,len,t);
130
  *ierr = EPSSetOptionsPrefix(*eps,t);
131
  FREECHAR(prefix,t);
132
}
133
 
1027 slepc 134
void PETSC_STDCALL epsappendoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
986 slepc 135
{
136
  char *t;
137
 
138
  FIXCHAR(prefix,len,t);
139
  *ierr = EPSAppendOptionsPrefix(*eps,t);
140
  FREECHAR(prefix,t);
141
}
142
 
1334 slepc 143
void PETSC_STDCALL epscreate_(MPI_Fint *comm,EPS *eps,PetscErrorCode *ierr)
144
{
145
  *ierr = EPSCreate(MPI_Comm_f2c(*(comm)),eps);
986 slepc 146
}
147
 
1331 slepc 148
void PETSC_STDCALL epsmonitorset_(EPS *eps,void (PETSC_STDCALL *monitor)(EPS*,int*,int*,PetscScalar*,PetscScalar*,PetscReal*,int*,void*,PetscErrorCode*),
1287 slepc 149
                                  void *mctx,void (PETSC_STDCALL *monitordestroy)(void *,PetscErrorCode *),PetscErrorCode *ierr)
986 slepc 150
{
1331 slepc 151
  if ((void(*)())monitor == (void(*)())epsmonitordefault_) {
152
    *ierr = EPSMonitorSet(*eps,EPSMonitorDefault,0,0);
153
  } else if ((void(*)())monitor == (void(*)())epsmonitorlg_) {
154
    *ierr = EPSMonitorSet(*eps,EPSMonitorLG,0,0);
986 slepc 155
  } else {
156
    f1  = monitor;
157
    if (FORTRANNULLFUNCTION(monitordestroy)) {
1331 slepc 158
      *ierr = EPSMonitorSet(*eps,ourmonitor,mctx,0);
986 slepc 159
    } else {
1287 slepc 160
      f2 = monitordestroy;
1331 slepc 161
      *ierr = EPSMonitorSet(*eps,ourmonitor,mctx,ourdestroy);
986 slepc 162
    }
163
  }
164
}
165
 
166
void PETSC_STDCALL epsgetoptionsprefix_(EPS *eps,CHAR prefix PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len))
167
{
168
  const char *tname;
169
 
170
  *ierr = EPSGetOptionsPrefix(*eps,&tname);
171
#if defined(PETSC_USES_CPTOFCD)
172
  {
173
    char *t = _fcdtocp(prefix); int len1 = _fcdlen(prefix);
174
    *ierr = PetscStrncpy(t,tname,len1); if (*ierr) return;
175
  }
176
#else
177
  *ierr = PetscStrncpy(prefix,tname,len); if (*ierr) return;
178
#endif
1421 slepc 179
  FIXRETURNCHAR(PETSC_TRUE,prefix,len);
986 slepc 180
}
181
 
182
void PETSC_STDCALL epsgetst_(EPS *eps,ST *st,int *ierr)
183
{
184
  *ierr = EPSGetST(*eps,st);
185
}
186
 
1345 slepc 187
void PETSC_STDCALL epsgetip_(EPS *eps,IP *ip,int *ierr)
188
{
189
  *ierr = EPSGetIP(*eps,ip);
190
}
191
 
986 slepc 192
void PETSC_STDCALL epsgetwhicheigenpairs_(EPS *eps,EPSWhich *which,int *ierr)
193
{
194
  *ierr = EPSGetWhichEigenpairs(*eps,which);
195
}
196
 
197
void PETSC_STDCALL epsgetproblemtype_(EPS *eps,EPSProblemType *type,int *ierr)
198
{
199
  *ierr = EPSGetProblemType(*eps,type);
200
}
201
 
1426 slepc 202
void PETSC_STDCALL epsgetprojection_(EPS *eps,EPSProjection *proj,int *ierr)
203
{
204
  *ierr = EPSGetProjection(*eps,proj);
205
}
206
 
1021 slepc 207
void PETSC_STDCALL epsgetclass_(EPS *eps,EPSClass *cl,int *ierr)
208
{
209
  *ierr = EPSGetClass(*eps,cl);
210
}
211
 
212
void PETSC_STDCALL epsgetconvergedreason_(EPS *eps,EPSConvergedReason *reason,int *ierr)
213
{
214
  *ierr = EPSGetConvergedReason(*eps,reason);
215
}
216
 
986 slepc 217
void PETSC_STDCALL epspowergetshifttype_(EPS *eps,EPSPowerShiftType *shift,int *ierr)
218
{
219
  *ierr = EPSPowerGetShiftType(*eps,shift);
220
}
221
 
222
void PETSC_STDCALL epslanczosgetreorthog_(EPS *eps,EPSLanczosReorthogType *reorthog,int *ierr)
223
{
224
  *ierr = EPSLanczosGetReorthog(*eps,reorthog);
225
}
226
EXTERN_C_END
227