10/28/2013

gcc and gfortran on OS X 10.9 Marvericks

A new release of OS X 10.9 Marvericks was installed on my MacBook 15-inch Retina Pro 2012.
I kept all softwares previously installed on OS X 10.8 as they were. All of them are working
well without a change except for the following.

gcc 4.8.1
========
I needed to install the Command Line Tools by issuing 
%xcode-select --install
to make gcc work. This is necessary regardless whether one has
already installed Xquartz or not.

gfortran
=========
I need
-fno-underscoring
option at the load time to use gnu extensions. 
This was not required before in my case.

10/17/2013

How to make PDF v1.6 files comprisable in LaTeX?

 This issue may concern when you are using TeX Live distribution of dvipdfmx.

It is a common problem that PDF v1.6 files are not comprisable in LaTeX sources to produce PDF outputs using dvipdfmx. This problem occurs due to a line at the beginning of a file dvipdfmx.cfg that reads

V 5

which specify the output PDF version to be 1.5. The problem is fixed by just replacing this line by

V 6

The file dvipdfmx.cfg is placed in <distribution>/texlive/<version>/texmf-config/dvipdfmx for typical cases of TeX Live distributions.

I encountered this problem in TeXShop with ptex2pdf for Japanese writing and found the file in the directory with <distribution> = /usr/local and <version> = 2013.

8/29/2013

A primitive way to pass a pointer to CINT macro

I have a TTree pointed to by *tree in my C++ program and want to pass it to MyMacro.C to use it in a CINT session invoked from the C++ program. Here is a primitive-but-it-does-work way as below.

Lines in my C++ program read

TTree *tree = ....
std::stringstream ss;
ss<< tree;
std::string macroName = "MyMacro.C("+'"'+ss.str()+'"'+")";
gROOT->Macro(macroName.c_str());

and in MyMacro.C, I have

void MyMacro(std::string &tp){

TTree *tree;
std::stringstream ss(tp);
ss>> tree;

int nentries = (Int_t)tree->GetEntries();
TObject *tobj;
...
}

8/27/2013

Using MyClass in a CINT macro

When I am evaluating something in my C++ program and calling a CINT macro by

gROOT->Macro(mymacro.C);

to draw figures, I need to pass parameters of the evaluation to this macro.
When the number of parameters increases and their structures get complicated,  passing them by

mymacro.C(hard coded parameter list)

is not useful. In this case, I prepare a class MyClass to define a set of parameters to use
in my evaluation and pass it to the macro. Results of the evaluation kept in MyClass
can certainly be passed to the macro for drawings. The way to do this is well described in
The CINT Dictionary Generator.

Here I note my sample case where MyClass is stand alone and not inheriting from TObject class.
MyClass is defined in MyClass.h and implemented in MyClass.cpp
MyClass has a constructor without arguments.
Parameters are defined as static members of MyClass.
MyClass is called in mymacro.C as

MyClass passParams;

In the Makefile which I showed on Aug. 13, the following lines are added to create
a dictionary MyClassDict.o to compile with the main part:
CINTCLASS = MyClass
UOBJS := $(UOBJS) $(CINTCLASS).o $(CINTCLASS)Dict.o
$(CINTCLASS)Dict.cpp: $(CINTCLASS).h
<<tab>> rootcint -f $(CINTCLASS)Dict.cpp -c $(CINTCLASS).h

Now I can draw figures of results from a C++ computation interactively in CINT.

8/16/2013

Geant 4.9.6 p02 installation


I use macports to install supplemental softwares:

sudo port -v install cmake (necessary)
sudo port -v install iAIDA (optional, I was just curious)
sudo port -v install xercesc3 (needed for GDML)
sudo port -v install qt4-mac +demos +examples (optional. This takes very long.)


I downloaded the newest available source from cern Source Download Page.
I am going to install it in /usr/local/geant4:

$ sudo mkdir /usr/local/geant4
$ cd /usr/local/geant4
$ mkdir build4.9.6.p02
$ sudo mv  ~/Downloads/geant* ./
$ sudo tar -xvf geant4.9.6.p02.tar
$ cd build4.9.6.p02

$ls -lO /
$sudo chflags nohidden /usr (to see files on finder)
$export G4INSTALL=/usr/local/geant4/geant4.9.6.p02
Now we use cmake
$sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DXERCESC_ROOT_DIR=/opt/local -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_USE_RAYTRACER_X11=ON -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_GDML=ON -DGEANT4_USE_QT=ON $G4INSTALL
For build options, refer to section 2.3 in ‎geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/fo/BookInstalGuide.pdf

Now proceed usual make:
$sudo make -j4
$sudo make install

$ls -lO /
$sudo chflags hidden /usr (to hide /usr from finder)

Build an example application:
$cd /my/private/directory
$mkdir B1-build
$cd B1-build
$source /usr/local/bin/geant4.sh
$cmake -DGeant4_DIR=/usr/local/lib/Geant4-9.6.2 $G4INSTALL/examples/basic/B1
$make
$./exampleB1

Build another example which requires a slight different targeting:
$cd ..
$mkdir rdecay01-build
$cd rdecay01-build
$cmake -DGeant4_DIR=/usr/local/lib/Geant4-9.6.2 $G4INSTALL/examples/extended/radioactivedecay/rdecay01

That's it.

#This installation was performed after an unsuccessful installation of a macports distribution of geant4.9.4 by

$sudo port -v install geant4 +aida +gdml +raytracerx

Precisely speaking, the installation process was successful. However, when I try to build an example, clang called in Darwin-g++.gmk couldn't find files such as libgcov.a in my OS X 10.8 system to generate a library. I therefore uninstalled the macports distributed geant4.9.4.p02 from my system.

8/13/2013

Makefile for my c++ lib with ROOT

For later reference, I put my Makefile in the following.


#===========================================================
#
##        The Standard Makefile
#
#(Usage)
# make U=<program_name>;  for compiling a single program
#              <program_name> = bar for bar.cpp
# make ; for compiling all (listed below all:)
#
#(Default Library) ROOT
#
#(History)
# 130813 updated
#===========================================================
main:
make library
make compile PROGRAM=$(U)

all:
make compile_all PROGRAM=testReadAData
make compile_all PROGRAM=testA2RT
make compile_all PROGRAM=testReadTTree
make compile_all PROGRAM=testSetDoPrm

WRKDIR = tmp
ULIBOBJS    = ReadAData-v03.2.o \
              A2RT-v03.5.o \
              ReadTTree-v03.3.o \
              SetDoPrm-v01.8.o

LIBRARY_NAME     = mycpplib
LIBRARY          = lib${LIBRARY_NAME}.a

ULIBDIR = /My/cpplib/is/here

#====================================================
### INCLUDES ###
include /opt/local/etc/root/Makefile.arch
INCLUDE = -I/opt/local/include
#------ include user headers
ULIBINC = -I$(ULIBDIR)/include -Iinclude -I.
INCLUDE := $(INCLUDE) $(ULIBINC)

### LIBS ###
LIBS := -L./ -l${LIBRARY_NAME} $(ROOTGLIBS) -L/opt/local/lib -lgsl

UOBJS    = <list your objects to be linked>
UOBJS    =

LANGSFX=cpp
COMPILER = g++
LINKER = g++

COMPOPT = $(ROOTCFLAGS)
LINKOPT =
GOPTION = -DDEBUG
#====================================================
SRC         = $(PROGRAM).$(LANGSFX)
OBJ         = $(PROGRAM).o

TARGET    = $(PROGRAM)_cxx

LDFLAGS    = $(LIBS)

COMPOPT := $(COMPOPT) $(GOPTION)
LINKOPT := $(LINKOPT) $(GOPTION)

LIBSRCS = $(addprefix $(WRKDIR)/,$(ULIBOBJS))

ULIBSRC = $(ULIBDIR)/src
UOBJDIR = $(WRKDIR)
UOBJS := $(addprefix $(UOBJDIR)/,$(UOBJS))
#----------------------------------------------------
library:
@if [ ! -d $(WRKDIR) ]; then mkdir $(WRKDIR); \
echo "## --> tmp/ created...";fi
rm -f ${LIBRARY}
rm -f ${LIBSRCS}
make ${LIBRARY}

${LIBRARY}: ${LIBSRCS}
ar cru $@ ${LIBSRCS}
ranlib $@

compile:
@if [ -f $(SRC) ]; \
then make $(TARGET); \
rm $(OBJ); \
else make all; fi

compile_all:
rm -f $(TARGET)
make $(TARGET)
rm $(OBJ)
#----------------------------------------------------

.SUFFIXES: .exe .f .c .o .a .cpp .cxx .cc

#=================================================  
$(TARGET):  $(OBJ) $(UOBJS)
$(LINKER) $(LINKOPT) $(OBJ) $(UOBJS) -o $@ $(LDFLAGS)

$(ROOTLINKSRC)Dist.cpp: $(ROOTGUIHDRS).h $(ROOTLINKSRC)LinkDef.h
rootcint -f $(WRKDIR)/$(ROOTLINKSRC)Dist.cpp -c $(INCLUDE) $(ROOTGUIHDRS).h $(ROOTLINKSRC)LinkDef.h

#The following line must be the first one
$(UOBJDIR)/%.o :  $(UOBJDIR)/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@

$(UOBJDIR)/%.o :  $(ULIBSRC)/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@

$(UOBJDIR)/%.o :  src/%.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@

$(UOBJDIR)/%.o :  %.cpp
$(COMPILER) -c $(COMPOPT) $< $(INCLUDE) -o $@

.f.o:
$(FCOMPILE) -c $(FCMPOPT) $(FINCLUDE) $<

.c.o:
$(CCOMPILE) -c $(CCMPOPT) $(CINCLUDE) $<

My c++ library with ROOT: test run

 A Makefile to compile my c++ library with ROOT is adjusted for the new environment. A flag -m32 is removed, an include path for Makefile.arch is changed for the new ROOT set (which I needed to look for in /opt/local/etc,) a link path for gsl is explicitly added. (Specifying  LD_LIBRARY_PATH in ~/.bashrc did not work. My make processes seem not referring to this env. variable.)
 All sample programs included in my library were complied with ROOT and run without any problem. I was expecting some mysterious problems occur to bother me. But no mysterious thing happen. It's I call a miracle!

8/12/2013

Preparing for numerical works

After moved from the old 32-bit mode mac, the first thing to do is to recompile sources of my private c++ library with gcc without -m32 flag. This step is going well and will be finished in 3 hours.

ROOT 5.34.09 installation

I install ROOT on my new MacBookPro via MacPorts (MacPorts Guide).

$ sudo port -v selfupdate
$ port info root
$ gcc --version
   4.2.1
$ python --version
  2.7.2

$sudo port -v install root +graphviz +gsl +minuit2 +opengl +python27 +roofit +soversion +ssl +tmva +xml
...
/usr/bin/clang++ -02 -m64 ...
...


Installation process finished.

disk space occupied = 3.87 GB
$ root
ROOT 5.34/09 (v5-34-09@v5-34-09, Jun 26 2013, 17:10:36 on macosx64)


$ port installed
The following ports are currently installed:
  bzip2 @1.0.6_0 (active)
  cairo @1.12.14_0+opengl+x11 (active)
  db46 @4.6.21_8 (active)
  db_select @0.1_2 (active)
  expat @2.1.0_0 (active)
  fontconfig @2.10.93_0 (active)
  freetype @2.5.0_1 (active)
  gd2 @2.0.35_14 (active)
  gdbm @1.10_2 (active)
  gettext @0.18.3_0 (active)
  giflib @4.2.1_0+x11 (active)
  glib2 @2.36.4_0 (active)
  gmp @5.0.5_0 (active)
  gobject-introspection @1.36.0_1 (active)
  graphite2 @1.2.3_0 (active)
  graphviz @2.32.0_0+pangocairo+x11 (active)
  gsl @1.15_2 (active)
  gts @0.7.6_2 (active)
  harfbuzz @0.9.19_0 (active)
  jasper @1.900.1_10 (active)
  jbigkit @2.0_2 (active)
  jpeg @9_1 (active)
 libedit @20121213-3.0_0 (active)
  libffi @3.0.13_0 (active)
  libiconv @1.14_0 (active)
  libLASi @1.1.1_0 (active)
  libpixman @0.30.2_0 (active)
  libpng @1.5.17_0 (active)
  libtool @2.4.2_3 (active)
  libxml2 @2.9.1_0 (active)
  lzo2 @2.06_0 (active)
  mesa @8.0.4_2+python27 (active)
  ncurses @5.9_2 (active)
  netpbm @10.62.02_0 (active)
  nkf @2.1.3_2 (active)
  openssl @1.0.1e_1 (active)
  pango @1.34.1_1+x11 (active)
  pcre @8.33_0 (active)
  perl5 @5.12.4_0+perl5_12 (active)
  perl5.12 @5.12.4_2 (active)
  pkgconfig @0.28_0 (active)
  python27 @2.7.5_1 (active)
  python_select @0.3_2 (active)
  root @5.34.09_1+graphviz+gsl+minuit2+opengl+python27+roofit+soversion+ssl+tmva+xml (active)
  sqlite3 @3.7.17_0 (active)
  tiff @4.0.3_1 (active)
  urw-fonts @1.0.7pre44_0 (active)
  webp @0.3.1_0 (active)
  Xft2 @2.3.1_0 (active)
  xorg-dri2proto @2.8_0 (active)
  xorg-fixesproto @5.0_0 (active)
 xorg-glproto @1.4.16_0 (active)
  xorg-inputproto @2.3_0 (active)
  xorg-kbproto @1.0.6_0 (active)
  xorg-libice @1.0.8_0 (active)
  xorg-libpthread-stubs @0.3_0 (active)
  xorg-libsm @1.2.1_0 (active)
  xorg-libX11 @1.6.1_0 (active)
  xorg-libXau @1.0.8_0 (active)
  xorg-libXaw @1.0.11_0 (active)
  xorg-libxcb @1.9.1_0+python27 (active)
  xorg-libXdmcp @1.1.1_0 (active)
  xorg-libXext @1.3.2_0 (active)
  xorg-libXfixes @5.0.1_0 (active)
  xorg-libXi @1.7.2_0 (active)
  xorg-libXmu @1.1.1_0 (active)
  xorg-libXt @1.1.4_0 (active)
  xorg-renderproto @0.11.1_0 (active)
  xorg-xcb-proto @1.8_0+python27 (active)
  xorg-xcb-util @0.3.9_0 (active)
  xorg-xextproto @7.2.1_0 (active)
  xorg-xproto @7.0.24_0 (active)
  xpm @3.5.10_0 (active)
  xrender @0.9.8_0 (active)
  xz @5.0.5_0 (active)
  zlib @1.2.8_0 (active)

5/28/2013

A business trip to Spain

I came back from a business trip to Barcelona a few days ago. I spent a week there most of the time eating sandwiches (Bocadillo) with Spanish cured ham (Jamón Serrano), visiting Antoni Gaudi's constructions including Sagrada Familia, Park Güell and Casa Milá. Sounds like a sight seeing tour? Actually, I had meetings every day for a few hours but I had had worked out most of materials in Japan and I needed to just keep thinking in the remaining time. Eating and seeing stimulates thinking and they often bring better results than just being "serious" like most of my country men. (Women are more liberated.) Walking around these places,  I saw surprisingly few Japanese tourists in this time. In practice, more than 90 % of asian tourists I had met were Chinese or Koreans. Rapidly weekend Yen against Euro may be an immediate reason. As a background, there is a long term shrinkage of Japanese economics and a tendency of young people who are reluctant to going out of the country. I had been thinking the later background was a result of the former. However, I am shocked by my own impressions that, surrounded by and chatting with non-Japanese asians, we are not welcomed to be among them. I had never gotten this feeling before around 5 years ago.

5/09/2013

My MacBookPro arrived

But I am too much involved in a pile of jobs and I'll not open the box until I finish them.

4/13/2013

Waking up with an alert just before a big earthquake

Early this morning, at around 5:30, I woke up with unfamiliar sound of alert. A few seconds later, everything started to shake with big noise. It was a M6.0 earthquake hit Awaji Island near Kobe. I got a phone call then from my working place for a request for an immediate checking of a machine there. I changed my clothes, washed my face in a few minutes and drove to the working place. After spending a busy quater day there checking and restarting for the normal operation, I found myself wondering about one thing: What was that sound of alert? TV was off and we have no radio in our house and all computers were shut off. Finally I found it was my iPhone5 which received a signal from J-alert system and made that sound of alert. This was very impressive incident.

4/10/2013

Plan for a new MacBookPro: Writing specification

When we have a plan to purchase something, our administrators require us to write a specification to open for a bidding. I can not, however, just write "I want a MacBook Pro quad-core Intel Core i7, 2.8 GHz model." They don't accept names of commercial products and I can not use words like "Mac" nor "Intel". They accept only descriptions of characteristics which I need for my purpose. So, only "quad-core" and "2.8 GHz" are accepted in the sentence above. This is something like

namespace admin{

class Specification{

     public:
        Specification & cpu_arch(std::string const& arg);
        Specification & cpu_speed(double const& arg);
        Specification & memory_size(double const& arg);
        Specification & memory_speed(double const& arg);
        Specification & storage_size(double const& arg);
       ........
};

} // admin namespace

to use it as

using namespace admin;

Specification I_want_a_MacBookPro(
          Specification.cpu_arch(X86-64)
                            .cpu_speed(2.8)
                            .memory_size(16)
                            .memory_speed(1.6)
                            .storage_size(512));


ROOT5.22 doesn't have TFitResult

I was to include root/include/TFitResultPtr.h in my c/c++ fitting routine. But I was told "No such file..." I found this class was not included in the root version 5.22, which I got from fink! (Yes, I'm getting old.) I have 3 choces:
(1) to upgrade 5.22 in my current MacBookPro,
(2) to install a brand new 5.34, or
(3) to find another way in 5.22 without TFitResultPtr.
My estimate for required elapse time for each case is as follows.
(1) a week, (2) 3 days, (3) 1 day
I take (3).
....Result
I was right. It took a few 10 minuits to find the information I needed was
available through TF1 object used in the fit for TGraph.

lesson:
If you don't find an object in your old root, find another way to obtain the information you need. It can not be happen that there is no way in 5.22.


4/09/2013

Plan for a new MacBookPro: Budget

I want the swiftest system with large enough memory and disk space. Therefore, it is straightforward for me to choose the high end model: 2.7 GHz quad Intel i7 with 16GB, 1.6 GHz memory and 512GB flash storage. I'm going to use it in the clamshell mode connecting to my old display and my lovely HappyHack keyboard. This means I don't need an excellent 15" Retina display. But it comes with anyway. OK, I'll take it. Cost = J¥245,800.

 I take an upgrade of the quad i7 to 2.8 GHz. Cost+= J¥22,800.

I don't take an option to increase the capacity of the flash storage. 512 GB is enough.

I need a Mini DisplayPort-VGA to connect to my display. Cost+=J¥2,800

I should have a Time Capsule. 2TB is enough, I think. Cost+=J¥26,400

Cost: J¥297,800 (Apple Store)

(Why I want a brand new MacBookPro?)
My current MacBookPro: Intel Core 2 Duo 2.8 GHz with 4GB memory. OS X 10.6.8. Used to be good enough for my purpose. I am just beginning to feel the limit of capacity when I run my 10K line c/c++ routine including root and geant4 libraries. More important is that I have installed these libraries in 32 bit mode. Why? Because CLHEP2 used in geant4 was only available for 32 bit. The real limitation with my MacBookPro is not of the hardware one. Some libraries like xmlrpc, when I use it to communicate with my computing environments, dosen't allow me to use 32 bit mode compiled with gcc -m32. So, I apparently need 64 bit environment somewhere at my hand. In principle, I can install 64 bit versions separately on my current Mac. But I don't want to get a mess like ones I have experienced in the past. I want to leave all 32 bit libraries working on the current MacBookPro and want a new 64 bit platform.

How did a japanese guy purchase a rice cooker on internet?

0. I made my wife a little nervous and she broke a rice cooker in our home.
1. I started to search for a new one, I mean a rice cooker, of course, on internet referring to prices and people's votes. Then chose the Zojirushi NP-RH05-TC, which has the volume of 3 rice cups (3*180 ml), just adequate for a couple of people.
2. I surveyed the cheapest offer (includeing tax and sending cost) among shops in kakaku.com and rakuten shopping mall, most popular internet shops in Japan. I chose D-Price.
3. I looked for so called point sites where one may purchase goods from registered shops and earn points (typically 1 to 5 % of purchasing prices). I didn't find the shop chosen in any of them.
4. Then I went to the shop directly and ordered the rice cooker. They will send me a mail of confirming my order tomorrow.
5. Finally I've reported all these steps to my wife. I don't know why she was getting nervous again?





4/08/2013

Specifying a file path at runtime

1. In c/c++ source code, specify the file with an environment variable:

std::string fileName = getenv("package_SRCDIR");
fileName = fileName+"<file.name>";
doSomething(fileName.c_str());

2. Ask bash users to prepare a run.sh which reads

export package_SRCDIR=/users/share/package_dir
$package_SRCDIR/source_cxx

where source_cxx is an executable of the source code.

Environment: Mac OS X 10.6, bash