/[escript]/trunk/finley/src/Mesh_read.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_read.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2059 by gross, Mon Nov 17 22:57:50 2008 UTC revision 2385 by gross, Wed Apr 15 03:52:38 2009 UTC
# Line 270  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 270  Finley_Mesh* Finley_Mesh_read_MPI(char*
270    
271  {  {
272    
273    Paso_MPIInfo *mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );    Paso_MPIInfo *mpi_info = NULL;
274    dim_t numNodes, numDim, numEle, i0, i1;    dim_t numNodes, numDim, numEle, i0, i1;
275    Finley_Mesh *mesh_p=NULL;    Finley_Mesh *mesh_p=NULL;
276    char name[LenString_MAX],element_type[LenString_MAX],frm[20];    char name[LenString_MAX],element_type[LenString_MAX],frm[20];
# Line 283  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 283  Finley_Mesh* Finley_Mesh_read_MPI(char*
283    int scan_ret;    int scan_ret;
284    
285    Finley_resetError();    Finley_resetError();
286      mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
287    
288    if (mpi_info->rank == 0) {    if (mpi_info->rank == 0) {
289       /* get file handle */       /* get file handle */
# Line 308  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 309  Finley_Mesh* Finley_Mesh_read_MPI(char*
309    /* MPI Broadcast numDim, numNodes, name if there are multiple MPI procs*/    /* MPI Broadcast numDim, numNodes, name if there are multiple MPI procs*/
310    if (mpi_info->size > 1) {    if (mpi_info->size > 1) {
311      int temp1[3], error_code;      int temp1[3], error_code;
312      temp1[0] = numDim;      if (mpi_info->rank == 0) {
313      temp1[1] = numNodes;         temp1[0] = numDim;
314      temp1[2] = strlen(name) + 1;         temp1[1] = numNodes;
315           temp1[2] = strlen(name) + 1;
316        } else {
317           temp1[0] = 0;
318           temp1[1] = 0;
319           temp1[2] = 1;
320        }
321      error_code = MPI_Bcast (temp1, 3, MPI_INT,  0, mpi_info->comm);      error_code = MPI_Bcast (temp1, 3, MPI_INT,  0, mpi_info->comm);
322      if (error_code != MPI_SUCCESS) {      if (error_code != MPI_SUCCESS) {
323        Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: broadcast of temp1 failed");        Finley_setError(PASO_MPI_ERROR, "Finley_Mesh_read: broadcast of temp1 failed");
# Line 326  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 333  Finley_Mesh* Finley_Mesh_read_MPI(char*
333    }    }
334  #endif  #endif
335    
336    
337       /* allocate mesh */       /* allocate mesh */
338       mesh_p = Finley_Mesh_alloc(name,numDim,order,reduced_order,mpi_info);       mesh_p = Finley_Mesh_alloc(name,numDim,order,reduced_order,mpi_info);
339       if (Finley_noError()) {       if (Finley_noError()) {
# Line 858  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 866  Finley_Mesh* Finley_Mesh_read_MPI(char*
866        /* get the name tags */        /* get the name tags */
867        if (Finley_noError()) {        if (Finley_noError()) {
868          char *remainder=0, *ptr;          char *remainder=0, *ptr;
869          size_t len;          size_t len=0;
870    #ifdef PASO_MPI
871            int len_i;
872    #endif
873          int tag_key;          int tag_key;
   
   
   
874          if (mpi_info->rank == 0) {  /* Master */          if (mpi_info->rank == 0) {  /* Master */
875        /* Read the word 'Tag' */        /* Read the word 'Tag' */
876        if (! feof(fileHandle_p)) {        if (! feof(fileHandle_p)) {
# Line 919  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 927  Finley_Mesh* Finley_Mesh_read_MPI(char*
927            }            }
928  #endif  #endif
929        len = strlen(remainder);        len = strlen(remainder);
930        while ((--len)>0 && isspace(remainder[len])) remainder[len]=0;  /*    while (((--len)>0) && isspace((int)(remainder[len]))) {remainder[len]=0;}  */
931          while ((len>1) && isspace(remainder[--len])) {remainder[len]=0;}
932        len = strlen(remainder);        len = strlen(remainder);
933            TMPMEMREALLOC(remainder,remainder,len+1,char);            TMPMEMREALLOC(remainder,remainder,len+1,char);
934          }          }
935  #ifdef PASO_MPI  #ifdef PASO_MPI
936    
937          if (MPI_Bcast (&len, 1, MPI_INT,  0, mpi_info->comm) != MPI_SUCCESS)          len_i=(int) len;
938            if (MPI_Bcast (&len_i, 1, MPI_INT,  0, mpi_info->comm) != MPI_SUCCESS)
939          {          {
940             Finley_setError(PASO_MPI_ERROR,             Finley_setError(PASO_MPI_ERROR,
941                             "Finley_Mesh_read: broadcast of tag len failed");                             "Finley_Mesh_read: broadcast of tag len failed");
942             return NULL;             return NULL;
943          }          }
944            len=(size_t) len_i;
945      if (mpi_info->rank != 0) {      if (mpi_info->rank != 0) {
946        remainder = TMPMEMALLOC(len+1, char);        remainder = TMPMEMALLOC(len+1, char);
947        remainder[0] = 0;        remainder[0] = 0;
948      }      }
   
949          if (MPI_Bcast (remainder, len+1, MPI_CHAR,  0, mpi_info->comm) !=          if (MPI_Bcast (remainder, len+1, MPI_CHAR,  0, mpi_info->comm) !=
950              MPI_SUCCESS)              MPI_SUCCESS)
951          {          {
# Line 944  Finley_Mesh* Finley_Mesh_read_MPI(char* Line 954  Finley_Mesh* Finley_Mesh_read_MPI(char*
954             return NULL;             return NULL;
955          }          }
956  #endif  #endif
957    
958      if (remainder[0]) {      if (remainder[0]) {
959            ptr = remainder;            ptr = remainder;
960            do {            do {

Legend:
Removed from v.2059  
changed lines
  Added in v.2385

  ViewVC Help
Powered by ViewVC 1.1.26