protected bool CopyMeteoFiles(MohidRunEngineData mre)
        {
            FileName dest = new FileName();

             orig.FullPath = @"..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\meteo.hdf5";
             dest.FullPath = mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\meteo.hdf5";
             if (!Directory.Exists(orig.Path))
            Directory.CreateDirectory(orig.Path);

             if (File.Exists(orig.FullPath))
             {
            FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
             }
             else
             {
            if (!GenerateMeteoFiles(mre))
            {
               Console.WriteLine("Was not possible to create the meteo files.");
               return false;
            }
            FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
             }

             return true;
        }
예제 #2
0
        protected bool CopyMeteoFiles(MohidRunEngineData mre)
        {
            FileName orig = new FileName();
             FileName dest = new FileName();

             orig.FullPath = @"..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\meteo.hdf5";
             dest.FullPath = mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\meteo.hdf5";
             if (Directory.Exists(orig.Path))
             {
            if (File.Exists(orig.FullPath))
            {
               FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
            }
            else
            {
               //Console.WriteLine("File {0} does not exists.", orig.FullName);
               if (!GenerateMeteoFiles(mre))
                  return false;
               FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
            }
             }
             else
             {
            Console.WriteLine("Folder {0} does not exists.", orig.Path);
            return false;
             }

             return true;
        }
예제 #3
0
 public OPTamegaScript()
 {
     root = null;
      mre = null;
      storeFolder = "";
      storeFolderOld = "";
      outputPath = "";
      outputName = "";
      tempFolder = "";
      pathToFilesToGlue = "";
      generalBoundary = new FilePath();
      replace_list = new Dictionary<string, string>();
      tool = new ExternalApp();
      filesToGlue = new List<string>();
 }
예제 #4
0
 public override bool OnStart(object data)
 {
     mre = (MohidRunEngineData)data;
      root = mre.cfg.Root.ChildNodes.Find(FindScriptBlocks);
      use_spin_up = root["use.spin.up.to.start", false].AsBool();
      return true;
 }
예제 #5
0
        protected bool GenerateMeteoFiles(MohidRunEngineData mre)
        {
            //bool result = true;
             DateTime simStartDate = mre.sim.Start;
             DateTime startsim;
             DateTime endsim;
             string dateStr;
             DateTime simStart = simStartDate.AddSeconds(1);
             int counter;
             string file;
             bool found_file;
             System.IO.FileInfo fi;

             //First is required the glue of two files
             HDFGlue tool = new HDFGlue();
             tool.AppName = "glue.exe";
             tool.AppPath = @"..\tools\glue\";
             tool.WorkingDirectory = @"..\tools\glue\";
             tool.Output = @"..\" + mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\mm5.glued.hdf5";
             tool.Is3DFile = false;

             startsim = simStart.AddHours(-5);
             endsim = startsim.AddHours(5);

             Console.WriteLine("Sim start: {0}", simStartDate.ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Generating Meteo file from {0} to {1}", startsim.ToString("yyyy/MM/dd HH:mm:ss"), startsim.AddHours(11).ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Gluing files...");
             for (counter = 0; counter < 57; counter++)
             {
            found_file = false;

            dateStr = startsim.ToString("yyyyMMddHH") + "_" + endsim.ToString("yyyyMMddHH");
            file = @"H:\mm5_6h\" + startsim.ToString("yyyy") + @"\D3_" + dateStr + ".hdf5";
            if (System.IO.File.Exists(file))
            {
               fi = new System.IO.FileInfo(file);
               if (fi.Length > 2000000)
                  found_file = true;
            }

            if (!found_file && startsim.Year == 2008)
            {
               file = @"H:\mm5_6h\2008_ANL\D3_" + dateStr + ".hdf5";
               if (System.IO.File.Exists(file))
               {
                  fi = new System.IO.FileInfo(file);
                  if (fi.Length > 2000000)
                     found_file = true;
               }
            }

            if (!found_file)
            {
               file = @"\\DATACENTER\alexandria3\modelos\Meteo_IST\mm5_6h\D3_" + dateStr + ".hdf5";
               if (System.IO.File.Exists(file))
               {
                  fi = new System.IO.FileInfo(file);
                  if (fi.Length > 2000000)
                     found_file = true;
               }
            }

            if (!found_file)
            {
               Console.WriteLine("The file 'D3_{0}.hdf5' was not found.", dateStr);
               return false;
            }
            else
            {
               tool.FilesToGlue.Add(file);
               //Console.WriteLine("Adding {0} to the list of files to be glued.", @"H:\mm5_6h\" + startsim.ToString("yyyy") + @"\D3_" + dateStr + ".hdf5");
               startsim = endsim.AddHours(1);
               endsim = startsim.AddHours(5);
            }
             }

             tool.ThrowExceptionOnError = true;
             if (tool.Glue() != 0) return false;

             Dictionary<string, string> replace_list = new Dictionary<string, string>();
             replace_list["<<glued>>"] = @"..\" + mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\";
             replace_list["<<father>>"] = @"..\..\general.data\digital.terrain\";
             replace_list["<<dest>>"] = @"..\..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\";
             replace_list["<<model>>"] = @"..\..\general.data\digital.terrain\";
             TextFile.Replace(mre.sim.SimDirectory.Path + @"templates\tools\convert.to.HDF5.action.template", @"..\tools\interpolation\converttoHDF5action.dat", ref replace_list);

             //Now, do the "extraction"
             //if (!FileTools.CopyFile(new FileName(mre.sim.SimDirectory.Path + @"templates\tools\convert.to.HDF5.action.template"), new FileName(@"..\tools\interpolation\converttoHDF5action.dat"), CopyOptions.OVERWRIGHT))
             //   return false;

             ExternalApp app = new ExternalApp();

             app.Executable = @"..\tools\interpolation\interpolation.exe";
             app.WorkingDirectory = @"..\tools\interpolation\";
             app.CheckSuccessMethod = CheckSuccessMethod.DEFAULTOUTPUT;
             app.TextToCheck = "successfully terminated";
             app.SearchTextOrder = SearchTextOrder.FROMEND;
             app.Wait = true;
             Console.WriteLine("Interpolating meteo file to model grid...");
             return app.Run();
        }
        protected bool GenerateMeteoFiles(MohidRunEngineData mre)
        {
            DateTime simStartDate = mre.sim.Start;
             DateTime startsim;
             DateTime endsim;
             string dateStr;
             DateTime simStart = simStartDate.AddSeconds(1);
             int counter;
             string file, outputPath, outputName;
             bool found_file;
             System.IO.FileInfo fi;

             ConfigNode node = mre.cfg.Root.ChildNodes.Find(FindScriptBlocks);
             if (node == null)
             {
            Console.WriteLine("Node 'script.data' was not found in the config file.");
            return false;
             }

             //First is required the glue of the files
             HDFGlue tool = new HDFGlue();
             tool.AppName = node["glue.exe.name", "glue.exe"].AsString();
             tool.AppPath = node["glue.exe.path", @"..\tools\glue\"].AsString();
             tool.WorkingDirectory = node["glue.working.folder", @"..\tools\glue\"].AsString();
             outputPath = node["glue.output.path", @"..\" + mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\"].AsString();
             outputName = node["glue.output.name", "mm5.glued.hdf5"].AsString();
             tool.Output = outputPath + outputName;
             tool.Is3DFile = false;

             //This will ensure that the first hour of simulation is included in the meteo file.
             startsim = simStart.AddHours(-5);
             endsim = startsim.AddHours(5);
             int maxSkips = node["max.skips", 10].AsInt();
             int numberOfSkips = 0;

             Console.WriteLine("Sim start: {0}", simStartDate.ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Generating Meteo file from {0} to {1}", startsim.ToString("yyyy/MM/dd HH:mm:ss"), mre.sim.End.ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Sim lenght: {0}", mre.sim.SimLenght);

             int numberOfFiles = (int)(mre.sim.SimLenght * 4 + 1.0);
             Console.WriteLine("Expected number of 6 hours files to look: {0}", numberOfFiles);
             Console.WriteLine("Folder where meteo files are: {0}", node["meteo.folder", @"H:\"].AsString());
             Console.WriteLine("");
             Console.WriteLine("Looking for files...");
             Console.WriteLine("");
             for (counter = 0; counter < numberOfFiles; counter++)
             {
            found_file = false;

            dateStr = startsim.ToString("yyyyMMddHH") + "_" + endsim.ToString("yyyyMMddHH");
            file = node["meteo.folder", @"H:\"].AsString() + @"D3_" + dateStr + ".hdf5";

            if (System.IO.File.Exists(file))
            {
               fi = new System.IO.FileInfo(file);
               if (fi.Length > 2000000)
               {
                  found_file = true;
                  tool.FilesToGlue.Add(file);
               }
            }

            if (!found_file)
            {
               Console.WriteLine("File '{0}' was not found.", file);

               if (counter + 1 == numberOfFiles)
               {
                  counter--;
                  numberOfSkips++;
                  if (numberOfSkips > maxSkips)
                  {
                     Console.WriteLine("Max number of skips reached during meteo creation file.");
                     return false;
                  }
               }
            }

            startsim = endsim.AddHours(1);
            endsim = startsim.AddHours(5);
             }

             Console.WriteLine("Gluing files...");

             tool.ThrowExceptionOnError = true;
             if (tool.Glue() != 0)
             {
            Console.WriteLine("Glue failed.");
            return false;
             }

             Dictionary<string, string> replace_list = new Dictionary<string, string>();
             replace_list["<<glued>>"] = outputPath;
             replace_list["<<father>>"] = node["father.grid", @"..\..\general.data\digital.terrain\"].AsString();
             replace_list["<<dest>>"] = node["hdf.output.path", @"..\..\general.data\boundary.conditions\"].AsString() + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss") + @"\";
             replace_list["<<model>>"] = node["model.grid", @"..\..\general.data\digital.terrain\"].AsString();

             string template = node["template", mre.sim.SimDirectory.Path + @"templates\tools\convert.to.HDF5.action.template"].AsString();
             string action = node["action.file",  @"..\tools\interpolation\converttoHDF5action.dat"].AsString();

             TextFile.Replace(template, action, ref replace_list);

             ExternalApp app = new ExternalApp();

             app.WorkingDirectory = node["interpolation.working.folder", @"..\tools\interpolation\"].AsString();
             app.Executable = node["interpolation.exe", @"..\tools\interpolation\interpolation.exe"].AsString();
             app.CheckSuccessMethod = CheckSuccessMethod.DEFAULTOUTPUT;
             app.TextToCheck = "successfully terminated";
             app.SearchTextOrder = SearchTextOrder.FROMEND;
             app.Wait = true;
             Console.WriteLine("Interpolating meteo file to model grid...");
             bool result = app.Run();
             if (!result)
             {
            Console.WriteLine("Interpolation failed.");
            return false;
             }

             //Saves the created meteo file in the folder
             if (!FileTools.CopyFile(new FilePath(replace_list["<<dest>>"]), new FilePath(orig.Path), "meteo.hdf5", Files.CopyOptions.OVERWRIGHT))
             {
            Console.WriteLine("Was not possible to copy the meteo file to the meteo storage folder.");
            return false;
             }

             return true;
        }
예제 #7
0
        public bool OnSimStart(object data)
        {
            mre = (MohidRunEngineData)data;
             DateTime start, end;

             root = mre.cfg.Root.ChildNodes.Find(FindScriptBlocks);
             if (root == null)
             {
            Console.WriteLine("Block 'script.data' was not found in the config file.");
            return false;
             }

             start = root["start"].AsDateTime(mre.dateFormat);
             end = root["end"].AsDateTime(mre.dateFormat);

             //Get some important input from the script block in config file
             outputPath           = root["glue.output.path"].AsString();
             outputName           = root["glue.output.name", "meteo.hdf5"].AsString();
             tempFolder           = root["interpolation.folder", @".\temp\"].AsString();
             pathToFilesToGlue    = root["glue.input.folder", @"..\interpolation\temp\"].AsString();

             if (!GenerateMeteoFiles(start, end))
            return false;

             return true;
        }
예제 #8
0
        protected bool GlueFiles(HDFGlue glue, bool is3D, FilePath workingFolder, FilePath destinationFolder, FileName toGlue, MohidRunEngineData mre)
        {
            glue.Output = @"..\..\cumulative\" + toGlue.FullName;
             glue.Is3DFile = false;
             glue.FilesToGlue.Clear();

             //Console.WriteLine("Checking if '{0}' exists", destinationFolder.Path + toGlue.FullName);
             if (!System.IO.File.Exists(destinationFolder.Path + toGlue.FullName))
             {
            //if (!FileTools.CopyFile(toGlue, new FileName(destinationFolder.Path + toGlue.FullName), CopyOptions.OVERWRIGHT))
            //   return false;

            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(mre.storeFolder.Path);
            foreach (System.IO.DirectoryInfo g in dir.GetDirectories())
            {
               if (System.IO.File.Exists(g.FullName + System.IO.Path.DirectorySeparatorChar + toGlue.FullName))
               {
                  //Console.WriteLine("File '{0}' exists", g.FullName + "\\" + toGlue.FullName);
                  glue.FilesToGlue.Add(g.FullName + System.IO.Path.DirectorySeparatorChar + toGlue.FullName);
               }
               else
               {
                  //Console.WriteLine("File '{0}' DO NOT exists", g.FullName + "\\" + toGlue.FullName);
               }
            }
            //Console.WriteLine("Found {0} files to GLUE.", glue.FilesToGlue.Count.ToString());
            if (glue.FilesToGlue.Count > 0)
               if (glue.Glue() != 0)
                  return false;

            return true;
             }

             if (!FileTools.CopyFile(new FileName(destinationFolder.Path + toGlue.FullName), new FileName(workingFolder.Path + toGlue.FullName), CopyOptions.OVERWRIGHT))
            return false;

             glue.FilesToGlue.Add(toGlue.FullName);
             glue.FilesToGlue.Add(".." + System.IO.Path.DirectorySeparatorChar + toGlue.FullPath);

             if (glue.Glue() != 0)
            return false;

             return true;
        }
예제 #9
0
        static void LoadConfig(CmdArgs args, MohidRunEngineData data)
        {
            data.cfg = new Config();
             Config cfg = data.cfg;

             string configFile;
             if (args.HasParameter("simcfg"))
            configFile = args.Parameter("simcfg");
             else
            configFile = "sim.cfg";

             cfg.ConfigFile.FullPath = configFile;
             if (!cfg.Load())
            throw new Exception("Was not possible to load the configuration file '" + configFile + "'. " + cfg.ExceptionMessage);
        }
예제 #10
0
        protected bool CopyMeteoFiles(MohidRunEngineData mre)
        {
            FileName orig = new FileName();
             FileName dest = new FileName();

             orig.FullPath = @"..\general.data\boundary.conditions\" + mre.sim.Start.ToString("yyyyMMddHH") + "_" + mre.sim.End.ToString("yyyyMMddHH") + @"\meteo.hdf5";
             dest.FullPath = mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\meteo.hdf5";
             if (Directory.Exists(orig.Path))
             {
            if (File.Exists(orig.FullPath))
            {
               FileTools.CopyFile(orig, dest, CopyOptions.OVERWRIGHT);
            }
            else
            {
               return false;
            }
             }
             else
             {
            return false;
             }

             return true;
        }
예제 #11
0
        protected bool GenerateMeteoFiles(MohidRunEngineData mre)
        {
            DateTime simStartDate = mre.sim.Start;
             DateTime startsim;
             DateTime endsim;
             string dateStr;
             DateTime simStart = simStartDate.AddSeconds(1);
             int counter;
             string file, outputPath, outputName, tempFolder;
             bool found_file;
             System.IO.FileInfo fi;
             HDFGlue glueTool = new HDFGlue();
             ExternalApp interpolateTool = new ExternalApp();

             ConfigNode node = mre.cfg.Root.ChildNodes.Find(FindScriptBlocks);
             if (node == null)
             {
            Console.WriteLine("Node 'script.data' was not found in the config file.");
            return false;
             }

             //This will ensure that the first hour of simulation is included in the meteo file.
             startsim = simStart.AddHours(-5);
             endsim = startsim.AddHours(5);

             Console.WriteLine("Sim start: {0}", simStartDate.ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Generating Meteo file from {0} to {1}", startsim.ToString("yyyy/MM/dd HH:mm:ss"), mre.sim.End.ToString("yyyy/MM/dd HH:mm:ss"));
             Console.WriteLine("Sim lenght: {0}", mre.sim.SimLenght);

             //Get some important input from the script block in config file
             outputPath = node["glue.output.path", @"..\" + mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\"].AsString();
             outputName = node["glue.output.name", "meteo.hdf5"].AsString();
             tempFolder = node["interpolation.folder", @".\temp\"].AsString();

             //First, find the required files.
             int numberOfFiles = (int)(mre.sim.SimLenght * 4 + 1.0);
             Console.WriteLine("Expected number of 6 hours files to look: {0}", numberOfFiles);
             Console.WriteLine("Folder where meteo files are: {0}", node["meteo.folder", @"H:\"].AsString());
             Console.WriteLine("");
             Console.WriteLine("Looking for files...");
             Console.WriteLine("");

             int maxSkips = node["max.skips", 10].AsInt();
             int numberOfSkips = 0;
             List<string> requiredFiles = new List<string>();

             for (counter = 0; counter < numberOfFiles; counter++)
             {
            found_file = false;

            dateStr = startsim.ToString("yyyyMMddHH") + "_" + endsim.ToString("yyyyMMddHH");
            file = node["meteo.folder", @"H:\"].AsString() + @"D3_" + dateStr + ".hdf5";

            if (System.IO.File.Exists(file))
            {
               fi = new System.IO.FileInfo(file);
               if (fi.Length > 2000000)
               {
                  found_file = true;
                  requiredFiles.Add(file);
               }
            }

            if (!found_file)
            {
               Console.WriteLine("File '{0}' was not found.", file);

               if (counter + 1 == numberOfFiles)
               {
                  counter--;
                  numberOfSkips++;
                  if (numberOfSkips > maxSkips)
                  {
                     Console.WriteLine("Max number of skips reached during meteo creation file.");
                     return false;
                  }
               }
            }

            startsim = endsim.AddHours(1);
            endsim = startsim.AddHours(5);
             }

             //Now the files were found, they will be interpolated to the model's grid
             Console.WriteLine("Interpolating meteo file to model grid...");
             Dictionary<string, string> replace_list = new Dictionary<string, string>();
             FileName f_name = new FileName();
             string path = node["glue.input.folder", @"..\interpolation\temp\"].AsString();
             bool skipInterpolation = node["skip.interpolation", false].AsBool();

             foreach (string f in requiredFiles)
             {
            f_name.FullPath = f;
            glueTool.FilesToGlue.Add(path + f_name.FullName);

            if (!skipInterpolation)
            {

               replace_list["<<input.hdf>>"] = f;
               replace_list["<<father.grid>>"] = node["father.grid", @"..\..\general.data\digital.terrain\mm5.dat"].AsString();
               replace_list["<<output.hdf>>"] = tempFolder + f_name.FullName;
               replace_list["<<model.grid>>"] = node["model.grid", @"..\..\general.data\digital.terrain\grid.dat"].AsString();

               string template = node["template", mre.sim.SimDirectory.Path + @"templates\tools\convert.to.HDF5.action.template"].AsString();
               string action = node["action.file", @"..\tools\interpolation\converttoHDF5action.dat"].AsString();

               TextFile.Replace(template, action, ref replace_list);

               interpolateTool.WorkingDirectory = node["interpolation.working.folder", @"..\tools\interpolation\"].AsString();
               interpolateTool.Executable = node["interpolation.exe", @"..\tools\interpolation\interpolation.exe"].AsString();
               interpolateTool.CheckSuccessMethod = CheckSuccessMethod.DEFAULTOUTPUT;
               interpolateTool.TextToCheck = "successfully terminated";
               interpolateTool.SearchTextOrder = SearchTextOrder.FROMEND;
               interpolateTool.Wait = true;

               bool result = interpolateTool.Run();
               if (!result)
               {
                  Console.WriteLine("Interpolation failed.");
                  return false;
               }
            }
             }

             //Now the interpolated files are glued
             glueTool.AppName = node["glue.exe.name", "glue.exe"].AsString();
             glueTool.AppPath = node["glue.exe.path", @"..\tools\glue\"].AsString();
             glueTool.WorkingDirectory = node["glue.working.folder", @"..\tools\glue\"].AsString();
             glueTool.Output = outputPath + outputName;
             glueTool.Is3DFile = false;
             glueTool.ThrowExceptionOnError = true;

             Console.WriteLine("Gluing files...");

             if (glueTool.Glue() != 0)
             {
            Console.WriteLine("Glue failed.");
            return false;
             }

             //Saves the created meteo file in the folder
             if (!FileTools.CopyFile(node["local.boundary.folder", @"..\actual\local.data\boundary.conditions\"].AsFilePath(), new FilePath(orig.Path), "meteo.hdf5", Files.CopyOptions.OVERWRIGHT))
             {
            Console.WriteLine("Was not possible to copy the meteo file to the meteo storage folder.");
            return false;
             }

             //Delete all the files in the temp directory
             try
             {
            System.IO.DirectoryInfo directory = new DirectoryInfo(@"..\tools\interpolation\temp\");
            foreach (System.IO.FileInfo fileToDelete in directory.GetFiles())
               fileToDelete.Delete();
             }
             catch (Exception ex)
             {
            Console.WriteLine("Was not possible to empty the temp directory due to an exception.");
            Console.WriteLine("Message returned was: {0}", ex.Message);
             }

             return true;
        }
예제 #12
0
        protected bool SendToFTPOnEnd(MohidRunEngineData mre)
        {
            bool res = true;

             Dictionary<string, string> toReplace = new Dictionary<string, string>();

             try
             {
            ExternalApp app = new ExternalApp();

            FileTools.CopyFile(new FileName(@"..\templates\Tools\ref-evtp-cumulative.template"), new FileName(@"..\tools\ftp\ftp.dat"), CopyOptions.OVERWRIGHT);

            app.Executable = "ftp";
            app.WorkingDirectory = @"..\Cumulative";
            app.CheckSuccessMethod = CheckSuccessMethod.DONOTCHECK;
            app.Wait = true;
            app.Arguments = "-n -s:" + @"..\tools\ftp\ftp.dat ftp.mywater-fp7.eu";

            res = app.Run();

             }
             catch
             {
            return false;
             }

             return res;
        }
예제 #13
0
        //public override bool OnEnd(object data)
        //{
        //   MohidRunEngineData mre = (MohidRunEngineData)data;
        //   return SendToFTPOnEnd(mre);
        //}
        protected bool SendToFTP(MohidRunEngineData mre)
        {
            bool res = true;

             Dictionary<string, string> toReplace = new Dictionary<string, string>();

             string folderName = mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss");

             try
             {
            toReplace["<<folder>>"] = folderName;
            TextFile.Replace(@"..\templates\tools\ref-evtp.template", @"..\tools\ftp\ftp.dat", ref toReplace);

            ExternalApp app = new ExternalApp();

            app.Executable = "ftp";
            app.WorkingDirectory = @"..\store\" + folderName + @"\To.FTP";
            app.CheckSuccessMethod = CheckSuccessMethod.DONOTCHECK;
            app.Wait = true;
            app.Arguments = "-n -s:" + @"..\..\..\tools\ftp\ftp.dat ftp.mywater-fp7.eu";

            res = app.Run();
            if (!res)
               return false;
             }
             catch
             {
            return false;
             }

             return res;
        }
예제 #14
0
        public bool GenerateCumulative(MohidRunEngineData mre)
        {
            HDFGlue tool = new HDFGlue();
             tool.AppName = "glue.exe";
             tool.AppPath = @"..\tools\glue\";
             tool.WorkingDirectory = @"..\tools\glue\";

             bool res = true;

             FilePath pathToGlue = new FilePath(mre.storeFolder.Path + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss"));
             FileName toGlue = new FileName();
             toGlue.Path = mre.storeFolder.Path + mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss");
             FilePath destinationFolder = new FilePath(@"..\cumulative\");
             FilePath workingFolder = new FilePath(tool.WorkingDirectory);

             toGlue.FullName = "basin.hdf5";
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             toGlue.FullName = "basin.refevtp.hdf5";
             Console.WriteLine("{0}", toGlue.FullPath);
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             toGlue.FullName = "basin.evtp.hdf5";
             Console.WriteLine("{0}", toGlue.FullPath);
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             //toGlue.FullName = "porous.media.hdf5";
             //Console.WriteLine("{0}", toGlue.FullPath);
             //if (!GlueFiles(tool, true, workingFolder, destinationFolder, toGlue, mre))
             //   return false;

             toGlue.FullName = "drainage.network.hdf5";
             Console.WriteLine("{0}", toGlue.FullPath);
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             toGlue.FullName = "runoff.hdf5";
             Console.WriteLine("{0}", toGlue.FullPath);
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             toGlue.FullName = "atmosphere.hdf5";
             Console.WriteLine("{0}", toGlue.FullPath);
             if (!GlueFiles(tool, false, workingFolder, destinationFolder, toGlue, mre))
            return false;

             //tool.FilesToGlue.Clear();
             //tool.Output = cumulativeFolder + "atmosphere.hdf5";
             //foreach (System.IO.DirectoryInfo g in dir.GetDirectories())
             //{
             //   if (System.IO.File.Exists(g.FullName + "\\atmosphere.hdf5"))
             //      tool.FilesToGlue.Add(g.FullName + "\\atmosphere.hdf5");
             //}
             //if (tool.FilesToGlue.Count > 0)
             //   if (tool.Glue() != 0)
             //      res = false;

             if (!SendToFTPOnEnd(mre))
            res = false;

             return res;
        }
예제 #15
0
        public override bool OnSimStart(object data)
        {
            mre = (MohidRunEngineData)data;

             if (root == null)
             {
            Console.WriteLine("Block 'script.data' was not found in the config file.");
            return false;
             }

             storeFolder = mre.sim.Start.ToString("yyyyMMdd.HHmmss") + "-" + mre.sim.End.ToString("yyyyMMdd.HHmmss");

             if (mre.simID != 1)
             {
            storeFolderOld = mre.sim.Start.AddDays(-mre.log[mre.log.LastIndex].NodeData["sim.lenght"].AsDouble()).ToString("yyyyMMdd.HHmmss") +
                             "-" +
                             mre.sim.Start.ToString("yyyyMMdd.HHmmss");
             }

             //Get some important input from the script block in config file
             generalBoundary.Path = root["general.boundary.conditions"].AsFilePath().Path + storeFolder;
             outputPath = root["glue.output.path", @"..\" + mre.sim.SimDirectory.Path + @"local.data\boundary.conditions\"].AsString();
             outputName = root["glue.output.name", "meteo.hdf5"].AsString();
             tempFolder = root["interpolation.folder", @".\temp\"].AsString();
             pathToFilesToGlue = root["glue.input.folder", @"..\interpolation\temp\"].AsString();

             if (!SetupTemplates())
            return false;

             if (!CopyIniFiles())
            return false;

             if (!CopyMeteoFiles())
            return false;

             if (!CreatePracticesIDHDFFile())
            return false;

             return true;
        }
예제 #16
0
        public override bool AfterInitialization(object data)
        {
            try
             {
            mred = (MohidRunEngineData)data;

            script_block = mred.cfg.Root.ChildNodes.Find(delegate(ConfigNode cfg) { return cfg.Name == "script.data"; });
            if (script_block == null)
               throw new Exception("Block 'script.data' was not found in the config file.");

            LoadGlobalConfiguration();
            LoadToolsConfiguration();

            if (!LoadTasksConfiguration() && exception_raised)
               throw exception;

            return true;
             }
             catch (Exception ex)
             {
            exception = ex;
            return false;
             }
        }
예제 #17
0
        static bool Run(CmdArgs args, bool Verbose)
        {
            bool sim_run = true;
             MohidRunEngineData data = new MohidRunEngineData();
             data.args = args;
             OPTamegaScript op = new OPTamegaScript();

             try
             {
            if (Verbose) Console.Write("Loading Configuration...");
            LoadConfig(args, data);
            if (Verbose) Console.WriteLine("[OK]");

            if (Verbose) Console.Write("Running...");
            op.OnSimStart(data);
            if (Verbose) Console.WriteLine("[OK]");

             }
             catch (Exception ex)
             {
            if (Verbose)
            {
               Console.WriteLine("[FAILED]");
               Console.WriteLine("");
               Console.WriteLine("An EXCEPTION was raised. The message returned was:");
               Console.WriteLine(ex.Message);
               Console.WriteLine("");
            }
             }

             return sim_run;
        }