2017-04-29

package vcompare

可以看 Wiki 的解釋

Compares the two version numbers given by version1 and version2. Returns -1 if version1 is an earlier version than version2, 0 if they are equal, and 1 if version1 is later than version2.


實際上的用法可以看 tcllib 中 zipfile::decode module。

if {[package vcompare $tcl_patchLevel "8.6"] < 0} {
  # Only needed pre-8.6
  package require Trf                       ; # Wrapper to zlib
  package require zlibtcl                   ; # Zlib usage. No commands, access through Trf
  set ::zipfile::decode::native_zip_functs 0
} else {
  set ::zipfile::decode::native_zip_functs 1
}

也就是如果 >= 8.6,使用內建的 zlib,如果小於就使用 Trf 與 zlibtcl。

接下來我檢查了一下 zipfile::decode module,發現 zipfile::decode module 並沒有修改完全,::zipfile::decode::GetFile 中沒有使用 native_zip_functs 來選擇要使用的 command。下面是修正的 patch。

     deflate {
         go     $fd(fileloc)
         nbytes $fd(csize)
-        return [zip -mode decompress -nowrap 1 -- [getval]]
+        if {$::zipfile::decode::native_zip_functs} {
+          return [zlib inflate [getval]]
+        } else {
+          return [zip -mode decompress -nowrap 1 -- [getval]]
+        }
     }
     default {
         Error "Unable to handle file \"$src\" compressed with method \"$fd(cm)\"" \



我已經在 Tcl Library Source Repository 開了一個 Ticket 來記錄這件事。

2017-04-14

tclmpi v1.0

目前在 Ubuntu 14.04 上測試過。

Ubuntu 14.04 需要安裝 openmpi,指令如下:
sudo apt-get install openmpi-bin libopenmpi-dev


然後從 https://github.com/akohlmey/tclmpi 或者是 http://sites.google.com/site/akohlmey/software/tclmpi 下載 v1.0 source code。

接下來需要修改 Makefile,讓 tcl.h 可以被正確找到。
TCLINCLUDE=-I/usr/include/tcl

修改完 Makefile 以後,執行 make,然後在 /usr/lib 建立 tclmpi1.0 目錄,將 pkgIndex.tcl, tclmpi.tcl 與 _tclmpi.so 三個檔案複製到 /usr/lib/tclmpi1.0,這樣就完成安裝。

再來使用 examples 下的 hello.tcl 來測試,如果有正確輸出,就表示安裝正確。

package require tclmpi 1.0

# initialize TclMPI
::tclmpi::init

set comm tclmpi::comm_world
set size [::tclmpi::comm_size $comm]
set rank [::tclmpi::comm_rank $comm]

puts "hello world, this is rank $rank of $size"

# close out TclMPI
::tclmpi::finalize
exit 0

2017-04-09

TclTLS-rpm-spec

TclTLS-rpm-spec
TclTLS website


參考 openSUSE 網站上的 RPM spec 以後,做一些小修改造出 1.7.11 的 RPM  檔案。看起來是可以使用,但是只有小量的測試而已,我不知道會不會有什麼問題。

然後寫一個 build.tcl 來加速整個流程。