int main(int argc, char ** argv){ Image * image; if(argc != 3 && argc != 4){ printf("VMIraw2tiff <file.raw> <file.tiff> [GMD.txt]\n"); exit(0); } FILE * in = fopen(argv[1],"r"); FILE * GMD = 0; if(!in){ perror("Could not open input file"); exit(1); } if(argc >= 4){ GMD = fopen(argv[3],"r"); if(!GMD){ perror("Could not GMD file"); } } int width,height; fread((void *)&width,sizeof(int),1,in); fread((void *)&height,sizeof(int),1,in); printf("Read an %dx%d image\n",width,height); if(strstr(argv[1],".sss")){ /* We have the stack of images case */ int num_images; fread((void *)&num_images,sizeof(int),1,in); for(int k = 0;k<num_images;k++){ image = sp_image_alloc(width,height,1); int bunch_id; fread((void *)&bunch_id,sizeof(int),1,in); printf("Bunch Id - %d\n",bunch_id); int i =0; char * data = malloc(sizeof(int)*width*height); fread(data,sizeof(char),width*height,in); char buffer[1024]; for(int y = 0;y<height;y++){ for(int x = 0;x<width;x++){ sp_image_set(image,x,y,0,sp_cinit(data[i],0)); i++; } } free(data); // append_tag(buffer,argv[2],bunch_id); GMDData * gd = get_values_from_GMD(GMD,bunch_id); char buffer2[1024]; char buffer3[1024]; sprintf(buffer2,"%d",bunch_id); append_tag(buffer3,argv[2],buffer2); if(!gd){ append_tag(buffer,buffer3,"xxxx"); }else{ sprintf(buffer2,"%f",gd->e_hall); append_tag(buffer,buffer3,buffer2); free(gd); } sp_image_write(image,buffer,SpColormapJet); sp_image_free(image); // exit(0); } }else{ /* We have the single image case */ int * data = malloc(sizeof(int)*width*height); fread(data,sizeof(int),width*height,in); image = sp_image_alloc(width,height,1); int i =0; for(int y = 0;y<height;y++){ for(int x = 0;x<width;x++){ sp_image_set(image,x,y,0,sp_cinit(data[i],0)); i++; } } ExtraData ed; fread(&ed,sizeof(ExtraData),1,in); printf("Timestamp - %d\n",ed.timestamp); GMDData * gd = get_values_from_GMD(GMD,ed.timestamp); char buffer[1024]; char buffer2[1024]; char buffer3[1024]; sprintf(buffer2,"%d",ed.timestamp); append_tag(buffer3,argv[2],buffer2); if(!gd){ append_tag(buffer,buffer3,"xxxx"); }else{ sprintf(buffer2,"%f",gd->e_hall); append_tag(buffer,buffer3,buffer2); free(gd); } sp_image_write(image,buffer,SpColormapJet); } return 0; }
bool QMCDriverFactory::setQMCDriver(int curSeries, xmlNodePtr cur) { string curName((const char*)cur->name); string update_mode("pbyp"); string qmc_mode("invalid"); string multi_tag("no"); string warp_tag("no"); string append_tag("no"); #if defined(QMC_CUDA) string gpu_tag("yes"); #else string gpu_tag("no"); #endif OhmmsAttributeSet aAttrib; aAttrib.add(qmc_mode,"method"); aAttrib.add(update_mode,"move"); aAttrib.add(multi_tag,"multiple"); aAttrib.add(warp_tag,"warp"); aAttrib.add(append_tag,"append"); aAttrib.add(gpu_tag,"gpu"); aAttrib.put(cur); bitset<QMC_MODE_MAX> WhatToDo; bool append_run =(append_tag == "yes"); WhatToDo[SPACEWARP_MODE]= (warp_tag == "yes"); WhatToDo[MULTIPLE_MODE]= (multi_tag == "yes"); WhatToDo[UPDATE_MODE]= (update_mode == "pbyp"); #if defined(QMC_CUDA) WhatToDo[GPU_MODE ] = (gpu_tag == "yes"); #endif OhmmsInfo::flush(); QMCRunType newRunType = DUMMY_RUN; if(curName != "qmc") qmc_mode=curName; int nchars=qmc_mode.size(); if(qmc_mode.find("linear") < nchars) { if (qmc_mode.find("cslinear") < nchars) newRunType=CS_LINEAR_OPTIMIZE_RUN; else newRunType=LINEAR_OPTIMIZE_RUN; } else if(qmc_mode.find("opt") < nchars) { newRunType=OPTIMIZE_RUN; } else { if(qmc_mode.find("ptcl")<nchars) WhatToDo[UPDATE_MODE]=1; if(qmc_mode.find("mul")<nchars) WhatToDo[MULTIPLE_MODE]=1; if(qmc_mode.find("warp")<nchars) WhatToDo[SPACEWARP_MODE]=1; // if (qmc_mode.find("rmcPbyP")<nchars) // { // newRunType=RMC_PBYP_RUN; // } // else else if(qmc_mode.find("vmc")<nchars) { newRunType=VMC_RUN; } else if(qmc_mode.find("dmc")<nchars) { newRunType=DMC_RUN; } } unsigned long newQmcMode=WhatToDo.to_ulong(); //initialize to 0 QMCDriver::BranchEngineType* branchEngine=0; if(qmcDriver) { if( newRunType != curRunType || newQmcMode != curQmcMode) { if(curRunType == DUMMY_RUN) { APP_ABORT("QMCDriverFactory::setQMCDriver\n Other qmc sections cannot come after <qmc method=\"test\">.\n"); } //pass to the new driver branchEngine=qmcDriver->getBranchEngine(); delete qmcDriver; //set to 0 so that a new driver is created qmcDriver = 0; //if the current qmc method is different from the previous one, append_run is set to false append_run = false; } else { app_log() << " Reusing " << qmcDriver->getEngineName() << endl; // if(curRunType == DMC_RUN) qmcDriver->resetComponents(cur); } } if(curSeries == 0) append_run = false; //continue with the existing qmcDriver if(qmcDriver) return append_run; //need to create a qmcDriver curRunType = newRunType; curQmcMode = newQmcMode; curQmcModeBits = WhatToDo; //create a driver createQMCDriver(cur); //initialize QMCDriver::myComm qmcDriver->initCommunicator(myComm); //branchEngine has to be transferred to a new QMCDriver if(branchEngine) qmcDriver->setBranchEngine(branchEngine); OhmmsInfo::flush(); return append_run; }
bool QMCDriverFactory::setQMCDriver(int curSeries, xmlNodePtr cur) { string curName((const char*)cur->name); string update_mode("walker"); string qmc_mode("invalid"); string multi_tag("no"); string warp_tag("no"); string append_tag("no"); OhmmsAttributeSet aAttrib; aAttrib.add(qmc_mode,"method"); aAttrib.add(update_mode,"move"); aAttrib.add(multi_tag,"multiple"); aAttrib.add(warp_tag,"warp"); aAttrib.add(append_tag,"append"); aAttrib.put(cur); bool append_run =(append_tag == "yes"); bitset<3> WhatToDo; WhatToDo[SPACEWARP_MODE]= (warp_tag == "yes"); WhatToDo[MULTIPLE_MODE]= (multi_tag == "yes"); WhatToDo[UPDATE_MODE]= (update_mode == "pbyp"); QMCRunType newRunType = DUMMY_RUN; if(curName != "qmc") qmc_mode=curName; int nchars=qmc_mode.size(); if(qmc_mode.find("opt") < nchars) { newRunType=OPTIMIZE_RUN; } else { if(qmc_mode.find("vmc")<nchars) { newRunType=VMC_RUN; } else if(qmc_mode.find("dmc")<nchars) { newRunType=DMC_RUN; } else if(qmc_mode.find("rmc")<nchars) { newRunType=RMC_RUN; } if(qmc_mode.find("ptcl")<nchars) WhatToDo[UPDATE_MODE]=1; if(qmc_mode.find("mul")<nchars) WhatToDo[MULTIPLE_MODE]=1; if(qmc_mode.find("warp")<nchars) WhatToDo[SPACEWARP_MODE]=1; } unsigned long newQmcMode=WhatToDo.to_ulong(); //initialize to 0 QMCDriver::BranchEngineType* branchEngine=0; if(qmcDriver) { if(newRunType != curRunType || newQmcMode != curQmcMode) { //copy the pointer of the BranchEngine branchEngine=qmcDriver->getBranchEngine(); //remove the qmcDriver delete qmcDriver; //set to 0 so that a new driver is created qmcDriver = 0; //if the current qmc method is different from the previous one, append_run is set to false append_run = false; } else { app_log() << " Reusing " << qmcDriver->getEngineName() << endl; } } if(curSeries == 0) append_run = false; //carryon with the existing qmcDriver if(qmcDriver) return append_run; //need to create a qmcDriver curRunType = newRunType; curQmcMode = newQmcMode; curQmcModeBits = WhatToDo; createQMCDriver(cur); if(qmcComm) qmcDriver->setCommunicator(qmcComm); else qmcDriver->setCommunicator(OHMMS::Controller); //branchEngine has to be transferred to a new QMCDriver if(branchEngine) qmcDriver->setBranchEngine(branchEngine); return append_run; }