Commit 2617a91c authored by jclamber's avatar jclamber

Fix bugs on sqlite3 db. Fix bug when trying to read a directory

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@160 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 806b8b47
#
nemocvs:
rsync -CRav --exclude-from=exclude.txt CMakeLists.txt INSTALL LICENSE 3rdparty cmake man src template test_src ${NEMO}/usr/jcl/unsio
rsync -CRav --exclude-from=exclude.txt CMakeLists.txt INSTALL LICENSE 3rdparty cmake man src scripts template test_src ${NEMO}/usr/jcl/unsio
tar :
cd ..;tar czhvf unsio/unsio-`date "+%d%b-%Y-%H.%M"`.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/CMakeLists.txt unsio/cmake/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/INSTALL unsio/mmakefile unsio/man/man3/* unsio/3rdparty/nemolight/build/CMakeLists.txt unsio/3rdparty/nemolight/src/*.{c,h} unsio/3rdparty/nemolight/src/inc/*.{c,h} unsio/3rdparty/nemolight/src/inc/snapshot/*.{c,h} unsio/3rdparty/nemolight/src/fortran_old_gcc/*.{c,h} unsio/template/uns_devel/cmake/*.cmake unsio/template/uns_devel/README unsio/template/uns_devel/CMakeLists.txt unsio/template/uns_devel/src/*.{c,cc,F} unsio/template/uns_devel/lib/src/*.{c,cc,F} 2> /dev/null`
cd ..;tar czhvf unsio/unsio-`date "+%d%b-%Y-%H.%M"`.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/CMakeLists.txt unsio/cmake/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/INSTALL unsio/mmakefile unsio/man/man3/* unsio/3rdparty/nemolight/build/CMakeLists.txt unsio/3rdparty/nemolight/src/*.{c,h} unsio/3rdparty/nemolight/src/inc/*.{c,h} unsio/3rdparty/nemolight/src/inc/snapshot/*.{c,h} unsio/3rdparty/nemolight/src/fortran_old_gcc/*.{c,h} unsio/template/uns_devel/cmake/*.cmake unsio/template/uns_devel/README unsio/template/uns_devel/CMakeLists.txt unsio/template/uns_devel/src/*.{c,cc,F} unsio/template/uns_devel/lib/src/*.{c,cc,F} unsio/scripts/perl/lib/Tools/*.pm unsio/scripts/perl/mains/*.pl unsio/scripts/sql/*.sql unsio/scripts/sql/README 2> /dev/null`
template:
cd template; tar czhvf ../uns_devel.tar.gz `ls uns_devel/cmake/*.cmake uns_devel/README uns_devel/CMakeLists.txt uns_devel/src/*.{c,cc,F} uns_devel/lib/src/*.{c,cc,F}`
......
......@@ -75,7 +75,7 @@ sub Sqlite::getValidDb
my $class = shift;
my $dbparam = shift;
if (defined($dbparam)) {
if (defined($dbparam) && $dbparam ne "") {
$db = $dbparam;
} else {
# parse parameter file
......
......@@ -30,6 +30,8 @@ BEGIN
use strict; # must define everything
use Getopt::Long;
use Tools::Tools;
use Tools::Sqlite3;
use DBI;
# -------------------------------------------------------------
# Main program
......@@ -46,7 +48,7 @@ my $halo2 ='';
my $gas ='';
my $bndry ='';
my $stars ='';
my $db = "/pil/programs/DB/simulation.dbl"; # Marseille database
my $db = ""; # Marseille database
my $help = 0;
GetOptions( 'simname=s' => \$name,
......@@ -69,6 +71,7 @@ if ( $help ) {
# check mandatory parameters
die "Option --simname not specified.\n" unless defined($name);
}
my $db = Sqlite->getValidDb($db);
printf STDERR "name=$name,total=$total,disk=$disk,bulge=$bulge,halo=$halo,halo2=$halo2 ,gas=$gas ,bndry=$bndry, stars=$stars [$db]\n";
......
......@@ -14,6 +14,11 @@
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <dirent.h>
namespace tools {
// ----------------------------------------------------------------------------
// isFileExist
......@@ -29,6 +34,16 @@ bool Ctools::isFileExist(std::string _file)
return status;
}
// ----------------------------------------------------------------------------
// isFileExist
bool Ctools::isDirectory(std::string _dir)
{
bool status=false;
if (opendir(_dir.c_str())) {
status=true;
}
return status;
}
// ----------------------------------------------------------------------------
// fixFortran
std::string Ctools::fixFortran(const char * _ff, const int len, const bool lower)
{
......
......@@ -60,6 +60,7 @@ namespace tools {
static std::string fixFortran(const char *,const bool lower=true);
static std::string fixFortran(const char *,const int len, const bool lower=true);
static bool isFileExist(std::string);
static bool isDirectory(std::string);
static std::string toupper(std::string);
static std::string tolower(std::string);
static int compBits(std::string s) {
......
......@@ -88,7 +88,7 @@ namespace uns {
{
assert(snapshot != NULL);
assert(snapshot->isValidData());
if ((simtype == "Nemo") && nemosim != "" && crv.size()>0) {
if ((tools::Ctools::tolower(simtype) == "nemo") && nemosim != "" && crv.size()>0) {
return &crv;
}
else {
......
......@@ -68,7 +68,7 @@ ComponentRangeVector * CSnapshotSimIn::getSnapshotRange()
{
assert(snapshot != NULL);
assert(snapshot->isValidData());
if ((simtype == "Nemo") && nemosim != "" && crv.size()>0) {
if ((tools::Ctools::tolower(interface_type) == "nemo") && nemosim != "" && crv.size()>0) {
return &crv;
}
else {
......
......@@ -77,7 +77,8 @@ namespace uns {
if (simname == "-") { // we assume here that "-"
tryNemo(); // is standard input and a NEMO stream...
} else {
if (tools::Ctools::isFileExist(simname)) { // file exist
if (tools::Ctools::isFileExist(simname) && // file exist
! tools::Ctools::isDirectory(simname)) { // not a directory
tryGadget(); // try gadget
if (!valid) { // gadget failed
tryRamses(); // try ramses
......@@ -103,6 +104,9 @@ namespace uns {
std::cerr << "File : " << snapshot->getFileName() << "\n";
std::cerr << "Interface : " << snapshot->getInterfaceType() << "\n";
}
if (!valid){
std::cerr << "\nFile ["<< snapshot->getFileName() <<"], unknown UNS file format, aborting.....\n\n";
}
}
// ----------------------------------------------------------------------------
// destructor for READING operations
......
......@@ -210,18 +210,21 @@ int main(int argc, char ** argv )
uns->snapshot->getData("time",&time);
std::cout << "Nbody selected = " << nbody << "\nTime="<<time <<"\n";
if (0 && file_structure=="range") {
displayInfo(display,maxlines,"all",uns);
} else {
component_exist=false;
displayInfo(display,maxlines,"gas" ,uns);
displayInfo(display,maxlines,"halo" ,uns);
displayInfo(display,maxlines,"disk" ,uns);
displayInfo(display,maxlines,"bulge",uns);
displayInfo(display,maxlines,"stars",uns);
displayInfo(display,maxlines,"bndry",uns);
if (!component_exist) { // no comp, diplay all
if (nbody >0) {
if (0 && file_structure=="range") {
displayInfo(display,maxlines,"all",uns);
} else {
component_exist=false;
displayInfo(display,maxlines,"gas" ,uns);
displayInfo(display,maxlines,"halo" ,uns);
displayInfo(display,maxlines,"disk" ,uns);
displayInfo(display,maxlines,"bulge",uns);
displayInfo(display,maxlines,"stars",uns);
displayInfo(display,maxlines,"bndry",uns);
if (!component_exist) { // no comp, diplay all
displayInfo(display,maxlines,"all",uns);
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment