[petsc-users] [petsc-dev] second patch for DMDAVecGetArrayF90

Satish Balay balay at mcs.anl.gov
Wed Jul 11 08:40:10 CDT 2012


The second patch has typos. Attaching the modified patch. If it works for 
you - I'll add it to petsc-3.3/petsc-dev

thanks,
Satish

On Wed, 11 Jul 2012, TAY wee-beng wrote:

> On 6/7/2012 5:48 PM, Barry Smith wrote:
> >     Blaise,
> > 
> >        Thanks.
> > 
> >     Satish,
> > 
> >        If they look good could you apply them to 3.3 and dev?
> > 
> >       Thanks
> > 
> >        Barry
> 
> Hi,
> 
> I downloaded petsc-dev a few days ago and applied both patches using "patch -v
> ..." in both linux and windows vs2008
> 
> It worked great in linux
> 
> However, when I compile and link in vs2008, it gives the error:
> /
> 1>Compiling manifest to resources...
> 1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
> 1>Copyright (C) Microsoft Corporation.  All rights reserved.
> 1>Linking...
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dCREATESCALAR referenced in function F90Array4dCreate
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dACCESSFORTRANADDR referenced in function F90Array4dAccess
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dACCESSINT referenced in function F90Array4dAccess
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dACCESSREAL referenced in function F90Array4dAccess
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dACCESSSCALAR referenced in function F90Array4dAccess
> 1>libpetsc.lib(f90_cwrap.o) : error LNK2019: unresolved external symbol
> F90ARRAY4dDESTROYSCALAR referenced in function F90Array4dDestroy
> 1>c:\obj_tmp\ibm2d_high_Re_staggered_old\Debug/ibm2d_high_Re_staggered.exe :
> fatal error LNK1120: 6 unresolved externals/
> 
> I wonder if it's fixed in the new petsc-dev.
> 
> Thanks
> > 
> > On Jul 6, 2012, at 6:30 AM, Blaise Bourdin wrote:
> > 
> > > Hi,
> > > 
> > > I have added the creation, destruction and accessor functions for 4d
> > > vectors in F90. The accessor was missing and needed for DMDAVecGetArrayF90
> > > with a 3d DMDA and >1 dof. As far as I can test, ex11f90 in DM should now
> > > completely work with the intel compilers.
> > > 
> > > Some of the functions are probably not used (F90Array4dAccessReal,
> > > F90Array4dAccessInt, F90Array4dAccessFortranAddr, for instance), but I
> > > added them anyway. Let me know if you want me to submit a patch without
> > > them.
> > > 
> > > Regards,
> > > 
> > > Blaise
> > > <DMDAVecRestoreArrayF90-2.patch>
> > > 
> > > 
> > > -- 
> > > Department of Mathematics and Center for Computation & Technology
> > > Louisiana State University, Baton Rouge, LA 70803, USA
> > > Tel. +1 (225) 578 1612, Fax  +1 (225) 578 4276
> > > http://www.math.lsu.edu/~bourdin
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> 
> 
> 
-------------- next part --------------
diff -r c449016b5325 src/dm/impls/da/f90-custom/zda1f90.c

--- a/src/dm/impls/da/f90-custom/zda1f90.c	Tue Jul 03 13:22:19 2012 -0500

+++ b/src/dm/impls/da/f90-custom/zda1f90.c	Fri Jul 06 15:15:48 2012 +0400

@@ -175,9 +175,7 @@ void PETSC_STDCALL dmdavecrestorearrayf9

   /* 

     F90Array4dAccess is not implemented, so the following call would fail

   */

-  /*

   *ierr = F90Array4dAccess(a,PETSC_SCALAR,(void**)&fa PETSC_F90_2PTR_PARAM(ptrd));

-  */

   *ierr = VecRestoreArray(*v,&fa);if (*ierr) return;

   *ierr = F90Array4dDestroy(&a,PETSC_SCALAR PETSC_F90_2PTR_PARAM(ptrd));

 }

diff -r c449016b5325 src/sys/f90-src/f90_cwrap.c

--- a/src/sys/f90-src/f90_cwrap.c	Tue Jul 03 13:22:19 2012 -0500

+++ b/src/sys/f90-src/f90_cwrap.c	Fri Jul 06 15:15:48 2012 +0400

@@ -307,17 +307,46 @@ PetscErrorCode  F90Array3dDestroy(F90Arr

 }

 

 /*************************************************************************/

-

 #if defined(PETSC_HAVE_FORTRAN_CAPS)

-#define f90array4dcreatescalar_           F90ARRAY4DCREATESCALAR

-#define f90array4ddestroyscalar_          F90ARRAY4DDESTROYSCALAR

+#define f90array4dcreatescalar_           F90ARRAY4DCREATESCALAR

+#define f90array4daccessscalar_           F90ARRAY4DACCESSSCALAR

+#define f90array4ddestroyscalar_          F90ARRAY4DDESTROYSCALAR

+#define f90array4dcreatereal_             F90ARRAY4DCREATEREAL

+#define f90array4daccessreal_             F90ARRAY4DACCESSREAL

+#define f90array4ddestroyreal_            F90ARRAY4DDESTROYREAL

+#define f90array4dcreateint_              F90ARRAY4DCREATEINT

+#define f90array4daccessint_              F90ARRAY4DACCESSINT

+#define f90array4ddestroyint_             F90ARRAY4DDESTROYINT

+#define f90array4dcreatefortranaddr_      F90ARRAY4DCREATEFORTRANADDR

+#define f90array4daccessfortranaddr_      F90ARRAY4DACCESSFORTRANADDR

+#define f90array4ddestroyfortranaddr_     F90ARRAY4DDESTROYFORTRANADDR

 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)

 #define f90array4dcreatescalar_           f90array4dcreatescalar

+#define f90array4daccessscalar_           f90array4daccessscalar

 #define f90array4ddestroyscalar_          f90array4ddestroyscalar

+#define f90array4dcreatereal_             f90array4dcreatereal

+#define f90array4daccessreal_             f90array4daccessreal

+#define f90array4ddestroyreal_            f90array4ddestroyreal

+#define f90array4dcreateint_              f90array4dcreateint

+#define f90array4daccessint_              f90array4daccessint

+#define f90array4ddestroyint_             f90array4ddestroyint

+#define f90array4dcreatefortranaddr_      f90array4dcreatefortranaddr

+#define f90array4daccessfortranaddr_      f90array4daccessfortranaddr

+#define f90array4ddestroyfortranaddr_     f90array4ddestroyfortranaddr

 #endif

 

 PETSC_EXTERN_C void PETSC_STDCALL f90array4dcreatescalar_(void *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt*,PetscInt*,F90Array4d * PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4daccessscalar_(F90Array4d*,void** PETSC_F90_2PTR_PROTO_NOVAR);

 PETSC_EXTERN_C void PETSC_STDCALL f90array4ddestroyscalar_(F90Array4d *ptr PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dcreatereal_(void *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt*,PetscInt*,F90Array4d * PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4daccessreal_(F90Array4d*,void** PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4ddestroyreal_(F90Array4d *ptr PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dcreateint_(void *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt*,PetscInt*,F90Array4d * PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4daccessint_(F90Array4d*,void** PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4ddestroyint_(F90Array4d *ptr PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dcreatefortranaddr_(void *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt *,PetscInt*,PetscInt*,F90Array4d * PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4daccessfortranaddr_(F90Array4d*,void** PETSC_F90_2PTR_PROTO_NOVAR);

+PETSC_EXTERN_C void PETSC_STDCALL f90array4ddestroyfortranaddr_(F90Array4d *ptr PETSC_F90_2PTR_PROTO_NOVAR);

 

 #undef __FUNCT__

 #define __FUNCT__ "F90Array4dCreate"

@@ -333,6 +362,25 @@ PetscErrorCode F90Array4dCreate(void *ar

 }

 

 #undef __FUNCT__

+#define __FUNCT__ "F90Array4dAccess"

+PetscErrorCode  F90Array4dAccess(F90Array4d *ptr,PetscDataType type,void **array PETSC_F90_2PTR_PROTO(ptrd))

+{

+  PetscFunctionBegin;

+  if (type == PETSC_SCALAR) {

+    f90array4daccessscalar_(ptr,array PETSC_F90_2PTR_PARAM(ptrd));

+  } else if (type == PETSC_REAL) {

+    f90array4daccessreal_(ptr,array PETSC_F90_2PTR_PARAM(ptrd));

+  } else if (type == PETSC_INT) {

+    f90array4daccessint_(ptr,array PETSC_F90_2PTR_PARAM(ptrd));

+  } else if (type == PETSC_FORTRANADDR) {

+    f90array4daccessfortranaddr_(ptr,array PETSC_F90_2PTR_PARAM(ptrd));

+  } else {

+    SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"unsupported PetscDataType: %d",(PetscInt)type);

+  }

+  PetscFunctionReturn(0);

+}

+

+#undef __FUNCT__

 #define __FUNCT__ "F90Array4dDestroy"

 PetscErrorCode  F90Array4dDestroy(F90Array4d *ptr,PetscDataType type PETSC_F90_2PTR_PROTO(ptrd))

 {

@@ -436,3 +484,31 @@ PETSC_EXTERN_C void PETSC_STDCALL f90arr

 }

 

 /*************************************************************************/

+#if defined(PETSC_HAVE_FORTRAN_CAPS)

+#define f90array4dgetaddrscalar_            F90ARRAY4DGETADDRSCALAR

+#define f90array4dgetaddrreal_              F90ARRAY4DGETADDRREAL

+#define f90array4dgetaddrint_               F90ARRAY4DGETADDRINT

+#define f90array4dgetaddrfortranaddr_       F90ARRAY4DGETADDRFORTRANADDR

+#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)

+#define f90array4dgetaddrscalar_            f90array4dgetaddrscalar

+#define f90array4dgetaddrreal_              f90array4dgetaddrreal

+#define f90array4dgetaddrint_               f90array4dgetaddrint

+#define f90array4dgetaddrfortranaddr_       f90array4dgetaddrfortranaddr

+#endif

+

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dgetaddrscalar_(void *array, PetscFortranAddr *address)

+{

+  *address = (PetscFortranAddr)array;

+}

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dgetaddrreal_(void *array, PetscFortranAddr *address)

+{

+  *address = (PetscFortranAddr)array;

+}

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dgetaddrint_(void *array, PetscFortranAddr *address)

+{

+  *address = (PetscFortranAddr)array;

+}

+PETSC_EXTERN_C void PETSC_STDCALL f90array4dgetaddrfortranaddr_(void *array, PetscFortranAddr *address)

+{

+  *address = (PetscFortranAddr)array;

+}

diff -r c449016b5325 src/sys/f90-src/fsrc/f90_fwrap.F

--- a/src/sys/f90-src/fsrc/f90_fwrap.F	Tue Jul 03 13:22:19 2012 -0500

+++ b/src/sys/f90-src/fsrc/f90_fwrap.F	Fri Jul 06 15:15:48 2012 +0400

@@ -322,23 +322,6 @@

       end subroutine

 

 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-      subroutine F90Array4dCreateScalar(array,start1,len1,                        &

-     &     start2,len2,start3,len3,start4,len4,ptr)

-      implicit none

-#include <finclude/petscsys.h>

-      PetscInt start1,len1

-      PetscInt start2,len2

-      PetscInt start3,len3

-      PetscInt start4,len4

-      PetscScalar, target ::                                                      &

-     &     array(start1:start1+len1-1,start2:start2+len2-1,                       &

-     &           start3:start3+len3-1,start4:start4+len4-1)

-      PetscScalar, pointer :: ptr(:,:,:,:)

-

-      ptr => array

-      end subroutine

-

-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

       subroutine F90Array3dAccessScalar(ptr,address)

       implicit none

 #include <finclude/petscsys.h>

@@ -426,10 +409,158 @@

       end subroutine

 

 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

+      subroutine F90Array4dCreateScalar(array,start1,len1,                        &

+     &     start2,len2,start3,len3,start4,len4,ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt start1,len1

+      PetscInt start2,len2

+      PetscInt start3,len3

+      PetscInt start4,len4

+      PetscScalar, target ::                                                      &

+     &     array(start1:start1+len1-1,start2:start2+len2-1,                       &

+     &           start3:start3+len3-1,start4:start4+len4-1)

+      PetscScalar, pointer :: ptr(:,:,:,:)

+

+      ptr => array

+      end subroutine

+

+      subroutine F90Array4dCreateReal(array,start1,len1,                          &

+     &     start2,len2,start3,len3,start4,len4,ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt start1,len1

+      PetscInt start2,len2

+      PetscInt start3,len3

+      PetscInt start4,len4

+      PetscReal, target ::                                                        &

+     &     array(start1:start1+len1-1,start2:start2+len2-1,                       &

+     &           start3:start3+len3-1,start4:start4+len4-1)

+      PetscReal, pointer :: ptr(:,:,:,:)

+

+      ptr => array

+      end subroutine

+

+      subroutine F90Array4dCreateInt(array,start1,len1,                           &

+     &     start2,len2,start3,len3,start4,len4,ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt start1,len1

+      PetscInt start2,len2

+      PetscInt start3,len3

+      PetscInt start4,len4

+      PetscInt, target ::                                                         &

+     &     array(start1:start1+len1-1,start2:start2+len2-1,                       &

+     &           start3:start3+len3-1,start4:start4+len4-1)

+      PetscInt, pointer :: ptr(:,:,:,:)

+

+      ptr => array

+      end subroutine

+

+      subroutine F90Array4dCreateFortranAddr(array,start1,len1,                   &

+     &     start2,len2,start3,len3,start4,len4,ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt start1,len1

+      PetscInt start2,len2

+      PetscInt start3,len3

+      PetscInt start4,len4

+      PetscFortranAddr, target ::                                                 &

+     &     array(start1:start1+len1-1,start2:start2+len2-1,                       &

+     &           start3:start3+len3-1,start4:start4+len4-1)

+      PetscFortranAddr, pointer :: ptr(:,:,:,:)

+

+      ptr => array

+      end subroutine

+

+      subroutine F90Array4dAccessScalar(ptr,address)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscScalar, pointer :: ptr(:,:,:,:)

+      PetscFortranAddr address

+      PetscInt start1,start2,start3,start4

+

+      start1 = lbound(ptr,1)

+      start2 = lbound(ptr,2)

+      start3 = lbound(ptr,3)

+      start4 = lbound(ptr,4)

+      call F90Array4dGetAddrScalar(ptr(start1,start2,start3,start4),              &

+     &                             address)

+      end subroutine

+

+      subroutine F90Array4dAccessReal(ptr,address)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscReal, pointer :: ptr(:,:,:,:)

+      PetscFortranAddr address

+      PetscInt start1,start2,start3,start4

+

+      start1 = lbound(ptr,1)

+      start2 = lbound(ptr,2)

+      start3 = lbound(ptr,3)

+      start4 = lbound(ptr,4)

+      call F90Array4dGetAddrReal(ptr(start1,start2,start3,start4),                &

+     &                             address)

+      end subroutine

+

+      subroutine F90Array4dAccessInt(ptr,address)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt, pointer :: ptr(:,:,:,:)

+      PetscFortranAddr address

+      PetscInt start1,start2,start3,start4

+

+      start1 = lbound(ptr,1)

+      start2 = lbound(ptr,2)

+      start3 = lbound(ptr,3)

+      start4 = lbound(ptr,4)

+      call F90Array4dGetAddrInt(ptr(start1,start2,start3,start4),                 &

+     &                             address)

+      end subroutine

+

+      subroutine F90Array4dAccessFortranAddr(ptr,address)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscScalar, pointer :: ptr(:,:,:,:)

+      PetscFortranAddr address

+      PetscFortranAddr start1,start2,start3,start4

+

+      start1 = lbound(ptr,1)

+      start2 = lbound(ptr,2)

+      start3 = lbound(ptr,3)

+      start4 = lbound(ptr,4)

+      call F90Array4dGetAddrFortranAddr(ptr(start1,start2,start3,                 &

+     &                                      start4),address)

+      end subroutine

+

       subroutine F90Array4dDestroyScalar(ptr)

       implicit none

 #include <finclude/petscsys.h>

-      PetscScalar, pointer :: ptr(:,:,:)

+      PetscScalar, pointer :: ptr(:,:,:,:)

+

+      nullify(ptr)

+      end subroutine

+

+      subroutine F90Array4dDestroyReal(ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscReal, pointer :: ptr(:,:,:,:)

+

+      nullify(ptr)

+      end subroutine

+

+      subroutine F90Array4dDestroyInt(ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscInt, pointer :: ptr(:,:,:,:)

+

+      nullify(ptr)

+      end subroutine

+

+      subroutine F90Array4dDestroyFortranAddr(ptr)

+      implicit none

+#include <finclude/petscsys.h>

+      PetscFortranAddr, pointer :: ptr(:,:,:,:)

 

       nullify(ptr)

       end subroutine



More information about the petsc-users mailing list