CoastalME (Coastal Modelling Environment)
Simulates the long-term behaviour of complex coastlines
Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
1
12
13/* ==============================================================================================================================
14
15 This file is part of CoastalME, the Coastal Modelling Environment.
16
17 CoastalME is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23==============================================================================================================================*/
24#include <assert.h>
25
26#ifdef _WIN32
27#include <windows.h> // Needed for CalcProcessStats()
28#include <psapi.h>
29#include <io.h> // For isatty()
30#elif defined __GNUG__
31#include <sys/resource.h> // Needed for CalcProcessStats()
32#include <unistd.h> // For isatty()
33#include <sys/types.h>
34#include <sys/wait.h>
35#endif
36
37#ifdef _OPENMP
38#include <omp.h>
39#endif
40
41#include <stdio.h>
42
43#include <cstdlib>
44
45#include <cctype>
46using std::tolower;
47
48#include <cmath>
49using std::floor;
50
51#include <ctime>
52using std::clock;
53using std::clock_t;
54using std::difftime;
55using std::localtime;
56using std::time;
57
58#include <ios>
59using std::fixed;
60
61#include <iostream>
62using std::cerr;
63using std::cout;
64using std::endl;
65using std::ios;
66
67#include <iomanip>
68using std::put_time;
69using std::resetiosflags;
70using std::setprecision;
71using std::setw;
72
73#include <string>
74using std::to_string;
75
76#include <sstream>
77using std::stringstream;
78
79#include <algorithm>
80using std::transform;
81
82#include <gdal.h>
83
84#include "cme.h"
85#include "simulation.h"
86#include "coast.h"
87#include "2di_point.h"
88
89//===============================================================================================================================
91//===============================================================================================================================
92int CSimulation::nHandleCommandLineParams(int nArg, char const* pcArgv[])
93{
94 if ((!isatty(fileno(stdout))) || (!isatty(fileno(stderr))))
95 // Running with stdout or stderr not a tty, so either redirected or running as a background job. Ignore all command line parameters
96 return RTN_OK;
97
98 // Process the parameters following the name of the executable
99 for (int i = 1; i < nArg; i++)
100 {
101 string strArg = pcArgv[i];
102 strArg = strTrim(&strArg);
103
104#ifdef _WIN32
105 // Swap any forward slashes to backslashes
106 strArg = pstrChangeToBackslash(&strArg);
107#endif
108
109 if (strArg.find("--gdal") != string::npos)
110 {
111 // User wants to know what GDAL raster drivers are available
112 cout << GDAL_DRIVERS << endl
113 << endl;
114
115 for (int j = 0; j < GDALGetDriverCount(); j++)
116 {
117 GDALDriverH hDriver = GDALGetDriver(j);
118
119 string strTmp(GDALGetDriverShortName(hDriver));
120 strTmp.append(" ");
121 strTmp.append(GDALGetDriverLongName(hDriver));
122
123 cout << strTmp << endl;
124 }
125
126 return (RTN_HELP_ONLY);
127 }
128
129 else
130 {
131 if (strArg.find("--about") != string::npos)
132 {
133 // User wants information about CoastalME
134 cout << ABOUT << endl;
135 cout << THANKS << endl;
136
137 return (RTN_HELP_ONLY);
138 }
139
140 else
141 {
142 if (strArg.find("--yaml") != string::npos)
143 {
144 // User wants to use YAML format for input datafile
145 m_bYamlInputFormat = true;
146 }
147
148 else if (strArg.find("--home") != string::npos)
149 {
150 // Read in user defined runtime directory
151 // string strTmp;
152
153 // Find the position of '='
154 size_t const pos = strArg.find('=');
155
156 // Was '=' found?
157 if (pos != string::npos)
158 {
159 // Yes, so get the substring after '=' and assign it to the global variable
160 m_strCMEIni = strArg.substr(pos + 1);
161 }
162
163 else
164 {
165 // No
166 cout << "No '=' found in the input string" << endl;
167 }
168
169 return (RTN_OK);
170 }
171
172 // TODO 049 Handle other command line parameters e.g. path to .ini file, path to datafile
173 else
174 {
175 // Display usage information
176 cout << USAGE << endl;
177 cout << USAGE1 << endl;
178 cout << USAGE2 << endl;
179 cout << USAGE3 << endl;
180 cout << USAGE4 << endl;
181 cout << USAGE5 << endl;
182 cout << USAGE6 << endl;
183
184 return (RTN_HELP_ONLY);
185 }
186 }
187 }
188 }
189
190 return RTN_OK;
191}
192
193//===============================================================================================================================
195//===============================================================================================================================
197{
198 cout << endl
199 << PROGRAM_NAME << " for " << PLATFORM << " " << strGetBuild() << endl;
200}
201
202//===============================================================================================================================
204//===============================================================================================================================
206{
207 // First start the 'CPU time' clock ticking
208 if (static_cast<clock_t>(-1) == clock())
209 {
210 // There's a problem with the clock, but continue anyway
211 LogStream << NOTE << "CPU time not available" << endl;
212 m_dCPUClock = -1;
213 }
214
215 else
216 {
217 // All OK, so get the time in m_dClkLast (this is needed to check for clock rollover on long runs)
218 m_dClkLast = static_cast<double>(clock());
219 m_dClkLast -= CLOCK_T_MIN; // necessary if clock_t is signed to make m_dClkLast unsigned
220 }
221
222 // And now get the actual time we started
223 m_tSysStartTime = time(nullptr);
224}
225
226//===============================================================================================================================
228//===============================================================================================================================
229bool CSimulation::bFindExeDir(char const* pcArg)
230{
231 string strTmp;
232 char szBuf[BUF_SIZE] = "";
233
234#ifdef _WIN32
235
236 if (0 != GetModuleFileName(NULL, szBuf, BUF_SIZE))
237 strTmp = szBuf;
238
239 else
240 // It failed, so try another approach
241 strTmp = pcArg;
242
243#else
244 // char* pResult = getcwd(szBuf, BUF_SIZE); // Used to use this, but what if cwd is not the same as the CoastalME dir?
245
246 if (-1 != readlink("/proc/self/exe", szBuf, BUF_SIZE))
247 strTmp = szBuf;
248
249 else
250 // It failed, so try another approach
251 strTmp = pcArg;
252
253#endif
254
255 // Neither approach has worked, so give up
256 if (strTmp.empty())
257 return false;
258
259 // It's OK, so trim off the executable's name
260 int const nPos = static_cast<int>(strTmp.find_last_of(PATH_SEPARATOR));
261 m_strCMEDir = strTmp.substr(0, nPos + 1); // Note that this must be terminated with a backslash
262
263 return true;
264}
265//===============================================================================================================================
267//===============================================================================================================================
269{
270 cout << COPYRIGHT << endl
271 << endl;
272 cout << LINE << endl;
273 cout << DISCLAIMER1 << endl;
274 cout << DISCLAIMER2 << endl;
275 cout << DISCLAIMER3 << endl;
276 cout << DISCLAIMER4 << endl;
277 cout << DISCLAIMER5 << endl;
278 cout << DISCLAIMER6 << endl;
279 cout << LINE << endl
280 << endl;
281
282 cout << START_NOTICE << strGetComputerName() << " at " << put_time(localtime(&m_tSysStartTime), "%T on %A %d %B %Y") << endl;
283 cout << INITIALIZING_NOTICE << endl;
284}
285
286//===============================================================================================================================
288//===============================================================================================================================
289double CSimulation::dGetTimeMultiplier(string const* strIn)
290{
291 // First decide what the time units are
292 int const nTimeUnits = nDoTimeUnits(strIn);
293
294 // Then return the correct multiplier, since m_dTimeStep is in hours
295 switch (nTimeUnits)
296 {
297 case TIME_UNKNOWN:
298 return TIME_UNKNOWN;
299 break;
300
301 case TIME_HOURS:
302 return 1; // Multiplier for hours
303 break;
304
305 case TIME_DAYS:
306 return 24; // Multiplier for days -> hours
307 break;
308
309 case TIME_MONTHS:
310 return 24 * 30.416667; // Multiplier for months -> hours (assume 30 + 5/12 day months, no leap years)
311 break;
312
313 case TIME_YEARS:
314 return 24 * 365.25; // Multiplier for years -> hours
315 break;
316 }
317
318 return 0;
319}
320
321//===============================================================================================================================
323//===============================================================================================================================
325{
326 // First decide what the time units are
327 int const nTimeUnits = nDoTimeUnits(strIn);
328
329 // Next set up the correct multiplier, since m_dTimeStep is in hours
330 switch (nTimeUnits)
331 {
332 case TIME_UNKNOWN:
333 return RTN_ERR_TIMEUNITS;
334 break;
335
336 case TIME_HOURS:
337 m_dDurationUnitsMult = 1; // Multiplier for hours
338 m_strDurationUnits = "hours";
339 break;
340
341 case TIME_DAYS:
342 m_dDurationUnitsMult = 24; // Multiplier for days -> hours
343 m_strDurationUnits = "days";
344 break;
345
346 case TIME_MONTHS:
347 m_dDurationUnitsMult = 24 * 30.416667; // Multiplier for months -> hours (assume 30 + 5/12 day months, no leap years)
348 m_strDurationUnits = "months";
349 break;
350
351 case TIME_YEARS:
352 m_dDurationUnitsMult = 24 * 365.25; // Multiplier for years -> hours
353 m_strDurationUnits = "years";
354 break;
355 }
356
357 return RTN_OK;
358}
359
360//===============================================================================================================================
362//===============================================================================================================================
363int CSimulation::nDoTimeUnits(string const* strIn)
364{
365 if (strIn->find("hour") != string::npos)
366 return TIME_HOURS;
367
368 else if (strIn->find("day") != string::npos)
369 return TIME_DAYS;
370
371 else if (strIn->find("month") != string::npos)
372 return TIME_MONTHS;
373
374 else if (strIn->find("year") != string::npos)
375 return TIME_YEARS;
376
377 else
378 return TIME_UNKNOWN;
379}
380
381//===============================================================================================================================
383//===============================================================================================================================
385{
386 if (m_nLogFileDetail == 0)
387 {
388 LogStream.open("/dev/null", ios::out | ios::trunc);
389 cout << "Warning: log file is not writting" << endl;
390 }
391
392 else
393 LogStream.open(m_strLogFile.c_str(), ios::out | ios::trunc);
394
395 if (!LogStream)
396 {
397 // Error, cannot open log file
398 cerr << ERR << "cannot open " << m_strLogFile << " for output" << endl;
399 return false;
400 }
401
402 return true;
403}
404
405//===============================================================================================================================
407//===============================================================================================================================
409{
410 // Tell the user what is happening
411#ifdef _WIN32
413#else
415#endif
416}
417
418//===============================================================================================================================
420//===============================================================================================================================
422{
423 cout << ALLOCATE_MEMORY << endl;
424}
425
426//===============================================================================================================================
428//===============================================================================================================================
430{
431 // Tell the user what is happening
432 cout << ADD_LAYERS << endl;
433}
434
435//===============================================================================================================================
437//===============================================================================================================================
439{
440 cout << READING_RASTER_FILES << endl;
441}
442
443//===============================================================================================================================
445//===============================================================================================================================
447{
448 cout << READING_VECTOR_FILES << endl;
449}
450
451//===============================================================================================================================
453//===============================================================================================================================
455{
456 // Tell the user what is happening
457 if (! m_strInitialLandformFile.empty())
458#ifdef _WIN32
460
461#else
463#endif
464}
465
466//===============================================================================================================================
468//===============================================================================================================================
470{
471 // Tell the user what is happening
472 if (! m_strInterventionClassFile.empty())
473#ifdef _WIN32
475
476#else
478#endif
479}
480
481//===============================================================================================================================
483//===============================================================================================================================
485{
486 // Tell the user what is happening
487 if (! m_strInterventionHeightFile.empty())
488#ifdef _WIN32
490
491#else
493#endif
494}
495
496//===============================================================================================================================
498//===============================================================================================================================
500{
501 // Tell the user what is happening
502 if (! m_strDeepWaterWavesInputFile.empty())
503#ifdef _WIN32
505
506#else
508#endif
509}
510
511//===============================================================================================================================
513//===============================================================================================================================
515{
516 // Tell the user what is happening
517 if (! m_strSedimentInputEventFile.empty())
518#ifdef _WIN32
520
521#else
523#endif
524}
525
526//===============================================================================================================================
528//===============================================================================================================================
530{
531 // Tell the user what is happening
532 if (! m_strFloodLocationShapefile.empty())
533#ifdef _WIN32
535
536#else
538#endif
539}
540
541//===============================================================================================================================
543//===============================================================================================================================
545{
546 // Tell the user what is happening
547#ifdef _WIN32
549#else
551#endif
552}
553
554//===============================================================================================================================
556//===============================================================================================================================
558{
559 // Tell the user what is happening
560#ifdef _WIN32
562#else
563 cout << READING_UNCONS_FINE_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialFineUnconsSedimentFile[nLayer] << endl;
564#endif
565}
566
567//===============================================================================================================================
569//===============================================================================================================================
571{
572 // Tell the user what is happening
573#ifdef _WIN32
575#else
576 cout << READING_UNCONS_SAND_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialSandUnconsSedimentFile[nLayer] << endl;
577#endif
578}
579
580//===============================================================================================================================
582//===============================================================================================================================
584{
585 // Tell the user what is happening
586#ifdef _WIN32
588#else
589 cout << READING_UNCONS_COARSE_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialCoarseUnconsSedimentFile[nLayer] << endl;
590#endif
591}
592
593//===============================================================================================================================
595//===============================================================================================================================
597{
598 // Tell the user what is happening
599#ifdef _WIN32
600 cout << READING_CONS_FINE_SEDIMENT_FILE << nLayer + 1 << "): " << pstrChangeToForwardSlash(&m_VstrInitialFineConsSedimentFile[nLayer]) << endl;
601#else
602 cout << READING_CONS_FINE_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialFineConsSedimentFile[nLayer] << endl;
603#endif
604}
605
606//===============================================================================================================================
608//===============================================================================================================================
610{
611 // Tell the user what is happening
612#ifdef _WIN32
613 cout << READING_CONS_SAND_SEDIMENT_FILE << nLayer + 1 << "): " << pstrChangeToForwardSlash(&m_VstrInitialSandConsSedimentFile[nLayer]) << endl;
614#else
615 cout << READING_CONS_SAND_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialSandConsSedimentFile[nLayer] << endl;
616#endif
617}
618
619//===============================================================================================================================
621//===============================================================================================================================
623{
624 // Tell the user what is happening
625#ifdef _WIN32
627#else
628 cout << READING_CONS_COARSE_SEDIMENT_FILE << nLayer + 1 << "): " << m_VstrInitialCoarseConsSedimentFile[nLayer] << endl;
629#endif
630}
631
632//===============================================================================================================================
634//===============================================================================================================================
636{
637#ifdef _WIN32
639#else
640 cout << READING_TIDE_DATA_FILE << m_strTideDataFile << endl;
641#endif
642}
643
644//===============================================================================================================================
646//===============================================================================================================================
651
652//===============================================================================================================================
654//===============================================================================================================================
656{
657 // Tell the user what is happening
658 cout << INITIALIZING << endl;
659}
660
661//===============================================================================================================================
663//===============================================================================================================================
665{
666 cout << RUN_NOTICE << endl;
667}
668
669//===============================================================================================================================
671//===============================================================================================================================
673{
674 string strTmp;
675
677 {
678 strTmp.append(RASTER_BASEMENT_ELEVATION_CODE);
679 strTmp.append(", ");
680 }
681
683 {
684 strTmp.append(RASTER_SEDIMENT_TOP_CODE);
685 strTmp.append(", ");
686 }
687
688 if (m_bTopSurfSave)
689 {
690 strTmp.append(RASTER_TOP_CODE);
691 strTmp.append(", ");
692 }
693
694 if (m_bSeaDepthSave)
695 {
696 strTmp.append(RASTER_SEA_DEPTH_NAME);
697 strTmp.append(", ");
698 }
699
701 {
702 strTmp.append(RASTER_AVG_SEA_DEPTH_CODE);
703 strTmp.append(", ");
704 }
705
706 if (m_bSeaMaskSave)
707 {
708 strTmp.append(RASTER_INUNDATION_MASK_CODE);
709 strTmp.append(", ");
710 }
711
713 {
714 strTmp.append(RASTER_WAVE_HEIGHT_CODE);
715 strTmp.append(", ");
716 }
717
719 {
720 strTmp.append(RASTER_WAVE_ORIENTATION_CODE);
721 strTmp.append(", ");
722 }
723
725 {
726 strTmp.append(RASTER_AVG_WAVE_HEIGHT_CODE);
727 strTmp.append(", ");
728 }
729
731 {
732 strTmp.append(RASTER_BEACH_PROTECTION_CODE);
733 strTmp.append(", ");
734 }
735
737 {
739 strTmp.append(", ");
740 }
741
743 {
745 strTmp.append(", ");
746 }
747
749 {
750 strTmp.append(RASTER_BEACH_DEPOSITION_CODE);
751 strTmp.append(", ");
752 }
753
755 {
757 strTmp.append(", ");
758 }
759
761 {
762 strTmp.append(RASTER_BEACH_MASK_CODE);
763 strTmp.append(", ");
764 }
765
767 {
769 strTmp.append(", ");
770 }
771
773 {
775 strTmp.append(", ");
776 }
777
779 {
781 strTmp.append(", ");
782 }
783
785 {
787 strTmp.append(", ");
788 }
789
791 {
793 strTmp.append(", ");
794 }
795
797 {
799 strTmp.append(", ");
800 }
801
803 {
805 strTmp.append(", ");
806 }
807
808 if (m_bLandformSave)
809 {
810 strTmp.append(RASTER_LANDFORM_CODE);
811 strTmp.append(", ");
812 }
813
815 {
816 strTmp.append(RASTER_LOCAL_SLOPE_CODE);
817 strTmp.append(", ");
818 }
819
821 {
822 strTmp.append(RASTER_INTERVENTION_CLASS_CODE);
823 strTmp.append(", ");
824 }
825
827 {
828 strTmp.append(RASTER_INTERVENTION_HEIGHT_CODE);
829 strTmp.append(", ");
830 }
831
833 {
834 strTmp.append(RASTER_SUSP_SED_CODE);
835 strTmp.append(", ");
836 }
837
839 {
840 strTmp.append(RASTER_AVG_SUSP_SED_CODE);
841 strTmp.append(", ");
842 }
843
845 {
846 strTmp.append(RASTER_FINE_UNCONS_CODE);
847 strTmp.append(", ");
848 }
849
851 {
852 strTmp.append(RASTER_SAND_UNCONS_CODE);
853 strTmp.append(", ");
854 }
855
857 {
858 strTmp.append(RASTER_COARSE_UNCONS_CODE);
859 strTmp.append(", ");
860 }
861
863 {
864 strTmp.append(RASTER_FINE_CONS_CODE);
865 strTmp.append(", ");
866 }
867
869 {
870 strTmp.append(RASTER_SAND_CONS_CODE);
871 strTmp.append(", ");
872 }
873
875 {
876 strTmp.append(RASTER_COARSE_CONS_CODE);
877 strTmp.append(", ");
878 }
879
881 {
882 strTmp.append(RASTER_COAST_CODE);
883 strTmp.append(", ");
884 }
885
887 {
888 strTmp.append(RASTER_COAST_NORMAL_CODE);
889 strTmp.append(", ");
890 }
891
893 {
894 strTmp.append(RASTER_ACTIVE_ZONE_CODE);
895 strTmp.append(", ");
896 }
897
899 {
900 strTmp.append(RASTER_POLYGON_CODE);
901 strTmp.append(", ");
902 }
903
905 {
907 strTmp.append(", ");
908 }
909
911 {
913 strTmp.append(", ");
914 }
915
916 // Remove the trailing comma and space
917 if (strTmp.size() > 2)
918 strTmp.resize(strTmp.size() - 2);
919
920 return strTmp;
921}
922
923//===============================================================================================================================
925//===============================================================================================================================
927{
928 string strTmp;
929
930 if (m_bCoastSave)
931 {
932 strTmp.append(VECTOR_COAST_CODE);
933 strTmp.append(", ");
934 }
935
936 if (m_bNormalsSave)
937 {
938 strTmp.append(VECTOR_NORMALS_CODE);
939 strTmp.append(", ");
940 }
941
943 {
944 strTmp.append(VECTOR_INVALID_NORMALS_CODE);
945 strTmp.append(", ");
946 }
947
949 {
951 strTmp.append(", ");
952 }
953
955 {
957 strTmp.append(", ");
958 }
959
961 {
962 strTmp.append(VECTOR_COAST_CURVATURE_CODE);
963 strTmp.append(", ");
964 }
965
967 {
969 strTmp.append(", ");
970 }
971
973 {
974 strTmp.append(VECTOR_MEAN_WAVE_ENERGY_CODE);
975 strTmp.append(", ");
976 }
977
979 {
981 strTmp.append(", ");
982 }
983
985 {
986 strTmp.append(VECTOR_POLYGON_NODE_CODE);
987 strTmp.append(", ");
988 }
989
991 {
992 strTmp.append(VECTOR_POLYGON_BOUNDARY_CODE);
993 strTmp.append(", ");
994 }
995
997 {
998 strTmp.append(VECTOR_CLIFF_NOTCH_SIZE_CODE);
999 strTmp.append(", ");
1000 }
1001
1003 {
1004 strTmp.append(VECTOR_SHADOW_BOUNDARY_CODE);
1005 strTmp.append(", ");
1006 }
1007
1009 {
1010 strTmp.append(VECTOR_DOWNDRIFT_BOUNDARY_CODE);
1011 strTmp.append(", ");
1012 }
1013
1015 {
1017 strTmp.append(", ");
1018 }
1019
1020 // Remove the trailing comma and space
1021 if (strTmp.size() > 2)
1022 strTmp.resize(strTmp.size() - 2);
1023
1024 return strTmp;
1025}
1026
1027//===============================================================================================================================
1029//===============================================================================================================================
1031{
1032 string strTmp;
1033
1034 if (m_bSeaAreaTSSave)
1035 {
1036 strTmp.append(TIME_SERIES_SEA_AREA_CODE);
1037 strTmp.append(", ");
1038 }
1039
1041 {
1043 strTmp.append(", ");
1044 }
1045
1047 {
1048 strTmp.append(TIME_SERIES_PLATFORM_EROSION_CODE);
1049 strTmp.append(", ");
1050 }
1051
1053 {
1055 strTmp.append(", ");
1056 }
1057
1059 {
1061 strTmp.append(", ");
1062 }
1063
1065 {
1067 strTmp.append(", ");
1068 }
1069
1071 {
1072 strTmp.append(TIME_SERIES_BEACH_EROSION_CODE);
1073 strTmp.append(", ");
1074 }
1075
1077 {
1078 strTmp.append(TIME_SERIES_BEACH_DEPOSITION_CODE);
1079 strTmp.append(", ");
1080 }
1081
1083 {
1084 strTmp.append(TIME_SERIES_BEACH_CHANGE_NET_CODE);
1085 strTmp.append(", ");
1086 }
1087
1088 if (m_bSuspSedTSSave)
1089 {
1091 strTmp.append(", ");
1092 }
1093
1095 {
1097 strTmp.append(", ");
1098 }
1099
1101 {
1103 strTmp.append(", ");
1104 }
1105
1106 // Remove the trailing comma and space
1107 if (strTmp.size() > 2)
1108 strTmp.resize(strTmp.size() - 2);
1109
1110 return strTmp;
1111}
1112
1113//===============================================================================================================================
1115//===============================================================================================================================
1117{
1118 string strTSFile;
1119
1120 if (m_bSeaAreaTSSave)
1121 {
1122 // Start with wetted area
1123 strTSFile = m_strOutPath;
1124 strTSFile.append(TIME_SERIES_SEA_AREA_NAME);
1125 strTSFile.append(CSVEXT);
1126
1127 // Open wetted time-series CSV file
1128 SeaAreaTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1129
1130 if (!SeaAreaTSStream)
1131 {
1132 // Error, cannot open wetted area time-series file
1133 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1134 return false;
1135 }
1136 }
1137
1139 {
1140 // Now still water level
1141 strTSFile = m_strOutPath;
1142 strTSFile.append(TIME_SERIES_STILL_WATER_LEVEL_NAME);
1143 strTSFile.append(CSVEXT);
1144
1145 // Open still water level time-series CSV file
1146 StillWaterLevelTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1147
1149 {
1150 // Error, cannot open still water level time-series file
1151 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1152 return false;
1153 }
1154 }
1155
1157 {
1158 // Erosion (fine, sand, coarse)
1159 strTSFile = m_strOutPath;
1160 strTSFile.append(TIME_SERIES_PLATFORM_EROSION_NAME);
1161 strTSFile.append(CSVEXT);
1162
1163 // Open erosion time-series CSV file
1164 PlatformErosionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1165
1167 {
1168 // Error, cannot open erosion time-series file
1169 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1170 return false;
1171 }
1172 }
1173
1175 {
1176 // Erosion due to cliff collapse
1177 strTSFile = m_strOutPath;
1179 strTSFile.append(CSVEXT);
1180
1181 // Open cliff collapse erosion time-series CSV file
1182 CliffCollapseErosionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1183
1185 {
1186 // Error, cannot open cliff collapse erosion time-series file
1187 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1188 return false;
1189 }
1190 }
1191
1193 {
1194 // Deposition due to cliff collapse
1195 strTSFile = m_strOutPath;
1197 strTSFile.append(CSVEXT);
1198
1199 // Open cliff collapse deposition time-series CSV file
1200 CliffCollapseDepositionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1201
1203 {
1204 // Error, cannot open cliff collapse deposition time-series file
1205 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1206 return false;
1207 }
1208 }
1209
1211 {
1212 // Net change in unconsolidated sediment due to cliff collapse
1213 strTSFile = m_strOutPath;
1214 strTSFile.append(TIME_SERIES_CLIFF_COLLAPSE_NET_NAME);
1215 strTSFile.append(CSVEXT);
1216
1217 // Open net cliff collapse time-series CSV file
1218 CliffCollapseNetChangeTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1219
1221 {
1222 // Error, cannot open net cliff collapse time-series file
1223 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1224 return false;
1225 }
1226 }
1227
1229 {
1230 // Beach erosion
1231 strTSFile = m_strOutPath;
1232 strTSFile.append(TIME_SERIES_BEACH_EROSION_NAME);
1233 strTSFile.append(CSVEXT);
1234
1235 // Open beach erosion time-series CSV file
1236 BeachErosionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1237
1239 {
1240 // Error, cannot open beach erosion time-series file
1241 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1242 return false;
1243 }
1244 }
1245
1247 {
1248 // Beach deposition
1249 strTSFile = m_strOutPath;
1250 strTSFile.append(TIME_SERIES_BEACH_DEPOSITION_NAME);
1251 strTSFile.append(CSVEXT);
1252
1253 // Open beach deposition time-series CSV file
1254 BeachDepositionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1255
1257 {
1258 // Error, cannot open beach deposition time-series file
1259 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1260 return false;
1261 }
1262 }
1263
1265 {
1266 // Beach sediment change
1267 strTSFile = m_strOutPath;
1268 strTSFile.append(TIME_SERIES_BEACH_CHANGE_NET_NAME);
1269 strTSFile.append(CSVEXT);
1270
1271 // Open net beach sediment change time-series CSV file
1272 BeachSedimentNetChangeTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1273
1275 {
1276 // Error, cannot open beach sediment change time-series file
1277 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1278 return false;
1279 }
1280 }
1281
1282 if (m_bSuspSedTSSave)
1283 {
1284 // Sediment load
1285 strTSFile = m_strOutPath;
1286 strTSFile.append(TIME_SERIES_SUSPENDED_SEDIMENT_NAME);
1287 strTSFile.append(CSVEXT);
1288
1289 // Open sediment load time-series CSV file
1290 FineSedSuspensionTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1291
1293 {
1294 // Error, cannot open sediment load time-series file
1295 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1296 return false;
1297 }
1298 }
1299
1301 {
1302 // Sediment load
1303 strTSFile = m_strOutPath;
1304 strTSFile.append(TIME_SERIES_FLOOD_SETUP_SURGE_CODE);
1305 strTSFile.append(CSVEXT);
1306
1307 // Open sediment load time-series CSV file
1308 FloodSetupSurgeTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1309
1311 {
1312 // Error, cannot open sediment load time-series file
1313 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1314 return false;
1315 }
1316 }
1317
1319 {
1320 // Sediment load
1321 strTSFile = m_strOutPath;
1323 strTSFile.append(CSVEXT);
1324
1325 // Open sediment load time-series CSV file
1326 FloodSetupSurgeRunupTSStream.open(strTSFile.c_str(), ios::out | ios::trunc);
1327
1329 {
1330 // Error, cannot open sediment load time-series file
1331 cerr << ERR << "cannot open " << strTSFile << " for output" << endl;
1332 return false;
1333 }
1334 }
1335
1336 return true;
1337}
1338
1339//===============================================================================================================================
1341//===============================================================================================================================
1343{
1344 // Add timestep to the total time simulated so far
1346
1348 {
1349 // It is time to quit
1352 return true;
1353 }
1354
1355 // Not quitting, so increment the timestep count, and recalc total timesteps
1356 m_ulIter++;
1357 m_ulTotTimestep = static_cast<unsigned long>(dRound(m_dSimDuration / m_dTimeStep));
1358
1359 // Check to see if we have done CLOCK_CHECK_ITERATION timesteps: if so, it is time to reset the CPU time running total in case the clock() function later rolls over
1362
1363 // Not yet time to quit
1364 return false;
1365}
1366
1367//===============================================================================================================================
1369//===============================================================================================================================
1371{
1372 string strComputerName;
1373
1374#ifdef _WIN32
1375 // Being compiled to run under Windows, either by MS VC++, Borland C++, or Cygwin
1376 strComputerName = getenv("COMPUTERNAME");
1377#else
1378 // Being compiled for another platform; assume for Linux-Unix
1379 char szHostName[BUF_SIZE] = "";
1380 gethostname(szHostName, BUF_SIZE);
1381
1382 strComputerName = szHostName;
1383
1384 if (strComputerName.empty())
1385 strComputerName = "Unknown Computer";
1386
1387#endif
1388
1389 return strComputerName;
1390}
1391
1392//===============================================================================================================================
1394//===============================================================================================================================
1396{
1397 if (static_cast<clock_t>(-1) == clock())
1398 {
1399 // Error
1400 LogStream << "CPU time not available" << endl;
1401 m_dCPUClock = -1;
1402 return;
1403 }
1404
1405 // OK, so carry on
1406 double dClkThis = static_cast<double>(clock());
1407 dClkThis -= CLOCK_T_MIN; // necessary when clock_t is signed, to make dClkThis unsigned
1408
1409 if (dClkThis < m_dClkLast)
1410 {
1411 // Clock has 'rolled over'
1412 m_dCPUClock += (CLOCK_T_RANGE + 1 - m_dClkLast); // this elapsed before rollover
1413 m_dCPUClock += dClkThis; // this elapsed after rollover
1414
1415#ifdef CLOCKCHECK
1416 // For debug purposes
1417 LogStream << "Rolled over: dClkThis=" << dClkThis << " m_dClkLast=" << m_dClkLast << endl
1418 << "\t"
1419 << " before rollover=" << (CLOCK_T_RANGE + 1 - m_dClkLast) << endl
1420 << "\t"
1421 << " after rollover=" << dClkThis << endl
1422 << "\t"
1423 << " ADDED=" << (CLOCK_T_RANGE + 1 - m_dClkLast + dClkThis) << endl;
1424#endif
1425 }
1426
1427 else
1428 {
1429 // No rollover
1430 m_dCPUClock += (dClkThis - m_dClkLast);
1431
1432#ifdef CLOCKCHECK
1433 // For debug purposes
1434 LogStream << "No rollover: dClkThis=" << dClkThis << " m_dClkLast=" << m_dClkLast << " ADDED=" << dClkThis - m_dClkLast << endl;
1435#endif
1436 }
1437
1438 // Reset for next time
1439 m_dClkLast = dClkThis;
1440}
1441
1442//===============================================================================================================================
1444//===============================================================================================================================
1446{
1447 cout << endl
1448 << FINAL_OUTPUT << endl;
1449}
1450
1451//===============================================================================================================================
1453//===============================================================================================================================
1454void CSimulation::CalcTime(double const dRunLength)
1455{
1456 // Reset CPU count for last time
1458
1459 if (! bFPIsEqual(m_dCPUClock, -1.0, TOLERANCE))
1460 {
1461 // Calculate CPU time in secs
1462 double const dDuration = m_dCPUClock / CLOCKS_PER_SEC;
1463
1464 // And write CPU time out to OutStream and LogStream
1465 OutStream << "CPU time elapsed: " << strDispTime(dDuration, false, true);
1466 LogStream << "CPU time elapsed: " << strDispTime(dDuration, false, true);
1467
1468 // Calculate CPU time per timestep
1469 double const dPerTimestep = dDuration / static_cast<double>(m_ulTotTimestep);
1470
1471 // And write CPU time per timestep to OutStream and LogStream
1472 OutStream << fixed << setprecision(4) << " (" << dPerTimestep << " per timestep)" << endl;
1473 LogStream << fixed << setprecision(4) << " (" << dPerTimestep << " per timestep)" << endl;
1474
1475 // Calculate ratio of CPU time to time simulated
1476 OutStream << resetiosflags(ios::floatfield);
1477 OutStream << fixed << setprecision(0) << "In terms of CPU time, this is ";
1478 LogStream << resetiosflags(ios::floatfield);
1479 LogStream << fixed << setprecision(0) << "In terms of CPU time, this is ";
1480
1481 if (dDuration > dRunLength)
1482 {
1483 OutStream << dDuration / dRunLength << " x slower than reality" << endl;
1484 LogStream << dDuration / dRunLength << " x slower than reality" << endl;
1485 }
1486
1487 else
1488 {
1489 OutStream << dRunLength / dDuration << " x faster than reality" << endl;
1490 LogStream << dRunLength / dDuration << " x faster than reality" << endl;
1491 }
1492 }
1493
1494 // Calculate run time
1495 double const dDuration = difftime(m_tSysEndTime, m_tSysStartTime);
1496
1497 // And write run time out to OutStream and LogStream
1498 OutStream << "Run time elapsed: " << strDispTime(dDuration, false, false);
1499 LogStream << "Run time elapsed: " << strDispTime(dDuration, false, false);
1500
1501 // Calculate run time per timestep
1502 double const dPerTimestep = dDuration / static_cast<double>(m_ulTotTimestep);
1503
1504 // And write run time per timestep to OutStream and LogStream
1505 OutStream << resetiosflags(ios::floatfield);
1506 OutStream << " (" << fixed << setprecision(4) << dPerTimestep << " per timestep)" << endl;
1507 LogStream << resetiosflags(ios::floatfield);
1508 LogStream << " (" << fixed << setprecision(4) << dPerTimestep << " per timestep)" << endl;
1509
1510 // Calculate ratio of run time to time simulated
1511 OutStream << fixed << setprecision(0) << "In terms of run time, this is ";
1512 LogStream << fixed << setprecision(0) << "In terms of run time, this is ";
1513
1514 if (dDuration > dRunLength)
1515 {
1516 OutStream << dDuration / dRunLength << " x slower than reality" << endl;
1517 LogStream << dDuration / dRunLength << " x slower than reality" << endl;
1518 }
1519
1520 else
1521 {
1522 OutStream << dRunLength / dDuration << " x faster than reality" << endl;
1523 LogStream << dRunLength / dDuration << " x faster than reality" << endl;
1524 }
1525}
1526
1527//===============================================================================================================================
1529//===============================================================================================================================
1530string CSimulation::strDispSimTime(const double dTimeIn)
1531{
1532 // Make sure no negative times
1533 double dTmpTime = tMax(dTimeIn, 0.0);
1534
1535 string strTime;
1536
1537 // Constants
1538 double const dHoursInYear = 24 * 365; // it was 365.25
1539 double const dHoursInDay = 24;
1540
1541 // Display years
1542 if (dTmpTime >= dHoursInYear)
1543 {
1544 double const dYears = floor(dTmpTime / dHoursInYear);
1545 dTmpTime -= (dYears * dHoursInYear);
1546
1547 strTime = to_string(static_cast<int>(dYears));
1548 strTime.append("y ");
1549 }
1550
1551 else
1552 strTime = "0y ";
1553
1554 // Display Julian days
1555 if (dTmpTime >= dHoursInDay)
1556 {
1557 double const dJDays = floor(dTmpTime / dHoursInDay);
1558 dTmpTime -= (dJDays * dHoursInDay);
1559
1560 stringstream ststrTmp;
1561 ststrTmp << FillToWidth('0', 3) << static_cast<int>(dJDays);
1562 strTime.append(ststrTmp.str());
1563 strTime.append("d ");
1564 }
1565
1566 else
1567 strTime.append("000d ");
1568
1569 // Display hours
1570 stringstream ststrTmp;
1571 ststrTmp << FillToWidth('0', 2) << static_cast<int>(dTmpTime);
1572 strTime.append(ststrTmp.str());
1573 strTime.append("h");
1574
1575 return strTime;
1576}
1577
1578//===============================================================================================================================
1580//===============================================================================================================================
1581string CSimulation::strDispTime(const double dTimeIn, const bool bRound, const bool bFrac)
1582{
1583 // Make sure no negative times
1584 double dTime = tMax(dTimeIn, 0.0);
1585
1586 string strTime;
1587
1588 if (bRound)
1589 dTime = dRound(dTime);
1590
1591 unsigned long ulTimeIn = static_cast<unsigned long>(floor(dTime));
1592 dTime -= static_cast<double>(ulTimeIn);
1593
1594 // Hours
1595 if (ulTimeIn >= 3600)
1596 {
1597 // Display some hours
1598 unsigned long const ulHours = ulTimeIn / 3600ul;
1599 ulTimeIn -= (ulHours * 3600ul);
1600
1601 strTime = to_string(ulHours);
1602 strTime.append(":");
1603 }
1604
1605 else
1606 strTime = "0:";
1607
1608 // Minutes
1609 if (ulTimeIn >= 60)
1610 {
1611 // display some minutes
1612 unsigned long const ulMins = ulTimeIn / 60ul;
1613 ulTimeIn -= (ulMins * 60ul);
1614
1615 stringstream ststrTmp;
1616 ststrTmp << FillToWidth('0', 2) << ulMins;
1617 strTime.append(ststrTmp.str());
1618 strTime.append(":");
1619 }
1620
1621 else
1622 strTime.append("00:");
1623
1624 // Seconds
1625 stringstream ststrTmp;
1626 ststrTmp << FillToWidth('0', 2) << ulTimeIn;
1627 strTime.append(ststrTmp.str());
1628
1629 if (bFrac)
1630 {
1631 // Fractions of a second
1632 strTime.append(".");
1633 ststrTmp.clear();
1634 ststrTmp.str(string());
1635 ststrTmp << FillToWidth('0', 2) << static_cast<unsigned long>(dTime * 100);
1636 strTime.append(ststrTmp.str());
1637 }
1638
1639 return strTime;
1640}
1641
1642//===============================================================================================================================
1644//===============================================================================================================================
1646{
1647 string strBuild("(");
1648 strBuild.append(__TIME__);
1649 strBuild.append(" ");
1650 strBuild.append(__DATE__);
1651#ifdef _DEBUG
1652 strBuild.append(" DEBUG");
1653#endif
1654 strBuild.append(" build)");
1655
1656 return strBuild;
1657}
1658
1659//===============================================================================================================================
1661//===============================================================================================================================
1663{
1664 if (isatty(fileno(stdout)))
1665 {
1666 // Stdout is connected to a tty, so not running as a background job
1667 static double sdElapsed = 0;
1668 static double sdToGo = 0;
1669 time_t const tNow = time(nullptr);
1670
1671 // Calculate time elapsed and remaining
1672 sdElapsed = difftime(tNow, m_tSysStartTime);
1673 sdToGo = (sdElapsed * m_dSimDuration / m_dSimElapsed) - sdElapsed;
1674
1675 // Tell the user about progress (note need to make several separate calls to cout here, or MS VC++ compiler appears to get confused)
1677 cout << fixed << setprecision(3) << setw(9) << 100 * m_dSimElapsed / m_dSimDuration;
1678 cout << "% (elapsed " << strDispTime(sdElapsed, false, false) << " remaining ";
1679
1680 cout << strDispTime(sdToGo, false, false) << ") ";
1681
1682 // Add a 'marker' for GIS saves etc.
1684 cout << setw(9) << "GIS" + to_string(m_nGISSave);
1685
1686 else if (m_bSedimentInputThisIter)
1687 cout << setw(9) << "SED INPUT";
1688
1689 else
1690 cout << setw(9) << SPACE;
1691
1692 cout.flush();
1693 }
1694}
1695
1696//===============================================================================================================================
1698//===============================================================================================================================
1700{
1701 string const NA = "Not available";
1702
1703 OutStream << endl;
1704 OutStream << "Process statistics" << endl;
1705 OutStream << "------------------" << endl;
1706
1707#ifdef _WIN32
1708 // First, find out which version of Windows we are running under
1709 OSVERSIONINFOEX osvi;
1710 BOOL bOsVersionInfoEx;
1711
1712 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); // fill this much memory with zeros
1713 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
1714
1715 if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*)&osvi)))
1716 {
1717 // OSVERSIONINFOEX didn't work so try OSVERSIONINFO instead
1718 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
1719
1720 if (!GetVersionEx((OSVERSIONINFO*)&osvi))
1721 {
1722 // That didn't work either, too risky to proceed so give up
1723 OutStream << NA << endl;
1724 return;
1725 }
1726 }
1727
1728 // OK, we have Windows version so display it
1729 OutStream << "Running under \t: ";
1730
1731 switch (osvi.dwPlatformId)
1732 {
1733 case VER_PLATFORM_WIN32_NT:
1734 if (osvi.dwMajorVersion <= 4)
1735 OutStream << "Windows NT ";
1736
1737 else if (5 == osvi.dwMajorVersion && 0 == osvi.dwMinorVersion)
1738 OutStream << "Windows 2000 ";
1739
1740 else if (5 == osvi.dwMajorVersion && 1 == osvi.dwMinorVersion)
1741 OutStream << "Windows XP ";
1742
1743 else if (6 == osvi.dwMajorVersion && 0 == osvi.dwMinorVersion)
1744 OutStream << "Windows Vista ";
1745
1746 else if (6 == osvi.dwMajorVersion && 1 == osvi.dwMinorVersion)
1747 OutStream << "Windows 7 ";
1748
1749 else if (6 == osvi.dwMajorVersion && 2 == osvi.dwMinorVersion)
1750 OutStream << "Windows 8 ";
1751
1752 else if (6 == osvi.dwMajorVersion && 3 == osvi.dwMinorVersion)
1753 OutStream << "Windows 8.1 ";
1754
1755 else if (10 == osvi.dwMajorVersion && 0 == osvi.dwMinorVersion)
1756 OutStream << "Windows 10 ";
1757
1758 else if (11 == osvi.dwMajorVersion && 0 == osvi.dwMinorVersion)
1759 OutStream << "Windows 11 ";
1760
1761 else
1762 OutStream << "unknown Windows version ";
1763
1764 // Display version, service pack (if any), and build number
1765 if (osvi.dwMajorVersion <= 4)
1766 OutStream << "version " << osvi.dwMajorVersion << "." << osvi.dwMinorVersion << " " << osvi.szCSDVersion << " (Build " << (osvi.dwBuildNumber & 0xFFFF) << ")" << endl;
1767
1768 else
1769 OutStream << osvi.szCSDVersion << " (Build " << (osvi.dwBuildNumber & 0xFFFF) << ")" << endl;
1770
1771 break;
1772
1773 case VER_PLATFORM_WIN32_WINDOWS:
1774 if (4 == osvi.dwMajorVersion && 0 == osvi.dwMinorVersion)
1775 {
1776 OutStream << "Windows 95";
1777
1778 if ('C' == osvi.szCSDVersion[1] || 'B' == osvi.szCSDVersion[1])
1779 OutStream << " OSR2";
1780
1781 OutStream << endl;
1782 }
1783
1784 else if (4 == osvi.dwMajorVersion && 10 == osvi.dwMinorVersion)
1785 {
1786 OutStream << "Windows 98";
1787
1788 if ('A' == osvi.szCSDVersion[1])
1789 OutStream << "SE";
1790
1791 OutStream << endl;
1792 }
1793
1794 else if (4 == osvi.dwMajorVersion && 90 == osvi.dwMinorVersion)
1795 OutStream << "Windows Me" << endl;
1796
1797 else
1798 OutStream << "unknown 16-bit Windows version " << endl;
1799
1800 break;
1801
1802 case VER_PLATFORM_WIN32s:
1803 OutStream << "Win32s" << endl;
1804 break;
1805 }
1806
1807 // Now get process timimgs: this only works under 32-bit windows
1808 if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId)
1809 {
1810 FILETIME ftCreate, ftExit, ftKernel, ftUser;
1811
1812 if (GetProcessTimes(GetCurrentProcess(), &ftCreate, &ftExit, &ftKernel, &ftUser))
1813 {
1814 ULARGE_INTEGER ul;
1815 ul.LowPart = ftUser.dwLowDateTime;
1816 ul.HighPart = ftUser.dwHighDateTime;
1817 OutStream << "Time spent executing user code \t: " << strDispTime(static_cast<double>(ul.QuadPart) * 1e-7, false) << endl;
1818 ul.LowPart = ftKernel.dwLowDateTime;
1819 ul.HighPart = ftKernel.dwHighDateTime;
1820 OutStream << "Time spent executing kernel code \t: " << strDispTime(static_cast<double>(ul.QuadPart) * 1e-7, false) << endl;
1821 }
1822 }
1823
1824 else
1825 OutStream << "Process timings \t: " << NA << endl;
1826
1827 // Finally get more process statistics: this needs psapi.dll, so only proceed if it is present on this system
1828 HINSTANCE hDLL = LoadLibrary("psapi.dll");
1829
1830 if (hDLL != NULL)
1831 {
1832 // The dll has been found
1833 typedef BOOL(__stdcall * DLLPROC)(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD);
1834 DLLPROC ProcAdd;
1835
1836 // Try to get the address of the function we will call
1837 ProcAdd = (DLLPROC)GetProcAddress(hDLL, "GetProcessMemoryInfo");
1838
1839 if (ProcAdd)
1840 {
1841 // Address was found
1842 PROCESS_MEMORY_COUNTERS pmc;
1843
1844 // Now call the function
1845 if ((ProcAdd)(GetCurrentProcess(), &pmc, sizeof(pmc)))
1846 {
1847 OutStream << "Peak working set size \t: " << pmc.PeakWorkingSetSize / (1024.0 * 1024.0) << " Mb" << endl;
1848 OutStream << "Current working set size \t: " << pmc.WorkingSetSize / (1024.0 * 1024.0) << " Mb" << endl;
1849 OutStream << "Peak paged pool usage \t: " << pmc.QuotaPeakPagedPoolUsage / (1024.0 * 1024.0) << " Mb" << endl;
1850 OutStream << "Current paged pool usage \t: " << pmc.QuotaPagedPoolUsage / (1024.0 * 1024.0) << " Mb" << endl;
1851 OutStream << "Peak non-paged pool usage \t: " << pmc.QuotaPeakNonPagedPoolUsage / (1024.0 * 1024.0) << " Mb" << endl;
1852 OutStream << "Current non-paged pool usage \t: " << pmc.QuotaNonPagedPoolUsage / (1024.0 * 1024.0) << " Mb" << endl;
1853 OutStream << "Peak pagefile usage \t: " << pmc.PeakPagefileUsage / (1024.0 * 1024.0) << " Mb" << endl;
1854 OutStream << "Current pagefile usage \t: " << pmc.PagefileUsage / (1024.0 * 1024.0) << " Mb" << endl;
1855 OutStream << "No. of page faults \t: " << pmc.PageFaultCount << endl;
1856 }
1857 }
1858
1859 // Free the memory used by the dll
1860 FreeLibrary(hDLL);
1861 }
1862
1863#elif defined __GNUG__
1864 rusage ru;
1865
1866 if (getrusage(RUSAGE_SELF, &ru) >= 0)
1867 {
1868 OutStream << "Time spent executing user code \t: " << strDispTime(static_cast<double>(ru.ru_utime.tv_sec), false, true) << endl;
1869 // OutStream << "ru_utime.tv_usec \t: " << ru.ru_utime.tv_usec << endl;
1870 OutStream << "Time spent executing kernel code \t: " << strDispTime(static_cast<double>(ru.ru_stime.tv_sec), false, true) << endl;
1871 // OutStream << "ru_stime.tv_usec \t: " << ru.ru_stime.tv_usec << endl;
1872 // OutStream << "Maximum resident set size \t: " << ru.ru_maxrss/1024.0 << " Mb" << endl;
1873 // OutStream << "ixrss (???) \t: " << ru.ru_ixrss << endl;
1874 // OutStream << "Sum of rm_asrss (???) \t: " << ru.ru_idrss << endl;
1875 // OutStream << "isrss (???) \t: " << ru.ru_isrss << endl;
1876 OutStream << "No. of page faults not requiring physical I/O\t: " << ru.ru_minflt << endl;
1877 OutStream << "No. of page faults requiring physical I/O \t: " << ru.ru_majflt << endl;
1878 // OutStream << "No. of times swapped out of main memory \t: " << ru.ru_nswap << endl;
1879 // OutStream << "No. of times performed input (read request) \t: " << ru.ru_inblock << endl;
1880 // OutStream << "No. of times performed output (write request)\t: " << ru.ru_oublock << endl;
1881 // OutStream << "No. of signals received \t: " << ru.ru_nsignals << endl;
1882 OutStream << "No. of voluntary context switches \t: " << ru.ru_nvcsw << endl;
1883 OutStream << "No. of involuntary context switches \t: " << ru.ru_nivcsw << endl;
1884 }
1885
1886 else
1887 OutStream << NA << endl;
1888
1889#else
1890 OutStream << NA << endl;
1891#endif
1892
1893 OutStream << endl;
1894
1895#ifdef _OPENMP
1896#pragma omp parallel
1897 {
1898 if (0 == omp_get_thread_num())
1899 {
1900 OutStream << "Number of OpenMP threads \t: " << omp_get_num_threads() << endl;
1901 OutStream << "Number of OpenMP processors \t: " << omp_get_num_procs() << endl;
1902
1903 LogStream << "Number of OpenMP threads \t: " << omp_get_num_threads() << endl;
1904 LogStream << "Number of OpenMP processors \t: " << omp_get_num_procs() << endl;
1905 }
1906 }
1907#endif
1908
1909 time_t const tRunTime = m_tSysEndTime - m_tSysStartTime;
1910 struct tm* ptmRunTime = gmtime(&tRunTime);
1911
1912 OutStream << "Time required for simulation \t: " << put_time(ptmRunTime, "%T") << endl;
1913 LogStream << "Time required for simulation \t: " << put_time(ptmRunTime, "%T") << endl;
1914
1915 double const dSpeedUp = m_dSimDuration * 3600 / static_cast<double>(tRunTime);
1916 OutStream << setprecision(0);
1917 OutStream << "Time simulated / time required for simulation\t: " << dSpeedUp << " x faster than reality" << endl;
1918
1919 LogStream << setprecision(0);
1920 LogStream << "Time simulated / time required for simulation\t: " << dSpeedUp << " x faster than reality" << endl;
1921}
1922
1923//===============================================================================================================================
1925//===============================================================================================================================
1926string CSimulation::strGetErrorText(int const nErr)
1927{
1928 string strErr;
1929
1930 switch (nErr)
1931 {
1932 case RTN_USER_ABORT:
1933 strErr = "run ended by user";
1934 break;
1935
1936 case RTN_ERR_BADPARAM:
1937 strErr = "error in command-line parameter";
1938 break;
1939
1940 case RTN_ERR_INI:
1941 strErr = "error reading initialization file";
1942 break;
1943
1944 case RTN_ERR_CMEDIR:
1945 strErr = "error in directory name";
1946 break;
1947
1948 case RTN_ERR_RUNDATA:
1949 strErr = "error reading run details file";
1950 break;
1951
1953 strErr = "error reading SCAPE shape function file";
1954 break;
1955
1957 strErr = "error reading tide data file";
1958 break;
1959
1960 case RTN_ERR_LOGFILE:
1961 strErr = "error creating log file";
1962 break;
1963
1964 case RTN_ERR_OUTFILE:
1965 strErr = "error creating text output file";
1966 break;
1967
1968 case RTN_ERR_TSFILE:
1969 strErr = "error creating time series file";
1970 break;
1971
1972 case RTN_ERR_DEMFILE:
1973 strErr = "error reading initial DEM file";
1974 break;
1975
1977 strErr = "error reading raster GIS file";
1978 break;
1979
1981 strErr = "error reading vector GIS file";
1982 break;
1983
1984 case RTN_ERR_MEMALLOC:
1985 strErr = "error allocating memory";
1986 break;
1987
1989 strErr = "problem with raster GIS output format";
1990 break;
1991
1993 strErr = "problem with vector GIS output format";
1994 break;
1995
1997 strErr = "error writing text output file";
1998 break;
1999
2001 strErr = "error writing raster GIS output file";
2002 break;
2003
2005 strErr = "error writing vector GIS output file";
2006 break;
2007
2009 strErr = "error writing time series output file";
2010 break;
2011
2012 case RTN_ERR_LINETOGRID:
2013 strErr = "error putting linear feature onto raster grid";
2014 break;
2015
2016 case RTN_ERR_NOSEACELLS:
2017 strErr = "no sea cells found";
2018 break;
2019
2020 case RTN_ERR_GRIDTOLINE:
2021 strErr = "error when searching grid for linear feature";
2022 break;
2023
2024 case RTN_ERR_NOCOAST:
2025 strErr = "no coastlines found. Is the SWL correct?";
2026 break;
2027
2029 strErr = "error writing coastline-normal profiles";
2030 break;
2031
2032 case RTN_ERR_TIMEUNITS:
2033 strErr = "error in time units";
2034 break;
2035
2037 strErr = "no solution when finding end point for coastline-normal line";
2038 break;
2039
2040 // case RTN_ERR_PROFILE_ENDPOINT_AT_GRID_EDGE:
2041 // strErr = "end point for coastline-normal line is at the grid edge";
2042 // break;
2044 strErr = "end point for coastline-normal line is not in the contiguous sea";
2045 break;
2046
2047 case RTN_ERR_CLIFFNOTCH:
2048 strErr = "cliff notch is above sediment top elevation";
2049 break;
2050
2052 strErr = "unable to deposit sediment from cliff collapse";
2053 break;
2054
2056 strErr = "coastline-normal profiles are too closely spaced";
2057 break;
2058
2060 strErr = "no coastline-normal profiles created, check the SWL";
2061 break;
2062
2064 strErr = "no coastline-normal profiles created during rasterization";
2065 break;
2066
2068 strErr = "hit grid edge when eroding beach";
2069 break;
2070
2072 strErr = "could not locate seaward end of profile when creating Dean profile for beach erosion";
2073 break;
2074
2076 strErr = "could not locate seaward end of profile when creating Dean profile for beach deposition (up-coast)";
2077 break;
2078
2080 strErr = "could not locate seaward end of profile when creating Dean profile for beach deposition (down-coast)";
2081 break;
2082
2084 strErr = "updating grid with landforms";
2085 break;
2086
2088 strErr = "no top layer of sediment";
2089 break;
2090
2092 strErr = "problem with polygon-to-polygon sediment routing sequence";
2093 break;
2094
2096 strErr = "inconsistent multiline";
2097 break;
2098
2100 strErr = "cannot insert point into multiline";
2101 break;
2102
2104 strErr = "cannot assign coastal landform";
2105 break;
2106
2108 strErr = "start point for cell-by-cell fill of wave shadow zone is outside grid";
2109 break;
2110
2112 strErr = "could not find start point for cell-by-cell fill of wave shadow zone";
2113 break;
2114
2116 strErr = "empty profile during during CShore wave propagation";
2117 break;
2118
2120 strErr = "creating file for CShore input";
2121 break;
2122
2124 strErr = "reading CShore output file";
2125 break;
2126
2128 strErr = "during wave interpolation lookup";
2129 break;
2130
2131 case RTN_ERR_GRIDCREATE:
2132 strErr = "while running GDALGridCreate()";
2133 break;
2134
2136 strErr = "cannot find edge cell while constructing grid-edge profile";
2137 break;
2138
2140 strErr = "CShore did not finish correctly";
2141 break;
2142
2144 strErr = "Could not find cell under coastline";
2145 break;
2146
2148 strErr = "opening deep sea wave time series file";
2149 break;
2150
2152 strErr = "reading deep sea wave time series file";
2153 break;
2154
2156 strErr = "finding edges of the bounding box";
2157 break;
2158
2160 strErr = "reading sediment input event time series file";
2161 break;
2162
2164 strErr = "simulating sediment input event";
2165 break;
2166
2168 strErr = "location of sediment input event is outside grod";
2169 break;
2170
2172 strErr = "location of wavestation is outside grid";
2173 break;
2174
2176 strErr = "cliff not in polygon";
2177 break;
2178
2180 strErr = "Cell marked as profile coast but not as profile";
2181 break;
2182
2184 strErr = "error tracing flood line on grid";
2185 break;
2186
2188 strErr = "error tracing coastline on grid, no coast start-finish points found";
2189 break;
2190
2192 strErr = "error tracing coastline on grid, no valid coast found";
2193 break;
2194
2196 strErr = "error tracing coastline on grid, coast search just repeats";
2197 break;
2198
2200 strErr = "error tracing coastline on grid, zero-length coast found";
2201 break;
2202
2204 strErr = "error tracing coastline on grid, coast below minimum permitted length";
2205 break;
2206
2208 strErr = "error tracing coastline on grid, coast ignored";
2209 break;
2210
2212 strErr = "error tracing coastline on grid, too many times round tracing loop";
2213 break;
2214
2216 strErr = "intersection cell not found in hit profile";
2217 break;
2218
2219 case RTN_ERR_UNKNOWN:
2220 strErr = "unknown error";
2221 break;
2222
2223 default:
2224 // should never get here
2225 strErr = "totally unknown error";
2226 }
2227
2228 return strErr;
2229}
2230
2231//===============================================================================================================================
2233//===============================================================================================================================
2235{
2236 // If we don't know the time that the run ended (e.g. because it did not finish correctly), then get it now
2237 if (m_tSysEndTime == 0)
2238 m_tSysEndTime = time(nullptr);
2239
2240 switch (nRtn)
2241 {
2242 case (RTN_OK):
2243 // normal ending
2244 cout << RUN_END_NOTICE << put_time(localtime(&m_tSysEndTime), "%T %A %d %B %Y") << endl;
2245 break;
2246
2247 case (RTN_HELP_ONLY):
2248 case (RTN_CHECK_ONLY):
2249 return;
2250
2251 default:
2252 // Aborting because of some error
2253 cerr << RUN_END_NOTICE << "iteration " << m_ulIter << ERROR_NOTICE << nRtn << " (" << strGetErrorText(nRtn) << ") on " << put_time(localtime(&m_tSysEndTime), "%T %A %d %B %Y") << endl;
2254
2255 if (m_ulIter > 1)
2256 {
2257 // If the run has actually started, then output all GIS files: this is very helpful in tracking down problems
2258 m_bSaveGISThisIter = true;
2259 m_nGISSave = 998; // Will get incremented to 999 when we write the files
2262 }
2263
2264 // Write the error message to the logfile and to stdout
2265 if (LogStream && LogStream.is_open())
2266 {
2267 LogStream << ERR << strGetErrorText(nRtn) << " (error code " << nRtn << ") on " << put_time(localtime(&m_tSysEndTime), "%T %A %d %B %Y") << endl;
2268 LogStream.flush();
2269 }
2270
2271 if (OutStream && OutStream.is_open())
2272 {
2273 OutStream << ERR << strGetErrorText(nRtn) << " (error code " << nRtn << ") on " << put_time(localtime(&m_tSysEndTime), "%T %A %d %B %Y") << endl;
2274 OutStream.flush();
2275 }
2276 }
2277
2278#ifdef __GNUG__
2279
2280 if (isatty(fileno(stdout)))
2281 {
2282 // Stdout is connected to a tty, so not running as a background job
2283 // cout << endl
2284 // << PRESS_KEY;
2285 // cout.flush();
2286 // getchar();
2287 }
2288 else
2289 {
2290 // Stdout is not connected to a tty, so must be running in the background; if we have something entered for the email address, then send an email
2291 if (! m_strMailAddress.empty())
2292 {
2293 cout << SEND_EMAIL << m_strMailAddress << endl;
2294
2295 string strCmd("echo \"");
2296
2297 stringstream ststrTmp;
2298 ststrTmp << put_time(localtime(&m_tSysEndTime), "%T on %A %d %B %Y") << endl;
2299
2300 // Send an email using Linux/Unix mail command
2301 if (RTN_OK == nRtn)
2302 {
2303 // Finished normally
2304 strCmd.append("Simulation ");
2305 strCmd.append(m_strRunName);
2306 strCmd.append(", running on ");
2307 strCmd.append(strGetComputerName());
2308 strCmd.append(", completed normally at ");
2309 strCmd.append(ststrTmp.str());
2310 strCmd.append("\" | mail -s \"");
2311 strCmd.append(PROGRAM_NAME);
2312 strCmd.append(": normal completion\" ");
2313 strCmd.append(m_strMailAddress);
2314 }
2315
2316 else
2317 {
2318 // Error, so give some information to help debugging
2319 strCmd.append("Simulation ");
2320 strCmd.append(m_strRunName);
2321 strCmd.append(", running on ");
2322 strCmd.append(strGetComputerName());
2323 strCmd.append(", aborted with error code ");
2324 strCmd.append(to_string(nRtn));
2325 strCmd.append(": ");
2326 strCmd.append(strGetErrorText(nRtn));
2327 strCmd.append(" at timestep ");
2328 strCmd.append(to_string(m_ulIter));
2329 strCmd.append(" (");
2330 strCmd.append(strDispSimTime(m_dSimElapsed));
2331 strCmd.append(").\n\nThis message sent at ");
2332 strCmd.append(ststrTmp.str());
2333 strCmd.append("\" | mail -s \"");
2334 strCmd.append(PROGRAM_NAME);
2335 strCmd.append(": ERROR\" ");
2336 strCmd.append(m_strMailAddress);
2337 }
2338
2339 int const nRet = system(strCmd.c_str());
2340
2341 if (WEXITSTATUS(nRet) != 0)
2342 cerr << ERR << EMAIL_ERROR << endl;
2343 }
2344 }
2345
2346#endif
2347}
2348
2349//===============================================================================================================================
2351//===============================================================================================================================
2352string CSimulation::pstrChangeToBackslash(string const* strIn)
2353{
2354 string strOut(*strIn);
2355 strOut.replace(strOut.begin(), strOut.end(), '/', '\\');
2356 return strOut;
2357}
2358
2359//===============================================================================================================================
2361//===============================================================================================================================
2362string CSimulation::pstrChangeToForwardSlash(string const* strIn)
2363{
2364 string strOut(*strIn);
2365 strOut.replace(strOut.begin(), strOut.end(), '\\', '/');
2366 return strOut;
2367}
2368
2369//===============================================================================================================================
2371//===============================================================================================================================
2372string CSimulation::strTrimLeft(string const* strIn)
2373{
2374 // Trim leading spaces
2375 size_t const nStartpos = strIn->find_first_not_of(" \t");
2376
2377 if (nStartpos == string::npos)
2378 return *strIn;
2379
2380 else
2381 return strIn->substr(nStartpos);
2382}
2383
2384//===============================================================================================================================
2386//===============================================================================================================================
2387string CSimulation::strTrimRight(string const* strIn)
2388{
2389 string strTmp(*strIn);
2390
2391 // Remove any stray carriage returns (can happen if file was edited in Windows)
2392 strTmp.erase(remove(strTmp.begin(), strTmp.end(), '\r'), strTmp.end());
2393
2394 // Trim trailing spaces
2395 size_t const nEndpos = strTmp.find_last_not_of(" \t");
2396
2397 if (nEndpos == string::npos)
2398 return strTmp;
2399
2400 else
2401 return strTmp.substr(0, nEndpos + 1);
2402}
2403
2404//===============================================================================================================================
2406//===============================================================================================================================
2407string CSimulation::strTrim(string const* strIn)
2408{
2409 string strTmp = *strIn;
2410
2411 // Remove any stray carriage returns (can happen if file was edited in Windows)
2412 strTmp.erase(remove(strTmp.begin(), strTmp.end(), '\r'), strTmp.end());
2413
2414 // Trim trailing spaces
2415 size_t nPos = strTmp.find_last_not_of(" \t");
2416
2417 if (nPos != string::npos)
2418 strTmp.resize(nPos + 1);
2419
2420 // Trim leading spaces
2421 nPos = strTmp.find_first_not_of(" \t");
2422
2423 if (nPos != string::npos)
2424 strTmp = strTmp.substr(nPos);
2425
2426 return strTmp;
2427}
2428
2429//===============================================================================================================================
2431//===============================================================================================================================
2432string CSimulation::strToLower(string const* strIn)
2433{
2434 string strOut = *strIn;
2435 transform(strIn->begin(), strIn->end(), strOut.begin(), tolower);
2436 return strOut;
2437}
2438
2439//===============================================================================================================================
2440// Returns the upper case version of an string, leaving the original unchanged
2441//===============================================================================================================================
2442// string CSimulation::strToUpper(string const* strIn)
2443// {
2444// string strOut = *strIn;
2445// transform(strIn->begin(), strIn->end(), strOut.begin(), toupper);
2446// return strOut;
2447// }
2448
2449//===============================================================================================================================
2451//===============================================================================================================================
2452string CSimulation::strRemoveSubstr(string* pStrIn, string const* pStrSub)
2453{
2454 size_t const nPos = pStrIn->find(*pStrSub);
2455
2456 if (nPos != string::npos)
2457 {
2458 // OK, found the substring
2459 pStrIn->replace(nPos, pStrSub->size(), "");
2460 return strTrim(pStrIn);
2461 }
2462
2463 else
2464 {
2465 // If not found, return the string unchanged
2466 return *pStrIn;
2467 }
2468}
2469
2470//===============================================================================================================================
2472//===============================================================================================================================
2473vector<string>* CSimulation::VstrSplit(string const* s, char const delim, vector<string>* elems)
2474{
2475 stringstream ss(*s);
2476 string item;
2477
2478 while (getline(ss, item, delim))
2479 {
2480 if (!item.empty())
2481 elems->push_back(item);
2482 }
2483
2484 return elems;
2485}
2486
2487//===============================================================================================================================
2489//===============================================================================================================================
2490vector<string> CSimulation::VstrSplit(string const* s, char const delim)
2491{
2492 vector<string> elems;
2493 VstrSplit(s, delim, &elems);
2494 return elems;
2495}
2496
2497// //===============================================================================================================================
2498// //! Calculates the vector cross product of three points
2499// //===============================================================================================================================
2500// double CSimulation::dCrossProduct(double const dX1, double const dY1, double const dX2, double const dY2, double const dX3, double const dY3)
2501// {
2502// // Based on code at http://debian.fmi.uni-sofia.bg/~sergei/cgsr/docs/clockwise.htm
2503// return (dX2 - dX1) * (dY3 - dY2) - ((dY2 - dY1) * (dX3 - dX2));
2504// }
2505
2506// //===============================================================================================================================
2507// //! Calculates the mean of a pointer to a vector of doubles
2508// //===============================================================================================================================
2509// double CSimulation::dGetMean(vector<double> const* pV)
2510// {
2511// double dSum = accumulate(pV->begin(), pV->end(), 0.0);
2512// double dMean = dSum / static_cast<double>(pV->size());
2513// return dMean;
2514// }
2515
2516// //===============================================================================================================================
2517// //! Calculates the standard deviation of a pointer to a vector of doubles. From http://stackoverflow.com/questions/7616511/calculate-mean-and-standard-deviation-from-a-vector-of-samples-in-c-using-boos
2518// //===============================================================================================================================
2519// double CSimulation::dGetStdDev(vector<double> const* pV)
2520// {
2521// double dSum = accumulate(pV->begin(), pV->end(), 0.0);
2522// double dMean = dSum / static_cast<double>(pV->size());
2523//
2524// double dSqSum = inner_product(pV->begin(), pV->end(), pV->begin(), 0.0);
2525// double dStdDev = sqrt(dSqSum / static_cast<double>(pV->size()) - dMean * dMean);
2526//
2527// return dStdDev;
2528// }
2529
2530//===============================================================================================================================
2532//===============================================================================================================================
2533void CSimulation::AppendEnsureNoGap(vector<CGeom2DIPoint>* pVPtiPoints, CGeom2DIPoint const* pPti)
2534{
2535 int const nX = pPti->nGetX();
2536 int const nY = pPti->nGetY();
2537 int const nXLast = pVPtiPoints->back().nGetX();
2538 int const nYLast = pVPtiPoints->back().nGetY();
2539 int const nXDiff = nX - nXLast;
2540 int const nYDiff = nY - nYLast;
2541 int const nXDiffA = tAbs(nXDiff);
2542 int const nYDiffA = tAbs(nYDiff);
2543 int const nDiff = tMax(nXDiffA, nYDiffA);
2544
2545 if (nDiff > 1)
2546 {
2547 // We have a gap
2548 double
2549 dXInc = 0,
2550 dYInc = 0;
2551
2552 if (nXDiffA > 1)
2553 dXInc = static_cast<double>(nXDiff) / nDiff;
2554
2555 if (nYDiffA > 1)
2556 dYInc = static_cast<double>(nYDiff) / nDiff;
2557
2558 for (int n = 1; n < nDiff; n++)
2559 {
2560 CGeom2DIPoint const Pti(nXLast + nRound(n * dXInc), nYLast + nRound(n * dYInc));
2561 pVPtiPoints->push_back(Pti);
2562 }
2563 }
2564
2565 pVPtiPoints->push_back(CGeom2DIPoint(nX, nY));
2566}
2567
2568//===============================================================================================================================
2570//===============================================================================================================================
2571void CSimulation::CalcDeanProfile(vector<double>* pdVDeanProfile, double const dInc, double const dDeanTopElev, double const dA, bool const bDeposition, int const nSeawardOffset, double const dStartCellElev)
2572{
2573 double dDistFromProfileStart = 0;
2574
2575 if (bDeposition)
2576 {
2577 // This Dean profile is for deposition i.e. seaward displacement of the profile
2578 pdVDeanProfile->at(0) = dStartCellElev; // Is talus-top elev for cliffs, coast elevation for coasts
2579
2580 for (int n = 1; n < static_cast<int>(pdVDeanProfile->size()); n++)
2581 {
2582 if (n <= nSeawardOffset)
2583 // As we extend the profile seaward, the elevation of any points coastward of the new coast point of the Dean profile are set to the elevation of the original coast or the talus top (is this realistic for talus?)
2584 pdVDeanProfile->at(n) = dStartCellElev;
2585
2586 else
2587 {
2588 double const dDistBelowTop = dA * pow(dDistFromProfileStart, DEAN_POWER);
2589 pdVDeanProfile->at(n) = dDeanTopElev - dDistBelowTop;
2590
2591 dDistFromProfileStart += dInc;
2592 }
2593 }
2594 }
2595
2596 else
2597 {
2598 // This Dean profile is for erosion i.e. landward displacement of the profile
2599 for (int n = 0; n < static_cast<int>(pdVDeanProfile->size()); n++)
2600 {
2601 double const dDistBelowTop = dA * pow(dDistFromProfileStart, DEAN_POWER);
2602 pdVDeanProfile->at(n) = dDeanTopElev - dDistBelowTop;
2603
2604 dDistFromProfileStart += dInc;
2605 }
2606 }
2607}
2608
2609//===============================================================================================================================
2611//===============================================================================================================================
2612double CSimulation::dSubtractProfiles(vector<double> const* pdVFirstProfile, vector<double> const* pdVSecondProfile, vector<bool> const* pbVIsValid)
2613{
2614 double dTotElevDiff = 0;
2615
2616 // Note that this assumes that all three vectors are of equal length, should really check this
2617 for (int n = 0; n < static_cast<int>(pdVFirstProfile->size()); n++)
2618 {
2619 if (pbVIsValid->at(n))
2620 {
2621 double const dProfileDiff = pdVFirstProfile->at(n) - pdVSecondProfile->at(n);
2622
2623 dTotElevDiff += dProfileDiff;
2624 }
2625 }
2626
2627 // // DEBUG CODE -----------------------------------------------------
2628 // LogStream << endl;
2629 // LogStream << "First profile = ";
2630 // for (int n = 0; n < static_cast<int>(pdVFirstProfile->size()); n++)
2631 // {
2632 // LogStream << pdVFirstProfile->at(n) << " ";
2633 // }
2634 // LogStream << endl;
2635 // LogStream << "Second profile = ";
2636 // for (int n = 0; n < static_cast<int>(pdVFirstProfile->size()); n++)
2637 // {
2638 // LogStream << pdVSecondProfile->at(n) << " ";
2639 // }
2640 // LogStream << endl;
2641 // LogStream << "Difference = ";
2642 // for (int n = 0; n < static_cast<int>(pdVFirstProfile->size()); n++)
2643 // {
2644 // LogStream << pdVFirstProfile->at(n) - pdVSecondProfile->at(n) << " ";
2645 // }
2646 // LogStream << endl;
2647 // // DEBUG CODE -----------------------------------------------------
2648
2649 return dTotElevDiff;
2650}
2651
2652//===============================================================================================================================
2654//===============================================================================================================================
2656{
2657 double
2658 dDeepWaterWaveHeight,
2659 dDeepWaterPeriod;
2660
2662 {
2663 dDeepWaterWaveHeight = m_dAllCellsDeepWaterWaveHeight;
2664 dDeepWaterPeriod = m_dAllCellsDeepWaterWavePeriod;
2665 }
2666
2667 else
2668 {
2669 dDeepWaterWaveHeight = m_dMaxUserInputWaveHeight;
2670 dDeepWaterPeriod = m_dMaxUserInputWavePeriod;
2671 }
2672
2673 // TODO 051 Calculate depth of closure using 'average of the maximum values observed during a typical year'
2674 // dL = 2.28 * Hsx − (68.5 * Hsx^2 / (g * Tsx^2))
2675 // where:
2676 // Hsx is the nearshore storm wave height that is exceeded only 12 hours each year
2677 // Tsx is the associated wave period
2678 // from Hallermeier, R.J. (1978). Uses for a calculated limit depth to beach erosion. Proc. 16th Coastal Engineering Conf., ASCE, New York. Pp 1493 - 1512
2679 //
2680 // For the time being, and since we assume wave height and period constant just use the actual wave height and period to calculate the depth of closure
2681 // m_dDepthOfClosure = (2.28 * dDeepWaterWaveHeight) - (68.5 * dDeepWaterWaveHeight * dDeepWaterWaveHeight / (m_dG * dDeepWaterPeriod * dDeepWaterPeriod));
2682
2683 // An alternative (which produces smaller depth of closure estimates) is Birkemeier (1985) TODO 007 Full reference needed
2684 // dL = 1.75 * Hsx - (57.9 * Hsx^2/ (g * Tsx^2))
2685 m_dDepthOfClosure = (1.75 * dDeepWaterWaveHeight) - (57.9 * dDeepWaterWaveHeight * dDeepWaterWaveHeight / (m_dG * dDeepWaterPeriod * dDeepWaterPeriod));
2686}
2687
2688// //===============================================================================================================================
2689// //! Tests a reference to a string to see if it is numeric (modified from https://tfetimes.com/c-determine-if-a-string-is-numeric/)
2690// //===============================================================================================================================
2691// bool CSimulation::bIsNumeric(string const*strIn)
2692// {
2693// return all_of(strIn->begin(), strIn->end(), isdigit);
2694// }
2695
2696//===============================================================================================================================
2698//===============================================================================================================================
2699bool CSimulation::bParseDate(string const* strDate, int& nDay, int& nMonth, int& nYear)
2700{
2701 vector<string> VstrTmp = VstrSplit(strDate, SLASH);
2702
2703 if (VstrTmp.size() < 3)
2704 {
2705 cerr << "date string must include day, month, and year '" << strDate << "'" << endl;
2706 return false;
2707 }
2708
2709 // Sort out day
2710 if (! bIsStringValidInt(VstrTmp[0]))
2711 {
2712 cerr << "invalid integer for day in date '" << strDate << "'" << endl;
2713 return false;
2714 }
2715
2716 nDay = stoi(VstrTmp[0]);
2717
2718 if ((nDay < 1) || (nDay > 31))
2719 {
2720 cerr << "day must be between 1 and 31 in date '" << strDate << "'" << endl;
2721 return false;
2722 }
2723
2724 // Sort out month
2725 if (! bIsStringValidInt(VstrTmp[1]))
2726 {
2727 cerr << "invalid integer for month in date '" << strDate << "'" << endl;
2728 return false;
2729 }
2730
2731 nMonth = stoi(VstrTmp[1]);
2732
2733 if ((nMonth < 1) || (nMonth > 12))
2734 {
2735 cerr << "month must be between 1 and 12 in date '" << strDate << "'" << endl;
2736 return false;
2737 }
2738
2739 // Sort out year
2740 if (! bIsStringValidInt(VstrTmp[2]))
2741 {
2742 cerr << "invalid integer for year in date '" << strDate << "'" << endl;
2743 return false;
2744 }
2745
2746 nYear = stoi(VstrTmp[2]);
2747
2748 if (nYear < 0)
2749 {
2750 cerr << "year must be > 0 in date '" << strDate << "'" << endl;
2751 return false;
2752 }
2753
2754 return true;
2755}
2756
2757//===============================================================================================================================
2759//===============================================================================================================================
2760bool CSimulation::bParseTime(string const* strTime, int& nHour, int& nMin, int& nSec)
2761{
2762 vector<string> VstrTmp = VstrSplit(strTime, DASH);
2763
2764 if (VstrTmp.size() < 3)
2765 {
2766 cerr << "time string must include hours, minutes, and seconds '" << strTime << "'" << endl;
2767 return false;
2768 }
2769
2770 // Sort out hour
2771 if (! bIsStringValidInt(VstrTmp[0]))
2772 {
2773 cerr << "invalid integer for hours in time '" << strTime << "'" << endl;
2774 return false;
2775 }
2776
2777 nHour = stoi(VstrTmp[0]);
2778
2779 if ((nHour < 0) || (nHour > 23))
2780 {
2781 cerr << "hour must be between 0 and 23 in time '" << strTime << "'" << endl;
2782 return false;
2783 }
2784
2785 // Sort out minutes
2786 if (! bIsStringValidInt(VstrTmp[1]))
2787 {
2788 cerr << "invalid integer for minutes in time '" << strTime << "'" << endl;
2789 return false;
2790 }
2791
2792 nMin = stoi(VstrTmp[1]);
2793
2794 if ((nMin < 0) || (nMin > 59))
2795 {
2796 cerr << "minutes must be betwen 0 and 59 in time '" << strTime << "'" << endl;
2797 return false;
2798 }
2799
2800 // Sort out seconds
2801 if (! bIsStringValidInt(VstrTmp[2]))
2802 {
2803 cerr << "invalid integer for seconds in time '" << strTime << "'" << endl;
2804 return false;
2805 }
2806
2807 nSec = stoi(VstrTmp[2]);
2808
2809 if ((nSec < 0) || (nSec > 59))
2810 {
2811 cerr << "seconds must be between 0 and 59 in time '" << strTime << "'" << endl;
2812 return false;
2813 }
2814
2815 return true;
2816}
2817
2818//===============================================================================================================================
2820//===============================================================================================================================
2821unsigned long CSimulation::ulConvertToTimestep(string const* pstrIn) const
2822{
2823 unsigned long ulTimeStep = 0;
2824
2825 // Convert to lower case, remove leading and trailing whitespace
2826 string strDate = strToLower(pstrIn);
2827 strDate = strTrim(&strDate);
2828
2829 if (strDate.find("hour") != string::npos)
2830 {
2831 // OK, this is a number of hours (a relative time, from the start of simulation)
2832 vector<string> VstrTmp = VstrSplit(&strDate, SPACE);
2833
2834 if ((VstrTmp.size() < 2) || (! bIsStringValidInt(VstrTmp[0])))
2835 {
2836 cerr << "Error in number of hours '" + strDate + "' for sediment input event" << endl;
2838 }
2839
2840 double const dHours = stod(strTrim(&VstrTmp[0]));
2841
2842 if (dHours > m_dSimDuration)
2843 {
2844 cerr << "Sediment input event '" + strDate + "' occurs after end of simulation" << endl;
2846 }
2847
2848 ulTimeStep = static_cast<unsigned long>(dRound(dHours / m_dTimeStep));
2849 }
2850
2851 else if (strDate.find("day") != string::npos)
2852 {
2853 // OK, this is a number of days (a relative time, from the start of simulation)
2854 vector<string> VstrTmp = VstrSplit(&strDate, SPACE);
2855
2856 if ((VstrTmp.size() < 2) || (! bIsStringValidInt(VstrTmp[0])))
2857 {
2858 cerr << "Error in number of days '" + strDate + "' for sediment input event" << endl;
2860 }
2861
2862 double const dHours = stod(strTrim(&VstrTmp[0])) * 24;
2863
2864 if (dHours > m_dSimDuration)
2865 {
2866 cerr << "Sediment input event '" + strDate + "' occurs after end of simulation" << endl;
2868 }
2869
2870 ulTimeStep = static_cast<unsigned long>(dRound(dHours / m_dTimeStep));
2871 }
2872
2873 else
2874 {
2875 // This is an absolute time/date in the format hh-mm-ss dd/mm/yyyy
2876 vector<string> VstrTmp = VstrSplit(&strDate, SPACE);
2877
2878 if (VstrTmp.size() < 2)
2879 {
2880 cerr << "Error in time/date '" + strDate + "' of sediment input event" << endl;
2882 }
2883
2884 int nHour = 0;
2885 int nMin = 0;
2886 int nSec = 0;
2887
2888 // OK, first sort out the time
2889 if (! bParseTime(&VstrTmp[0], nHour, nMin, nSec))
2890 {
2891 cerr << "Error in time '" + VstrTmp[0] + "' of sediment input event" << endl;
2893 }
2894
2895 int nDay = 0;
2896 int nMonth = 0;
2897 int nYear = 0;
2898
2899 // Now sort out the time
2900 if (! bParseDate(&VstrTmp[1], nDay, nMonth, nYear))
2901 {
2902 cerr << "Error in date '" + VstrTmp[1] + "' of sediment input event" << endl;
2904 }
2905
2906 // This is modified from https://stackoverflow.com/questions/14218894/number-of-days-between-two-dates-c
2907 struct tm tmSimStart = {};
2908 tmSimStart.tm_sec = m_nSimStartSec;
2909 tmSimStart.tm_min = m_nSimStartMin;
2910 tmSimStart.tm_hour = m_nSimStartHour;
2911 tmSimStart.tm_mday = m_nSimStartDay;
2912 tmSimStart.tm_mon = m_nSimStartMonth - 1;
2913 tmSimStart.tm_year = m_nSimStartYear - 1900;
2914
2915 struct tm tmSimEvent = {};
2916 tmSimEvent.tm_sec = nSec;
2917 tmSimEvent.tm_min = nMin;
2918 tmSimEvent.tm_hour = nHour;
2919 tmSimEvent.tm_mday = nDay;
2920 tmSimEvent.tm_mon = nMonth - 1;
2921 tmSimEvent.tm_year = nYear - 1900;
2922
2923 time_t const tStart = mktime(&tmSimStart);
2924 time_t const tEvent = mktime(&tmSimEvent);
2925
2926 if (tStart == (time_t)(-1))
2927 {
2928 cerr << "Error in simulation start time/date" << endl;
2930 }
2931
2932 if (tEvent == (time_t)(-1))
2933 {
2934 cerr << "Error in time/date '" + strDate + "' of sediment input event" << endl;
2936 }
2937
2938 double const dHours = difftime(tEvent, tStart) / (60 * 60);
2939
2940 if (dHours < 0)
2941 {
2942 cerr << "Sediment input event '" + strDate + "' occurs before start of simulation" << endl;
2944 }
2945
2946 if (dHours > m_dSimDuration)
2947 {
2948 cerr << "Sediment input event '" + strDate + "' occurs after end of simulation" << endl;
2950 }
2951
2952 ulTimeStep = static_cast<unsigned long>(dHours / m_dTimeStep);
2953 }
2954
2955 return ulTimeStep;
2956}
2957
2958//===============================================================================================================================
2960//===============================================================================================================================
2961bool CSimulation::bIsInterventionCell(int const nX, int const nY) const
2962{
2963 if (m_pRasterGrid->m_Cell[nX][nY].pGetLandform()->nGetLFCategory() == LF_CAT_INTERVENTION)
2964 return true;
2965
2966 return false;
2967}
2968
2969//===============================================================================================================================
2971//===============================================================================================================================
2973{
2974 return static_cast<int>(m_pVCoastPolygon.size());
2975}
2976
2977//===============================================================================================================================
2979//===============================================================================================================================
2981{
2982 // TODO 055 No check to see if nPoly < m_pVCoastPolygon.size()
2983 return m_pVCoastPolygon[nPoly];
2984}
2985
2986//===============================================================================================================================
2988//===============================================================================================================================
2990{
2991 m_pVCoastPolygon.push_back(pPolygon);
2992}
2993
2994//===============================================================================================================================
2996//===============================================================================================================================
2998{
2999 // Clear all vector coastlines, profiles, and polygons
3000 for (int i = 0; i < static_cast<int>(m_pVCoastPolygon.size()); i++)
3001 delete m_pVCoastPolygon[i];
3002
3003 m_pVCoastPolygon.clear();
3004 m_VCoast.clear();
3005
3006 // m_VFloodWaveSetup.clear();
3007 m_VFloodWaveSetupSurge.clear();
3009}
Contains CGeom2DIPoint definitions.
Geometry class used to represent 2D point objects with integer coordinates.
Definition 2di_point.h:29
int nGetY(void) const
Returns the CGeom2DIPoint object's integer Y coordinate.
Definition 2di_point.cpp:55
int nGetX(void) const
Returns the CGeom2DIPoint object's integer X coordinate.
Definition 2di_point.cpp:49
Geometry class used for coast polygon objects.
void CalcDepthOfClosure(void)
Calculate the depth of closure.
Definition utils.cpp:2655
int m_nLogFileDetail
The level of detail in the log file output. Can be LOG_FILE_LOW_DETAIL, LOG_FILE_MIDDLE_DETAIL,...
Definition simulation.h:579
bool m_bAvgSeaDepthSave
Save average sea depth raster GIS files?
Definition simulation.h:114
vector< string > m_VstrInitialSandConsSedimentFile
The name of the initial sand-sized consolidated sediment GIS file.
double m_dAllCellsDeepWaterWaveHeight
Deep water wave height (m) for all sea cells.
Definition simulation.h:759
static void AnnounceInitializing(void)
Tells the user that we are now initializing.
Definition utils.cpp:655
bool m_bTopSurfSave
Save fop surface (sediment and sea) raster DEMs?
Definition simulation.h:99
static void AnnounceReadSCAPEShapeFunctionFile(void)
Now reading the SCAPE shape function file.
Definition utils.cpp:647
string m_strInitialSuspSedimentFile
Name of initial suspended sediment file.
static void AnnounceIsRunning(void)
Tell the user that the simulation is now running.
Definition utils.cpp:664
void DoCPUClockReset(void)
Resets the CPU clock timer to prevent it 'rolling over', as can happen during long runs....
Definition utils.cpp:1395
bool m_bSedimentTopSurfSave
Save sediment top surface raster DEMs?
Definition simulation.h:96
bool m_bFineUnconsSedSave
Save fine unconsolidated sediment raster GIS files?
Definition simulation.h:198
string m_strSedimentInputEventFile
The name of the sediment input events time series file.
time_t m_tSysEndTime
System finish-simulation time.
string m_strCMEIni
Folder for the CME .ini file.
double m_dG
Gravitational acceleration (m**2/sec)
Definition simulation.h:816
vector< string > m_VstrInitialCoarseUnconsSedimentFile
The name of the initial coarse-sized unconsolidated sediment GIS file.
void AnnounceReadDeepWaterWaveValuesGIS(void) const
Tells the user that we are now reading the deep water wave values GIS file.
Definition utils.cpp:499
ofstream CliffCollapseNetChangeTSStream
bool m_bCoastSave
Save.
Definition simulation.h:270
bool m_bBeachDepositionTSSave
Save the beach (unconsolidated sediment) deposition time series file?
Definition simulation.h:321
static string strRemoveSubstr(string *, string const *)
Returns a string with a substring removed, and with whitespace trimmed.
Definition utils.cpp:2452
CGeomRasterGrid * m_pRasterGrid
Pointer to the raster grid object.
static bool bParseTime(string const *, int &, int &, int &)
Parses a time string into hours, minutes, and seconds, and checks each of them.
Definition utils.cpp:2760
void AnnounceReadInitialSandConsSedGIS(int const) const
Tells the user that we are now reading the initial sand consolidated sediment depth GIS file.
Definition utils.cpp:609
string strListRasterFiles(void) const
Return a space-separated string containing the names of the raster GIS output files.
Definition utils.cpp:672
void AnnounceReadInitialSandUnconsSedGIS(int const) const
Tells the user that we are now reading the initial sand unconsolidated sediment depth GIS file.
Definition utils.cpp:570
string strListVectorFiles(void) const
Return a space-separated string containing the names of the vector GIS output files.
Definition utils.cpp:926
double m_dMaxUserInputWavePeriod
Used to constrain depth of closure.
Definition simulation.h:771
bool m_bFloodSetupSurgeRunupTSSave
Save the flood setup surge runup time series file? TODO 007 Does this work correctly?
Definition simulation.h:333
bool bSetUpTSFiles(void)
The bSetUpTSFiles member function sets up the time series files.
Definition utils.cpp:1116
ofstream LogStream
void AnnounceReadInitialFineUnconsSedGIS(int const) const
Tells the user that we are now reading the initial fine unconsolidated sediment depth GIS file.
Definition utils.cpp:557
vector< CRWCoast > m_VFloodWaveSetupSurgeRunup
TODO 007 Info needed.
vector< CRWCoast > m_VCoast
The coastline objects.
static string pstrChangeToForwardSlash(string const *)
Swaps all backslashes in the input string to forward slashes, leaving the original unchanged.
Definition utils.cpp:2362
bool m_bSaveGISThisIter
Save GIS files this iteration?
Definition simulation.h:336
void DoSimulationEnd(int const)
Carries out end-of-simulation tidying (error messages etc.)
Definition utils.cpp:2234
double m_dCPUClock
Total elapsed CPU time.
Definition simulation.h:699
bool bSaveAllVectorGISFiles(void)
bool m_bSingleDeepWaterWaveValues
Do we have just a point source for (i.e. only a single measurement of) deep water wave values.
Definition simulation.h:390
string m_strRunName
The name of this simulation.
static string strGetComputerName(void)
Returns a string, hopefully giving the name of the computer on which the simulation is running.
Definition utils.cpp:1370
static string strDispSimTime(double const)
strDispSimTime returns a string formatted as year Julian_day hour, given a parameter in hours
Definition utils.cpp:1530
bool m_bAvgWaveAngleAndHeightSave
Save average wave angle and average wave height raster GIS files?
Definition simulation.h:132
bool m_bInvalidNormalsSave
Save invalid coastline-normal vector GIS files?
Definition simulation.h:279
bool m_bShadowBoundarySave
Save wave shadow boundary vector GIS files?
Definition simulation.h:294
int nDoSimulationTimeMultiplier(string const *)
Given a string containing time units, this sets up the appropriate multiplier and display units for t...
Definition utils.cpp:324
bool m_bActualBeachErosionSave
Save actual (supply-limited) beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:165
bool m_bStillWaterLevelTSSave
Save the still water level time series file?
Definition simulation.h:303
bool m_bYamlInputFormat
Use YAML format for input datafile instead of .dat format?
Definition simulation.h:351
bool m_bTotalActualPlatformErosionSave
Save total actual (supply-limited) shore platform erosion raster GIS files?
Definition simulation.h:159
static string strTrimLeft(string const *)
Trims whitespace from the left side of a string, does not change the original string.
Definition utils.cpp:2372
vector< string > m_VstrInitialFineConsSedimentFile
The name of the initial fine-sized consolidated sediment GIS file.
bool m_bBasementElevSave
Save basement raster DEMs?
Definition simulation.h:93
int m_nSimStartHour
Start time of the simulation (hours)
Definition simulation.h:564
bool m_bCoarseUnconsSedSave
Save coarse unconsolidated sediment raster GIS files?
Definition simulation.h:204
bool m_bSuspSedTSSave
Save the suspended sediment time series file?
Definition simulation.h:327
bool m_bCliffCollapseNetTSSave
Save the cliff collapse net change time series file?
Definition simulation.h:315
bool m_bPotentialPlatformErosionMaskSave
Save potential platform erosion mask raster GIS files?
Definition simulation.h:240
static void AnnounceSimEnd(void)
Announce the end of the simulation.
Definition utils.cpp:1445
void AnnounceReadICGIS(void) const
Tells the user that we are now reading the Intervention class GIS file.
Definition utils.cpp:469
bool m_bWaveHeightSave
Save wave height raster GIS files?
Definition simulation.h:117
bool m_bLandformSave
Save coast landform raster GIS files?
Definition simulation.h:180
ofstream CliffCollapseDepositionTSStream
Cliff collapse deposition time series file output stream.
vector< CRWCoast > m_VFloodWaveSetupSurge
TODO 007 Info needed.
static string strTrim(string const *)
Trims whitespace from both sides of a string, does not change the original string.
Definition utils.cpp:2407
bool m_bTotalBeachDepositionSave
Save total beach (unconsolidated sediment) deposition raster GIS files?
Definition simulation.h:177
int m_nSimStartSec
Start time of the simulation (seconds)
Definition simulation.h:558
int m_nSimStartDay
Start date of the simulation (day)
Definition simulation.h:567
bool m_bSandUnconsSedSave
Save sand unconsolidated sediment raster GIS files?
Definition simulation.h:201
bool m_bActualPlatformErosionTSSave
Save the actual (supply-limited) shore platform erosion time series file?
Definition simulation.h:306
unsigned long ulConvertToTimestep(string const *) const
For sediment input events, parses a string that may be relative (a number of hours or days after the ...
Definition utils.cpp:2821
static void AnnounceAddLayers(void)
Tells the user that we are now adding layers.
Definition utils.cpp:429
bool m_bRasterPolygonSave
Save raster polygon raster GIS files?
Definition simulation.h:237
bool m_bBeachDepositionSave
Save beach (unconsolidated sediment) deposition raster GIS files?
Definition simulation.h:174
bool bFindExeDir(char const *)
Finds the folder (directory) in which the CoastalME executable is located.
Definition utils.cpp:229
static double dSubtractProfiles(vector< double > const *, vector< double > const *, vector< bool > const *)
Calculate the total elevation difference between every point in two elevation profiles (first profile...
Definition utils.cpp:2612
bool m_bNormalsSave
Save coastline-normal vector GIS files?
Definition simulation.h:276
bool m_bAvgWaveHeightSave
Save wave height raster GIS files?
Definition simulation.h:120
static string strToLower(string const *)
Returns the lower case version of an string, leaving the original unchanged.
Definition utils.cpp:2432
bool m_bHaveSandSediment
Does this simulation consider sand-sized sediment?
Definition simulation.h:87
bool m_bSeaDepthSave
Save sea depth raster GIS files?
Definition simulation.h:111
bool m_bWaveAngleAndHeightSave
Save wave angle and wave height raster GIS files?
Definition simulation.h:129
ofstream BeachDepositionTSStream
Beach sediment deposition time series file output stream.
string m_strInitialBasementDEMFile
Name of initial basement DEM file.
static string strTrimRight(string const *)
Trims whitespace from the right side of a string, does not change the original string.
Definition utils.cpp:2387
void AnnounceReadSedimentEventInputValuesGIS(void) const
Tells the user that we are now reading the sediment input events GIS file.
Definition utils.cpp:514
string m_strLogFile
Name of output log file.
time_t m_tSysStartTime
System start-simulation time.
void AnnounceReadFloodLocationGIS(void) const
Tells the user that we are now reading the flood location GIS file.
Definition utils.cpp:529
void StartClock(void)
Starts the clock ticking.
Definition utils.cpp:205
bool m_bRasterNormalProfileSave
Save rasterized coastline-normal profiles GIS files?
Definition simulation.h:219
bool m_bActiveZoneSave
Save active zone raster GIS files?
Definition simulation.h:222
void AnnounceReadInitialSuspSedGIS(void) const
Tells the user that we are now reading the initial suspended sediment depth GIS file.
Definition utils.cpp:544
ofstream StillWaterLevelTSStream
SWL time series file output stream.
void DoEndOfRunDeletes(void)
Do end-of-run memory clearance.
Definition utils.cpp:2997
vector< string > m_VstrInitialSandUnconsSedimentFile
The name of the initial sand-sized unconsolidated sediment GIS file.
static int nDoTimeUnits(string const *)
This finds time units in a string.
Definition utils.cpp:363
static void AnnounceReadRasterFiles(void)
Now reading raster GIS files.
Definition utils.cpp:438
string m_strCMEDir
The CME folder.
bool m_bMeanWaveEnergySave
Save mean wave energy raster GIS files?
Definition simulation.h:141
ofstream BeachSedimentNetChangeTSStream
double m_dSimElapsed
Time simulated so far, in hours.
Definition simulation.h:684
static double dGetTimeMultiplier(string const *)
Given a string containing time units, this returns the appropriate multiplier.
Definition utils.cpp:289
bool m_bCoastCurvatureSave
Save coastline-curvature vector GIS files?
Definition simulation.h:282
void AnnounceReadBasementDEM(void) const
Tells the user that we are now reading the DEM file.
Definition utils.cpp:408
bool m_bBreakingWaveHeightSave
Save breaking wave height raster GIS files?
Definition simulation.h:144
string m_strMailAddress
An email addresx to which to send end-of-simulation messages.
bool m_bPolygonNodeSave
Save polygon node vector GIS files?
Definition simulation.h:285
string strListTSFiles(void) const
Return a space-separated string containing the names of the time series output files.
Definition utils.cpp:1030
bool m_bFloodSetupSurgeTSSave
Save the flood setup surge time series file? TODO 007 Does this work correctly?
Definition simulation.h:330
bool m_bTotalPotentialPlatformErosionSave
Save total potential shore platform erosion raster GIS files?
Definition simulation.h:156
bool m_bWaveEnergySinceCollapseSave
Save wave energy since cliff collapse raster GIS files?
Definition simulation.h:138
static void AnnounceStart(void)
Tells the user that we have started the simulation.
Definition utils.cpp:196
ofstream CliffCollapseErosionTSStream
Cliff collapse erosion time series file output stream.
bool m_bPotentialBeachErosionSave
Save potential beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:162
static bool bParseDate(string const *, int &, int &, int &)
Parses a date string into days, months, and years, and checks each of them.
Definition utils.cpp:2699
string m_strFloodLocationShapefile
The name of the flood loction events shape file.
int m_nSimStartMonth
Start date of the simulation (month)
Definition simulation.h:570
bool m_bSuspSedSave
Save suspended sediment raster GIS files?
Definition simulation.h:192
string m_strDurationUnits
The duration units for this simulation.
bool m_bPolygonBoundarySave
Save polygon boundary vector GIS files?
Definition simulation.h:288
vector< string > m_VstrInitialFineUnconsSedimentFile
The name of the initial fine-sized unconsolidated sediment GIS file.
bool m_bActualPlatformErosionSave
Save actual (supply-limited) shore platform erosion raster GIS files?
Definition simulation.h:153
int m_nSimStartMin
Start time of the simulation (minutes)
Definition simulation.h:561
bool bSaveAllRasterGISFiles(void)
bool m_bHaveFineSediment
Does this simulation consider fine-sized sediment?
Definition simulation.h:84
string m_strOutPath
Path for all output files.
bool m_bBeachErosionTSSave
Save the beach (unconsolidated sediment) erosion time series file?
Definition simulation.h:318
static string strGetBuild(void)
Returns the date and time on which the program was compiled.
Definition utils.cpp:1645
string m_strTideDataFile
Name of tide data file.
bool m_bTotalPotentialBeachErosionSave
Save total potential beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:168
int m_nGISSave
The save number for GIS files (can be sequential, or the iteration number)
Definition simulation.h:507
string m_strInterventionClassFile
Name of intervention class file.
bool m_bSeaMaskSave
Save sea mask raster GIS files?
Definition simulation.h:243
void CalcTime(double const)
Calculates and displays time elapsed in terms of CPU time and real time, also calculates time per tim...
Definition utils.cpp:1454
bool m_bInterventionClassSave
Save intervention class raster GIS files?
Definition simulation.h:186
int m_nSimStartYear
Start date of the simulation (year)
Definition simulation.h:573
bool m_bTotalActualBeachErosionSave
Save total actual (supply-limited) beach (unconsolidated sediment) erosion raster GIS files?
Definition simulation.h:171
bool m_bRasterCoastlineSave
Save rasterized coastline GIS files?
Definition simulation.h:216
string m_strDeepWaterWavesInputFile
The name of the deep water wave stations time series file.
static string pstrChangeToBackslash(string const *)
Changes all forward slashes in the input string to backslashes, leaving the original unchanged.
Definition utils.cpp:2352
bool m_bInterventionHeightSave
Save intervention height raster GIS files?
Definition simulation.h:189
ofstream SeaAreaTSStream
Sea area time series file output stream.
void AnnounceReadIHGIS(void) const
Tells the user that we are now reading the Intervention height GIS file.
Definition utils.cpp:484
void AnnounceReadInitialCoarseConsSedGIS(int const) const
Tells the user that we are now reading the initial coarse consolidated sediment depth GIS file.
Definition utils.cpp:622
static string strGetErrorText(int const)
Returns an error message given an error code.
Definition utils.cpp:1926
bool m_bSandConsSedSave
Save sand consolidated sediment raster GIS files?
Definition simulation.h:210
CGeomCoastPolygon * pGetPolygon(int const) const
Returns a pointer to a coast polygon, in down-coast sequence.
Definition utils.cpp:2980
bool m_bSedimentInputEventSave
Save sediment inut data?
Definition simulation.h:408
bool m_bHaveCoarseSediment
Does this simulation consider coarse-sized sediment?
Definition simulation.h:90
double m_dTimeStep
The length of an iteration (a time step) in hours.
Definition simulation.h:681
static void AnnounceAllocateMemory(void)
Tells the user that we are now allocating memory.
Definition utils.cpp:421
bool m_bCliffCollapseDepositionTSSave
Save the cliff collapse deposition time series file?
Definition simulation.h:312
ofstream PlatformErosionTSStream
Shore platform erosion time series file output stream.
bool m_bDeepWaterWaveAngleAndHeightSave
Save deep water wave angle and wave height raster GIS files?
Definition simulation.h:135
double m_dMaxUserInputWaveHeight
Maximum deep water wave height.
Definition simulation.h:768
void AnnounceReadInitialFineConsSedGIS(int const) const
Tells the user that we are now reading the initial fine consolidated sediment depth GIS file.
Definition utils.cpp:596
bool m_bBeachProtectionSave
Save beach protection raster GIS files>
Definition simulation.h:147
static string strDispTime(double const, bool const, bool const)
strDispTime returns a string formatted as h:mm:ss, given a parameter in seconds, with rounding and fr...
Definition utils.cpp:1581
bool m_bFineConsSedSave
Save fine consolidated sediment raster GIS files?
Definition simulation.h:207
bool m_bShadowDowndriftBoundarySave
Save wave shadow downdrift boundary vector GIS files?
Definition simulation.h:297
string m_strInitialLandformFile
Name of initial landform file.
string m_strInterventionHeightFile
Name of intervention height file.
bool m_bBeachSedimentChangeNetTSSave
Save the beach (unconsolidated sediment) net change time series file?
Definition simulation.h:324
bool m_bCoarseConsSedSave
Save coarse consolidated sediment raster GIS files?
Definition simulation.h:213
bool m_bSeaAreaTSSave
Save the sea area time series file?
Definition simulation.h:300
void CalcProcessStats(void)
This calculates and displays process statistics.
Definition utils.cpp:1699
int nGetCoastPolygonSize(void) const
Returns the size of the coast polygon vector.
Definition utils.cpp:2972
bool m_bBeachMaskSave
Save beach mask raster GIS files?
Definition simulation.h:246
bool bOpenLogFile(void)
Opens the log file.
Definition utils.cpp:384
static void AppendEnsureNoGap(vector< CGeom2DIPoint > *, CGeom2DIPoint const *)
Appends a CGeom2DIPoint to a vector<CGeom2DIPoint>, making sure that the new end point touches the pr...
Definition utils.cpp:2533
unsigned long m_ulIter
The number of the current iteration (time step)
Definition simulation.h:603
void AnnounceLicence(void)
Tells the user about the licence.
Definition utils.cpp:268
bool m_bAvgSuspSedSave
Save average suspended sediment raster GIS files?
Definition simulation.h:195
vector< string > m_VstrInitialCoarseConsSedimentFile
The name of the initial coarse-sized consolidated sediment GIS file.
double m_dSimDuration
Duration of simulation, in hours.
Definition simulation.h:678
ofstream FloodSetupSurgeTSStream
Flood setup surge time series file output stream.
bool bTimeToQuit(void)
Checks to see if the simulation has gone on too long, amongst other things.
Definition utils.cpp:1342
bool bIsInterventionCell(int const, int const) const
Returns true if the cell is an intervention.
Definition utils.cpp:2961
void AnnounceProgress(void)
Displays information regarding the progress of the simulation.
Definition utils.cpp:1662
double m_dAllCellsDeepWaterWavePeriod
Deep water wave period for all sea cells.
Definition simulation.h:765
void AnnounceReadLGIS(void) const
Tells the user that we are now reading the Landscape category GIS file.
Definition utils.cpp:454
static void AnnounceReadVectorFiles(void)
Now reading vector GIS files.
Definition utils.cpp:446
double m_dDepthOfClosure
Depth of closure (in m) TODO 007 can be calculated using Hallermeier, R.J. (1978) or Birkemeier (1985...
Definition simulation.h:822
static void CalcDeanProfile(vector< double > *, double const, double const, double const, bool const, int const, double const)
Calculates a Dean equilibrium profile h(y) = A * y^(2/3) where h(y) is the distance below the highest...
Definition utils.cpp:2571
ofstream FineSedSuspensionTSStream
Fine sediment in suspension time series file output stream.
ofstream FloodSetupSurgeRunupTSStream
Flood setup surge runup time series file output stream.
void AnnounceReadTideData(void) const
Now reading tide data file.
Definition utils.cpp:635
double m_dClkLast
Last value returned by clock()
Definition simulation.h:696
bool m_bCliffCollapseErosionTSSave
Save the cliff collapse erosion time series file?
Definition simulation.h:309
bool m_bPotentialPlatformErosionSave
Save potential shore platform erosion raster GIS files?
Definition simulation.h:150
ofstream BeachErosionTSStream
Beach sediment erosion time series file output stream.
void AnnounceReadInitialCoarseUnconsSedGIS(int const) const
Tells the user that we are now reading the initial coarse unconsolidated sediment depth GIS file.
Definition utils.cpp:583
int nHandleCommandLineParams(int, char const *[])
Handles command-line parameters.
Definition utils.cpp:92
ofstream OutStream
The main output file stream.
double m_dDurationUnitsMult
Multiplier for duration units, to convert to hours.
Definition simulation.h:645
unsigned long m_ulTotTimestep
The target number of iterations.
Definition simulation.h:606
static vector< string > * VstrSplit(string const *, char const, vector< string > *)
From http://stackoverflow.com/questions/236129/split-a-string-in-c They implement (approximately) Pyt...
Definition utils.cpp:2473
bool m_bSedimentInputThisIter
Do we have a sediment input event this iteration?
Definition simulation.h:411
bool m_bCliffNotchSave
Save cliff notch incision depth vector GIS files?
Definition simulation.h:291
bool m_bWaveAngleSave
Save wave angle raster GIS files?
Definition simulation.h:123
void AppendPolygon(CGeomCoastPolygon *)
Appends a pointer to a coast polygon to the coast polygon vector.
Definition utils.cpp:2989
vector< CGeomCoastPolygon * > m_pVCoastPolygon
Pointers to coast polygon objects, in down-coast sequence TODO 044 Will need to use global polygon ID...
bool m_bLocalSlopeSave
Save local slope raster GIS files?
Definition simulation.h:183
This file contains global definitions for CoastalME.
string const TIME_SERIES_CLIFF_COLLAPSE_DEPOSITION_CODE
Definition cme.h:1222
string const READING_UNCONS_SAND_SEDIMENT_FILE
Definition cme.h:872
string const TIME_SERIES_SUSPENDED_SEDIMENT_CODE
Definition cme.h:1237
char const SLASH
Definition cme.h:452
string const RASTER_POTENTIAL_PLATFORM_EROSION_MASK_CODE
Definition cme.h:970
string const RASTER_SEA_DEPTH_NAME
Definition cme.h:951
string const USAGE3
Definition cme.h:856
int const RTN_ERR_READING_SEDIMENT_INPUT_EVENT
Definition cme.h:756
int const RTN_ERR_CLIFFNOTCH
Definition cme.h:730
double const TOLERANCE
Definition cme.h:823
string const TIME_SERIES_PLATFORM_EROSION_CODE
Definition cme.h:1216
int const RTN_ERR_NO_TOP_LAYER
Definition cme.h:738
string const DISCLAIMER4
Definition cme.h:845
string const RASTER_COARSE_CONS_CODE
Definition cme.h:1012
string const VECTOR_POLYGON_NODE_CODE
Definition cme.h:1156
int const RTN_ERR_GRIDTOLINE
Definition cme.h:726
int const RTN_ERR_TIMEUNITS
Definition cme.h:729
string const COPYRIGHT
Definition cme.h:840
string const USAGE1
Definition cme.h:854
string const TIME_SERIES_FLOOD_SETUP_SURGE_RUNUP_CODE
Definition cme.h:1243
string const READING_VECTOR_FILES
Definition cme.h:877
string const READING_CONS_FINE_SEDIMENT_FILE
Definition cme.h:874
int const RTN_ERR_NOCOAST
Definition cme.h:727
int const RTN_ERR_DEMFILE
Definition cme.h:707
string const READING_BASEMENT
Definition cme.h:865
string const RASTER_ACTIVE_ZONE_CODE
Definition cme.h:1018
int const RTN_HELP_ONLY
Definition cme.h:695
int const RTN_ERR_COAST_CANT_FIND_EDGE_CELL
Definition cme.h:750
int const RTN_ERR_CSHORE_FILE_INPUT
Definition cme.h:746
string const RASTER_SAND_CONS_CODE
Definition cme.h:1010
string const USAGE6
Definition cme.h:859
string const TIME_SERIES_FLOOD_SETUP_SURGE_CODE
Definition cme.h:1240
int const RTN_ERR_MEMALLOC
Definition cme.h:710
string const DISCLAIMER5
Definition cme.h:846
int const RTN_ERR_SCAPE_SHAPE_FUNCTION_FILE
Definition cme.h:702
int const RTN_CHECK_ONLY
Definition cme.h:696
string const ERR
Definition cme.h:903
int const RTN_ERR_WAVESTATION_LOCATION
Definition cme.h:759
int const RTN_ERR_LOGFILE
Definition cme.h:704
string const RASTER_COAST_NORMAL_CODE
Definition cme.h:1016
string const RASTER_AVG_SUSP_SED_CODE
Definition cme.h:1000
string const TIME_SERIES_STILL_WATER_LEVEL_NAME
Definition cme.h:1212
string const RASTER_COAST_CODE
Definition cme.h:1014
int const RTN_ERR_SHADOW_ZONE_FLOOD_START_POINT
Definition cme.h:744
string const RASTER_SEDIMENT_INPUT_EVENT_CODE
Definition cme.h:1058
string const VECTOR_WAVE_ENERGY_SINCE_COLLAPSE_CODE
Definition cme.h:1150
string const USAGE4
Definition cme.h:857
string const RASTER_WAVE_ORIENTATION_CODE
Definition cme.h:960
int const RTN_ERR_EDGE_OF_GRID
Definition cme.h:733
string const ABOUT
Definition cme.h:849
string const READING_CONS_SAND_SEDIMENT_FILE
Definition cme.h:875
int const RTN_ERR_GRIDCREATE
Definition cme.h:749
int const RTN_ERR_RASTER_GIS_OUT_FORMAT
Definition cme.h:711
string const TIME_SERIES_BEACH_EROSION_NAME
Definition cme.h:1227
int const RTN_ERR_LANDFORM_TO_GRID
Definition cme.h:737
int const RTN_ERR_RASTER_FILE_WRITE
Definition cme.h:714
string const INITIALIZING_NOTICE
Definition cme.h:862
string const RASTER_COARSE_UNCONS_CODE
Definition cme.h:1006
int const RTN_ERR_BADPARAM
Definition cme.h:698
string const READING_RASTER_FILES
Definition cme.h:866
string const USAGE2
Definition cme.h:855
char const PATH_SEPARATOR
Definition cme.h:449
int const RTN_ERR_SHADOW_ZONE_FLOOD_FILL_NOGRID
Definition cme.h:743
string const VECTOR_INVALID_NORMALS_CODE
Definition cme.h:1142
int const RTN_ERR_TOO_LONG_TRACING_COAST
Definition cme.h:770
string const RASTER_BASEMENT_ELEVATION_CODE
Definition cme.h:942
int const RTN_ERR_PROFILEWRITE
Definition cme.h:728
string const RASTER_WAVE_HEIGHT_CODE
Definition cme.h:956
string const RASTER_INTERVENTION_CLASS_CODE
Definition cme.h:994
int const RTN_ERR_IGNORING_COAST
Definition cme.h:769
string const EMAIL_ERROR
Definition cme.h:894
string const RASTER_POTENTIAL_PLATFORM_EROSION_CODE
Definition cme.h:972
int const RTN_ERR_WAVE_INTERPOLATION_LOOKUP
Definition cme.h:748
string const RASTER_POTENTIAL_BEACH_EROSION_CODE
Definition cme.h:980
string const READING_CONS_COARSE_SEDIMENT_FILE
Definition cme.h:876
string const READING_TIDE_DATA_FILE
Definition cme.h:882
int const RTN_ERR_RASTER_FILE_READ
Definition cme.h:708
string const VECTOR_MEAN_WAVE_ENERGY_CODE
Definition cme.h:1152
int const TIME_UNKNOWN
Definition cme.h:520
string const READING_SCAPE_SHAPE_FUNCTION_FILE
Definition cme.h:881
int const RTN_ERR_CSHORE_ERROR
Definition cme.h:751
string const TIME_SERIES_BEACH_DEPOSITION_NAME
Definition cme.h:1230
string const READING_INTERVENTION_CLASS_FILE
Definition cme.h:868
bool bFPIsEqual(const T d1, const T d2, const T dEpsilon)
Definition cme.h:1304
string const DISCLAIMER3
Definition cme.h:844
int const RTN_ERR_PROFILESPACING
Definition cme.h:718
string const READING_UNCONS_COARSE_SEDIMENT_FILE
Definition cme.h:873
int const TIME_HOURS
Definition cme.h:521
string const READING_DEEP_WATER_WAVE_FILE
Definition cme.h:878
string const CSVEXT
Definition cme.h:929
int const RTN_ERR_BOUNDING_BOX
Definition cme.h:755
int const RTN_ERR_NO_SEAWARD_END_OF_PROFILE_DOWNCOAST_BEACH_DEPOSITION
Definition cme.h:736
string const TIME_SERIES_CLIFF_COLLAPSE_NET_CODE
Definition cme.h:1225
int const RTN_ERR_OPEN_DEEP_WATER_WAVE_DATA
Definition cme.h:753
int const RTN_ERR_RUNDATA
Definition cme.h:701
int const RTN_ERR_SEDIMENT_INPUT_EVENT_LOCATION
Definition cme.h:758
string const RASTER_TOTAL_ACTUAL_BEACH_EROSION_CODE
Definition cme.h:986
string const INITIALIZING
Definition cme.h:885
string const VECTOR_NORMALS_CODE
Definition cme.h:1140
int const CLOCK_CHECK_ITERATION
Definition cme.h:467
string const RASTER_BEACH_DEPOSITION_CODE
Definition cme.h:988
string const FINAL_OUTPUT
Definition cme.h:888
string const RASTER_TOTAL_BEACH_DEPOSITION_CODE
Definition cme.h:990
string const USAGE
Definition cme.h:853
T tMax(T a, T b)
Definition cme.h:1253
string const SIMULATING
Definition cme.h:887
string const TIME_SERIES_BEACH_CHANGE_NET_NAME
Definition cme.h:1233
int const RTN_ERR_NO_ADJACENT_POLYGON
Definition cme.h:739
string const USAGE5
Definition cme.h:858
string const DISCLAIMER1
Definition cme.h:842
string const VECTOR_DEEP_WATER_WAVE_ANGLE_AND_HEIGHT_CODE
Definition cme.h:1166
int const RTN_ERR_TSFILE
Definition cme.h:706
string const READING_LANDFORM_FILE
Definition cme.h:867
int const RTN_ERR_READING_CSHORE_FILE_OUTPUT
Definition cme.h:747
string const RUN_NOTICE
Definition cme.h:886
string const RASTER_BEACH_PROTECTION_CODE
Definition cme.h:968
string const RASTER_TOTAL_POTENTIAL_PLATFORM_EROSION_CODE
Definition cme.h:976
int const RTN_ERR_CLIFF_NOT_IN_POLYGON
Definition cme.h:761
int const TIME_MONTHS
Definition cme.h:523
string const TIME_SERIES_CLIFF_COLLAPSE_EROSION_CODE
Definition cme.h:1219
string const PROGRAM_NAME
Definition cme.h:836
int const RTN_ERR_VECTOR_FILE_READ
Definition cme.h:709
string const RASTER_BEACH_MASK_CODE
Definition cme.h:966
int const RTN_ERR_NOSEACELLS
Definition cme.h:725
int const RTN_ERR_VECTOR_GIS_OUT_FORMAT
Definition cme.h:712
string const RASTER_AVG_WAVE_HEIGHT_CODE
Definition cme.h:958
string const READING_INTERVENTION_HEIGHT_FILE
Definition cme.h:869
int const RTN_USER_ABORT
Definition cme.h:697
string const TIME_SERIES_BEACH_EROSION_CODE
Definition cme.h:1228
int const RTN_ERR_NO_START_FINISH_POINTS_TRACING_COAST
Definition cme.h:764
int const RTN_ERR_TRACING_FLOOD
Definition cme.h:763
string const RASTER_TOTAL_POTENTIAL_BEACH_EROSION_CODE
Definition cme.h:984
int const RTN_ERR_CMEDIR
Definition cme.h:700
string const RASTER_AVG_SEA_DEPTH_CODE
Definition cme.h:952
int const RTN_ERR_NO_PROFILES_2
Definition cme.h:724
int const RTN_ERR_PROFILE_ENDPOINT_IS_INLAND
Definition cme.h:720
string const RASTER_SAND_UNCONS_CODE
Definition cme.h:1004
string const RUN_END_NOTICE
Definition cme.h:890
string const TIME_SERIES_PLATFORM_EROSION_NAME
Definition cme.h:1215
int const RTN_ERR_INI
Definition cme.h:699
int const RTN_ERR_BAD_MULTILINE
Definition cme.h:740
string const READING_SED_INPUT_EVENT_FILE
Definition cme.h:879
int const RTN_OK
Definition cme.h:694
int const RTN_ERR_COAST_TOO_SMALL
Definition cme.h:768
int const RTN_ERR_TEXT_FILE_WRITE
Definition cme.h:713
string const VECTOR_CLIFF_NOTCH_SIZE_CODE
Definition cme.h:1160
string const RASTER_LANDFORM_CODE
Definition cme.h:992
int const RTN_ERR_VECTOR_FILE_WRITE
Definition cme.h:715
string const TIME_SERIES_CLIFF_COLLAPSE_NET_NAME
Definition cme.h:1224
string const RASTER_TOTAL_ACTUAL_PLATFORM_EROSION_CODE
Definition cme.h:978
string const DISCLAIMER6
Definition cme.h:847
int const RTN_ERR_READING_DEEP_WATER_WAVE_DATA
Definition cme.h:754
string const RASTER_ACTUAL_PLATFORM_EROSION_CODE
Definition cme.h:974
string const VECTOR_BREAKING_WAVE_HEIGHT_CODE
Definition cme.h:1154
int const RTN_ERR_CELL_MARKED_PROFILE_COAST_BUT_NOT_PROFILE
Definition cme.h:762
string const TIME_SERIES_CLIFF_COLLAPSE_EROSION_NAME
Definition cme.h:1218
int const RTN_ERR_NO_PROFILES_1
Definition cme.h:723
unsigned long const SEDIMENT_INPUT_EVENT_ERROR
Definition cme.h:803
int const TIME_YEARS
Definition cme.h:524
int const RTN_ERR_TIDEDATAFILE
Definition cme.h:703
int const TIME_DAYS
Definition cme.h:522
string const THANKS
Definition cme.h:850
string const RASTER_SUSP_SED_CODE
Definition cme.h:998
int const RTN_ERR_CANNOT_INSERT_POINT
Definition cme.h:741
int const RTN_ERR_NO_VALID_COAST
Definition cme.h:765
string const VECTOR_SHADOW_BOUNDARY_CODE
Definition cme.h:1162
string const VECTOR_COAST_CURVATURE_CODE
Definition cme.h:1144
string const TIME_SERIES_SEA_AREA_NAME
Definition cme.h:1209
int const RTN_ERR_CLIFFDEPOSIT
Definition cme.h:731
int const RTN_ERR_UNKNOWN
Definition cme.h:773
double const DEAN_POWER
Definition cme.h:817
int const RTN_ERR_ZERO_LENGTH_COAST
Definition cme.h:767
string const NOTE
Definition cme.h:905
string const READING_SUSPENDED_SEDIMENT_FILE
Definition cme.h:870
int const RTN_ERR_CANNOT_ASSIGN_COASTAL_LANDFORM
Definition cme.h:742
string const READING_FLOOD_LOCATION
Definition cme.h:880
int const RTN_ERR_REPEATING_WHEN_TRACING_COAST
Definition cme.h:766
int const RTN_ERR_OUTFILE
Definition cme.h:705
string const ALLOCATE_MEMORY
Definition cme.h:883
string const RASTER_LOCAL_SLOPE_CODE
Definition cme.h:944
string const TIME_SERIES_SUSPENDED_SEDIMENT_NAME
Definition cme.h:1236
int const RTN_ERR_NO_SOLUTION_FOR_ENDPOINT
Definition cme.h:721
string const TIME_SERIES_CLIFF_COLLAPSE_DEPOSITION_NAME
Definition cme.h:1221
string const RASTER_FINE_CONS_CODE
Definition cme.h:1008
string const LINE
Definition cme.h:841
string const VECTOR_POLYGON_BOUNDARY_CODE
Definition cme.h:1158
string const DISCLAIMER2
Definition cme.h:843
string const RASTER_FINE_UNCONS_CODE
Definition cme.h:1002
string const TIME_SERIES_STILL_WATER_LEVEL_CODE
Definition cme.h:1213
string const RASTER_SEDIMENT_TOP_CODE
Definition cme.h:938
int const BUF_SIZE
Definition cme.h:465
int const RTN_ERR_CELL_NOT_FOUND_IN_HIT_PROFILE_DIFFERENT_COASTS
Definition cme.h:771
string const VECTOR_WAVE_ANGLE_AND_HEIGHT_CODE
Definition cme.h:1146
string const SEND_EMAIL
Definition cme.h:889
T tAbs(T a)
Definition cme.h:1278
int const RTN_ERR_SEDIMENT_INPUT_EVENT
Definition cme.h:757
int const RTN_ERR_CSHORE_EMPTY_PROFILE
Definition cme.h:745
string const VECTOR_AVG_WAVE_ANGLE_AND_HEIGHT_CODE
Definition cme.h:1149
string const TIME_SERIES_BEACH_CHANGE_NET_CODE
Definition cme.h:1234
string const RASTER_INTERVENTION_HEIGHT_CODE
Definition cme.h:996
string const TIME_SERIES_BEACH_DEPOSITION_CODE
Definition cme.h:1231
int const RTN_ERR_NO_SEAWARD_END_OF_PROFILE_BEACH_EROSION
Definition cme.h:734
string const READING_UNCONS_FINE_SEDIMENT_FILE
Definition cme.h:871
string const START_NOTICE
Definition cme.h:861
string const ADD_LAYERS
Definition cme.h:884
string const RASTER_POLYGON_CODE
Definition cme.h:1040
string const RASTER_ACTUAL_BEACH_EROSION_CODE
Definition cme.h:982
string const RASTER_INUNDATION_MASK_CODE
Definition cme.h:954
string const VECTOR_COAST_CODE
Definition cme.h:1136
string const TIME_SERIES_SEA_AREA_CODE
Definition cme.h:1210
int const RTN_ERR_NO_SEAWARD_END_OF_PROFILE_UPCOAST_BEACH_DEPOSITION
Definition cme.h:735
int const RTN_ERR_LINETOGRID
Definition cme.h:717
string const GDAL_DRIVERS
Definition cme.h:851
char const DASH
Definition cme.h:448
string const ERROR_NOTICE
Definition cme.h:893
int const RTN_ERR_NO_CELL_UNDER_COASTLINE
Definition cme.h:752
int const LF_CAT_INTERVENTION
Definition cme.h:545
string const RASTER_TOP_CODE
Definition cme.h:940
int const RTN_ERR_TIMESERIES_FILE_WRITE
Definition cme.h:716
char const SPACE
Definition cme.h:453
string const VECTOR_DOWNDRIFT_BOUNDARY_CODE
Definition cme.h:1164
Contains CRWCoast definitions.
Contains CSimulation definitions.
double dRound(double const d)
Correctly rounds doubles.
bool bIsStringValidInt(string &str)
Checks to see if a string can be read as a valid integer, from https://stackoverflow....
int nRound(double const d)
Version of the above that returns an int.