Search This Blog

Sunday, March 23, 2014

how to use at command with output

at -m -f myscript.sh now > test.txt  2>&1


source: http://kb.iu.edu/data/aewo.html#examples

openssl installation on Mac



1. Download openssl:  openssl-1.0.1f.tar.gz
2.
./configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.1f
make make install


http://mac-dev-env.patrickbougie.com/openssl/

Friday, March 21, 2014

Cross compiling between FORTRAN and C to use memset.


Makefile

===
FC=ifort
CC=icc
foo: mainf.o fmemset.o
        $(FC) mainf.o fmemset.o -o foo

mainf.o: mainf.f90
        $(FC) -c mainf.f90 -o mainf.o

fmemset.o: fmemset.c
        $(CC)  -c fmemset.c -o fmemset.o
run:
        ./foo

clean:
        /bin/rm -f *.o ./foo
===


FORTRAN code: mainf.f90
===
program Albert
    integer  :: x,y
    real :: a(4,4)
    do 20 i=1,4
        do 10 j=1,4
            a(i,j) = 4
            write (*,*) a(i,j)
10      continue
20  continue
    ! zeroing out 4*4 elements, each of 4 bytes
    call fmemset(a,4*4*4)
    write (*,*) "UPDATED ARRAY:"
    do 40 i=1,4
        do 30 j=1,4
            write (*,*) a(i,j)
30      continue
40  continue
    write(*,*) size(a)
end program Albert
===




C code: fmemset.c
===
#include
void fmemset_(void *a, int *n)  {
         memset(a,0,*n);
}
===



Developed by Prof. Henri Casanova at UHM.  Thanks!



Saturday, March 8, 2014

bash script default input values

#!/bin/sh
dir1=$1
dir2=$2
: ${dir1:="TxtInOut-serial"}
: ${dir2:="TxtInOut-omp-02"}

Friday, May 24, 2013

shell script with options

http://www.mkssoftware.com/docs/man1/getopts.1.asp


EXAMPLE
This is an example of using getopts in a shell script. Compare it to the getopt example.

# Example illustrating use of getopts builtin. This
# shell script would implement the paste command,
# using getopts to process options, if the underlying
# functionality was embedded in hypothetical utilities
# hpaste and vpaste, which perform horizontal and
# vertical pasting respectively.
#
paste=vpaste # default is vertical pasting
seplist="\t" # default separator is tab

while getopts d:s o
do case "$o" in
d) seplist="$OPTARG";;
s) paste=hpaste;;
[?]) print >&2 "Usage: $0 [-s] [-d seplist] file ..."
exit 1;;
esac
done
shift $OPTIND-1

# perform actual paste command
$paste -d "$seplist" "$@"

Thursday, May 23, 2013

How to make DHDall.xyz

#!/bin/bash

DHDfile=($(ls -1 DHD?????.xyz))  # Read all files of DHD?????.xyz
interval=$1        # Interval is the first argument.
: ${interval:=1}   # If there is no argument, default value is 1.


if [ -f DHDall.xyz ] # If DHDall.xyz exist
then
   rm DHDall.xyz     # then delete it.
fi
touch DHDall.xyz     # As DHDall.xyz is absent, touch it.

for (( i=0; i < ${#DHDfile[@]} ; i=i+$interval )) do
   cat  ${DHDfile[$i]} >> DHDall.xyz
done
exit








Friday, May 17, 2013

fortran file append


This partial code is to open existing (OLD) file, DHD00000.xyz, and write (APPEND) additional information from the end of the file

open(unit=1,file='DHD00000.xyz',status='old',position='append')
 write(1,*) "Here we go!"
close(1)

stop
end




Labels