1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <boost/tokenizer.hpp>
using namespace std;
using namespace boost;
//external Fortran function prototype
extern"C" {
void getrec_(int *irw,const char *stname,int *sampin,int *mofm,int *nparm,\
int *pc,double *val,const char *flag,const char *dflg1,\
const char *dflg2,int *osmin,int *oemin,int *amin,int *iflag);
void rsif_(int *iflag);
void getfn_(int *iflag);
// fortran common block declaration
extern struct
{
bool prompt;
} pr_;
extern struct
{
char fnsif[80],fndat[80],fnerr[80],fnonly[80];
char fnhis[80],fncrp[80],fnnp[80],action[72];
} c6_;
extern struct
{
float lat, lon, elev;
int cr210t, pcatot, valwin, sifem, sifsm, trlqc, trlsa, trlrrd;
short int statn, staten, outtab[6][5], parttab[4][50];
} c2_;
}
int main(int argc, char *argv[])
{
int arg;
char *inFilename;
fstream rawFile;
string rawData;
char_separator<char> sep(", -");
int iflag;
int irw = 1;
// handle command-line arguments
if (argc == 3)
{
for (arg = 1; arg < argc; ++arg)
{
char *argCp = argv[arg];
if (argCp[0] != '-')
cerr << "Illegal switch ignored: " << argCp << '\n';
else
switch (argCp[1])
{
case 'f':
inFilename = argv[++arg];
break;
default:
cerr << "Illegal switch ignored: " << argCp << '\n';
break;
}
}
}
else
{
cerr << "Specify Command-line Arguments (-h for help)" << '\n';
return(EXIT_FAILURE);
}
// Prompt user for station ID
pr_.prompt = true;
getfn_(&iflag);
if (iflag != 0)
{
cerr << "Error During getfn" << '\n';
return(EXIT_FAILURE);
}
rsif_(&iflag);
if (iflag != 0)
{
cerr << "Error During rsif" << '\n';
return(EXIT_FAILURE);
}
// read data from inFile
cout << "Reading data from File: " << inFilename << '\n';
rawFile.open(inFilename);
// tokenize data
while (rawFile.good())
{
getline(rawFile, rawData);
tokenizer< char_separator<char> > data(rawData, sep);
}
return(EXIT_SUCCESS);
}
|