您的位置:首页 > 其它

Fortran学习杂记(一)

2015-11-27 13:48 429 查看

Fortran学习杂记(一)

1. 内置函数

1) 数值运算

常见:- abs( ) - aimag( ) -conj( ) -max( ) ** -min( ) - mod(a, b) - real( )- cmplx(a, b)

2) 学函数(命名类似matlab)

- sin( ) - asin( ) - cos( ) - acos( ) - tan( ) - atan( ) - log( ) - sinh( ) - cosh( ) - tanh( ) - sqrt( )

3)数组函数

-matmul( ) 矩阵相乘 -dot_product ( ) 向量内积-tranpose( ) 转置 -

4) 其他函数

计算CPU 计算时间

- call cpu_time

real(kind=8) :: start, finish
call cpu_time(start)
! put code to test here
call cpu_time(finish)
print '("Time = ",f10.9," seconds.")',finish-start


-size

integer a(5,5,5),c,d
c=size(a)
!c=125
d=size(a,1)
!d=5


2.变量声明

1) 常规变量

real(kind=8) :: a
complex :: b
integer :: c
character  (len=10) :: d


2) 常数

integer, parameter:: a=5


3) 数组

a. 声明:

real(kind=8) :: a(5,5)
complex :: b(5)
integer :: c(7)


b.赋值

a=(\1,2,3,4,5\)
data a \1,2,3,4,5\


c.可变数组

integer, allocatable::  a(:) ! 二维a(:,:)
allocate(a(size))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: