This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
forked from garrelt/C2-Ray1D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.F90
83 lines (60 loc) · 1.96 KB
/
time.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
!>
!! \brief This module handles the time variables
!!
!! Module for C2-Ray (f90)
!!
!! \b Author: Garrelt Mellema
!!
!! \b Date: 2008-05-29 (no date before)
!<
module times
! This module handles the time variables
use precision, only: dp
use my_mpi
use file_admin, only: stdinput, file_input
use astroconstants, only: YEAR
implicit none
private
real(kind=dp),public :: end_time !< End time of simulation
real(kind=dp),public :: dt !< Time step
real(kind=dp),public :: output_time !< Time interval between outputs
public :: time_ini
contains
! =======================================================================
!>
!! Initializes the module variables
!<
subroutine time_ini( )
! Initializes number of time steps per frame (integration and output)
! Author: Garrelt Mellema
! Date: 20-Aug-2006 (f77: 10-Mar-2004)
real(kind=dp) :: end_time_yrs,output_time_yrs
integer :: number_timesteps
#ifdef MPI
integer :: ierror
#endif
if (rank == 0) then
! Ask for end time
if (.not.file_input) write(*,'(A,$)') 'Enter end time of calculation (years): '
read(stdinput,*) end_time_yrs
! Convert to seconds
end_time=end_time_yrs*YEAR
! Ask for number of time steps
if (.not.file_input) write(*,'(A,$)') 'Enter number of time steps: '
read(stdinput,*) number_timesteps
! Ask for interval between outputs
if (.not.file_input) write(*,'(A,$)') 'Enter time interval between outputs (years): '
read(stdinput,*) output_time_yrs
! Convert to seconds
output_time=output_time_yrs*YEAR
endif
#ifdef MPI
! Distribute the input parameters to the other nodes
call MPI_BCAST(end_time,1,MPI_DOUBLEPRECISION,0,&
MPI_COMM_NEW,ierror)
call MPI_BCAST(output_time,1,MPI_DOUBLEPRECISION,0,MPI_COMM_NEW,ierror)
#endif
! Set value of time step
dt=end_time/real(number_timesteps)
end subroutine time_ini
end module times