curiosity is your instinct. So
First learning method is to ask your own questions. The simplest will be 'what is the meaning of XXX?' Do not think about its stupidity.
Second, you have to find your way to learn something. For our human, we need one standing point, i.e. origin. Namely, you have to copy something from your parents, your teachers, your observation, etc. Then try to use the knowledge you have to know other unknown things. Therefore, analog is important.
Third, we have to understand something based on your origin (the basic concepts). You can not just copy others' thoughts. We have to find our own ways to understand the new concept, new method, new principles, new knowledge. Your own way to understand new things or concepts are extremely important because it only works for you. Other peoples' methods may totally do not work for you. Or even they work for you, you may not find the best way for yourself, therefore you waste your time and lose your identity.
Wednesday, July 23, 2014
Tuesday, July 15, 2014
questions about yourself
1. How to be a good PI?
2. Where is your limitation?
3. How to test your limitation?
4. Why you care about outside if you even can not control yourself?
2. Where is your limitation?
3. How to test your limitation?
4. Why you care about outside if you even can not control yourself?
Monday, June 30, 2014
fortran learning note 6- some easily made mistakes
1. 3n should be 3*n (forget the multiplication)
2. The array index is out of range.
3. Forget to stop reading a file when it ends.
4. When counting the number of lines of a file, do not forget to use "read (unit,'(a120)')" to include the blank line too.
5. Recognize different types of variables and DO NOT use them with mistakes.
2. The array index is out of range.
3. Forget to stop reading a file when it ends.
4. When counting the number of lines of a file, do not forget to use "read (unit,'(a120)')" to include the blank line too.
5. Recognize different types of variables and DO NOT use them with mistakes.
Friday, June 27, 2014
shell script - learning note 2
shell can return value (0: succeed, non-0: fail) expr 1 + 3 # show 4, because of with spaceecho $? $ will show 0
expr 1+ 3 #show syntax errorecho $? $ will show non-0, here 2 in fact.
read: almost same as Fortran.Example:echo "Your first name please:"
read fname
echo "Hello $fname, Lets be friend!"Wildcard (shorthand) 未知数,通配符* means any string or group of characters.? means any single character.
[xxx] Matches any one of the enclosed characters.
two command or more in one line
Example: data;who;cal
Some useful command:
tail file # print last 10 lines of the file.
diamond (i.e. <>)symbol
Example: sort < sname > sorted_names
Pipe: a way to connect the output of one program to the input of another program without any temporary file.
Example: who | sort
ls -l | wl -l
Loop
Bash supports: for loop and while loop
Example: for (( i = 0 ; i <= 5; i++ )) # WATCH OUT THE DOUBLE PARENTHESIS. There is no reason, you have to use it this way.
do
echo "Welcome $i times"
done shell script leanring - note1
Because computers only understand the language of 0 and 1, which is called binary language.
What is Shell?
So Shell is a language interpreter that executes commands read from the standard input device (keyboard) or from a file. It reads your command, interpret and transfer your command to kernal in Linux.
What is Kernel?
Kernel decides who will use this resource, for how long and when. It runs your command or programs (or execute binary files).
$ is important in Bash shell.
Example: $HOME, $n. Only $ + variable can work.
User defined variables
Example: n=10
atring=hello
Rules for naming variables:
1. Variable name must begin with Alphanumeric character or underscore character (_), followed by one or more Alphanumeric character.
2. DON'T put spaces on either side of the equal sign when assigning value to variable. THIS IS IMPORTANT since you can easily forget it.
3. Variables are case-sensitive, e.g. N /=n
4. DO NOT use *, or ?
Math operation in Shell
1. expr op1 math-operator op2## WATCH THE SPACE BETWEEN OPERATOR.
2. echo `expr 5 + 6` # will show 11. Watch the punctuation is not quote.
Double quote, single quote and back quote.
echo "today is date" # output: today is date
echo "today is `date`" #output: today is Fri Jun 27 13:40:19 PDT 2014
echo 'today is `date`' #output: today is `date`
What is Shell?
So Shell is a language interpreter that executes commands read from the standard input device (keyboard) or from a file. It reads your command, interpret and transfer your command to kernal in Linux.
What is Kernel?
Kernel decides who will use this resource, for how long and when. It runs your command or programs (or execute binary files).
$ is important in Bash shell.
Example: $HOME, $n. Only $ + variable can work.
User defined variables
Example: n=10
atring=hello
Rules for naming variables:
1. Variable name must begin with Alphanumeric character or underscore character (_), followed by one or more Alphanumeric character.
2. DON'T put spaces on either side of the equal sign when assigning value to variable. THIS IS IMPORTANT since you can easily forget it.
3. Variables are case-sensitive, e.g. N /=n
4. DO NOT use *, or ?
Math operation in Shell
1. expr op1 math-operator op2## WATCH THE SPACE BETWEEN OPERATOR.
2. echo `expr 5 + 6` # will show 11. Watch the punctuation is not quote.
Double quote, single quote and back quote.
echo "today is date" # output: today is date
echo "today is `date`" #output: today is Fri Jun 27 13:40:19 PDT 2014
echo 'today is `date`' #output: today is `date`
Thursday, June 26, 2014
fortran learning note-5- some frequen error messages
use -g to make debugging.
Segmentation fault: often related to a memory issue (e.g.out of array size or stacksize.)
Stacksize: it consists of a limited amount of address space, often determined at the start of the program. The size of the stack depends on the programming language, machine architecture, multi-threading, and amount of available memory.
A process: in the simplest terms, is an executing program.
A thread: the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread.
A thread pool: a collection of worker threads that efficiently execute asynchronous callbacks on behalf of the application. The thread pool is primarily used to reduce the number of application threads and provide management of the worker threads.
A fiber: a unit of execution that must be manually scheduled by the application. Fibers run in the context of the threads that schedule them.
Segmentation fault: often related to a memory issue (e.g.out of array size or stacksize.)
Stacksize: it consists of a limited amount of address space, often determined at the start of the program. The size of the stack depends on the programming language, machine architecture, multi-threading, and amount of available memory.
A process: in the simplest terms, is an executing program.
A thread: the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread.
A thread pool: a collection of worker threads that efficiently execute asynchronous callbacks on behalf of the application. The thread pool is primarily used to reduce the number of application threads and provide management of the worker threads.
A fiber: a unit of execution that must be manually scheduled by the application. Fibers run in the context of the threads that schedule them.
Monday, June 23, 2014
fotran learning notes 4--subroutine and function
Differences: the function is relative simple and just return one value.
Subroutine will return all values in its variable list or may just operate something without input parameters. In addition, you have to call it.
function example
________________________________________________
program fn1
implicit none
real:: a,b,c,bigroot ! ! Program to demonstrate the use of a FUNCTION subprogram !
write(6,10) !! write out on screen
read(5,*) a, b, c !! read from keyboard??
write(6,20) bigroot(a, b, c)
10 format(' Enter the coefficients a, b, c '/)
20 format(' The larger root is ',F12.6)
end program fn1
! ! End of main program
function bigroot(a, b, c)
implicit none
real:: bigroot, a, b, c, test, root1, root2
! ! Function to find largest root of a quadratic
! If no real roots then function returns value -9.0E35
test = b*b - 4.0*a*c
if(test.ge.0.0) then
root1 = (-b + sqrt(test)) / (2.0 * a)
root2 = (-b - sqrt(test)) / (2.0 * a)
if(root2.gt.root1) then
bigroot = root2
else
bigroot = root1
end if
else
bigroot = -9.0e35
end if
return
end function bigroot
subroutine
----------------------------------------------------------------------------------------
program subrout1
implicit none
real:: a,b,c,root1,root2
logical:: realroots
write(*,10)
read(*,*) a,b,c
call solvit(a,b,c,root1,root2,realroots)
if (realroots) then
write(*,20) root1,root2
else
write(*,*) 'Sorry, there are no real roots'
endif
!
10 format('Enter 3 coefficients')
20 format('The roots are',2f12.6)
stop
end program
!subroutine solvit
subroutine solvit(a,b,c,root1,root2,realroots)
implicit none
real::a,b,c,root1,root2,test
logical::realroots
test=b**2 - 4*a*c
if(test>=0.0) then
root1 = (-b + sqrt(test))/(2.0*a)
root2 = (-b - sqrt(test))/(2.0*a)
realroots = .true.
else
realroots = .false.
end if
return
end
Subroutine will return all values in its variable list or may just operate something without input parameters. In addition, you have to call it.
function example
________________________________________________
program fn1
implicit none
real:: a,b,c,bigroot ! ! Program to demonstrate the use of a FUNCTION subprogram !
write(6,10) !! write out on screen
read(5,*) a, b, c !! read from keyboard??
write(6,20) bigroot(a, b, c)
10 format(' Enter the coefficients a, b, c '/)
20 format(' The larger root is ',F12.6)
end program fn1
! ! End of main program
function bigroot(a, b, c)
implicit none
real:: bigroot, a, b, c, test, root1, root2
! ! Function to find largest root of a quadratic
! If no real roots then function returns value -9.0E35
test = b*b - 4.0*a*c
if(test.ge.0.0) then
root1 = (-b + sqrt(test)) / (2.0 * a)
root2 = (-b - sqrt(test)) / (2.0 * a)
if(root2.gt.root1) then
bigroot = root2
else
bigroot = root1
end if
else
bigroot = -9.0e35
end if
return
end function bigroot
subroutine
----------------------------------------------------------------------------------------
program subrout1
implicit none
real:: a,b,c,root1,root2
logical:: realroots
write(*,10)
read(*,*) a,b,c
call solvit(a,b,c,root1,root2,realroots)
if (realroots) then
write(*,20) root1,root2
else
write(*,*) 'Sorry, there are no real roots'
endif
!
10 format('Enter 3 coefficients')
20 format('The roots are',2f12.6)
stop
end program
!subroutine solvit
subroutine solvit(a,b,c,root1,root2,realroots)
implicit none
real::a,b,c,root1,root2,test
logical::realroots
test=b**2 - 4*a*c
if(test>=0.0) then
root1 = (-b + sqrt(test))/(2.0*a)
root2 = (-b - sqrt(test))/(2.0*a)
realroots = .true.
else
realroots = .false.
end if
return
end
Subscribe to:
Posts (Atom)