| Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
| Version 1.9 Build 803 |
|
We start with the main program which will simply call a couple of routines to check the coding (The source code for this program is found in $AIPSROOT/code/trial/implement/test/tExample3.cc).
1 #include <aips/aips.h>
2 #include <aips/AipsIO.h>
3 #include <aips/ArrayIO.h>
4 #include <aips/Input.h>
5 #include <aips/Math.h>
6 #include <aips/Matrix.h>
7 #include <aips/AsciiFileIO.h>
9
10 main(int argc, char **argv)
11 {
12 Input inputs(1);
13 inputs.Version("$w{Revision}$");
14 inputs.Usage("Testing Ascii IO routines");
15 inputs.Create("infile1","Input1","Float Input file name?","Infile");
16 inputs.Create("infile2","Input2","Int Input file name?","Infile");
17 inputs.Create("infile3","Input3","Double Input file name?","Infile");
18 inputs.Create("outfile","Output","Output file name?","Outfile");
19 inputs.ReadArguments(argc, argv);
20
21 const char *filein1 = inputs.GetString("infile1");
22 const char *filein2 = inputs.GetString("infile2");
23 const char *filein3 = inputs.GetString("infile3");
24 const char *fileout = inputs.GetString("outfile");
25
26 Int rows, cols;
27 try {
28 Matrix <Float> mat1;
29 Matrix <Int> mat2;
30 Matrix <Double> mat3;
31
32 ReadAsciiFile(filein1, mat1);
33 mat1.shape(rows, cols);
34 cout << "The first Matrix is " << rows << " by " << cols << endl;
35
36 ReadAsciiFile(filein2, mat2);
37 mat2.shape(rows, cols);
38 cout << "The second Matrix is " << rows << " by " << cols << endl;
39
40 ReadAsciiFile(filein3, mat3);
41 mat3.shape(rows, cols);
42 cout << "The third Matrix is " << rows << " by " << cols << endl;
43
44 WriteAsciiFile(fileout, mat1);
45
46 cout.precision(12);
47 cout << mat1 << mat2 << mat3;
48 }
49
50 return 0;
51
52 catch (AipsError x) {
53 cerr << "aipserror: error " << x.getMesg() << endl;
54 return 1;
55 }
56
58 }
The following discussion refers to the line numbers which have been prepended to the code above: