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