Thursday, February 26, 2009

A C++ debug class

I finally got tired of commenting/uncommenting "cerr" and "cout" statements, and started to think about a simple debug helper class a few days ago. With this class, I need to archive:
1. An overall switch be should able to control the verbose level. This can be done through static class methods.
2. Can easily switch output from stderr to stdout, or a file. This can also be done with a static method.
3. The class should be able to track the execution of the code automatically, i.e. report when entering and exiting a function.
4. It should have an easy way of printing any variables in the code.
5. It can be easily plugged in existing code.
6. It has minimum impact on the performance of the code.

With these in mind, I come up with this Debug class:
1. The verbose level is from 0 (no debug output) to 5 (very verbose), with 1 being a special "trace only" level. In level 1, the class only report when entering and exiting a function.
2. To use it, one define a Debug object at the very beginning of a function. The constructor handles the "entering" trace, and the destructor handles the "exiting" trace.
3. The class provides many overloaded () operator to report any state variables. These methods return a reference to the debug object so that multiple debug entries can be stacked together:
  int test_func(){
Debug dbg("test_func");
...
dbg(2,a)(3,b)(5,c,d,e);
...
}
4. In addition to an overall verbose control, each individual object has an optional verbose level control as the second argument of the constructor.
5. The operator() methods, as well as the constructor and destructor, should be implemented as inline to improve performance.

Here is the interface of the class:
  class Debug{

public:

Debug(const string & trace_key, int verbose = -1);
~Debug();

// types with defined ostream<< operator
template <typename T>
Debug & operator()(int verbose, const T&);
template <typename T1, typename T2>
Debug & operator()(int verbose, const T1&, const T2&);
template <typename T1, typename T2, typename T3>
Debug & operator()(int verbose, const T1&, const T2&, const T3&);
template <typename T1, typename T2, typename T3, typename T4>
Debug & operator()(int verbose, const T1&, const T2&, const T3&, const T4&);
template <typename T1, typename T2, typename T3, typename T4, typename T5>
Debug & operator()(int verbose, const T1&, const T2&, const T3&, const T4&, const T5&);
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
Debug & operator()(int verbose, const T1&, const T2&, const T3&, const T4&, const T5&, const T6&);

// static methods to set the overall debug specs
static void set_verbose(int); // verbose level, default 0, no debug info will be printed
static void set_nesting_max(int); // maximum nesting level. default 8. no indent if set to 0
static void set_output(const string & filename, bool append=false); // output file
static void set_output(ostream &); // output stream, default clog

private:
...

};

Monday, January 12, 2009

Add a non-graphical login option in Ubuntu

By default, Ubuntu would bring you directly to a graphical login window (gdm). Sometimes I just want to do some quick work and don't want to waste the extra 20 seconds to bring up Xfce/Gnome/Kde, here is how.

Before doing anything, we need to prepare ourselves with the boot process in Ubuntu. For this regard, here is a very helpful article by Aaron Toponce. In summary, Ubuntu will first boot into the S runlevel to excute some critical initializing scripts, then it will switch to runlevel 2. As most other linux distributions, Ubuntu does have 4 multi-user runlevels (2-5), but it only uses 2. Our goal is to revise runlevel 3 to boot to a non-graphical login window, and add an option in grub to start the process.

Step 1. Prepare runlevel 3.
For this non-graphical runlevel, we don't want any thing related to X windows brought up upon boot. Thus, we remove the gdm service script in /etc/rc3.d:
  sudo mv /etc/rc3.d/S30gdm /etc/rc3.d/s30gdm
Next, Ubuntu has x11-common brought up in the S runlevel, we don't want that in our non-graphical login, so move it to runlevel 2:
  sudo mv /etc/rcS.d/S99x11-common /etc/rc2.d/S01x11-common

Step 2. Add a menu item in grub.
The normal way to boot to a desired runlevel is to add a kernel option with a single digits or the letter "S". This is simple in Ubuntu. Open /boot/grub/menu.lst and add this following line:
  #altoptions=(non-graphical) quiet 3
and update grub menu:
  sudo update-grub

Step 3. Tell Ubuntu to go into that runlevel
You don't need this step is you are using a different distribution other than Ubuntu, since the kernel option is automatically recorgnized. In Ubuntu, however, the system use the script /etc/init.d/rc-default to determine next runlevel after the S runlevel. The one shipped with Ubuntu will only boot to runlevel 2 and single user mode. We need to modify this file so that it will accept the kernel runlevel parameter. Just add these lines in /etc/init.d/rc-default before the part testing for "single" in the command line:
  # Before testing for single user runlevel in the kernel parameter list, add these lines:
RL=`sed -n -e "s/.*[ \t]\([S0-6]\)[ \t].*/\1/p" -e "s/.*[ \t]\([S0-6]\)$/\1/p" /proc/cmdline`
if [ 'x'$RL != 'x' ]; then
telinit $RL;
elif ... (following the original script here to test "single" in the cmdline)
And that's it. Now when you power up your computer and there will be a grub menu item to boot your system to non-graphical mode.

Wednesday, January 7, 2009

eee 901, end of story

I ordered a Asus Eee 901 about a month ago after some research on the tiny netbooks. It was a windows edition because the linux version was not on sale. The netbook arrived a week later, and the first glance was impressive -- it's really small, especially because I'm used to my 14 inch T61. The keyboard is quite undersized, but not as bad as many online reviews claim.

Putting Xubuntu on it is an easy task, and I was all happy the next day before first the screen and then the whole thing died completely. That's a little more than 24 hours after I put my hands on it. I thought that it was pure bad luck -- I haven't seen any complaints about the build quality of the Eee PCs. So I contacted TigerDirect.com, where I ordered the computer from, and they were quite willingful to send me another one for exchange. They also provided a return shipping label. It's another two weeks before I receive the replacement due to backordering, but I did get it before the New Year.

This time, it didn't take me 24 hours to find out what's defective: the battery cannot be charged beyond 51%. A quick online search leads to a few similar cases and a few solutions, but none works for the unit I have. So I decide to drain out the battery to see what would happen. Yes, miracle happens, when the battery indicator drops to 0%, the computer is still alive, and stay alive for another 3 hours! This saying, the battery is actually good, but it gives wrongful information to the system. Now I start to recharge the battery, the battery capacity indicator increase from 0% instantly rather than wait until it's half charged. That's a good sign, and indeed, this time the indicator does show 100% charge, but -- why there is always a but -- charging does not stop there. The charging light on the front of the computer keeps blinking in red for a whole night, and there is actually a small charging current of about 20 mA (the normal current is between 1000mA and 2000 mA).

This is not good! Two defective products in a row cannot be explained by my bad luck. So I send it back and decide to wait until the weight of Thinkpad X2** drops to bellow 2.5 lbs.

Saturday, January 3, 2009

Speed up ubuntu, Part I -- Boot up

I've done some tweaks on my T61 to make xubuntu startup and run faster. These tricks are mostly collected from different forums/blogs.

Part I. Boot Up

One easy way to measure boot time is to install bootchart:
  sudo apt-get install bootchart
Once installed, a png image will be generated at /var/log/bootchart every time the system reboots, showing the starting up processes and how long they each take. You probably don't want it after you have done tweaks with the start-up process.

I.1 Clean installed packages (http://www.linuxine.com/2008/06/speed-up-ubuntu-boot-speed.html )

Delete residual config packages: in Synaptic package manager, check status and remove all residual config packages.
Delete incomplete packages:
  sudo apt-get autoclean
Delete isolated libraries:
  sudo apt-get install deborphan
sudo deborphan | xargs sudo apt-get -y purge
sudo apt-get autoremove --purge
This is more like a help on the overall performance than booting only. But it will clean out some broken packages that might be loaded during booting.

I.2 Disable unnecessary services (http://ubuntuforums.org/showthread.php?t=89491)

IMPORTANT! Since we're going to mess up with some critical system files, I would back them up:
  mkdir ~/sysbak
cp -rPp /etc/rc?.d ~/sysbak
The -P option in cp tells it to copy symbolic links rather than files they point to, the -p option tells it to preserve all file properties.

A quick introduction on the symbolic links in the rc*.d directory. Each rc*.d directory corresponds to a runlevel (S, 0-6). S/1 are the single user runlevel, 0 is shutdown, 6 is reboot, 2-5 are multiuser runlevels. In ubuntu, runlevels 2-5 are the same by default. In each rc*.d directory, there are two type of symbolics: those begin with "K??" and those with "S??". Upon entering each runlevels, the system will kill all services beginning with "K??", then start those beginning with "S??", in order of the two digits "??". In the default boot process, after the kernel is loaded, the system enters runlevel S, then 2 and stay in 2. To enable/disable a service at a certain runlevel, simply add/remove a S?? symbolic link to the service script in /etc/init.d. To learn more about Ubuntu boot process and runlevels, see this two-part article by Aaron Toponce.

Here is a list of services available by default on my T61 laptop:

must enable, critical,
should enable,
may disable.

letter and numbers in parenthesis shows ubuntu default runlevels.

NetworkManager (S): Automate switching between different network connections.
acpi-support, acpid (2,3,4,5): power management
alsa-utils (2,3,4,5): sound
anacron (2,3,4,5): excute delayed cron jobs
apparmor (S): application security, I don't need it on my laptop
apport (2,3,4,5): Automatic crash report. Safe to turn off.
atd (2,3,4,5): excute commands assigned by at.
aumix (2,3,4,5): Turn off if you are using alsa-utils.
avahi-daemon (2,3,4,5): MS/Apple Zeroconf implementation.
binfmt-support (2,3,4,5): Support non-native binary format. If you run Windows program through wine, you'll need it.
bluetooth (2,3,4,5): Bluetooth support, turn off if you don't connect to a BT device regularly.
bootlogd (S), stop-bootlogd (2,3,4,5): Record boot messages, but currently it's broken in Ubuntu.
cron (2,3,4,5):
cups (2,3,4,5): turn off if you don't connect to a printer regularly.
dbus (2,3,4,5): Message bus system.
dkms_autoinstaller (2,3,4,5): Kernal module auto generator and installer.
dns-clean (S): Mainly for cleaning up the dns info when using dial-up connection
gdm (2,3,4,5): Gnome desktop manager
hal (2,3,4,5):
halt (0):
hotkey-setup (2,3,4,5): Setup some hotkeys for HP, Acer, ASUS, Sony, Dell, and IBM laptops.
killprocs (1):
klogd (2,3,4,5): Kernel logging
laptop-mode (2,3,4,5): laptop battary managing. not needed for desktops
linux-restricted-modules-common (0,6,S): needed if restricted modules are used, e.g., nVidia driver.
loopback (S): providing loopback device.
module-init-tool (S): load extra modules in /etc/modules.
networking (0,6,S):
pcmciautils (S): pcmcia card support. I don't have any pcmcia devices.
policykit (2,3,4,5):
defining and handling the policy that allows unprivileged processes to speak to privileged processes
powernowd, powernowd-early (2,3,4,5): manage CPU frequency
pppd-dns (2,3,4,5): dial-up service
procps (S): provide infomation about /proc
rc.local (2,3,4,5)
readahead (S), readahead-desktop (S), stop-readahead (2,3,4,5): Speed up booting by read all needed files into the memory. Use this with kernel profiling reduce the startup time on my T61 from 27 seconds to 20 seconds.
reboot (6)
rmnologin (2,3,4,5): remove nologin
rsync (2,3,4,5): Rsync service
screen-clean (S):
sendsigs (0,6): send signals during reboot or shutdown
single (1): single user mode
sysklogd (2,3,4,5): kernel logging
system-tools (2,3,4,5)
udev, udev-finish (S): udev service
ufw (S): uncomplicated firewall, you may want a firewall to protect you computer, but I don't.
umountfs (0,6)
umountroot (0,6)
urandom (0,6,S): random number generator
usplash (S): splash screen during booting
vbesave (2,3,4,5): Video card BIOS configration
wpa-ifupdown (0,6): secured wireless connection
x11-common (S): start xserver, I changed it to runlevel 2 since I sometimes want to boot to non-graphical terminal windows.
xserver-xorg-input-wacom (2,3,4,5): Wacom tablet input device support, I don't have one.

Now we are going to remove/add symbolic links in the /etc/rc*.d directories. If you haven' t backed up the original links yet, DO IT NOW.

Generally, you don't want to mess up with anything in runlevels 0, 1, and 6. But I would remove the K scripts in 0 and 6 which are not started in any other runlevels. Runlevels 0 and 6 are identical except the last script excuted: halt in 0, but reboot in 6.

Here are what these directories look like in my T61 after all the modifications:
$ ls /etc/rcS.d
README
S01mountkernfs.sh
S01readahead
S02hostname.sh
S06keyboard-setup
S07linux-restricted-modules-common
S08hwclockfirst.sh
S08loopback
S10udev
S11hwclock.sh
S11mountdevsubfs.sh
S13pcmciautils
S15module-init-tools
S17procps
S20checkroot.sh
S22mtab.sh
S30checkfs.sh
S35mountall.sh
S36mountall-bootclean.sh
S37mountoverflowtmp
S37udev-finish
S39readahead-desktop
S40networking
S45mountnfs.sh
S46mountnfs-bootclean.sh
S49console-setup
S55bootmisc.sh
S55urandom
S70screen-cleanup
S90console-screen.kbd.sh
$ ls /etc/rc0.d
K01gdm
K20apport
K25hwclock.sh
K50alsa-utils
K63mountoverflowtmp
K74dkms_autoinstaller
K86avahi-daemon
K99laptop-mode
README
S01linux-restricted-modules-common
S15wpa-ifupdown
S20sendsigs
S30urandom
S31umountnfs.sh
S35networking
S40umountfs
S60umountroot
S90halt
$ ls /etc/rc2.d
README
S01policykit
S01x11-common
S05vbesave
S10acpid
S10powernowd.early
S10sysklogd
S11klogd
S12dbus
S14avahi-daemon
S20apport
S20dkms_autoinstaller
S20hotkey-setup
S20powernowd
S20rsync
S24hal
S28NetworkManager
S30gdm
S30system-tools-backends
S50alsa-utils
S89anacron
S89cron
S99acpi-support
S99laptop-mode
S99rc.local
S99rmnologin
S99stop-bootchart
S99stop-readahead
hat's it for now. I will cover how to take advantage of runlevels 3-5 in a separate topic.

I.3 Profile the boot up process.

This will work only if you enable readahead service in previous section. The kernel parameter "profile" tells it to record all disk access during the booting process, then readahead can load all the files at once to save from random access of harddrive. This might not help much for SSD since SSDs have the advantage of fast random access.

The kernal parameter can be added in your /boot/grub/menu.lst, but since we only need it once, it's better to add it in the grub boot menu. At the boot menu, press "e" will allow you to change booting parameters. Highlight the kernel line, press "e" again, and append "profile" at the end of the line. Hit "b" to reboot, and wait for the computer to start. It will be slow, probably 5 times slower than an normal boot, but remember that we only need to do this once.

I.3 Concurrent booting (http://www.my10sen.com/2007/10/05/ubuntu-a-speedup-guide/)

Concurrent booting allows Ubuntu to take full advantage of dual-core processors, as well as processors that hyperthread or multithread. These settings are located in your /etc/init.d/rc file.

Change
  CONCURRENCY=none
to
  CONCURRENCY=shell
To be frankly, this change does not help me much although I have Intel Core Duo processers.

I.4 Remove extra virtual terminals (http://paulsdigitalworld.blogspot.com/2008/01/complete-ubuntu-speed-up-tweak-guide.html)
  cd /etc/event.d
sudo mv tty3 tty3.bak
sudo mv tty4 tty4.bak
sudo mv tty5 tty5.bak
sudo mv tty6 tty6.bak

I.5 Reduce forced disk check

By defaults, ext2/ext3 partitions are forced to do disk check about every 30 mounts, or every 6 months. I typically turn off my laptop every day, so the 30 mounts cap reaches rather often. Since laptop's harddrives are subject to more potential damage than desktop's or server's, I prefer to have it checked every 3 months or 100 mounts. This can be done with tune2fs:
  sudo tune2fs -c 101 -i 3m /dev/sda1
The -c option is the mount count cap, and -i option is for time interval. Do this for all ext2/ext3 partitions. Be sure not to use the same numbers for all partitions. Otherwise your boot time might prolong to an hour if all partition checks are synchronized.

Thursday, December 11, 2008

A few helpful emacs tweaks

I find them randomly on the web, or in the Emacs manual. Add these line in the .emacs file in your home directory, you'll get the desired feature.
  ;; turn off scroll bar
(toggle-scroll-bar 0)

;; don't show toolbar
(tool-bar-mode 0)

;; disable menu bar
(menu-bar-mode 0)

;; do not display a splash screen on startup
;; only needed for emacs 22+
(setq inhibit-splash-screen t)

;; disable side fringe
;; this only works for emacs 22+
(set-fringe-mode 0)

;; toggle full screen
(defun switch-full-screen ()
(interactive)
(shell-command "wmctrl -r :ACTIVE: -btoggle,fullscreen"))
(global-set-key [f11] 'switch-full-screen)
The last full screen function using the wmctrl utility:
  sudo apt-get install wmctrl
You can also use Emacs' own frame control to go full screen:
  (defun fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(global-set-key [f11] 'fullscreen)
But the window will be maximized after toggling back.
  ;; define the compile command to be make filename.o, and bind to C-x c
(setq compile-command '(concat "make "
(file-name-sans-extension (file-name-nondirectory buffer-file-name))
".o"))
(global-set-key "\C-xc" 'compile)

By the way, my new Eee 901 died today, after 30 hours being in my hands. Bad luck or bad quality? Luckily TigerDirect allow me to send it back and replace it. We will see how the next one doing.

Wednesday, December 10, 2008

Install xubuntu 8.10 on eee 901

Got my WindowXP eee901 today. Actually, it arrived in a *pink* box.

First impression: It's really small, especially when viewing it side by side with my T61. The keyboard is indeed small, and some keys are in unconventional places. But the feeling of key strokes is not bad. The screen is matte rather than glassy finishing, which I really like. Unfortunately, the outside of the screen panel is polished, which I don't really like.

Now the important thing: take off the Windows XP sticker and put the xubuntu 8.10 on it. There are quite a few tutorials online on this, just name a couple:

http://thanhsiang.org/faqing/node/116
http://tombuntu.com/index.php/2008/11/17/installing-ubuntu-810-on-the-eee-pc-901/

A side notes. When I tried to make the first flash drive live disk a few days back, I ended up with a stick which didn't boot. The complaint is "No operating system found". I came across a post in some forum (I tried hard to locate it today, but not able to) saying about the same problem, and the fix is to use the testdisk utility to fix disk errors (MBR, partition table etc). So I installed the utility:
  sudo apt-get install testdisk
and it did the job. Now I have a bootable xubuntu stick made with the usb-creator program come with ubuntu 8.10, and ready to purge the XP.

Step 1: Install xubuntu 8.10 on the eee 901.

i) The flash drive is treated as hard drive rather than Removable drive in the eee's BIOS. So you should find it in the HDD boot device menu.

ii) The installer window is a little big bigger than eee's screen and buttons might be missing. Maximizing the window solves the problem.

iii) Disk partition. The eee 901 has a 4GB primary and a 8GB(windows) or 16GB(linux) secondary SSD. I formated the 4GB one to ext2 and used it for the root file system. The secondary SSD is also formated into a single partition and mounted at /home. This way, your home directory is untouched anytime you want to reinstall the system. I didn't make any swap partition since SSD is slow, and frequent reading/writing might do a lot of harm to the disk. The installer will complain about this, just ignore it.


After the installer has done its job, unplug the flash drive and boot into the new system. Wireless network does not work at this point, but the wired LAN works.

Step 2. Install the array.org kernel.

Follow their instructions to install either the stable eeepc kernel or the eeepc-lean kernel. Reboot, the wireless network and most other hardwares now work.

Step 3. Install eee-control, which will make life a little bit easier.

Step 4. Tombuntu provides a few helpful tweaks.

Step 5. Remove preinstalled useless packages, upgrade, and install wanted packages, -- the usual thing.

Bash one-liner: batch rename

Here is a bash recipe to rename files in batch. It can also be used to retag mp3 files according to their file names.
for a in *; do b=`echo $a|sed 's/.*\([0-9][0-9]*\).*\(\..*\)$/\1\2/' `; mv "$a" "$b"; done
In this example, all files are renamed to the first collection of numbers in its original names, while keeping the original postfix. E.g.,
blue4.mp3 -> 4.mp3
11help.dat -> 11.dat

Monday, December 8, 2008

Why Asus eee 901?

I ordered a black Asus eee 901 last week, and it should arrive in two days. Here I make some notes on how I decided on the Eee.

Reference reviews:
http://portablemonkey.com/article/asus-eee-pc-901-vs-acer-aspire-one-vs-dell-mini-9/
http://www.youtube.com/watch?v=0CuxV-jsrk8
http://blog.laptopmag.com/asus-eee-pc-901-mini-review
http://www.slashgear.com/asus-eee-pc-901-linux-edition-review-2412220/
http://www.brighthand.com/default.asp?newsID=14238
http://www.t3.com/news/netbook-spec-showdown-acer-aspire-one-asus-eee-pc-901-dell-inspiron-mini-9-hp-mini-note-msi-wind-and-lg-x110?=36605

I have tired of carrying my Thinkpad T61 to conferences after a few trips, and news comes that everyone is making 9" "netbook" now. I read about Asus' news release before their first Eee PC a year ago, but a 7" screen on a 9" frame discoraged me. Now the 9-inches comes out and it's time for me to jump in. In fact, I have quite a few to choose from: Asus Eee 901, Acer Aspire One, Dell Mini 8, HP 2133 MiniNote.

First thing first, what I'm looking for in a tiny computer?

i) able to run Linux. All four models have linux version, so this is not a problem.

ii) using SSD rather than magnetic HD to save weight (sorry, HP). HD capacity is not very import to me -- I'm not going to carry all the simulation data with me, and a few Gig for programming and document writting is enough. In this case, the added weight and vunerability is a big minus.

iii) size and weight. The wasted boarder on the screen panel does not make any sense to me, although this would allow a slightly bigger keyboard. In this regard, the HP is the worst, followed by the Acer.

iv) Battery life. The Eee comes with 6-cell battery, which might last 6-7 hours. The Aspire also has a 6-cell battery option, but only with the HDD version. Dell and HP come with 4-cell and 3-cell, which is not good although the Dell weighs less. However, 1.04kg and 1.1 kg do not really make a difference when sitting on your knees; the added 3 hours' more computing time is much more attractive.

v) Intel Atom processor preferred. Intel's latest processor consumes less power, yet it's performance comprimises little. Again, no HP.

vi) upgradable/expandable. 12-16 Gig of SSD is probably not enough, and 1GB of memory is definitely not.

vii) display resolution. For a 8.9" screen, 1024x600 is enough. The HP has a 1280x800 screen, but you will most like using a larger font to make it readable. It's a plus, but only by a little bit.

viii) I hate glassy coating on any computer screen. This pretty much rules out everyone except the Eee.

So now,
HP 2133 MiniNote: no SSD version, using non-Atom processor, large, short battery life;
Acer Aspire One: glassy finishing, large, short battery life;
This two are out of question, which leave me with
Dell Mini 8: glassy finishing, short battery life but light;
Asus Eee 901: heavy but much longer battery life;

First of all, why any one still want to buy from Dell? Besides, the 12GB version of Eee 901 was on sale at Tigerdirect.com at the time of my purchase ($350), and M$ live search gives 10% cashback. I would very like to get the 20GB linux version, but it's $150 more. I also ordered a 2GB kingston memory and a 8GB A-Data SDHC card from the Egg for the total of $30. These should meet my immediate need.

One of the biggest complaint about the Eee in most reviews is its undersized keyboard. Many people claim that they have to resolve to two-finger typing. Although my hands are not huge, they are not tiny either. We will see how it feels.

Useful links:
http://www.bit-tech.net/hardware/2008/06/17/inside-the-eeepc-901-investigating-atom/1

Mixed C++ and Fortran programming

This note is for compiling C++ and Fortran code. For general language issues concerning mixed programming, check out these references:
http://www.physiology.wisc.edu/comp/docs/notes/not017.html
http://www.math.utah.edu/software/c-with-fortran.html

All individual sources should be compiled into object files by using the "-c" compiler option. Here is how to link these ".o" files. I assume that the main program is in C and a few Fortran subroutines are called.

In gcc-4.0:

".o" from Fortran code is treated the same as those from C++ code. So just use the normal link command:
  g++ $(C_FLAGS) $(COBJS) $(FOBJS) $(LIBS) -o $(EXE)

In gcc-3.0:

Same as the 4.0 version, but the code must be linked against libg2c:
  g++ $(C_FLAGS) $(COBJS) $(FOBJS) $(LIBS) -lg2c -o $(EXE)

In icc:

Fortran compiler, rather than c++ compiler must be used. The option "-nofor_main" tells the compiler that there is no Fortran main subroutine; "-cxxlib" means to link to the C++ libraries.
  ifort -nofor_main -cxxlib $(COBJS) $(FOBJS) $(LIBS) -o $(EXE)
 
Creative Commons License All contents on this page are licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.