⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getvec.cpp

📁 用于电力系统潮流计算 c++程序
💻 CPP
字号:
/* Transform e-vector to SMMS format */

#ifndef WINDOWS
#include <stdio.h>
#else
#include "pfwstdio.h"
#endif
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "constant.h"
#include "param.h"


#ifdef ANSIPROTO
void ErrorStop(char *Msg);
void ErrorHalt(char *Msg);
int main(int argc,char **argv);
#else
void ErrorStop();
void ErrorHalt();
int main();
#endif


/* ---------------------- ErrorStop ------------------------------------ */
#ifdef ANSIPROTO
void ErrorStop(char *Msg)
#else
void ErrorStop(Msg)
char *Msg;
#endif
{
  fprintf(stdout,"Transform PoC e-vectors to SMMS format (c)1992 C. Canizares\n");
  if (!NullName(Msg)) fprintf(stdout,"Error: %s\n",Msg);
  fprintf(stdout,"Usage: getvec [-h] [<]input_file [>]output_file\n");
  fprintf(stdout,"       Program to transform PoC e-vectors to SMMS old vector format.\n");
  fprintf(stdout,"       The input_file is assumed to be in I Var Value format, which is\n");
  fprintf(stdout,"       similar to the standard SMMS I J Value format.  If this file\n");
  fprintf(stdout,"       is missing, the program reads from standard input.\n");
  fprintf(stdout,"       The output_file is optional; the program writes to standard output\n");
  fprintf(stdout,"       by default in I Val format.\n");
  fprintf(stdout,"Options: -h     Prints this message.\n");
  if (!NullName(Msg)) exit(ERROREXIT); else exit(NORMALEXIT);
}


/* ===================== ErrorHalt ================================ */
#ifdef ANSIPROTO
void ErrorHalt(char *Msg)
#else
void ErrorHalt(Msg)
char *Msg;
#endif
{
  fprintf(stderr,"Error: %s\n",Msg);
  exit(ERROREXIT);
}


/* --------------------------- Main Program  ------------------------------ */
#ifdef ANSIPROTO
int main(int argc,char **argv)
#else
int main(argc,argv)
int argc;
char **argv;
#endif
/* Transform e-vector format */
{
  char *Name,var[20],Line[BUFLEN];
  VALUETYPE val;
  FILE *In,*Out;
  INDEX i;


  SetArguments(argc,argv);
  if (HelpRequested()) ErrorStop("");
  In=(FILE *) OpenInput(TrueParamStr(1));
  Out=(FILE *) OpenOutput(TrueParamStr(2));
  if (fgets(Line,BUFLEN,In)==NULL) ErrorStop("Wrong input data.");
  for (;;) {
    if (fgets(Line,BUFLEN,In)==NULL) ErrorStop("Wrong input data: Check for 0 0 0 line.");
    if(sscanf(Line,"%d %s %lf",&i,var,&val)!=3) ErrorStop("Wrong input data:  Check input data format.");
    else if (i) {
      fprintf(Out,"%4d %-11.5g\n",i,val);
    } else break;
  }
  fprintf(Out,"0 0.0\n");
  fclose(Out);
  return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -