예제 #1
0
        /// <summary>
        /// Read the point source data from the file "point.dat" and create and fill the point source arrays
        /// </summary>
        public static void Read()
        {
            List <SourceData> PQ = new List <SourceData>();

            double totalemission    = 0;
            int    countrealsources = 0;

            double[] emission_sourcegroup = new double[101];

            PQ.Add(new SourceData());

            if (Program.IMQ.Count == 0)
            {
                Program.IMQ.Add(0);
            }

            Deposition Dep = new Deposition();

            StreamReader read = new StreamReader("point.dat");

            try
            {
                string[] text = new string[1];
                string   text1;
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                while ((text1 = read.ReadLine()) != null)
                {
                    text = text1.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
                    if (text.Length > 9)
                    {
                        double xsi = Convert.ToDouble(text[0].Replace(".", Program.Decsep)) - Program.IKOOAGRAL;
                        double eta = Convert.ToDouble(text[1].Replace(".", Program.Decsep)) - Program.JKOOAGRAL;
                        double dia = Convert.ToDouble(text[8].Replace(".", Program.Decsep));

                        //excluding all point sources outside GRAL domain
                        if (((eta - dia * 0.5) > Program.EtaMinGral) && ((xsi - dia * 0.5) > Program.XsiMinGral) && ((eta + dia * 0.5) < Program.EtaMaxGral) && ((xsi + dia * 0.5) < Program.XsiMaxGral))
                        {
                            //excluding all point sources with undesired source groups
                            {
                                Int16 SG       = Convert.ToInt16(text[10]);
                                int   SG_index = Program.Get_Internal_SG_Number(SG); // get internal SG number

                                if (SG_index >= 0)
                                {
                                    SourceData sd = new SourceData();
                                    sd.X1          = Convert.ToDouble(text[0].Replace(".", Program.Decsep));
                                    sd.Y1          = Convert.ToDouble(text[1].Replace(".", Program.Decsep));
                                    sd.Z1          = Convert.ToSingle(text[2].Replace(".", Program.Decsep));
                                    sd.ER          = Convert.ToDouble(text[3].Replace(".", Program.Decsep));
                                    sd.V           = Convert.ToSingle(text[7].Replace(".", Program.Decsep));
                                    sd.D           = Convert.ToSingle(text[8].Replace(".", Program.Decsep));
                                    sd.T           = Convert.ToSingle(text[9].Replace(".", Program.Decsep));
                                    sd.SG          = Convert.ToInt16(text[10]);
                                    sd.Mode        = 0; // standard mode = concentration only
                                    totalemission += sd.ER;
                                    emission_sourcegroup[SG_index] += sd.ER;
                                    countrealsources++;

                                    sd.TimeSeriesTemperature = GetTransientTimeSeriesIndex.GetIndex(Program.PS_TimeSerTempValues, "Temp@_", text);
                                    sd.TimeSeriesVelocity    = GetTransientTimeSeriesIndex.GetIndex(Program.PS_TimeSerVelValues, "Vel@_", text);

                                    if (text.Length > 15)         // deposition data available
                                    {
                                        Dep.Dep_Start_Index = 11; // start index for point sources
                                        Dep.SD         = sd;
                                        Dep.SourceData = PQ;
                                        Dep.Text       = text;
                                        if (Dep.Compute() == false)
                                        {
                                            throw new IOException();
                                        }
                                    }
                                    else // no depositon
                                    {
                                        PQ.Add(sd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                string err = "Error when reading file point.dat in line " + (countrealsources + 3).ToString() + " Execution stopped: press ESC to stop";
                Console.WriteLine(err);
                ProgramWriters.LogfileProblemreportWrite(err);

                if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                {
                    while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                    {
                        ;
                    }
                }
                Environment.Exit(0);
            }
            read.Close();
            read.Dispose();

            int counter = PQ.Count + 1;

            Program.PS_Count += PQ.Count - 1;

            // Copy Lists to global arrays
            Array.Resize(ref Program.PS_ER, counter);
            Array.Resize(ref Program.PS_X, counter);
            Array.Resize(ref Program.PS_Y, counter);
            Array.Resize(ref Program.PS_Z, counter);
            Array.Resize(ref Program.PS_V, counter);
            Array.Resize(ref Program.PS_D, counter);
            Array.Resize(ref Program.PS_T, counter);
            Array.Resize(ref Program.PS_SG, counter);
            Array.Resize(ref Program.PS_PartNumb, counter);
            Array.Resize(ref Program.PS_Mode, counter);
            Array.Resize(ref Program.PS_V_Dep, counter);
            Array.Resize(ref Program.PS_V_sed, counter);
            Array.Resize(ref Program.PS_ER_Dep, counter);
            Array.Resize(ref Program.PS_Absolute_Height, counter);
            Array.Resize(ref Program.PS_TimeSeriesTemperature, counter);
            Array.Resize(ref Program.PS_TimeSeriesVelocity, counter);

            for (int i = 1; i < PQ.Count; i++)
            {
                Program.PS_ER[i] = PQ[i].ER;
                Program.PS_X[i]  = PQ[i].X1;
                Program.PS_Y[i]  = PQ[i].Y1;

                if (PQ[i].Z1 < 0) // negative value = absolute height
                {
                    Program.PS_Absolute_Height[i] = true;
                    if (Program.Topo != 1)
                    {
                        string err = "You are using absolute coordinates but flat terrain  - ESC = Exit";
                        Console.WriteLine(err);
                        ProgramWriters.LogfileProblemreportWrite(err);

                        if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                        {
                            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                            {
                                ;
                            }
                        }
                        Environment.Exit(0);
                    }
                }
                else
                {
                    Program.PS_Absolute_Height[i] = false;
                }

                Program.PS_Z[i]      = (float)Math.Abs(PQ[i].Z1);
                Program.PS_V[i]      = PQ[i].V;
                Program.PS_D[i]      = PQ[i].D;
                Program.PS_T[i]      = PQ[i].T;
                Program.PS_SG[i]     = (byte)PQ[i].SG;
                Program.PS_V_Dep[i]  = PQ[i].Vdep;
                Program.PS_V_sed[i]  = PQ[i].Vsed;
                Program.PS_Mode[i]   = PQ[i].Mode;
                Program.PS_ER_Dep[i] = (float)(PQ[i].ER_dep);
                Program.PS_TimeSeriesTemperature[i] = PQ[i].TimeSeriesTemperature;
                Program.PS_TimeSeriesVelocity[i]    = PQ[i].TimeSeriesVelocity;
            }

            string info = "Total number of point sources: " + countrealsources.ToString();

            Console.WriteLine(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            string unit = "[kg/h]: ";

            if (Program.Odour == true)
            {
                unit = "[MOU/h]: ";
            }

            info = "Total emission " + unit + (totalemission).ToString("0.000");
            Console.Write(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            Console.Write(" (");
            for (int im = 0; im < Program.SourceGroups.Count; im++)
            {
                info = "  SG " + Program.SourceGroups[im] + unit + emission_sourcegroup[im].ToString("0.000");
                Console.Write(info);
                ProgramWriters.LogfileGralCoreWrite(info);
            }
            Console.WriteLine(" )");

            Program.PS_effqu = new float[Program.PS_Count + 1];

            PQ  = null;
            Dep = null;
        }
예제 #2
0
        /// <summary>
        /// Read Line Sources from the file "line.dat"
        /// </summary>
        public static void Read()
        {
            List <SourceData> LQ = new List <SourceData>();

            LQ.Add(new SourceData());

            double totalemission    = 0;
            int    countrealsources = 0;

            double[] emission_sourcegroup = new double[101];

            if (Program.IMQ.Count == 0)
            {
                Program.IMQ.Add(0);
            }

            Deposition Dep = new Deposition();

            StreamReader read = new StreamReader("line.dat");

            try
            {
                string[] text = new string[1];
                string   text1;
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                while ((text1 = read.ReadLine()) != null)
                {
                    text = text1.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

                    double xsi1 = Convert.ToDouble(text[3].Replace(".", Program.Decsep)) - Program.IKOOAGRAL;
                    double eta1 = Convert.ToDouble(text[4].Replace(".", Program.Decsep)) - Program.JKOOAGRAL;
                    double xsi2 = Convert.ToDouble(text[6].Replace(".", Program.Decsep)) - Program.IKOOAGRAL;
                    double eta2 = Convert.ToDouble(text[7].Replace(".", Program.Decsep)) - Program.JKOOAGRAL;

                    //excluding all line sources outside GRAL domain
                    if ((eta1 > Program.EtaMinGral) && (xsi1 > Program.XsiMinGral) && (eta1 < Program.EtaMaxGral) && (xsi1 < Program.XsiMaxGral) &&
                        (eta2 > Program.EtaMinGral) && (xsi2 > Program.XsiMinGral) && (eta2 < Program.EtaMaxGral) && (xsi2 < Program.XsiMaxGral))
                    {
                        //excluding all line sources with undesired source groups
                        {
                            Int16 SG       = Convert.ToInt16(text[2]);
                            int   SG_index = Program.Get_Internal_SG_Number(SG); // get internal SG number

                            if (SG_index >= 0)
                            {
                                SourceData sd = new SourceData();

                                sd.SG      = Convert.ToInt16(text[2]);
                                sd.X1      = Convert.ToDouble(text[3].Replace(".", Program.Decsep));
                                sd.Y1      = Convert.ToDouble(text[4].Replace(".", Program.Decsep));
                                sd.Z1      = Convert.ToSingle(text[5].Replace(".", Program.Decsep));
                                sd.X2      = Convert.ToDouble(text[6].Replace(".", Program.Decsep));
                                sd.Y2      = Convert.ToDouble(text[7].Replace(".", Program.Decsep));
                                sd.Z2      = Convert.ToSingle(text[8].Replace(".", Program.Decsep));
                                sd.Width   = Convert.ToSingle(text[9].Replace(".", Program.Decsep));
                                sd.VertExt = Convert.ToSingle(text[10].Replace(".", Program.Decsep));
                                sd.Mode    = 0; // standard mode = concentration only

                                //Conversion of emissions given in kg/h/km in kg/h
                                float length = (float)Math.Sqrt(Math.Pow(sd.X1 - sd.X2, 2) +
                                                                Math.Pow(sd.Y1 - sd.Y2, 2) +
                                                                Math.Pow(sd.Z1 - sd.Z2, 2));
                                double emission      = Convert.ToDouble(text[13].Replace(".", Program.Decsep));
                                double emission_kg_h = length * emission * 0.001F;

                                if (length > 0.001) // Kuntner 4.10.2017 Filter sources with length < 0.001
                                {
                                    sd.ER = emission_kg_h;

                                    totalemission += sd.ER;
                                    emission_sourcegroup[SG_index] += sd.ER;
                                    countrealsources++;

                                    if (text.Length > 24)         // deposition data available
                                    {
                                        Dep.Dep_Start_Index = 19; // start index for line sources
                                        Dep.SD         = sd;
                                        Dep.SourceData = LQ;
                                        Dep.Text       = text;
                                        if (Dep.Compute() == false)
                                        {
                                            throw new IOException();
                                        }
                                    }
                                    else // no depositon
                                    {
                                        LQ.Add(sd);
                                    }
                                } // Filter sources
                            }
                        }
                    }
                }
            }
            catch
            {
                string err = "Error when reading file line.dat in line " + (countrealsources + 3).ToString() + " Execution stopped: press ESC to stop";
                Console.WriteLine(err);
                ProgramWriters.LogfileProblemreportWrite(err);

                if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                {
                    while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                    {
                        ;
                    }
                }

                Environment.Exit(0);
            }
            read.Close();
            read.Dispose();

            int counter = LQ.Count + 1;

            Program.LS_Count = LQ.Count - 1;
            // Copy Lists to global arrays
            Array.Resize(ref Program.LS_ER, counter);
            Array.Resize(ref Program.LS_X1, counter);
            Array.Resize(ref Program.LS_Y1, counter);
            Array.Resize(ref Program.LS_Z1, counter);
            Array.Resize(ref Program.LS_X2, counter);
            Array.Resize(ref Program.LS_Y2, counter);
            Array.Resize(ref Program.LS_Z2, counter);
            Array.Resize(ref Program.LS_Width, counter);
            Array.Resize(ref Program.LS_Laerm, counter);
            Array.Resize(ref Program.LS_SG, counter);
            Array.Resize(ref Program.LS_PartNumb, counter);
            Array.Resize(ref Program.LS_Mode, counter);
            Array.Resize(ref Program.LS_V_Dep, counter);
            Array.Resize(ref Program.LS_V_sed, counter);
            Array.Resize(ref Program.LS_ER_Dep, counter);
            Array.Resize(ref Program.LS_Absolute_Height, counter);

            for (int i = 1; i < LQ.Count; i++)
            {
                Program.LS_ER[i] = LQ[i].ER;
                Program.LS_X1[i] = LQ[i].X1;
                Program.LS_Y1[i] = LQ[i].Y1;

                if (LQ[i].Z1 < 0 && LQ[i].Z2 < 0) // negative values = absolute heights
                {
                    Program.LS_Absolute_Height[i] = true;
                    if (Program.Topo != 1)
                    {
                        string err = "You are using absolute coordinates but flat terrain  - ESC = Exit";
                        Console.WriteLine(err);
                        ProgramWriters.LogfileProblemreportWrite(err);

                        if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                        {
                            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                            {
                                ;
                            }
                        }

                        Environment.Exit(0);
                    }
                }
                else
                {
                    Program.LS_Absolute_Height[i] = false;
                }

                Program.LS_Z1[i]     = (float)Math.Abs(LQ[i].Z1);
                Program.LS_X2[i]     = LQ[i].X2;
                Program.LS_Y2[i]     = LQ[i].Y2;
                Program.LS_Z2[i]     = (float)Math.Abs(LQ[i].Z2);
                Program.LS_Width[i]  = LQ[i].Width;
                Program.LS_Laerm[i]  = LQ[i].VertExt;
                Program.LS_SG[i]     = (byte)LQ[i].SG;
                Program.LS_V_Dep[i]  = LQ[i].Vdep;
                Program.LS_V_sed[i]  = LQ[i].Vsed;
                Program.LS_Mode[i]   = LQ[i].Mode;
                Program.LS_ER_Dep[i] = (float)(LQ[i].ER_dep);
            }

            string info = "Total number of line source segments: " + countrealsources.ToString();

            Console.WriteLine(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            string unit = "[kg/h]: ";

            if (Program.Odour == true)
            {
                unit = "[MOU/h]: ";
            }

            info = "Total emission " + unit + (totalemission).ToString("0.000");
            Console.Write(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            Console.Write(" (");
            for (int im = 0; im < Program.SourceGroups.Count; im++)
            {
                info = "  SG " + Program.SourceGroups[im] + unit + emission_sourcegroup[im].ToString("0.000");
                Console.Write(info);
                ProgramWriters.LogfileGralCoreWrite(info);
            }
            Console.WriteLine(" )");

            LQ  = null;
            Dep = null;
        }
예제 #3
0
        /// <summary>
        /// Read Area Sources from the file "cadestre.dat"
        /// </summary>
        public static void Read()
        {
            List <SourceData> AQ = new List <SourceData>();

            double totalemission    = 0;
            int    countrealsources = 0;

            double[] emission_sourcegroup = new double[101];

            AQ.Add(new SourceData());

            if (Program.IMQ.Count == 0)
            {
                Program.IMQ.Add(0);
            }

            Deposition Dep = new Deposition();

            StreamReader read = new StreamReader("cadastre.dat");

            try
            {
                string[] text = new string[1];
                string   text1;
                text1 = read.ReadLine();
                while ((text1 = read.ReadLine()) != null)
                {
                    text = text1.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

                    double xsi1 = (Convert.ToDouble(text[0].Replace(".", Program.Decsep)) + Convert.ToDouble(text[3].Replace(".", Program.Decsep)) * 0.5) - Program.IKOOAGRAL;
                    double xsi2 = (Convert.ToDouble(text[0].Replace(".", Program.Decsep)) - Convert.ToDouble(text[3].Replace(".", Program.Decsep)) * 0.5) - Program.IKOOAGRAL;
                    double xsi3 = Math.Min(xsi1, xsi2);
                    double xsi4 = Math.Max(xsi1, xsi2);
                    double eta1 = (Convert.ToDouble(text[1].Replace(".", Program.Decsep)) + Convert.ToDouble(text[4].Replace(".", Program.Decsep)) * 0.5) - Program.JKOOAGRAL;
                    double eta2 = (Convert.ToDouble(text[1].Replace(".", Program.Decsep)) - Convert.ToDouble(text[4].Replace(".", Program.Decsep)) * 0.5) - Program.JKOOAGRAL;
                    double eta3 = Math.Min(eta1, eta2);
                    double eta4 = Math.Max(eta1, eta2);

                    //excluding all area sources outside GRAL domain
                    if ((eta3 > Program.EtaMinGral) && (xsi3 > Program.XsiMinGral) && (eta4 < Program.EtaMaxGral) && (xsi4 < Program.XsiMaxGral))
                    {
                        //excluding all area sources with undesired source groups
                        {
                            Int16 SG       = Convert.ToInt16(text[10]);
                            int   SG_index = Program.Get_Internal_SG_Number(SG); // get internal SG number

                            if (SG_index >= 0)
                            {
                                SourceData sd = new SourceData();
                                sd.X1          = Convert.ToDouble(text[0].Replace(".", Program.Decsep));
                                sd.Y1          = Convert.ToDouble(text[1].Replace(".", Program.Decsep));
                                sd.Z1          = Convert.ToSingle(text[2].Replace(".", Program.Decsep));
                                sd.X2          = Convert.ToDouble(text[3].Replace(".", Program.Decsep));
                                sd.Y2          = Convert.ToDouble(text[4].Replace(".", Program.Decsep));
                                sd.Z2          = Convert.ToSingle(text[5].Replace(".", Program.Decsep));
                                sd.ER          = Convert.ToDouble(text[6].Replace(".", Program.Decsep));
                                sd.SG          = Convert.ToInt16(text[10]);
                                sd.Mode        = 0; // standard mode = concentration only
                                totalemission += sd.ER;
                                emission_sourcegroup[SG_index] += sd.ER;
                                countrealsources++;

                                if (text.Length > 16)         // deposition data available
                                {
                                    Dep.Dep_Start_Index = 11; // start index for area sources
                                    Dep.SD         = sd;
                                    Dep.SourceData = AQ;
                                    Dep.Text       = text;
                                    if (Dep.Compute() == false)
                                    {
                                        throw new IOException();
                                    }
                                }
                                else // no depositon
                                {
                                    AQ.Add(sd);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                string err = "Error when reading file cadastre.dat in line " + (Program.AS_Count + 3).ToString();
                Console.WriteLine(err + " Execution stopped: press ESC to stop");
                ProgramWriters.LogfileProblemreportWrite(err);

                if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                {
                    while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                    {
                        ;
                    }
                }

                Environment.Exit(0);
            }
            read.Close();
            read.Dispose();

            int counter = AQ.Count + 1;

            Program.AS_Count = AQ.Count - 1;
            // Copy Lists to global arrays
            Array.Resize(ref Program.AS_X, counter);
            Array.Resize(ref Program.AS_Y, counter);
            Array.Resize(ref Program.AS_Z, counter);
            Array.Resize(ref Program.AS_dX, counter);
            Array.Resize(ref Program.AS_dY, counter);
            Array.Resize(ref Program.AS_dZ, counter);
            Array.Resize(ref Program.AS_ER, counter);
            Array.Resize(ref Program.AS_SG, counter);
            Array.Resize(ref Program.AS_PartNumb, counter);
            Array.Resize(ref Program.AS_Mode, counter);
            Array.Resize(ref Program.AS_V_Dep, counter);
            Array.Resize(ref Program.AS_V_sed, counter);
            Array.Resize(ref Program.AS_ER_Dep, counter);
            Array.Resize(ref Program.AS_Absolute_Height, counter);

            for (int i = 1; i < AQ.Count; i++)
            {
                Program.AS_X[i] = AQ[i].X1;
                Program.AS_Y[i] = AQ[i].Y1;

                if (AQ[i].Z1 < 0) // negative value = absolute height
                {
                    Program.AS_Absolute_Height[i] = true;
                    if (Program.Topo != 1)
                    {
                        string err = "You are using absolute coordinates but flat terrain  - ESC = Exit";
                        Console.WriteLine(err);
                        ProgramWriters.LogfileProblemreportWrite(err);

                        if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                        {
                            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                            {
                                ;
                            }
                        }

                        Environment.Exit(0);
                    }
                }
                else
                {
                    Program.AS_Absolute_Height[i] = false;
                }

                Program.AS_Z[i]      = (float)Math.Abs(AQ[i].Z1);
                Program.AS_dX[i]     = AQ[i].X2;
                Program.AS_dY[i]     = AQ[i].Y2;
                Program.AS_dZ[i]     = AQ[i].Z2;
                Program.AS_ER[i]     = AQ[i].ER;
                Program.AS_SG[i]     = (byte)AQ[i].SG;
                Program.AS_V_Dep[i]  = AQ[i].Vdep;
                Program.AS_V_sed[i]  = AQ[i].Vsed;
                Program.AS_Mode[i]   = AQ[i].Mode;
                Program.AS_ER_Dep[i] = (float)(AQ[i].ER_dep);
            }

            string info = "Total number of area source partitions: " + countrealsources.ToString();

            Console.WriteLine(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            string unit = "[kg/h]: ";

            if (Program.Odour == true)
            {
                unit = "[MOU/h]: ";
            }

            info = "Total emission " + unit + (totalemission).ToString("0.000");
            Console.Write(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            Console.Write(" (");
            for (int im = 0; im < Program.SourceGroups.Count; im++)
            {
                info = "  SG " + Program.SourceGroups[im] + unit + emission_sourcegroup[im].ToString("0.000");
                Console.Write(info);
                ProgramWriters.LogfileGralCoreWrite(info);
            }
            Console.WriteLine(" )");
        }
예제 #4
0
        /// <summary>
        /// Read Portal Sources from the file "portal.dat"
        /// </summary>
        public static void Read()
        {
            List <SourceData> TQ = new List <SourceData>();
            CultureInfo       ic = CultureInfo.InvariantCulture;

            double totalemission    = 0;
            int    countrealsources = 0;

            double[] emission_sourcegroup = new double[101];

            TQ.Add(new SourceData());

            if (Program.IMQ.Count == 0)
            {
                Program.IMQ.Add(0);
            }

            Deposition Dep = new Deposition();

            StreamReader read = new StreamReader("portals.dat");

            try
            {
                string[] text = new string[1];
                string   text1;
                text1 = read.ReadLine();
                text1 = read.ReadLine();
                while ((text1 = read.ReadLine()) != null)
                {
                    text = text1.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

                    double xsi1 = Convert.ToDouble(text[0], ic) - Program.IKOOAGRAL;
                    double eta1 = Convert.ToDouble(text[1], ic) - Program.JKOOAGRAL;
                    double xsi2 = Convert.ToDouble(text[2], ic) - Program.IKOOAGRAL;
                    double eta2 = Convert.ToDouble(text[3], ic) - Program.JKOOAGRAL;

                    //excluding all tunnel portals outside GRAL domain
                    if ((eta1 > Program.EtaMinGral) && (xsi1 > Program.XsiMinGral) && (eta1 < Program.EtaMaxGral) && (xsi1 < Program.XsiMaxGral) &&
                        (eta2 > Program.EtaMinGral) && (xsi2 > Program.XsiMinGral) && (eta2 < Program.EtaMaxGral) && (xsi2 < Program.XsiMaxGral))
                    {
                        //excluding all tunnel portals with undesired source groups
                        if (text.Length > 9)
                        {
                            Int16 SG       = Convert.ToInt16(text[10]);
                            int   SG_index = Program.Get_Internal_SG_Number(SG); // get internal SG number

                            if (SG_index >= 0)
                            {
                                SourceData sd = new SourceData();
                                sd.X1   = Convert.ToDouble(text[0], ic);
                                sd.Y1   = Convert.ToDouble(text[1], ic);
                                sd.X2   = Convert.ToDouble(text[2], ic);
                                sd.Y2   = Convert.ToDouble(text[3], ic);
                                sd.Z1   = Convert.ToSingle(text[4], ic);
                                sd.Z2   = Convert.ToSingle(text[5], ic);
                                sd.ER   = Convert.ToDouble(text[6], ic);
                                sd.SG   = Convert.ToInt16(text[10]);
                                sd.Mode = 0; // standard mode

                                totalemission += sd.ER;
                                emission_sourcegroup[SG_index] += sd.ER;
                                countrealsources++;

                                sd.TimeSeriesTemperature = GetTransientTimeSeriesIndex.GetIndex(Program.TS_TimeSerTempValues, "Temp@_", text);
                                sd.TimeSeriesVelocity    = GetTransientTimeSeriesIndex.GetIndex(Program.TS_TimeSerVelValues, "Vel@_", text);

                                if (text.Length > 17)         // deposition data available
                                {
                                    Dep.Dep_Start_Index = 11; // start index for portal sources
                                    if (text.Length > 20)
                                    {
                                        sd.T = Convert.ToSingle(text[19], ic);
                                        sd.V = Convert.ToSingle(text[20], ic);
                                    }
                                    Dep.SD         = sd;
                                    Dep.SourceData = TQ;
                                    Dep.Text       = text;
                                    if (Dep.Compute() == false)
                                    {
                                        throw new IOException();
                                    }
                                }
                                else // no depositon
                                {
                                    if (text.Length > 12) // DeltaT and ExitVel available
                                    {
                                        sd.T = Convert.ToSingle(text[11], ic);
                                        sd.V = Convert.ToSingle(text[12], ic);
                                    }
                                    TQ.Add(sd);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                string err = "Error when reading file Portals.dat in line " + (countrealsources + 3).ToString() + " Execution stopped: press ESC to stop";
                Console.WriteLine(err);
                ProgramWriters.LogfileProblemreportWrite(err);

                if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                {
                    while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                    {
                        ;
                    }
                }

                Environment.Exit(0);
            }
            read.Close();
            read.Dispose();

            int counter = TQ.Count + 1;

            Program.TS_Count = TQ.Count - 1;

            // Copy Lists to global arrays
            Array.Resize(ref Program.TS_X1, counter);
            Array.Resize(ref Program.TS_Y1, counter);
            Array.Resize(ref Program.TS_X2, counter);
            Array.Resize(ref Program.TS_Y2, counter);
            Array.Resize(ref Program.TS_Z1, counter);
            Array.Resize(ref Program.TS_Z2, counter);
            Array.Resize(ref Program.TS_ER, counter);
            Array.Resize(ref Program.TS_SG, counter);
            Array.Resize(ref Program.TS_PartNumb, counter);
            Array.Resize(ref Program.TS_Mode, counter);
            Array.Resize(ref Program.TS_V_Dep, counter);
            Array.Resize(ref Program.TS_V_sed, counter);
            Array.Resize(ref Program.TS_ER_Dep, counter);
            Array.Resize(ref Program.TS_Absolute_Height, counter);
            Array.Resize(ref Program.TS_T, counter);
            Array.Resize(ref Program.TS_V, counter);
            Array.Resize(ref Program.TS_TimeSeriesTemperature, counter);
            Array.Resize(ref Program.TS_TimeSeriesVelocity, counter);

            for (int i = 1; i < TQ.Count; i++)
            {
                Program.TS_X1[i] = TQ[i].X1;
                Program.TS_Y1[i] = TQ[i].Y1;
                Program.TS_X2[i] = TQ[i].X2;
                Program.TS_Y2[i] = TQ[i].Y2;

                if (TQ[i].Z1 < 0 && TQ[i].Z2 < 0) // negative values = absolute heights
                {
                    Program.TS_Absolute_Height[i] = true;
                    if (Program.Topo != 1)
                    {
                        string err = "You are using absolute coordinates but flat terrain  - ESC = Exit";
                        Console.WriteLine(err);
                        ProgramWriters.LogfileProblemreportWrite(err);

                        if (Program.IOUTPUT <= 0 && Program.WaitForConsoleKey) // not for Soundplan or no keystroke
                        {
                            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                            {
                                ;
                            }
                        }
                        Environment.Exit(0);
                    }
                }
                else
                {
                    Program.TS_Absolute_Height[i] = false;
                }

                Program.TS_Z1[i]     = (float)Math.Abs(TQ[i].Z1);
                Program.TS_Z2[i]     = (float)Math.Abs(TQ[i].Z2);
                Program.TS_ER[i]     = TQ[i].ER;
                Program.TS_SG[i]     = (byte)TQ[i].SG;
                Program.TS_V_Dep[i]  = TQ[i].Vdep;
                Program.TS_V_sed[i]  = TQ[i].Vsed;
                Program.TS_Mode[i]   = TQ[i].Mode;
                Program.TS_ER_Dep[i] = (float)(TQ[i].ER_dep);
                Program.TS_T[i]      = TQ[i].T;
                Program.TS_V[i]      = TQ[i].V;
                Program.TS_TimeSeriesTemperature[i] = TQ[i].TimeSeriesTemperature;
                Program.TS_TimeSeriesVelocity[i]    = TQ[i].TimeSeriesVelocity;
            }

            string info = "Total number of tunnel portals: " + countrealsources.ToString();

            Console.WriteLine(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            string unit = "[kg/h]: ";

            if (Program.Odour == true)
            {
                unit = "[MOU/h]: ";
            }

            info = "Total emission " + unit + (totalemission).ToString("0.000");
            Console.Write(info);
            ProgramWriters.LogfileGralCoreWrite(info);

            Console.Write(" (");
            for (int im = 0; im < Program.SourceGroups.Count; im++)
            {
                info = "  SG " + Program.SourceGroups[im] + unit + emission_sourcegroup[im].ToString("0.000");
                Console.Write(info);
                ProgramWriters.LogfileGralCoreWrite(info);
            }
            Console.WriteLine(" )");

            Program.TS_Area     = new float[Program.TS_Count + 1];
            Program.TS_Width    = new float[Program.TS_Count + 1];
            Program.TS_Height   = new float[Program.TS_Count + 1];
            Program.TS_cosalpha = new float[Program.TS_Count + 1];
            Program.TS_sinalpha = new float[Program.TS_Count + 1];

            TQ  = null;
            Dep = null;
        }