Esempio n. 1
0
std::vector<std::string> ConfigFile::getArray(std::string strAttribute, std::vector<std::string> listDefaults)
{
    std::map<std::string, ConfigAttribute>::iterator p;
    
    //Find the uppercase string in the map
    std::string lstr = Uppercase(strAttribute);
    p = m_mapConfig.find(lstr);
    
    if (p != m_mapConfig.end() && p->second.bIsArray)
    {
        return p->second.listValues;
    }
    else
    {
        std::cout << "Variable " << strAttribute.c_str() << " does not exist in config file or is not an array." <<  std::endl;
        
        //Store the default value in the config file
        if(m_bAddDefaultsToConfig && listDefaults.size() > 0)
        {
            setArray(strAttribute, listDefaults);
        }

        return listDefaults;
    }
}
Esempio n. 2
0
File: enum.c Progetto: jaykrell/j
BOOL
CALLBACK
EnumNamesProc(
    HMODULE Module,
    PCWSTR Type,
    PWSTR Name,
    LONG Param
    )
{
    if (!EnumResourceLanguagesW(Module, Uppercase(Type), Uppercase(Name), EnumLangProc, 0))
    {
        DWORD Error = GetLastError();
        wprintf(L"EnumResourceLanguages failed %x\n", Error);
    }
    return TRUE;
}
Esempio n. 3
0
void ConfigFile::setString(std::string strAttribute, std::string strValue)
{
    ConfigAttribute element;
    element.strAttribute = strAttribute;
    element.strValue = strValue;
    m_mapConfig[Uppercase(strAttribute)] = element;
    bIsModified = true;
}
Esempio n. 4
0
LPTSTR lstrfind( LPTSTR pszStr, LPTSTR pszSearchStr )
/************************************************************************/
{
    LPTSTR psz, pszSearch, pszStart = NULL;
    WORD wChar, wCharSearch;

    if( !( psz = Uppercase( pszStr )))
	    return( NULL );

    if( !( pszSearch = Uppercase( pszSearchStr )))
	    return( NULL );

    while( *psz )
    {
        if( IsDBCSLeadByte(( BYTE )*psz ))
            wChar = *(( LPWORD )psz );
        else
            wChar = *psz;

        if( IsDBCSLeadByte(( BYTE )*pszSearch ))
    	    wCharSearch = *(( LPWORD )pszSearch );
        else
    	    wCharSearch = *pszSearch;

	    if( wChar == wCharSearch ) 	// If a character match...
	    { 
		    pszSearch = MyCharNext( pszSearch );
		    if( !pszStart )
			    pszStart = psz;
	    }
	    else                		// If not a character match...
        {
		    pszSearch = pszSearchStr;
		    pszStart = NULL;
	    }

	    if( !( *pszSearch )) 		// If at the end of the search string...
		    break;

        psz = MyCharNext( psz );
    }
    return( pszStart );
}
Esempio n. 5
0
bool ConfigFile::getBool(std::string strAttribute, bool bDefault)
{
    std::string strReturn;
    std::string strDefault;
    std::ostringstream strStream;
    
    strStream << bDefault;
    strDefault = strStream.str();
    
    strReturn = getString(strAttribute, strDefault);
    if(strReturn == "1" || Uppercase(strReturn) == "TRUE")
    {
        return true;
    }
    return false;
}
Esempio n. 6
0
File: enum.c Progetto: jaykrell/j
BOOL
CALLBACK
EnumTypesProc(
    HMODULE Module,
    PWSTR Type,
    LONG Param
    )
{
    if (!EnumResourceNamesW(Module, Type = Uppercase(Type), EnumNamesProc, 0))
    {
        WCHAR Buffer[20];
        DWORD Error = GetLastError();
        wprintf(L"EnumResourceNames(%p, %x %ls) failed %x\n", Module, Type, IdToString(Type, Buffer, NUMBER_OF(Buffer)), Error);
    }
    return TRUE;
}
Esempio n. 7
0
void ConfigFile::setArray(std::string strAttribute, std::vector<std::string> listValues)
{
    //Put the string in the map
    setString(strAttribute, "Array()");

    //Get the ConfigAttribute out of the map
    std::map<std::string, ConfigAttribute>::iterator p;
    
    //Find the uppercase string in the map
    std::string lstr = Uppercase(strAttribute);
    p = m_mapConfig.find(lstr);
    
    if (p != m_mapConfig.end())
    {
        p->second.bIsArray = true;
        p->second.listValues = listValues;
    }
    
}
Esempio n. 8
0
std::string ConfigFile::getString(std::string strAttribute, std::string strDefault)
{
    std::map<std::string, ConfigAttribute>::iterator p;
    
    //Find the uppercase string in the map
    std::string lstr = Uppercase(strAttribute);
    p = m_mapConfig.find(lstr);
    
    if (p != m_mapConfig.end())
    {
        return p->second.strValue;
    }
    else
    {
        std::cout << "Variable " << strAttribute.c_str() << " does not exist in config file." <<  std::endl;

        //Store the default value in the config file
        if(m_bAddDefaultsToConfig)
        {
            setString(strAttribute, strDefault);
        }
        return strDefault;
    }
 }
long ReadLandMarkFile (char filename[], Land_Mark *onelandmark, 
		       long reportlevel)
{
/*** 

  Read in a set of points that define landmarks.  These are not just
  coronaries, but can also be occlusions, stimulus needles or other
  goodies.

 Input:
 	filename    name of the coronary artery file to open.
	surfnum	    current surface number
	onelandmark pointer to the land mark structure for this surface
         
 Return:
        error       =1 for successful reading of an old format coronary file.
	    	    =2 for success with a new format file.
	    	    otherwise, error of some sort.
 ***/

    long i, j_start, pnum, firstpnum;
    long error, ncorpts, nnewcorpts, segnum, segnumval;
    long pntnum;
    double distance, dist_threshold=0;
    char instring[80], lmstring[20], *instring_p, *atoken_p;
    char newfilename[100];
    char sepchars[] = " ,\n";
    FILE *luin_p;
/***********************************************************************/

    if( reportlevel )
	fprintf(stderr,"In ReadLMarkFile\n ");

    error = 2;

 /* First, open the file. */
    
    if ((luin_p = fopen(filename, "r")) == NULL) 
    {
	strcpy( newfilename, filename );
	StripExtension( newfilename );
	strcat( newfilename, ".lmarks");
	if ((luin_p = fopen(newfilename, "r")) == NULL) 
	{
	    fprintf(stderr, "In readlmarkfile.c: error opening landmark file\n"
		    " Could not open either %s or %s \n", 
		    filename, newfilename);
	    return ERR_FILE;
	}
    }
    
 /*** Now, read in the contents of the file. ***/

 /*** First line: the number of landmark segments to read ***/

    if ( ReadLine( instring, luin_p ) == NULL )
    {
	fprintf(stderr,"**** Readlmarkfile Error: end of file hit "
		" at start of file"
		" ***\n");
	return -5;
    }
	
    if (sscanf(instring, "%i", &onelandmark->numsegs) != 1) 
    {
	fprintf(stderr,"*** In readlmarkfile.c: error in first "
		"line of read ***\n");
	error = -10;
	return error;
    }

 /*** Set up the memory to hold the segments of the landmark  ***/

    if (( onelandmark->segs = (LandMarkSeg *)
	 calloc( (size_t) onelandmark->numsegs, sizeof(LandMarkSeg) )) 
	== NULL)
    {
	printf("*** ReadLandMarkfile: error getting memory\n");
	return( ERR_MEM );
    }

 /*** Now the loop that reads all the Landmarks. ***/
    
    for( segnum=0; segnum < onelandmark->numsegs; segnum++ )
    {
      long optional[4] = {-1, -1, -1, -1};
      int optionalIndex = 0;
	if ( reportlevel > 2 )
	    printf(" segnum = %d resetting npts to 0\n", segnum);
	onelandmark->segs[segnum].segnum = segnum;
	
	npts = 0;
	if( ReadLine( instring, luin_p ) == NULL )
	{
	    fprintf(stderr,"+++ (readlmarkfile.c)\n"
		    "+++ End of file hit before expected\n"
		    "+++ Will take the %d landmarks we have already\n",
		    segnum);
	    onelandmark->numsegs = segnum;
	    return error;
	}

 /*** Read through the line token by token and permit some flexibility
      of the contents of this line, allowing the segnumval and setstring
      parameters to be optional. ***/

	instring_p = instring;
	atoken_p = strtok( instring_p, sepchars );
	i = strtol( atoken_p, NULL, 10 );
	strcpy(lmstring, strtok( NULL, sepchars ) );
	if ( lmstring == NULL )
	{
	    ReportError( "ReadLMarkFile", "reading landmark type string",
			 ERR_FILE, instring);
	    return( ERR_FILE );
	}
	if ( ( atoken_p = strtok( NULL, sepchars ) ) == NULL )
	{
	    ReportError( "ReadLMarkFile", "reading number of landmark points",
			 ERR_FILE, instring);
	    return( ERR_FILE );
	}
	ncorpts = strtol( atoken_p, NULL, 10 );
        // allow for either segnumval, a color triple, or both
        while ( (atoken_p = strtok( NULL, sepchars)) != NULL && 
		optionalIndex < 4) {
	    optional[optionalIndex] = (short) strtol( atoken_p, NULL, 10 );
            optionalIndex++;
        }

        if (optionalIndex == 1 || optionalIndex == 4)
          segnumval = optional[0];
        else
          segnumval = -1;

        {
          int c;
          for (c = 0; c < 3; c++) {
            onelandmark->segs[segnum].color[c] =
          (short) optional[c + (optionalIndex != 3?1:0)];
          }
        }
	
 /*
	if (sscanf(instring, "%d %s %d %d %s", &i, instring, &ncorpts) != 3) 
	{
	    fprintf(stderr,"*** In readlmarkfile.c: error reading number of"
		    " points and landmark type in coronary #%d ***\n", 
		    segnum+1);
	    fprintf(stderr,"*** Each landmark must be preceeded by a line"
		    " that tells the segment number,"
		    " the type of landmark it is\n"
		    " and number of points\n");
	    error = -10;
	    return error;
	}
 */
	if ( i != segnum+1 )
	    fprintf(stderr,"+++ (readlmarkfile.c): the file says this is"
		    " segment %d\n"
		    "+++ But I have it as number %d\n", i, segnum+1);

	onelandmark->segs[segnum].numpts = ncorpts;
	onelandmark->segs[segnum].segnumval = segnumval;
	
 /*** Now some pointer gymnastics to get rid of leading blanks
      and terminate the string properly, and convert it to uppercase.***/

	/*	lmstring_p = &instring[0];
	lmstring_p += strspn( lmstring_p, " ");
	len = strcspn( lmstring_p, "\n#" );
	*(lmstring_p+len) = '\0';
	strncpy( lmstring, lmstring_p, (size_t) len+1);
	*/
	Uppercase( lmstring );

 /*** Now see if the string matches the legal values. ***/
	    
	if( strncmp( lmstring, "CORONAR", 6 ) == 0 ||
	    strncmp( lmstring, "ARTER", 5) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_COR;
	}
	else if ( strncmp( lmstring, "OCCLUS", 3 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_OCCLUS;
	}
	else if ( strncmp( lmstring, "STITCH", 5 ) == 0  ||
		  strncmp( lmstring, "CLOS", 4 ) == 0 ) 
	{
	    onelandmark->segs[segnum].type = LM_STITCH;
	}
	else if ( strncmp( lmstring, "STIM", 3 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_STIM;
	}
	else if ( strncmp( lmstring, "LEAD", 4 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_LEAD;
	}
	else if ( strncmp( lmstring, "PLANE", 5 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_PLANE;
	}
	else if ( strncmp( lmstring, "ROD", 3 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_ROD;
	}
	else if ( strncmp( lmstring, "PACENEEDLE", 6 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_PACENEEDLE;
	}
	else if ( strncmp( lmstring, "CATH", 4 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_CATH;
	}
	else if ( strncmp( lmstring, "FIBER", 4 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_FIBER;
	}
	else if ( strncmp( lmstring, "RECNEEDLE", 6 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_RECNEEDLE;
	}
	else if ( strncmp( lmstring, "CANNULA", 6 ) == 0 )
	{
	    onelandmark->segs[segnum].type = LM_CANNULA;
	} else 
	{
	    printf("** ReadLMarkfile:  With landmark string: %s\n"
		   "**      we cannot set the type\n", lmstring);
	    onelandmark->segs[segnum].type = -1;
	}
	
 /*** Set aside some memory for the coronary points. ***/

	if( reportlevel > 2 )
	    fprintf(stderr," Allocating space for points "
		    "in landmarks\n"
		    " We want space for %d points\n",
		    ncorpts );

	if( ( onelandmark->segs[segnum].pts = Alloc_fmatrix( ncorpts, 3 )
	      ) == NULL )
	{
	    printf("*** ReadLandmarkFile: error getting memory for %d pts\n",
		   ncorpts);
	    return (ERR_MEM);
	}
	if( ( onelandmark->segs[segnum].rad = (float *)
	     calloc((size_t) ncorpts, sizeof(float) ) ) == NULL )
	{
	    fprintf(stderr,"*** Readlmarkfile, error allocating memory\n"
		    " for rads");
	    return (ERR_MEM);
	}
        if ( (onelandmark->segs[segnum].labels = Alloc_cmatrix( ncorpts, 40)
              ) == NULL )
	{
	    printf("*** ReadLandmarkFile: error getting memory for labels\n");
	    return (ERR_MEM);
	}
	
	
 /*** Check the first line of the points and see if we have a new
	  or old coronary file format. ***/
	
	if ( segnum == 0 )
	{
	    if( ReadLine( instring, luin_p ) == NULL )
	    {
		fprintf(stderr,"*** (readlmarkfile.c)\n"
			"*** End of file hit while reading landmark %d\n",
			segnum+1);
		return( ERR_FILE );
	    }
	    if (sscanf( instring, "%f %f %f %f %39s", 
		       &onelandmark->segs[segnum].pts[npts][CUTIL_X], 
		       &onelandmark->segs[segnum].pts[npts][CUTIL_Y],
		       &onelandmark->segs[segnum].pts[npts][CUTIL_Z], 
		       &onelandmark->segs[segnum].rad[npts],
                       onelandmark->segs[segnum].labels[npts]) >= 4)
	    {
		if (reportlevel > 2) 
		    fprintf(stderr," Landmark file seems to be in "
			    "proper format\n");
	    }
	    else if (sscanf( instring, "%f %f", 
			    &onelandmark->segs[segnum].pts[npts][CUTIL_X],
			    &onelandmark->segs[segnum].pts[npts][CUTIL_Y]) == 2)
	    {
		printf(" This is old format Coronary file\n"
		       " Redo the file !!!\n");
		onelandmark->numsegs = 0;
		return( ERR_FILE );
	    } else
	    {
		fprintf(stderr,"*** Error in Readlmarkfile since file does not"
			" fit a known format ***\n");
		fprintf(stderr," Line reads %s", instring);
		fprintf(stderr," So problems here\n");
		return(-1);
	    }
	    j_start = 1;
	    npts++;
	} else
	    j_start = 0;

 /*** Now get on with reading the file. ***/

	firstpnum = npts;
	nnewcorpts = ncorpts;

	for( pntnum=j_start; pntnum<ncorpts; pntnum++ )
	{
	    if( ReadLine( instring, luin_p ) == NULL )
	    {
		fprintf(stderr,"**** (readlmarkfile.c)\n"
			"**** End of file hit while reading landmark %d\n"
			"**** and point %d\n", segnum+1, pntnum+1);
		return( ERR_FILE );
	    }
	    if (sscanf( instring, "%f %f %f %f %39s", 
		       &onelandmark->segs[segnum].pts[npts][CUTIL_X], 
		       &onelandmark->segs[segnum].pts[npts][CUTIL_Y],
		       &onelandmark->segs[segnum].pts[npts][CUTIL_Z], 
		       &onelandmark->segs[segnum].rad[npts],
                       onelandmark->segs[segnum].labels[npts])
		< 4)
	    {
		fprintf(stderr,"*** In readlmarkfile: error reading points"
			" at coronary #%d and point #%d ***\n",
			segnum+1, pntnum+1);
		fprintf(stderr,"*** instring reads %s", instring);
		error = -20;
		return (error);
	    }
	    if ( pntnum == j_start )
		dist_threshold = ( onelandmark->segs[segnum].pts[npts][CUTIL_X] *
				   onelandmark->segs[segnum].pts[npts][CUTIL_X] +
				   onelandmark->segs[segnum].pts[npts][CUTIL_Y] *
				   onelandmark->segs[segnum].pts[npts][CUTIL_Y] +
				   onelandmark->segs[segnum].pts[npts][CUTIL_Z] *
				   onelandmark->segs[segnum].pts[npts][CUTIL_Z] ) /
		10.E8;
	    npts++;
	    
 /*** Check for doubles. ***/

	    for (pnum=firstpnum; pnum<npts-1; pnum++)
	    {
		if ( ( distance =
		      VECMAG3((onelandmark->segs[segnum].pts[pnum][CUTIL_X] - 
			       onelandmark->segs[segnum].pts[npts-1][CUTIL_X] ),
			      (onelandmark->segs[segnum].pts[pnum][CUTIL_Y] - 
			       onelandmark->segs[segnum].pts[npts-1][CUTIL_Y] ),
			      (onelandmark->segs[segnum].pts[pnum][CUTIL_Z] - 
			       onelandmark->segs[segnum].pts[npts-1][CUTIL_Z] ) ) )
		    < dist_threshold ) {
		    fprintf(stderr,"+++ ReadLmarkfile in segment %d"
			    ": You have doubled"
			    " points dude!\n"
			    " Point %d has a double"
			    " %f, %f, %f \n"
			    " And distance between them is %f\n",
			    segnum+1, pntnum+1, 
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_X],
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_Y],
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_Z],
			    distance);
		    npts--;
		    nnewcorpts--;
		}
	    }
	    if ( reportlevel > 3 )
	    {
		if ( npts < 50 )
		{
		    fprintf(stderr," Line %d reads %s\n"
			    " and returns %f %f %f and %f\n",
			    npts, instring, 
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_X],
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_Y],
			    onelandmark->segs[segnum].pts[npts-1][CUTIL_Z],
			    onelandmark->segs[segnum].rad[npts-1]);
		}
	    }
	}
	if ( nnewcorpts != ncorpts ) {
	    onelandmark->segs[segnum].numpts = nnewcorpts;
	}

	if ( reportlevel > 3 )
	{
	    fprintf(stderr," Coronary points and radii from segment %d\n",
		    segnum);
	    for( i=0; i < onelandmark->segs[segnum].numpts; i++ )
	    {
		fprintf(stderr," %d %f %f %f %f \n",
			i, 
			onelandmark->segs[segnum].pts[i][CUTIL_X], 
			onelandmark->segs[segnum].pts[i][CUTIL_Y],
			onelandmark->segs[segnum].pts[i][CUTIL_Z], 
			onelandmark->segs[segnum].rad[i]);
	    }
	}
    }
    
    fclose(luin_p);
    
    return (error);
}
// get the next element in source, returns true no error, bEof will be set to true if eof is hit
bool Elementizer::GetNext(bool& bEof)
{
    // update back data
    m_backOffsets[m_backIndex&0x03] = m_sourceOffset;
    m_backFlags[m_backIndex&0x03] = m_sourceFlags;
    m_backIndex++;

    // default to type_undefined
    m_type = 0;
    m_value = 0;
    m_value_2 = 0;
    m_asm = -1;
    m_opType = -1;
    m_pSymbolEntry = 0;

    // no error, and not end of file
    int error = error_none;
    bEof = false;
    bool bDocComment = false;
    int constantBase = 0;

    // setup source and symbol pointers
    char* pSource = m_pCompilerData->source;
    int sourceStart = m_sourceOffset;

    m_currentSymbol[0] = 0;
    int symbolOffset = 0;

    while(1)
    {
        char currentChar = pSource[m_sourceOffset++];

        // parse
        if (constantBase > 0)
        {
            // this handles reading in a constant of base 2, 4, 10, or 16
            // the constantBase value is set based on prefix characters handled below

            if (currentChar == '_')
            {
                // skip over _'s
                continue;
            }
            char digitValue;
            if (!CheckDigit(currentChar, digitValue, (char)constantBase))
            {
                char notUsed;
                char nextChar = pSource[m_sourceOffset];
                bool bNextCharDigit = CheckDigit(nextChar, notUsed, (char)constantBase);

                if ((constantBase == 10 &&
                    (currentChar == '.' && bNextCharDigit)) ||
                    currentChar == 'e' || currentChar == 'E')
                {
                    // handle float
                    m_sourceOffset = sourceStart;
                    if (GetFloat(pSource, m_sourceOffset, m_value))
                    {
                        m_sourceOffset--; // back up to point at last digit
                        m_type = type_con_float;
                    }
                    else
                    {
                        error = error_fpcmbw;
                    }
                }
                else
                {
                    // done with this constant
                    m_sourceOffset--; // back up to point at last digit
                    m_type = type_con;
                }
                constantBase = 0;
                break;
            }
            else
            {
                // multiply accumulate the constant
                m_value *= constantBase;
                m_value += digitValue;
            }
            continue;
        }
        else if (m_sourceFlags != 0)
        {
            // old string? (continue parsing a string)

            // for strings, m_sourceFlags will start out 0, and then cycle between 1 and 2 for
            // each character of the string, when it is 1, a type_comma is returned, when it is
            // 2 the next character is returned

            // return a comma element between each character of the string
            if (m_sourceFlags == 1)
            {
                m_sourceFlags++;
                m_sourceOffset--;
                m_type = type_comma;
                break;
            }

            // reset flag
            m_sourceFlags = 0;

            // check for errors
            if (currentChar == '\"')
            {
                error = error_es;
                break;
            }
            else if (currentChar == 0)
            {
                m_sourceOffset--; // back up from eof
                error = error_eatq;
                break;
            }
            else if (currentChar == 13)
            {
                error = error_eatq;
                break;
            }

            // return the character
            m_value = currentChar;

            // check the next character, if it's not a " then setup so the next
            // call returns a type_comma, if it is a ", then we are done with this string
            // and we leave the offset pointing after the "
            currentChar = pSource[m_sourceOffset++];
            if (currentChar != '\"')
            {
                m_sourceOffset--;
                m_sourceFlags++;
            }

            // return the character constant
            m_type = type_con;
            break;
        }
        else if (currentChar == '\"')
        {
            // new string (start parsing a string)

            // we got here because m_sourceFlags was 0 and the character is a "

            // get first character of string
            currentChar = pSource[m_sourceOffset++];

            // check for errors
            if (currentChar == '\"')
            {
                error = error_es;
                break;
            }
            else if (currentChar == 0)
            {
                m_sourceOffset--; // back up from eof
                error = error_eatq;
                break;
            }
            else if (currentChar == 13)
            {
                error = error_eatq;
                break;
            }

            // return the character in value
            m_value = currentChar & 0x000000FF;

            // check the next character, it's it's not a " then setup so the next
            // call returns a type_comma, if it is a " then it means it's a one character
            // string and we leave the offset pointing after the "
            currentChar = pSource[m_sourceOffset++];
            if (currentChar != '\"')
            {
                m_sourceOffset--; // back up, so this character will be read after the type_comma
                m_sourceFlags = 1; // cause the next call to return a type_comma
            }

            // return the character constant
            m_type = type_con;
            break;
        }
        else if (currentChar == 0)
        {
            // eof
            m_type = type_end;
            bEof = true;
            m_sourceOffset--;
            sourceStart = m_sourceOffset;
            break;
        }
        else if (currentChar == 13)
        {
            // eol
            m_type = type_end;
            break;
        }
        else if (currentChar <= ' ')
        {
            // space or tab?
            sourceStart = m_sourceOffset;
            continue;
        }
        else if (currentChar == '\'')
        {
            // comment
            // read until end of line or file, handle doc comment
            if (pSource[m_sourceOffset] == '\'')
            {
                m_sourceOffset++; // skip over second '
                bDocComment = true;
                g_pCompilerData->doc_flag = true;
            }
            while(1)
            {
                currentChar = pSource[m_sourceOffset++];
                if (currentChar == 0)
                {
                    m_sourceOffset--; // back up from eof
                    m_type = type_end;
                    bEof = true;
                    break;
                }
                if (bDocComment)
                {
                    DocPrint(currentChar);
                }
                if (currentChar == 13)
                {
                    m_type = type_end;
                    break;
                }
            }
            break;
        }
        else if (currentChar == '{')
        {
            // brace comment
            // read the whole comment, handling doc comments as needed
            int braceCommentLevel = 1;
            if (pSource[m_sourceOffset] == '{')
            {
                m_sourceOffset++; // skip over second {
                bDocComment = true;
                g_pCompilerData->doc_flag = true;
                if (pSource[m_sourceOffset] == 13)
                {
                    m_sourceOffset++; // skip over end if present
                }
            }
            while(1)
            {
                currentChar = pSource[m_sourceOffset++];
                if (currentChar == 0)
                {
                    if (bDocComment)
                    {
                        error = error_erbb;
                    }
                    else
                    {
                        error = error_erb;
                    }
                    m_sourceOffset--; // back up from eof
                    sourceStart = m_sourceOffset;
                    break;
                }
                else if (!bDocComment && currentChar == '{')
                {
                    braceCommentLevel++;
                }
                else if (currentChar == '}')
                {
                    if (bDocComment && pSource[m_sourceOffset] == '}')
                    {
                        m_sourceOffset++; // skip over second }
                        break;
                    }
                    else if (!bDocComment)
                    {
                        braceCommentLevel--;
                        if (braceCommentLevel < 1)
                        {
                            break;
                        }
                    }
                }
                else if (bDocComment)
                {
                    DocPrint(currentChar);
                }
            }
            if (error == error_none)
            {
                sourceStart = m_sourceOffset;
                continue;
            }
            else
            {
                break;
            }
        }
        else if (currentChar == '}')
        {
            // unmatched brace comment end
            error = error_bmbpbb;
            break;
        }
        else if (currentChar == '%')
        {
            // binary
            currentChar = pSource[m_sourceOffset++];
            char temp;
            if (currentChar == '%')
            {
                // double binary
                currentChar = pSource[m_sourceOffset++];
                if (!CheckDigit(currentChar, temp, 4))
                {
                    error = error_idbn;
                    break;
                }
                constantBase = 4;
            }
            else
            {
                if (!CheckDigit(currentChar, temp, 2))
                {
                    error = error_idbn;
                    break;
                }
                constantBase = 2;
            }
            m_sourceOffset--; // back up to first digit
            // constantBase is now set, so loop back around to read in the constant
            continue;
        }
        else if (currentChar == '$')
        {
            // hex
            currentChar = pSource[m_sourceOffset++];
            char temp;
            if (!CheckDigit(currentChar, temp, 16))
            {
                m_sourceOffset--;
                m_type = type_asm_org;
                break;
            }
            constantBase = 16;
            m_sourceOffset--; // back up to first digit
            // constantBase is now set, so loop back around to read in the constant
            continue;
        }
        else if (currentChar >= '0' && currentChar <= '9')
        {
            // dec
            constantBase = 10;
            m_sourceOffset--; // back up to first digit
            // constantBase is now set, so loop back around to read in the constant
            continue;
        }
        else
        {
            // symbol
            currentChar = Uppercase(currentChar);
            if (CheckWordChar(currentChar))
            {
                // do word symbol
                while(CheckWordChar(currentChar) && symbolOffset <= symbol_limit)
                {
                    m_currentSymbol[symbolOffset++] = currentChar;
                    currentChar = Uppercase(pSource[m_sourceOffset++]);
                }
                if (symbolOffset > symbol_limit)
                {
                    error = error_sexc;
                }
                else
                {
                    // back up so we point at last char of symbol
                    m_sourceOffset--;
                    // terminate symbol
                    m_currentSymbol[symbolOffset] = 0;
                    m_pSymbolEntry = m_pSymbolEngine->FindSymbol(m_currentSymbol);
                }
            }
            else
            {
                // try non-word symbol (one or two char operators)
                m_currentSymbol[symbolOffset++] = currentChar;
                currentChar = pSource[m_sourceOffset++];

                bool bDoOneChar = false;
                bool bDoTwoChar = false;

                // if the next char is not whitespace or eol
                if (currentChar > ' ')
                {
                    // three char symbol

                    // assign second char into symbol
                    m_currentSymbol[symbolOffset++] = currentChar;

                    // read third char into symbol
                    m_currentSymbol[symbolOffset++] = pSource[m_sourceOffset++];

                    // terminate symbol
                    m_currentSymbol[symbolOffset] = 0;

                    m_pSymbolEntry = m_pSymbolEngine->FindSymbol(m_currentSymbol);
                    if (m_pSymbolEntry == 0)
                    {
                        bDoTwoChar = true;
                        symbolOffset--;
                    }
                }

                if (bDoTwoChar)
                {
                    // two char symbol

                    // back up so we point at last char of symbol
                    m_sourceOffset--;

                    // terminate symbol
                    m_currentSymbol[symbolOffset] = 0;

                    m_pSymbolEntry = m_pSymbolEngine->FindSymbol(m_currentSymbol);
                    if (m_pSymbolEntry == 0)
                    {
                        bDoOneChar = true;
                        symbolOffset--;
                    }
                }

                if (bDoOneChar || currentChar <= ' ')
                {
                    // one char symbol

                    // back up so we point at last char of symbol
                    m_sourceOffset--;

                    // terminate symbol
                    m_currentSymbol[symbolOffset] = 0;

                    m_pSymbolEntry = m_pSymbolEngine->FindSymbol(m_currentSymbol);
                    if (m_pSymbolEntry == 0)
                    {
                        error = error_uc;
                    }
                }
            }
            break;
        }
    }

    // update pointers
    m_pCompilerData->source_start = sourceStart;
    m_pCompilerData->source_finish = m_sourceOffset;

    // if we got a symbol, then set the type, value, etc.
    if (m_type == 0 && m_pSymbolEntry)
    {
        SetFromSymbolEntry();
    }

    if (error != error_none)
    {
        m_pCompilerData->error = true;
        m_pCompilerData->error_msg = g_pErrorStrings[error];
        return false;
    }

    return true;
}
Esempio n. 11
0
bool strieql(const std::string s1, const std::string s2)
{
	std::string cs1 = s1, cs2 = s2;
	Uppercase(cs1); Uppercase(cs2);
	return (cs1 == cs2);
}
Esempio n. 12
0
bool ConfigFile::ImportXML(std::string strXML)
{
    TiXmlDocument doc;
    
    //Load document from strXML using streams
    std::istringstream strIStream;
    strIStream.str(strXML);
    strIStream >> doc;
    
    if ( doc.NoChildren() )
	{
		std::cout << "Could not parse xml string. Error='" << doc.ErrorDesc() << "'. Using Default Data"  << std::endl;
        m_strLastError = doc.ErrorDesc();
        //Use already loaded defaults
		return false;
	}

    TiXmlNode* parent = 0;
    TiXmlNode* child = 0;
    TiXmlNode* tempChild = 0;
	TiXmlElement* configElement = 0;
	TiXmlElement* itemElement = 0;
    TiXmlElement* tempElement = 0;

	// Get the "configData" element.
    parent = doc.FirstChild( m_strIdentifier.c_str() );
	assert( parent  );
	configElement =parent->ToElement();
	assert( configElement  );	

	//Read all the configuration data
    for( child = configElement->FirstChild(); child; child = child->NextSibling() )
    {
        itemElement = child->ToElement();
	    assert( itemElement  );
        
        //convert to uppercase
        std::string strElement = itemElement->Value();

        //replace underscore with whitespace
        std::replace(strElement.begin(), strElement.end(), '_', ' ');

        ConfigAttribute element;
        element.strAttribute = strElement;
        element.strValue = itemElement->Attribute( "value");
        
        //Read the sub items from the file and store as an array
        if(!itemElement->NoChildren() || element.strValue == "Array()")
        {
            element.bIsArray = true;

            for( tempChild = itemElement->FirstChild(); tempChild; tempChild = tempChild->NextSibling() )
            {
                tempElement = tempChild->ToElement();
                assert( tempElement  );

                element.listValues.push_back(tempElement->Attribute( "value"));
            }

        }
        m_mapConfig[Uppercase(strElement)] = element;
    }

    return true;

    return true;
}
Esempio n. 13
0
/**
* Fill the Option fields, with the argc array
*/
int Read_Command_Line(option *io, int argc, char **argv)
{
  int c;
  int idx;
  int i;
  int writemode;

  PhyML_Printf("\n. command-line: ");
  For(i,argc) PhyML_Printf("%s ",argv[i]);


  if(argc == 1) Exit("\n. No argument was passed to the program. Please check the documentation. \n");

  struct option longopts[] =
    {
      {"n_rgrft",           required_argument,NULL,0},
      {"n_globl",           required_argument,NULL,1},
      {"max_dist",          required_argument,NULL,2},
      {"n_optim",           required_argument,NULL,3},
      {"n_best",            required_argument,NULL,4},
      {"model",             required_argument,NULL,5},
      {"search",            required_argument,NULL,6},
      {"datatype",          required_argument,NULL,7},
      {"multiple",          required_argument,NULL,8},
      {"input",             required_argument,NULL,9},
      {"bootstrap",         required_argument,NULL,10},
      {"ts/tv",             required_argument,NULL,11},
      {"nclasses",          required_argument,NULL,12},
      {"pinv",              required_argument,NULL,13},
      {"alpha",             required_argument,NULL,14},
      {"inputtree",         required_argument,NULL,15},
      {"min_diff_lk_local", required_argument,NULL,16},
      {"min_diff_lk_global",required_argument,NULL,17},
      {"steph_spr",         no_argument,NULL,18},
      {"brent_it_max",      required_argument,NULL,19},
      {"rand_start",        no_argument,NULL,20},
      {"n_rand_starts",     required_argument,NULL,21},
      {"sequential",        no_argument,NULL,22},
      {"inside_opt",        no_argument,NULL,23},
      {"p_moves",           required_argument,NULL,24},
      {"fast_nni",          no_argument,NULL,25},
      {"g_pars",            no_argument,NULL,26},
      {"r_seed",            required_argument,NULL,27},
      {"collapse_boot",     required_argument,NULL,28},
      {"random_boot",       required_argument,NULL,29},
      {"print_trace",       no_argument,NULL,30},
      {"print_site_lnl",    no_argument,NULL,31},
      {"print_site_lk",    no_argument,NULL,31},
      {"cov",               no_argument,NULL,32},
      {"cov_delta",         required_argument,NULL,33},
      {"cov_alpha",         required_argument,NULL,34},
      {"cov_ncats",         required_argument,NULL,35},
      {"ps",                no_argument,NULL,36},
      {"cov_free",          no_argument,NULL,37},
      {"no_gap",            no_argument,NULL,38},
      {"n_rr_branch",       required_argument,NULL,39},
      {"append",            no_argument,NULL,40},
      {"no_five_branch",    no_argument,NULL,41},
      {"pars_thresh",       required_argument,NULL,42},
      {"min_diff_lk_move",  required_argument,NULL,43},
      {"hybrid",            no_argument,NULL,44},
      {"use_median",        no_argument,NULL,45},
      {"run_id",            required_argument,NULL,46},
      {"pars",              no_argument,NULL,47},
      {"quiet",             no_argument,NULL,48},
      {"version",           no_argument,NULL,49},
      {"calibration_file",    required_argument,NULL,50},
      {"calibration",         required_argument,NULL,50},
      {"clade_file",          required_argument,NULL,50},
      {"boot_progress_every", required_argument,NULL,51},
      {"aa_rate_file",        required_argument,NULL,52},
      {"chain_len",           required_argument,NULL,53},
      {"sample_freq",         required_argument,NULL,54},
      {"burnin",              required_argument,NULL,55},
      {"no_memory_check",     no_argument,NULL,56},
      {"no_colalias",         no_argument,NULL,57},
      {"alias_subpatt",       no_argument,NULL,58},      
      {"no_sequences",        no_argument,NULL,59},      
      {"prior",               no_argument,NULL,59},      
      {"fastlk",              no_argument,NULL,60},      
      {"free_rates",          no_argument,NULL,61},
      {"freerates",           no_argument,NULL,61},
      {"freerate",            no_argument,NULL,61},
      {"free_rate",            no_argument,NULL,61},
      {"is",                  no_argument,NULL,62},
      // no 63 since it corresponds to character '?' 
      {"rate_model",          required_argument,NULL,64},
      {"ratemodel",           required_argument,NULL,64},
      {"log_l",               no_argument,NULL,65},
      {"gamma_lens",          no_argument,NULL,66},
      {"il",                  no_argument,NULL,66},
      {"codpos",              required_argument,NULL,67},
      {"constraint_file",     required_argument,NULL,68},
      {"constraint_tree",     required_argument,NULL,68},
      {"help",                no_argument,NULL,69},
      {"mutmap",              no_argument,NULL,70},
      {"parvals",             required_argument,NULL,71},
      {"constrained_lens",    no_argument,NULL,72},
      {"xml",                 required_argument,NULL,73},
      {"l_var",               required_argument,NULL,74},
#ifdef BEAGLE
      {"beagle_resource",     required_argument,NULL,75},
#endif
      {"ancestral",           no_argument,NULL,76},
      {"anc",                 no_argument,NULL,76},
      {"coord_file",          required_argument,NULL,77},
      {0,0,0,0}
    };

  io->datatype = UNDEFINED;

  #ifndef PHYML
  int open_ps_file = 0;
  #endif

  idx=-1;

    do
    {     
      c = getopt_long(argc,argv,"qi:d:m:b:n:t:f:zk:v:c:a:u:ho:s:x:g:l:ep",longopts,&idx);

      switch(c)
	{

        case 77:
          {
	    char *tmp;
	    tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));

	    if(strlen(optarg) > T_MAX_FILE -11)
	      {
		char choix;
		strcpy (tmp, "\n. The file name'");
		strcat (tmp, optarg);
		strcat (tmp, "' is too long.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else if (!Filexists (optarg))
	      {
		char choix;
		strcpy (tmp, "\n. The file '");
		strcat (tmp, optarg);
		strcat (tmp, "' doesn't exist.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
                strcpy(io->in_coord_file, optarg);
                io->fp_in_coord = Openfile(io->in_coord_file,READ);
	      }
	    Free(tmp);
            break;
          }

	case 76:
          {
            io->ancestral = YES;
            break;
          }
#ifdef BEAGLE
	case 75:
          {
            io->beagle_resource = (int)atoi(optarg);
            break;
          }
#endif
	case 74:
          {
            io->mod->l_var_sigma = String_To_Dbl(optarg);
            break;
          }
	case 73:
	  {
#ifdef INVITEE
            Free_Optimiz(io->mod->s_opt);
            M4_Free_M4_Model(io->mod->m4mod);
            Free_Model_Basic(io->mod);
            Free_Input(io);
            PhyTime_XML(optarg);
            return 0;

#elif defined(PHYML)

            Free_Optimiz(io->mod->s_opt);
            M4_Free_M4_Model(io->mod->m4mod);
            Free_Model_Basic(io->mod);
            Free_Input(io);
            PhyML_XML(optarg);
            return 0;

#elif defined(DATE)

            Free_Optimiz(io->mod->s_opt);
            M4_Free_M4_Model(io->mod->m4mod);
            Free_Model_Basic(io->mod);
            Free_Input(io);
            DATE_XML(optarg);
            return 0;
#endif
            break;
	  }
	case 72:
	  {
	    io->mod->s_opt->constrained_br_len = YES;
	    break;
	  }
	case 71:
	  {
	    io->mcmc->in_fp_par = fopen(optarg,"r");
	    io->mcmc->randomize = NO;
	    break;
	  }
	case 70:
	  {
	    io->mutmap = YES;
	    break;
	  }
	case 68:
	  {
	    char *tmp;
	    tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));

	    if(strlen(optarg) > T_MAX_FILE -11)
	      {
		char choix;
		strcpy (tmp, "\n. The file name'");
		strcat (tmp, optarg);
		strcat (tmp, "' is too long.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else if (!Filexists (optarg))
	      {
		char choix;
		strcpy (tmp, "\n. The file '");
		strcat (tmp, optarg);
		strcat (tmp, "' doesn't exist.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		strcpy(io->in_constraint_tree_file, optarg);
		io->fp_in_constraint_tree = Openfile(io->in_constraint_tree_file,0);
	      }
	    Free(tmp);
	    break;
	  }
	case 67:
	  {
	    phydbl pos;
	    pos = atof(optarg);
	    io->codpos = (int)pos;
	    if(io->codpos < 1 || io->codpos > 3)
	      {
		char choix;
		PhyML_Printf("\n. Coding position must be set to 1, 2 or 3.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	    
	    break;
	  }
	case 66:
	  {
	    io->mod->gamma_mgf_bl = YES;
	    io->mod->s_opt->opt_gamma_br_len = YES;
	    break;
	  }
	case 65:
	  {
	    io->mod->log_l = YES;
	    break;
	  }
	case 64:
	  {
	    char *s;
	    int i;
	    s = (char *)mCalloc(T_MAX_NAME,sizeof(char));
	    i = 0;
	    while(optarg[i++]) s[i]=tolower(optarg[i]);
	    if(!strcmp(optarg,"gbd")) io->rates->model               = THORNE;
	    else if(!strcmp(optarg,"gbs")) io->rates->model          = GUINDON;
	    else if(!strcmp(optarg,"gamma")) io->rates->model        = GAMMA;
	    else if(!strcmp(optarg,"clock")) io->rates->model        = STRICTCLOCK;
	    else if(!strcmp(optarg,"strictclock")) io->rates->model  = STRICTCLOCK;
	    else if(!strcmp(optarg,"strict_clock")) io->rates->model = STRICTCLOCK;
	    else 
	      {
		PhyML_Printf("\n. rate_model should be 'gbs', 'gbd', 'gamma' or 'clock'.");
		Exit("\n");
	      }
	    Free(s);
	    break;
	  }
	
	
	case 62:
	  {
	    io->mcmc->is = YES;
	    break;
	  }
	case 61:
	  {
	    io->mod->ras->free_mixt_rates            = YES;
	    io->mod->s_opt->opt_free_mixt_rates = YES;
	    break;
	  }
	case 60:
	  {
	    io->lk_approx = NORMAL;		
	    break;
	  }
	case 59:
	  {
	    io->mcmc->use_data = NO;
	    break;
	  }
	case 58:
	  {
	    io->do_alias_subpatt = YES;
	    break;
	  }
	case 57:
	  {	    
	    io->colalias = NO;
	    break;
	  }
	case 56:
	  {
	    io->mem_question = NO;
	    break;
	  }
	case 55:
	  {
	    phydbl len;
	    len = atof(optarg);
	    io->mcmc->chain_len_burnin = (int)len;
	    if(io->mcmc->chain_len_burnin < 1)
	      {
		char choix;
		PhyML_Printf("\n. chain_len_burnin must be an integer greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }	  
	case 54:
	  {
	    phydbl len;
	    len = atof(optarg);
	    io->mcmc->sample_interval = (int)len;
	    if(io->mcmc->sample_interval < 1)
	      {
		char choix;
		PhyML_Printf("\n. sample_interval must be an integer greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }	  
	case 53:
	  {
	    phydbl len;
	    len = atof(optarg);
	    io->mcmc->chain_len = (int)len;
	    if(io->mcmc->chain_len < 1)
	      {
		char choix;
		PhyML_Printf("\n. chain_len must be an integer greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }	  
	case 52:
	  {
	    char *s;
	    s = (char *)mCalloc(T_MAX_FILE, sizeof(char));
	    strcpy(s,optarg);
	    io->mod->fp_aa_rate_mat = Openfile(s,0);
	    strcpy(io->mod->aa_rate_mat_file->s,s);
	    Free(s);
	    break;
	  }
	case 51:
	  {
	    io->boot_prog_every = atoi(optarg);
	    if(io->boot_prog_every < 1)
	      {
		char choix;
		PhyML_Printf("\n. boot_progress_every must be an integer greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }
	case 50:
	  {
	    strcpy(io->clade_list_file,optarg);
	    break;
	  }
	case 49:
	  {
	    PhyML_Printf("\n. This is PhyML version %s.\n\n",VERSION);
	    Exit("");
	    break;
	  }	  
	case 48 : 
	  {
	    io->quiet = 1;
	    break;
	  }
	case 'p' : case 47 : 
	  {
	    io->in_tree = 1;
	    break;
	  }
	case 46 : 
	  {
	    io->append_run_ID = YES;
	    strcpy(io->run_id_string,optarg);
	    break;
	  }
	case 45 : 
	  {
	    io->mod->ras->gamma_median = 1;
	    break;
	  }
	case 44 :
	  {
	    io->mod->s_opt->hybrid_thresh = 0;
	    break;
	  }
	case 43 :
	  {
	    io->mod->s_opt->min_diff_lk_move = atof(optarg);
	    if(io->mod->s_opt->min_diff_lk_move < 0)
	      {
		char choix;
		PhyML_Printf("\n. Min_diff_lk_move must be a double greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }
	case 42 :
	  {
	    io->mod->s_opt->pars_thresh = (int)atoi(optarg);
	    if(io->mod->s_opt->pars_thresh < 0)
	      {
		PhyML_Printf("\n. The parsimony threshold must be an integer greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		Exit("\n");
	      }
	    break;
	  }
	case 41 :
	  {
	    io->mod->s_opt->opt_five_branch = 0;
	    break;
	  }
	case 40 :
	  {
	    writemode = 2;
	    break;
	  }
	case 39 :
	  {
	    break;
	  }
	case 38 :
	  {
	    io->rm_ambigu = 1;
	    break;
	  }
	case 37 :
	  {
	    io->mod->s_opt->opt_cov_free_rates = YES;
	    io->mod->m4mod->use_cov_alpha      = NO;
	    io->mod->m4mod->use_cov_free       = YES;
	    break;
	  }
	case 36 :
	  {
	    #ifndef PHYML
            open_ps_file = 1;
            #endif
	    break;
	  }
	case 35 :
	  {
	    io->mod->m4mod->n_h = (int)atoi(optarg);
	    
	    if(io->mod->m4mod->n_h < 1)
	      {
		char choix;
		PhyML_Printf("\n. The number of classes must be greater than 0.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }
	case 34 :
	  {
	    io->mod->m4mod->use_cov_alpha = YES;
	    io->mod->m4mod->use_cov_free  = NO;
	    
	    if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
	       !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
	      {
		io->mod->s_opt->opt_cov_alpha = YES;
		io->mod->m4mod->alpha         = 1.0;
	      }
	    else
	      {
		io->mod->m4mod->alpha = (phydbl)atof(optarg);
		
		if(io->mod->m4mod->alpha < 1.E-5)
		  {
		    char choix;
		    PhyML_Printf("\n. The value of alpha must be greater than 1.E-5.\n");
		    PhyML_Printf("\n. Type any key to exit.\n");
		    if(!scanf("%c",&choix)) Exit("\n");
		    Exit("\n");
		  }
	      }
	    break;
	  }
	case 33 :
	  {
	    if(!strcmp(optarg,"e") || !strcmp(optarg,"E") ||
	       !strcmp(optarg,"estimated") || !strcmp(optarg,"ESTIMATED"))
	      {
		io->mod->s_opt->opt_cov_delta = YES;
		io->mod->m4mod->delta         = 1.0;
	      }
	    else
	      {
		io->mod->m4mod->delta = (phydbl)atof(optarg);
		
		if(atof(optarg) < 1.E-10)
		  {
		    char choix;
		    PhyML_Printf("\n. The value of delta must be larger than 1.E-10.\n");
		    PhyML_Printf("\n. Type any key to exit.\n");
		    if(!scanf("%c",&choix)) Exit("\n");
		    Exit("\n");
		  }
	      }
	    break;
	  }
	case 32 :
	  {
	    io->mod->use_m4mod = YES;
	    break;
	  }
	case 31 :
	  {
	    io->print_site_lnl = YES;
	    break;
	  }
	case 30 :
	  {
	    io->print_trace = YES;
	    break;
	  }
	case 29 :
	  {
	    io->random_boot_seq_order = (int)atoi(optarg);
	    break;
	  }
	case 28 :
	  {
	    io->collapse_boot = (int)atoi(optarg);
	    break;
	  }
	case 27 :
	  {
	    io->r_seed = (int)atoi(optarg);
	    break;
	  }
	case 26 :
	  {
	    io->mod->s_opt->general_pars = YES;
	    break;
	  }
	case 25 :
	  {
	    io->mod->s_opt->fast_nni = YES;
	    break;
	  }
	case 24 :
	  {
	    io->mod->s_opt->p_moves_to_examine = (phydbl)atof(optarg);
	    break;
	  }
	case 23 :
	  {
	    io->mod->s_opt->wim_inside_opt = 1;
	    break;
	  }
	case 0 :
	  {
	    io->mod->s_opt->wim_n_rgrft = atoi(optarg);
	    break;
	  }
	case 1 :
	  {
	    io->mod->s_opt->wim_n_globl = atoi(optarg);
	    break;
	  }
	case 2 :
	  {
	    io->mod->s_opt->wim_max_dist = atoi(optarg);
	    break;
	  }
	case 3 :
	  {
	    io->mod->s_opt->wim_n_optim = atoi(optarg);
	    break;
	  }
	case 4 :
	  {
	    io->mod->s_opt->wim_n_best = atoi(optarg);
	    break;
	  }
	case 16 :
	  {
	    io->mod->s_opt->min_diff_lk_local = atof(optarg);
	    break;
	  }
	case 17 :
	  {
	    io->mod->s_opt->min_diff_lk_global = atof(optarg);
	    break;
	  }
	case 18 :
	  {
	    io->mod->s_opt->steph_spr = 0;
	    io->mod->s_opt->greedy    = 1;
	    break;
	  }
	case 19 :
	  {
	    io->mod->s_opt->brent_it_max = atoi(optarg);
	    break;
	  }
	case 20 :
	  {
	    io->mod->s_opt->random_input_tree = 1;
	    break;
	  }
	case 21 :
	  {
	    io->mod->s_opt->random_input_tree = 1;
	    io->mod->s_opt->n_rand_starts = atoi(optarg);
	    if(io->mod->s_opt->n_rand_starts < 1) Exit("\n== Number of random starting trees must be > 0.\n\n");
	  }
	case 's':case 6:
	  {
	    if((!strcmp(optarg,"spr")) || (!strcmp(optarg,"SPR")))
	      {
		io->mod->s_opt->topo_search = SPR_MOVE;
		io->mod->s_opt->greedy      = (io->mod->s_opt->steph_spr)?(0):(1);
	      }
	    else if((!strcmp(optarg,"nni")) || (!strcmp(optarg,"NNI")))
	      {
		io->mod->s_opt->topo_search         = NNI_MOVE;
		io->mod->s_opt->random_input_tree   = 0;
	      }
	    else if((!strcmp(optarg,"best")) || (!strcmp(optarg,"BEST")))
	      {
		io->mod->s_opt->topo_search = BEST_OF_NNI_AND_SPR;
		io->mod->s_opt->greedy      = (io->mod->s_opt->steph_spr)?(0):(1);
	      }
	    break;
	  }
	  
	case 'd':case 7:
	  {
	    if(!strcmp(optarg,"nt"))
	      {
		io->datatype        = NT;
		io->mod->ns         = 4;
		io->mod->m4mod->n_o = 4;
		
		if((io->mod->whichmodel == LG)        ||
		   (io->mod->whichmodel == WAG)       ||
		   (io->mod->whichmodel == DAYHOFF)   ||
		   (io->mod->whichmodel == JTT)       ||
		   (io->mod->whichmodel == BLOSUM62)  ||
		   (io->mod->whichmodel == MTREV)     ||
		   (io->mod->whichmodel == RTREV)     ||
		   (io->mod->whichmodel == CPREV)     ||
		   (io->mod->whichmodel == DCMUT)     ||
		   (io->mod->whichmodel == VT)        ||
		   (io->mod->whichmodel == MTMAM)     ||
		   (io->mod->whichmodel == MTART)     ||
		   (io->mod->whichmodel == HIVW)      ||
		   (io->mod->whichmodel == HIVB)      ||
		   (io->mod->whichmodel == AB)        ||
		   (io->mod->whichmodel == CUSTOMAA)
		   )
		  {
		    io->mod->whichmodel = HKY85;
		    strcpy(io->mod->modelname->s, "HKY85\0");
		  }
	      }
	    else if (!strcmp(optarg,"aa"))
	      {
		io->datatype              = AA;
		io->mod->s_opt->opt_kappa = NO;
		io->mod->ns               = 20;
		io->mod->m4mod->n_o       = 20;

		if(
		   (io->mod->whichmodel == JC69)   ||
		   (io->mod->whichmodel == K80)    ||
		   (io->mod->whichmodel == F81)    ||
		   (io->mod->whichmodel == HKY85)  ||
		   (io->mod->whichmodel == F84)    ||
		   (io->mod->whichmodel == TN93)   ||
		   (io->mod->whichmodel == GTR)    ||
		   (io->mod->whichmodel == CUSTOM)
		   )
		  {
		    io->mod->whichmodel = LG;
		    strcpy(io->mod->modelname->s, "LG\0");
		  }
	      }
	    else if ((!strcmp(optarg,"generic")) || (!strcmp(optarg,"gen")))
	      {
		io->datatype = GENERIC;
	      }
	    else
	      {
		char choix;
		PhyML_Printf("\n. Unknown argument to -d option: please use `nt' for DNA or `aa' for Amino-Acids\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    
	    break;
	  }
	case 'm': case 5 :
	  {
	    int i;
	    
	    For(i,strlen(optarg)) Uppercase(optarg+i);
	    
	    if(!isalpha(optarg[0]))
	      {
		strcpy(io->mod->custom_mod_string->s,optarg);
		
		if(strlen(io->mod->custom_mod_string->s) != 6)
		  {
		    Warn_And_Exit("\n. The string should be of length 6.\n");
		  }
		else
		  {
		    /* Make_Custom_Model(io->mod); */
		    /* Translate_Custom_Mod_String(io->mod); */
		  }
		
		io->datatype              = NT;
		io->mod->whichmodel       = CUSTOM;
		strcpy(io->mod->modelname->s, "custom");
		io->mod->s_opt->opt_kappa = NO;
		io->mod->s_opt->opt_rr    = YES;
	      }
	    
	    else if (strcmp(optarg, "JC69") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = JC69;
	      }
	    else if(strcmp(optarg, "K80") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = K80;
	      }
	    else if(strcmp(optarg, "F81") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = F81;
	      }
	    else if (strcmp(optarg, "HKY85") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = HKY85;
	      }
	    else if(strcmp(optarg, "F84") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = F84;
	      }
	    else if (strcmp (optarg,"TN93") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = TN93;
	      }
	    else if(strcmp (optarg, "GTR") == 0)
	      {
		io->datatype              = NT;
		io->mod->whichmodel       = GTR;
	      }
	    else if(strcmp(optarg, "DAYHOFF") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = DAYHOFF;
	      }
	    else if(strcmp (optarg, "JTT") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = JTT;
	      }
	    else if(strcmp(optarg, "MTREV") == 0)
	      {
		io->datatype             = AA;
		io->mod->whichmodel      = MTREV;
	      }
	    else if(strcmp (optarg, "LG") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = LG;
	      }
	    else if(strcmp (optarg, "WAG") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = WAG;
	      }
	    else if(strcmp(optarg, "DCMUT") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = DCMUT;
	      }
	    else if(strcmp (optarg, "RTREV") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = RTREV;
	      }
	    else if(strcmp(optarg, "CPREV") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = CPREV;
	      }
	    else if(strcmp(optarg, "VT") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = VT;
	      }
	    else if(strcmp(optarg, "BLOSUM62") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = BLOSUM62;
	      }
	    else if(strcmp(optarg, "MTMAM") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = MTMAM;
	      }
	    else if (strcmp(optarg,"MTART") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = MTART;
	      }
	    else if (strcmp(optarg,"HIVW") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = HIVW;
	      }
	    else if(strcmp(optarg, "HIVB") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = HIVB;
	      }
	    else if(strcmp(optarg, "AB") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = AB;
	      }
	    else if (strcmp(optarg, "CUSTOM") == 0)
	      {
		io->datatype              = AA;
		io->mod->whichmodel       = CUSTOMAA;
	      }
	    else
	      {
		PhyML_Printf("\n. The model name is incorrect. Please see the documentation.\n");
		Exit("\n");
	      }

	    Set_Model_Name(io->mod);
	    
	    break;
	  }
	  
	case 'a':case 14 :
	  {
	    if ((strcmp (optarg, "e") == 0) ||
		(strcmp (optarg, "E") == 0) ||
		(strcmp (optarg, "estimated") == 0) ||
		(strcmp (optarg, "ESTIMATED") == 0))
	      {
		io->mod->s_opt->opt_alpha = YES;
	      }
	    else if (atof(optarg) < 1.E-10)
	      {
		char choix;
		PhyML_Printf("\n. Alpha must be > 1.E-10.\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		io->mod->ras->alpha->v = (phydbl)atof(optarg);
		io->mod->s_opt->opt_alpha  = 0;
	      }
	    break;
	  }
	case 'b':case 10:
	  {
	    if ((int)String_To_Dbl(optarg) < -5)
	      {
		char choix;
		PhyML_Printf("\n. Branch test value must be a positive integer for bootstrap, or between -1 and -4 for aLRT branch test\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		if((int)String_To_Dbl(optarg) > 0)
		  {
		    io->ratio_test       = 0;
		    io->mod->bootstrap   = (int)atoi(optarg);
		    io->print_boot_trees = 1;
		    
		    if(io->n_data_sets > 1)
		      {
			char choix;
			PhyML_Printf("\n. Bootstrap option is not allowed with multiple data sets\n");
			PhyML_Printf("\n. Type any key to exit.\n");
			if(!scanf("%c",&choix)) Exit("\n");
			Exit("\n");
		      }
		  }
		else if (atoi(optarg)==0)
		  {
		    io->mod->bootstrap = 0;
		    io->ratio_test     = 0;
		  }
		else
		  {
		    io->mod->bootstrap = 0;
		    io->ratio_test     = -(int)atoi(optarg);
		  }
	      }
	    break;
	  }
	case 'c':case 12:
	  {
	    if ((!atoi(optarg)) || (atoi(optarg) < 0))
	      {
		char choix;
		PhyML_Printf("\n. Unknown argument to -c option: the number of rate categories must be a positive integer\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");		  
		Exit("\n");
	      }
	    else 
	      {
		io->mod->ras->n_catg = atoi(optarg);
		if(io->mod->ras->n_catg < 1) 
		  {
		    PhyML_Printf("\n. The number of rate categories must be a positive integer\n");
		    Exit("\n");
		  }
	      }
	    break;
	  }
	case 'f':
	  {
	    if(!strcmp(optarg,"e"))
	      {
	        if(io->datatype == NT)
		  io->mod->s_opt->opt_state_freq = NO;
		else if (io->datatype == AA)
		  io->mod->s_opt->opt_state_freq = YES;
		else
		  {
		    PhyML_Printf("\n. Please define the data type (nt or aa) before setting the -f option\n");
		    Exit("\n");
		  }
	      }
	    else if(!strcmp(optarg,"m"))
	      {
	        if (io->datatype == NT)
		  io->mod->s_opt->opt_state_freq = YES;
		else if (io->datatype == AA)
		  io->mod->s_opt->opt_state_freq = NO;
		else
		  {
		    PhyML_Printf("\n. Please define the data type (nt or aa) before setting the -f option\n");
		    Exit("\n");
		  }
	      }
	    else if(!isalpha(optarg[0]))
	      {
		phydbl sum;
		double val1,val2,val3,val4;
		
		io->mod->s_opt->opt_state_freq  = 0;
		io->mod->s_opt->user_state_freq = 1;
		
		/* 		sscanf(optarg,"%lf,%lf,%lf,%lf", */
		/* 		       io->mod->user_b_freq, */
		/* 		       io->mod->user_b_freq+1, */
		/* 		       io->mod->user_b_freq+2, */
		/* 		       io->mod->user_b_freq+3); */
		sscanf(optarg,"%lf,%lf,%lf,%lf",&val1,&val2,&val3,&val4);
		io->mod->user_b_freq->v[0] = (phydbl)val1;
		io->mod->user_b_freq->v[1] = (phydbl)val2;
		io->mod->user_b_freq->v[2] = (phydbl)val3;
		io->mod->user_b_freq->v[3] = (phydbl)val4;
		
		sum =
		  (io->mod->user_b_freq->v[0] +
		   io->mod->user_b_freq->v[1] +
		   io->mod->user_b_freq->v[2] +
		   io->mod->user_b_freq->v[3]);
		
		io->mod->user_b_freq->v[0] /= sum;
		io->mod->user_b_freq->v[1] /= sum;
		io->mod->user_b_freq->v[2] /= sum;
		io->mod->user_b_freq->v[3] /= sum;
		
		
		if(io->mod->user_b_freq->v[0] < .0 ||
		   io->mod->user_b_freq->v[1] < .0 ||
		   io->mod->user_b_freq->v[2] < .0 ||
		   io->mod->user_b_freq->v[3] < .0 ||
		   io->mod->user_b_freq->v[0] > 1. ||
		   io->mod->user_b_freq->v[1] > 1. ||
		   io->mod->user_b_freq->v[2] > 1. ||
		   io->mod->user_b_freq->v[3] > 1.)
		  {
		    Warn_And_Exit("\n. Invalid base frequencies.\n");
		  }
	      }
	    break;
	  }
	  
	case 'h':case 69:
	  {
	    Usage();
	    break;
	  }
	  
	case 'i':case 9:
	  {
	    char *tmp;
	    tmp = (char *) mCalloc (T_MAX_FILE, sizeof(char));
	    if (strlen (optarg) > T_MAX_FILE -16)
	      {
		char choix;
		strcpy (tmp, "\n. The file name'");
		strcat (tmp, optarg);
		strcat (tmp, "' is too long.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    
	    else if (!Filexists (optarg))
	      {
		char choix;
		strcpy (tmp, "\n. The file '");
		strcat (tmp, optarg);
		strcat (tmp, "' does not exist.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		strcpy(io->in_align_file, optarg);
		io->fp_in_align = Openfile(io->in_align_file,0);
                
		strcpy(io->out_file, optarg);
		strcpy(io->out_tree_file,optarg);
#ifdef PHYML
		strcat(io->out_tree_file,"_phyml_tree");
#elif M4
		strcat(io->out_tree_file,"_m4_tree");
#elif PHYREX
		strcat(io->out_tree_file,"_phyrex_tree");
#endif
                
		strcpy(io->out_stats_file,optarg);
#ifdef PHYML
		strcat(io->out_stats_file,"_phyml_stats");
#elif M4
		strcat(io->out_stats_file,"_m4_stats");
#elif PHYREX
		strcat(io->out_stats_file,"_phyrex_stats");
#endif


#ifdef PHYREX
		strcpy(io->out_summary_file,optarg);
		strcat(io->out_summary_file,"_phyrex_summary");
#endif


	      }
	    Free (tmp);
	    break;
	  }
	  
	case 't':case 11:
	  {
	    if ((io->mod->whichmodel != JC69) &&
		(io->mod->whichmodel != F81)  &&
		(io->mod->whichmodel != GTR))
	      {
		if ((strcmp(optarg, "e") == 0) ||
		    (strcmp(optarg, "E") == 0) ||
		    (strcmp(optarg, "estimated") == 0) ||
		    (strcmp(optarg, "ESTIMATED") == 0))
		  {
		    io->mod->kappa->v              = 4.0;
		    io->mod->s_opt->opt_kappa      = YES;
		    if (io->mod->whichmodel == TN93)
		      io->mod->s_opt->opt_lambda   = YES;
		  }
		else
		  {
		    if (atof(optarg) < .0)
		      {
			char choix;
			PhyML_Printf("\n. The ts/tv ratio must be a positive number\n");
			PhyML_Printf("\n. Type any key to exit.\n");
			if(!scanf("%c",&choix)) Exit("\n");
			Exit("\n");
		      }
		    else
		      {
			io->mod->kappa->v = (phydbl)atof(optarg);
			io->mod->s_opt->opt_kappa  = 0;
			io->mod->s_opt->opt_lambda = 0;
		      }
		  }
	      }
	    break;
	  }
	case 'n':case 8:
	  {
	    if ((!atoi(optarg)) || (atoi(optarg) < 0))
	      {
		char choix;
		PhyML_Printf("\n. The number of alignments must be a positive integer\n");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else io->n_data_sets = atoi (optarg);
	    break;
	  }
	case 'q':case 22:
	  {
	    io->interleaved = NO;
	    break;
	  }
	case 'u':case 15:
	  {
	    char *tmp;
	    tmp = (char *)mCalloc(T_MAX_FILE, sizeof(char));
	    if(strlen(optarg) > T_MAX_FILE -11)
	      {
		char choix;
		strcpy (tmp, "\n. The file name'");
		strcat (tmp, optarg);
		strcat (tmp, "' is too long.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else if (! Filexists (optarg))
	      {
		char choix;
		strcpy (tmp, "\n. The file '");
		strcat (tmp, optarg);
		strcat (tmp, "' doesn't exist.\n");
		PhyML_Printf("%s",tmp);
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		strcpy(io->in_tree_file, optarg);
		io->in_tree = 2;
		io->fp_in_tree = Openfile(io->in_tree_file,READ);
	      }
	    Free(tmp);
	    break;
	  }
	  
	case 'v':case 13:
	  {
	    if ((strcmp (optarg, "e") == 0) ||
		(strcmp (optarg, "E") == 0) ||
		(strcmp (optarg, "estimated") == 0) ||
		(strcmp (optarg, "ESTIMATED") == 0)) 
	      {
		io->mod->s_opt->opt_pinvar = YES;
		io->mod->ras->invar        = YES;
	      }
	    
	    else if ((atof(optarg) < 0.0) || (atof(optarg) > 1.0))
	      {
		char choix;
		PhyML_Printf("\n. The proportion of invariable site must be a number between 0.0 and 1.0\n");
		PhyML_Printf("\n. Type any key to exit.");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    else
	      {
		io->mod->ras->pinvar->v = (phydbl)atof(optarg);
		if (io->mod->ras->pinvar->v > 0.0+SMALL)
		  io->mod->ras->invar = 1;
		else
		  io->mod->ras->invar = 0;
		io->mod->s_opt->opt_pinvar = 0;
	      }
	    break;
	  }
	case 'o':
	  {
	    if(!strcmp(optarg,"tlr"))
	      {
		io->mod->s_opt->opt_topo        = YES;
		io->mod->s_opt->opt_bl          = YES;
		io->mod->s_opt->opt_subst_param = YES;
	      }
	    else if(!strcmp(optarg,"tl"))
	      {
		io->mod->s_opt->opt_topo        = YES;
		io->mod->s_opt->opt_bl          = YES;
		io->mod->s_opt->opt_subst_param = NO;
	      }
	    else if(!strcmp(optarg,"t"))
	      {
		Warn_And_Exit("\n. You can't optimize the topology without adjusting branch length too...\n");
	      }
	    else if(!strcmp(optarg,"lr"))
	      {
		io->mod->s_opt->opt_topo        = NO;
		io->mod->s_opt->opt_bl          = YES;
		io->mod->s_opt->opt_subst_param = YES;
	      }
	    else if(!strcmp(optarg,"l"))
	      {
		io->mod->s_opt->opt_topo        = NO;
		io->mod->s_opt->opt_bl          = YES;
		io->mod->s_opt->opt_subst_param = NO;
	      }
	    else if(!strcmp(optarg,"r"))
	      {
		io->mod->s_opt->opt_topo        = NO;
		io->mod->s_opt->opt_bl          = NO;
		io->mod->s_opt->opt_subst_param = YES;
	      }
	    else if(!strcmp(optarg,"none") || !strcmp(optarg,"n"))
	      {
		io->mod->s_opt->opt_topo        = NO;
		io->mod->s_opt->opt_bl          = NO;
		io->mod->s_opt->opt_subst_param = NO;
	      }
	    else
	      {
		char choix;
		PhyML_Printf ("\n. The optimization parameter must be 'tlr' or 'tl' or 'lr' or 'l' or 'r' or ''.");
		PhyML_Printf("\n. Type any key to exit.\n");
		if(!scanf("%c",&choix)) Exit("\n");
		Exit("\n");
	      }
	    break;
	  }
	
	case '?':
	  {      
	    Exit("\n");
	    break;
	  }
	  
	case -1:
	  {      
	    break;
	  }

	default:
	  {
	    Usage();
	    break;
	  }
	}
    }while(c != -1);

  
  /*   if((io->mod->whichmodel == K80) || (io->mod->whichmodel == JC69)) */
  /*     { */
  /*       if(io->mod->s_opt->opt_state_freq) */
  /* 	{ */
  /* 	  char c; */
  /* 	  PhyML_Printf("\n. WARNING: nucleotide frequencies must be set to 1/4 with this model.\n"); */
  /* 	  PhyML_Printf("\n. Type the enter key to resume the analysis.\n"); */
  /* 	  scanf("%c",&c); */
  /* 	} */
  /*       io->mod->s_opt->opt_state_freq = 0; */
  /*     } */
  
  
  if(io->mod->s_opt->constrained_br_len == YES)
    {
      io->mod->s_opt->opt_topo = NO;
      /* io->mod->s_opt->opt_bl   = NO; */
    }

#ifndef PHYML
  if((open_ps_file) || (io->m4_model == YES))
    {
      strcpy(io->out_ps_file,io->in_align_file);
      strcat(io->out_ps_file, "_mc_tree.ps");
      io->fp_out_ps = Openfile(io->out_ps_file,WRITE);
    }
#endif 
  
  
  if(io->datatype == UNDEFINED) io->datatype = NT;


  if((io->mod->s_opt->n_rand_starts)           && 
     (io->mod->s_opt->topo_search == NNI_MOVE) && 
     (io->mod->s_opt->random_input_tree))
    {
      Warn_And_Exit("\n== The random starting tree option is only compatible with SPR based search options.\n"); 
    }
  
  if ((io->datatype == NT) && (io->mod->whichmodel > 10))
    {
      char choix;
      PhyML_Printf("\n== Err.: model incompatible with the data type. Please use JC69, K80, F81, HKY, F84, TN93 or GTR\n");
      PhyML_Printf("\n== Type any key to exit.\n");
      if(!scanf("%c",&choix)) Exit("\n");
      Warn_And_Exit("\n");
    }
  else if ((io->datatype == AA) && (io->mod->whichmodel < 11))
    {
      char choix;
      PhyML_Printf("\n== Err.: model incompatible with the data type. Please use LG, Dayhoff, JTT, MtREV, WAG, DCMut, RtREV, CpREV, VT, Blosum62, MtMam, MtArt, HIVw, HIVb or AB.\n");
      PhyML_Printf("\n== Type any key to exit.\n");
      if(!scanf("%c",&choix)) Exit("\n");
      Exit("\n");
    }
  

  

  if(io->mod->use_m4mod == NO)
    {
      io->mod->s_opt->opt_cov_delta      = 0;
      io->mod->s_opt->opt_cov_alpha      = 0;
      io->mod->s_opt->opt_cov_free_rates = 0;
    }
  
  if((io->mod->s_opt->opt_cov_free_rates) && (io->mod->s_opt->opt_cov_alpha))
    {
      io->mod->s_opt->opt_cov_free_rates = 1;
      io->mod->m4mod->use_cov_alpha      = 0;
      io->mod->m4mod->use_cov_free       = 1;
    }
  
  if(io->print_site_lnl)
    {
      strcpy(io->out_lk_file,io->in_align_file);
      strcat(io->out_lk_file, "_phyml_lk");
      if(io->append_run_ID) { strcat(io->out_lk_file,"_"); strcat(io->out_lk_file,io->run_id_string); }
      io->fp_out_lk = Openfile(io->out_lk_file,1);
    }
  
  if(io->print_trace)
    {
      strcpy(io->out_trace_file,io->in_align_file);
      strcat(io->out_trace_file,"_phyml_trace");
      if(io->append_run_ID) { strcat(io->out_trace_file,"_"); strcat(io->out_trace_file,io->run_id_string); }
      io->fp_out_trace = Openfile(io->out_trace_file,1);
    }
  
  if(io->mod->s_opt->random_input_tree)
    {
      strcpy(io->out_trees_file,io->in_align_file);
      strcat(io->out_trees_file,"_phyml_rand_trees");
      if(io->append_run_ID) { strcat(io->out_trees_file,"_"); strcat(io->out_trees_file,io->run_id_string); }
      io->fp_out_trees = Openfile(io->out_trees_file,1);
    }
  
  if((io->print_boot_trees) && (io->mod->bootstrap > 0))
    {
      strcpy(io->out_boot_tree_file,io->in_align_file);
      strcat(io->out_boot_tree_file,"_phyml_boot_trees");
      if(io->append_run_ID) { strcat(io->out_boot_tree_file,"_"); strcat(io->out_boot_tree_file,io->run_id_string); }
      io->fp_out_boot_tree = Openfile(io->out_boot_tree_file,1);
      
      strcpy(io->out_boot_stats_file,io->in_align_file);
      strcat(io->out_boot_stats_file,"_phyml_boot_stats");
      if(io->append_run_ID) { strcat(io->out_boot_stats_file,"_"); strcat(io->out_boot_stats_file,io->run_id_string); }
      io->fp_out_boot_stats = Openfile(io->out_boot_stats_file,1);
    }
  
  if(io->append_run_ID)
    {
      strcat(io->out_tree_file,"_");
      strcat(io->out_stats_file,"_");
      strcat(io->out_tree_file,io->run_id_string);
      strcat(io->out_stats_file,io->run_id_string);
    }
  
  if(io->mod->ras->n_catg == 1) io->mod->s_opt->opt_alpha = 0;
  
  if(!io->mod->s_opt->opt_subst_param)
    {
      io->mod->s_opt->opt_alpha  = 0;
      io->mod->s_opt->opt_kappa  = 0;
      io->mod->s_opt->opt_lambda = 0;
      io->mod->s_opt->opt_pinvar = 0;
      io->mod->s_opt->opt_rr     = 0;	
    }
  
  if(io->mod->whichmodel != K80 && 
     io->mod->whichmodel != HKY85 && 
     io->mod->whichmodel != F84 &&
     io->mod->whichmodel != TN93)
    {
      io->mod->s_opt->opt_kappa = 0;
    }
  
  if(io->datatype == AA && io->mod->whichmodel == CUSTOMAA && !io->mod->fp_aa_rate_mat)
    {
      PhyML_Printf("\n== Custom model option with amino-acid requires you to specify a rate matrix file through the '--aa_rate_file' option.\n");
      Exit("\n");
    }
  
#if !defined(PHYTIME) 
  // Make sure you don't erase the input file...
  if(!strcmp(io->out_tree_file,io->in_align_file) ||
     !strcmp(io->out_stats_file,io->in_align_file)) Generic_Exit(__FILE__,__LINE__,__FUNCTION__);    

  writemode = WRITE;

  io->fp_out_tree  = Openfile(io->out_tree_file,writemode);
  io->fp_out_stats = Openfile(io->out_stats_file,writemode);
#endif
  

#if defined(PHYREX)
  io->fp_out_summary = Openfile(io->out_summary_file,writemode);
#endif

  writemode++; // just to silence a warning message at compilation
  
  if(io->mod->whichmodel == GTR) 
    {
      /* Make_Custom_Model(io->mod); */
      io->mod->s_opt->opt_rr = 1;
    }
  

  return 1;
}