folly::Optional<ModuleConfig> ModuleRegistry::getConfig(const std::string& name) {
  SystraceSection s("getConfig", "module", name);

  // Initialize modulesByName_
  if (modulesByName_.empty() && !modules_.empty()) {
    moduleNames();
  }

  auto it = modulesByName_.find(name);
  if (it == modulesByName_.end()) {
    return nullptr;
  }

  CHECK(it->second < modules_.size());
  NativeModule* module = modules_[it->second].get();

  // string name, object constants, array methodNames (methodId is index), [array promiseMethodIds], [array syncMethodIds]
  folly::dynamic config = folly::dynamic::array(name);

  {
    SystraceSection s_("getConstants");
    config.push_back(module->getConstants());
  }

  {
    SystraceSection s_("getMethods");
    std::vector<MethodDescriptor> methods = module->getMethods();

    folly::dynamic methodNames = folly::dynamic::array;
    folly::dynamic promiseMethodIds = folly::dynamic::array;
    folly::dynamic syncMethodIds = folly::dynamic::array;

    for (auto& descriptor : methods) {
      // TODO: #10487027 compare tags instead of doing string comparison?
      methodNames.push_back(std::move(descriptor.name));
      if (descriptor.type == "promise") {
        promiseMethodIds.push_back(methodNames.size() - 1);
      } else if (descriptor.type == "sync") {
        syncMethodIds.push_back(methodNames.size() - 1);
      }
    }

    if (!methodNames.empty()) {
      config.push_back(std::move(methodNames));
      if (!promiseMethodIds.empty() || !syncMethodIds.empty()) {
        config.push_back(std::move(promiseMethodIds));
        if (!syncMethodIds.empty()) {
          config.push_back(std::move(syncMethodIds));
        }
      }
    }
  }

  if (config.size() == 2 && config[1].empty()) {
    // no constants or methods
    return nullptr;
  } else {
    return ModuleConfig({it->second, config});
  }
}
Exemple #2
0
std::string oskar_settings_utility_string_to_upper(const std::string& s)
{
    std::string s_(s);
    for (size_t i = 0; i < s_.length(); ++i)
        s_[i] = toupper(s_[i]);
    return s_;
}
void read_nprow_npcol_freefem(string *string_option, int *nprow, int *npcol, int *matrixdist){
  
  static const char* comp[] = {"Fact","Equil","ParSymbFact","ColPerm","RowPerm",
			       "DiagPivotThresh","IterRefine","Trans",
			       "ReplaceTinyPivot","SolveInitialized",
			       "RefineInitialized","PrintStat","nprow","npcol","matrix",0};

  char data[string_option->size()+1];  
  strcpy( data, string_option->c_str()); 
  char *tictac;
  char *tictac2;
  tictac = strtok(data," =,\t\n");
  
  while(tictac != NULL){
    int id_option = s_(tictac, comp);
    tictac2 = tictac;
    tictac = strtok(NULL," =,\t\n");
    int val_options;
    printf("param %s = value %s , id_option %d\n",tictac2,tictac,id_option);
    switch (id_option)
      { 
      case 13: // nprow
	*nprow = atoi(tictac);
	break;
      case 14: // npcol 
	*npcol = atoi(tictac);
	break;
      case 15: // matrix
	printf("parameter matrix \n");
	if(strcmp(tictac,"assembled") == 0)
	  *matrixdist = 0;
	else if(strcmp(tictac,"distributedglobal") == 0) 
	  *matrixdist = 1;
	else if(strcmp(tictac,"distributed") == 0) 
	  *matrixdist = 2;
	else{
	  printf("value of parameter matrix is not correct %s \n", tictac );
	}
	break;
      default: // Equivalent of case default
	if(id_option == 0)
	  {
	    printf("parameter is not valid for superlu_dist %s \n", tictac2 );
	    exit(1);
	  }	  
	break;
      }  
    tictac = strtok(NULL," =,\t\n");
  }
}
Exemple #4
0
    void operator()( const tbb::blocked_range<int>& r) const
    {
        for( int j = r.begin(); j < r.end(); ++j)
        {
            image_view_t::x_iterator dst_it( dst_.row_begin( j));

            Imath::V2f p ( 0, j * yscale_);
            float xinc( src_.width() / dst_.width());

            for( int i = 0; i < dst_.width(); ++i)
            {
                *dst_it++ = s_( p);
                p.x += xinc;
            }
        }
    }
Exemple #5
0
    void operator()( const tbb::blocked_range<int>& r) const
    {
		vector2_t du, dv;
		inv_xform_.multDirMatrix( vector2_t( 0.5, 0), du);
		inv_xform_.multDirMatrix( vector2_t( 0, 0.5), dv);

		for( int j = r.begin(); j < r.end(); ++j)
		{
				vector2_t p ( vector2_t( active_area_.min.x, j) * inv_xform_);
				vector2_t p1( vector2_t( active_area_.max.x, j) * inv_xform_);
				vector2_t inc( ( p1 - p) / ( active_area_.max.x - active_area_.min.x));
	
			for( int i = active_area_.min.x; i <= active_area_.max.x; ++i)
			{
				dst_( i - dst_area_.min.x, j - dst_area_.min.y) = s_( p, du, dv);
				p += inc;
			}
		}
    }
Exemple #6
0
std::string
get_proxy_subject(std::string const& x509_proxy)
{
  static std::string const null_string;

  std::FILE* fd = std::fopen(x509_proxy.c_str(), "r");
  if (!fd) return null_string;
  boost::shared_ptr<std::FILE> fd_(fd, std::fclose);

  ::X509* const cert = ::PEM_read_X509(fd, 0, 0, 0);
  if (!cert) return null_string;
  boost::shared_ptr< ::X509> cert_(cert, ::X509_free);

  char* const s = ::X509_NAME_oneline(::X509_get_subject_name(cert), 0, 0);
  if (!s) return null_string;
  boost::shared_ptr<char> s_(s, ::free);

  return std::string(s);
}
void read_nprow_npcol_freefem(string *string_option, int *nprow, int *npcol){
  
  static const char* comp[] = {"Fact","Equil","ParSymbFact","ColPerm","RowPerm",
			       "DiagPivotThresh","IterRefine","Trans",
			       "ReplaceTinyPivot","SolveInitialized",
			       "RefineInitialized","PrintStat","nprow","npcol",0};

  char data[string_option->size()+1];  
  strcpy( data, string_option->c_str()); 
  char *tictac;
  char *tictac2;
  tictac = strtok(data," =,\t\n");
  
  while(tictac != NULL){
    int id_option = s_(tictac, comp);
    tictac2 = tictac;
    tictac = strtok(NULL," =,\t\n");
    int val_options;

    switch (id_option)
      { 
      case 13: // nprow
	*nprow = atoi(tictac);
	break;
      case 14: // npcol 
	*npcol = atoi(tictac);
	break;
      default: // Equivalent of case default
	if(id_option == 0)
	  {
	    printf("parameter is not valid for superlu_dist %s \n", tictac2 );
	    exit(1);
	  }	  
	break;
      }  
    tictac = strtok(NULL," =,\t\n");
  }
}
Exemple #8
0
void
SessionImpl::RegisterFileType (/*[in]*/ FileType fileType)
{
    if (fileType.Get() >= fileTypes.size())
    {
        fileTypes.resize (FileType::E_N_D);
    }


    if (fileTypes[fileType.Get()].fileType == fileType.Get())
    {
        // already registered
        return;
    }

    switch (fileType.Get())
    {

    case FileType::AFM:
        RegisterFileType (
            FileType::AFM,
            "afm",
            0,
            ".afm",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_AFM_DIR)),
            P2_("AFMFONTS", "TEXFONTS"));
        break;

    case FileType::BASE:
        RegisterFileType (
            FileType::BASE,
            "base",
            "METAFONT",
            ".base",
            P2_(CURRENT_DIRECTORY, s_(MIKTEX_PATH_BASE_DIR)),
            "");
        break;

    case FileType::BIB:
        RegisterFileType (
            FileType::BIB,
            "bib",
            "BibTeX",
            ".bib",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/bib")),
            P2_("BIBINPUTS", "TEXBIB"));
        break;

    case FileType::BST:
        RegisterFileType (
            FileType::BST,
            "bst",
            "BibTeX",
            ".bst",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/{bst,csf}")),
            "BSTINPUTS");
        break;

    case FileType::CID:
        RegisterFileType (
            FileType::CID,
            "cid maps",
            0,
            P2_(".cid", ".cidmap"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CIDMAP_DIR)),
            "FONTCIDMAPS");
        break;

    case FileType::CLUA:
        RegisterFileType (
            FileType::CLUA,
            "clua",
            0,
            P2_(".dll", ".so"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}/lua")),
            "CLUAINPUTS");
        break;

    case FileType::CNF:
        RegisterFileType (
            FileType::CNF,
            "cnf",
            0,
            ".cnf",
            S_(MIKTEX_PATH_WEB2C_DIR),
            "TEXMFCNF");
        break;

    case FileType::CMAP:
        RegisterFileType (
            FileType::CMAP,
            "cmap files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CMAP_DIR)),
            P2_("CMAPFONTS", "TEXFONTS"));
        break;

    case FileType::CWEB:
        RegisterFileType (
            FileType::CWEB,
            "cweb",
            "CWeb",
            ".w",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CWEB_DIR)),
            "CWEBINPUTS");
        break;

    case FileType::DB:
        RegisterFileType (
            FileType::DB,
            "ls-R",
            0,
            "",
            "",
            "TEXMFDBS");
        break;

    case FileType::DVI:
        RegisterFileType (
            FileType::DVI,
            "dvi",
            0,
            ".dvi",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_DOC_DIR)),
            "");
        break;

    case FileType::DVIPSCONFIG:
        RegisterFileType (
            FileType::DVIPSCONFIG,
            "dvips config",
            "Dvips",
            "",
            R_(MIKTEX_PATH_DVIPS_DIR),
            "TEXCONFIG");
        break;

    case FileType::ENC:
        RegisterFileType (
            FileType::ENC,
            "enc",
            0,
            ".enc",
            P6_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_ENC_DIR),
                R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_DVIPDFM_DIR)),
            P2_("ENCFONTS", "TEXFONTS"));
        break;

    case FileType::EXE:
#if defined(MIKTEX_WINDOWS)
    case FileType::WindowsCommandScriptFile:
#endif
    {
        string extensions;
#if defined(MIKTEX_WINDOWS)
        if (! Utils::GetEnvironmentString("PATHEXT", extensions)
                || extensions.empty())
        {
            extensions = P3_(".com",".exe", ".bat");
        }
#elif defined(MIKTEX_EXE_FILE_SUFFIX)
        extensions = MIKTEX_EXE_FILE_SUFFIX;
#endif
        string exePath;
        PathName userBinDir = GetSpecialPath(SpecialPath::UserInstallRoot);
        userBinDir += MIKTEX_PATH_BIN_DIR;
        userBinDir.Canonicalize ();
        if (! IsAdminMode()
                && ! Utils::Contains(exePath.c_str(),
                                     userBinDir.Get(),
                                     PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += userBinDir.Get();
        }
        PathName commonBinDir = GetSpecialPath(SpecialPath::CommonInstallRoot);
        commonBinDir += MIKTEX_PATH_BIN_DIR;
        commonBinDir.Canonicalize ();
        if (! Utils::Contains(exePath.c_str(),
                              commonBinDir.Get(),
                              PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += commonBinDir.Get();
        }
        string str;
        if (Utils::GetEnvironmentString(MIKTEX_ENV_BIN_DIR, str))
        {
            PathName binDir = str;
            binDir.Canonicalize ();
            if (! Utils::Contains(exePath.c_str(),
                                  binDir.Get(),
                                  PATH_DELIMITER_STRING))
            {
                if (! exePath.empty())
                {
                    exePath += PATH_DELIMITER;
                }
                exePath += binDir.Get();
            }
        }
        PathName myLocation = GetMyLocation(true);
        if (! Utils::Contains(exePath.c_str(),
                              myLocation.Get(),
                              PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += myLocation.Get();
        }
        if (fileType.Get() == FileType::EXE)
        {
            RegisterFileType (
                FileType::EXE,
                "exe",
                0,
                extensions.c_str(),
                exePath.c_str(),
                "");
        }
#if defined(MIKTEX_WINDOWS)
        else if (fileType.Get() == FileType::WindowsCommandScriptFile)
        {
            RegisterFileType (
                FileType::WindowsCommandScriptFile,
                "Windows command script file",
                0,
                P2_(".bat", ".cmd"),
                P_(R_(MIKTEX_PATH_SCRIPT_DIR), exePath.c_str()),
                "");
        }
#endif
        break;
    }

    case FileType::FEA:
        RegisterFileType (
            FileType::FEA,
            "font feature files",
            0,
            ".fea",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_FEATURE_DIR)),
            "FONTFEATURES");
        break;

    case FileType::FMT:
        RegisterFileType (
            FileType::FMT,
            "fmt",
            "TeX",
            ".fmt",
            P2_(CURRENT_DIRECTORY, s_(MIKTEX_PATH_FMT_DIR "/{$engine,}")),
            "");
        break;

    case FileType::GF:
        RegisterFileType (
            FileType::GF,
            "gf",
            0,
            ".gf",
            // <todo>
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            // <todo/>
            P3_("GFFONTS", "GLYPHFONTS", "TEXFONTS"));
        break;

    case FileType::GLYPHFONT:
        RegisterFileType (
            FileType::GLYPHFONT,
            "bitmap font",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            P2_("GLYPHFONTS", "TEXFONTS"));
        break;

    case FileType::GRAPHICS:
        RegisterFileType (
            FileType::GRAPHICS,
            "graphic/figure",
            0,
            P3_(".eps", ".epsi",".png"),
            P4_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_TEX_DIR)),
            P2_("TEXPICTS", "TEXINPUTS"));
        break;

    case FileType::HBF:
        RegisterFileType (
            FileType::HBF,
            "hbf",
            0,
            ".hbf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_HBF_DIR),
                R_(MIKTEX_PATH_TYPE1_DIR)),
            "");
        break;

    case FileType::IST:
        RegisterFileType (
            FileType::IST,
            "ist",
            "MakeIndex",
            ".ist",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MAKEINDEX_DIR)),
            P2_("TEXINDEXSTYLE", "INDEXSTYLE"));
        break;

    case FileType::LIG:
        RegisterFileType (
            FileType::LIG,
            "lig files",
            0,
            ".lig",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_LIG_DIR)),
            "TEXFONTS");
        break;

    case FileType::LUA:
        RegisterFileType (
            FileType::LUA,
            "lua",
            0,
            P7_(".lua", ".luatex", ".luc", ".luctex", ".texlua", ".texluc", ".tlu"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}/{lua,}"),
               GetFileTypeInfo(FileType::TEX).searchPath.c_str()),
            "LUAINPUTS");
        break;

    case FileType::MAP:
        RegisterFileType (
            FileType::MAP,
            "map",
            0,
            ".map",
            P6_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_MAP_DIR "/{$progname,pdftex,dvips,}"),
                R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_DVIPDFM_DIR)),
            P2_("TEXFONTMAPS", "TEXFONTS"));
        break;

    case FileType::MEM:
        RegisterFileType (
            FileType::MEM,
            "mem",
            "MetaPost",
            ".mem",
            CURRENT_DIRECTORY,
            "");
        break;

    case FileType::MF:
        RegisterFileType (
            FileType::MF,
            "mf",
            "METAFONT",
            ".mf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_METAFONT_DIR),
                R_(MIKTEX_PATH_FONT_SOURCE_DIR)),
            "MFINPUTS");
        break;

    case FileType::MFPOOL:
        RegisterFileType (
            FileType::MFPOOL,
            "mfpool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("MFPOOL", "TEXMFINI"));
        break;

    case FileType::MFT:
        RegisterFileType (
            FileType::MFT,
            "mft",
            0,
            ".mft",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MFT_DIR)),
            "MFTINPUTS");
        break;

    case FileType::MISCFONT:
        RegisterFileType (
            FileType::MISCFONT,
            "misc fonts",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MISCFONTS_DIR)),
            P2_("MISCFONTS","TEXFONTS"));
        break;

    case FileType::MLBIB:
        RegisterFileType (
            FileType::MLBIB,
            "mlbib",
            0,
            P2_(".mlbib", ".bib"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/bib/{mlbib,}")),
            P3_("MLBIBINPUTS", "BIBINPUTS", "TEXBIB"));
        break;

    case FileType::MLBST:
        RegisterFileType (
            FileType::MLBST,
            "mlbst",
            0,
            ".bst",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/{mlbst,bst}")),
            P2_( "MLBSTINPUTS", "BSTINPUTS"));
        break;

    case FileType::MP:
        RegisterFileType (
            FileType::MP,
            "mp",
            "MetaPost",
            ".mp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_METAPOST_DIR)),
            "MPINPUTS");
        break;

    case FileType::MPPOOL:
        RegisterFileType (
            FileType::MPPOOL,
            "mppool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("MPPOOL", "TEXMFINI"));
        break;

    case FileType::MPSUPPORT:
        RegisterFileType (
            FileType::MPSUPPORT,
            "MetaPost support",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MPSUPPORT_DIR)),
            "MPSUPPORT");
        break;

    case FileType::OCP:
        RegisterFileType (
            FileType::OCP,
            "ocp",
            "Omega",
            ".ocp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OCP_DIR)),
            "OCPINPUTS");
        break;

    case FileType::OFM:
        RegisterFileType (
            FileType::OFM,
            "ofm",
            "Omega",
            P2_(".ofm", ".tfm"),
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_OFM_DIR),
                R_(MIKTEX_PATH_TFM_DIR)),
            P2_("OFMFONTS", "TEXFONTS"));
        break;

    case FileType::OPL:
        RegisterFileType (
            FileType::OPL,
            "opl",
            0,
            ".opl",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OPL_DIR)),
            P2_("OPLFONTS", "TEXFONTS"));
        break;

    case FileType::OTP:
        RegisterFileType (
            FileType::OTP,
            "otp",
            "otp2ocp",
            ".otp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OTP_DIR)),
            "OTPINPUTS");
        break;

    case FileType::OTF:
        RegisterFileType (
            FileType::OTF,
            "opentype fonts",
            0,
            ".otf",
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_OPENTYPE_DIR),
               GetLocalFontDirectories().c_str()),
            P2_("OPENTYPEFONTS", "TEXFONTS"));
        break;

    case FileType::OVF:
        RegisterFileType (
            FileType::OVF,
            "ovf",
            0,
            ".ovf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_OVF_DIR),
                R_(MIKTEX_PATH_VF_DIR)),
            P2_("OVFFONTS", "TEXFONTS"));
        break;

    case FileType::OVP:
        RegisterFileType (
            FileType::OVP,
            "ovp",
            0,
            ".ovp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OVP_DIR)),
            P2_("OVPFONTS", "TEXFONTS"));
        break;

    case FileType::PDFTEXCONFIG:
        RegisterFileType (
            FileType::PDFTEXCONFIG,
            "pdftex config",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_PDFTEX_DIR "/{$progname,}")),
            "PDFTEXCONFIG");
        break;

    case FileType::PERLSCRIPT:
        RegisterFileType (
            FileType::PERLSCRIPT,
            "perlscript",
            0,
            ".pl",
            P8_(R_(MIKTEX_PATH_SCRIPT_DIR),
                R_(MIKTEX_PATH_CONTEXT_DIR),
                R_(MIKTEX_PATH_MIKTEX_DIR),
                R_(MIKTEX_PATH_NTS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_PSUTILS_DIR),
                R_(MIKTEX_PATH_SOURCE_DIR),
                R_(MIKTEX_PATH_TEX_DIR)),
            "");
        break;

    case FileType::PK:
        RegisterFileType (
            FileType::PK,
            "pk",
            0,
            ".pk",
            // <todo>
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            // </todo>
            "");
        break;

    case FileType::PROGRAMBINFILE:
        RegisterFileType (
            FileType::PROGRAMBINFILE,
            "other binary files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_("/$progname")),
            "");
        break;

    case FileType::PROGRAMTEXTFILE:
        RegisterFileType (
            FileType::PROGRAMTEXTFILE,
            "other text files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_("/$progname")),
            "");
        break;

    case FileType::PSHEADER:
        RegisterFileType (
            FileType::PSHEADER,
            "PostScript header",
            0,
            P2_(".pro", ".enc"),
            P10_(CURRENT_DIRECTORY,
                 R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                 R_(MIKTEX_PATH_DVIPS_DIR),
                 R_(MIKTEX_PATH_PDFTEX_DIR),
                 R_(MIKTEX_PATH_DVIPDFM_DIR),
                 R_(MIKTEX_PATH_ENC_DIR),
                 R_(MIKTEX_PATH_TYPE1_DIR),
                 R_(MIKTEX_PATH_TYPE42_DIR),
                 R_(MIKTEX_PATH_TYPE3_DIR),
                 "$psfontdirs"),
            P2_("TEXPSHEADERS", "PSHEADERS"));
        break;

    case FileType::SCRIPT:
        RegisterFileType (
            FileType::SCRIPT,
            "texmfscripts",
            0,
            "",
            R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}"),
            "TEXMFSCRIPTS");
        break;

    case FileType::SFD:
        RegisterFileType (
            FileType::SFD,
            "subfont definition files",
            0,
            ".sfd",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SFD_DIR)),
            P2_("SFDFONTS", "TEXFONTS"));
        break;

    case FileType::TCX:
        RegisterFileType (
            FileType::TCX,
            "tcx",
            0,
            ".tcx",
            P3_(CURRENT_DIRECTORY,
                S_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                S_(MIKTEX_PATH_WEB2C_DIR)),
            "");
        break;

    case FileType::TEX:
        RegisterFileType (
            FileType::TEX,
            "tex",
            "TeX",
            ".tex",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TEX_DIR "/{$progname,generic,}")),
            "TEXINPUTS");
        break;

    case FileType::TEXPOOL:
        RegisterFileType (
            FileType::TEXPOOL,
            "texpool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("TEXPOOL", "TEXMFINI"));
        break;

    case FileType::TEXSOURCE:
        RegisterFileType (
            FileType::TEXSOURCE,
            "TeX system sources",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SOURCE_DIR)),
            "TEXSOURCES");
        break;

    case FileType::TEXSYSDOC:
        RegisterFileType (
            FileType::TEXSYSDOC,
            "TeX system documentation",
            0,
#if defined(MIKTEX_WINDOWS)
            P6_(".chm", ".dvi", ".html", ".txt", ".pdf", ".ps"),
#else
            P5_(".dvi", ".html", ".txt", ".pdf", ".ps"),
#endif
            P2_(R_(MIKTEX_PATH_MIKTEX_DOC_DIR),
                R_(MIKTEX_PATH_DOC_DIR)),
            "TEXDOCS");
        break;

    case FileType::TFM:
        RegisterFileType (
            FileType::TFM,
            "tfm",
            0,
            ".tfm",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TFM_DIR)),
            P2_("TFMFONTS", "TEXFONTS"));
        break;

    case FileType::TROFF:
        RegisterFileType (
            FileType::TROFF,
            "troff fonts",
            0,
            "",
            "",
            "TRFONTS");
        break;

    case FileType::TTF:
        RegisterFileType (
            FileType::TTF,
            "truetype fonts",
            0,
            P2_(".ttf", ".ttc"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_TRUETYPE_DIR),
               GetLocalFontDirectories().c_str()),
            P2_("TTFONTS", "TEXFONTS"));
        break;

    case FileType::TYPE1:
        RegisterFileType (
            FileType::TYPE1,
            "type1 fonts",
            0,
            P2_(".pfb", ".pfa"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_TYPE1_DIR),
               GetLocalFontDirectories().c_str()),
            P5_("T1FONTS", "T1INPUTS", "TEXFONTS", "TEXPSHEADERS", "PSHEADERS"));
        break;

    case FileType::TYPE42:
        RegisterFileType (
            FileType::TYPE42,
            "type42 fonts",
            0,
#if defined(MIKTEX_WINDOWS)
            ".t42",
#else
            P2_(".t42", ".T42"),
#endif
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TYPE42_DIR)),
            P2_("T42FONTS", "TEXFONTS"));
        break;

    case FileType::VF:
        RegisterFileType (
            FileType::VF,
            "vf",
            0,
            ".vf",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_VF_DIR)),
            P2_("VFFONTS", "TEXFONTS"));
        break;

    case FileType::WEB:
        RegisterFileType (
            FileType::WEB,
            "web",
            0,
            ".web",
            R_(MIKTEX_PATH_WEB_DIR),
            "WEBINPUTS");
        break;

    case FileType::WEB2C:
        RegisterFileType (
            FileType::WEB2C,
            "web2c files",
            0,
            "",
            R_(MIKTEX_PATH_WEB2C_DIR),
            "");
        break;

    default:
        UNEXPECTED_CONDITION ("SessionImpl::RegisterFileType");
    }
}
void read_options_freefem (string string_option, superlu_options_t *options) {
	static const yes_no_t enumyes_no_t[2] = {NO, YES};
	static const fact_t enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED};
	static const colperm_t enumcolperm_t[5] = {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC};
	static const trans_t enumtrans_t[3] = {NOTRANS, TRANS, CONJ};
	static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA};
	static const char *compyes_no_t [] = {"NO", "YES", 0};
	static const char *compfact_t [] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED", 0};
	static const char *compcolperm_t [] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
	static const char *comptrans_t [] = {"NOTRANS", "TRANS", "CONJ", 0};
	static const char *compIterRefine_t [] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0};
	static const char *comp [] = {"Fact", "Equil", "ColPerm",
		                          "DiagPivotThresh", "Trans", "IterRefine",
		                          "SymmetricMode", "PivotGrowth", "ConditionNumber",
		                          "PrintStat", 0};

	/* Set the default values for options argument:
	 *   options.Fact = DOFACT;
	 *   options.Equil = YES;
	 *   options.ColPerm = COLAMD;
	 *   options.DiagPivotThresh = 1.0;
	 *   options.Trans = NOTRANS;
	 *   options.IterRefine = NOREFINE;
	 *   options.SymmetricMode = NO;
	 *   options.PivotGrowth = NO;
	 *   options.ConditionNumber = NO;
	 *   options.PrintStat = YES;
	 */
	// cout << "string_option" <<  *string_option << endl;
	KN<char> kdata(string_option.size() + 1);

	char *data = kdata;
	strcpy(data, string_option.c_str());
	cout << "data=" << data << endl;
	char *tictac;
	tictac = strtok(data, " =,\t\n");
	cout << "tictac=" << data << endl;

// #ifdef __cplusplus
// while(tictac != NULL){
// int id_option = s_(tictac, "Fact", "Equil","ColPerm",
// "DiagPivotThresh","Trans","IterRefine",
// "SymmetricMode","PivotGrowth","ConditionNumber",
// "PrintStat",0);
// tictac = strtok(NULL," ,\t\n");
// int val_options;
// switch (id_option)
// {
// case 1 : // Fact
// val_options= s_(tictac, "DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","Fact");
// exit(1);
// }
// options->Fact= enumfact_t[val_options-1];
// break;
// case 2:  // Equil
// val_options= s_(tictac, "NO", "YES", 0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","Equil");
// exit(1);
// }
// options->Equil= enumyes_no_t[val_options-1];
// break;
// case 3:  // ColPerm
// val_options= s_(tictac,"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","ColPerm");
// exit(1);
// }
// options->ColPerm= enumcolperm_t[val_options-1];
// case 4:  // DiagPivotThresh
// options->DiagPivotThresh= strtod(tictac,&tictac);
// break;
// case 5:  // Trans
// val_options= s_(tictac, "NOTRANS", "TRANS", "CONJ",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","Trans");
// exit(1);
// }
// options->Trans= enumtrans_t[val_options-1];
// break;
// case 6:  // IterRefine
// val_options= s_(tictac, "NOREFINE", "SINGLE", "DOUBLE", "EXTRA",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","IterRefine");
// exit(1);
// }
// options->IterRefine= enumIterRefine_t[val_options-1];
// break;
// case 7:  // SymmetricMode
// val_options= s_(tictac, "NO","YES",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","SymmetricMode");
// exit(1);
// }
// options->SymmetricMode= enumyes_no_t[val_options-1];
// break;
// case 8:  // PivotGrowth
// val_options= s_(tictac, "NO","YES",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","PivotGrowth");
// exit(1);
// }
// options->PivotGrowth= enumyes_no_t[val_options-1];
// break;
// case 9:  // ConditionNumber
// val_options= s_(tictac, "NO","YES",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","ConditionNumber");
// exit(1);
// }
// options->ConditionNumber = enumyes_no_t[val_options-1];
// break;
// case 10: // PrintStat
// val_options= s_(tictac, "NO","YES",0);
// if( val_options == 0){
// printf("value given for SuperLU for options %s is not correct\n","PrintStat");
// exit(1);
// }
// options->PrintStat = enumyes_no_t[val_options-1];
// break;
// case 0: // Equivalent of case default
// printf("A false parameter for  SuperLU is given %s \n",tictac);
// exit(1);
// }
// tictac = strtok(NULL," ,\t\n");
// }
// #else
	while (tictac != NULL) {
		// char* comp[] = {"Fact", "Equil","ColPerm",
		// "DiagPivotThresh","Trans","IterRefine",
		// "SymmetricMode","PivotGrowth","ConditionNumber",
		// "PrintStat",0 };
		int id_option = s_(tictac, comp);
		tictac = strtok(NULL, " =,\t\n");
		int val_options;

		switch (id_option) {
		case 1:	// Fact
			// char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0};
			val_options = s_(tictac, compfact_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "Fact");
				exit(1);
			}

			options->Fact = enumfact_t[val_options - 1];
			break;
		case 2:	// Equil
			// char* comp2[] = {"NO", "YES", 0};
			val_options = s_(tictac, compyes_no_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "Equil");
				exit(1);
			}

			options->Equil = enumyes_no_t[val_options - 1];
			break;
		case 3:	// ColPerm
			// char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
			val_options = s_(tictac, compcolperm_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "ColPerm");
				exit(1);
			}

			options->ColPerm = enumcolperm_t[val_options - 1];
			break;
		case 4:	// DiagPivotThresh
			options->DiagPivotThresh = strtod(tictac, &tictac);
			break;
		case 5:	// Trans
			// char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0};
			val_options = s_(tictac, comptrans_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "Trans");
				exit(1);
			}

			options->Trans = enumtrans_t[val_options - 1];
			break;
		case 6:	// IterRefine
			// char* comp6[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA", 0};
			val_options = s_(tictac, compIterRefine_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "IterRefine");
				exit(1);
			}

			options->IterRefine = enumIterRefine_t[val_options - 1];
			break;
		case 7:	// SymmetricMode
			// char* comp7[] = {"NO","YES", 0};
			val_options = s_(tictac, compyes_no_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "SymmetricMode");
				exit(1);
			}

			options->SymmetricMode = enumyes_no_t[val_options - 1];
			break;
		case 8:	// PivotGrowth
			// char* comp8[] = {"NO","YES", 0};
			val_options = s_(tictac, compyes_no_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "PivotGrowth");
				exit(1);
			}

			options->PivotGrowth = enumyes_no_t[val_options - 1];
			break;
		case 9:	// ConditionNumber
			// char* comp9[] = {"NO","YES", 0};
			val_options = s_(tictac, compyes_no_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "ConditionNumber");
				exit(1);
			}

			options->ConditionNumber = enumyes_no_t[val_options - 1];
			break;
		case 10:// PrintStat
			val_options = s_(tictac, compyes_no_t);
			if (val_options == 0) {
				printf("value given for SuperLU for options %s is not correct\n", "PrintStat");
				exit(1);
			}

			options->PrintStat = enumyes_no_t[val_options - 1];
			break;
		case 0:	// Equivalent of case default
			break;
		}

		tictac = strtok(NULL, " =,\t\n");
	}

	// #endif
}
void read_options_superlu_datafile(string *data_option, superlu_options_t *options, int_t *nprow, int_t *npcol, int *matrixdist, DiagScale_t *diag){
  static const yes_no_t  enumyes_no_t[2] = {NO, YES};
  static const fact_t  enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED};
  static const colperm_t  enumcolperm_t[6] = {NATURAL, MMD_AT_PLUS_A, MMD_ATA, METIS_AT_PLUS_A,PARMETIS, MY_PERMC};
  static const rowperm_t  enumrowperm_t[3] = {NOROWPERM, LargeDiag, MY_PERMR};
  static const DiagScale_t enumDiagScale_t[4] = {NOEQUIL, ROW, COL, BOTH};
  static const trans_t  enumtrans_t[3] = {NOTRANS, TRANS, CONJ};
  static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA};  
  //static const MemType enumMemType_t[4] = {LUSUP, UCOL, LSUB, USUB};  
  //static const stack_end_t enumstack_end_t[2] = {HEAD, TAIL};
  //static const LU_space_t enumLU_space_t[2] = {SYSTEM, USER};

 
  static const char* compyes_no_t[] = {"NO", "YES",0};
  static const char* compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0};
  static const char* comprowperm_t[] = {"NOROWPERM", "LargeDiag", "MY_PERMR",0};
  static const char* compcolperm_t[] = {"NATURAL", "MMD_AT_PLUS_A", "MMD_ATA", "METIS_AT_PLUS_A", "PARMETIS", "MY_PERMC",0};
  static const char* compDiagScale_t[] = {"NOEQUIL", "ROW", "COL", "BOTH",0};
  static const char* comptrans_t[] = {"NOTRANS", "TRANS", "CONJ",0};
  static const char* compIterRefine_t[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA",0};
  
  //int_t ffnprow,ffnpcol;
  //int matrixdist;

  char datafile[data_option->size()+1];  
  strcpy( datafile, data_option->c_str()); 
  
  FILE* pfile= fopen( datafile,"rt");
  char data[256];
  char *tictac;
  
  fgets(data,256,pfile);
  cout << "data=" << data << endl;
  tictac = strtok(data," /!#\t\n");
  *nprow = (int) atol(tictac);
  if(verbosity) printf("nprow=%d\n",*nprow);

  fgets(data,256,pfile);
  tictac = strtok(data," /!#\t\n");
  *npcol = (int) atol(tictac);
  if(verbosity) printf("npcol=%d\n",*npcol);

  fgets(data,256,pfile);
  tictac = strtok(data," /!#\t\n");
  if(strcmp(tictac,"assembled") == 0)
    *matrixdist = 0;
  else if(strcmp(tictac,"distributedglobal") == 0) 
    *matrixdist = 1;
  else if(strcmp(tictac,"distributed") == 0) 
    *matrixdist = 2;
  else{
    printf("matrix input %s for superlu_dist is not correct\n", tictac );
    exit(1);
  }

  int id_option=0;
  
  while( !feof(pfile) && id_option<12){
    fgets(data,256,pfile);
    tictac = strtok(data," /!#\t\n");
    id_option++;
    int val_options;
    switch (id_option)
      { 
	
      case 1 : // Fact
	//char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0};
	val_options= s_(tictac,compfact_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Fact");
	  exit(1);
	}
	
	options->Fact = enumfact_t[val_options-1];
	break;
      case 2:  // Equil
	//char* comp2[] = {"NO", "YES", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Equil");
	  exit(1);
	}
	options->Equil = enumyes_no_t[val_options-1];
	break;
      case 3:  // ParSymbFact
	//char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->ParSymbFact = enumyes_no_t[val_options-1];
	break;
      case 4:  // ColPerm
	val_options= s_(tictac,compcolperm_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->ColPerm = enumcolperm_t[val_options-1];
	break;
      case 5:  // RowPerm
	val_options= s_(tictac,comprowperm_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->RowPerm = enumrowperm_t[val_options-1];
	break;
      case 6:  // DiagPivotThresh
	options->DiagPivotThresh= strtod(tictac,&tictac);
	break;
      case 7:  // IterRefine
	val_options= s_(tictac,compIterRefine_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->IterRefine = enumIterRefine_t[val_options-1];
	break;
      case 8:  // Trans
	//char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0};
	val_options= s_(tictac, comptrans_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Trans");
	  exit(1);
	}
	options->Trans = enumtrans_t[val_options-1];
	break;
      case 9:  // ReplaceTinyPivot
	//char* comp7[] = {"NO","YES", 0};
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","SymmetricMode");
	  exit(1);
	}
	options->ReplaceTinyPivot= enumyes_no_t[val_options-1]; 
	break;
      case 10:  // SolveInitialized
	//char* comp8[] = {"NO","YES", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PivotGrowth");
	  exit(1);
	}
	options->SolveInitialized = enumyes_no_t[val_options-1];
	break;
      case 11:  // RefineInitialized
	//char* comp9[] = {"NO","YES", 0};
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ConditionNumber");
	  exit(1);
	}
	options->RefineInitialized = enumyes_no_t[val_options-1];
	break;
      case 12: // PrintStat
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PrintStat");
	  exit(1);
	}
	options->PrintStat = enumyes_no_t[val_options-1];
	break;
      case 13: // DiagScale_t
	val_options= s_(tictac, compDiagScale_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PrintStat");
	  exit(1);
	}
        *diag = enumDiagScale_t[val_options-1];
	break;
      default: // Equivalent of case default
	if(id_option == 0 && id_option > 13)
	  {
	    printf("Error in reading data file for superlu_dist %s\n",datafile);
	    exit(1);
	  }	 
	break;
      }  
  }
  fclose(pfile);
}
void read_options_freefem(string *string_option, superlu_options_t *options, DiagScale_t *diag){
  static const yes_no_t  enumyes_no_t[2] = {NO, YES};
  static const fact_t  enumfact_t[4] = {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED};
  static const colperm_t  enumcolperm_t[6] = {NATURAL, MMD_AT_PLUS_A, MMD_ATA, METIS_AT_PLUS_A,PARMETIS, MY_PERMC};
  static const rowperm_t  enumrowperm_t[3] = {NOROWPERM, LargeDiag, MY_PERMR};
  static const DiagScale_t enumDiagScale_t[4] = {NOEQUIL, ROW, COL, BOTH};
  static const trans_t  enumtrans_t[3] = {NOTRANS, TRANS, CONJ};
  static const IterRefine_t enumIterRefine_t[4] = {NOREFINE, SLU_SINGLE, SLU_DOUBLE, SLU_EXTRA};  
  //static const MemType enumMemType_t[4] = {LUSUP, UCOL, LSUB, USUB};  
  //static const stack_end_t enumstack_end_t[2] = {HEAD, TAIL};
  //static const LU_space_t enumLU_space_t[2] = {SYSTEM, USER};

 
  static const char* compyes_no_t[] = {"NO", "YES",0};
  static const char* compfact_t[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0};
  static const char* comprowperm_t[] = {"NOROWPERM", "LargeDiag", "MY_PERMR",0};
  static const char* compcolperm_t[] = {"NATURAL", "MMD_AT_PLUS_A", "MMD_ATA", "METIS_AT_PLUS_A", "PARMETIS", "MY_PERMC",0};
  static const char* compDiagScale_t[] = {"NOEQUIL", "ROW", "COL", "BOTH",0};
  static const char* comptrans_t[] = {"NOTRANS", "TRANS", "CONJ",0};
  static const char* compIterRefine_t[] = {"NOREFINE", "SINGLE", "DOUBLE", "EXTRA",0};
  //static const char* compMemType_t[] = {"LUSUP", "UCOL", "LSUB", "USUB",0};  
  //static const char* compstack_end_t[] = {"HEAD", "TAIL",0};
  //static const char* compLU_space_t[] = {"SYSTEM", "USER",0};

  static const char* comp[] = {"Fact","Equil","ParSymbFact","ColPerm","RowPerm",
			       "DiagPivotThresh","IterRefine","Trans",
			       "ReplaceTinyPivot","SolveInitialized",
			       "RefineInitialized","PrintStat","nprow","npcol","DiagScale","matrix",0};

  char data[string_option->size()+1];  
  strcpy( data, string_option->c_str()); 
  cout << "data=" << data << endl;
  char *tictac;
  char *tictac2;
  tictac = strtok(data," =,\t\n");

  while(tictac != NULL){
    int id_option = s_(tictac, comp);
    tictac2=tictac;
    tictac = strtok(NULL," =,\t\n");
    int val_options;

    switch (id_option)
      { 
      case 1 : // Fact
	//char* comp1[] = {"DOFACT", "SamePattern", "SamePattern_SameRowPerm", "FACTORED",0};
	val_options= s_(tictac,compfact_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Fact");
	  exit(1);
	}
	options->Fact = enumfact_t[val_options-1];
	break;
      case 2:  // Equil
	//char* comp2[] = {"NO", "YES", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Equil");
	  exit(1);
	}
	options->Equil = enumyes_no_t[val_options-1];
	break;
      case 3:  // ParSymbFact
	//char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->ParSymbFact = enumyes_no_t[val_options-1];
	break;
      case 4:  // ColPerm
	//char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
	val_options= s_(tictac,compcolperm_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->ColPerm = enumcolperm_t[val_options-1];
	break;
      case 5:  // RowPerm
	//char* comp3[] = {"NATURAL", "MMD_ATA", "MMD_AT_PLUS_A", "COLAMD", "MY_PERMC", 0};
	val_options= s_(tictac,comprowperm_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->RowPerm = enumrowperm_t[val_options-1];
	break;
      case 6:  // DiagPivotThresh
	options->DiagPivotThresh= strtod(tictac,&tictac);
	break;
      case 7:  // IterRefine
	val_options= s_(tictac,compIterRefine_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ColPerm");
	  exit(1);
	}
	options->IterRefine = enumIterRefine_t[val_options-1];
	break;
      case 8:  // Trans
	//char* comp5[] = {"NOTRANS", "TRANS", "CONJ", 0};
	val_options= s_(tictac, comptrans_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","Trans");
	  exit(1);
	}
	options->Trans = enumtrans_t[val_options-1];
	break;
      case 9:  // ReplaceTinyPivot
	//char* comp7[] = {"NO","YES", 0};
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","SymmetricMode");
	  exit(1);
	}
	options->ReplaceTinyPivot= enumyes_no_t[val_options-1]; 
	break;
      case 10:  // SolveInitialized
	//char* comp8[] = {"NO","YES", 0};
	val_options= s_(tictac,compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PivotGrowth");
	  exit(1);
	}
	options->SolveInitialized = enumyes_no_t[val_options-1];
	break;
      case 11:  // RefineInitialized
	//char* comp9[] = {"NO","YES", 0};
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","ConditionNumber");
	  exit(1);
	}
	options->RefineInitialized = enumyes_no_t[val_options-1];
	break;
      case 12: // PrintStat
	val_options= s_(tictac, compyes_no_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PrintStat");
	  exit(1);
	}
	options->PrintStat = enumyes_no_t[val_options-1];
	break;
	// case 13 nprow
	// case 14 npcol
      case 15: // DiagScale_t
	val_options= s_(tictac, compDiagScale_t);
	if( val_options == 0){
	  printf("value given for SuperLU for options %s is not correct\n","PrintStat");
	  exit(1);
	}
        *diag = enumDiagScale_t[val_options-1];
	break;
      default: // Equivalent of case default
	if(id_option == 0)
	  {
	    printf("parameter is not valid for superlu_dist %s \n", tictac2);
	    exit(1);
	  }	 
	break;
      }  
    tictac = strtok(NULL," =,\t\n");
  }
  
}
Exemple #12
0
Optional<String>
readFile(StringView s) noexcept {
    String s_(s);
    return readFile(s_);
}
Exemple #13
0
int
r_sendmsg(PROCTBL_P p, u_int msg)
{
    sigset_t oset;
    sigset_t clock_block_set;
    extern sigset_t alert_set;
    int rval, pindex;
    PEND *pp;

    /*
     * 'r_sendmsg()' is not reentrant.
     * 
     * Must block other signals from preempting while in 'r_sendmsg()'.
     * Otherwise 'r_sendmsg()' might be called reentrantly.  Note
     * also that the int process is also receiving another signal every
     * msec that invokes the clock routine.  This routine also calls
     * 'r_sendmsg()'.
     */

	/* if called from inside interrupt routine just return an error */
    if(inside_int) {
		rxerr("Cannot call 'r_sendmsg()' from inside interrupt routine");
		return(-1);
    }

	/* if called when NOT inside the clock routine
	 * do this block and return
	 */
    if(!inside_clock) {
		if(sigprocmask(SIG_BLOCK, &alert_set, &oset) == -1) {
			rxerr("r_sendmsg(): cannot sigprocmask");
		}
		
		rval = do_send(p, msg, 0);
		
		if(sigprocmask(SIG_SETMASK, &oset, NULL) == -1) {
			rxerr("r_sendmsg(): cannot sigprocmask");
		}
		return(rval);
    }

    /*
     * Called from inside clock routine of 'int' process.  First
     * see if this process has pending messages that haven't
     * been sent.  Block reinterrupts via clock signal.  Don't
     * need to explicitly block the ALERT signal because it is
     * already blocked when in the clock routine.
     */
    sigemptyset(&clock_block_set);
    sigaddset(&clock_block_set, S_STATESIG);
    if(sigprocmask(SIG_BLOCK, &alert_set, &oset) == -1) {
	    rxerr("r_sendmsg(): cannot sigprocmask");
	}
    pindex= (p - &i_b->ptbl[0]) / sizeof(PROCTBL);
    pp= &pend[pindex];
	
    if(pp->pend_back != NP) {
		pp->pend_msg |= s_(msg);
    }
	else {	/* if there are no pending messages, send this one */
		rval= do_send(p, msg, 0);	/* try to send it */
		if(rval == -2) {	/* if the message couldn't be sent */
			/*
			 * Queue request for another try later.
			 */
			pp->pend_msg |= s_(msg);
			pp->pend_p= p;
			if(pp->pend_back == 0) {
				pp->pend_back= pend_last.pend_back;
				pp->pend_back->pend_for= pp;
				pp->pend_for= &pend_last;
				pend_last.pend_back= pp;
			}
		}
    }

    /*
     * Try to send any pending messages.
     */
    for(pp= pend_first.pend_for; pp->pend_for != NP; pp= pp->pend_for) {
		if((rval= do_send(pp->pend_p, pp->pend_msg, 1)) == 0) {
			/*
			 * Successful- dequeue.
			 */
			pp->pend_back->pend_for= pp->pend_for;
			pp->pend_for->pend_back= pp->pend_back;
			pp->pend_back= NP;
		}
    }

    /*
     * If pending messages were sent, the return value is not
     * accurate.  Okay, becuase instances of sending in the clock
     * routine don't care.
     */
    if(sigprocmask(SIG_SETMASK, &oset, NULL) == -1) {
		rxerr("r_sendmsg(): cannot sigprocmask");
	}
    return(rval);
}
Exemple #14
0
static int
do_send(PROCTBL_P p, u_int msg, int msg_flag)
{
	u_int msgbit;
	int killRet;

#ifdef A_DEBUG
dprintf("-smsg: p %d, msg 0%o-", p, s_(msg));
#endif

	if(p->p_id <= 0) {
		rxerr("r_sendmsg(): Attempt to send msg to non-existant proc");
		return(-1);
	}
	if(msg_flag) msgbit= msg;
	else msgbit= s_(msg);

	/*
	 * Procs that are stopped can receive only certain messages.
	 */
	if(p != COMM && ((p->p_state & P_RUN_ST) == 0) &&
	   ((msgbit & (s_(G_KILL)|s_(G_STOP)|s_(G_RUN))) == 0)) {
		rxerr("r_sendmsg(): Cannot send msg; process is in stop state");
		return(-1);
	}

	if(inside_clock) {
	    /*
	     * This is the 'int' process, and we are inside the clock
	     * routine.  Don't call protect() if it would block!
	     */
		InterruptDisable();
	    if(!p->p_sem) {
			/*
			 * Just return -2.  'clock()' will try again next
			 * interrupt.
			 */
			InterruptEnable();
			return(-2);
	    }
		else protect(&p->p_sem);
		InterruptEnable();
	}
	else {
		protect(&p->p_sem);
	}
	p->p_msg |= msgbit;		/* set message bit */

	/*
	 * Signal sending is interlocked so that a signal is sent only
	 * when necessary to wake up the receiving process, OR re-interrupt
	 * a lower priority message currently executing in the receiving
	 * process.
	 */
	if( ! (p->p_state & P_NOSIG_ST)) {	/* signalling allowed */
		/*
		 * If the receiving process is currently not asleep but
		 * processing a message that has allowed re-interrupts, the
		 * re-interrupt mask will specify which messages are permitted
		 * to signal and cause a re-interrupt.
		 */
		if(msgbit & ~p->p_rmask) {
			p->p_state |= P_NOSIG_ST;
			release_(&p->p_sem);
#ifdef A_DEBUG
dprintf("-smsg: killing %d-", p->p_id);
#endif
            killRet = kill(p->p_id, S_ALERT);
			if(killRet == -1) {
				perror("do_send() kill error");
				stufs(p->p_name, &noproc[BLANKS], &noproc[0] +
								sizeof(noproc));
				rxerr(noproc);
				p->p_state &= ~P_NOSIG_ST;
				return(-1);
			}
			return(0);
		}
	}
	release_(&p->p_sem);
	return(0);
}