43 #include "Epetra_Comm.h"
44 #include "Epetra_BlockMap.h"
45 #include "Epetra_Map.h"
46 #include "Epetra_Vector.h"
47 #include "Epetra_IntVector.h"
48 #include "Epetra_LongLongVector.h"
49 #include "Epetra_GIDTypeVector.h"
50 #include "Epetra_SerialDenseVector.h"
51 #include "Epetra_IntSerialDenseVector.h"
52 #include "Epetra_LongLongSerialDenseVector.h"
53 #include "Epetra_GIDTypeSerialDenseVector.h"
54 #include "Epetra_Import.h"
55 #include "Epetra_CrsMatrix.h"
62 std::FILE * handle = 0;
64 handle = fopen(filename,
"w");
65 if (!handle)
return(-1);
70 if (fclose(handle))
return(-1);
75 const char * matrixName,
76 const char *matrixDescription,
78 long long M = A.GlobalLength64();
85 handle = fopen(filename,
"w");
86 if (!handle)
return(-1);
93 if (writeHeader==
true) {
97 if (matrixName!=0) fprintf(handle,
"%% \n%% %s\n", matrixName);
98 if (matrixDescription!=0) fprintf(handle,
"%% %s\n%% \n", matrixDescription);
107 if (fclose(handle))
return(-1);
118 template<
typename int_type>
144 Epetra_Map allGidsMap((int_type) -1, numRows, (int_type) 0,comm);
147 for (
int i=0; i<numRows; i++) allGids[i] = (int_type) map.GID64(i);
150 int numChunks = numProc;
151 int stripSize = allGids.GlobalLength64()/numChunks;
152 int remainder = allGids.GlobalLength64()%numChunks;
154 int curStripSize = 0;
157 importGidList.Size(stripSize+1);
158 for (
int i=0; i<numChunks; i++) {
159 if (comm.
MyPID()==0) {
160 curStripSize = stripSize;
161 if (i<remainder) curStripSize++;
162 for (
int j=0; j<curStripSize; j++) importGidList[j] = j + curStart;
163 curStart += curStripSize;
166 Epetra_Map importGidMap((int_type) -1, curStripSize, importGidList.Values(), (int_type) 0, comm);
169 if (importGids.Import(allGids, gidImporter,
Insert))
return(-1);
175 Epetra_Map importMap((int_type) -1, importGids.MyLength(), importGids.Values(), (int_type) 0, comm);
178 if (importA.Import(A1, importer,
Insert))
return(-1);
188 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
190 return TMultiVectorToHandle<int>(handle, A, mmFormat);
194 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
196 return TMultiVectorToHandle<long long>(handle, A, mmFormat);
200 throw "EpetraExt::MultiVectorToHandle: GlobalIndices type unknown";
206 long long length = A.GlobalLength64();
209 if (comm.
MyPID()!=0) {
213 if (length!=A.
MyLength()) ierr = -1;
214 for (
int j=0; j<numVectors; j++) {
215 for (
long long i=0; i<length; i++) {
216 double val = A[j][i];
218 fprintf(handle,
"%22.16e\n", val);
220 fprintf(handle,
"%22.16e ", val);
222 if (!mmFormat) fprintf(handle,
"%s",
"\n");
226 comm.
MinAll(&ierr, &ierrGlobal, 1);