| Class | Basis |
| In: |
basis.f90
|
基本的な計算関数を実行するモジュール
| Function : | |||
| c2i_convert : | integer | ||
| cval : | character(*), intent(in)
|
文字型を実数型に変換する
integer function c2i_convert( cval ) ! 文字型を実数型に変換する implicit none character(*), intent(in) :: cval ! 変換する文字 read(cval,*) c2i_convert return end function
| Function : | |||
| c2r_convert : | real | ||
| cval : | character(*), intent(in)
|
文字型を実数型に変換する
real function c2r_convert( cval ) ! 文字型を実数型に変換する implicit none character(*), intent(in) :: cval ! 変換する文字 read(cval,*) c2r_convert return end function
| Function : | |||
| i2c_convert : | character(100) | ||
| ival : | integer, intent(in)
| ||
| forma : | character(*), intent(in), optional
|
実数型を文字型に変換する
character(100) function i2c_convert( ival, forma )
! 実数型を文字型に変換する
implicit none
integer, intent(in) :: ival ! 変換する整数
character(*), intent(in), optional :: forma ! 指定するフォーマット
character(100) :: tmp
if(present(forma))then
write(tmp,trim(forma)) ival
else
write(tmp,*) ival
end if
i2c_convert=tmp
return
end function
| Function : | |||
| r2c_convert : | character(100) | ||
| rval : | real, intent(in)
| ||
| forma : | character(*), intent(in), optional
|
実数型を文字型に変換する
character(100) function r2c_convert( rval, forma )
! 実数型を文字型に変換する
implicit none
real, intent(in) :: rval ! 変換する実数
character(*), intent(in), optional :: forma ! 指定するフォーマット
character :: tmp
if(present(forma))then
write(tmp,trim(forma)) rval
else
write(tmp,*) rval
end if
r2c_convert=tmp
return
end function
| Subroutine : | |||
| L : | integer, intent(in)
| ||
| output : | integer, intent(inout)
|
任意の桁数で擬似乱数を生成するサブルーチン 混合合同法という乱数生成アルゴリズムを用いて擬似乱数を生成 $x_{n+1}=a\times x_{n}+b (mod \; L)$
subroutine rand_make(L,output)
! 任意の桁数で擬似乱数を生成するサブルーチン
! 混合合同法という乱数生成アルゴリズムを用いて擬似乱数を生成
! $x_{n+1}=a\times x_{n}+b (mod \; L)$
implicit none
integer, intent(in) :: L ! 出力する最大桁数 + 1 の数値
integer, intent(inout) :: output ! 出力される乱数
integer :: a, b, x0, i, input
integer, external :: time
input=time()
input=mod(input,L)
write(*,*) input
a=11
b=12
x0=input
do i=1,10
x0=a*x0+b
x0=mod(x0,L)
end do
output=x0
end subroutine