0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ADDA > bash script > read_numIter_170916_exec > v0.1, v0.2 > to extract the number of iterations from log files

Last updated at Posted at 2017-09-15
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.2.1
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
ADDA v.1.3b6

About

Is used to extract followings from the 'log' files

  • Re{m}: real part of refractive index
  • Im{m}: imaginary part of refractive index
  • number of iterations

code v0.1

bash script

# !/usr/bin/env bash

#
# v0.1 Sep. 16, 2017
#   - extract number of iterations in ADDA log file
#   - extract Re{m} and Im{m}
#

LOGFILE="log"

# debug
# target="run845_sphere_g26_m1.5"

for target in $(ls | grep run):
do
	refrac=$(grep refrac $target/$LOGFILE | awk '{print $3}')
	arys=$(echo $refrac | sed 's/+/ /g' | sed 's/i//g')
	# set -x  # start debugging
	rem=$(echo $arys | awk '{print $1}')  # real part
	imm=$(echo $arys | awk '{print $2}')  # imaginary part

	num=$(grep RE_ $target/$LOGFILE | tail -n 1 | sed 's/_/ /g' | awk '{print $2}')

	echo "$rem,$imm,$num"
done

run

The code can be executed in the directory where you see ADDA output directories (e.g., run859_sphere_g26_m1.5).

$ ls | head
run425_sphere_g26_m1.4
run426_sphere_g26_m1.4
run427_sphere_g26_m1.4
run428_sphere_g26_m1.4
run429_sphere_g26_m1.4
run430_sphere_g26_m1.4
run431_sphere_g26_m1.4
run432_sphere_g26_m1.4
run433_sphere_g26_m1.4
run434_sphere_g26_m1.4
$ bash read_numIter_170916_exec > ReIm_170916.tbl
$ head ReIm_170916.tbl 
1.4,1e-05,038
1.4,1.3e-05,039
1.4,1.6e-05,039
1.4,2e-05,039
1.4,2.5e-05,039
1.4,3.2e-05,039
1.4,4e-05,039
1.4,5e-05,038
1.4,6.3e-05,039
1.4,7.9e-05,039

code v0.2

To skip the directories having no [log file.

# !/usr/bin/env bash

#
# v0.2 Sep. 16, 2017
#   - check whether the log file exists or not
# v0.1 Sep. 16, 2017
#   - extract number of iterations in ADDA log file
#   - extract Re{m} and Im{m}
#

LOGFILE="log"

# debug
# target="run845_sphere_g26_m1.5"

for target in $(ls | grep run):
do
	if [ -e $target/$LOGFILE ]; then
		refrac=$(grep refrac $target/$LOGFILE | awk '{print $3}')
		arys=$(echo $refrac | sed 's/+/ /g' | sed 's/i//g')
		# set -x  # start debugging
		rem=$(echo $arys | awk '{print $1}')  # real part
		imm=$(echo $arys | awk '{print $2}')  # imaginary part

		num=$(grep RE_ $target/$LOGFILE | tail -n 1 | sed 's/_/ /g' | awk '{print $2}')

		echo "$rem,$imm,$num"
	fi
done
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?