Thursday, December 12, 2013

Meng-compile Fortran

Salin file fortran dari Flashdisk (FD) ke Server.
Ternyata harus me-mount FD terlebih dahulu sebelum menyalin file dari FD ke Server

Cek nama device FD.
[root@master ~]# fdisk -l

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       60802   488386583+  ee  GPT

Disk /dev/mapper/vg_master-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_master-lv_swap: 4110 MB, 4110417920 bytes
255 heads, 63 sectors/track, 499 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_master-lv_home: 441.6 GB, 441572130816 bytes
255 heads, 63 sectors/track, 53684 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdc: 8242 MB, 8242855936 bytes
35 heads, 56 sectors/track, 8213 cylinders
Units = cylinders of 1960 * 512 = 1003520 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7bafb7fc

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        8214     8049008    b  W95 FAT32

Ternyata nama device FD saya adalah /dev/sdc1.
Sebelum me-mount FD, buat folder terlebih dahulu.
[root@master ~]# mkdir /media/ictp

Mount FD (/dev/sdc1) ke folder tersebut (/media/ictp)
[root@master ~]# mount /dev/sdc1 /media/ictp

Coba cek isi FD
[root@master ~]# cd /media/ictp/
[root@master ictp]# ls
autorun.inf  day1  day2  day3  day4  day5  FOUND.000  hp pavillion  Misc  sw

Salin file fortran ke /root/Fortran_source, dimana folder /root/Fortran_source adalah folder baru
[root@master Fortran_source]# mkdir /root/Fortran_source

Salin file dari FD ke Server
[root@master Fortran_source]# cp *.* /root/Fortran_source/.

Cek hasil penyalinan :
[root@master Fortran_source]# ls /root/Fortran_source/
transport.f90           transport_parallel.f90~  transport_serial.f90~
transport_parallel.f90  transport_serial.f90

Un-mount FD jika sudah selesai.
[root@master Fortran_source]# umount /media/ictp/

Cek un-mount
[root@master Fortran_source]# ls /media/ictp
Isi file kosong, artinya FD sudah dapat dilepas dari server.

[root@master Fortran_source]# mount /dev/sdc1 /media/ictp
[root@master Fortran_source]# cp /media/ictp/day1/Fortran_source/Makefile .

[root@master Fortran_source]# ls
Makefile       transport_parallel.f90   transport_serial.f90
transport.f90  transport_parallel.f90~  transport_serial.f90~


[root@master Fortran_source]# make
gfortran -O3 -cpp -o transport_serial.x transport_serial.f90
make: gfortran: Command not found
make: *** [transport_serial.x] Error 127

Download paket Fortrannya dulu
[root@master ~]# wget http://ftp.g95.org/g95_source.tgz
--2013-12-11 16:21:08--  http://ftp.g95.org/g95_source.tgz
Resolving ftp.g95.org... 69.89.19.165
Connecting to ftp.g95.org|69.89.19.165|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1357116 (1.3M) [application/x-tar]
Saving to: “g95_source.tgz”

100%[======================================>] 1,357,116   56.7K/s   in 28s

2013-12-11 16:21:42 (47.8 KB/s) - “g95_source.tgz” saved [1357116/1357116]

Ekstrak file hasil download tsb
[root@master ~]# tar xzf g95_source.tgz
[root@master ~]# ls
anaconda-ks.cfg  g95-0.94        install.log
Fortran_source   g95_source.tgz  install.log.syslog


Masuk ke folder hasil ekstrak dan cek isinya
[root@master ~]# cd g95-0.94/
[root@master g95-0.94]# ls
aclocal.m4    depcomp          io.c                  scanner.c
arith.c       dump.c           iresolve.c            select.c
array.c       entry.c          kinds.c               show.c
AUTHORS       error.c          lang.opt              simplify.c
autogen.sh    expr.c           lang-options.c        specs.h
bbt.c         f95-lang.c       libf95.a-0.94.tar.gz  st.c
bigint.c      forall.c         Makefile.am           symbol.c
bigreal.c     format.c         Makefile.in           TODO
BUGS          g95-config.h.in  MANIFEST              trans-array.c
ChangeLog     g95.h            match.c               trans.c
check.c       G95Manual.pdf    matchexp.c            trans-common.c
compile       g95spec.c        misc.c                trans-const.c
config.guess  g95-support.h    missing               trans-decl.c
config.sub    ggc-page40.c     mkinstalldirs         trans-expr.c
configure     ggc-page41.c     module.c              trans.h
configure.in  imodule.c        NEWS                  trans-intrinsic.c
CONTRIB       INSTALL          parse.c               trans-io.c
convert.c     install-sh       primary.c             trans-stmt.c
COPYING       interface.c      README                trans-types.c
data.c        intrinsic.c      resolve.c
decl.c        intrinsic.h      scalarize.c

Lihat cara instalasi di salah satu filenya.
[root@master g95-0.94]# more INSTALL
How to install g95:

1) Unpack the downloaded tarball (e.g. g95-x86-linux.tgz) in a directory
of your choice:

   tar -zxvf g95-x86-linux.tgz

2) For your convenience, you can create another symbolic link from a
directory in your $PATH (e.g. ~/bin) to the executable

   ln -s $PWD/g95-install/bin/*g95* ~/bin/g95

You should now be able to run g95 and create executables.


To get a list of environment variables that control the library, run a
compiled binary with the --g95 option, ie:

  ./a.out --g95
ls
   Have Fun!


Coba download paket fortran yang lebih pas 
[root@master ~]# wget http://ftp.g95.org/g95-x86-linux.tgz
--2013-12-11 16:32:04--  http://ftp.g95.org/g95-x86-linux.tgz
Resolving ftp.g95.org... 69.89.19.165
Connecting to ftp.g95.org|69.89.19.165|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2914448 (2.8M) [application/x-tar]
Saving to: “g95-x86-linux.tgz”

100%[======================================>] 2,914,448   28.8K/s   in 85s

2013-12-11 16:33:37 (33.3 KB/s) - “g95-x86-linux.tgz” saved [2914448/2914448]

Ekstrak file hasil download
[root@master ~]# tar -zxvf g95-x86-linux.tgz
g95-install/
g95-install/INSTALL
g95-install/G95Manual.pdf
g95-install/bin/
g95-install/bin/i686-pc-linux-gnu-g95
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/f951
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/cc1
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/crtbegin.o
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/crtbeginS.o
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/crtbeginT.o
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/crtend.o
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/crtendS.o
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/libgcc.a
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/libgcc_eh.a
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/libgcc_s.so
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/libgcc_s.so.1
g95-install/lib/gcc-lib/i686-pc-linux-gnu/4.0.3/libf95.a

Ikutin apa kata yang ada dalam file INSTALL
[root@master ~]# ln -s $PWD/g95-install/bin/*g95* ~/bin/g95
ln: creating symbolic link `/root/bin/g95': No such file or directory

[root@master ~]# ln -s $PWD/g95-install/bin/*g95* /bin/g95

[root@master ~]# cd Fortran_source/
[root@master Fortran_source]# make
gfortran -O3 -cpp -o transport_serial.x transport_serial.f90
make: gfortran: Command not found
make: *** [transport_serial.x] Error 127

[root@master g95-install]# ls
bin  G95Manual.pdf  INSTALL  lib

[root@master g95-install]# cp bin/i686-pc-linux-gnu-g95 /usr/bin/
[root@master g95-install]# cp bin/i686-pc-linux-gnu-g95 /usr/bin/g95
[root@master g95-install]# g95
-bash: /bin/g95: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

[root@master Fortran_source]# g95 transport_serial.f90
-bash: /bin/g95: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory


http://answers.splunk.com/answers/89697/check-point-ospec-lea-app-bad-elf-interpreter-error

Please refer to the Application system requirements, it seems the following glibc & pam libraries are missing and will need to be installed first

glibc.i686 (32-bit version)
pam.i686 (32-bit version)

Install using: yum install glibc.i686; yum install pam.i686

DNS kayaknya gak jalan nih
[root@master ~]# ping www.batan.go.id
ping: unknown host www.batan.go.id

Ubah file /etc/resolv.conf
[root@master ~]# vi /etc/resolv.conf
; generated by /sbin/dhclient-script
nameserver 202.152.0.2
nameserver 202.152.5.36

Setelah diubah file resolv.conf (tanpa ada yang perlu di-restart), akhirnya DNS jalan lagi. Ini penting untuk proses YUM.

 http://answers.splunk.com/answers/89697/check-point-ospec-lea-app-bad-elf-interpreter-error

Please refer to the Application system requirements, it seems the following glibc & pam libraries are missing and will need to be installed first

glibc.i686 (32-bit version)
pam.i686 (32-bit version)

Install using: yum install glibc.i686; yum install pam.i686


[root@master ~]# yum install pam.i686
ada pesan error :
       Protected multilib versions: pam-1.1.1-17.el6.i686 != pam-1.1.1-13.el6.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

[root@master ~]# yum install pam.i686 --skip-broken
ada pesan error :
       Protected multilib versions: pam-1.1.1-17.el6.i686 != pam-1.1.1-13.el6.x86_64
 You could try running: rpm -Va --nofiles --nodigest

[root@master ~]# yum upgrade libgcc.x86_64 pam.x86_64
[root@master ~]# yum install pam.i686

[root@master Fortran_source]# g95 transport_serial.f90
In file transport_serial.f90:121

#if defined __DEBUG
1
Error: Unclassifiable statement at (1)
In file transport_serial.f90:123

#endif
1
Error: Unclassifiable statement at (1)
In file transport_serial.f90:158

#if defined __DEBGU
1
Error: Unclassifiable statement at (1)
In file transport_serial.f90:160

#endif
1
Error: Unclassifiable statement at (1)


Coba file fortran yang sederhana, untuk uji coba
[root@master Fortran_source]# vi hello.f90
Program Hello
Print *, "Hello World!"
End Program Hello


[root@master Fortran_source]# g95 -o hello hello.f90
/tmp/ccftL8NI.s: Assembler messages:
/tmp/ccftL8NI.s:11: Error: suffix or operands invalid for `push'

Contoh-contoh fortran
http://www.physics.unlv.edu/~pang/cp_f90.html

[root@master Fortran_source]# wget http://www.physics.unlv.edu/%7Epang/comp3/code11.f90
--2013-12-11 19:52:40--  http://www.physics.unlv.edu/%7Epang/comp3/code11.f90
Resolving www.physics.unlv.edu... 131.216.64.10
Connecting to www.physics.unlv.edu|131.216.64.10|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1744 (1.7K) [text/x-fortran]
Saving to: “code11.f90”

100%[======================================>] 1,744       --.-K/s   in 0s

2013-12-11 19:52:48 (235 MB/s) - “code11.f90” saved [1744/1744]

[root@master Fortran_source]# ls
code11.f90  transport.f90           transport_parallel.f90~
hello.f90   transport.mod           transport_serial.f90
Makefile    transport_parallel.f90  transport_serial.f90~
[root@master Fortran_source]# g95 -o code11 code11.f90
/tmp/ccMTjGdb.s: Assembler messages:
/tmp/ccMTjGdb.s:14: Error: suffix or operands invalid for `push'

No comments:

Post a Comment