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