Commit 9af1ffe1 authored by jcl's avatar jcl

new SVN structure

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@55 ce2cc22f-6084-46ce-a062-084b172ee5dc
parents
To compile UNSIO library, you need to install CMAKE utility
(Cf http://www.cmake.org/)
*) compilation
proceed as following :
cd build
cmake .
make
*) installation
make install
it will install the project into $HOME/local directory, unless the
environnement variable LOCAL was defined in another place before
running "cmake ." command.
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2009-2011
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Laboratoire d'Astrophysique de Marseille
# Pole de l'Etoile, site de Chateau-Gombert
# 38, rue Frederic Joliot-Curie
# 13388 Marseille cedex 13 France
# CNRS U.M.R 6110
# ============================================================================
# CMakeListst.txt file for UNS library
# ============================================================================
cmake_minimum_required(VERSION 2.6)
#INCLUDE(CPack)
# project name
project (UNSIO)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
# extra path for NEMO
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_BINARY_DIR})
SET(OSX FALSE)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(OSX TRUE)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
FIND_PACKAGE(NEMO)
FIND_PACKAGE(SQLITE3)
IF (NOT NEMO_INSTALLED)
MESSAGE(FATAL_ERROR "NEMO environment not loaded !!!")
ELSE (NOT NEMO_INSTALLED)
set(NEMOLIB $ENV{NEMOLIB})
set(NEMOINC $ENV{NEMOINC})
ENDIF (NOT NEMO_INSTALLED)
MESSAGE( STATUS "NEMOLIB : " ${NEMOLIB} )
# contains the full path to the top level directory of your build tree
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
# contains the full path to the root of your project source directory,
# i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
# Find all the sources for the LIB
FILE(GLOB LIBSOURCES ../src/*.cc)
# Destination path for the lib
SET(LIBRARY_OUTPUT_PATH ../lib)
# compilation options
add_definitions(-Wall -g -Wswitch -Wcast-align -Wreturn-type -Wno-unused-function -fno-strict-aliasing -ggdb ${DNOSQLITE3})
# create library "uns"
add_library (unsio SHARED ${LIBSOURCES} )
if(OSX)
set_target_properties(unsio PROPERTIES LINK_FLAGS "-L${NEMOLIB} -lnemo -lsqlite3")
endif(OSX)
#
# ------------------
# TEST PROGRAM
# ------------------
# Enable Fortran support
ENABLE_LANGUAGE(Fortran)
#SET(CMAKE_Fortran_COMPILER ${FORT_COMP})
SET(CMAKE_Fortran_COMPILER gfortran)
# Executbale output path
set(EXECUTABLE_OUTPUT_PATH ../bin)
MESSAGE( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
# Make sure the compiler can find include files from our Hello library.
include_directories (${UNSIO_SOURCE_DIR}/../src $ENV{NEMOINC} ${NEMOLIB} ${SQLITE3_H_PATH})
# Make sure the linker can find the Hello library once it is built.
link_directories (${UNSIO_BINARY_DIR}/lib /usr/X11/lib ${SQLITE3_LIB_PATH} ${NEMOLIB} ${FC_GFORT_PATH} ${FC_G77_PATH})
# Find all LIB's sources files
FILE(GLOB exe_sources ../test_src/*.F)
# ----------------------------------------------------------
# Make sure the compiler can find include files from our Hello library.
#include_directories (${UNS_SOURCE_DIR}/src $ENV{NEMOINC} ${NEMOLIB})
# Find all LIB's sources files
FILE(GLOB execpp_sources ../test_src/*.cc)
# build cpp executables according to the source
FOREACH(exe_cpp ${execpp_sources})
get_filename_component(exe ${exe_cpp} NAME_WE)
MESSAGE( STATUS "New executable ==> " ${exe})
add_executable (${exe} ${exe_cpp})
# Link the executable to the Hello library.
target_link_libraries (${exe} unsio nemo ${SQLITE3_LIB} X11 pgplot ${FC_GFORT_LIB} ${FC_G77_LIB} stdc++)
ENDFOREACH(exe_cpp ${execpp_sources})
# build Fortran executables according to the source
# compilation options
FOREACH(exe_f ${exe_sources})
get_filename_component(exe ${exe_f} NAME_WE)
MESSAGE( STATUS "New executable ==> " ${exe})
add_executable (${exe} ${exe_f})
# Link the executable to the Hello library.
#target_link_libraries (${exe} unsio nemomaing77 nemo g2c sqlite3 stdc++)
target_link_libraries (${exe} unsio nemomaing77 nemo ${SQLITE3_LIB} ${FC_LIB} stdc++)
SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE Fortran)
# add "-lstdc++"
#SET(CMAKE_Fortran_LINK_FLAGS "-L${NEMOLIB} ") #-lstdc++")
ENDFOREACH(exe_f ${exe_sources})
# ----------------------------------------------------------
# install target
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX $ENV{NEMO})
# lib
IF (OSX) # Mac OSX
INSTALL(FILES ${UNSIO_BINARY_DIR}/../lib/libunsio.dylib DESTINATION lib)
ELSE (OSX) # Linux
INSTALL(FILES ${UNSIO_BINARY_DIR}/../lib/libunsio.so DESTINATION lib)
ENDIF(OSX)
# includes
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/uns.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/unsdebug.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/snapshotinterface.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/componentrange.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/ctools.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO_BINARY_DIR}/../src/userselection.h DESTINATION inc/uns)
ENDIF (NEMO_INSTALLED)
# man
INSTALL(FILES ${UNSIO_BINARY_DIR}/../man/man3/unsiof.3 DESTINATION man/man3)
#set (CMAKE_INSTALL_PREFIX $ENV{NEMOBIN})
#INSTALL(PROGRAMS ${UNSIO_BINARY_DIR}/../bin/unscpp DESTINATION bin)
SET(NEMO_INSTALLED FALSE)
FILE(GLOB GLOB_TEMP_VAR $ENV{NEMO})
IF(GLOB_TEMP_VAR)
SET(NEMO_INSTALLED TRUE)
# Detect fortran compiler from ${NEMOLIB}/makedefs
# files (variable FC = )
FILE(READ $ENV{NEMOLIB}/makedefs MAKEDEFS)
STRING(REGEX MATCH "FC = gfortran" GFORTRAN_IS_SET ${MAKEDEFS})
IF ("FC = gfortran" STREQUAL "${GFORTRAN_IS_SET}")
MESSAGE("GFortran compiler Detected......")
SET (FORT_COMP gfortran)
ELSE("FC = gfortran" STREQUAL "${GFORTRAN_IS_SET}")
# g77 stuffs
MESSAGE("Assuming G77 compiler")
SET (FORT_COMP g77)
ENDIF ("FC = gfortran" STREQUAL "${GFORTRAN_IS_SET}")
# gfortran stuffs
SET (FC_GFORT_LIB "")
SET (FC_GFORT_PATH "")
set (GFORTPATH "")
execute_process(COMMAND gfortran -print-file-name=libgfortran.a
OUTPUT_VARIABLE GFORTPATH OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (NOT ${GFORTPATH} STREQUAL "")
MESSAGE("GFORTRAN compiler exist, adding libgfortran......")
execute_process(COMMAND dirname ${GFORTPATH}
OUTPUT_VARIABLE FC_GFORT_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
SET (FC_GFORT_LIB gfortran)
ENDIF(NOT ${GFORTPATH} STREQUAL "")
# g77 stuffs
SET (FC_G77_LIB "")
SET (FC_G77_PATH "")
set (G2CFPATH "")
execute_process(COMMAND g77 -print-file-name=libg2c.a
OUTPUT_VARIABLE G2CFPATH OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (NOT ${G2CFPATH} STREQUAL "")
MESSAGE("G77 compiler exist, adding libg2c......")
execute_process(COMMAND dirname ${G2CFPATH}
OUTPUT_VARIABLE FC_G77_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
SET (FC_G77_LIB g2c)
ENDIF(NOT ${G2CFPATH} STREQUAL "")
ENDIF(GLOB_TEMP_VAR)
if (NOT NEMO_INSTALLED)
MESSAGE(STATUS "NEMO environement not loaded.... using nemo_light")
endif (NOT NEMO_INSTALLED)
# --------------------------------------------------------
# CMake module to detect SQLITE3 library
# --------------------------------------------------------
SET(SQLITE3_FOUND FALSE)
SET(DNOSQLITE3 "-DNOSQLITE3") # if sqlite3 does not exist
SET(SQLITE3_LIB_PATH "")
SET(SQLITE3_H_PATH "")
SET(SQLITE3_LIB "")
find_file(SQLITE3_H NAMES "sqlite3.h" PATH /usr/local/include)
IF (SQLITE3_H)
get_filename_component(SQLITE3_H_PATH ${SQLITE3_H} PATH)
MESSAGE(STATUS "Found sqlite3.h:" ${SQLITE3_H})
MESSAGE(STATUS "Found sqlite3.h path:" ${SQLITE3_H_PATH})
find_library(SQLITE3 NAMES sqlite3 PATH /usr/local/lib)
IF (SQLITE3)
SET(SQLITE3_FOUND TRUE)
SET(DNOSQLITE3 "") # SQLITE3 exist
SET(SQLITE3_LIB sqlite3)
MESSAGE(STATUS "Found library here :" ${SQLITE3})
get_filename_component(SQLITE3_LIB_PATH ${SQLITE3} PATH)
MESSAGE(STATUS "Found library PATH :" ${SQLITE3_LIB_PATH})
ENDIF(SQLITE3)
ENDIF(SQLITE3_H)
This diff is collapsed.
#
nemocvs:
rsync -CRav --exclude-from=exclude.txt build/CMakeLists.txt build/FindNEMO.cmake . ${NEMO}/usr/jcl/unsio
tar :
cd ..;tar czhvf unsio/unsio.tar.gz `ls unsio/src/*.{f,F,cc,h} unsio/test_src/*.{f,F,cc,h} unsio/build/CMakeLists.txt unsio/build/*.cmake unsio/doc/*.{odp,pdf,txt} unsio/HOWTO_INSTALL unsio/mmakefile 2> /dev/null`
#
[Dolphin]
Timestamp=2009,9,18,9,28,5
ViewMode=1
# -*-makefile-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2008
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Laboratoire d'Astrophysique de Marseille
# Pole de l'Etoile, site de Chateau-Gombert
# 38, rue Frederic Joliot-Curie
# 13388 Marseille cedex 13 France
# CNRS U.M.R 6110
# ============================================================================
#include $(NEMOLIB)/makedefs
SHELL = /bin/csh -f
# Compilation otions
CPP = g++
CPPFLAGS = -I$(NEMOINC) -I$(NEMOLIB) -Wall -g
LNEMO = -L$(NEMOLIB) -lnemo++ -lnemo
OS = linux
ifeq (${OS},linux)
LDL=-ldl
else
LDL=
endif
# Files OBJ
FOBJ = obj
# Files BIN
# FILES SOURCES
FSRC = ./
# targets
lib : dirs $(FOBJ)/libuns.a testlib
bin : dirs info gad
info : dirs $(FBIN)/g2info
gad : dirs $(FBIN)/gadget2nemo
nem : dirs $(FBIN)/nemo2gadget
#install: info gad
# \cp -p $(FBIN)/gadget2nemo $(FBIN)/g2info ${NEMOBIN}
# chmod 755 ${NEMOBIN}/gadget2nemo ${NEMOBIN}/g2info
#nemo_bin: install
clean:
@/bin/rm $(OBJLIB) $(LIB) >& /dev/null
#--
# LIBs
#
LIB := $(FOBJ)/libuns.a
#--
IO := $(FOBJ)/gadgetio.o
COMP := $(FOBJ)/componentrange.o
USER := $(FOBJ)/userselection.o
UNS := $(FOBJ)/unsengine.o
UNSI := $(FOBJ)/unsidentifier.o
UNSW := $(FOBJ)/unsfwrapper.o
INTER := $(FOBJ)/snapshotinterface.o
SNAPGAD := $(FOBJ)/snapshotgadget.o
OBJLIB := $(IO) $(COMP) $(USER) $(UNS) $(UNSI) $(UNSW) $(SNAPGAD)
OBJTOOLS := $(IO) $(COMP)
$(UNS) : $(FSRC)/unsengine.cc $(FSRC)/unsengine.h $(SNAPGAD)
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/unsengine.cc
$(UNSI): $(FSRC)/unsidentifier.cc $(FSRC)/unsidentifier.h $(UNS)
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/unsidentifier.cc
$(UNSW): $(FSRC)/unsfwrapper.cc $(UNSI)
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/unsfwrapper.cc
$(IO) : $(FSRC)/gadgetio.cc $(FSRC)/gadgetio.h $(FSRC)/componentrange.h $(FSRC)/userselection.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/gadgetio.cc
$(COMP) : $(FSRC)/componentrange.cc $(FSRC)/componentrange.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/componentrange.cc
$(USER) : $(FSRC)/userselection.cc $(FSRC)/userselection.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/userselection.cc
$(SNAPGAD) : $(FSRC)/snapshotgadget.cc $(FSRC)/snapshotgadget.h $(FSRC)/snapshotinterface.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/snapshotgadget.cc
#$(INTER): $(FSRC)/snapshotinterface.cc $(FSRC)/snapshotinterface.h $(COMP)
# $(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/snapshotinterface.cc
$(FSRC)/snapshotinterface.h : $(FSRC)/componentrange.h
#-- lib
$(FOBJ)/libuns.a : $(OBJLIB)
ar rcv $@ $(OBJLIB)
#-- testlib target
OBJF := $(FOBJ)/testlib.o
testlib : $(FOBJ)/testlib.o
$(FC) $(FFLAGS) -o $@ $(FOBJ)/testlib.o $(FOBJ)/libuns.a -lstdc++
$(FOBJ)/testlib.o : $(FSRC)/testlib.F $(FOBJ)/libuns.a
$(FC) $(FFLAGS) -o $@ -c $(FSRC)/testlib.F
#--
OBJ1 := $(FOBJ)/gadget2nemo.o
$(FBIN)/gadget2nemo : $(OBJ1) $(OBJTOOLS) $(USER)
$(CPP) -o $@ $(OBJ1) $(OBJTOOLS) $(USER) $(LNEMO) ${LDL} -lstdc++ -lm
$(OBJ1) : $(FSRC)/gadget2nemo.cc $(FSRC)/gadgetio.h $(FSRC)/userselection.h $(FSRC)/componentrange.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/gadget2nemo.cc
#--
OBJ2 = $(FOBJ)/nemo2gadget.o
$(FBIN)/nemo2gadget : $(OBJ2) $(OBJTOOLS)
$(CPP) -o $@ $(OBJ2) $(OBJTOOLS) $(LNEMO) ${LDL} -lstdc++ -lm
$(OBJ2) : $(FSRC)/nemo2gadget.cc $(FSRC)/gadgetio.h $(FSRC)/userselection.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/nemo2gadget.cc
#--
OBJ3 := $(FOBJ)/g2info.o
$(FBIN)/g2info : $(OBJ3) $(OBJTOOLS)
$(CPP) -o $@ $(OBJ3) $(OBJTOOLS) $(LNEMO) ${LDL} -lstdc++ -lm
$(OBJ3) : $(FSRC)/g2info.cc $(FSRC)/gadgetio.h
$(CPP) $(CPPFLAGS) -o $@ -c $(FSRC)/g2info.cc
# targets
dirs :
@mkdir -p ${FOBJ} ${FBIN}
tar:
(cd ../..; tar czhvf gadget2-tools/gadget2-tools.tar.gz `ls gadget2-tools/src/*.{cc,h,txt} gadget2-tools/src/Makefile`)
#
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2008-2010
// e-mail: Jean-Charles.Lambert@oamp.fr
// address: Dynamique des galaxies
// Laboratoire d'Astrophysique de Marseille
// Ple de l'Etoile, site de Chteau-Gombert
// 38, rue Frdric Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 6110
// ============================================================================
#include "componentrange.h"
#include <sstream>
#include <iostream>
#include "assert.h"
namespace uns {
// ============================================================================
// constructor
ComponentRange::ComponentRange()
{
n=0;
position=first=last=-1;
range="";
type="";
}
// ============================================================================
// copy constructor
ComponentRange::ComponentRange(const ComponentRange&m)
{
n = m.n;
first = m.first;
last = m.last;
range = m.range;
type = m.type;
position = m.position;
}
// ============================================================================
ComponentRange::~ComponentRange()
{
}
// ============================================================================
void ComponentRange::setData(const int _f, const int _l, const std::string _t)
{
first=_f;
last = _l;
setType(_t);
computeN();
buildRange();
}
// ============================================================================
int ComponentRange::computeN()
{
n=last-first+1;
return n;
}
// ============================================================================
void ComponentRange::buildRange()
{
std::ostringstream stm1,stm2;
stm1 << first;
stm2 << last;
range = stm1.str()+":"+stm2.str();
}
// ============================================================================
// getIndexMatchType
// return the index vector matching the type of object in the component range
// vector. Return also the object offset in the index tab
int ComponentRange::getIndexMatchType(const ComponentRangeVector * crv, const std::string type,
int &offset, bool crvuser)
{
int status=-1;
offset=0;
assert(crv);
for (unsigned int i=0; i<crv->size()&&status==-1; i++) {
//std::cerr << "i="<<i<<" crv.type =" <<(*crv)[i].type<<" type="<<type<<"\n";
if ((*crv)[i].type == type) status=i;
else {
if (i>0 || crvuser) { // skip first which match "all" component
// or User's crv is processing "no all"
offset+=(*crv)[i].n;
}
}
}
return status;
}
// ============================================================================
void ComponentRange::list(const ComponentRangeVector * crv)
{
std::cerr << "ComponentRange::list size"<<crv->size()<<"\n";
for (unsigned int i=0; i<crv->size(); i++) {
std::cerr << "-----------------------------------------------------------\n";
std::cerr << "Component #"<<i<<"\n";
std::cerr << "type :"<<(*crv)[i].type<<"\n";
std::cerr << "range :"<<(*crv)[i].range<<"\n";
std::cerr << "nbody :"<<(*crv)[i].n<<"\n";
}
}
// ============================================================================
int ComponentRange::print(const ComponentRangeVector * crv, std::string select)
{
for (unsigned int i=0; i<crv->size(); i++) {
if ((*crv)[i].type == select) return i;
}
return -1;
}
} // namespace
// ============================================================================
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2008-2010
// e-mail: Jean-Charles.Lambert@oamp.fr
// address: Dynamique des galaxies
// Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 6110
// ============================================================================
#ifndef UNSCOMPONENTRANGE_H
#define UNSCOMPONENTRANGE_H
/**
@author Jean-Charles Lambert <jean-charles.lambert@oamp.fr>
*/
#include <vector>
#include <string>
namespace uns {
class ComponentRange;
typedef std::vector <ComponentRange> ComponentRangeVector;
class ComponentRange{
public:
ComponentRange();
ComponentRange(const ComponentRange&); // copy constructor
~ComponentRange();
void setData(const int _f,const int _l, const std::string _type="");
void setType(std::string _type) { type = _type; }
void setPosition(const int _pos) { position = _pos;}
static int getIndexMatchType(const ComponentRangeVector * crv, const std::string type,
int & offset,bool crvuser=false);
static void list(const ComponentRangeVector * crv);
static int print(const ComponentRangeVector * crv, std::string select);
static bool compareFirst(const ComponentRange &a ,const ComponentRange &b) {
return a.first < b.first;
};
static bool comparePos(const ComponentRange &a ,const ComponentRange &b) {
return a.position < b.position;
};
std::string range, // "0:99999"
type; // "all", "halo", "disk", "bulge", "gas", "other"....
int first,last,n;
int position;
private:
int computeN();
void buildRange();
};
}
#endif
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2009-2010
// e-mail: Jean-Charles.Lambert@oamp.fr
// address: Dynamique des galaxies
// Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 6110
// ============================================================================
#include "ctools.h"
#include <cstdlib>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <algorithm>
namespace tools {
// ----------------------------------------------------------------------------
// isFileExist
bool Ctools::isFileExist(std::string _file)
{
bool status=false;
std::ifstream ftest;
ftest.open(_file.c_str(),std::ios::in);
if ( ftest.is_open()) {
status=true;
ftest.close();
}
return status;
}
// ----------------------------------------------------------------------------
// fixFortran
std::string Ctools::fixFortran(const char * _ff, const int len, const bool lower)
{
char * buff = new char[len+1];
strncpy(buff,_ff,len);
buff[len]='\0';
std::string str=buff;
delete [] buff;
size_t found;
// for backward compatibility
// correct old program with explicit '\0' character
found = str.find("\\");
if (found!=std::string::npos) {
//std::cerr << "FOUND at "<<found<< "\n";
str.replace(found,2," ");
}
found=str.find_last_not_of(" ");
if (found!=std::string::npos)
str.erase(found+1);
else
str.clear(); // str is all whitespace
//std::cerr << "fix_fortran2 =["<<str<<"]\n";
return str;
}
// ----------------------------------------------------------------------------
// fixFortran
std::string Ctools::fixFortran(const char * _ff, const bool lower)
{
static char buff[200], * p;
memset( buff, '\0', 200 );
//std::cerr << "Fortran string ["<<_ff<<"]\n";
p=(char *) strchr(_ff,'\\');
if (p) {
//std::cerr << "Got \\ \n";
assert (p-_ff<=200);
strncpy(buff,_ff,p-_ff);
}
else {
p=(char *) strchr(_ff,'#');
if (p) {
//std::cerr << "Got #\n";
assert (p-_ff<=200);
strncpy(buff,_ff,p-_ff);
} else {
//std::cerr << "Got nothing.....\n";
strcpy(buff,_ff);
}
}
//std::cerr << "Buff ["<<buff<<"]\n";
if (lower)
return tolower(std::string(buff));
else
return std::string(buff);
}
// ----------------------------------------------------------------------------
// tolower
std::string Ctools::tolower(std::string s)
{
std::transform(s.begin(),s.end(),s.begin(),(int(*)(int)) std::tolower);
return s;
}
// ----------------------------------------------------------------------------
// tolupper
std::string Ctools::toupper(std::string s)
{
std::transform(s.begin(),s.end(),s.begin(),(int(*)(int)) std::toupper);
return s;
}
}
// ============================================================================
// Copyright Jean-Charles LAMBERT - 2009-2010
// e-mail: Jean-Charles.Lambert@oamp.fr
// address: Dynamique des galaxies
// Laboratoire d'Astrophysique de Marseille
// Pole de l'Etoile, site de Chateau-Gombert
// 38, rue Frederic Joliot-Curie
// 13388 Marseille cedex 13 France
// CNRS U.M.R 6110
// ============================================================================
#ifndef CTOOLS_H
#define CTOOLS_H
/**
@author Jean-Charles Lambert <jean-charles.lambert@oamp.fr>
*/
#include <cctype>
#include <cstring>
#include <string>
namespace tools {
// Physical bits
#define TIME_BIT (1 << 1)
#define KEYS_BIT (1 << 2)
#define HEADER_BIT (1 << 3)
#define MASS_BIT (1 << 4)
#define POS_BIT (1 << 5)
#define VEL_BIT (1 << 6)
#define EPS_BIT (1 << 7)
#define RHO_BIT (1 << 8)
#define HSML_BIT (1 << 9)
#define U_BIT (1 << 10)
#define ID_BIT (1 << 11)
#define METAL_BIT (1 << 12)
#define AGE_BIT (1 << 13)
#define AUX_BIT (1 << 14)
#define POT_BIT (1 << 15)
#define ACC_BIT (1 << 16)
#define TEMP_BIT (1 << 17)
#define ZS_BIT (1 << 18)
#define ZSMT_BIT (1 << 19)
#define IM_BIT (1 << 20)
// Component BITS
#define ALL_BIT (1 << 1)
#define GAS_BIT (1 << 2)