[Trilinos-Users] Teuchos link error with Xcode
Heroux, Mike
MHeroux at CSBSJU.EDU
Sat Jul 18 22:32:17 EDT 2015
The line that Mark mentions is a special situation added for 64-but
support. Otherwise, Epetra method use integer return codes. A zero value
means normal behavior, positive a diagnostic (usually performance
related), negative is a real error.
Exceptions are consistently used in constructors, where an int return code
is not possible. Epetra was designed to work with C and Fortran as much
as possible, which is why exceptions were not widely used.
The first thing you should do is check the return codes on Epetra method
calls. You can also do a try and catch on the constructor calls.
Mike
On 7/17/15, 6:17 PM, "Trilinos-Users on behalf of Hoemmen, Mark"
<trilinos-users-bounces at trilinos.org on behalf of mhoemme at sandia.gov>
wrote:
>On 7/17/15, 9:48 AM, "trilinos-users-request at trilinos.org"
><trilinos-users-request at trilinos.org> wrote:
>>Message: 1
>>Date: Tue, 14 Jul 2015 14:11:44 +0200
>>From: Sensei <senseiwa at gmail.com>
>>To: trilinos-users at trilinos.org
>>Subject: Re: [Trilinos-Users] Teuchos link error with Xcode
>>Message-ID: <55A4FC80.8040005 at gmail.com>
>>Content-Type: text/plain; charset=utf-8; format=flowed
>>
>>An addition to the problem.
>>
>>It seems I cannot create an Epetra_Map correctly. In addition to the
>>code I've posted, which cannot be linked for some missing identifiers,
>>I've found a weird error.
>>
>>If I create a map, be either with RCP or standalone, it crashes.
>>
>>Take a look at this code, crashing when accessing a map:
>>
>>...
>>int main(int argc, char * argv[])
>>{
>> int rank = 0;
>>
>>#ifdef EPETRA_MPI
>> // Initialize MPI
>> MPI_Init(&argc,&argv);
>> Epetra_MpiComm Comm(MPI_COMM_WORLD);
>> rank = Comm.MyPID();
>>#else
>> Epetra_SerialComm Comm;
>>#endif
>>
>> typedef double ST;
>> typedef Teuchos::ScalarTraits<ST> SCT;
>> typedef SCT::magnitudeType MT;
>> typedef Epetra_MultiVector MV;
>> typedef Epetra_Operator OP;
>> typedef Belos::MultiVecTraits<ST,MV> MVT;
>> typedef Belos::OperatorTraits<ST,MV,OP> OPT;
>> using Teuchos::ParameterList;
>> using Teuchos::RCP;
>> using Teuchos::rcp;
>>
>> RCP<Epetra_Map> Map;//(new Epetra_Map(20, 0, Comm)); // LINK ERROR
>>IF CONSTRUCTED WITH new Epetra_Map
>> RCP<Epetra_CrsMatrix> A;
>> RCP<Epetra_MultiVector> B, X;
>>
>> Epetra_Map m(200, 0, Comm); // RUNTIME ERROR
>>
>> if (rank == 0) {
>> std::cout << "Communicator size " << Comm.NumProc() <<
>>std::endl;
>> int willCrash = 1;
>> switch (willCrash) {
>> case 1: // CRASH WITH MAP
>> std::cout << "MAP " << rank << " #global " <<
>>m.NumGlobalElements() << " #local " << m.NumMyElements() << std::endl;
>> break;
>>
>> case 2: // CRASH WITH RCP
>> std::cout << "RCP " << rank << " #global " <<
>>Map->NumGlobalElements() << " #local " << Map->NumMyElements() <<
>>std::endl;
>> break;
>>
>> default: // NO CRASH
>> std::cout << rank << std::endl;
>> break;
>> }
>> }
>>
>>#ifdef EPETRA_MPI
>> MPI_Finalize();
>>#endif
>> return 0;
>>}
>>
>>The error at runtime is the following:
>>
>>Communicator size 4
>>MAP 0 #global libc++abi.dylib: terminating with uncaught exception of
>>type char const*
>>...
>>Why is Epetra_BlockMap::NumGlobalElements crashing? Am I doing something
>>really stupid?
>
>
>Epetra actually does throw exceptions of type "char const*, which are
>error messages. A first step to figuring out what's going on might be to
>catch and print them. I don't think Epetra necessarily promises parallel
>consistency, so you'll have to use std::cerr to print them out on each
>process.
>
>I think the only place where Epetra_BlockMap::NumGlobalElements could
>throw is line 549 of Epetra_BlockMap.h. Furthermore, the only way it can
>throw is if GlobalIndicesInt() returns false. That's a little bit weird,
>given that you are passing in an int as the global size, rather than a
>long long. Of course Epetra_Map's constructor shouldn't be throwing here
>-- I think your code is OK.
>
>
>mfh
>
>
>
>
>
>_______________________________________________
>Trilinos-Users mailing list
>Trilinos-Users at trilinos.org
>https://trilinos.org/mailman/listinfo/trilinos-users
More information about the Trilinos-Users
mailing list