FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
m_timepoint.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
2 ! Copyright (c) 2019 FrontISTR Commons
3 ! This software is released under the MIT License, see LICENSE.txt
4 !-------------------------------------------------------------------------------
6 module m_timepoint
7  use hecmw
8  implicit none
9 
10  integer, parameter :: tprstep = 1
11  integer, parameter :: tprtotal = 2
12 
15  character( len=80 ) :: name
16  integer :: n_points
17  integer :: range_type
18  real(kind=kreal), pointer :: points(:) => null()
19  end type
20 
21 contains
22 
23  subroutine init_time_points(tp)
24  type(time_points), intent(inout) :: tp
25 
26  tp%name = ''
27  tp%n_points = 0
28  tp%range_type = tprstep
29  end subroutine
30 
31  subroutine print_time_points(tp)
32  type(time_points), intent(in) :: tp
33 
34  write(*,*) 'timepoints name=',trim(tp%name)
35  write(*,*) 'n_points, range_type',tp%n_points, tp%range_type
36  write(*,*) 'points'
37  if( associated(tp%points) ) then
38  write(*,*) tp%points
39  else
40  write(*,*) ' not allocated.'
41  endif
42  end subroutine
43 
44  logical function is_at_timepoints(totaltime,starttime,tp)
45  real(kind=kreal), intent(in) :: totaltime
46  real(kind=kreal), intent(in) :: starttime
47  type(time_points), intent(in) :: tp
48 
49  integer :: i
50  real(kind=kreal) :: time
51 
52  time = totaltime
53  if( tp%range_type == tprstep ) time = totaltime - starttime
54 
55  is_at_timepoints =.false.
56  do i=1,tp%n_points
57  if( dabs(time-tp%points(i)) > 1.d-10 ) cycle
58  is_at_timepoints = .true.
59  exit
60  end do
61 
62  end function
63 
64  real(kind=kreal) function get_remain_to_next_timepoints(totaltime,starttime,tp)
65  real(kind=kreal), intent(in) :: totaltime
66  real(kind=kreal), intent(in) :: starttime
67  type(time_points), intent(in) :: tp
68 
69  integer :: i
70  real(kind=kreal) :: time
71 
72  time = totaltime
73  if( tp%range_type == tprstep ) time = totaltime - starttime
74 
76  if( time < tp%points(1)-1.d-10 ) then
77  get_remain_to_next_timepoints = tp%points(1)-time
78  end if
79  do i=1,tp%n_points-1
80  if( time < tp%points(i)-1.d-10 ) cycle
81  if( time >= tp%points(i+1)-1.d-10 ) cycle
82  get_remain_to_next_timepoints = tp%points(i+1)-time
83  exit
84  end do
85 
86  end function
87 
88 end module
m_timepoint::init_time_points
subroutine init_time_points(tp)
Definition: m_timepoint.f90:24
m_timepoint::time_points
Time points storage for output etc.
Definition: m_timepoint.f90:14
m_timepoint::is_at_timepoints
logical function is_at_timepoints(totaltime, starttime, tp)
Definition: m_timepoint.f90:45
m_timepoint::tprtotal
integer, parameter tprtotal
Definition: m_timepoint.f90:11
m_timepoint
This module manages timepoint information.
Definition: m_timepoint.f90:6
hecmw
Definition: hecmw.f90:6
m_timepoint::tprstep
integer, parameter tprstep
Definition: m_timepoint.f90:10
m_timepoint::get_remain_to_next_timepoints
real(kind=kreal) function get_remain_to_next_timepoints(totaltime, starttime, tp)
Definition: m_timepoint.f90:65
m_timepoint::print_time_points
subroutine print_time_points(tp)
Definition: m_timepoint.f90:32