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