static void parseFile(ParserInterface *parser, Entry *root,EntryNav *rootNav,FileDef *fd,const char *fn, bool sameTu,QStrList &filesInSameTu) { static bool clangAssistedParsing = FALSE; QCString fileName=fn; QCString extension; int ei = fileName.findRev('.'); if (ei!=-1) { extension=fileName.right(fileName.length()-ei); } else { extension = ".no_extension"; } QFileInfo fi(fileName); BufStr preBuf(fi.size()+4096); if (true && parser->needsPreprocessing(extension)) { BufStr inBuf(fi.size()+4096); readInputFile(fileName,inBuf); // preprocessFile(fileName,inBuf,preBuf); } else // no preprocessing { readInputFile(fileName,preBuf); } if (preBuf.data() && preBuf.curPos()>0 && *(preBuf.data()+preBuf.curPos()-1)!='\n') { preBuf.addChar('\n'); // add extra newline to help parser } BufStr convBuf(preBuf.curPos()+1024); // convert multi-line C++ comments to C style comments convertCppComments(&preBuf,&convBuf,fileName); convBuf.addChar('\0'); // use language parse to parse the file parser->parseInput(fileName,convBuf.data(),root,sameTu,filesInSameTu); // store the Entry tree in a file and create an index to // navigate/load entries //printf("root->createNavigationIndex for %s\n",fd->name().data()); root->createNavigationIndex(rootNav,g_storage,fd); }
void CGeneratorInput::readInputFile(const std::string& fileName) { CPinPass::States states; io::TheFileSystem::Get().setRootDir(""); readInputFile(fileName, states); }
bool CLTool::readInput( int argc, char**argv, FILE* in, FILE*out ){ plumed_massert( inputdata!=unset,"You have not specified where your tool reads its input. " "If it is from the command line (like driver) add inputdata=commandline to the " "tools constructor. If it reads everything from an input file (like simplemd) " "add inputdata=ifile to the tools constructor"); if(inputdata==commandline) return readCommandLineArgs( argc, argv, out ); if(inputdata==ifile) return readInputFile( argc, argv, in, out ); return true; }
int main(void) { setvbuf(stdout, NULL, _IONBF, 0); FILE *input_file1 = fopen("in1.bmp", "rb"); FILE *input_file2 = fopen("in2.bmp", "rb"); FILE *blend = fopen("blend.bmp", "wb"); FILE *checker = fopen("checker.bmp", "wb"); char headerA_1[2], headerA_2[12], headerA_3[8], headerA_4[16]; char headerB_1[2], headerB_2[12], headerB_3[8], headerB_4[16]; int width1 = 0, height1 = 0, width2 = 0, height2 = 0; int file_size1 = 0, file_size2 = 0, image_size1 = 0, image_size2 = 0; readInputFile(input_file1, headerA_1, headerA_2, headerA_3, headerA_4, &file_size1, &image_size1, &width1, &height1); readInputFile(input_file2, headerB_1, headerB_2, headerB_3, headerB_4, &file_size2, &image_size2, &width2, &height2); unsigned char pixels1[height1][width1 * 3], pixels2[height2][width2 * 3]; unsigned char checkerData[height1][width1 * 3]; unsigned char blendData[height1][width1 * 3]; readPixels(input_file1, &width1, &height1, pixels1); readPixels(input_file2, &width2, &height2, pixels2); blender(&width1, &height1, pixels1, pixels2, blendData); transformCheckerBoard(&width1, &height1, pixels1, pixels2, checkerData); printOutput(blend, headerA_1, headerA_2, headerA_3, headerA_4, &file_size1, &image_size1, &width1, &height1, blendData); printOutput(checker, headerB_1, headerB_2, headerB_3, headerB_4, &file_size2, &image_size2, &width2, &height2, checkerData); fclose(blend); fclose(checker); return 0; }
int main(int argc, char** argv) { /* Check number of parameters. */ if (argc != 4) usage(argv[0]); /* Read the grid from the input file. */ readInputFile(argv[1]); /* Read the solution file generated by the Prolog run. */ readPrologFile(argv[2]); /* Write the query file. */ writeOutputFile(argv[3]); return 0; }
int main(int argc, char *argv[]){ double **A; int n; int i, j; n = 3; if(DBG) printf("Entering Main\n"); n = readInputFile(&A); if(DBG) printf("Exiting ReadInputFile\n"); procedureLU(A, n); if(DBG) printf("Program Done\n"); return 0; }
int main(int argc, char **argv) { char* fileName; if (argc == 1) { // No parameters fileName = "testInput"; } else { fileName = argv[1]; } int numberOfCases; unsigned long *cases; readInputFile(fileName, &numberOfCases, &cases); printOutput(numberOfCases, cases); free(cases); return EXIT_SUCCESS; }
int main(int argc,char* argv[]) { if(argv[2]==NULL) { printf("Please enter value of num_Empty!!!\n"); return 1; } if(argv[1]==NULL) { printf("Please enter File Name!!!\n"); return 1; } EMPTY=atoi(argv[2]); int readInputFile(char *); int displaynetwork(); int sendMessage(int ,int ,int ,int ); int enterQueue(struct Message *,int ); int displayMessage(struct Message *); int checkQueue(); struct Message* getMessage(int); int initializeQueues(); int broadcastMessage(); logFile=fopen("stage7_log","w"); int statusRead=readInputFile(argv[1]); if(statusRead==0) displaynetwork(); printf("\n"); //creating totalPeers thread int i,status; for (i=2; i<totalPeers+2; i++) thr_create(NULL, 0, peer, (void*)i, THR_BOUND, &thr[i]); printf("\n"); broadcastMessage(); //wait for all threads to finish while (thr_join(0, &tid, (void**)&status)==0) printf("\n[Status of thread Id %d is=%d]", tid,status); checkQueue(); fclose(logFile); fclose(fp); return 0; }
/** * Do it. */ int main(int argc, char** argv) { size_t size; uint8_t* pBuffer; if (argc != 3) usage(argv[0]); pBuffer = malloc(EF_MAX_CART_SIZE + 1); if (pBuffer == NULL) { fprintf(stderr, "Out of memory\n"); return 2; } size = readInputFile(pBuffer, argv[1]); writeCRTLinearLayout(argv[2], pBuffer, size); return 0; }
int main(){ Film *film; int n = 200, vTot, k; double alpha, *prt, *Ft, *Fexp; film = (Film*)allocArrayMemory(sizeof(Film), n); //citirea readInputFile("DateFilme.txt", film, n, &vTot); qsort(film, n, sizeof(Film), cmpFilm);//sortarea reRank(film, n, vTot);//calculul rangurilor writeDebug(film, n); scrierePuncte("NumeLeader2.txt", film, n); //partea de pana aici calculeaza alpha; alpha = 0.897675610478; prt = Zipf(alpha, n); writeOutputFiles(film, n, prt); calcVectRep(prt, film, n, &Ft, &Fexp); for(k=0;(k<n) && (Ft[k]<0.75);k++);// ";" nu e din greasala!!!!!!!!! printf("\nNumarul de file salvate in cache este k = %d\n", k); simulareVizualizari(Ft, n, k); simulareVizualizari(Fexp, n, k); if(prt) free(prt); if(Ft) free(prt); if(Fexp) free(prt); free(film); getch(); return 0; }
void CGeneratorInput::readInputs(const TiXmlElement* elem, CPinPass::States& states) { const TiXmlElement* first = elem->FirstChildElement(); const TiXmlElement* current = first; while(current != NULL) { CLeafElement leaf(current); std::string name = leaf.getName(); if(name == "file") readInputFile(TheGenerator::Get().applyConstants(leaf.getValue()), states); else base::lwrn<<"Unknown element \""<<name<< "\" in inputs block (element \""<< elem->Value()<<"\")."; current = current->NextSiblingElement(); } }
void PlumedMain::init() { // check that initialization just happens once initialized=true; atoms.init(); if(!log.isOpen()) log.link(stdout); log<<"PLUMED is starting\n"; log<<"Version: "<<config::getVersionLong()<<" (git: "<<config::getVersionGit()<<") compiled on " __DATE__ " at " __TIME__ "\n"; log<<"Please cite this paper when using PLUMED "; log<<cite("Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014)"); log<<"\n"; log<<"For further information see the PLUMED web page at http://www.plumed.org\n"; log<<"Root: "<<config::getPlumedRoot()<<"\n"; log<<"For installed feature, see "<<config::getPlumedRoot() + "/src/config/config.txt\n"; log.printf("Molecular dynamics engine: %s\n",MDEngine.c_str()); log.printf("Precision of reals: %d\n",atoms.getRealPrecision()); log.printf("Running over %d %s\n",comm.Get_size(),(comm.Get_size()>1?"nodes":"node")); log<<"Number of threads: "<<OpenMP::getNumThreads()<<"\n"; log<<"Cache line size: "<<OpenMP::getCachelineSize()<<"\n"; log.printf("Number of atoms: %d\n",atoms.getNatoms()); if(grex) log.printf("GROMACS-like replica exchange is on\n"); log.printf("File suffix: %s\n",getSuffix().c_str()); if(plumedDat.length()>0) { readInputFile(plumedDat); plumedDat=""; } atoms.updateUnits(); log.printf("Timestep: %f\n",atoms.getTimeStep()); if(atoms.getKbT()>0.0) log.printf("KbT: %f\n",atoms.getKbT()); else { log.printf("KbT has not been set by the MD engine\n"); log.printf("It should be set by hand where needed\n"); } log<<"Relevant bibliography:\n"; log<<citations; log<<"Please read and cite where appropriate!\n"; log<<"Finished setup\n"; }
/****************************************************************************\ ** ** tInputFile Constructor ** ** Looks for a file called filename, opens it if found or generates an ** error if not. Then reads the base name for output files and creates ** a file called <filename>.inputs which will act as a log file for ** parameters read. (This is often useful when the original input file ** gets lost or modified). ** ** Modifications: ** - 2/02: error check for inoutfile added (GT) ** - rewritten 11/07/2003 AD ** \****************************************************************************/ tInputFile::tInputFile( const char *filename ) { std::ifstream infile; // the input file // Open file infile.open( filename ); if( !infile.good() ) { std::cerr << "tInputFile::tInputFile: Unable to open '" << filename << "'." << std::endl; ReportFatalError( "The file may not exist or may be mis-named." ); } // Set KeyWordTable { tList< tKeyPair > KeyWordList; readInputFile(infile, KeyWordList); setKeyWordTable(KeyWordTable, KeyWordList); } infile.close(); // write log File writeLogFile(); }
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( MeshGenerator, mixed, DeviceType ) { MPI_Comm comm = MPI_COMM_WORLD; Kokkos::View<DTK_CellTopology *, DeviceType> cell_topologies_view; Kokkos::View<unsigned int *, DeviceType> cells; Kokkos::View<double **, DeviceType> coordinates; // 2D test std::string filename = "mixed_2d.txt"; std::vector<std::vector<DataTransferKit::Coordinate>> coordinates_ref; std::vector<unsigned int> cells_ref; std::tie( coordinates_ref, cells_ref ) = readInputFile( filename ); unsigned int dim = 2; // Move mesh according to the rank int comm_rank; MPI_Comm_rank( comm, &comm_rank ); double offset = 3. * comm_rank; for ( auto &coord : coordinates_ref ) coord[0] += offset; std::tie( cell_topologies_view, cells, coordinates ) = buildMixedMesh<DeviceType>( comm, dim ); // Check view size unsigned int n_vertices = coordinates_ref.size(); unsigned int n_cells = 6; TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells ); TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() ); TEST_EQUALITY( coordinates.extent( 0 ), n_vertices ); // Check topology auto cell_topologies_view_host = Kokkos::create_mirror_view( cell_topologies_view ); Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view ); std::vector<DTK_CellTopology> cell_topology_ref = { {DTK_QUAD_4, DTK_TRI_3, DTK_QUAD_4, DTK_QUAD_4, DTK_TRI_3, DTK_QUAD_4}}; for ( unsigned int i = 0; i < n_cells; ++i ) TEST_EQUALITY( cell_topologies_view_host( i ), cell_topology_ref[i] ); // Check cells auto cells_host = Kokkos::create_mirror_view( cells ); Kokkos::deep_copy( cells_host, cells ); TEST_COMPARE_ARRAYS( cells_host, cells_ref ); // Check coordinates auto coordinates_host = Kokkos::create_mirror_view( coordinates ); Kokkos::deep_copy( coordinates_host, coordinates ); for ( unsigned int i = 0; i < n_vertices; ++i ) for ( unsigned int j = 0; j < dim; ++j ) TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] ); // 3D test filename = "mixed_3d.txt"; std::tie( coordinates_ref, cells_ref ) = readInputFile( filename ); dim = 3; // Move mesh according to the rank for ( auto &coord : coordinates_ref ) coord[0] += offset; std::tie( cell_topologies_view, cells, coordinates ) = buildMixedMesh<DeviceType>( comm, dim ); // Check view size n_vertices = coordinates_ref.size(); TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells ); TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() ); TEST_EQUALITY( coordinates.extent( 0 ), n_vertices ); // Check topology Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view ); cell_topology_ref = { {DTK_HEX_8, DTK_TET_4, DTK_HEX_8, DTK_HEX_8, DTK_TET_4, DTK_HEX_8}}; for ( unsigned int i = 0; i < n_cells; ++i ) TEST_EQUALITY( cell_topologies_view_host( i ), cell_topology_ref[i] ); // Check cells cells_host = Kokkos::create_mirror_view( cells ); Kokkos::deep_copy( cells_host, cells ); TEST_COMPARE_ARRAYS( cells_host, cells_ref ); // Check coordinates coordinates_host = Kokkos::create_mirror_view( coordinates ); Kokkos::deep_copy( coordinates_host, coordinates ); for ( unsigned int i = 0; i < n_vertices; ++i ) for ( unsigned int j = 0; j < dim; ++j ) TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] ); }
int main(int argc, char **argv) { node_t * curr; tree_info root; mergelist *mergeroot,*mergetemp,*mergecurrent,*mergeprev; int i,j; char *word; char *searchString; // int wordLength; long long fileSize; long long currFileSize; int fileCount; long long fileOffset; long long low, prevlow, high,prevhigh, mid ; int numiterations; char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; char *tempFileName; FILE *input, *output; fileCount=0; if(argc != 4) { printf(" Usage : %s <inputfile> <searchstring> <numiterations>",argv[0]); return -1; } searchString = argv[2]; numiterations = atol(argv[3]); input = fopen(argv[1],"r"); if(!input) { printf("Failed to open input file"); return -1; } fseek(input,0,SEEK_END); fileSize = ftell(input); printf("filesize = %d\n",fileSize); fseek(input,0,SEEK_SET); i=0; low=0; high = fileSize-1; while(1) { int templow; int temphigh; mid=(low+high)/2; printf("low =%lld, high = %lld, mid = %lld , high - low =%lld, high - mid = %lld\n", low,high, mid, high -low, high -mid); fseek(input,mid,SEEK_SET); word=readInputFile(input); templow = mid+strlen(word); free(word); word = readInputFile(input); temphigh = templow+strlen(word); if(high -mid <strlen(word)) { break; } /**if(ftell(input) >high) { free(word); fseek(input,low,SEEK_SET); while(ftell(input)<=high) { word = readInputFile(input); if(word!=NULL) { printf("Processed %s\n",word); free(word); } } word = readInputFile(input); if(word!=NULL) { printf("Processed %s\n",word); free(word); } word = readInputFile(input); if(word!=NULL) { printf("Processed %s\n",word); free(word); } break; }**/ if(word!=NULL) { printf("%s\n",word); prevhigh = high; prevlow = low; if(strcmp(searchString,word) < 0) { high=temphigh; } else { low=templow; } free(word); } if((high==prevhigh)&&(low==prevlow)) { break; } i++; if(i==numiterations) { break; } } fseek(input,low,SEEK_SET); word = readInputFile(input); printf("Processed %s\n",word); free(word); word = readInputFile(input); printf("Processed %s\n",word); free(word); word = readInputFile(input); printf("Processed %s\n",word); free(word); fclose(input); return -1; grandTotalTreeNodes=0; grandTotalTreeSize=0;; while(!feof(input)) { tempFileName=(char *)malloc(strlen(argv[4])+1+strlen(argv[3])+4+1); sprintf(tempFileName,"%s\\%s.%d",argv[4],argv[3],fileCount+1); printf("%s",tempFileName); output = fopen(tempFileName,"w"); if(!output) { printf("Failed to open output file"); return -1; } root.node = NULL; root.treeMemSize =0; totalTreeSize = 0; totalTreeNodes =0; while(totalTreeSize <fileSize) { curr = (node_t *)malloc(sizeof(node_t)); if(!curr) { printf("Failed to allocate memory 1"); return -1; } curr->left = curr->right = NULL; if((word=readInputFile(input)) !=NULL) { curr->val = word; insert(&(root.node), curr); } else { break; } } // } root.treeMemSize = totalTreeSize; root.treeNumNodes = totalTreeNodes; printToFile(root.node,output); printf("In freemem \n"); freemem(root.node); printf("Total treesize = %d\n",root.treeMemSize); printf("Total treenodes = %d\n",root.treeNumNodes); grandTotalTreeNodes+=totalTreeNodes; grandTotalTreeSize+=totalTreeSize; free(tempFileName); fileCount++; fclose(output); } printf("Grand Total treesize = %d\n",grandTotalTreeSize); printf("Gran Total treenodes = %d\n",grandTotalTreeNodes); fclose(input); mergeroot=NULL; grandTotalTreeNodes=0; for(i=0;i<fileCount;i++) { mergetemp=(mergelist *)malloc(sizeof(mergelist)); tempFileName=(char *)malloc(strlen(argv[4])+1+strlen(argv[3])+4+1); sprintf(tempFileName,"%s\\%s.%d",argv[4],argv[3],i+1); mergetemp->input = fopen(tempFileName,"r"); if(!mergetemp->input) { printf("Failed to open input file"); return -1; } mergetemp->val=readInputFile(mergetemp->input); mergetemp->isFinished=0; mergetemp->next=mergeroot; mergeroot=mergetemp; } output = fopen(argv[2],"w"); if(!output) { printf("Failed to open output file"); return -1; } while(1) { mergetemp=mergeroot; mergecurrent=NULL; mergeprev=NULL; while(mergetemp!=NULL) { if(mergetemp->isFinished==1) { mergetemp=mergetemp->next; continue; } if(mergetemp->val !=NULL) { if(mergecurrent==NULL) { mergecurrent=mergetemp; } else if(strcmp(mergetemp->val,mergecurrent->val)<0) { mergeprev = mergecurrent; mergecurrent=mergetemp; } } else { mergetemp->isFinished = 1; fclose(mergetemp->input); } mergetemp=mergetemp->next; } if(mergecurrent==NULL) { break; } else { while((mergeprev==NULL||strcmp(mergecurrent->val,mergeprev->val)<0)&&mergecurrent->val!=NULL) { fprintf(output,"%s\n",mergecurrent->val); grandTotalTreeNodes+=1; mergecurrent->val=readInputFile(mergecurrent->input);; } } } printf("Gran Total treenodes after merge= %d\n",grandTotalTreeNodes); fclose(output); }
int main (int argc, char **argv) { int retval = 0; /* 0 - test succeeded. -1 - test failed */ SECStatus rv; PLOptState *optstate; PLOptStatus optstatus; char *program_name; const char *input_file = NULL; /* read encrypted data from here (or create) */ const char *output_file = NULL; /* write new encrypted data here */ const char *value = default_value; /* Use this for plaintext */ SECItem data; SECItem result = {0, 0, 0}; SECItem text; PRBool ascii = PR_FALSE; secuPWData pwdata = { PW_NONE, 0 }; pr_stderr = PR_STDERR; result.data = 0; text.data = 0; text.len = 0; program_name = PL_strrchr(argv[0], '/'); program_name = program_name ? (program_name + 1) : argv[0]; optstate = PL_CreateOptState (argc, argv, "?Had:i:o:t:vf:p:"); if (optstate == NULL) { SECU_PrintError (program_name, "PL_CreateOptState failed"); return -1; } while ((optstatus = PL_GetNextOpt(optstate)) == PL_OPT_OK) { switch (optstate->option) { case '?': short_usage (program_name); return retval; case 'H': long_usage (program_name); return retval; case 'a': ascii = PR_TRUE; break; case 'd': SECU_ConfigDirectory(optstate->value); break; case 'i': input_file = optstate->value; break; case 'o': output_file = optstate->value; break; case 't': value = optstate->value; break; case 'f': if (pwdata.data) { PORT_Free(pwdata.data); short_usage(program_name); return -1; } pwdata.source = PW_FROMFILE; pwdata.data = PORT_Strdup(optstate->value); break; case 'p': if (pwdata.data) { PORT_Free(pwdata.data); short_usage(program_name); return -1; } pwdata.source = PW_PLAINTEXT; pwdata.data = PORT_Strdup(optstate->value); break; case 'v': verbose = PR_TRUE; break; } } PL_DestroyOptState(optstate); if (optstatus == PL_OPT_BAD) { short_usage (program_name); return -1; } if (!output_file && !input_file && value == default_value) { short_usage (program_name); PR_fprintf (pr_stderr, "Must specify at least one of -t, -i or -o \n"); return -1; } /* * Initialize the Security libraries. */ PK11_SetPasswordFunc(SECU_GetModulePassword); if (output_file) { rv = NSS_InitReadWrite(SECU_ConfigDirectory(NULL)); } else { rv = NSS_Init(SECU_ConfigDirectory(NULL)); } if (rv != SECSuccess) { SECU_PrintError(program_name, "NSS_Init failed"); retval = -1; goto prdone; } /* Convert value into an item */ data.data = (unsigned char *)value; data.len = strlen(value); /* Get the encrypted result, either from the input file * or from encrypting the plaintext value */ if (input_file) { if (verbose) printf("Reading data from %s\n", input_file); if (!strcmp(input_file, "-")) { retval = readStdin(&result); ascii = PR_TRUE; } else { retval = readInputFile(input_file, &result); } if (retval != 0) goto loser; if (ascii) { /* input was base64 encoded. Decode it. */ SECItem newResult = {0, 0, 0}; SECItem *ok = NSSBase64_DecodeBuffer(NULL, &newResult, (const char *)result.data, result.len); if (!ok) { SECU_PrintError(program_name, "Base 64 decode failed"); retval = -1; goto loser; } SECITEM_ZfreeItem(&result, PR_FALSE); result = *ok; } } else { SECItem keyid = { 0, 0, 0 }; SECItem outBuf = { 0, 0, 0 }; PK11SlotInfo *slot = NULL; /* sigh, initialize the key database */ slot = PK11_GetInternalKeySlot(); if (slot && PK11_NeedUserInit(slot)) { switch (pwdata.source) { case PW_FROMFILE: rv = SECU_ChangePW(slot, 0, pwdata.data); break; case PW_PLAINTEXT: rv = SECU_ChangePW(slot, pwdata.data, 0); break; default: rv = SECU_ChangePW(slot, "", 0); break; } if (rv != SECSuccess) { SECU_PrintError(program_name, "Failed to initialize slot \"%s\"", PK11_GetSlotName(slot)); return SECFailure; } } if (slot) { PK11_FreeSlot(slot); } rv = PK11SDR_Encrypt(&keyid, &data, &result, &pwdata); if (rv != SECSuccess) { if (verbose) SECU_PrintError(program_name, "Encrypt operation failed\n"); retval = -1; goto loser; } if (verbose) printf("Encrypted result is %d bytes long\n", result.len); if (!strcmp(output_file, "-")) { ascii = PR_TRUE; } if (ascii) { /* base64 encode output. */ char * newResult = NSSBase64_EncodeItem(NULL, NULL, 0, &result); if (!newResult) { SECU_PrintError(program_name, "Base 64 encode failed\n"); retval = -1; goto loser; } outBuf.data = (unsigned char *)newResult; outBuf.len = strlen(newResult); if (verbose) printf("Base 64 encoded result is %d bytes long\n", outBuf.len); } else { outBuf = result; } /* -v printf("Result is %.*s\n", text.len, text.data); */ if (output_file) { PRFileDesc *file; PRInt32 count; if (verbose) printf("Writing result to %s\n", output_file); if (!strcmp(output_file, "-")) { file = PR_STDOUT; } else { /* Write to file */ file = PR_Open(output_file, PR_CREATE_FILE|PR_WRONLY, 0666); } if (!file) { if (verbose) SECU_PrintError(program_name, "Open of output file %s failed\n", output_file); retval = -1; goto loser; } count = PR_Write(file, outBuf.data, outBuf.len); if (file == PR_STDOUT) { puts(""); } else { PR_Close(file); } if (count != outBuf.len) { if (verbose) SECU_PrintError(program_name, "Write failed\n"); retval = -1; goto loser; } if (ascii) { free(outBuf.data); } } } /* Decrypt the value */ rv = PK11SDR_Decrypt(&result, &text, &pwdata); if (rv != SECSuccess) { if (verbose) SECU_PrintError(program_name, "Decrypt operation failed\n"); retval = -1; goto loser; } if (verbose) printf("Decrypted result is \"%.*s\"\n", text.len, text.data); /* Compare to required value */ if (text.len != data.len || memcmp(data.data, text.data, text.len) != 0) { if (verbose) PR_fprintf(pr_stderr, "Comparison failed\n"); retval = -1; goto loser; } loser: if (text.data) SECITEM_ZfreeItem(&text, PR_FALSE); if (result.data) SECITEM_ZfreeItem(&result, PR_FALSE); if (NSS_Shutdown() != SECSuccess) { exit(1); } prdone: PR_Cleanup (); if (pwdata.data) { PORT_Free(pwdata.data); } return retval; }
int main(int argc, char** argv) { char fromXChar, toXChar, fromYChar, toYChar; int useIPC; ipc_memory *ipc; myDNA = malloc(sizeof(dna)); if (myDNA == null) { printf("Unable to allocate memory for my DNA!\n"); exit(1); } myDNA->noBasePair = 0.984120; // After 47 evolutions myDNA->oneBasePair = 0.576126; myDNA->twoBasePair = 0.315090; myDNA->threeBasePair = -0.972065; myDNA->lineLengthBasePair = 0.020435; myDNA->currentMarginBasePair = 0.660055; // Initial stuff gameBoard = null; possibleMovesFound = 0; useIPC = 0; if (DEBUG) { printf("\n"); } // Make sure we have arguments if ((argc < 2) || (argc > 4)) { printf("Error: bad command line arguments. Please call as:\n"); printf("\t/path/to/program /path/to/input [/path/to/output] [/path/to/dna]\n"); printf("\t/path/to/program --ipc key_number\n"); exit(1); } if (strncmp(argv[1], "--ipc", 5) == 0) { if (argc == 3) { // Key is in the command line, so let's get it if(sscanf(argv[2], "%d", &useIPC) != 1) { // We couldn't load it printf("Unable to load the IPC key. Given '%s'.\n", argv[3]); exit(1); } } else { // We didn't get enough info printf("Error: bad command line arguments for IPC. Please call as:\n"); printf("\t/path/to/program /path/to/input [/path/to/output] [/path/to/dna]\n"); printf("\t/path/to/program --ipc key_number\n"); exit(1); } } // Read the input file if (useIPC) { // Set up the IPC shared memory ipc = null; ipc = (ipc_memory *) shmat(useIPC, 0, 0); if (ipc == (ipc_memory *) -1) { printf("Unable to get shared memory: error %d\n", errno); exit(1); } // Now set the stuff that readInputFile would do for us me = ipc->player; boardHeight = ipc->height; boardWidth = ipc->width; gameBoard = (int *) &(ipc->gameBoard); playerOneScore = ipc->pOneScore; playerOneTimeLeft = ipc->pOneTime; playerTwoScore = ipc->pTwoScore; playerTwoTimeLeft = ipc->pTwoTime; if (me == 1) { him = 2; ourScore = &playerOneScore; ourTime = &playerOneTimeLeft; hisScore = &playerTwoScore; hisTime = &playerTwoTimeLeft; } else { him = 1; hisScore = &playerOneScore; hisTime = &playerOneTimeLeft; ourScore = &playerTwoScore; ourTime = &playerTwoTimeLeft; } } else { readInputFile(argv[1]); } // Read our DNA if they gave it to us if (useIPC) { // We get the DNA through the IPC myDNA = &(ipc->theDNA); } else { // Load the DNA from a file if given if (argc == 4) { loadDNA(argv[3]); } } // Initialize other stuff memset(possibleMoves, 0, MAX_POSSIBLE_MOVES * sizeof(move *)); // Clear out the possible moves array // Generate a list of possible moves generateMoveList(); if (DEBUG) { printf("We found %d possible moves.\n\n", possibleMovesFound); } // Seed the RNG srand((unsigned) time(NULL)); // Time to start processing. selectMove(); // Figure out our move // Print out the move if (useIPC) { // Since we are using IPC, things are easy copyMove(&finalMove, &(ipc->chosenMove)); } else { fromXChar = columnToChar(finalMove.from_x); toXChar = columnToChar(finalMove.to_x); fromYChar = '1' + finalMove.from_y; toYChar = '1' + finalMove.to_y; if (argc == 2) { // Just print out the result printf("%c%c %c%c\n", fromXChar, fromYChar, toXChar, toYChar); } else { // They want our output put into a file, so we'll have to do that. FILE *out = null; out = fopen(argv[2], "w"); if (out == null) { // We couldn't open the file, so complain printf("Unable to open output file! Error %d.\n", errno); printf("%c%c %c%c\n", fromXChar, fromYChar, toXChar, toYChar); } else { // We opened the file, write out stuff and quit. fprintf(out, "%c%c %c%c\n", fromXChar, fromYChar, toXChar, toYChar); fclose(out); } } } if (DEBUG) { printBoard(gameBoard); printf("%c%c %c%c\n", fromXChar, fromYChar, toXChar, toYChar); } // Clean up the possible move list if (possibleMovesFound > 0) { int i; for (i = 0; i < possibleMovesFound; i++) { free(possibleMoves[i]); } } // Detatch from the shared memory if we are using it if (useIPC) { shmdt(ipc); } // Now return return 0; }
void init(){ int i, j, k; printf("\n\n\t\tMAPA DE KOHONEN PARA IDENTIFICAR ROBALOS E SALMÕES\n"); printf("\nEntre com o número de entradas e o número de características:\n"); scanf("%d %d", &g_inputs, &g_features); printf("\nEntre com o tamanho da topologia (Comprimento X Altura):\n"); scanf("%d %d", &g_columns, &g_lines); printf ("\nEntre com o grau da vizinhança:\n"); scanf("%d", &g_ndegree); printf ("\nEntre com a taxa de aprendizado inicial:\n"); scanf("%f", &g_startLearning); printf("\nEntre com o número máximo de iterações\n"); scanf("%d", &g_iteractions); g_learning = g_startLearning; if(!(g_input = (double**)malloc(g_inputs * sizeof(double*)))){ printf ("Erro ao alocar memória\n"); exit(1); } for (i = 0; i < g_inputs; i++){ if (!(g_input[i] = (double*)malloc(g_features * sizeof(double)))){ printf ("Erro ao alocar memória\n"); exit(1); } } if (!(minimum = (double*)malloc(g_features * sizeof(double)))){ printf("Erro ao alocar memória\n"); exit(1); } if (!(maximum = (double*)malloc(g_features * sizeof(double)))){ printf("Erro ao alocar memória\n"); exit(1); } readInputFile(); if (!(g_kohonenMap = (KohonenMap**)malloc(g_lines * sizeof(KohonenMap*)))){ printf ("Erro ao alocar memória\n"); exit(1); } if(!(g_outputMap = (char**)malloc(g_lines * sizeof(char*)))){ printf ("Erro ao alocar memória\n"); exit(1); } for (i = 0; i < g_lines; i++){ if (!(g_kohonenMap[i] = (KohonenMap*)malloc(g_columns * sizeof(KohonenMap)))){ printf ("Erro ao alocar memória\n"); exit(1); } if (!(g_outputMap[i] = (char*)malloc(g_columns * sizeof(char)))){ printf ("Erro ao alocar memória\n"); exit(1); } } for (i = 0; i < g_lines; i++){ for (j = 0; j < g_columns; j++){ if (!(g_kohonenMap[i][j].weight = (double*) malloc(g_features * sizeof(double)))){ printf ("Erro ao alocar memória\n"); exit(1); } } } startRandombly(); //inicializa o mapa de saída for (i = 0; i < g_lines; i++){ for (j = 0; j < g_columns; j++){ g_outputMap[i][j] = '-'; } } }
int main(int argc, char *argv[]) { DistillerStatus st; UINT32 len; int i; char nextfile[MAX_FILENAME]; char logFile[MAX_FILENAME]; char *timeStr; TestRun runs[MAX_TESTRUNS]; FILE *f; time_t t; int numRuns; int repeatCount; DistillerInput in; DistillerOutput out; C_DistillerType distType; sprintf(distType.string, "test " INPUT_MIME_TYPE); if (argc < 3) { usage(); exit(1); } if (!(numRuns = readInputFile(argv[1],runs))) { fprintf(stderr, "Error reading input file %s.\n", argv[1]); exit(1); } repeatCount = atoi(argv[2]); if (repeatCount <=0) { fprintf(stderr, "Invaild count value.\n"); exit(1); } if ((st = DistillerInit(distType, 0, NULL)) != distOk) { fprintf(stderr, "DistillerInit failed: error %d\n", (int)st); exit(1); } sprintf(logFile,"harness.log"); t = time(NULL); timeStr = ctime(&t); printf("%s\n",logFile); if ((f = fopen(logFile, "a")) == NULL) { fprintf(stderr, "Can't open log file %s\n", logFile); return 0; } SetMimeType(&in, INPUT_MIME_TYPE); for (i=0;i<numRuns;i++) { int fd; int count; int ii; fprintf(stdout,"Test run for case %s:\n",runs[i].inputFileName); fprintf(f,"Test run for case %s:\n",runs[i].inputFileName); printArguments(f,*(runs[i].argList)); fd = open(runs[i].inputFileName, O_RDONLY); if (fd == -1) { fprintf(stderr, "Can't read %s, skipping\n", runs[i].inputFileName); fprintf(f, "Can't read %s, skipping\n", runs[i].inputFileName); continue; } for (len = 0; (count = read(fd, (void*)(buf+len), (sizeof(buf)-len))) > 0; len += count) ; fprintf(stderr, "Read %lu bytes from %s\n", len, runs[i].inputFileName); fprintf(f, "Read %lu bytes from %s\n", len, runs[i].inputFileName); SetData(&in, (void *)buf); SetDataLength(&in, len); SetMetadata(&in, NULL); SetMetadataLength(&in, 0); for (ii= 0; ii<repeatCount; ii++) { fprintf(stderr,"Calling distiller main\n"); fprintf(f,"Calling distiller main\n"); /* Distiller status */ st = DistillerMain(runs[i].argList->arg,runs[i].argList->nargs,&in,&out); if (st != distOk) { fprintf(stderr, "DistillerMain failed: error %d\n", (int)st); fprintf(f, "DistillerMain failed: error %d\n", (int)st); } close(fd); strcpy(nextfile,runs[i].inputFileName); strcat(nextfile, ".OUT"); fd = open(nextfile, O_CREAT | O_WRONLY | O_TRUNC, 0666); if (fd == -1) { fprintf(stderr, "Can't write %s, using stdout\n", nextfile); fprintf(f, "Can't write %s, using stdout\n", nextfile); fd = fileno(stdout); } len = write(fd, (const void *)DataPtr(&out), (size_t)(DataLength(&out))); if (fd != fileno(stdout)) close(fd); fprintf(stderr, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile); fprintf(f, "Wrote %lu of %lu bytes to %s\n", len, DataLength(&out), nextfile); if (out.data.freeMe == gm_True) DistillerFree(DataPtr(&out)); if (out.metadata.freeMe == gm_True) DistillerFree(MetadataPtr(&out)); } } fclose(f); return(1); }
void PlumedMain::cmd(const std::string & word,void*val){ stopwatch.start(); std::vector<std::string> words=Tools::getWords(word); unsigned nw=words.size(); if(nw==0){ // do nothing } else { int iword=-1; double d; std::map<std::string, int>::const_iterator it=plumedMainWordMap().find(words[0]); if(it!=plumedMainWordMap().end()) iword=it->second; switch(iword) { case cmd_setBox: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setBox(val); break; case cmd_setPositions: CHECK_INIT(initialized,word); atoms.setPositions(val); break; case cmd_setMasses: CHECK_INIT(initialized,word); atoms.setMasses(val); break; case cmd_setCharges: CHECK_INIT(initialized,word); atoms.setCharges(val); break; case cmd_setPositionsX: CHECK_INIT(initialized,word); atoms.setPositions(val,0); break; case cmd_setPositionsY: CHECK_INIT(initialized,word); atoms.setPositions(val,1); break; case cmd_setPositionsZ: CHECK_INIT(initialized,word); atoms.setPositions(val,2); break; case cmd_setVirial: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setVirial(val); break; case cmd_setEnergy: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setEnergy(val); break; case cmd_setForces: CHECK_INIT(initialized,word); atoms.setForces(val); break; case cmd_setForcesX: CHECK_INIT(initialized,word); atoms.setForces(val,0); break; case cmd_setForcesY: CHECK_INIT(initialized,word); atoms.setForces(val,1); break; case cmd_setForcesZ: CHECK_INIT(initialized,word); atoms.setForces(val,2); break; case cmd_calc: CHECK_INIT(initialized,word); calc(); break; case cmd_prepareDependencies: CHECK_INIT(initialized,word); prepareDependencies(); break; case cmd_shareData: CHECK_INIT(initialized,word); shareData(); break; case cmd_prepareCalc: CHECK_INIT(initialized,word); prepareCalc(); break; case cmd_performCalc: CHECK_INIT(initialized,word); performCalc(); break; case cmd_performCalcNoUpdate: CHECK_INIT(initialized,word); performCalcNoUpdate(); break; case cmd_update: CHECK_INIT(initialized,word); update(); break; case cmd_setStep: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); step=(*static_cast<int*>(val)); atoms.startStep(); break; case cmd_setStepLong: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); step=(*static_cast<long int*>(val)); atoms.startStep(); break; // words used less frequently: case cmd_setAtomsNlocal: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setAtomsNlocal(*static_cast<int*>(val)); break; case cmd_setAtomsGatindex: CHECK_INIT(initialized,word); atoms.setAtomsGatindex(static_cast<int*>(val),false); break; case cmd_setAtomsFGatindex: CHECK_INIT(initialized,word); atoms.setAtomsGatindex(static_cast<int*>(val),true); break; case cmd_setAtomsContiguous: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setAtomsContiguous(*static_cast<int*>(val)); break; case cmd_createFullList: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.createFullList(static_cast<int*>(val)); break; case cmd_getFullList: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.getFullList(static_cast<int**>(val)); break; case cmd_clearFullList: CHECK_INIT(initialized,word); atoms.clearFullList(); break; case cmd_read: CHECK_INIT(initialized,word); if(val)readInputFile(static_cast<char*>(val)); else readInputFile("plumed.dat"); break; case cmd_readInputLine: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); readInputLine(static_cast<char*>(val)); break; case cmd_clear: CHECK_INIT(initialized,word); actionSet.clearDelete(); break; case cmd_getApiVersion: CHECK_NOTNULL(val,word); *(static_cast<int*>(val))=4; break; // commands which can be used only before initialization: case cmd_init: CHECK_NOTINIT(initialized,word); init(); break; case cmd_setRealPrecision: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setRealPrecision(*static_cast<int*>(val)); break; case cmd_setMDLengthUnits: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.MD2double(val,d); atoms.setMDLengthUnits(d); break; case cmd_setMDChargeUnits: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.MD2double(val,d); atoms.setMDChargeUnits(d); break; case cmd_setMDMassUnits: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.MD2double(val,d); atoms.setMDMassUnits(d); break; case cmd_setMDEnergyUnits: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.MD2double(val,d); atoms.setMDEnergyUnits(d); break; case cmd_setMDTimeUnits: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.MD2double(val,d); atoms.setMDTimeUnits(d); break; case cmd_setNaturalUnits: // set the boltzman constant for MD in natural units (kb=1) // only needed in LJ codes if the MD is passing temperatures to plumed (so, not yet...) // use as cmd("setNaturalUnits") CHECK_NOTINIT(initialized,word); atoms.setMDNaturalUnits(true); break; case cmd_setNoVirial: CHECK_NOTINIT(initialized,word); novirial=true; break; case cmd_setPlumedDat: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); plumedDat=static_cast<char*>(val); break; case cmd_setMPIComm: CHECK_NOTINIT(initialized,word); comm.Set_comm(val); atoms.setDomainDecomposition(comm); break; case cmd_setMPIFComm: CHECK_NOTINIT(initialized,word); comm.Set_fcomm(val); atoms.setDomainDecomposition(comm); break; case cmd_setMPImultiSimComm: CHECK_NOTINIT(initialized,word); multi_sim_comm.Set_comm(val); break; case cmd_setNatoms: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setNatoms(*static_cast<int*>(val)); break; case cmd_setTimestep: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setTimeStep(val); break; /* ADDED WITH API==2 */ case cmd_setKbT: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); atoms.setKbT(val); break; /* ADDED WITH API==3 */ case cmd_setRestart: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); if(*static_cast<int*>(val)!=0) restart=true; break; case cmd_setMDEngine: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); MDEngine=static_cast<char*>(val); break; case cmd_setLog: CHECK_NOTINIT(initialized,word); log.link(static_cast<FILE*>(val)); break; case cmd_setLogFile: CHECK_NOTINIT(initialized,word); CHECK_NOTNULL(val,word); log.open(static_cast<char*>(val)); break; // other commands that should be used after initialization: case cmd_setStopFlag: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); stopFlag=static_cast<int*>(val); break; case cmd_getExchangesFlag: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); exchangePatterns.getFlag((*static_cast<int*>(val))); break; case cmd_setExchangesSeed: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); exchangePatterns.setSeed((*static_cast<int*>(val))); break; case cmd_setNumberOfReplicas: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); exchangePatterns.setNofR((*static_cast<int*>(val))); break; case cmd_getExchangesList: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); exchangePatterns.getList((static_cast<int*>(val))); break; case cmd_runFinalJobs: CHECK_INIT(initialized,word); runJobsAtEndOfCalculation(); break; case cmd_isEnergyNeeded: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); if(atoms.isEnergyNeeded()) *(static_cast<int*>(val))=1; else *(static_cast<int*>(val))=0; break; case cmd_getBias: CHECK_INIT(initialized,word); CHECK_NOTNULL(val,word); atoms.double2MD(getBias()/(atoms.getMDUnits().getEnergy()/atoms.getUnits().getEnergy()),val); break; case cmd_checkAction: CHECK_NOTNULL(val,word); plumed_assert(nw==2); *(static_cast<int*>(val))=(actionRegister().check(words[1]) ? 1:0); break; case cmd_GREX: if(!grex) grex=new GREX(*this); plumed_massert(grex,"error allocating grex"); { std::string kk=words[1]; for(unsigned i=2;i<words.size();i++) kk+=" "+words[i]; grex->cmd(kk.c_str(),val); } break; case cmd_CLTool: CHECK_NOTINIT(initialized,word); if(!cltool) cltool=new CLToolMain; { std::string kk=words[1]; for(unsigned i=2;i<words.size();i++) kk+=" "+words[i]; cltool->cmd(kk.c_str(),val); } break; default: plumed_merror("cannot interpret cmd(\"" + word + "\"). check plumed developers manual to see the available commands."); break; } } stopwatch.pause(); }
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( MeshGenerator, structured, DeviceType ) { MPI_Comm comm = MPI_COMM_WORLD; Kokkos::View<DTK_CellTopology *, DeviceType> cell_topologies_view; Kokkos::View<unsigned int *, DeviceType> cells; Kokkos::View<double **, DeviceType> coordinates; // 2D test std::string filename = "structured_2d.txt"; std::vector<std::vector<DataTransferKit::Coordinate>> coordinates_ref; std::vector<unsigned int> cells_ref; std::tie( coordinates_ref, cells_ref ) = readInputFile( filename ); // Move mesh according to the rank int comm_rank; MPI_Comm_rank( comm, &comm_rank ); std::vector<unsigned int> n_subdivisions = {{4, 3}}; double offset = n_subdivisions[1] * comm_rank; for ( auto &coord : coordinates_ref ) coord[1] += offset; std::tie( cell_topologies_view, cells, coordinates ) = buildStructuredMesh<DeviceType>( comm, n_subdivisions ); // Check view size unsigned int n_vertices = coordinates_ref.size(); unsigned int n_cells = 1; for ( auto n_sub : n_subdivisions ) n_cells *= n_sub; TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells ); TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() ); TEST_EQUALITY( coordinates.extent( 0 ), n_vertices ); // Check topology auto cell_topologies_view_host = Kokkos::create_mirror_view( cell_topologies_view ); Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view ); for ( unsigned int i = 0; i < n_cells; ++i ) TEST_EQUALITY( cell_topologies_view_host( i ), DTK_QUAD_4 ); // Check cells auto cells_host = Kokkos::create_mirror_view( cells ); Kokkos::deep_copy( cells_host, cells ); TEST_COMPARE_ARRAYS( cells_host, cells_ref ); // Check coordinates unsigned int dim = 2; auto coordinates_host = Kokkos::create_mirror_view( coordinates ); Kokkos::deep_copy( coordinates_host, coordinates ); for ( unsigned int i = 0; i < n_vertices; ++i ) for ( unsigned int j = 0; j < dim; ++j ) TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] ); // 3D test filename = "structured_3d.txt"; std::tie( coordinates_ref, cells_ref ) = readInputFile( filename ); // Move mesh according to the rank n_subdivisions = {{2, 3, 4}}; offset = n_subdivisions[2] * comm_rank; for ( auto &coord : coordinates_ref ) coord[2] += offset; std::tie( cell_topologies_view, cells, coordinates ) = buildStructuredMesh<DeviceType>( comm, n_subdivisions ); n_vertices = coordinates_ref.size(); n_cells = 1; for ( auto n_sub : n_subdivisions ) n_cells *= n_sub; TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells ); TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() ); TEST_EQUALITY( coordinates.extent( 0 ), n_vertices ); // Check topology cell_topologies_view_host = Kokkos::create_mirror_view( cell_topologies_view ); Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view ); for ( unsigned int i = 0; i < n_cells; ++i ) TEST_EQUALITY( cell_topologies_view_host( i ), DTK_HEX_8 ); // Check cells cells_host = Kokkos::create_mirror_view( cells ); Kokkos::deep_copy( cells_host, cells ); TEST_COMPARE_ARRAYS( cells_host, cells_ref ); // Check coordinates dim = 3; coordinates_host = Kokkos::create_mirror_view( coordinates ); Kokkos::deep_copy( coordinates_host, coordinates ); for ( unsigned int i = 0; i < n_vertices; ++i ) for ( unsigned int j = 0; j < dim; ++j ) TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] ); }