Example #1
0
bool MakeDynLink::Action()
{
	if (GetParams()->size() < 2)
	{
		return false;
	}	
    else
	{
		Cmd* cmd = Cmd::Instance();
		Fs::Path path1 = GetParams()->at(0);
		Fs::Path path2 = GetParams()->at(1);

		Fs::Object* obj = cmd->GetWorkPath(&path1);
		if (obj)
		{
			if (!path1.GetFile().empty())
			{
				for (size_t i = 0; i < obj->GetChilds().size(); i++)
				{
					if (cmd->GetFs()->IsFile(obj->GetChilds()[i]) && (obj->GetChilds()[i]->GetName() == path1.GetFile()))
					{
						cmd->GetFs()->MakeDynLink(obj->GetChilds()[i], cmd->GetWorkPath(&path2));
						break;
					}
				}
			}
			else
			{
				cmd->GetFs()->MakeDynLink(obj, cmd->GetWorkPath(&path2));
			}
		}
	}
	return true;

}
Example #2
0
void MenuButton::load(GameObjectParams params){
    SDLGameObject::load(params);
    GetParams().setScrolling(false);
    GetParams().setFrame(MOUSE_OUT);
    GetParams().setScale(.5);
    
}
Example #3
0
void MenuButton::update(){
    Vector2D<double>* pMousePos = InputHandler::Instance()->getMousePosition();
    
    double zoom = Game::Instance()->getGlobalZoom();

    
    if (pMousePos->getX() < GetParams().getX() * zoom +
        GetParams().getWidth() * zoom &&
        pMousePos->getX() > GetParams().getX() * zoom  &&
        pMousePos->getY() < GetParams().getY()  * zoom +
        GetParams().getHeight() * zoom  &&
        pMousePos->getY() > GetParams().getY() * zoom
        ){
        GetParams().setFrame(MOUSE_OVER);
        
        if (InputHandler::Instance()->getMouseButtonState(LEFT)){
            GetParams().setFrame(MOUSE_CLICKED);
            if (m_bReleased && m_callback){
                m_callback();
                m_bReleased = false;
            }
        } else{
            m_bReleased = true;
        }
    } else {
        GetParams().setFrame(MOUSE_OUT);
    }
    
}
Example #4
0
bool DelTree::Action()
{
	if (!GetParams()->empty())
	{
		Cmd* cmd = Cmd::Instance();
		cmd->GetFs()->DelTree(cmd->GetWorkPath(&GetParams()->front()));
	}
	
	return true;

}
Example #5
0
bool RemoveDir::Action()
{
	if (!GetParams()->empty())
	{
		Cmd* cmd = Cmd::Instance();
		cmd->GetFs()->RemoveDir(cmd->GetWorkPath(&GetParams()->front()));
	}
	
	return true;

}
Example #6
0
bool MakeFile::Action()
{
	if (!GetParams()->empty())
	{
		Cmd* cmd = Cmd::Instance();
	
		cmd->GetFs()->MakeFile(cmd->GetWorkPath(&GetParams()->front()), &GetParams()->front());
	}
	
	return true;

}
Example #7
0
bool MakeDir::Action()
{
	if (!GetParams()->empty())
	{
		Cmd* cmd = Cmd::Instance();
		Fs::Path path = GetParams()->at(0);
		
		path.SetFile(path.GetPath()->back());
		path.GetPath()->pop_back();
		
		cmd->GetFs()->MakeDir(cmd->GetWorkPath(&path), &path);
	}
	
	return true;
};
Example #8
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeDialog::DoStartStop(bool Start, bool Synchronize)
{
  if (FOnStartStop)
  {
    TSynchronizeParamType SParams = GetParams();
    SParams.Options =
      (SParams.Options & ~(soSynchronize | soSynchronizeAsk)) |
      FLAGMASK(Synchronize, soSynchronize);
    if (Start)
    {
      DebugAssert(*FOnFeedSynchronizeError == NULL);
      *FOnFeedSynchronizeError =
        (FLAGSET(SParams.Options, soContinueOnError) ? &FeedSynchronizeError : TFeedSynchronizeError(NULL));
      delete FSynchronizeOptions;
      FSynchronizeOptions = new TSynchronizeOptions;
      FOnGetOptions(SParams.Params, *FSynchronizeOptions);
    }
    else
    {
      *FOnFeedSynchronizeError = NULL;
    }
    FOnStartStop(this, Start, SParams, CopyParams, FSynchronizeOptions, DoAbort,
      NULL, DoLog);
  }
}
Example #9
0
bool CWeapon::CheckSprint()
{
	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(!pPlayer || pPlayer->IsSliding())
		return false;

	SPlayerStats *pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
	assert(pStats);

	if(pPlayer->IsSprinting())
	{
		pStats->bIgnoreSprinting = true;

		float delayScale = pPlayer->GetModifiableValues().GetValue(kPMV_WeaponFireFromSprintTimeScale);
		m_delayedFireActionTimeOut = GetParams().sprintToFireDelay * delayScale;

		return true;
	}
	else if (m_delayedFireActionTimeOut > 0.f)
	{
		return true;
	}

	return false;
}
Example #10
0
BView* GlNode1d::NewView(gl_new_view_params& params) const
{
	if (params.viewType != GL_INSPECTOR_VIEW) return inherited::NewView(params);
	ArpVALIDATE(Parent(), return 0);

	GlStrainedParamList		list;
	status_t				err = GetParams(list);
	if (err != B_OK) return 0;
//	if (GetParams(params) != B_OK) return 0;

	GlParamView*		v = new GlParamView(params, Parent()->Id(), Id());
	if (!v) return 0;

	float					sx = float(Prefs().GetInt32(ARP_PADX)),
							sy = float(Prefs().GetInt32(ARP_PADY));
	float					fh = v->ViewFontHeight();
//	float					div = get_divider(params, this);
	v->mRect.Set(sx, sy, 152, sy + fh);
	v->AddLabel(v->mRect, "label", AddOn()->Label());

	v->mRect.Set(v->mRect.left, v->mRect.bottom + sy, v->mRect.right, v->mRect.bottom + sy + 50);
	v->AddVisualView(v->mRect, "bm", NewVisual(params.ref), 0);

	v->AddParamControls(list);

	return v;
}
Example #11
0
void GetRealTime()
{
    if (gPeriod == 0) {
        InitTime();
        GetParams(pthread_self(), &gPeriod, &gComputation, &gConstraint);
    }
}
//-----------------------------------------------------------------------------------------------//
STDMETHODIMP CMyTrackPriceInfoWithNotify::SubscribeQuote(QuoteUpdateParams *Params)
{
	ATLTRACE(_T("CMyTrackPriceInfoWithNotify::SubscribeQuote\n"));
	CComVariant varParams;
	try
	{
		//		ResetEvent(m_hDisconnect);

		_bstr_t bstrSymbol;
		_bstr_t bstrExchange;
		GetParams(varParams,Params);
		bstrSymbol = Params->Symbol;
		if(Params->Exchange)
			bstrExchange = Params->Exchange;

		_Module.GetMyTrackCore ()->SubscribeQuote(static_cast<CBaseNotifier*>(this),
			Params->Type,
			(LPCSTR)bstrSymbol,
			(LPCSTR)bstrExchange,
			varParams);
	}
	catch (_com_error &err)
	{
		return eg_lib::utils::ComError2ErrInfo (err,this);
	}
	varParams.Clear ();
	return S_OK;
}
Example #13
0
//#include <server/mb/pg_wchar.h>
//#pragma comment(lib,")
bool SPostgres::Connect()
{
	if(m_pConn != NULL)
		DisConnect();

	SString sParam = GetParams();//hostaddr=127.0.0.1;port=5432;dbname=znl4;user=postgres;password=123456;
	SString sTemp,sTempNoPwd;
	if(SString::GetAttributeValue(sParam,"hostaddr").length() == 0)
		return false;
	sTemp.sprintf("hostaddr=%s port=%s dbname=%s user=%s password=%s connect_timeout=0",
		SString::GetAttributeValue(sParam,"hostaddr").data(),
		SString::GetAttributeValue(sParam,"port").data(),
		SString::GetAttributeValue(sParam,"dbname").data(),
		SString::GetAttributeValue(sParam,"user").data(),
		SString::GetAttributeValue(sParam,"password").data());
	sTempNoPwd.sprintf("hostaddr=%s port=%s dbname=%s user=%s password=%s connect_timeout=0",
		SString::GetAttributeValue(sParam,"hostaddr").data(),
		SString::GetAttributeValue(sParam,"port").data(),
		SString::GetAttributeValue(sParam,"dbname").data(),
		SString::GetAttributeValue(sParam,"user").data(),
		"******");

	LOGDEBUG("Begin to Connect Postgres:%s",sTempNoPwd.data());
	m_pConn = PQconnectdb(sTemp.data());		

	if (PQstatus(m_pConn) != CONNECTION_OK)
	{
		SetStatus(DBERROR);
		SString err;

		err.sprintf("Connect to postgres ERROR:%s params:%s",PQerrorMessage(m_pConn),sTempNoPwd.data());
		LOGERROR("%s",err.data());
		DisConnect();
		return false;
	}
	LOGDEBUG("Connect to postgres OK params:%s",sTempNoPwd.data());
	int ret = PQsetClientEncoding(m_pConn,"GBK");
	if(ret < 0)
	{
		LOGERROR("设置字符集为GBK时失败!");
	}
//	encoding = PQclientEncoding(m_pConn);
//	ret = PQsetClientEncoding(m_pConn,"UNICODE");
//	encoding = PQclientEncoding(m_pConn);
//	ret = PQsetClientEncoding(m_pConn,"SQL_ASCII");
//	encoding = PQclientEncoding(m_pConn);
//	ret = PQsetClientEncoding(m_pConn,"GB18030");
//	encoding = PQclientEncoding(m_pConn);
//	ret = PQsetClientEncoding(m_pConn,"UTF8");
//	encoding = PQclientEncoding(m_pConn);
	
	SetStatus(IDLE);

//	Execute("RESET CLIENT_ENCODING;");

//	SString sql = "insert into substation values('222',1,'新站','亲站','aa','aa','',1,0,0,'')";
//	Execute(sql);
	return true;
}
Example #14
0
bool ChangeDir::Action()
{
	Cmd* cmd = Cmd::Instance();
	
	if (!GetParams()->empty())
	{
		Fs::Path path = GetParams()->front();
		Fs::Object* obj = cmd->GetCurrentPath();
		
		obj = cmd->GetWorkPath(&path);
		
		if (obj)
			cmd->SetCurrentPath(obj);
	}
	
	return true;

}
Example #15
0
//---------------------------------------------------------------------------
void __fastcall TCustomCommandDialog::GetCommand(TCustomCommandType & Command)
{
  Command.Name = DescriptionEdit->Text;
  Command.Command = CommandEdit->Text;
  Command.Params = GetParams();
  if (FMode != ccmAdHoc)
  {
    Command.ShortCut = GetShortCutCombo(ShortCutCombo);
  }
}
 ///////////////////////////////////////////////////////////////////////
 ///  Function: On_WM_COMMAND_IDC_FALSE_WindowMessage
 ///
 ///    Author: $author$
 ///      Date: 5/11/2012
 ///////////////////////////////////////////////////////////////////////
 virtual LRESULT On_WM_COMMAND_IDC_FALSE_WindowMessage
 (HWND hWnd,
  UINT msg,
  WPARAM wParam,
  LPARAM lParam) 
 {
     LRESULT lResult = FALSE;
     GetParams();
     return lResult;
 }
	void UpdateLookTarget()
	{
		const SLookAroundParams& params = GetParams();

		//--- TODO! Context use of random number generator!
		float yaw   = cry_random(params.yawMin, params.yawMax);
		float pitch = cry_random(params.pitchMin, params.pitchMax);
		m_lookOffset.Set(sin_tpl(yaw), cos_tpl(yaw), 0.0f);
		m_lookAroundTime = cry_random(params.timeMin, params.timeMax);
	}
Example #18
0
int dele::init(const char *jpl_name)
{
        strcpy(this->fileName, jpl_name);

        int res = Initialize_Ephemeris(fileName);

        GetParams(H1, H2, R1);

        return res;
}
Example #19
0
bool Del::Action()
{
	if (!GetParams()->empty())
	{
		Cmd* cmd = Cmd::Instance();
		Fs::Object* obj = cmd->GetWorkPath(&GetParams()->front());
		
		if (!GetParams()->front().GetFile().empty())
		{
			for (size_t i = 0; i < obj->GetChilds().size(); i++)
			{
				if (obj->GetChilds()[i]->GetName() == GetParams()->front().GetFile())
				{
					cmd->GetFs()->Del(obj->GetChilds()[i]);
					break;
				}
			}
		}
	}
	
	return true;

}
Example #20
0
CString CMessage::ToString(unsigned int uFlags) const {
    CString sMessage;

    // <tags>
    if (!(uFlags & ExcludeTags) && !m_mssTags.empty()) {
        CString sTags;
        for (const auto& it : m_mssTags) {
            if (!sTags.empty()) {
                sTags += ";";
            }
            sTags += it.first;
            if (!it.second.empty())
                sTags += "=" + it.second.Escape_n(CString::EMSGTAG);
        }
        sMessage = "@" + sTags;
    }

    // <prefix>
    if (!(uFlags & ExcludePrefix)) {
        CString sPrefix = m_Nick.GetHostMask();
        if (!sPrefix.empty()) {
            if (!sMessage.empty()) {
                sMessage += " ";
            }
            sMessage += ":" + sPrefix;
        }
    }

    // <command>
    if (!m_sCommand.empty()) {
        if (!sMessage.empty()) {
            sMessage += " ";
        }
        sMessage += m_sCommand;
    }

    // <params>
    if (!m_vsParams.empty()) {
        if (!sMessage.empty()) {
            sMessage += " ";
        }
        sMessage += GetParams(0);
    }

    return sMessage;
}
Example #21
0
//--------------------------------------------------------------------
bool CWeapon::PreMeleeAttack()
{
	CPlayer *pPlayer = static_cast<CPlayer*>(GetOwnerActor());
	if(!pPlayer)
		return false;

	SPlayerStats* pStats = static_cast<SPlayerStats*>(pPlayer->GetActorStats());
	assert(pStats);

	if (!pPlayer->IsSprinting())
		return true;

	pStats->bIgnoreSprinting = true;
	float delayScale = pPlayer->GetModifiableValues().GetValue(kPMV_WeaponFireFromSprintTimeScale);
	m_delayedMeleeActionTimeOut = GetParams().sprintToMeleeDelay * delayScale;

	return (m_delayedMeleeActionTimeOut <= 0.f);
}
Example #22
0
//---------------------------------------------------------------------------
void __fastcall TSynchronizeDialog::DoStartStop(bool Start, bool Synchronize)
{
  if (FOnStartStop)
  {
    TSynchronizeParamType SParams = GetParams();
    SParams.Options =
      (SParams.Options & ~(soSynchronize | soSynchronizeAsk)) |
      FLAGMASK(Synchronize, soSynchronize);
    if (Start)
    {
      delete FSynchronizeOptions;
      FSynchronizeOptions = new TSynchronizeOptions;
      FOnGetOptions(SParams.Params, *FSynchronizeOptions);
    }
    FOnStartStop(this, Start, SParams, CopyParams, FSynchronizeOptions, DoAbort,
      NULL, DoLog);
  }
}
Example #23
0
int main(int argc, char **argv)
{
	char	EncodingString[2048];
	int	Index = 0;
	int	ErrorCode = 0;
	DEVICE_INFO_T	DeviceInfo;
	Q_ENTRY	*req = qCgiRequestParse(NULL, (Q_CGI_T) 0);

	SvcLog = NULL;
	SvcLog = openLog("DEVICEINFO", LOG_FILE, LOG_MODE);

	memset(&DeviceInfo, 0x00, sizeof(DEVICE_INFO_T));
	memset(EncodingString, 0x00, 2048);

	if((ErrorCode = GetParams(req, EncodingString)) == SDRM_NO_ERROR)	{
		if(strncmp(EncodingString, "IA", 2) == 0)  {
			Index = 2;
		}
		else if(strncmp(EncodingString, "EA", 2) == 0)  {
			Index = 2;
		}

		ErrorCode = DecodingDeviceString4MGR(EncodingString+Index, &DeviceInfo);
		ToUpperString(DeviceInfo.UUID, strlen(DeviceInfo.UUID));
		ToUpperString(DeviceInfo.SecondaryUUID, strlen(DeviceInfo.SecondaryUUID));

		printLog(HEAD, "ClientIP(%s)Input(%s)\t\n<=>UUID(%s)SecondaryUUID(%s)UUIDTypes(%s)DeviceName(%s)OSVersion(%s)AppVersion(%s)RegVersion(%s)BuildNum(%s)ErrorCode(%d)\n",
			getenv("REMOTE_ADDR"), EncodingString, DeviceInfo.UUID, DeviceInfo.SecondaryUUID, DeviceInfo.UUIDTypes, 
			DeviceInfo.DeviceName, DeviceInfo.OSVersion, DeviceInfo.AppVersion, DeviceInfo.RegisterVersion, DeviceInfo.BuildNumber, ErrorCode);

	}
	else	{
		printLog(HEAD, "CientIP(%s)InvalidParams...\n", getenv("REMOTE_ADDR"));
	}
	qCgiResponseSetContentType(req, "text/html");
	printResultDeviceInfo(ErrorCode, DeviceInfo);

	closeLog(SvcLog);

	return 0;
}
void ReadMaterialComp()
{
  char *input, fname[MAX_STR], word[MAX_STR], pname[MAX_STR], **params;
  long loc0, loc1, mat, mat0, iso, iso0, nuc, i0, i, np, j, n, line, r, g, b;
  double val, sum;
  FILE *fp;

  /* Get pointer to file list */

  if ((loc0 = (long)RDB[DATA_PTR_COMP_FILE]) < VALID_PTR)
    return;

  fprintf(out, "Overriding initial material compositions...\n");

  /* Reset previous pointer */

  mat0 = -1;

  /* Reset counters for line number calculation */

  WDB[DATA_LINE_NUM_N0] = 0.0;
  WDB[DATA_LINE_NUM_NL0] = 1.0;

  /* Loop over list */

  while (RDB[loc0] > VALID_PTR)
    {
      /* Get file name */

      sprintf(fname, "%s", GetText(loc0));

      /* Check that file exists */

      if ((fp = fopen(fname, "r")) != NULL)
	fclose(fp);
      else
	{
	  /* File not found */
	  
	  Error(0, "Material composition file \"%s\" does not exist", fname);
	}

      /* Read input file */
  
      input = ReadTextFile(fname);

      /* Avoid compiler warning */
      
      params = NULL;

      /* Loop over file */
      
      i0 = 0;
      while ((i = NextWord(&input[i0], word)) > 0)
	{
	  /* update pointer */
	  
	  i0 = i0 + i;

	  /* Get line number for error messages */
	  
	  line = GetLineNumber(input, i0);

	  /* Look for material definition */

	  if (!strcasecmp(word, "mat"))
	    {
	      /* Copy parameter name */

	      strcpy (pname, word);

	      /* Read parameters */

	      params = GetParams(word, input, &np, &i0, 4, 4*MAX_ISOTOPES + 8, 
				 fname);

	      /* Read data */

	      j = 0;

	      /* Find material (try starting from previous) */

	      mat = mat0;
	      while (mat > VALID_PTR)
		{
		  /* Compare */

		  if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
		    break;

		  /* Next */

		  mat = NextItem(mat);
		}

	      /* Find material (start from beginning) */

	      if (mat < VALID_PTR)
		{
		  mat = (long)RDB[DATA_PTR_M0];
		  while (mat > VALID_PTR)
		    {
		      /* Compare */
		      
		      if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
			break;
		      
		      /* Next */
		      
		      mat = NextItem(mat);
		    }
		}

	      /* Check */

	      if (mat < VALID_PTR)
		Error(-1, pname, fname, line, "Material %s is not defined",
		      params[j]);
	      else
		j++;

	      /* Remember previous */

	      mat0 = NextItem(mat);
	      
	      /* Material density */

	      if (!strcmp(params[j], "sum"))
		{
		  /* Set value to -inf to calculate sum from composition */
		  
		  WDB[mat + MATERIAL_ADENS] = -INFTY;
		  
		  j++;
		}
	      else
		{
		  /* Read value */
		  
		  WDB[mat + MATERIAL_ADENS] = 
		    TestParam(pname, fname, line, params[j++], PTYPE_REAL,
			      -1000.0, 1000.0);
		}

	      /* Reset sum */

	      sum = 0.0;

	      /* Reset previous pointer */

	      iso0 = -1;

	      /* Loop over parameters */
	  
	      while (j < np)
		{
		  /* Check parameter */
		  
		  if (!strcmp(params[j], "tmp"))
		    {
		      /***** Temperature for Doppler-breadening **************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_DOPPLER_TEMP] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);

		      /* Set option */
		      
		      WDB[DATA_USE_DOPPLER_PREPROCESSOR] = (double)YES;
		      
		      /*******************************************************/
		    }
		  if (!strcmp(params[j], "tms") || !strcmp(params[j], "ettm"))
		    {
		      /***** Temperature for TMS *****************************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Copy to maximum */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			RDB[mat + MATERIAL_TMS_TMIN];
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "rgb"))
		    {
		      /***** Material colour *********************************/

		      j++;
		      
		      /* Get r, b and g */
		      
		      r = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);
		      
		      g = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      b = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      /* Set color */
		      
		      WDB[mat + MATERIAL_RGB] = b + 1000.0*g + 1000000.0*r;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "vol"))
		    {
		      /***** Material volume *********************************/
		      
		      j++;
		      
		      /* Get volume */
		      
		      WDB[mat + MATERIAL_VOLUME_GIVEN] =
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "fix"))
		    {
		      /***** Default library ID and temperature***************/

		      j++;
		  
		      /* Get default ID and temperature */
		      
		      WDB[mat + MATERIAL_DEFAULT_PTR_LIB_ID] = 
			PutText(params[j++]);
		      WDB[mat + MATERIAL_DEFAULT_TMP] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "mass"))
		    {
		      /***** Material mass ***********************************/

		      j++;
		      
		      /* Get mass */
		      
		      WDB[mat + MATERIAL_MASS_GIVEN] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);

		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "burn"))
		    {
		      /***** Burnable material *******************************/
		      
		      j++;
		      
		      /* Set burn flag */
		      
		      SetOption(mat + MATERIAL_OPTIONS, OPT_BURN_MAT);
		      
		      /* Set burn sort flag and materials flag */
		      
		      WDB[mat + MATERIAL_BURN_SORT_FLAG] = 1.0;
		      WDB[DATA_BURN_MATERIALS_FLAG] = (double)YES;
		      
		      /* Get number of rings */
		      
		      WDB[mat + MATERIAL_BURN_RINGS] = 
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 0, 10000000);
		  
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "moder"))
		    {
		      /***** Thermal scattering data *************************/

		      j++;
		      
		      /* Check number of parameters */
		      
		      if (j > np - 3)
			Error(mat, "Invalid number of parameters");
		      
		      /* Create new item (use the same structure as with */
		      /* the therm card) */
		      
		      WDB[mat + MATERIAL_PTR_SAB] = NULLPTR;
		      loc1 = NewItem(mat + MATERIAL_PTR_SAB, 
				     THERM_BLOCK_SIZE);

		      /* Read name */
		      
		      WDB[loc1 + THERM_PTR_ALIAS] = 
			(double)PutText(params[j++]);
		      
		      /* Read ZA */
		      
		      WDB[loc1 + THERM_ZA] =  
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 1001, 120000);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "tft"))
		    {
		      /***** Minimum and maximum temperatures for TMS ********/

		      j++;
		      
		      /* Get minimum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Get maximum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, RDB[mat + MATERIAL_TMS_TMIN],
				  100000.0);
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else 
		    {
		      /***** Composition *************************************/

		      /* Find nuclide in composition (start from previous) */

		      iso = iso0;
		      while (iso > VALID_PTR)
			{
			  /* Pointer to nuclide data */

			  nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			  CheckPointer(FUNCTION_NAME, "(nuc)", DATA_ARRAY,nuc);

			  /* Compare */
			  
			  if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
				      params[j]))
			    break;

			  /* Next */

			  iso = NextItem(iso);
			}

		      /* Find nuclide in composition (start from beginning) */

		      if (iso < VALID_PTR)
			{			  
			  iso = (long)RDB[mat + MATERIAL_PTR_COMP];
			  while (iso > VALID_PTR)
			    {
			      /* Pointer to nuclide data */
			      
			      nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			      CheckPointer(FUNCTION_NAME, "(nuc)", 
					   DATA_ARRAY,nuc);

			      /* Compare */
			  
			      if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
					  params[j]))
				break;
			      
			      /* Next */
			      
			      iso = NextItem(iso);
			    }
			}

		      /* Check pointer */
		      
		      if (iso < VALID_PTR)
			Error(-1, pname, fname, line, 
			      "Material %s has no nuclide %s in composition",
			      GetText(mat + MATERIAL_PTR_NAME), params[j]);
		      else
			j++;

		      /* Remember pointer */

		      iso0 = iso;
			      
		      /* Read fraction */
		  
		      val = TestParam(pname, fname, line, params[j++], 
				      PTYPE_REAL, -100.0, 1E+25);
		  
		      /* Put value */

		      WDB[iso + COMPOSITION_ADENS] = val;

		      /* Add to sum */
		      
		      sum = sum + val;
		      
		      /*******************************************************/
		    }
		}
	      
	      /* Set density if sum */

	      if (RDB[mat + MATERIAL_ADENS] == -INFTY)
		WDB[mat + MATERIAL_ADENS] = sum;

	      /* Calculate normalized fractions */
	      
	      IsotopeFractions(mat);
  	    }

	  /* Free parameter list */
      
	  if (np > 0)
	    for (n = 0; n < np + 1; n++)
	      Mem(MEM_FREE, params[n]);
	}

      /* Free memory */
  
      Mem(MEM_FREE, input);

      /* Next file */

      loc0++;
    }

  /* This must be called to get the divided compositions into material */
  /* structures */

  SumDivCompositions();
  
  fprintf(out, "OK.\n\n");
}
Example #25
0
int _tmain(int argc, _TCHAR* argv[]) {
	LONG retval;
	Params p;
	LPVOID cert, crl;
	DWORD certSz = 0, crlSz = 0, index = 0, disp = 0;
	HKEY rootKey = NULL, storesKey = NULL, key = NULL;

	HCERTSTORE hCertStore = NULL;
	TCHAR root[MAX_REG_KEY_LEN];

	// Get params
	if (!GetParams(&p, argc, argv)) {
		_tprintf(TEXT("Usage:\n"));
		_tprintf(TEXT("%s hive crt.cer [/CRL crl.crl] [/Store store]\n\n"), argv[0]);
		_tprintf(TEXT("hive\ta registry hive for HKLM\\SOFTWARE (user hives not supported)\n"));
		_tprintf(TEXT("  found at Windows\\System32\\config\\SOFTWARE (cannot use be an in-use hive)\n"));
		_tprintf(TEXT("crt.cer\tthe certificate to import\n"));
		_tprintf(TEXT("crl.crl\tif provided adds a CRL as well\n"));
		_tprintf(TEXT("store\tthe store to import to, defaults to ROOT\n\n"));
		return -1;
	}

	// Enable privileges
	if (!EnablePriv(SE_TAKE_OWNERSHIP_NAME) || !EnablePriv(SE_BACKUP_NAME) || !EnablePriv(SE_RESTORE_NAME)) {
		return LastError(TEXT("Failed to enable take ownership, backup, and restore privileges"), NULL);
	}

	// Read the certificate file
	if ((cert = Read(p.cert, &certSz)) == NULL) {
		return LastError(TEXT("Failed to read certificate file '%s'"), p.cert);
	}

	// Read the CRL file
	if (p.crl && ((crl = Read(p.crl, &crlSz)) == NULL)) {
		LocalFree(cert);
		return LastError(TEXT("Failed to read the CRL file '%s'"), p.crl);
	}

	// Find a subkey that's available
	_tcsncpy(root, TEXT("TEMPHIVE"), MAX_REG_KEY_LEN);
	if ((retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, root, 0, KEY_READ, &key)) != ERROR_FILE_NOT_FOUND) {
		if (retval != ERROR_SUCCESS) {
			LocalFree(crl);
			LocalFree(cert);
			return Error(TEXT("Failed to find subkey to load hive"), NULL, retval);
		}
		RegCloseKey(key);
		_sntprintf(root, MAX_REG_KEY_LEN, TEXT("TEMPHIVE%u"), index++);
	}
	key = NULL;

	// Load the hive
	if ((retval = RegLoadKey(HKEY_LOCAL_MACHINE, root, p.hive)) != ERROR_SUCCESS) {
		LocalFree(cert);
		if (crl) LocalFree(crl);
		return Error(TEXT("Failed to load hive file '%s'"), p.hive, retval);
	}

	// Open the HKLM\TEMPHIVE\Microsoft\SystemCertificates
	if ((retval = RegOpenKeyEx(HKEY_LOCAL_MACHINE, root, 0, KEY_ALL_ACCESS, &rootKey)) != ERROR_SUCCESS) {
		Error(TEXT("Failed to get root key '%s'"), root, retval);
	} else if ((retval = RegOpenKeyEx(rootKey, TEXT("Microsoft\\SystemCertificates"), 0, KEY_ALL_ACCESS, &storesKey)) != ERROR_SUCCESS) {
		Error(TEXT("Failed to get stores key: %u\n"), NULL, retval);

	// Create/Open the registry certificate store
	} else if ((retval = RegCreateKeyEx(storesKey, p.store, 0, NULL, REG_OPTION_BACKUP_RESTORE, KEY_ALL_ACCESS, NULL, &key, &disp)) != ERROR_SUCCESS) {
		Error(TEXT("Failed to create store key '%s'"), p.store, retval);

	// Open the store
	} else if ((hCertStore = CertOpenStore(CERT_STORE_PROV_REG, 0, (HCRYPTPROV)NULL, CERT_STORE_BACKUP_RESTORE_FLAG | CERT_STORE_OPEN_EXISTING_FLAG, key)) == NULL) {
		retval = LastError(TEXT("Failed to create certificate store"), NULL);

	// Add the certificate to the store
	} else if (!CertAddEncodedCertificateToStore(hCertStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, cert, certSz, CERT_STORE_ADD_REPLACE_EXISTING, NULL)) {
		retval = LastError(TEXT("Failed add certificate to store"), NULL);

	// Add the crl to the store
	} else if (crl && !CertAddEncodedCRLToStore(hCertStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, crl, crlSz, CERT_STORE_ADD_REPLACE_EXISTING, NULL)) {
		retval = LastError(TEXT("Failed add the CRL to store"), NULL);
	}

	// Cleanup
	if (hCertStore) { CertCloseStore(hCertStore, CERT_CLOSE_STORE_FORCE_FLAG); }
	if (key)		{ RegCloseKey(key); }
	if (storesKey)	{ RegCloseKey(storesKey); }
	if (rootKey)	{ RegCloseKey(rootKey); }
	LocalFree(crl);
	LocalFree(cert);

	// Unload the hive
	if ((disp = RegUnLoadKey(HKEY_LOCAL_MACHINE, root)) != ERROR_SUCCESS) {
		if (retval == ERROR_SUCCESS) { retval = disp; }
		Error(TEXT("Failed to unload the hive"), NULL, disp);
	}

	// Successful? Yeah!
	if (retval == ERROR_SUCCESS) {
		if (p.crl) {
			_tprintf(TEXT("Successfully added %s and %s to the %s store in %s\n\n"), p.cert, p.crl, p.store, p.hive);
		} else {
			_tprintf(TEXT("Successfully added %s to the %s store in %s\n\n"), p.cert, p.store, p.hive);
		}
	}

	return retval;
}
Example #26
0
mixture::mixture(bool fulltable,char* sublminfo,int depth,int prunefreq,char* ipfile,char* opfile):
  mdiadaptlm((char *)NULL,depth)
{

  prunethresh=prunefreq;
  ipfname=ipfile;
  opfname=opfile;
  usefulltable=fulltable;

  mfstream inp(sublminfo,ios::in );
  if (!inp) {
		std::stringstream ss_msg;
		ss_msg << "cannot open " << sublminfo;
		exit_error(IRSTLM_ERROR_IO, ss_msg.str());
  }

	char line[MAX_LINE];
	inp.getline(line,MAX_LINE);
	
	sscanf(line,"%d",&numslm);
	
  sublm=new interplm* [numslm];

  cerr << "WARNING: Parameters PruneSingletons (ps) and PruneTopSingletons (pts) are not taken into account for this type of LM (mixture); please specify the singleton pruning policy for each submodel using parameters \"-sps\" and \"-spts\" in the configuraton file\n";

  int max_npar=6;
  for (int i=0; i<numslm; i++) {
    char **par=new char*[max_npar];
    par[0]=new char[BUFSIZ];
    par[0][0]='\0';
		
		inp.getline(line,MAX_LINE);
		
		const char *const wordSeparators = " \t\r\n";
		char *word = strtok(line, wordSeparators);
		int j = 1;
		
		while (word){
			if (i>max_npar){
				std::stringstream ss_msg;
				ss_msg << "Too many parameters (expected " << max_npar << ")";
				exit_error(IRSTLM_ERROR_DATA, ss_msg.str());
			}
			par[j] = new char[MAX_LINE];
			strcpy(par[j],word);
//			std::cerr << "par[j]:|" << par[j] << "|" << std::endl;
		  word = strtok(0, wordSeparators);
			j++;
		}
	
    int actual_npar = j;	
		
    char *subtrainfile;
    int slmtype;
    bool subprunesingletons;
    bool subprunetopsingletons;
    int subprunefreq;

    DeclareParams((char*)
      "SubLanguageModelType",CMDENUMTYPE|CMDMSG, &slmtype, SLmTypeEnum, "type of the sub LM",
			"slm",CMDENUMTYPE|CMDMSG, &slmtype, SLmTypeEnum, "type of the sub LM",
			"sTrainOn",CMDSTRINGTYPE|CMDMSG, &subtrainfile, "training file of the sub LM",
      "str",CMDSTRINGTYPE|CMDMSG, &subtrainfile, "training file of the sub LM",
      "sPruneThresh",CMDSUBRANGETYPE|CMDMSG, &subprunefreq, 0, 1000, "threshold for pruning the sub LM",
      "sp",CMDSUBRANGETYPE|CMDMSG, &subprunefreq, 0, 1000, "threshold for pruning the sub LM",									
      "sPruneSingletons",CMDBOOLTYPE|CMDMSG, &subprunesingletons,  "boolean flag for pruning of singletons of the sub LM (default is true)",
      "sps",CMDBOOLTYPE|CMDMSG, &subprunesingletons, "boolean flag for pruning of singletons of the sub LM (default is true)",
      "sPruneTopSingletons",CMDBOOLTYPE|CMDMSG, &subprunetopsingletons, "boolean flag for pruning of singletons at the top level of the sub LM (default is false)",
      "spts",CMDBOOLTYPE|CMDMSG, &subprunetopsingletons, "boolean flag for pruning of singletons at the top level of the sub LM (default is false)",				
			(char *)NULL  );

    subtrainfile=NULL;
    slmtype=0;
    subprunefreq=-1;
    subprunesingletons=true;
    subprunetopsingletons=false;

		GetParams(&actual_npar, &par, (char*) NULL);
		

    if (!slmtype) {
			std::stringstream ss_msg;
			ss_msg << "The type (-slm) for sub LM number " << i+1 << "  is not specified" ;
			exit_error(IRSTLM_ERROR_DATA, ss_msg.str());
    }

		if (!subtrainfile) {
			std::stringstream ss_msg;
			ss_msg << "The file (-str) for sub lm number " << i+1 << " is not specified";
			exit_error(IRSTLM_ERROR_DATA, ss_msg.str());
    }

		if (subprunefreq==-1) {
			std::stringstream ss_msg;
			ss_msg << "The prune threshold (-sp) for sub lm number " << i+1 << "  is not specified";
			exit_error(IRSTLM_ERROR_DATA, ss_msg.str());
    }

		switch (slmtype) {

    case LINEAR_WB:
      sublm[i]=new linearwb(subtrainfile,depth,subprunefreq,MSHIFTBETA_I);
      break;

    case SHIFT_BETA:
      sublm[i]=new shiftbeta(subtrainfile,depth,subprunefreq,-1,SHIFTBETA_I);
      break;

    case SHIFT_ONE:
      sublm[i]=new shiftbeta(subtrainfile,depth,subprunefreq,SIMPLE_I);
      break;

    case MOD_SHIFT_BETA:
      sublm[i]=new mshiftbeta(subtrainfile,depth,subprunefreq,MSHIFTBETA_I);
      break;

    case MIXTURE:
      sublm[i]=new mixture(usefulltable,subtrainfile,depth,subprunefreq);
      break;

    default:
				exit_error(IRSTLM_ERROR_DATA, "not implemented yet");
    };

    sublm[i]->prunesingletons(subprunesingletons==true);
    sublm[i]->prunetopsingletons(subprunetopsingletons==true);

    if (subprunetopsingletons==true)
      //apply most specific pruning method
      sublm[i]->prunesingletons(false);


    cerr << "eventually generate OOV code of sub lm[" << i << "]\n";
    sublm[i]->dict->genoovcode();

    //create super dictionary
    dict->augment(sublm[i]->dict);

    //creates the super n-gram table
    if(usefulltable) augment(sublm[i]);

  }
	
	cerr << "eventually generate OOV code of the mixture\n";
  dict->genoovcode();
  cerr << "dict size of the mixture:" << dict->size() << "\n";
  //tying parameters
  k1=2;
  k2=10;
};
CDrawingObjectParams CDrawingObject::GetParams() const
{
	CDrawingObjectParams params;
	GetParams(params);
	return params;
}
Example #28
0
void ParseCommand(char *string)
{
  char Command;
  char Command2 = 0;
  unsigned int Params[MAX_COMMAND_PARAMS];
  unsigned int NumParams=0;

/*  UsartWriteString("Command Received: ");
  UsartWriteString(string);
  UsartWriteString("\n\r");
*/
  // assume commands are single character followed by numerical parameters sep by spaces
  // e.g. "s 1 5", "b 7", "b 100 120 001 212 123"
  Command = string[0];
  if(IsAlpha(string[1])) // multi-char command (e.g. pa, oa, ia, etc)
	  Command2 = string[1];

  if(Command != 0)
  {
    NumParams=GetParams(string,Params); // read any optional parameters after command

/*
    UsartWriteString("CommandID: ");
    UsartWriteChar(Command);
    if(Command2 != 0)
      UsartWriteChar(Command2);
    UsartWriteString(" #Params: ");
    UsartWriteChar(48+NumParams);
    UsartWriteString("\n\r");
*/
  }
  else
  {
  UsartWriteString("No Command\n\r");
  };

  unsigned short lcdDataIn;
  static char buffer[10];

  switch(Command)
  {


    case 'a': // ADC do immediate conversion
	    PORTQ.OUTCLR = PIN0_bm | PIN2_bm; //ENCODE pins
		_delay_ms(1);
		PORTQ.OUTSET = PIN0_bm | PIN2_bm;
		_delay_ms(1);
		char value = PORTD.IN;
		
		
		
		IntToString(value,&buffer[0]);
		UsartWriteLine(buffer);
	  break;

	case 'b': // read imager flag
		PORTA.DIR &= ~0x01;
		char bb6 = PORTA.IN & 0x01;
		
		IntToString(bb6,&buffer[0]);
		UsartWriteLine(buffer);
	  break;

	case 'y': // Start Image
		frame = 0;
		start_interrupts();
	break;

	case 'z': // Stop Image
		stop_interrupts();
	break;

    case 'l':
		lcdDataIn = TSLCDInDat();
		IntToString(lcdDataIn,&buffer[0]);
		UsartWriteLine(buffer);
      break;

	case 'x':
		IntToString(4,&buffer[0]);
		UsartWriteLine(buffer);
      break;

    case 'T': // Usart TX test
	  DoUsartTx(Command2,Params[0],"0123456789");
	  break;

    case 'S': // Config SPI port
	  DoSpiConfig(Command2,Params[0]);
	  break;

    case 'X': // SPI TX test
	  DoSpiTx(Command2,"0123456789");
	  break;

    case 's': // Sleep CPU
	  DoSleep(Params[0]); // this will not return 
	  break;

    case 'O': // Set oscillator source
	  DoOscillator(Params[0]); // this will not return 
	  break;

    case 'h': // Usage
	  break;

  };	  


return;
};
Example #29
0
BOOL CALLBACK OptionDlg::run_dlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
	switch (Message) 
	{
		case WM_INITDIALOG:
		{
			goToCenter();

			for (int i = 0; i < SFMT_MAX; i++)
			{
				::SendDlgItemMessage(_hSelf, IDC_COMBO_SIZE_FORMAT, CB_ADDSTRING, 0, (LPARAM)pszSizeFmt[i]);
			}
			for (i = 0; i < DFMT_MAX; i++)
			{
				::SendDlgItemMessage(_hSelf, IDC_COMBO_DATE_FORMAT, CB_ADDSTRING, 0, (LPARAM)pszDateFmt[i]);
			}
			::SendDlgItemMessage(_hSelf, IDC_EDIT_TIMEOUT, EM_LIMITTEXT, 5, 0);
			
			SetParams();
			LongUpdate();

			/* change language */
			NLChangeDialog(_hInst, _nppData._nppHandle, _hSelf, _T("Options"));
			NLChangeCombo(_hInst, _nppData._nppHandle, ::GetDlgItem(_hSelf, IDC_COMBO_SIZE_FORMAT), _T("ComboSize"), SFMT_MAX);
			NLChangeCombo(_hInst, _nppData._nppHandle, ::GetDlgItem(_hSelf, IDC_COMBO_DATE_FORMAT), _T("ComboDate"), DFMT_MAX);

			break;
		}
		case WM_COMMAND : 
		{
			switch (LOWORD(wParam))
			{
				case IDC_CHECK_LONG:
				{
					LongUpdate();
					return TRUE;
				}
				case IDC_BTN_OPENDLG:
				{
					// This code was copied and slightly modifed from:
					// http://www.bcbdev.com/faqs/faq62.htm

					// SHBrowseForFolder returns a PIDL. The memory for the PIDL is
					// allocated by the shell. Eventually, we will need to free this
					// memory, so we need to get a pointer to the shell malloc COM
					// object that will free the PIDL later on.
					LPMALLOC pShellMalloc = 0;
					if (::SHGetMalloc(&pShellMalloc) == NO_ERROR)
					{
						// If we were able to get the shell malloc object,
						// then proceed by initializing the BROWSEINFO stuct
						BROWSEINFO info;
						ZeroMemory(&info, sizeof(info));
						info.hwndOwner			= _hParent;
						info.pidlRoot			= NULL;
						info.pszDisplayName		= (LPTSTR)new TCHAR[MAX_PATH];
						info.lpszTitle			= _T("Select a folder:");
						info.ulFlags			= BIF_RETURNONLYFSDIRS;
						info.lpfn				= BrowseCallbackProc;
						info.lParam				= (LPARAM)_pProp->nppExecProp.szScriptPath;

						// Execute the browsing dialog.
						LPITEMIDLIST pidl = ::SHBrowseForFolder(&info);

						// pidl will be null if they cancel the browse dialog.
						// pidl will be not null when they select a folder.
						if (pidl) 
						{
							// Try to convert the pidl to a display string.
							// Return is true if success.
							if (::SHGetPathFromIDList(pidl, _pProp->nppExecProp.szScriptPath))
							{
								// Set edit control to the directory path.
								::SetWindowText(::GetDlgItem(_hSelf, IDC_EDIT_SCRIPTPATH), _pProp->nppExecProp.szScriptPath);
							}
							pShellMalloc->Free(pidl);
						}
						pShellMalloc->Release();
						delete [] info.pszDisplayName;
					}
					break;
				}
				case IDC_BTN_EXAMPLE_FILE:
				{
#ifdef UNICODE
					CHAR	szBOM[]			= {0xFF, 0xFE};
#endif
					DWORD	dwByteWritten	= 0;
					TCHAR	szExampleScriptPath[MAX_PATH];

					if (_pProp->nppExecProp.szScriptPath[0] == '.')
					{
						/* module path of notepad */
						GetModuleFileName(_hInst, szExampleScriptPath, sizeof(szExampleScriptPath));
						PathRemoveFileSpec(szExampleScriptPath);
						PathAppend(szExampleScriptPath, _pProp->nppExecProp.szScriptPath);
					} else {
						_tcscpy(szExampleScriptPath, _pProp->nppExecProp.szScriptPath);
					}
					::PathAppend(szExampleScriptPath, _T("Goto path.exec"));

					HANDLE	hFile = ::CreateFile(szExampleScriptPath, 
						GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 
						NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

#ifdef UNICODE
					::WriteFile(hFile, szBOM, sizeof(szBOM), &dwByteWritten, NULL);
#endif
					for (INT i = 0; i < MAX_NPP_EXAMPLE_LINE; i++)
						::WriteFile(hFile, szExampleScript[i], _tcslen(szExampleScript[i]) * sizeof(TCHAR), &dwByteWritten, NULL);

					::CloseHandle(hFile);
					break;
				}
				case IDCANCEL:
					::EndDialog(_hSelf, IDCANCEL);
					return TRUE;
				case IDOK:
				{
					if (GetParams() == FALSE)
					{
						return FALSE;
					}
					::EndDialog(_hSelf, IDOK);
					return TRUE;
				}
				default:
					return FALSE;
			}
			break;
		}
		default:
			break;
	}
	return FALSE;
}
Example #30
0
int main (int argc, char *argv[])
{
    /*data--------- */
    int *Geno;                    /*NUMINDSxLINES: genotypes */
    float *R;                    /*NUMINDS */
    float *Mapdistance;          /*NUMLOCI */
    float *Phase;                /*NUMLOCI*NUMINDS */
    int *Phasemodel=NULL;         /*NUMINDS */
    char *Markername;             /*GENELEN*NUMLOCI */

    struct IND *Individual;       /*NUMINDS: records for each individual */
    int *Translation;             /*NUMLOCIxMAXALLELES: value of each coded allele */
    int *NumAlleles;              /*NUMLOCI: number of alleles at each locus */

    /* only used for recessive or inbreeding models: */
    int *PreGeno=
        NULL;           /*NUMINDSxLINESxNUMLOCI; diploid genotype if recessive alleles */
    int *Recessive=
        NULL;         /*NUMLOCI recessive allele at each locus, or -1 if there is none */


    /*Basic parameters */
    int *Z;                       /*NUMINDSx2xNUMLOCI: Z=pop of origin for each allele */
    int *Z1;
    float *Q;                    /*NUMINDSxMAXPOPS:  Q=ancestry of individuals */
    float *P;                    /*NUMLOCIxMAXPOPSxMAXALLELES: P=population allele freqs */
    float *Epsilon;              /*NUMLOCIxMAXALLELES: Dirichlet parameter for allele
                                  frequencies. This is either LAMBDA (if uncorrelated), or
                                  ancestral allele freqs if they are correlated */
    float *Fst;          /*MAXPOPS: Factor multiplied by epsilon under the Fst model */
    float *Alpha;                /*MAXPOPS: Dirichlet parameter for degree of admixture.
                                  Start this at ALPHA, and possibly change
                                  (if INFERALPHA==1) */
    float *lambda;                /*Dirichlet prior parameter for allele frequencies;
                                   start this at LAMBDA, and update if INFERLAMBDA*/
    float *sumlambda;
    /*Summaries */
    int    *NumLociPop;           /*NUMINDSxMAXPOPS: Number of alleles from each pop (by ind) */
    float *PSum;                 /*NUMLOCIxMAXPOPSxMAXALLELES: sum of AlFreqs */
    float *QSum;                 /*NUMINDSxMAXPOPS:  sum of Ancestries */
    float *FstSum;               /*MAXPOPS:  Sum of Fst */
    float *SumEpsilon=
        NULL;      /*NUMLOCIxMAXALLELES: sum of ancestral allele freqs*/
    float *sumAlpha;              /*MAXPOPS*/
    float *sumR;                 /*NUMINDS */
    float *varR;                 /*NUMINDS */
    float recomblikelihood=0.0;
    float *like;                  /*current likelihood value */
    float *sumlikes;              /*sum of likelihood values */
    float *sumsqlikes;            /*sum of squared likelihoods */

    int *popflags; /*The populationflags of individuals*/
    unsigned int *randGens;


    /*Melissa added 7/12/07 for calculating DIC*/
    float *sumIndLikes, *indLikesNorm;

    int    *AncestDist=
        NULL;      /*NUMINDS*MAXPOPS*NUMBOXES histogram of Q values */
    float *UsePopProbs=
        NULL;     /*NUMINDS*MAXPOPS*(GENSBACK+1) This is used when the
                                  population info is used.  It stores the probability that an
                                  individual has each of a specified set of ancestry amounts */
    /*loop variables-------------- */
    int rep;                      /*MCMC iterations so far */
    int savefreq;                 /*frequency of saving to file */
    int ind;

    /*Melissa's new variables added 7/12/07 to use priors based on sampling location*/
    float *LocPrior=NULL, *sumLocPrior=NULL, LocPriorLen=0;

    /* ======================= GPU Structure ======================== */
    /*Dict to that keeps track of CL info */
    /*CLDict *clDict = NULL;*/
    float * randomArr; /* array of random numbers */
    int POPFLAGINDS = 0;
    float invsqrtnuminds;
    /* enum BUFFER buffers[5]; */
    /* char         *names[5]; */
    /* size_t        sizes[5]; */
    /* void         *dests[5]; */

    float  *reduceresult;
    int *Numafrompopscl;
    int *Numlocipopscl;

    if (signal(SIGINT, catch_function) == SIG_ERR) {
        fputs("An error occurred while setting a signal handler.\n", stderr);
        return EXIT_FAILURE;
    }

    clDict = malloc(sizeof (*clDict));
    sumlikes = calloc(1,sizeof(float));
    sumsqlikes = calloc(1,sizeof(float));
    like = calloc(1,sizeof(float));
    /*=====Code for getting started=============================*/

    Welcome (stdout);             /*welcome */
    GetParams (0,argc,argv);      /*read in parameter values */

    CheckParamCombinations();     /*check that some parameter combinations are valid*/

    Mapdistance = calloc (NUMLOCI, sizeof (float));
    Phase = calloc (NUMLOCI * NUMINDS, sizeof (float));


    if (LINES ==2 && PHASED ==0) {
        Phasemodel=calloc(NUMINDS,sizeof(int));
        for (ind=0; ind<NUMINDS; ind++) {
            if (MARKOVPHASE) {
                Phasemodel[ind]=0;
            } else {
                Phasemodel[ind]=1;
            }
        }
    }

    lambda=calloc(MAXPOPS, sizeof (float));
    sumlambda=calloc(MAXPOPS, sizeof (float));

    Markername = calloc (GENELEN*NUMLOCI, sizeof (char));
    Geno = calloc (LINES * NUMLOCI * NUMINDS, sizeof (int));
    if (RECESSIVEALLELES) {
        PreGeno = calloc (LINES * NUMLOCI * NUMINDS, sizeof (int));
        Recessive = calloc (NUMLOCI, sizeof (int));
        if (PreGeno == NULL || Recessive == NULL) {
            printf ("Error (3) in assigning memory\n");
            Kill ();
        }
    }

    Individual = calloc (NUMINDS, sizeof (struct IND));
    if (Geno == NULL || Individual == NULL || Mapdistance == NULL
            || Markername == NULL) {
        printf ("Error in assigning memory (not enough space?)\n");
        Kill ();
    }
    Randomize(RANDOMIZE, &SEED);

    /*read in data file */
    if (RECESSIVEALLELES) {
        ReadInputFile(PreGeno, Mapdistance, Markername, Individual, Phase, Recessive);
    } else {
        ReadInputFile (Geno, Mapdistance, Markername, Individual, Phase, Recessive);
    }

    if (RECESSIVEALLELES) {
        MAXALLELES = FindMaxAlleles (PreGeno, Recessive);
    } else {
        MAXALLELES = FindMaxAlleles (Geno, Recessive);
    }


    /*=============set aside memory space=====================*/
    Translation = calloc (NUMLOCI * MAXALLELES, sizeof (int));
    NumAlleles = calloc (NUMLOCI, sizeof (int));
    Z = calloc (NUMINDS * LINES * NUMLOCI, sizeof (int));
    Z1 = calloc (NUMINDS * LINES * NUMLOCI, sizeof (int));
    Q = calloc (NUMINDS * MAXPOPS, sizeof (float));
    P = calloc (NUMLOCI * MAXPOPS * MAXALLELES, sizeof (float));
    R = calloc (NUMINDS, sizeof (float));
    sumR = calloc (NUMINDS, sizeof (float));
    varR = calloc (NUMINDS, sizeof (float));
    Epsilon = calloc (NUMLOCI * MAXALLELES, sizeof (float));
    if (FREQSCORR) {
        SumEpsilon = calloc (NUMLOCI * MAXALLELES, sizeof (float));
    }
    Fst = calloc (MAXPOPS, sizeof (float));
    FstSum = calloc (MAXPOPS, sizeof (float));
    NumLociPop = calloc (NUMINDS * MAXPOPS, sizeof (int));
    PSum = calloc (NUMLOCI * MAXPOPS * MAXALLELES, sizeof (float));
    QSum = calloc (NUMINDS * MAXPOPS, sizeof (float));


    if (ANCESTDIST) {
        AncestDist = calloc (NUMINDS * MAXPOPS * NUMBOXES, sizeof (int));
    }
    if (USEPOPINFO) {
        UsePopProbs = calloc (NUMINDS * MAXPOPS * (GENSBACK + 1), sizeof (float));
    }

    /*Melissa added 7/12/07*/
    if (LOCDATA>0 || LOCISPOP) {
        GetNumLocations(Individual);
    }

    /*Allocate the LocPrior vector.
      For no-admixture, it contains r, and the vectors nu and gamma.
      For admixture, it contains gamma.  The alphas_locals are stored with alpha global*/
    if (LOCPRIOR) {
        if (NOADMIX) {
            LocPriorLen = 1+MAXPOPS*(NUMLOCATIONS+1);
        } else {
            LocPriorLen=1;
        }
        LocPrior = malloc(LocPriorLen*sizeof(float));
        sumLocPrior = malloc(LocPriorLen*sizeof(float));
    }

    if (LOCPRIOR && NOADMIX==0) {
        Alpha = malloc(MAXPOPS*(NUMLOCATIONS+1)*sizeof(float));
        sumAlpha = malloc(MAXPOPS*(NUMLOCATIONS+1)*sizeof(float));
    } else {
        Alpha = calloc(MAXPOPS, sizeof (float));
        sumAlpha = calloc(MAXPOPS, sizeof (float));
    }

    /* this is for DIC */
    sumIndLikes = malloc(NUMINDS*sizeof(float));
    indLikesNorm = malloc(NUMINDS*sizeof(float));

    if ((Translation == NULL) || (NumAlleles == NULL) || (Z == NULL)
            || (Z1 == NULL) || (Q == NULL) ||
            (P == NULL) || (R == NULL) || (sumR == NULL) || (varR == NULL)
            || (Epsilon == NULL) ||
            (Fst == NULL) || (NumLociPop == NULL) ||
            (PSum == NULL) || (QSum == NULL) ||  (FstSum == NULL) ||
            ((ANCESTDIST) && (AncestDist == NULL)) ||
            ((USEPOPINFO) && (UsePopProbs == NULL))||(Alpha == NULL)||(sumAlpha==NULL)||
            ((FREQSCORR) && (SumEpsilon == NULL)) ||
            (LocPriorLen>0 && (LocPrior==NULL || sumLocPrior==NULL)) ||
            sumIndLikes==NULL || indLikesNorm==NULL) {

        printf ("Error in assigning memory (not enough space?)\n");
        FreeAll(Mapdistance, Phase, Phasemodel, lambda, sumlambda, Markername, Geno,
                PreGeno, Recessive,
                Individual, Translation, NumAlleles, Z, Z1, Q, P,  R, sumR, varR, Epsilon,
                SumEpsilon,
                Fst, FstSum, NumLociPop, PSum, QSum,  AncestDist, UsePopProbs, LocPrior,
                sumLocPrior, Alpha, sumAlpha, sumIndLikes, indLikesNorm, clDict);
        Kill ();
    }
    /*=========done setting aside memory space=====================*/

    /*initialize variables and arrays */
    Initialization (Geno, PreGeno, Individual, Translation, NumAlleles, Z, Z1,
                    Epsilon, SumEpsilon,
                    Fst, PSum, Q, QSum, FstSum, AncestDist, UsePopProbs, Alpha,
                    sumAlpha, sumR, varR, sumlikes, sumsqlikes, &savefreq, R, lambda,
                    sumlambda,Phase,Recessive, LocPrior, sumLocPrior, LocPriorLen, sumIndLikes,
                    indLikesNorm, clDict);

    /* ==================== GPU Structure ==================== */

    /*Allocate an array of random numbers. Primarily used so that we can compare
     CL implementation to the original */
    randomArr = calloc(RANDSIZE,sizeof(float));
    randGens = calloc(NUMRANDGENS,sizeof(unsigned int));

    Numafrompopscl = calloc(NUMLOCI*MAXPOPS*MAXALLELES,sizeof(int));
    Numlocipopscl = calloc(NUMINDS*MAXPOPS,sizeof(int));

    /* ====== OpenCL initialized ====== */

    printf ("\n\n--------------------------------------\n\n");
    printf ("Finished initialization; starting MCMC \n");
    printf ("%d iterations + %d burnin\n\n", NUMREPS, BURNIN);

    /*=====Main MCMC loop=======================================*/

    writeBuffer(clDict,Numafrompopscl,sizeof(int) * NUMLOCI*MAXPOPS*MAXALLELES,NUMAFROMPOPSCL,"NumAFromPops");
    writeBuffer(clDict,Numlocipopscl,sizeof(int)*NUMINDS*MAXPOPS,NUMLOCIPOPSCL,"NUMLOCIPOPS");
    /* init buffers on GPU */
    writeBuffer(clDict,P,sizeof(float) * PSIZE,PCL,"P");
    writeBuffer(clDict,Z,sizeof(int)*ZSIZE,ZCL,"Z");
    writeBuffer(clDict,Q, sizeof(float) * QSIZE,QCL, "Q");
    writeBuffer(clDict,NumAlleles,sizeof(int) * NUMLOCI,NUMALLELESCL,"NumAlleles");
    writeBuffer(clDict,lambda,sizeof(float) * MAXPOPS,LAMBDACL,"LAMBDA");
    if(!RECESSIVEALLELES){
        writeBuffer(clDict,Geno,sizeof(int)*GENOSIZE,GENOCL,"Geno");
    }

    popflags = calloc(NUMINDS,sizeof(int));
    for(ind = 0; ind < NUMINDS;ind++){
        popflags[ind] = Individual[ind].PopFlag;
        if (!((USEPOPINFO) && (Individual[ind].PopFlag))) {
            POPFLAGINDS++;
        }
    }

    printf("Setting updatealpha arg\n");
    setKernelArgExplicit(clDict,UpdateAlphaKernel,sizeof(int),&POPFLAGINDS,7);

    printf("Setting invsqrtnuminds arg\n");
    invsqrtnuminds = 1.0/sqrt(NUMINDS);
    setKernelArgExplicit(clDict,NonIndUpdateEpsilonKernel,sizeof(float),&invsqrtnuminds,6);

    writeBuffer(clDict,popflags,sizeof(int)*NUMINDS,POPFLAGCL,"popflags");

    writeBuffer(clDict,Alpha,sizeof(float) *MAXPOPS,ALPHACL,"Alpha");
    reduceresult = calloc(NUMINDS*NUMLOCI*MAXGROUPS,sizeof(float));
    if(reduceresult == NULL){
        printf("Failed to allocate reduce result\n");
    }
    printf("Writing reduce results\n");
    writeBuffer(clDict,reduceresult,sizeof(float)*MAXGROUPS*NUMINDS*NUMLOCI,REDUCERESULTSCL,"result");
    printf("Done writing reduce results\n");

    writeBuffer(clDict,sumAlpha, sizeof(float) * MAXPOPS,ALPHASUMCL, "alphasum");
    writeBuffer(clDict,sumlambda, sizeof(float) * MAXPOPS,LAMBDASUMCL, "lambdasum");

    writeBuffer(clDict,like, sizeof(float),LIKECL, "like");
    writeBuffer(clDict,sumsqlikes, sizeof(float),SUMSQLIKESCL, "sumsqlikes");
    writeBuffer(clDict,sumlikes, sizeof(float),SUMLIKESCL, "sumlikes");

    writeBuffer(clDict,QSum, sizeof(float) * QSIZE,QSUMCL, "qsum");
    writeBuffer(clDict,PSum, sizeof(float) * PSIZE,PSUMCL, "psum");
    writeBuffer(clDict,SumEpsilon, sizeof(float) * NUMLOCI*MAXALLELES,EPSILONSUMCL, "epssum");
    if(ANCESTDIST){
        writeBuffer(clDict,AncestDist, sizeof(int)*NUMINDS*MAXPOPS*NUMBOXES,ANCESTDISTCL, "ancest dist");
    }

    if (FREQSCORR) {
        writeBuffer(clDict,Fst,sizeof(float) * MAXPOPS,FSTCL,"FST");
        writeBuffer(clDict,FstSum, sizeof(float) * MAXPOPS,FSTSUMCL, "fstsum");
        writeBuffer(clDict,Epsilon,sizeof(float) * NUMLOCI*MAXALLELES,EPSILONCL,
                    "EPSILON");
    }
    /*printf("%d, %d\n",INFERALPHA,INFERLAMBDA);*/
    /*printf("%d\n",USEPOPINFO);*/
    /*printf("%d\n",RECESSIVEALLELES);*/
    /*printf("%d\n",LINKAGE);*/
    /*printf("%d\n",COMPUTEPROB);*/
    /*printf("%d\n",POPALPHAS);*/
    /*printf("%d\n",NOADMIX);*/
    /*printf("%d\n",LOCPRIOR);*/
    /*handleCLErr(1,clDict,"heyhey");*/

    /*Initialize Q */
    initQ(Q);
    initRandGens(clDict,randGens);
    finishWaitList(clDict);
    printf("Waitlist finished!\n");
    for (rep = 0; rep < (NUMREPS + BURNIN); rep++) {
        breakP(clDict);

        /*FillArrayWithRandomCL(clDict,randomArr,NUMLOCI*MAXALLELES*MAXPOPS*MAXRANDOM);*/
        /*FillArrayWithRandom(randomArr,NUMLOCI*MAXALLELES*MAXPOPS*MAXRANDOM);*/
        /*FillArrayWithRandom(randomArr,RANDSIZE);*/

        /* if(DEBUGCOMPARE) { */
        /*     readBuffer(clDict,randomArr, */
        /*             sizeof(float) * NUMLOCI*MAXALLELES*MAXPOPS*MAXRANDOM,RANDCL, */
        /*             "randomArr"); */
        /*     comparePCLandP(clDict,P,Epsilon, Fst, NumAlleles, Geno, Z, */
        /*                    lambda, Individual, randomArr); */
        /* } */
        /* if (USEWORKINGCL) { */
            /* clear buffer */
            writeBuffer(clDict,Numafrompopscl,sizeof(int) * NUMLOCI*MAXPOPS*MAXALLELES,NUMAFROMPOPSCL,"NumAFromPops");
            UpdatePCL (clDict,P, Epsilon, Fst, NumAlleles, Geno, Z, lambda,
                       Individual,
                       randomArr);
        /* }  else { */
        /*     readBuffer(clDict,randomArr, */
        /*             sizeof(float) * NUMLOCI*MAXALLELES*MAXPOPS*MAXRANDOM,RANDCL, */
        /*             "randomArr"); */
        /*     UpdateP (P, Epsilon, Fst, NumAlleles, Geno, Z, lambda, Individual, */
        /*              randomArr); */
        /* } */

        /* Update Q */
        /*FillArrayWithRandomCL(clDict,randomArr,NUMINDS+NUMINDS*MAXRANDOM);*/
        if (LINKAGE && rep >= ADMBURNIN) {
            UpdateQMetroRecombine (Geno, Q, Z, P, Alpha, rep,
                                   Individual, Mapdistance, R, Phase,Phasemodel,randomArr);
        } else {
            writeBuffer(clDict,Numlocipopscl,sizeof(int)*NUMINDS*MAXPOPS,NUMLOCIPOPSCL,"NUMLOCIPOPS");
            UpdateQCL (clDict,Geno, PreGeno, Q, P, Z, Alpha, rep, Individual, UsePopProbs,
                     Recessive, LocPrior,randomArr);
        }

        if (LOCPRIOR && UPDATELOCPRIOR) {
            UpdateLocPrior(Q, LocPrior, Alpha, Individual);
        }

        if (RECESSIVEALLELES) {
            UpdateGeno (PreGeno, Geno, P, Z, Recessive, NumAlleles, Q);
            writeBuffer(clDict,Geno,sizeof(int) * GENOSIZE,GENOCL,"Geno");
            /*The Zs are not correct after UpdateGeno, until UpdateZ is run */
        }

        if (LINKAGE && rep > ADMBURNIN) {
            if (!INDIVIDUALR) {
                recomblikelihood = UpdateZandSingleR(Z,  Q, P, Geno,
                                                     R, Mapdistance, rep, Phase, Z1,Phasemodel, rep+1 > BURNIN? sumIndLikes : NULL,
                                                     indLikesNorm);
            } else {
                recomblikelihood = UpdateZandR(Z,  Q, P, Geno, R,
                                               Mapdistance, rep, Phase, Z1,Phasemodel, rep+1 > BURNIN ? sumIndLikes:NULL,
                                               indLikesNorm);
            }
        } else {
            /*FillArrayWithRandomCL(clDict,randomArr,NUMINDS*NUMLOCI*LINES);*/
            /* if (DEBUGCOMPARE) { */
            /*     readBuffer(clDict,randomArr, */
            /*             sizeof(float) * NUMINDS*NUMLOCI*LINES,RANDCL, */
            /*             "randomArr"); */
            /*     compareZCLandZ(clDict,Z,Q,P,Geno,randomArr); */
            /* } */
            /* if (USEWORKINGCL) { */
                UpdateZCL (clDict,Z,  Q, P, Geno,randomArr);
                /* Not needed */
                /*readBuffer(clDict,Z,sizeof(int)*ZSIZE,ZCL,"Z");*/
            /* } else { */
            /*     readBuffer(clDict,randomArr, */
            /*             sizeof(float) * NUMINDS*NUMLOCI*LINES,RANDCL, */
            /*             "randomArr"); */
            /*     UpdateZ (Z,  Q, P, Geno,randomArr); */
            /* } */
            /*      printf("done updatez alpha[2]=%e\n", Alpha[2]); */
        }


        if (LOCPRIOR && NOADMIX==0) {
            UpdateAlphaLocPrior(Q, Alpha, LocPrior, Individual);
        } else if (INFERALPHA) {

            UpdateAlphaCL (clDict,Q, Alpha, Individual, rep,POPFLAGINDS);

            /* readBuffer(clDict,Q, sizeof(float) * QSIZE,QCL, "Q"); */
            /* readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha"); */

            /* UpdateAlpha(Q, Alpha, Individual, rep); */

            /* writeBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha"); */
        }

        if (INFERLAMBDA) {
            readBuffer(clDict,P,sizeof(float) * PSIZE,PCL,"P");
            if  (POPSPECIFICLAMBDA) {
                UpdatePopLambda(P,lambda,NumAlleles);
            } else {
                UpdateLambda (P,Epsilon,lambda, NumAlleles);
            }
            writeBuffer(clDict,lambda,sizeof(float) * MAXPOPS,LAMBDACL,"LAMBDA");
        }

        if (FREQSCORR) {
            UpdateEpsilonCL(clDict,P,Epsilon,Fst,NumAlleles,lambda[0]);

            UpdateFstCL (clDict,Epsilon, Fst, P, NumAlleles);

            /* readBuffer(clDict,P, sizeof(float) * PSIZE,PCL, "P"); */
            /* readBuffer(clDict,Fst,sizeof(float) * MAXPOPS,FSTCL,"FST"); */
            /* readBuffer(clDict,Epsilon,sizeof(float) * NUMLOCI*MAXALLELES,EPSILONCL,"eps"); */

            /* UpdateEpsilon(P,Epsilon,Fst,NumAlleles,lambda[0]); */

            /* UpdateFst (Epsilon, Fst, P, NumAlleles); */

            /* writeBuffer(clDict,Epsilon,sizeof(float) * NUMLOCI*MAXALLELES,EPSILONCL,"eps"); */
            /* writeBuffer(clDict,Fst,sizeof(float) * MAXPOPS,FSTCL,"FST"); */
        }

        /*====book-keeping stuff======================*/
        if (rep + 1 > BURNIN) {
            /*buffers[0] = PCL;
            names[0] = "P"; dests[0] = P; sizes[0] = sizeof(float) * PSIZE;
            buffers[1] = QCL;
            names[1] = "Q"; dests[1] = Q; sizes[1] = sizeof(float) * QSIZE;

            readBuffers(clDict,dests,sizes,buffers,names,2);*/
            /*readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha");
            if(rep % 100 == 0){
            printf("%f",Alpha[0]);
            }*/
            DataCollectionCL (clDict,Geno, PreGeno, Q, QSum, Z, Z1,  P, PSum,
                            Fst, FstSum, NumAlleles,
                            AncestDist, Alpha, sumAlpha, sumR, varR, like,
                            sumlikes, sumsqlikes, R, Epsilon,SumEpsilon,recomblikelihood,
                            lambda, sumlambda, Recessive, LocPrior, sumLocPrior, LocPriorLen, sumIndLikes,
                            indLikesNorm, rep);
        }


        if ((savefreq) && ((rep + 1) > BURNIN)
                && (((rep + 1 - BURNIN) % savefreq) == 0)
                && ((rep + 1) != NUMREPS + BURNIN)) {
            /* readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha"); */
            readBuffer(clDict,Fst, sizeof(float) * MAXPOPS,FSTCL, "fst");
            readBuffer(clDict,sumAlpha, sizeof(float) * MAXPOPS,ALPHASUMCL, "alphasum");
            readBuffer(clDict,sumlambda, sizeof(float) * MAXPOPS,LAMBDASUMCL, "lambdasum");
            readBuffer(clDict,FstSum, sizeof(float) * MAXPOPS,FSTSUMCL, "fstsum");
            readBuffer(clDict,QSum, sizeof(float) * QSIZE,QSUMCL, "Qsum");
            readBuffer(clDict,PSum, sizeof(float) * PSIZE,PSUMCL, "Psum");
            readBuffer(clDict,SumEpsilon, sizeof(float) * NUMLOCI*MAXALLELES,EPSILONSUMCL, "epssum");
            readBuffer(clDict,like, sizeof(float),LIKECL, "like");
            readBuffer(clDict,sumlikes, sizeof(float),SUMLIKESCL, "sumlike");
            readBuffer(clDict,sumsqlikes, sizeof(float),SUMSQLIKESCL, "sumsqlikes");
            OutPutResults (Geno, rep + 1, savefreq, Individual, PSum, QSum,
                           FstSum, AncestDist, UsePopProbs, *sumlikes,
                           *sumsqlikes, sumAlpha, sumR, varR,
                           NumAlleles, Translation, 0, Markername, R,
                           SumEpsilon,
                           lambda,sumlambda,sumLocPrior, LocPriorLen,
                           sumIndLikes, indLikesNorm, argc,argv);
        }


        if (PRINTLIKES) {
            readBuffer(clDict,like, sizeof(float),LIKECL, "like");
            PrintLike (*like, rep, Geno, PreGeno, Q, P,recomblikelihood);
        }

        if (((rep + 1) % UPDATEFREQ) == 0) {
            readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha");
            readBuffer(clDict,Fst, sizeof(float) * MAXPOPS,FSTCL, "fst");
            readBuffer(clDict,like, sizeof(float),LIKECL, "like");
            readBuffer(clDict,sumlikes, sizeof(float),SUMLIKESCL, "sumlike");
            readBuffer(clDict,sumsqlikes, sizeof(float),SUMSQLIKESCL, "sumsqlikes");
            /*readBuffer(clDict,sumAlpha, sizeof(float) * MAXPOPS,ALPHASUMCL, "alphasum");
            readBuffer(clDict,sumlambda, sizeof(float) * MAXPOPS,LAMBDASUMCL, "lambdasum");
            readBuffer(clDict,FstSum, sizeof(float) * MAXPOPS,FSTSUMCL, "fstsum");
            readBuffer(clDict,QSum, sizeof(float) * QSIZE,QSUMCL, "Qsum");
            readBuffer(clDict,PSum, sizeof(float) * PSIZE,PSUMCL, "Psum");
            readBuffer(clDict,SumEpsilon, sizeof(float) * NUMLOCI*MAXALLELES,EPSILONSUMCL, "epssum");*/
            PrintUpdate (rep + 1, Geno, PreGeno, Alpha, Fst, P, Q, *like,
                         *sumlikes, *sumsqlikes, NumAlleles, R, lambda,Individual,
                         recomblikelihood, Recessive, LocPrior, LocPriorLen);
        }
        finishWaitList(clDict);
    }

    /*====final book-keeping====================================*/
    if ((rep % UPDATEFREQ) != 0) {
        readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha");
        readBuffer(clDict,Fst, sizeof(float) * MAXPOPS,FSTCL, "fst");
        readBuffer(clDict,like, sizeof(float),LIKECL, "like");
        readBuffer(clDict,sumsqlikes, sizeof(float),SUMSQLIKESCL, "sumsqlikes");
            readBuffer(clDict,sumlikes, sizeof(float),SUMLIKESCL, "sumlikes");
        /*readBuffer(clDict,sumAlpha, sizeof(float) * MAXPOPS,ALPHASUMCL, "alphasum");
        readBuffer(clDict,sumlambda, sizeof(float) * MAXPOPS,LAMBDASUMCL, "lambdasum");
        readBuffer(clDict,FstSum, sizeof(float) * MAXPOPS,FSTSUMCL, "fstsum");
        readBuffer(clDict,QSum, sizeof(float) * QSIZE,QSUMCL, "Qsum");
        readBuffer(clDict,PSum, sizeof(float) * PSIZE,PSUMCL, "Psum");
        readBuffer(clDict,SumEpsilon, sizeof(float) * NUMLOCI*MAXALLELES,EPSILONSUMCL, "epssum");*/
        PrintUpdate (rep, Geno, PreGeno, Alpha, Fst, P, Q, *like, *sumlikes,
                     *sumsqlikes, NumAlleles,R, lambda, Individual,recomblikelihood,
                     Recessive, LocPrior, LocPriorLen);
    }


    readBuffer(clDict,Alpha, sizeof(float) * MAXPOPS,ALPHACL, "alpha");
    readBuffer(clDict,Fst, sizeof(float) * MAXPOPS,FSTCL, "fst");
    readBuffer(clDict,sumAlpha, sizeof(float) * MAXPOPS,ALPHASUMCL, "alphasum");
    readBuffer(clDict,sumlambda, sizeof(float) * MAXPOPS,LAMBDASUMCL, "lambdasum");
    readBuffer(clDict,FstSum, sizeof(float) * MAXPOPS,FSTSUMCL, "fstsum");
    readBuffer(clDict,QSum, sizeof(float) * QSIZE,QSUMCL, "Qsum");
    readBuffer(clDict,PSum, sizeof(float) * PSIZE,PSUMCL, "Psum");
    readBuffer(clDict,SumEpsilon, sizeof(float) * NUMLOCI*MAXALLELES,EPSILONSUMCL, "epssum");
    readBuffer(clDict,like, sizeof(float),LIKECL, "like");
    readBuffer(clDict,sumsqlikes, sizeof(float),SUMSQLIKESCL, "sumsqlikes");
    readBuffer(clDict,sumlikes, sizeof(float),SUMLIKESCL, "sumlikes");
    OutPutResults (Geno, rep, savefreq, Individual, PSum, QSum,
                   FstSum, AncestDist, UsePopProbs,
                   *sumlikes, *sumsqlikes,
                   sumAlpha, sumR, varR, NumAlleles, Translation, 1,
                   Markername, R, SumEpsilon,
                   lambda,sumlambda,sumLocPrior, LocPriorLen,
                   sumIndLikes, indLikesNorm,
                   argc,argv);

    /*=====Closing everything down==============================*/
    FreeAll(Mapdistance, Phase, Phasemodel, lambda, sumlambda, Markername, Geno,
            PreGeno, Recessive,
            Individual, Translation, NumAlleles, Z, Z1, Q, P, R, sumR, varR, Epsilon,
            SumEpsilon,
            Fst, FstSum, NumLociPop, PSum, QSum,  AncestDist, UsePopProbs, LocPrior,
            sumLocPrior, Alpha, sumAlpha, sumIndLikes, indLikesNorm, clDict);
    free(randomArr);
    free(randGens);
    free(like);
    free(sumsqlikes);
    free(sumlikes);
    free(reduceresult);
    printf("Structure seed: %d\n", SEED);
    return (0);
}