This subroutine reads the data from disc and stores it in the tem_from_file_temporal_type.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_from_file_temporal_type), | intent(inout) | :: | me |
temporal predefined from_file type |
subroutine load_datafile( me )
! --------------------------------------------------------------------------
!> temporal predefined from_file type
type(tem_from_file_temporal_type),intent(inout) :: me
! --------------------------------------------------------------------------
! unit of the datafile
integer :: datafile_unit
! status of IO
integer :: stat = 0
! tmp time value
real(kind=rk) :: tmp_time
! tmp vel value
real(kind=rk) :: tmp_vel
! --------------------------------------------------------------------------
! initialize the data array
call init( me = me%signal, width = 2 )
! open the datafile
call tem_open( newunit = datafile_unit, &
& file = trim(me%datafile), &
& action = 'read', &
& status = 'old', &
& form = 'formatted', &
& access = 'sequential' )
! as long as there is no io error (end of file is not reached)
do
! ... read the data
read( unit = datafile_unit, fmt='(2e15.8)', iostat=stat ) tmp_time, &
& tmp_vel
! ... check wether the file has reached its end to prevent storing
! the last item twice
if ( stat .ne. 0) then
exit
end if
! ... and append them to the growing array of tuples
call append( me = me%signal, val = (/ tmp_time, tmp_vel/) )
end do
! multiply the data with the provided factor
me%signal%val(2,:)=me%fac*me%signal%val(2,:)
if( stat .gt. 0 ) then
write(logUnit(1),*)'Error when reading the inlet data from file!'
write(logUnit(1),*)'STOPPING'
call tem_abort()
end if
! close the file
close( unit = datafile_unit )
end subroutine load_datafile