現在の Fortran 乱数状態をファイルへ保存する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | out_dir |
出力ディレクトリ。 |
||
| integer(kind=i32), | intent(in), | optional | :: | mpi_rank | ||
| integer(kind=i32), | intent(in), | optional | :: | mpi_size | ||
| type(mpi_context), | intent(in), | optional | :: | mpi |
subroutine write_rng_state_file(out_dir, mpi_rank, mpi_size, mpi) character(len=*), intent(in) :: out_dir integer(i32), intent(in), optional :: mpi_rank, mpi_size type(mpi_context), intent(in), optional :: mpi character(len=1024) :: path integer :: n, u, ios, i integer, allocatable :: seed(:) integer(i32) :: local_rank, world_size call resolve_parallel_rank_size(local_rank, world_size, mpi_rank, mpi_size, mpi, 'write_rng_state_file') call random_seed(size=n) allocate (seed(n)) call random_seed(get=seed) path = restart_rng_state_path(trim(out_dir), mpi_rank=local_rank, mpi_size=world_size) open (newunit=u, file=trim(path), status='replace', action='write', iostat=ios) if (ios /= 0) error stop 'Failed to open rng_state.txt.' write (u, '(i0)') n do i = 1, n write (u, '(i0)') seed(i) end do close (u) end subroutine write_rng_state_file