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