1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h> 20ec63f53SRichard Tran Mills #include <petscdmshell.h> /*I "petscdmshell.h" I*/ 30ec63f53SRichard Tran Mills 40ec63f53SRichard Tran Mills #if defined(PETSC_HAVE_FORTRAN_CAPS) 50ec63f53SRichard Tran Mills #define dmshellsetcreatematrix_ DMSHELLSETCREATEMATRIX 60ec63f53SRichard Tran Mills #define dmshellsetcreateglobalvector_ DMSHELLSETCREATEGLOBALVECTOR_ 7dc43b69eSJed Brown #define dmshellsetcreatelocalvector_ DMSHELLSETCREATELOCALVECTOR_ 8f2d7aa87SRichard Tran Mills #define dmshellsetglobaltolocal_ DMSHELLSETGLOBALTOLOCAL_ 9f2d7aa87SRichard Tran Mills #define dmshellsetlocaltoglobal_ DMSHELLSETLOCALTOGLOBAL_ 10f3db62a7SRichard Tran Mills #define dmshellsetlocaltolocal_ DMSHELLSETLOCALTOLOCAL_ 110ec63f53SRichard Tran Mills #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 120ec63f53SRichard Tran Mills #define dmshellsetcreatematrix_ dmshellsetcreatematrix 130ec63f53SRichard Tran Mills #define dmshellsetcreateglobalvector_ dmshellsetcreateglobalvector 14dc43b69eSJed Brown #define dmshellsetcreatelocalvector_ dmshellsetcreatelocalvector 15f2d7aa87SRichard Tran Mills #define dmshellsetglobaltolocal_ dmshellsetglobaltolocal 16f2d7aa87SRichard Tran Mills #define dmshellsetlocaltoglobal_ dmshellsetlocaltoglobal 17f3db62a7SRichard Tran Mills #define dmshellsetlocaltolocal_ dmshellsetlocaltolocal_ 180ec63f53SRichard Tran Mills #endif 190ec63f53SRichard Tran Mills 200ec63f53SRichard Tran Mills /* 21dc43b69eSJed Brown * C routines are required for matrix and global vector creation. We define C routines here that call the corresponding 22dc43b69eSJed Brown * Fortran routine (indexed by _cb) that was set by the user. 230ec63f53SRichard Tran Mills */ 240ec63f53SRichard Tran Mills 25dc43b69eSJed Brown static struct { 26dc43b69eSJed Brown PetscFortranCallbackId creatematrix; 27dc43b69eSJed Brown PetscFortranCallbackId createglobalvector; 28dc43b69eSJed Brown PetscFortranCallbackId createlocalvector; 29f2d7aa87SRichard Tran Mills PetscFortranCallbackId globaltolocalbegin; 30f2d7aa87SRichard Tran Mills PetscFortranCallbackId globaltolocalend; 31f2d7aa87SRichard Tran Mills PetscFortranCallbackId localtoglobalbegin; 32f2d7aa87SRichard Tran Mills PetscFortranCallbackId localtoglobalend; 33f3db62a7SRichard Tran Mills PetscFortranCallbackId localtolocalbegin; 34f3db62a7SRichard Tran Mills PetscFortranCallbackId localtolocalend; 35dc43b69eSJed Brown } _cb; 36dc43b69eSJed Brown 37b412c318SBarry Smith static PetscErrorCode ourcreatematrix(DM dm,Mat *A) 380ec63f53SRichard Tran Mills { 39a348f287SBarry Smith PetscObjectUseFortranCallbackSubType(dm,_cb.creatematrix,(DM*,Mat*,PetscErrorCode*),(&dm,A,&ierr)); 400ec63f53SRichard Tran Mills } 410ec63f53SRichard Tran Mills 420ec63f53SRichard Tran Mills static PetscErrorCode ourcreateglobalvector(DM dm,Vec *v) 430ec63f53SRichard Tran Mills { 4417da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.createglobalvector,(DM*,Vec*,PetscErrorCode*),(&dm,v,&ierr)); 450ec63f53SRichard Tran Mills } 460ec63f53SRichard Tran Mills 47dc43b69eSJed Brown static PetscErrorCode ourcreatelocalvector(DM dm,Vec *v) 480ec63f53SRichard Tran Mills { 4917da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.createlocalvector,(DM*,Vec*,PetscErrorCode*),(&dm,v,&ierr)); 50dc43b69eSJed Brown } 51dc43b69eSJed Brown 52f2d7aa87SRichard Tran Mills static PetscErrorCode ourglobaltolocalbegin(DM dm,Vec g,InsertMode mode,Vec l) 53f2d7aa87SRichard Tran Mills { 5417da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.globaltolocalbegin,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&g,&mode,&l,&ierr)); 55f2d7aa87SRichard Tran Mills } 56f2d7aa87SRichard Tran Mills 57f2d7aa87SRichard Tran Mills static PetscErrorCode ourglobaltolocalend(DM dm,Vec g,InsertMode mode,Vec l) 58f2d7aa87SRichard Tran Mills { 5917da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.globaltolocalend,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&g,&mode,&l,&ierr)); 60f2d7aa87SRichard Tran Mills } 61f2d7aa87SRichard Tran Mills 62f2d7aa87SRichard Tran Mills static PetscErrorCode ourlocaltoglobalbegin(DM dm,Vec l,InsertMode mode,Vec g) 63f2d7aa87SRichard Tran Mills { 6417da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.localtoglobalbegin,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&l,&mode,&g,&ierr)); 65f2d7aa87SRichard Tran Mills } 66f2d7aa87SRichard Tran Mills 67f2d7aa87SRichard Tran Mills static PetscErrorCode ourlocaltoglobalend(DM dm,Vec l,InsertMode mode,Vec g) 68f2d7aa87SRichard Tran Mills { 6917da0f0dSJed Brown PetscObjectUseFortranCallbackSubType(dm,_cb.localtoglobalend,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&l,&mode,&g,&ierr)); 70f2d7aa87SRichard Tran Mills } 71f2d7aa87SRichard Tran Mills 72f3db62a7SRichard Tran Mills static PetscErrorCode ourlocaltolocalbegin(DM dm,Vec g,InsertMode mode,Vec l) 73f3db62a7SRichard Tran Mills { 74f3db62a7SRichard Tran Mills PetscObjectUseFortranCallbackSubType(dm,_cb.localtolocalbegin,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&g,&mode,&l,&ierr)); 75f3db62a7SRichard Tran Mills } 76f3db62a7SRichard Tran Mills 77f3db62a7SRichard Tran Mills static PetscErrorCode ourlocaltolocalend(DM dm,Vec g,InsertMode mode,Vec l) 78f3db62a7SRichard Tran Mills { 79f3db62a7SRichard Tran Mills PetscObjectUseFortranCallbackSubType(dm,_cb.localtolocalend,(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),(&dm,&g,&mode,&l,&ierr)); 80f3db62a7SRichard Tran Mills } 81f3db62a7SRichard Tran Mills 82f3db62a7SRichard Tran Mills 83*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetcreatematrix_(DM *dm,void (*func)(DM*,Mat*,PetscErrorCode*,PETSC_FORTRAN_CHARLEN_T len),PetscErrorCode *ierr) 84dc43b69eSJed Brown { 85aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.creatematrix,(PetscVoidFunction)func,NULL);if (*ierr) return; 860ec63f53SRichard Tran Mills *ierr = DMShellSetCreateMatrix(*dm,ourcreatematrix); 870ec63f53SRichard Tran Mills } 880ec63f53SRichard Tran Mills 89*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetcreateglobalvector_(DM *dm,void (*func)(DM*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) 900ec63f53SRichard Tran Mills { 91aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.createglobalvector,(PetscVoidFunction)func,NULL);if (*ierr) return; 920ec63f53SRichard Tran Mills *ierr = DMShellSetCreateGlobalVector(*dm,ourcreateglobalvector); 930ec63f53SRichard Tran Mills } 94fa59e805SSatish Balay 95*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetcreatelocalvector_(DM *dm,void (*func)(DM*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) 96dc43b69eSJed Brown { 97aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.createlocalvector,(PetscVoidFunction)func,NULL);if (*ierr) return; 98dc43b69eSJed Brown *ierr = DMShellSetCreateLocalVector(*dm,ourcreatelocalvector); 99dc43b69eSJed Brown } 100f2d7aa87SRichard Tran Mills 101*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetglobaltolocal_(DM *dm,void (*begin)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),void (*end)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) 102f2d7aa87SRichard Tran Mills { 103aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.globaltolocalbegin,(PetscVoidFunction)begin,NULL);if (*ierr) return; 104aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.globaltolocalend,(PetscVoidFunction)end,NULL);if (*ierr) return; 105f2d7aa87SRichard Tran Mills *ierr = DMShellSetGlobalToLocal(*dm,ourglobaltolocalbegin,ourglobaltolocalend); 106f2d7aa87SRichard Tran Mills } 107f2d7aa87SRichard Tran Mills 108*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetlocaltoglobal_(DM *dm,void (*begin)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),void (*end)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) 109f2d7aa87SRichard Tran Mills { 110aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.localtoglobalbegin,(PetscVoidFunction)begin,NULL);if (*ierr) return; 111aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.localtoglobalend,(PetscVoidFunction)end,NULL);if (*ierr) return; 11217da0f0dSJed Brown *ierr = DMShellSetLocalToGlobal(*dm,ourlocaltoglobalbegin,ourlocaltoglobalend); 113f2d7aa87SRichard Tran Mills } 114f3db62a7SRichard Tran Mills 115*19caf8f3SSatish Balay PETSC_EXTERN void dmshellsetlocaltolocal_(DM *dm,void (*begin)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),void (*end)(DM*,Vec*,InsertMode*,Vec*,PetscErrorCode*),PetscErrorCode *ierr) 116f3db62a7SRichard Tran Mills { 117aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.localtolocalbegin,(PetscVoidFunction)begin,NULL);if (*ierr) return; 118aecf964fSBarry Smith *ierr = PetscObjectSetFortranCallback((PetscObject)*dm,PETSC_FORTRAN_CALLBACK_SUBTYPE,&_cb.localtolocalend,(PetscVoidFunction)end,NULL);if (*ierr) return; 119f3db62a7SRichard Tran Mills *ierr = DMShellSetLocalToLocal(*dm,ourlocaltolocalbegin,ourlocaltolocalend); 120f3db62a7SRichard Tran Mills } 121