'it'에 해당되는 글 2건

  1. 2011.10.21 티스토리 초대장 드립니다. 19
  2. 2010.06.03 Fortran - Subroutines for sort
전에 안 쓴 2장 + 새로나온 5장 해서 총 7장 있습니다.
초대장을 뿌려보니 만들어놓고 안 쓴다던가 하는 분들이 많아서,
무엇을 포스팅할지에 대해 명확하게 윤곽을 잡아놓은 분들께 드립니다.
특히, 3S 관련된 포스팅 말고
뭔가 제대로 '정보'를 포스팅할 분들께 드립니다.

p.s 넘쳐나는 연예, 드라마, 스포츠 이야기에서 그날 그날 방영된 이슈에만 집중하실 분들은 다음이나 네이버 블로그로 가심이 더 낫지 말입니다. 티스토리는 그들만의 리그에 뛰어들기에 썩 좋은 곳은 아닙니다.

'일상' 카테고리의 다른 글

우스갯소리 - 한국 과학계의 현실  (1) 2011.02.19
카시오 PX-130 White (디지털피아노)  (3) 2010.06.17
깨끗한 하늘이다.  (0) 2010.05.26
블로그 시작-_-  (0) 2010.05.25
Posted by 당근day
,
These subroutines were made to sort various data.
All these subroutines were built my self.
I tested it in Fortran 77, Fortran 95 in Ubuntu 9.XX and both of fortran compiles it well.


1. sort a simple data
-explanation for Input-
E - a real dimension with 'ns' data.
ns - an integer variable. It represents a number of data of another input 'E'.

-warring-
E wil be sorted and changed to be an output.

      subroutine sort(ns,E)
      real C,E(ns)
      integer i,j
      do i=1,ns
       do j=1,ns-1
        if (E(j+1).lt.E(j)) then
         C=E(j)
         E(j)=E(j+1)
         E(j+1)=C
        endif
       enddo
      enddo
      return
      end


2. sort two data
Input parameters are similar as a simple sort.
-explanation for Input-
E1,E2 - a real dimension with 'ns' data.
ns - an integer variable. It represents a number of data of another input 'E1','E2'.

-warring-
E1,E2 wil be sorted by E1 and changed to be an output.

      subroutine sort2(ns,E1,E2)
      real C1,C2,E1(ns),E2(ns)
      integer i,j
      do i=1,ns
       do j=1,ns-1
        if (E1(j+1).lt.E1(j)) then
         C1=E1(j)
         C2=E2(j)
         E1(j)=E1(j+1)
         E2(j)=E2(j+1)
         E1(j+1)=C1
         E2(j+1)=C2
        endif
       enddo
      enddo
      return
      end


3. sort a 2nd dimension

-explanation for Input-
x- a real 2nd dimension with 'n' data.
n - an integer variable. It represents a number of data of another input 'x'.

-warring-
x wil be sorted by x(n,1) and changed to be an output.


      subroutine 2ndsort(x,n)
      real   x(n,2),x1,x2
      integer n
      do i=1,n
       do j=1,n-1
        if(x(j+1,1).lt.x(j,1)) then
         x1=x(j,1)
         x2=x(j,2)
         x(j,1)=x(j+1,1)
         x(j,2)=x(j+1,2)
         x(j+1,1)=x1
         x(j+1,2)=x2
        endif
       enddo
      enddo
      return
      end


4. sort a large size data

-explanation for Input-
val- a real dimension with 'nstar' data. The data 'ch' will be sorted by the value in this dimension.
ch - a character dimension which contains the data wrote in character.
nstar - an integer variable. It represents a number of data of another input 'val', 'ch'.

-warring-
val,ch wil be sorted by val and changed to be an output.
Be careful to have same size of character (ch, chref).
 
      subroutine datasort(val,ch,n)
      integer n
      real val(n),ref
      character ch(n)*250,chref*250
      do i=1,nstar
       do j=1,nstar-1
        if(val(j+1).lt.val(j)) then
         ref=val(j)
         write(chref,'(a250)') ch(j)
         val(j)=val(j+1)
         write(ch(j),'(a250)') ch(j+1)
         val(j+1)=ref
         write(ch(j+1),'(a250)') chref
        endif
       enddo
      enddo
      return
      end




Posted by 당근day
,