| 18 | 
  | 
    | 
| 19 | 
  | 
   if(!output){ | 
| 20 | 
  | 
     sprintf( painCave.errMsg, | 
| 21 | 
< | 
              "Could not open \"s\" for z constrain output \n", | 
| 22 | 
< | 
               filename); | 
| 21 | 
> | 
              "Could not open %s for z constrain output \n", | 
| 22 | 
> | 
         filename); | 
| 23 | 
  | 
     painCave.isFatal = 1; | 
| 24 | 
  | 
     simError(); | 
| 25 | 
  | 
   } | 
| 26 | 
  | 
   output << "#number of z constrain molecules" << endl; | 
| 27 | 
  | 
   output << "#global Index of molecule\tzPos" << endl; | 
| 28 | 
< | 
 | 
| 29 | 
< | 
   parameters = thePara; | 
| 30 | 
< | 
        writeZPos(); | 
| 31 | 
< | 
 | 
| 28 | 
> | 
   output << "#every frame will contain below data" <<endl; | 
| 29 | 
  | 
   output << "#time(fs)" << endl; | 
| 30 | 
  | 
   output << "#number of fixed z-constrain molecules" << endl; | 
| 31 | 
  | 
   output << "#global Index of molecule\tzconstrain force\tcurrentZPos" << endl; | 
| 32 | 
  | 
 | 
| 33 | 
+ | 
   parameters = thePara; | 
| 34 | 
+ | 
   writeZPos(); | 
| 35 | 
  | 
 | 
| 36 | 
  | 
#ifdef IS_MPI | 
| 37 | 
  | 
  } | 
| 51 | 
  | 
#endif | 
| 52 | 
  | 
} | 
| 53 | 
  | 
 | 
| 54 | 
< | 
void ZConsWriter::writeFZ(double time, int num, int* index, double* fz, double* curZPos) | 
| 55 | 
< | 
{ | 
| 54 | 
> | 
/** | 
| 55 | 
> | 
 * | 
| 56 | 
> | 
 */ | 
| 57 | 
> | 
void ZConsWriter::writeFZ(double time, int num, int* index, double* fz, double* curZPos){ | 
| 58 | 
  | 
 | 
| 59 | 
  | 
#ifndef IS_MPI | 
| 60 | 
  | 
  output << time << endl; | 
| 61 | 
  | 
  output << num << endl; | 
| 62 | 
< | 
         | 
| 62 | 
> | 
   | 
| 63 | 
  | 
  for(int i = 0; i < num; i++) | 
| 64 | 
  | 
    output << index[i] <<"\t" << fz[i] << "\t" << curZPos[i] << endl; | 
| 65 | 
  | 
 | 
| 66 | 
  | 
#else | 
| 67 | 
< | 
 | 
| 67 | 
> | 
  int totalNum; | 
| 68 | 
> | 
  MPI_Allreduce(&num, &totalNum, 1, MPI_INT,MPI_SUM, MPI_COMM_WORLD);  | 
| 69 | 
> | 
   | 
| 70 | 
> | 
  if(worldRank == 0){ | 
| 71 | 
> | 
    output << time << endl; | 
| 72 | 
> | 
    output << totalNum << endl; | 
| 73 | 
> | 
  } | 
| 74 | 
> | 
   | 
| 75 | 
  | 
  int whichNode; | 
| 76 | 
  | 
  enum CommType { RequesPosAndForce, EndOfRequest} status; | 
| 77 | 
  | 
  double pos; | 
| 86 | 
  | 
    int *MolToProcMap; | 
| 87 | 
  | 
    MolToProcMap = mpiSim->getMolToProcMap(); | 
| 88 | 
  | 
     | 
| 89 | 
< | 
    for(int i = 0; i < parameters->size(); i++){ | 
| 89 | 
> | 
    for(int i = 0; i < (int)(parameters->size()); i++){ | 
| 90 | 
  | 
       | 
| 91 | 
  | 
      globalIndexOfCurMol = (*parameters)[i].zconsIndex; | 
| 92 | 
  | 
      whichNode = MolToProcMap[globalIndexOfCurMol]; | 
| 93 | 
  | 
       | 
| 94 | 
  | 
      if(whichNode == 0){ | 
| 95 | 
  | 
         | 
| 96 | 
< | 
             for(int j = 0; j < num; j++) | 
| 97 | 
< | 
              if(index[j] == globalIndexOfCurMol){ | 
| 98 | 
< | 
                localIndex = j; | 
| 99 | 
< | 
                break; | 
| 100 | 
< | 
              } | 
| 96 | 
> | 
       for(int j = 0; j < num; j++) | 
| 97 | 
> | 
        if(index[j] == globalIndexOfCurMol){ | 
| 98 | 
> | 
          localIndex = j; | 
| 99 | 
> | 
          break; | 
| 100 | 
> | 
        } | 
| 101 | 
  | 
 | 
| 102 | 
< | 
                        force = fz[localIndex]; | 
| 103 | 
< | 
                        pos = curZPos[localIndex]; | 
| 104 | 
< | 
                   | 
| 102 | 
> | 
      force = fz[localIndex]; | 
| 103 | 
> | 
      pos = curZPos[localIndex]; | 
| 104 | 
> | 
       | 
| 105 | 
  | 
      } | 
| 106 | 
  | 
      else{ | 
| 107 | 
  | 
        status = RequesPosAndForce; | 
| 108 | 
  | 
        MPI_Send(&status, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); | 
| 109 | 
< | 
             MPI_Send(&globalIndexOfCurMol, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); | 
| 109 | 
> | 
        MPI_Send(&globalIndexOfCurMol, 1, MPI_INT, whichNode, tag, MPI_COMM_WORLD); | 
| 110 | 
  | 
        MPI_Recv(&force, 1, MPI_DOUBLE_PRECISION, whichNode, tag, MPI_COMM_WORLD, &ierr); | 
| 111 | 
  | 
        MPI_Recv(&pos, 1, MPI_DOUBLE_PRECISION, whichNode, tag, MPI_COMM_WORLD, &ierr); | 
| 112 | 
  | 
      } | 
| 113 | 
  | 
 | 
| 114 | 
< | 
                output << globalIndexOfCurMol << "\t" << force << "\t" << pos << endl; | 
| 114 | 
> | 
     output << globalIndexOfCurMol << "\t" << force << "\t" << pos << endl; | 
| 115 | 
  | 
               | 
| 116 | 
  | 
    } //End of Request Loop | 
| 117 | 
  | 
     | 
| 132 | 
  | 
     | 
| 133 | 
  | 
      switch (status){ | 
| 134 | 
  | 
           | 
| 135 | 
< | 
        case RequesPosAndForce :  | 
| 135 | 
> | 
         case RequesPosAndForce :  | 
| 136 | 
  | 
           | 
| 137 | 
< | 
               MPI_Recv(&whichMol, 1, MPI_INT, 0, tag, MPI_COMM_WORLD,&ierr); | 
| 138 | 
< | 
           | 
| 139 | 
< | 
               for(int i = 0; i < num; i++) | 
| 140 | 
< | 
                 if(index[i] == whichMol){ | 
| 141 | 
< | 
                   localIndex = i; | 
| 142 | 
< | 
                   break; | 
| 143 | 
< | 
                 } | 
| 144 | 
< | 
           | 
| 145 | 
< | 
               MPI_Send(&fz[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD);         | 
| 146 | 
< | 
               MPI_Send(&curZPos[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD);            | 
| 147 | 
< | 
               break; | 
| 148 | 
< | 
              | 
| 137 | 
> | 
           MPI_Recv(&whichMol, 1, MPI_INT, 0, tag, MPI_COMM_WORLD,&ierr); | 
| 138 | 
> | 
     | 
| 139 | 
> | 
           for(int i = 0; i < num; i++) | 
| 140 | 
> | 
           if(index[i] == whichMol){ | 
| 141 | 
> | 
             localIndex = i; | 
| 142 | 
> | 
             break; | 
| 143 | 
> | 
           } | 
| 144 | 
> | 
     | 
| 145 | 
> | 
           MPI_Send(&fz[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD);     | 
| 146 | 
> | 
           MPI_Send(&curZPos[localIndex], 1, MPI_DOUBLE_PRECISION, 0, tag, MPI_COMM_WORLD);        | 
| 147 | 
> | 
           break; | 
| 148 | 
> | 
        | 
| 149 | 
  | 
        case EndOfRequest : | 
| 150 | 
  | 
          | 
| 151 | 
< | 
               done = true; | 
| 152 | 
< | 
               break; | 
| 151 | 
> | 
         done = true; | 
| 152 | 
> | 
         break; | 
| 153 | 
  | 
      } | 
| 154 | 
  | 
       | 
| 155 | 
  | 
    } | 
| 160 | 
  | 
 | 
| 161 | 
  | 
} | 
| 162 | 
  | 
 | 
| 163 | 
+ | 
/* | 
| 164 | 
+ | 
 * | 
| 165 | 
+ | 
 */ | 
| 166 | 
  | 
void ZConsWriter::writeZPos(){ | 
| 167 | 
  | 
 | 
| 168 | 
  | 
#ifdef IS_MPI | 
| 169 | 
  | 
  if(worldRank == 0){ | 
| 170 | 
  | 
#endif | 
| 171 | 
  | 
     | 
| 172 | 
< | 
     output << parameters->size() << endl;      | 
| 172 | 
> | 
    output << parameters->size() << endl;      | 
| 173 | 
  | 
     | 
| 174 | 
< | 
    for(int i =0 ; i < parameters->size(); i++) | 
| 174 | 
> | 
    for(int i =0 ; i < (int)(parameters->size()); i++) | 
| 175 | 
  | 
      output << (*parameters)[i].zconsIndex << "\t" <<  (*parameters)[i].zPos << endl; | 
| 176 | 
  | 
 | 
| 177 | 
  | 
#ifdef IS_MPI |