Download presentation
Presentation is loading. Please wait.
Published byPiers Grant Modified over 9 years ago
1
7. 정리 및 추가 용법
2
7. 1 변수의 선언 Static variables Five intrinsic fortran data: integer, real, logical, character, complex Derived data types Type point Real:: x, y, z End type point type(point):: center, apex apex%x=0.0 apex%y=1.0 apex%z=2.0 Pointer 자료를 전혀 갖지 않는 대신에 다른 변수의 메모리의 주소를 가짐 Real, pointer:: p1 Real, target:: aa P1=> aa
3
kind Real value: mantissa, exponent 로 구성 Mantissa: 상수의 precision 을 결정함, 유효숫자 Exponent: 상수의 범위를 결정함 32bit 중 24bit 에는 mantissa 를 8bit 는 exponent 에 할당 System 마다 real 의 범위가 다른데 PC 의 경우 Mantissa: 6, exponent=7 Exponent range: 10 -37 to 10 37 Double precision 으로 바꾸고 싶은 경우 kind 를 사용 Real(kind=2):: var
4
System 마다 kind 의 값이 다름 해당 시스템의 kind 의 값을 확인하는 방법 Kind_number=selected_real_kind (p=6, r=37) Real format rFw.d rEw.d : 지수형으로 씀 0.ddddE ee w d+7
5
7.2 Dimension ( 배열 ) A(1,1)A(1,2)A(1,3)A(1,4) A(2,1)A(2,2)A(2,3)A(2,4) A(3,1)A(3,2)A(3,3)A(3,4) row1 Column 1 row2 row3 A(1,1), A(2,1), A(3,1), A(1, 2), A(2,2), A(3,2), …………….
6
7.3 Procedures 1)Subroutine aaa(argument list) 2)Module : 독립적으로 compile 됨 sharing data module module procedure : contain subroutine 3) Function 하나의 값만 줌 intrinsic function 들 sin(a), exp(a),log(a), log10(a), mod(a,b) maxloc(array), maxval(array)
7
7.4 Where Where (mask expression) Statement Elsewhere Statement End where Where (value >0) Logval=log(value) Elsewhere logval=-999. End where Value 와 logval 은 배열임 Do i=1, ndim1 Do j=1, ndim2 If(value(I,j) >0 ) then Logval(I,j)=log(value(I,j)) Else Logval( I,j)=-999. Endif Enddo
8
7.5 Forall Forall (i=1:n, j=1:m, logical expression) Statement End forall Example Forall (i=1:n, j=1:m, work(I,j)/=0) Work(I,j)=1./work(I,j) End forall Do i=1, n do j=1,m if(work(I,j) /=0) then work(I,j)=1./work(I,j) Endif enddo
9
7.6 Allocatable array Real, allocatable, dimension(:,:) :: arr1 Allocate(list of arrays to allocate, stat=status) Deallocate(list of arrays to allocate, stat=status) Allocate(arr1(100,100), stat=status) Deallocate(arr1, stat=status)
10
7.7 파일 열기 닫기 Open(unit, file=‘filename’,status=‘unknown’, iostat=ierror) Open(unit, file=‘test.dat’, form=‘unformatted’, status=‘old’, &access=‘direct’, recl=40) Close(unit) Rewind(unit) : 다시 자료를 처음 줄로 옮김 Backspace(unit): 자료를 한 record 이전으로 옮김 Read(unit, *) : 10 번 파일을 unformat 으로 Read(unit, *, end=999) : 자료를 다 읽으면 999 로 감
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.