main.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /****************************************************************************
  2. *
  3. * MODULE: shed
  4. * AUTHOR(S): Charles Ehlschlaeger, CERL (original contributor)
  5. * Markus Neteler <neteler itc.it>, Roberto Flor <flor itc.it>,
  6. * Brad Douglas <rez touchofmadness.com>,
  7. * Hamish Bowman <hamish_b yahoo.com>
  8. * PURPOSE: Watershed determination
  9. * COPYRIGHT: (C) 1999-2006 by the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General Public
  12. * License (>=v2). Read the file COPYING that comes with GRASS
  13. * for details.
  14. *
  15. *****************************************************************************/
  16. #include <stdlib.h>
  17. #include <grass/gis.h>
  18. #include <grass/glocale.h>
  19. #include "watershed.h"
  20. #include "string.h"
  21. int main(int argc, char *argv[])
  22. {
  23. INPUT input;
  24. OUTPUT output;
  25. G_gisinit(argv[0]);
  26. G_set_program_name("r.watershed");
  27. G_get_window(&(output.window));
  28. intro();
  29. output.num_maps = 0;
  30. com_line_Gwater(&input, &output); /* develops r.watershed command line */
  31. basin_maps(&input, &output); /* organizes map layers output */
  32. if (input.fast || input.slow) {
  33. if (input.fast) {
  34. if (G_system(input.com_line_ram)) {
  35. if (input.slow) {
  36. G_message(_("Slow version of water analysis program starting now"));
  37. if (G_system(input.com_line_seg)) {
  38. free_input(&input);
  39. free_output(&output);
  40. G_fatal_error(_("<<%s>> command line failed"),
  41. input.com_line_seg);
  42. }
  43. }
  44. }
  45. }
  46. else if (G_system(input.com_line_seg)) {
  47. free_input(&input);
  48. free_output(&output);
  49. G_fatal_error(_("<<%s>> command line failed"),
  50. input.com_line_seg);
  51. }
  52. }
  53. /*
  54. ARMSED: This section exists to create the stats part.
  55. input.ar_file_name could be used as a flag to determine this stuff
  56. should be run.
  57. */
  58. #ifdef ARMSED
  59. ar_file_in(input.ar_file_name, &output);
  60. read_basins(input.haf_name, &output);
  61. valid_basins(input.accum_name, &output);
  62. free_input(&input);
  63. if ((output.out_file = fopen(output.file_name, "w")) == NULL) {
  64. free_output(&output);
  65. G_fatal_error(_("unable to open output file"));
  66. }
  67. if (output.do_basin) {
  68. fprintf(output.out_file,
  69. "\n\nThese values are accumulations within the basin itself\n");
  70. fprintf(output.out_file, "They do not include sub-basins\n\n");
  71. print_output(&output);
  72. }
  73. if (output.do_accum) {
  74. accum_down(&output);
  75. fprintf(output.out_file,
  76. "\n\nThese values are accumulations of basins and sub-basins\n");
  77. print_output(&output);
  78. }
  79. free_output(&output);
  80. #endif
  81. /*
  82. end of ARMSED comment code
  83. */
  84. exit(EXIT_SUCCESS);
  85. }