forked from samhatfield/lorenz63-4dvar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.f90
39 lines (34 loc) · 1.11 KB
/
io.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
!> @author
!> Sam Hatfield, AOPP, University of Oxford
!> @brief
!> Contains functions for I/O.
module io
use params
implicit none
private
public output
contains
!> @brief
!> Outputs the given 2D array with the given time axis as the first column.
!> @param[in] time_axis an array of time values corresponding to each row
!> of the output array
!> @param[in] output_array the array containing the data to output
!> @param[in] stride_in an optional argument allowing only every nth value
!> to be output
subroutine output(time_axis, output_array, filename, stride_in)
real(dp), intent(in) :: time_axis(:), output_array(:,:)
character(len=*), intent(in) :: filename
integer, optional :: stride_in
integer :: i, stride
if (present(stride_in)) then
stride = stride_in
else
stride = 1
end if
open(1, file=filename)
do i = 1, size(output_array, 1)
write (1,*) time_axis(1+(i-1)*stride), output_array(i,:)
end do
close(1)
end subroutine output
end module io