[petsc-users] PetscMalloc with Fortran
Jonas Mairhofer
mairhofer at itt.uni-stuttgart.de
Thu May 15 11:56:44 CDT 2014
If 'colors' can be a dynamically allocated array then I dont know where
the mistake is in this code:
ISColoring iscoloring
Integer, allocatable :: colors(:)
PetscInt maxc
...
!calculate max. number of colors
maxc = 2*irc+1 !irc is the number of ghost nodes needed to
calculate the function I want to solve
allocate(colors(user%xm)) !where user%xm is the number of locally
owned nodes of a global array
!Set colors
DO i=1,user%xm
colors(i) = mod(i,maxc)
END DO
call
ISColoringCreate(PETSC_COMM_WORLD,maxc,user%xm,colors,iscoloring,ierr)
...
deallocate(colors)
call ISColoringDestroy(iscoloring,ierr)
On execution I get the following error message (running the DO Loop from
0 to user%xm-1 does not change anything):
[0]PETSC ERROR: --------------------- Error Message
------------------------------------
[0]PETSC ERROR: Arguments are incompatible!
[0]PETSC ERROR: Number of colors passed in 291 is less then the actual
number of colors in array 61665!
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 3.4.4, Mar, 13, 2014
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: ./DFT on a arch-linux2-c-debug named
aries.itt.uni-stuttgart.de by mhofer Thu May 15 18:01:41 2014
[0]PETSC ERROR: Libraries linked from
/usr/ITT/mhofer/Documents/Diss/NumericalMethods/Libraries/Petsc/petsc-3.4.4/arch-linux2-c-debug/lib
[0]PETSC ERROR: Configure run at Wed Mar 19 11:00:35 2014
[0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran
--download-f-blas-lapack --download-mpich
[0]PETSC ERROR:
------------------------------------------------------------------------
[0]PETSC ERROR: ISColoringCreate() line 276 in
/usr/ITT/mhofer/Documents/Diss/NumericalMethods/Libraries/Petsc/petsc-3.4.4/src/vec/is/is/utils/iscoloring.c
But when I print out colors, it only has entries from 0 to 218, so no
entry is larger then 291 as stated in the error message.
Am 15.05.2014 16:45, schrieb Jed Brown:
> Jonas Mairhofer <mairhofer at itt.uni-stuttgart.de> writes:
>
>> Hi, I'm trying to set the coloring of a matrix using ISColoringCreate.
>> Therefore I need an array 'colors' which in C can be creates as (from
>> example ex5s.c)
>>
>> int *colors
>> PetscMalloc(...,&colors)
> There is no PetscMalloc in Fortran, due to language "deficiencies".
>
>> colors(i) = ....
>>
>> ISColoringCreate(...)
>>
>> How do I have to define the array colors in Fortran?
>>
>> I tried:
>>
>> Integer, allocatable :: colors(:) and allocate() instead of
>> PetscMalloc
>>
>> and
>>
>> Integer, pointer :: colors
>>
>> but neither worked.
> The ISColoringCreate Fortran binding copies from the array you pass into
> one allocated using PetscMalloc. You should pass a normal Fortran array
> (statically or dynamically allocated).
More information about the petsc-users
mailing list