OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
table_io.cpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <iostream>
3 #include <iomanip>
4 #include <fstream>
5 #include <ctime>
6 #include <cmath>
7 #include <cstring>
8 
9 using namespace std;
10 
11 #include "table_io.h"
12 
13 //****************************************************************************80
14 
15 char ch_cap(char ch)
16 
17 //****************************************************************************80
18 //
19 // Purpose:
20 //
21 // CH_CAP capitalizes a single character.
22 //
23 // Discussion:
24 //
25 // This routine should be equivalent to the library "toupper" function.
26 //
27 // Licensing:
28 //
29 // This code is distributed under the GNU LGPL license.
30 //
31 // Modified:
32 //
33 // 19 July 1998
34 //
35 // Author:
36 //
37 // John Burkardt
38 //
39 // Parameters:
40 //
41 // Input, char CH, the character to capitalize.
42 //
43 // Output, char CH_CAP, the capitalized character.
44 //
45 {
46  if (97 <= ch && ch <= 122) {
47  ch = ch - 32;
48  }
49 
50  return ch;
51 }
52 //****************************************************************************80
53 
54 bool ch_eqi(char ch1, char ch2)
55 
56 //****************************************************************************80
57 //
58 // Purpose:
59 //
60 // CH_EQI is true if two characters are equal, disregarding case.
61 //
62 // Licensing:
63 //
64 // This code is distributed under the GNU LGPL license.
65 //
66 // Modified:
67 //
68 // 13 June 2003
69 //
70 // Author:
71 //
72 // John Burkardt
73 //
74 // Parameters:
75 //
76 // Input, char CH1, CH2, the characters to compare.
77 //
78 // Output, bool CH_EQI, is true if the two characters are equal,
79 // disregarding case.
80 //
81 {
82  if (97 <= ch1 && ch1 <= 122) {
83  ch1 = ch1 - 32;
84  }
85  if (97 <= ch2 && ch2 <= 122) {
86  ch2 = ch2 - 32;
87  }
88 
89  return ( ch1 == ch2);
90 }
91 //****************************************************************************80
92 
93 int ch_to_digit(char ch)
94 
95 //****************************************************************************80
96 //
97 // Purpose:
98 //
99 // CH_TO_DIGIT returns the integer value of a base 10 digit.
100 //
101 // Example:
102 //
103 // CH DIGIT
104 // --- -----
105 // '0' 0
106 // '1' 1
107 // ... ...
108 // '9' 9
109 // ' ' 0
110 // 'X' -1
111 //
112 // Licensing:
113 //
114 // This code is distributed under the GNU LGPL license.
115 //
116 // Modified:
117 //
118 // 13 June 2003
119 //
120 // Author:
121 //
122 // John Burkardt
123 //
124 // Parameters:
125 //
126 // Input, char CH, the decimal digit, '0' through '9' or blank are legal.
127 //
128 // Output, int CH_TO_DIGIT, the corresponding integer value. If the
129 // character was 'illegal', then DIGIT is -1.
130 //
131 {
132  int digit;
133 
134  if ('0' <= ch && ch <= '9') {
135  digit = ch - '0';
136  } else if (ch == ' ') {
137  digit = 0;
138  } else {
139  digit = -1;
140  }
141 
142  return digit;
143 }
144 //****************************************************************************80
145 
147 
148 //****************************************************************************80
149 //
150 // Purpose:
151 //
152 // FILE_COLUMN_COUNT counts the columns in the first line of a file.
153 //
154 // Discussion:
155 //
156 // The file is assumed to be a simple text file.
157 //
158 // Most lines of the file are presumed to consist of COLUMN_NUM words,
159 // separated by spaces. There may also be some blank lines, and some
160 // comment lines, which have a "#" in column 1.
161 //
162 // The routine tries to find the first non-comment non-blank line and
163 // counts the number of words in that line.
164 //
165 // If all lines are blanks or comments, it goes back and tries to analyze
166 // a comment line.
167 //
168 // Licensing:
169 //
170 // This code is distributed under the GNU LGPL license.
171 //
172 // Modified:
173 //
174 // 05 July 2009
175 //
176 // Author:
177 //
178 // John Burkardt
179 //
180 // Parameters:
181 //
182 // Input, string FILENAME, the name of the file.
183 //
184 // Output, int FILE_COLUMN_COUNT, the number of columns assumed
185 // to be in the file.
186 //
187 {
188  int column_num;
189  ifstream input;
190  bool got_one;
191  string text;
192  //
193  // Open the file.
194  //
195  input.open(filename.c_str());
196 
197  if (!input) {
198  column_num = -1;
199  cerr << "\n";
200  cerr << "FILE_COLUMN_COUNT - Fatal error!\n";
201  cerr << " Could not open the file:\n";
202  cerr << " \"" << filename << "\"\n";
203  return column_num;
204  }
205  //
206  // Read one line, but skip blank lines and comment lines.
207  //
208  got_one = false;
209 
210  for (;;) {
211  getline(input, text);
212 
213  if (input.eof()) {
214  break;
215  }
216 
217  if (s_len_trim(text) <= 0) {
218  continue;
219  }
220 
221  if (text[0] == '#' || text[0] == '/' || text[0] == '!') {
222  continue;
223  }
224  got_one = true;
225  break;
226  }
227 
228  if (!got_one) {
229  input.close();
230 
231  input.open(filename.c_str());
232 
233  for (;;) {
234  input >> text;
235 
236  if (input.eof()) {
237  break;
238  }
239 
240  if (s_len_trim(text) == 0) {
241  continue;
242  }
243  got_one = true;
244  break;
245  }
246  }
247 
248  input.close();
249 
250  if (!got_one) {
251  cerr << "\n";
252  cerr << "FILE_COLUMN_COUNT - Warning!\n";
253  cerr << " The file does not seem to contain any data.\n";
254  return -1;
255  }
256 
257  column_num = s_word_count(text);
258 
259  return column_num;
260 }
261 //****************************************************************************80
262 
263 int file_row_count(string input_filename)
264 
265 //****************************************************************************80
266 //
267 // Purpose:
268 //
269 // FILE_ROW_COUNT counts the number of row records in a file.
270 //
271 // Discussion:
272 //
273 // It does not count lines that are blank, or that begin with a
274 // comment symbol '#'.
275 //
276 // Licensing:
277 //
278 // This code is distributed under the GNU LGPL license.
279 //
280 // Modified:
281 //
282 // 23 February 2009
283 //
284 // Author:
285 //
286 // John Burkardt
287 //
288 // Parameters:
289 //
290 // Input, string INPUT_FILENAME, the name of the input file.
291 //
292 // Output, int FILE_ROW_COUNT, the number of rows found.
293 //
294 {
295  int comment_num;
296  ifstream input;
297  string line;
298  int record_num;
299  int row_num;
300 
301  row_num = 0;
302  comment_num = 0;
303  record_num = 0;
304 
305  input.open(input_filename.c_str());
306 
307  if (!input) {
308  cerr << "\n";
309  cerr << "FILE_ROW_COUNT - Fatal error!\n";
310  cerr << " Could not open the input file: \"" << input_filename << "\"\n";
311  return (-1);
312  }
313 
314  for (;;) {
315  getline(input, line);
316 
317  if (input.eof()) {
318  break;
319  }
320 
321  record_num = record_num + 1;
322 
323  if (line[0] == '#' || line[0] == '/' || line[0] == '!') {
324  comment_num = comment_num + 1;
325  continue;
326  }
327 
328  if (s_len_trim(line) == 0) {
329  comment_num = comment_num + 1;
330  continue;
331  }
332 
333  row_num = row_num + 1;
334 
335  }
336 
337  input.close();
338 
339  return row_num;
340 }
341 //****************************************************************************80
342 
343 int i4_log_10(int i)
344 
345 //****************************************************************************80
346 //
347 // Purpose:
348 //
349 // I4_LOG_10 returns the integer part of the logarithm base 10 of ABS(X).
350 //
351 // Example:
352 //
353 // I I4_LOG_10
354 // ----- --------
355 // 0 0
356 // 1 0
357 // 2 0
358 // 9 0
359 // 10 1
360 // 11 1
361 // 99 1
362 // 100 2
363 // 101 2
364 // 999 2
365 // 1000 3
366 // 1001 3
367 // 9999 3
368 // 10000 4
369 //
370 // Discussion:
371 //
372 // I4_LOG_10 ( I ) + 1 is the number of decimal digits in I.
373 //
374 // Licensing:
375 //
376 // This code is distributed under the GNU LGPL license.
377 //
378 // Modified:
379 //
380 // 04 January 2004
381 //
382 // Author:
383 //
384 // John Burkardt
385 //
386 // Parameters:
387 //
388 // Input, int I, the number whose logarithm base 10 is desired.
389 //
390 // Output, int I4_LOG_10, the integer part of the logarithm base 10 of
391 // the absolute value of X.
392 //
393 {
394  int i_abs;
395  int ten_pow;
396  int value;
397 
398  if (i == 0) {
399  value = 0;
400  } else {
401  value = 0;
402  ten_pow = 10;
403 
404  i_abs = abs(i);
405 
406  while (ten_pow <= i_abs) {
407  value = value + 1;
408  ten_pow = ten_pow * 10;
409  }
410 
411  }
412 
413  return value;
414 }
415 //****************************************************************************80
416 
417 int i4_max(int i1, int i2)
418 
419 //****************************************************************************80
420 //
421 // Purpose:
422 //
423 // I4_MAX returns the maximum of two I4's.
424 //
425 // Licensing:
426 //
427 // This code is distributed under the GNU LGPL license.
428 //
429 // Modified:
430 //
431 // 13 October 1998
432 //
433 // Author:
434 //
435 // John Burkardt
436 //
437 // Parameters:
438 //
439 // Input, int I1, I2, are two integers to be compared.
440 //
441 // Output, int I4_MAX, the larger of I1 and I2.
442 //
443 {
444  int value;
445 
446  if (i2 < i1) {
447  value = i1;
448  } else {
449  value = i2;
450  }
451  return value;
452 }
453 //****************************************************************************80
454 
455 int i4_min(int i1, int i2)
456 
457 //****************************************************************************80
458 //
459 // Purpose:
460 //
461 // I4_MIN returns the minimum of two I4's.
462 //
463 // Licensing:
464 //
465 // This code is distributed under the GNU LGPL license.
466 //
467 // Modified:
468 //
469 // 13 October 1998
470 //
471 // Author:
472 //
473 // John Burkardt
474 //
475 // Parameters:
476 //
477 // Input, int I1, I2, two integers to be compared.
478 //
479 // Output, int I4_MIN, the smaller of I1 and I2.
480 //
481 {
482  int value;
483 
484  if (i1 < i2) {
485  value = i1;
486  } else {
487  value = i2;
488  }
489  return value;
490 }
491 //****************************************************************************80
492 
493 int *i4mat_border_add(int m, int n, int table[])
494 
495 //****************************************************************************80
496 //
497 // Purpose:
498 //
499 // I4MAT_BORDER_ADD adds a "border" to an I4MAT.
500 //
501 // Discussion:
502 //
503 // An I4MAT is an array of I4's.
504 //
505 // We suppose the input data gives values of a quantity on nodes
506 // in the interior of a 2D grid, and we wish to create a new table
507 // with additional positions for the nodes that would be on the
508 // border of the 2D grid.
509 //
510 // 0 0 0 0 0 0
511 // * * * * 0 * * * * 0
512 // * * * * --> 0 * * * * 0
513 // * * * * 0 * * * * 0
514 // 0 0 0 0 0 0
515 //
516 // The illustration suggests the situation in which a 3 by 4 array
517 // is input, and a 5 by 6 array is to be output.
518 //
519 // The old data is shifted to its correct positions in the new array.
520 //
521 // Licensing:
522 //
523 // This code is distributed under the GNU LGPL license.
524 //
525 // Modified:
526 //
527 // 25 January 2005
528 //
529 // Author:
530 //
531 // John Burkardt
532 //
533 // Parameters:
534 //
535 // Input, int M, the spatial dimension.
536 //
537 // Input, int N, the number of points.
538 //
539 // Input, int TABLE[M*N], the table data.
540 //
541 // Output, int TABLE2[(M+2)*(N+2)], the augmented table data.
542 //
543 {
544  int i;
545  int j;
546  int *table2;
547 
548  table2 = new int[(m + 2)*(n + 2)];
549 
550  for (j = 0; j < n + 2; j++) {
551  for (i = 0; i < m + 2; i++) {
552  if (i == 0 || i == m + 1 || j == 0 || j == n + 1) {
553  table2[i + j * (m + 2)] = 0;
554  } else {
555  table2[i + j * (m + 2)] = table[(i - 1)+(j - 1) * m];
556  }
557  }
558  }
559 
560  return table2;
561 }
562 //****************************************************************************80
563 
564 int *i4mat_border_cut(int m, int n, int table[])
565 
566 //****************************************************************************80
567 //
568 // Purpose:
569 //
570 // I4MAT_BORDER_CUT cuts the "border" of an I4MAT.
571 //
572 // Discussion:
573 //
574 // An I4MAT is an array of I4's.
575 //
576 // We suppose the input data gives values of a quantity on nodes
577 // on a 2D grid, and we wish to create a new table corresponding only
578 // to those nodes in the interior of the 2D grid.
579 //
580 // 0 0 0 0 0 0
581 // 0 * * * * 0 * * * *
582 // 0 * * * * 0 -> * * * *
583 // 0 * * * * 0 * * * *
584 // 0 0 0 0 0 0
585 //
586 // The illustration suggests the situation in which a 5 by 6 array
587 // is input, and a 3 by 4 array is to be output.
588 //
589 // Licensing:
590 //
591 // This code is distributed under the GNU LGPL license.
592 //
593 // Modified:
594 //
595 // 25 January 2005
596 //
597 // Author:
598 //
599 // John Burkardt
600 //
601 // Parameters:
602 //
603 // Input, int M, the spatial dimension.
604 //
605 // Input, int N, the number of points.
606 //
607 // Input, int TABLE[M*N], the table data.
608 //
609 // Output, int TABLE2[(M-2)*(N-2)], the "interior" table data.
610 //
611 {
612  int i;
613  int j;
614  int *table2;
615 
616  if (m <= 2 || n <= 2) {
617  return NULL;
618  }
619 
620  table2 = new int[(m - 2)*(n - 2)];
621 
622  for (j = 0; j < n - 2; j++) {
623  for (i = 0; i < m - 2; i++) {
624  table2[i + j * (m - 2)] = table[(i + 1)+(j + 1) * m];
625  }
626  }
627 
628  return table2;
629 }
630 //****************************************************************************80
631 
632 int *i4mat_data_read(string input_filename, int m, int n)
633 
634 //****************************************************************************80
635 //
636 // Purpose:
637 //
638 // I4MAT_DATA_READ reads data from an I4MAT file.
639 //
640 // Discussion:
641 //
642 // An I4MAT is an array of I4's.
643 //
644 // The file is assumed to contain one record per line.
645 //
646 // Records beginning with '#' are comments, and are ignored.
647 // Blank lines are also ignored.
648 //
649 // Each line that is not ignored is assumed to contain exactly (or at least)
650 // M real numbers, representing the coordinates of a point.
651 //
652 // There are assumed to be exactly (or at least) N such records.
653 //
654 // Licensing:
655 //
656 // This code is distributed under the GNU LGPL license.
657 //
658 // Modified:
659 //
660 // 23 February 2009
661 //
662 // Author:
663 //
664 // John Burkardt
665 //
666 // Parameters:
667 //
668 // Input, string INPUT_FILENAME, the name of the input file.
669 //
670 // Input, int M, the number of spatial dimensions.
671 //
672 // Input, int N, the number of points. The program
673 // will stop reading data once N values have been read.
674 //
675 // Output, int I4MAT_DATA_READ[M*N], the table data.
676 //
677 {
678  bool error;
679  ifstream input;
680  int i;
681  int j;
682  string line;
683  int *table;
684  int *x;
685 
686  input.open(input_filename.c_str());
687 
688  if (!input) {
689  cerr << "\n";
690  cerr << "I4MAT_DATA_READ - Fatal error!\n";
691  cerr << " Could not open the input file: \"" << input_filename << "\"\n";
692  return NULL;
693  }
694 
695  table = new int[m * n];
696 
697  x = new int[m];
698 
699  j = 0;
700 
701  while (j < n) {
702  getline(input, line);
703 
704  if (input.eof()) {
705  break;
706  }
707 
708  if (line[0] == '#' || line[0] == '/' || line[0] == '!' || s_len_trim(line) == 0) {
709  continue;
710  }
711 
712  error = s_to_i4vec(line, m, x);
713 
714  if (error) {
715  continue;
716  }
717 
718  for (i = 0; i < m; i++) {
719  // table[i+j*m] = x[i];
720  table[i * n + j] = x[i];
721  }
722  j = j + 1;
723 
724  }
725 
726  input.close();
727 
728  delete [] x;
729 
730  return table;
731 }
732 //****************************************************************************80
733 
734 void i4mat_header_read(string input_filename, int *m, int *n)
735 
736 //****************************************************************************80
737 //
738 // Purpose:
739 //
740 // I4MAT_HEADER_READ reads the header from an I4MAT file.
741 //
742 // Discussion:
743 //
744 // An I4MAT is an array of I4's.
745 //
746 // Licensing:
747 //
748 // This code is distributed under the GNU LGPL license.
749 //
750 // Modified:
751 //
752 // 23 February 2009
753 //
754 // Author:
755 //
756 // John Burkardt
757 //
758 // Parameters:
759 //
760 // Input, string INPUT_FILENAME, the name of the input file.
761 //
762 // Output, int *M, the number of spatial dimensions.
763 //
764 // Output, int *N, the number of points
765 //
766 {
767  *m = file_column_count(input_filename);
768 
769  if (*m <= 0) {
770  cerr << "\n";
771  cerr << "I4MAT_HEADER_READ - Fatal error!\n";
772  cerr << " FILE_COLUMN_COUNT failed.\n";
773  *n = -1;
774  return;
775  }
776 
777  *n = file_row_count(input_filename);
778 
779  if (*n <= 0) {
780  cerr << "\n";
781  cerr << "I4MAT_HEADER_READ - Fatal error!\n";
782  cerr << " FILE_ROW_COUNT failed.\n";
783  return;
784  }
785 
786  return;
787 }
788 //****************************************************************************80
789 
790 int *i4mat_indicator(int m, int n)
791 
792 //****************************************************************************80
793 //
794 // Purpose:
795 //
796 // I4MAT_INDICATOR sets up an "indicator" I4MAT.
797 //
798 // Discussion:
799 //
800 // An I4MAT is an array of I4's.
801 //
802 // The value of each entry suggests its location, as in:
803 //
804 // 11 12 13 14
805 // 21 22 23 24
806 // 31 32 33 34
807 //
808 // Licensing:
809 //
810 // This code is distributed under the GNU LGPL license.
811 //
812 // Modified:
813 //
814 // 25 January 2005
815 //
816 // Author:
817 //
818 // John Burkardt
819 //
820 // Parameters:
821 //
822 // Input, int M, the number of rows of the matrix.
823 // M must be positive.
824 //
825 // Input, int N, the number of columns of the matrix.
826 // N must be positive.
827 //
828 // Output, int TABLE[M*N], the indicator matrix.
829 //
830 {
831  int fac;
832  int i;
833  int j;
834  int *table;
835 
836  table = new int[m * n];
837 
838  fac = (int) pow(10.0, (i4_log_10(n) + 1));
839 
840  for (i = 1; i <= m; i++) {
841  for (j = 1; j <= n; j++) {
842  table[i - 1 + (j - 1) * m] = fac * i + j;
843  }
844  }
845 
846  return table;
847 }
848 //****************************************************************************80
849 
850 void i4mat_print(int m, int n, int a[], string title)
851 
852 //****************************************************************************80
853 //
854 // Purpose:
855 //
856 // I4MAT_PRINT prints an I4MAT, with an optional title.
857 //
858 // Discussion:
859 //
860 // An I4MAT is an array of I4's.
861 //
862 // Licensing:
863 //
864 // This code is distributed under the GNU LGPL license.
865 //
866 // Modified:
867 //
868 // 30 April 2003
869 //
870 // Author:
871 //
872 // John Burkardt
873 //
874 // Parameters:
875 //
876 // Input, int M, the number of rows in A.
877 //
878 // Input, int N, the number of columns in A.
879 //
880 // Input, int A[M*N], the M by N matrix.
881 //
882 // Input, string TITLE, a title to be printed.
883 //
884 {
885 
886  i4mat_print_some(m, n, a, 1, 1, m, n, title);
887 
888  return;
889 }
890 //****************************************************************************80
891 
892 void i4mat_print_some(int m, int n, int a[], int ilo, int jlo, int ihi,
893  int jhi, string title)
894 
895 //****************************************************************************80
896 //
897 // Purpose:
898 //
899 // I4MAT_PRINT_SOME prints some of an I4MAT.
900 //
901 // Discussion:
902 //
903 // An I4MAT is an array of I4's.
904 //
905 // Licensing:
906 //
907 // This code is distributed under the GNU LGPL license.
908 //
909 // Modified:
910 //
911 // 09 April 2004
912 //
913 // Author:
914 //
915 // John Burkardt
916 //
917 // Parameters:
918 //
919 // Input, int M, the number of rows of the matrix.
920 // M must be positive.
921 //
922 // Input, int N, the number of columns of the matrix.
923 // N must be positive.
924 //
925 // Input, int A[M*N], the matrix.
926 //
927 // Input, int ILO, JLO, IHI, JHI, designate the first row and
928 // column, and the last row and column to be printed.
929 //
930 // Input, string TITLE, a title for the matrix.
931 {
932 #define INCX 10
933 
934  int i;
935  int i2hi;
936  int i2lo;
937  int j;
938  int j2hi;
939  int j2lo;
940 
941  if (0 < s_len_trim(title)) {
942  cout << "\n";
943  cout << title << "\n";
944  }
945  //
946  // Print the columns of the matrix, in strips of INCX.
947  //
948  for (j2lo = jlo; j2lo <= jhi; j2lo = j2lo + INCX) {
949  j2hi = j2lo + INCX - 1;
950  j2hi = i4_min(j2hi, n);
951  j2hi = i4_min(j2hi, jhi);
952 
953  cout << "\n";
954  //
955  // For each column J in the current range...
956  //
957  // Write the header.
958  //
959  cout << " Col: ";
960  for (j = j2lo; j <= j2hi; j++) {
961  cout << setw(6) << j << " ";
962  }
963  cout << "\n";
964  cout << " Row\n";
965  cout << " ---\n";
966  //
967  // Determine the range of the rows in this strip.
968  //
969  i2lo = i4_max(ilo, 1);
970  i2hi = i4_min(ihi, m);
971 
972  for (i = i2lo; i <= i2hi; i++) {
973  //
974  // Print out (up to INCX) entries in row I, that lie in the current strip.
975  //
976  cout << setw(5) << i << " ";
977  for (j = j2lo; j <= j2hi; j++) {
978  cout << setw(6) << a[i - 1 + (j - 1) * m] << " ";
979  }
980  cout << "\n";
981  }
982  }
983 
984  return;
985 #undef INCX
986 }
987 //****************************************************************************80
988 
989 int *i4mat_read(string input_filename, int *m, int *n)
990 
991 //****************************************************************************80
992 //
993 // Purpose:
994 //
995 // I4MAT_READ reads the information from an I4MAT file.
996 //
997 // Discussion:
998 //
999 // An I4MAT is an array of I4's.
1000 //
1001 // The file is assumed to contain one record per line.
1002 //
1003 // Records beginning with '#' are comments, and are ignored.
1004 // Blank lines are also ignored.
1005 //
1006 // Each line that is not ignored is assumed to contain exactly (or at least)
1007 // M real numbers, representing the coordinates of a point.
1008 //
1009 // There are assumed to be exactly (or at least) N such records.
1010 //
1011 // Licensing:
1012 //
1013 // This code is distributed under the GNU LGPL license.
1014 //
1015 // Modified:
1016 //
1017 // 23 February 2009
1018 //
1019 // Author:
1020 //
1021 // John Burkardt
1022 //
1023 // Parameters:
1024 //
1025 // Input, string INPUT_FILENAME, the name of the input file.
1026 //
1027 // Output, int *M, the number of spatial dimensions.
1028 //
1029 // Output, int *N, the number of points. The program
1030 // will stop reading data once N values have been read.
1031 //
1032 // Output, int I4MAT_READ[M*N], the table data.
1033 //
1034 {
1035  int *table;
1036 
1037  i4mat_header_read(input_filename, m, n);
1038 
1039  table = i4mat_data_read(input_filename, *m, *n);
1040 
1041  return table;
1042 }
1043 //****************************************************************************80
1044 
1045 void i4mat_write(string output_filename, int m, int n, int table[])
1046 
1047 //****************************************************************************80
1048 //
1049 // Purpose:
1050 //
1051 // I4MAT_WRITE writes an I4MAT file with no header.
1052 //
1053 // Discussion:
1054 //
1055 // An I4MAT is an array of I4's.
1056 //
1057 // Licensing:
1058 //
1059 // This code is distributed under the GNU LGPL license.
1060 //
1061 // Modified:
1062 //
1063 // 01 June 2009
1064 //
1065 // Author:
1066 //
1067 // John Burkardt
1068 //
1069 // Parameters:
1070 //
1071 // Input, string OUTPUT_FILENAME, the output filename.
1072 //
1073 // Input, int M, the spatial dimension.
1074 //
1075 // Input, int N, the number of points.
1076 //
1077 // Input, int TABLE[M*N], the table data.
1078 //
1079 {
1080  int i;
1081  int j;
1082  ofstream output;
1083  //
1084  // Open the file.
1085  //
1086  output.open(output_filename.c_str());
1087 
1088  if (!output) {
1089  cerr << "\n";
1090  cerr << "I4MAT_WRITE - Fatal error!\n";
1091  cerr << " Could not open the output file.\n";
1092  return;
1093  }
1094  //
1095  // Write the data.
1096  //
1097  for (j = 0; j < n; j++) {
1098  for (i = 0; i < m; i++) {
1099  output << " " << setw(10) << table[i + j * m];
1100  }
1101  output << "\n";
1102  }
1103  //
1104  // Close the file.
1105  //
1106  output.close();
1107 
1108  return;
1109 }
1110 //****************************************************************************80
1111 
1112 double *r8mat_data_read(string input_filename, int m, int n)
1113 
1114 //****************************************************************************80
1115 //
1116 // Purpose:
1117 //
1118 // R8MAT_DATA_READ reads the data from an R8MAT file.
1119 //
1120 // Discussion:
1121 //
1122 // An R8MAT is an array of R8's.
1123 //
1124 // The file is assumed to contain one record per line.
1125 //
1126 // Records beginning with '#' are comments, and are ignored.
1127 // Blank lines are also ignored.
1128 //
1129 // Each line that is not ignored is assumed to contain exactly (or at least)
1130 // M real numbers, representing the coordinates of a point.
1131 //
1132 // There are assumed to be exactly (or at least) N such records.
1133 //
1134 // Licensing:
1135 //
1136 // This code is distributed under the GNU LGPL license.
1137 //
1138 // Modified:
1139 //
1140 // 23 February 2009
1141 //
1142 // Author:
1143 //
1144 // John Burkardt
1145 //
1146 // Parameters:
1147 //
1148 // Input, string INPUT_FILENAME, the name of the input file.
1149 //
1150 // Input, int M, the number of spatial dimensions.
1151 //
1152 // Input, int N, the number of points. The program
1153 // will stop reading data once N values have been read.
1154 //
1155 // Output, double R8MAT_DATA_READ[M*N], the table data.
1156 //
1157 {
1158  bool error;
1159  ifstream input;
1160  int i;
1161  int j;
1162  string line;
1163  double *table;
1164  double *x;
1165 
1166  input.open(input_filename.c_str());
1167 
1168  if (!input) {
1169  cerr << "\n";
1170  cerr << "R8MAT_DATA_READ - Fatal error!\n";
1171  cerr << " Could not open the input file: \"" << input_filename << "\"\n";
1172  return NULL;
1173  }
1174 
1175  table = new double[m * n];
1176 
1177  x = new double[m];
1178 
1179  j = 0;
1180 
1181  while (j < n) {
1182  getline(input, line);
1183 
1184  if (input.eof()) {
1185  break;
1186  }
1187 
1188  if (line[0] == '#' || line[0] == '/' || line[0] == '!' || s_len_trim(line) == 0) {
1189  continue;
1190  }
1191 
1192  error = s_to_r8vec(line, m, x);
1193 
1194  if (error) {
1195  continue;
1196  }
1197 
1198  for (i = 0; i < m; i++) {
1199  // table[i+j*m] = x[i];
1200  table[i * n + j] = x[i];
1201  }
1202  j = j + 1;
1203 
1204  }
1205 
1206  input.close();
1207 
1208  delete [] x;
1209 
1210  return table;
1211 }
1212 //****************************************************************************80
1213 
1214 float *r4mat_data_read(string input_filename, int m, int n)
1215 
1216 //****************************************************************************80
1217 //
1218 // Purpose:
1219 //
1220 // R8MAT_DATA_READ reads the data from an R8MAT file.
1221 //
1222 // Discussion:
1223 //
1224 // An R8MAT is an array of R8's.
1225 //
1226 // The file is assumed to contain one record per line.
1227 //
1228 // Records beginning with '#' are comments, and are ignored.
1229 // Blank lines are also ignored.
1230 //
1231 // Each line that is not ignored is assumed to contain exactly (or at least)
1232 // M real numbers, representing the coordinates of a point.
1233 //
1234 // There are assumed to be exactly (or at least) N such records.
1235 //
1236 // Licensing:
1237 //
1238 // This code is distributed under the GNU LGPL license.
1239 //
1240 // Modified:
1241 //
1242 // 23 February 2009
1243 //
1244 // Author:
1245 //
1246 // John Burkardt
1247 //
1248 // Parameters:
1249 //
1250 // Input, string INPUT_FILENAME, the name of the input file.
1251 //
1252 // Input, int M, the number of spatial dimensions.
1253 //
1254 // Input, int N, the number of points. The program
1255 // will stop reading data once N values have been read.
1256 //
1257 // Output, double R8MAT_DATA_READ[M*N], the table data.
1258 //
1259 {
1260  bool error;
1261  ifstream input;
1262  int i;
1263  int j;
1264  string line;
1265  float *table;
1266  double *x;
1267 
1268  input.open(input_filename.c_str());
1269 
1270  if (!input) {
1271  cerr << "\n";
1272  cerr << "R8MAT_DATA_READ - Fatal error!\n";
1273  cerr << " Could not open the input file: \"" << input_filename << "\"\n";
1274  return NULL;
1275  }
1276 
1277  table = new float[m * n];
1278 
1279  x = new double[m];
1280 
1281  j = 0;
1282 
1283  while (j < n) {
1284  getline(input, line);
1285 
1286  if (input.eof()) {
1287  break;
1288  }
1289 
1290  if (line[0] == '#' || line[0] == '/' || line[0] == '!' || s_len_trim(line) == 0) {
1291  continue;
1292  }
1293 
1294  error = s_to_r8vec(line, m, x);
1295 
1296  if (error) {
1297  continue;
1298  }
1299 
1300  for (i = 0; i < m; i++) {
1301  // table[i+j*m] = x[i];
1302  table[i * n + j] = x[i];
1303  }
1304  j = j + 1;
1305 
1306  }
1307 
1308  input.close();
1309 
1310  delete [] x;
1311 
1312  return table;
1313 }
1314 //****************************************************************************80
1315 
1316 void r8mat_header_read(string input_filename, int *m, int *n)
1317 
1318 //****************************************************************************80
1319 //
1320 // Purpose:
1321 //
1322 // R8MAT_HEADER_READ reads the header from an R8MAT file.
1323 //
1324 // Discussion:
1325 //
1326 // An R8MAT is an array of R8's.
1327 //
1328 // Licensing:
1329 //
1330 // This code is distributed under the GNU LGPL license.
1331 //
1332 // Modified:
1333 //
1334 // 23 February 2009
1335 //
1336 // Author:
1337 //
1338 // John Burkardt
1339 //
1340 // Parameters:
1341 //
1342 // Input, string INPUT_FILENAME, the name of the input file.
1343 //
1344 // Output, int *M, the number of spatial dimensions.
1345 //
1346 // Output, int *N, the number of points.
1347 //
1348 {
1349  *m = file_column_count(input_filename);
1350 
1351  if (*m <= 0) {
1352  cerr << "\n";
1353  cerr << "R8MAT_HEADER_READ - Fatal error!\n";
1354  cerr << " FILE_COLUMN_COUNT failed.\n";
1355  *n = -1;
1356  return;
1357  }
1358 
1359  *n = file_row_count(input_filename);
1360 
1361  if (*n <= 0) {
1362  cerr << "\n";
1363  cerr << "R8MAT_HEADER_READ - Fatal error!\n";
1364  cerr << " FILE_ROW_COUNT failed.\n";
1365  return;
1366  }
1367 
1368  return;
1369 }
1370 //****************************************************************************80
1371 
1372 double *r8mat_indicator(int m, int n)
1373 
1374 //****************************************************************************80
1375 //
1376 // Purpose:
1377 //
1378 // R8MAT_INDICATOR sets up an "indicator" R8MAT.
1379 //
1380 // Discussion:
1381 //
1382 // An R8MAT is an array of R8's.
1383 //
1384 // The value of each entry suggests its location, as in:
1385 //
1386 // 11 12 13 14
1387 // 21 22 23 24
1388 // 31 32 33 34
1389 //
1390 // Licensing:
1391 //
1392 // This code is distributed under the GNU LGPL license.
1393 //
1394 // Modified:
1395 //
1396 // 25 January 2005
1397 //
1398 // Author:
1399 //
1400 // John Burkardt
1401 //
1402 // Parameters:
1403 //
1404 // Input, int M, the number of rows of the matrix.
1405 // M must be positive.
1406 //
1407 // Input, int N, the number of columns of the matrix.
1408 // N must be positive.
1409 //
1410 // Output, double TABLE[M*N], the indicator matrix.
1411 //
1412 {
1413  int fac;
1414  int i;
1415  int j;
1416  double *table;
1417 
1418  table = new double[m * n];
1419 
1420  fac = (int) pow(10.0, (i4_log_10(n) + 1));
1421 
1422  for (i = 1; i <= m; i++) {
1423  for (j = 1; j <= n; j++) {
1424  table[i - 1 + (j - 1) * m] = (double) (fac * i + j);
1425  }
1426  }
1427 
1428  return table;
1429 }
1430 //****************************************************************************80
1431 
1432 void r8mat_print(int m, int n, double a[], string title)
1433 
1434 //****************************************************************************80
1435 //
1436 // Purpose:
1437 //
1438 // R8MAT_PRINT prints an R8MAT, with an optional title.
1439 //
1440 // Discussion:
1441 //
1442 // An R8MAT is an array of R8's.
1443 //
1444 // Licensing:
1445 //
1446 // This code is distributed under the GNU LGPL license.
1447 //
1448 // Modified:
1449 //
1450 // 29 August 2003
1451 //
1452 // Author:
1453 //
1454 // John Burkardt
1455 //
1456 // Parameters:
1457 //
1458 // Input, int M, the number of rows in A.
1459 //
1460 // Input, int N, the number of columns in A.
1461 //
1462 // Input, double A[M*N], the M by N matrix.
1463 //
1464 // Input, string TITLE, a title to be printed.
1465 //
1466 {
1467  r8mat_print_some(m, n, a, 1, 1, m, n, title);
1468 
1469  return;
1470 }
1471 //****************************************************************************80
1472 
1473 void r8mat_print_some(int m, int n, double a[], int ilo, int jlo, int ihi,
1474  int jhi, string title)
1475 
1476 //****************************************************************************80
1477 //
1478 // Purpose:
1479 //
1480 // R8MAT_PRINT_SOME prints some of an R8MAT.
1481 //
1482 // Discussion:
1483 //
1484 // An R8MAT is an array of R8's.
1485 //
1486 // Licensing:
1487 //
1488 // This code is distributed under the GNU LGPL license.
1489 //
1490 // Modified:
1491 //
1492 // 09 April 2004
1493 //
1494 // Author:
1495 //
1496 // John Burkardt
1497 //
1498 // Parameters:
1499 //
1500 // Input, int M, the number of rows of the matrix.
1501 // M must be positive.
1502 //
1503 // Input, int N, the number of columns of the matrix.
1504 // N must be positive.
1505 //
1506 // Input, double A[M*N], the matrix.
1507 //
1508 // Input, int ILO, JLO, IHI, JHI, designate the first row and
1509 // column, and the last row and column to be printed.
1510 //
1511 // Input, string TITLE, a title for the matrix.
1512 {
1513 #define INCX 5
1514 
1515  int i;
1516  int i2hi;
1517  int i2lo;
1518  int j;
1519  int j2hi;
1520  int j2lo;
1521 
1522  if (0 < s_len_trim(title)) {
1523  cout << "\n";
1524  cout << title << "\n";
1525  }
1526  //
1527  // Print the columns of the matrix, in strips of 5.
1528  //
1529  for (j2lo = jlo; j2lo <= jhi; j2lo = j2lo + INCX) {
1530  j2hi = j2lo + INCX - 1;
1531  j2hi = i4_min(j2hi, n);
1532  j2hi = i4_min(j2hi, jhi);
1533 
1534  cout << "\n";
1535  //
1536  // For each column J in the current range...
1537  //
1538  // Write the header.
1539  //
1540  cout << " Col: ";
1541  for (j = j2lo; j <= j2hi; j++) {
1542  cout << setw(7) << j << " ";
1543  }
1544  cout << "\n";
1545  cout << " Row\n";
1546  cout << " ---\n";
1547  //
1548  // Determine the range of the rows in this strip.
1549  //
1550  i2lo = i4_max(ilo, 1);
1551  i2hi = i4_min(ihi, m);
1552 
1553  for (i = i2lo; i <= i2hi; i++) {
1554  //
1555  // Print out (up to) 5 entries in row I, that lie in the current strip.
1556  //
1557  cout << setw(5) << i << " ";
1558  for (j = j2lo; j <= j2hi; j++) {
1559  cout << setw(12) << a[i - 1 + (j - 1) * m] << " ";
1560  }
1561  cout << "\n";
1562  }
1563 
1564  }
1565 
1566  return;
1567 #undef INCX
1568 }
1569 //****************************************************************************80
1570 
1571 double *r8mat_read(string input_filename, int *m, int *n)
1572 
1573 //****************************************************************************80
1574 //
1575 // Purpose:
1576 //
1577 // R8MAT_READ reads information from an R8MAT file.
1578 //
1579 // Discussion:
1580 //
1581 // An R8MAT is an array of R8's.
1582 //
1583 // The file is assumed to contain one record per line.
1584 //
1585 // Records beginning with '#' are comments, and are ignored.
1586 // Blank lines are also ignored.
1587 //
1588 // Each line that is not ignored is assumed to contain exactly (or at least)
1589 // M real numbers, representing the coordinates of a point.
1590 //
1591 // There are assumed to be exactly (or at least) N such records.
1592 //
1593 // Licensing:
1594 //
1595 // This code is distributed under the GNU LGPL license.
1596 //
1597 // Modified:
1598 //
1599 // 23 February 2009
1600 //
1601 // Author:
1602 //
1603 // John Burkardt
1604 //
1605 // Parameters:
1606 //
1607 // Input, string INPUT_FILENAME, the name of the input file.
1608 //
1609 // Output, int *M, the number of spatial dimensions.
1610 //
1611 // Output, int *N, the number of points. The program
1612 // will stop reading data once N values have been read.
1613 //
1614 // Output, double R8MAT_READ[M*N], the table data.
1615 //
1616 {
1617  double *table;
1618 
1619  r8mat_header_read(input_filename, m, n);
1620 
1621  table = r8mat_data_read(input_filename, *m, *n);
1622 
1623  return table;
1624 }
1625 //****************************************************************************80
1626 
1627 void r8mat_transpose_print(int m, int n, double a[], string title)
1628 
1629 //****************************************************************************80
1630 //
1631 // Purpose:
1632 //
1633 // R8MAT_TRANSPOSE_PRINT prints an R8MAT, transposed.
1634 //
1635 // Discussion:
1636 //
1637 // An R8MAT is an array of R8's.
1638 //
1639 // Licensing:
1640 //
1641 // This code is distributed under the GNU LGPL license.
1642 //
1643 // Modified:
1644 //
1645 // 11 August 2004
1646 //
1647 // Author:
1648 //
1649 // John Burkardt
1650 //
1651 // Parameters:
1652 //
1653 // Input, int M, N, the number of rows and columns.
1654 //
1655 // Input, double A[M*N], an M by N matrix to be printed.
1656 //
1657 // Input, string TITLE, an optional title.
1658 //
1659 {
1660  r8mat_transpose_print_some(m, n, a, 1, 1, m, n, title);
1661 
1662  return;
1663 }
1664 //****************************************************************************80
1665 
1666 void r8mat_transpose_print_some(int m, int n, double a[], int ilo, int jlo,
1667  int ihi, int jhi, string title)
1668 
1669 //****************************************************************************80
1670 //
1671 // Purpose:
1672 //
1673 // R8MAT_TRANSPOSE_PRINT_SOME prints some of an R8MAT, transposed.
1674 //
1675 // Discussion:
1676 //
1677 // An R8MAT is an array of R8's.
1678 //
1679 // Licensing:
1680 //
1681 // This code is distributed under the GNU LGPL license.
1682 //
1683 // Modified:
1684 //
1685 // 11 August 2004
1686 //
1687 // Author:
1688 //
1689 // John Burkardt
1690 //
1691 // Parameters:
1692 //
1693 // Input, int M, N, the number of rows and columns.
1694 //
1695 // Input, double A[M*N], an M by N matrix to be printed.
1696 //
1697 // Input, int ILO, JLO, the first row and column to print.
1698 //
1699 // Input, int IHI, JHI, the last row and column to print.
1700 //
1701 // Input, string TITLE, an optional title.
1702 //
1703 {
1704 #define INCX 5
1705 
1706  int i;
1707  int i2;
1708  int i2hi;
1709  int i2lo;
1710  int inc;
1711  int j;
1712  int j2hi;
1713  int j2lo;
1714 
1715  if (0 < s_len_trim(title)) {
1716  cout << "\n";
1717  cout << title << "\n";
1718  }
1719 
1720  for (i2lo = i4_max(ilo, 1); i2lo <= i4_min(ihi, m); i2lo = i2lo + INCX) {
1721  i2hi = i2lo + INCX - 1;
1722  i2hi = i4_min(i2hi, m);
1723  i2hi = i4_min(i2hi, ihi);
1724 
1725  inc = i2hi + 1 - i2lo;
1726 
1727  cout << "\n";
1728  cout << " Row: ";
1729  for (i = i2lo; i <= i2hi; i++) {
1730  cout << setw(7) << i << " ";
1731  }
1732  cout << "\n";
1733  cout << " Col\n";
1734 
1735  j2lo = i4_max(jlo, 1);
1736  j2hi = i4_min(jhi, n);
1737 
1738  for (j = j2lo; j <= j2hi; j++) {
1739  cout << setw(5) << j << " ";
1740  for (i2 = 1; i2 <= inc; i2++) {
1741  i = i2lo - 1 + i2;
1742  cout << setw(14) << a[(i - 1)+(j - 1) * m];
1743  }
1744  cout << "\n";
1745  }
1746  }
1747 
1748  return;
1749 #undef INCX
1750 }
1751 //****************************************************************************80
1752 
1753 double *r8mat_uniform_01(int m, int n, int *seed)
1754 
1755 //****************************************************************************80
1756 //
1757 // Purpose:
1758 //
1759 // R8MAT_UNIFORM_01 returns a unit pseudorandom R8MAT.
1760 //
1761 // Discussion:
1762 //
1763 // An R8MAT is an array of R8's.
1764 //
1765 // This routine implements the recursion
1766 //
1767 // seed = 16807 * seed mod ( 2**31 - 1 )
1768 // unif = seed / ( 2**31 - 1 )
1769 //
1770 // The integer arithmetic never requires more than 32 bits,
1771 // including a sign bit.
1772 //
1773 // Licensing:
1774 //
1775 // This code is distributed under the GNU LGPL license.
1776 //
1777 // Modified:
1778 //
1779 // 03 October 2005
1780 //
1781 // Author:
1782 //
1783 // John Burkardt
1784 //
1785 // Reference:
1786 //
1787 // Paul Bratley, Bennett Fox, Linus Schrage,
1788 // A Guide to Simulation,
1789 // Springer Verlag, pages 201-202, 1983.
1790 //
1791 // Bennett Fox,
1792 // Algorithm 647:
1793 // Implementation and Relative Efficiency of Quasirandom
1794 // Sequence Generators,
1795 // ACM Transactions on Mathematical Software,
1796 // Volume 12, Number 4, pages 362-376, 1986.
1797 //
1798 // Peter Lewis, Allen Goodman, James Miller,
1799 // A Pseudo-Random Number Generator for the System/360,
1800 // IBM Systems Journal,
1801 // Volume 8, pages 136-143, 1969.
1802 //
1803 // Parameters:
1804 //
1805 // Input, int M, N, the number of rows and columns.
1806 //
1807 // Input/output, int *SEED, the "seed" value. Normally, this
1808 // value should not be 0. On output, SEED has
1809 // been updated.
1810 //
1811 // Output, double R8MAT_UNIFORM_01[M*N], a matrix of pseudorandom values.
1812 //
1813 {
1814  int i;
1815  int j;
1816  int k;
1817  double *r;
1818 
1819  if (*seed == 0) {
1820  cerr << "\n";
1821  cerr << "R8MAT_UNIFORM_01 - Fatal error!\n";
1822  cerr << " Input value of SEED = 0.\n";
1823  exit(1);
1824  }
1825 
1826  r = new double[m * n];
1827 
1828  for (j = 0; j < n; j++) {
1829  for (i = 0; i < m; i++) {
1830  k = *seed / 127773;
1831 
1832  *seed = 16807 * (*seed - k * 127773) - k * 2836;
1833 
1834  if (*seed < 0) {
1835  *seed = *seed + 2147483647;
1836  }
1837 
1838  r[i + j * m] = (double) (*seed) * 4.656612875E-10;
1839  }
1840  }
1841 
1842  return r;
1843 }
1844 //****************************************************************************80
1845 
1846 void r8mat_write(string output_filename, int m, int n, double table[])
1847 
1848 //****************************************************************************80
1849 //
1850 // Purpose:
1851 //
1852 // R8MAT_WRITE writes an R8MAT file.
1853 //
1854 // Discussion:
1855 //
1856 // An R8MAT is an array of R8's.
1857 //
1858 // Licensing:
1859 //
1860 // This code is distributed under the GNU LGPL license.
1861 //
1862 // Modified:
1863 //
1864 // 29 June 2009
1865 //
1866 // Author:
1867 //
1868 // John Burkardt
1869 //
1870 // Parameters:
1871 //
1872 // Input, string OUTPUT_FILENAME, the output filename.
1873 //
1874 // Input, int M, the spatial dimension.
1875 //
1876 // Input, int N, the number of points.
1877 //
1878 // Input, double TABLE[M*N], the table data.
1879 //
1880 {
1881  int i;
1882  int j;
1883  ofstream output;
1884  //
1885  // Open the file.
1886  //
1887  output.open(output_filename.c_str());
1888 
1889  if (!output) {
1890  cerr << "\n";
1891  cerr << "R8MAT_WRITE - Fatal error!\n";
1892  cerr << " Could not open the output file.\n";
1893  return;
1894  }
1895  //
1896  // Write the data.
1897  //
1898  for (j = 0; j < n; j++) {
1899  for (i = 0; i < m; i++) {
1900  output << " " << setw(24) << setprecision(16) << table[i + j * m];
1901  }
1902  output << "\n";
1903  }
1904  //
1905  // Close the file.
1906  //
1907  output.close();
1908 
1909  return;
1910 }
1911 //****************************************************************************80
1912 
1913 int s_len_trim(string s)
1914 
1915 //****************************************************************************80
1916 //
1917 // Purpose:
1918 //
1919 // S_LEN_TRIM returns the length of a string to the last nonblank.
1920 //
1921 // Licensing:
1922 //
1923 // This code is distributed under the GNU LGPL license.
1924 //
1925 // Modified:
1926 //
1927 // 05 July 2009
1928 //
1929 // Author:
1930 //
1931 // John Burkardt
1932 //
1933 // Parameters:
1934 //
1935 // Input, string S, a string.
1936 //
1937 // Output, int S_LEN_TRIM, the length of the string to the last nonblank.
1938 // If S_LEN_TRIM is 0, then the string is entirely blank.
1939 //
1940 {
1941  int n;
1942 
1943  n = s.length();
1944 
1945  while (0 < n) {
1946  if (s[n - 1] != ' ') {
1947  return n;
1948  }
1949  n = n - 1;
1950  }
1951 
1952  return n;
1953 }
1954 //****************************************************************************80
1955 
1956 int s_to_i4(string s, int *last, bool *error)
1957 
1958 //****************************************************************************80
1959 //
1960 // Purpose:
1961 //
1962 // S_TO_I4 reads an I4 from a string.
1963 //
1964 // Licensing:
1965 //
1966 // This code is distributed under the GNU LGPL license.
1967 //
1968 // Modified:
1969 //
1970 // 05 July 2009
1971 //
1972 // Author:
1973 //
1974 // John Burkardt
1975 //
1976 // Parameters:
1977 //
1978 // Input, string S, a string to be examined.
1979 //
1980 // Output, int *LAST, the last character of S used to make IVAL.
1981 //
1982 // Output, bool *ERROR is TRUE if an error occurred.
1983 //
1984 // Output, int *S_TO_I4, the integer value read from the string.
1985 // If the string is blank, then IVAL will be returned 0.
1986 //
1987 {
1988  char c;
1989  int i;
1990  int isgn;
1991  int istate;
1992  int ival;
1993 
1994  *error = false;
1995  istate = 0;
1996  isgn = 1;
1997  i = 0;
1998  ival = 0;
1999 
2000  for (;;) {
2001  c = s[i];
2002  i = i + 1;
2003  //
2004  // Haven't read anything.
2005  //
2006  if (istate == 0) {
2007  if (c == ' ') {
2008  } else if (c == '-') {
2009  istate = 1;
2010  isgn = -1;
2011  } else if (c == '+') {
2012  istate = 1;
2013  isgn = +1;
2014  } else if ('0' <= c && c <= '9') {
2015  istate = 2;
2016  ival = c - '0';
2017  } else {
2018  *error = true;
2019  return ival;
2020  }
2021  } //
2022  // Have read the sign, expecting digits.
2023  //
2024  else if (istate == 1) {
2025  if (c == ' ') {
2026  } else if ('0' <= c && c <= '9') {
2027  istate = 2;
2028  ival = c - '0';
2029  } else {
2030  *error = true;
2031  return ival;
2032  }
2033  } //
2034  // Have read at least one digit, expecting more.
2035  //
2036  else if (istate == 2) {
2037  if ('0' <= c && c <= '9') {
2038  ival = 10 * (ival) + c - '0';
2039  } else {
2040  ival = isgn * ival;
2041  *last = i - 1;
2042  return ival;
2043  }
2044 
2045  }
2046  }
2047  //
2048  // If we read all the characters in the string, see if we're OK.
2049  //
2050  if (istate == 2) {
2051  ival = isgn * ival;
2052  *last = s_len_trim(s);
2053  } else {
2054  *error = true;
2055  *last = 0;
2056  }
2057 
2058  return ival;
2059 }
2060 //****************************************************************************80
2061 
2062 bool s_to_i4vec(string s, int n, int ivec[])
2063 
2064 //****************************************************************************80
2065 //
2066 // Purpose:
2067 //
2068 // S_TO_I4VEC reads an I4VEC from a string.
2069 //
2070 // Licensing:
2071 //
2072 // This code is distributed under the GNU LGPL license.
2073 //
2074 // Modified:
2075 //
2076 // 05 July 2009
2077 //
2078 // Author:
2079 //
2080 // John Burkardt
2081 //
2082 // Parameters:
2083 //
2084 // Input, string S, the string to be read.
2085 //
2086 // Input, int N, the number of values expected.
2087 //
2088 // Output, int IVEC[N], the values read from the string.
2089 //
2090 // Output, bool S_TO_I4VEC, is TRUE if an error occurred.
2091 //
2092 {
2093  int begin;
2094  bool error;
2095  int i;
2096  int lchar;
2097  int length;
2098 
2099  begin = 0;
2100  length = s.length();
2101  error = 0;
2102 
2103  for (i = 0; i < n; i++) {
2104  ivec[i] = s_to_i4(s.substr(begin, length), &lchar, &error);
2105 
2106  if (error) {
2107  return error;
2108  }
2109  begin = begin + lchar;
2110  length = length - lchar;
2111  }
2112 
2113  return error;
2114 }
2115 //****************************************************************************80
2116 
2117 double s_to_r8(string s, int *lchar, bool *error)
2118 
2119 //****************************************************************************80
2120 //
2121 // Purpose:
2122 //
2123 // S_TO_R8 reads an R8 from a string.
2124 //
2125 // Discussion:
2126 //
2127 // This routine will read as many characters as possible until it reaches
2128 // the end of the string, or encounters a character which cannot be
2129 // part of the real number.
2130 //
2131 // Legal input is:
2132 //
2133 // 1 blanks,
2134 // 2 '+' or '-' sign,
2135 // 2.5 spaces
2136 // 3 integer part,
2137 // 4 decimal point,
2138 // 5 fraction part,
2139 // 6 'E' or 'e' or 'D' or 'd', exponent marker,
2140 // 7 exponent sign,
2141 // 8 exponent integer part,
2142 // 9 exponent decimal point,
2143 // 10 exponent fraction part,
2144 // 11 blanks,
2145 // 12 final comma or semicolon.
2146 //
2147 // with most quantities optional.
2148 //
2149 // Example:
2150 //
2151 // S R
2152 //
2153 // '1' 1.0
2154 // ' 1 ' 1.0
2155 // '1A' 1.0
2156 // '12,34,56' 12.0
2157 // ' 34 7' 34.0
2158 // '-1E2ABCD' -100.0
2159 // '-1X2ABCD' -1.0
2160 // ' 2E-1' 0.2
2161 // '23.45' 23.45
2162 // '-4.2E+2' -420.0
2163 // '17d2' 1700.0
2164 // '-14e-2' -0.14
2165 // 'e2' 100.0
2166 // '-12.73e-9.23' -12.73 * 10.0**(-9.23)
2167 //
2168 // Licensing:
2169 //
2170 // This code is distributed under the GNU LGPL license.
2171 //
2172 // Modified:
2173 //
2174 // 05 July 2009
2175 //
2176 // Author:
2177 //
2178 // John Burkardt
2179 //
2180 // Parameters:
2181 //
2182 // Input, string S, the string containing the
2183 // data to be read. Reading will begin at position 1 and
2184 // terminate at the end of the string, or when no more
2185 // characters can be read to form a legal real. Blanks,
2186 // commas, or other nonnumeric data will, in particular,
2187 // cause the conversion to halt.
2188 //
2189 // Output, int *LCHAR, the number of characters read from
2190 // the string to form the number, including any terminating
2191 // characters such as a trailing comma or blanks.
2192 //
2193 // Output, bool *ERROR, is true if an error occurred.
2194 //
2195 // Output, double S_TO_R8, the real value that was read from the string.
2196 //
2197 {
2198  char c;
2199  int ihave;
2200  int isgn;
2201  int iterm;
2202  int jbot;
2203  int jsgn;
2204  int jtop;
2205  int nchar;
2206  int ndig;
2207  double r;
2208  double rbot;
2209  double rexp;
2210  double rtop;
2211  char TAB = 9;
2212 
2213  nchar = s_len_trim(s);
2214  *error = false;
2215  r = 0.0;
2216  *lchar = -1;
2217  isgn = 1;
2218  rtop = 0.0;
2219  rbot = 1.0;
2220  jsgn = 1;
2221  jtop = 0;
2222  jbot = 1;
2223  ihave = 1;
2224  iterm = 0;
2225 
2226  for (;;) {
2227  c = s[*lchar + 1];
2228  *lchar = *lchar + 1;
2229  //
2230  // Blank or TAB character.
2231  //
2232  if (c == ' ' || c == TAB) {
2233  if (ihave == 2) {
2234  } else if (ihave == 6 || ihave == 7) {
2235  iterm = 1;
2236  } else if (1 < ihave) {
2237  ihave = 11;
2238  }
2239  } //
2240  // Comma.
2241  //
2242  else if (c == ',' || c == ';') {
2243  if (ihave != 1) {
2244  iterm = 1;
2245  ihave = 12;
2246  *lchar = *lchar + 1;
2247  }
2248  } //
2249  // Minus sign.
2250  //
2251  else if (c == '-') {
2252  if (ihave == 1) {
2253  ihave = 2;
2254  isgn = -1;
2255  } else if (ihave == 6) {
2256  ihave = 7;
2257  jsgn = -1;
2258  } else {
2259  iterm = 1;
2260  }
2261  } //
2262  // Plus sign.
2263  //
2264  else if (c == '+') {
2265  if (ihave == 1) {
2266  ihave = 2;
2267  } else if (ihave == 6) {
2268  ihave = 7;
2269  } else {
2270  iterm = 1;
2271  }
2272  } //
2273  // Decimal point.
2274  //
2275  else if (c == '.') {
2276  if (ihave < 4) {
2277  ihave = 4;
2278  } else if (6 <= ihave && ihave <= 8) {
2279  ihave = 9;
2280  } else {
2281  iterm = 1;
2282  }
2283  } //
2284  // Exponent marker.
2285  //
2286  else if (ch_eqi(c, 'E') || ch_eqi(c, 'D')) {
2287  if (ihave < 6) {
2288  ihave = 6;
2289  } else {
2290  iterm = 1;
2291  }
2292  } //
2293  // Digit.
2294  //
2295  else if (ihave < 11 && '0' <= c && c <= '9') {
2296  if (ihave <= 2) {
2297  ihave = 3;
2298  } else if (ihave == 4) {
2299  ihave = 5;
2300  } else if (ihave == 6 || ihave == 7) {
2301  ihave = 8;
2302  } else if (ihave == 9) {
2303  ihave = 10;
2304  }
2305 
2306  ndig = ch_to_digit(c);
2307 
2308  if (ihave == 3) {
2309  rtop = 10.0 * rtop + (double) ndig;
2310  } else if (ihave == 5) {
2311  rtop = 10.0 * rtop + (double) ndig;
2312  rbot = 10.0 * rbot;
2313  } else if (ihave == 8) {
2314  jtop = 10 * jtop + ndig;
2315  } else if (ihave == 10) {
2316  jtop = 10 * jtop + ndig;
2317  jbot = 10 * jbot;
2318  }
2319 
2320  } //
2321  // Anything else is regarded as a terminator.
2322  //
2323  else {
2324  iterm = 1;
2325  }
2326  //
2327  // If we haven't seen a terminator, and we haven't examined the
2328  // entire string, go get the next character.
2329  //
2330  if (iterm == 1 || nchar <= *lchar + 1) {
2331  break;
2332  }
2333 
2334  }
2335  //
2336  // If we haven't seen a terminator, and we have examined the
2337  // entire string, then we're done, and LCHAR is equal to NCHAR.
2338  //
2339  if (iterm != 1 && (*lchar) + 1 == nchar) {
2340  *lchar = nchar;
2341  }
2342  //
2343  // Number seems to have terminated. Have we got a legal number?
2344  // Not if we terminated in states 1, 2, 6 or 7!
2345  //
2346  if (ihave == 1 || ihave == 2 || ihave == 6 || ihave == 7) {
2347  *error = true;
2348  return r;
2349  }
2350  //
2351  // Number seems OK. Form it.
2352  //
2353  if (jtop == 0) {
2354  rexp = 1.0;
2355  } else {
2356  if (jbot == 1) {
2357  rexp = pow(10.0, jsgn * jtop);
2358  } else {
2359  rexp = jsgn * jtop;
2360  rexp = rexp / jbot;
2361  rexp = pow(10.0, rexp);
2362  }
2363 
2364  }
2365 
2366  r = isgn * rexp * rtop / rbot;
2367 
2368  return r;
2369 }
2370 //****************************************************************************80
2371 
2372 bool s_to_r8vec(string s, int n, double rvec[])
2373 
2374 //****************************************************************************80
2375 //
2376 // Purpose:
2377 //
2378 // S_TO_R8VEC reads an R8VEC from a string.
2379 //
2380 // Licensing:
2381 //
2382 // This code is distributed under the GNU LGPL license.
2383 //
2384 // Modified:
2385 //
2386 // 05 July 2009
2387 //
2388 // Author:
2389 //
2390 // John Burkardt
2391 //
2392 // Parameters:
2393 //
2394 // Input, string S, the string to be read.
2395 //
2396 // Input, int N, the number of values expected.
2397 //
2398 // Output, double RVEC[N], the values read from the string.
2399 //
2400 // Output, bool S_TO_R8VEC, is true if an error occurred.
2401 //
2402 {
2403  int begin;
2404  bool error;
2405  int i;
2406  int lchar;
2407  int length;
2408 
2409  begin = 0;
2410  length = s.length();
2411  error = 0;
2412 
2413  for (i = 0; i < n; i++) {
2414  rvec[i] = s_to_r8(s.substr(begin, length), &lchar, &error);
2415 
2416  if (error) {
2417  return error;
2418  }
2419  begin = begin + lchar;
2420  length = length - lchar;
2421  }
2422 
2423  return error;
2424 }
2425 //****************************************************************************80
2426 
2427 int s_word_count(string s)
2428 
2429 //****************************************************************************80
2430 //
2431 // Purpose:
2432 //
2433 // S_WORD_COUNT counts the number of "words" in a string.
2434 //
2435 // Licensing:
2436 //
2437 // This code is distributed under the GNU LGPL license.
2438 //
2439 // Modified:
2440 //
2441 // 05 July 2009
2442 //
2443 // Author:
2444 //
2445 // John Burkardt
2446 //
2447 // Parameters:
2448 //
2449 // Input, string S, the string to be examined.
2450 //
2451 // Output, int S_WORD_COUNT, the number of "words" in the string.
2452 // Words are presumed to be separated by one or more blanks.
2453 //
2454 {
2455  bool blank;
2456  int char_count;
2457  int i;
2458  int word_count;
2459 
2460  word_count = 0;
2461  blank = true;
2462 
2463  char_count = s.length();
2464 
2465  for (i = 0; i < char_count; i++) {
2466  if (isspace(s[i]) || s[i] == ',') {
2467  blank = true;
2468  } else if (blank) {
2469  word_count = word_count + 1;
2470  blank = false;
2471  }
2472  }
2473 
2474  return word_count;
2475 }
2476 //****************************************************************************80
2477 
2479 
2480 //****************************************************************************80
2481 //
2482 // Purpose:
2483 //
2484 // TIMESTAMP prints the current YMDHMS date as a time stamp.
2485 //
2486 // Example:
2487 //
2488 // 31 May 2001 09:45:54 AM
2489 //
2490 // Licensing:
2491 //
2492 // This code is distributed under the GNU LGPL license.
2493 //
2494 // Modified:
2495 //
2496 // 08 July 2009
2497 //
2498 // Author:
2499 //
2500 // John Burkardt
2501 //
2502 // Parameters:
2503 //
2504 // None
2505 //
2506 {
2507 #define TIME_SIZE 40
2508 
2509  static char time_buffer[TIME_SIZE];
2510  const struct std::tm *tm_ptr;
2511  std::time_t now;
2512 
2513  now = std::time(NULL);
2514  tm_ptr = std::localtime(&now);
2515 
2516  std::strftime(time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr);
2517 
2518  std::cout << time_buffer << "\n";
2519 
2520  return;
2521 #undef TIME_SIZE
2522 }
2523 
2524 extern "C" int table_column_count(char *input_filename) {
2525  return (file_column_count(input_filename));
2526 }
2527 
2528 extern "C" int table_row_count(char *input_filename) {
2529  return (file_row_count(input_filename));
2530 }
2531 
2532 extern "C" int *table_read_i4(char *input_filename, int m, int n) {
2533  return (i4mat_data_read(input_filename, m, n));
2534 }
2535 
2536 extern "C" double *table_read_r8(char *input_filename, int m, int n) {
2537  return (r8mat_data_read(input_filename, m, n));
2538 }
2539 
2540 extern "C" float *table_read_r4(char *input_filename, int m, int n) {
2541  return (r4mat_data_read(input_filename, m, n));
2542 }
2543 
2544 extern "C" void table_free_i4(int *table) {
2545  delete [] table;
2546 }
2547 
2548 extern "C" void table_free_r8(double *table) {
2549  delete [] table;
2550 }
2551 
2552 extern "C" void table_free_r4(float *table) {
2553  delete [] table;
2554 }
2555 
int i4_min(int i1, int i2)
Definition: table_io.cpp:455
int32 value
Definition: Granule.c:1235
int r
Definition: decode_rs.h:73
void r8mat_write(string output_filename, int m, int n, double table[])
Definition: table_io.cpp:1846
float * table_read_r4(char *input_filename, int m, int n)
Definition: table_io.cpp:2540
void r8mat_print(int m, int n, double a[], string title)
Definition: table_io.cpp:1432
int j
Definition: decode_rs.h:73
int table_column_count(char *input_filename)
Definition: table_io.cpp:2524
void i4mat_print_some(int m, int n, int a[], int ilo, int jlo, int ihi, int jhi, string title)
Definition: table_io.cpp:892
char ch_cap(char ch)
Definition: table_io.cpp:15
int * i4mat_read(string input_filename, int *m, int *n)
Definition: table_io.cpp:989
an array had not been initialized Several spelling and grammar corrections were which is read from the appropriate MCF the above metadata values were hard coded A problem calculating the average background DN for SWIR bands when the moon is in the space view port was corrected The new algorithm used to calculate the average background DN for all reflective bands when the moon is in the space view port is now the same as the algorithm employed by the thermal bands For non SWIR changes in the averages are typically less than Also for non SWIR the black body DNs remain a backup in case the SV DNs are not available For SWIR the changes in computed averages were larger because the old which used the black body suffered from contamination by the micron leak As a consequence of the if SV DNs are not available for the SWIR the EV pixels will not be the granule time is used to identify the appropriate tables within the set given for one LUT table(e.g. m1) to be used for interpolation. The table values will be linearly interpolated using the tables corresponding to the node times bracketing the granule time. If the granule time falls before the time of the first node or after the time of the last node
#define NULL
Definition: decode_rs.h:63
int i4_max(int i1, int i2)
Definition: table_io.cpp:417
void timestamp()
Definition: table_io.cpp:2478
float tm[MODELMAX]
void r8mat_header_read(string input_filename, int *m, int *n)
Definition: table_io.cpp:1316
void i4mat_write(string output_filename, int m, int n, int table[])
Definition: table_io.cpp:1045
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific output
Definition: HISTORY.txt:186
void i4mat_header_read(string input_filename, int *m, int *n)
Definition: table_io.cpp:734
void table_free_r8(double *table)
Definition: table_io.cpp:2548
int table_row_count(char *input_filename)
Definition: table_io.cpp:2528
float * r4mat_data_read(string input_filename, int m, int n)
Definition: table_io.cpp:1214
instr * input
void table_free_r4(float *table)
Definition: table_io.cpp:2552
#define fac
int * table_read_i4(char *input_filename, int m, int n)
Definition: table_io.cpp:2532
int i4_log_10(int i)
Definition: table_io.cpp:343
a context in which it is NOT documented to do so subscript error
Definition: HISTORY.txt:53
double * r8mat_uniform_01(int m, int n, int *seed)
Definition: table_io.cpp:1753
void i4mat_print(int m, int n, int a[], string title)
Definition: table_io.cpp:850
double * r8mat_read(string input_filename, int *m, int *n)
Definition: table_io.cpp:1571
int s_to_i4(string s, int *last, bool *error)
Definition: table_io.cpp:1956
int ch_to_digit(char ch)
Definition: table_io.cpp:93
void r8mat_transpose_print(int m, int n, double a[], string title)
Definition: table_io.cpp:1627
void table_free_i4(int *table)
Definition: table_io.cpp:2544
int s_len_trim(string s)
Definition: table_io.cpp:1913
char filename[FILENAME_MAX]
Definition: atrem_corl1.h:122
double * table_read_r8(char *input_filename, int m, int n)
Definition: table_io.cpp:2536
integer, parameter double
#define isspace(c)
double * r8mat_data_read(string input_filename, int m, int n)
Definition: table_io.cpp:1112
int * i4mat_data_read(string input_filename, int m, int n)
Definition: table_io.cpp:632
bool s_to_i4vec(string s, int n, int ivec[])
Definition: table_io.cpp:2062
int * i4mat_border_cut(int m, int n, int table[])
Definition: table_io.cpp:564
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned resolving bug report Corrected to filter out Aqua attitude records with missing status helping resolve bug MOD_PR03 will still correctly write scan and pixel data that does not depend upon the start time
Definition: HISTORY.txt:248
#define TIME_SIZE
int * i4mat_border_add(int m, int n, int table[])
Definition: table_io.cpp:493
u5 which has been done in the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT production Changes from v6 which may affect scientific the sector rotation may actually occur during one of the scans earlier than the one where it is first reported As a the b1 values are about the LOCALGRANULEID metadata should have an extension NRT It is requested to identify the NRT to fill pixels affected by dead subframes with a special value Output the metadata of noisy and dead subframe Dead Subframe EV and Detector Quality Flag2 Removed the function call of Fill_Dead_Detector_SI to stop interpolating SI values for dead but also for all downstream products for science test only Changes from v5 which will affect scientific to conform to MODIS requirements Removed the Mixed option from the ScanType in the code because the L1A Scan Type is never Mixed Changed for ANSI C compliance and comments to better document the fact that when the HDF_EOS metadata is stricly the and products are off by and in the track respectively Corrected some misspelling of RCS swir_oob_sending_detector to the Reflective LUTs to enable the SWIR OOB correction detector so that if any of the sending detectors becomes noisy or non near by good detectors from the same sending band can be specified as the substitute in the new look up table Code change for adding an additional dimension of mirror side to the Band_21_b1 LUT to separate the coefficient of the two mirror sides for just like other thermal emissive so that the L1B code can calibrate Band scan to scan with mirror side dependency which leads better calibration result Changes which do not affect scientific when the EV data are not provided in this Crosstalk Correction will not be performed to the Band calibration data Changes which do not affect scientific and BB_500m in L1A Logic was added to turn off the or to spatial aggregation processes and the EV_250m_Aggr1km_RefSB and EV_500m_Aggr1km_RefSB fields were set to fill values when SDSs EV_250m and EV_500m are absent in L1A file Logic was added to skip the processing and turn off the output of the L1B QKM and HKM EV data when EV_250m and EV_500m are absent from L1A In this the new process avoids accessing and reading the and L1A EV skips and writing to the L1B and EV omits reading and subsampling SDSs from geolocation file and writing them to the L1B and omits writing metadata to L1B and EV and skips closing the L1A and L1B EV and SDSs Logic was added to turn off the L1B OBC output when the high resolution OBC SDSs are absent from L1A This is accomplished by skipping the openning the writing of metadata and the closing of the L1B OBC hdf which is Bit in the scan by scan bit QA has been changed Until now
Definition: HISTORY.txt:361
bool ch_eqi(char ch1, char ch2)
Definition: table_io.cpp:54
void r8mat_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title)
Definition: table_io.cpp:1473
data_t s[NROOTS]
Definition: decode_rs.h:75
bool s_to_r8vec(string s, int n, double rvec[])
Definition: table_io.cpp:2372
#define INCX
void r8mat_transpose_print_some(int m, int n, double a[], int ilo, int jlo, int ihi, int jhi, string title)
Definition: table_io.cpp:1666
int * i4mat_indicator(int m, int n)
Definition: table_io.cpp:790
int file_row_count(string input_filename)
Definition: table_io.cpp:263
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed as required for compatibility with version of the SDP toolkit Corrected test output file names to end in per delivery and then split off a new MYD_PR03 pcf file for Aqua Added AssociatedPlatformInstrumentSensor to the inventory metadata in MOD01 mcf and MOD03 mcf Created new versions named MYD01 mcf and MYD03 where AssociatedPlatformShortName is rather than Terra The program itself has been changed to read the Satellite Instrument validate it against the input L1A and LUT and to use it determine the correct files to retrieve the ephemeris and attitude data from Changed to produce a LocalGranuleID starting with MYD03 if run on Aqua data Added the Scan Type file attribute to the Geolocation copied from the L1A and attitude_angels to radians rather than degrees The accumulation of Cumulated gflags was moved from GEO_validate_earth_location c to GEO_locate_one_scan c
Definition: HISTORY.txt:464
double s_to_r8(string s, int *lchar, bool *error)
Definition: table_io.cpp:2117
#define abs(a)
Definition: misc.h:90
int i
Definition: decode_rs.h:71
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
int file_column_count(string filename)
Definition: table_io.cpp:146
int k
Definition: decode_rs.h:73
double * r8mat_indicator(int m, int n)
Definition: table_io.cpp:1372
int s_word_count(string s)
Definition: table_io.cpp:2427