psblas3-mcbind:

cbind/Makefile
 cbind/prec/Makefile
 cbind/prec/psb_c_dprec.c
 cbind/prec/psb_c_dprec.h
 cbind/prec/psb_dprec_cbind_mod.f90
 cbind/prec/psb_dprec_cbind_mod.mod
 cbind/prec/psb_prec_cbind.h
 cbind/prec/psb_prec_cbind_mod.f90

First step for C binding of PREC stuff.
psblas3-mcbind
Salvatore Filippone 8 years ago
parent 4734f19167
commit b6686e96f6

@ -5,7 +5,7 @@ LIBDIR=../lib
INCDIR=../include
LIBNAME=$(CBINDLIBNAME)
lib: based
lib: based precd
/bin/cp -p $(CPUPDFLAG) $(HERE)/$(LIBNAME) $(LIBDIR)
/bin/cp -p $(CPUPDFLAG) *$(.mod) *.h $(INCDIR)
@ -13,10 +13,13 @@ lib: based
based:
cd base && $(MAKE) lib LIBNAME=$(LIBNAME)
precd:
cd prec && $(MAKE) lib LIBNAME=$(LIBNAME)
clean:
cd base && $(MAKE) clean
cd prec && $(MAKE) clean
veryclean: clean

@ -0,0 +1,32 @@
TOP=../..
include $(TOP)/Make.inc
LIBDIR=$(TOP)/lib
INCLUDEDIR=$(TOP)/include
HERE=..
FINCLUDES=$(FMFLAG). $(FMFLAG)$(INCLUDEDIR)
CINCLUDES=-I. -I$(INCLUDEDIR)
OBJS=psb_prec_cbind_mod.o psb_dprec_cbind_mod.o psb_c_dprec.o
CMOD=psb_prec_cbind.h psb_c_dprec.h
LIBMOD=psb_prec_cbind_mod$(.mod)
LOCAL_MODS=$(LIBMOD)
LIBNAME=$(CPRECLIBNAME)
lib: $(OBJS) $(CMOD)
$(AR) $(HERE)/$(LIBNAME) $(OBJS)
$(RANLIB) $(HERE)/$(LIBNAME)
/bin/cp -p $(HERE)/$(LIBNAME) $(LIBDIR)
/bin/cp -p $(LIBMOD) $(CMOD) $(INCLUDEDIR)
psb_prec_cbind_mod.o: psb_dprec_cbind_mod.o
veryclean: clean
/bin/rm -f $(HERE)/$(LIBNAME)
clean:
/bin/rm -f $(OBJS) $(LOCAL_MODS)
veryclean: clean

@ -0,0 +1,12 @@
#include <stdlib.h>
#include "psb_c_dprec.h"
psb_c_dprec* psb_c_new_dprec()
{
psb_c_dprec* temp;
temp=(psb_c_dprec *) malloc(sizeof(psb_c_dprec));
temp->dprec=NULL;
return(temp);
}

@ -0,0 +1,24 @@
#ifndef PSB_C_DPREC_
#define PSB_C_DPREC_
#include "psb_base_cbind.h"
/* Object handle related routines */
/* Note: psb_get_XXX_handle returns: <= 0 unsuccessful */
/* >0 valid handle */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct PSB_C_DPREC {
void *dprec;
} psb_c_dprec;
psb_c_dprec* psb_c_new_dprec();
int psb_c_dprecinit(psb_c_dprec *ph, const char *ptype);
int psb_c_dprecbld(psb_c_dspmat *ah, psb_c_descriptor *cdh, psb_c_dprec *ph);
int psb_c_dprecfree(psb_c_dprec *ph);
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,118 @@
module psb_dprec_cbind_mod
use iso_c_binding
use psb_prec_mod, only : psb_dprec_type
use psb_objhandle_mod
use psb_base_string_cbind_mod
type, bind(c) :: psb_c_dprec
type(c_ptr) :: item = c_null_ptr
end type psb_c_dprec
contains
function psb_c_dprecinit(ph,ptype) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_base_string_cbind_mod
implicit none
integer(c_int) :: res
type(psb_c_dprec) :: ph
character(c_char) :: ptype(*)
type(psb_dprec_type), pointer :: precp
integer :: info
character(len=80) :: fptype
res = -1
if (c_associated(ph%item)) then
return
end if
allocate(precp,stat=info)
if (info /= 0) return
ph%item = c_loc(precp)
call stringc2f(ptype,fptype)
call psb_precinit(precp,fptype,info)
res = min(0,info)
return
end function psb_c_dprecinit
function psb_c_dprecbld(ah,cdh,ph) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_objhandle_mod
use psb_base_string_cbind_mod
implicit none
integer(c_int) :: res
type(psb_c_dspmat) :: ah
type(psb_c_dprec) :: ph
type(psb_c_descriptor) :: cdh
type(psb_desc_type), pointer :: descp
type(psb_dspmat_type), pointer :: ap
type(psb_dprec_type), pointer :: precp
integer :: info
res = -1
!!$ write(*,*) 'Entry: ', psb_c_cd_get_local_rows(cdh)
if (c_associated(cdh%item)) then
call c_f_pointer(cdh%item,descp)
else
return
end if
if (c_associated(ah%item)) then
call c_f_pointer(ah%item,ap)
else
return
end if
if (c_associated(ph%item)) then
call c_f_pointer(ph%item,precp)
else
return
end if
call psb_precbld(ap,descp, precp, info)
res = min(info,0)
end function psb_c_dprecbld
function psb_c_dprecfree(ph) bind(c) result(res)
use psb_base_mod
use psb_prec_mod
use psb_objhandle_mod
use psb_base_string_cbind_mod
implicit none
integer(c_int) :: res
type(psb_c_dprec) :: ph
type(psb_dprec_type), pointer :: precp
integer :: info
res = -1
if (c_associated(ph%item)) then
call c_f_pointer(ph%item,precp)
else
return
end if
call psb_precfree(precp, info)
res = min(info,0)
end function psb_c_dprecfree
end module psb_dprec_cbind_mod

@ -0,0 +1,6 @@
#ifndef PSB_PREC_CBIND_
#define PSB_PREC_CBIND_
#include "psb_c_dprec.h"
#endif

@ -0,0 +1,3 @@
module psb_prec_cbind_mod
use psb_dprec_cbind_mod
end module psb_prec_cbind_mod
Loading…
Cancel
Save