-
Notifications
You must be signed in to change notification settings - Fork 6
/
initialise.f90
153 lines (124 loc) · 4.16 KB
/
initialise.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
!Crown Copyright 2012 AWE.
!
! This file is part of CloverLeaf.
!
! CloverLeaf is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the
! Free Software Foundation, either version 3 of the License, or (at your option)
! any later version.
!
! CloverLeaf is distributed in the hope that it will be useful, but
! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! CloverLeaf. If not, see http://www.gnu.org/licenses/.
!> @brief Top level initialisation routine
!> @author Wayne Gaudin
!> @details Checks for the user input and either invokes the input reader or
!> switches to the internal test problem. It processes the input and strips
!> comments before writing a final input file.
!> It then calls the start routine.
SUBROUTINE initialise
USE clover_module
USE parse_module
USE report_module
IMPLICIT NONE
INTEGER :: ios
INTEGER :: get_unit,stat,uin,out_unit
CHARACTER(LEN=g_len_max) :: ltmp
IF(parallel%boss)THEN
g_out=get_unit(dummy)
OPEN(FILE='clover.out',ACTION='WRITE',UNIT=g_out,IOSTAT=ios)
IF(ios.NE.0) CALL report_error('initialise','Error opening clover.out file.')
ELSE
g_out=6
ENDIF
IF(parallel%boss)THEN
WRITE(g_out,*)
WRITE(g_out,'(a15,f8.3)') 'Clover Version ',g_version
WRITE(g_out,*)
WRITE(*,*)'Output file clover.out opened. All output will go there.'
ENDIF
CALL clover_barrier
IF(parallel%boss)THEN
WRITE(g_out,*) 'Clover will run from the following input:-'
WRITE(g_out,*)
ENDIF
IF(parallel%boss)THEN
uin=get_unit(dummy)
OPEN(FILE='clover.in',ACTION='READ',STATUS='OLD',UNIT=uin,IOSTAT=ios)
IF(ios.NE.0) THEN
out_unit=get_unit(dummy)
OPEN(FILE='clover.in',UNIT=out_unit,STATUS='REPLACE',ACTION='WRITE',IOSTAT=ios)
WRITE(out_unit,'(A)')'*clover'
WRITE(out_unit,'(A)')' state 1 density=0.2 energy=1.0'
WRITE(out_unit,'(A)')' state 2 density=1.0 energy=2.5 geometry=rectangle xmin=0.0 xmax=5.0 ymin=0.0 ymax=2.0'
WRITE(out_unit,'(A)')' x_cells=10'
WRITE(out_unit,'(A)')' y_cells=2'
WRITE(out_unit,'(A)')' xmin=0.0'
WRITE(out_unit,'(A)')' ymin=0.0'
WRITE(out_unit,'(A)')' xmax=10.0'
WRITE(out_unit,'(A)')' ymax=2.0'
WRITE(out_unit,'(A)')' initial_timestep=0.04'
WRITE(out_unit,'(A)')' timestep_rise=1.5'
WRITE(out_unit,'(A)')' max_timestep=0.04'
WRITE(out_unit,'(A)')' end_time=3.0'
WRITE(out_unit,'(A)')' test_problem 1'
WRITE(out_unit,'(A)')'*endclover'
CLOSE(out_unit)
uin=get_unit(dummy)
OPEN(FILE='clover.in',ACTION='READ',STATUS='OLD',UNIT=uin,IOSTAT=ios)
ENDIF
out_unit=get_unit(dummy)
OPEN(FILE='clover.in.tmp',UNIT=out_unit,STATUS='REPLACE',ACTION='WRITE',IOSTAT=ios)
IF(ios.NE.0) CALL report_error('initialise','Error opening clover.in.tmp file')
stat=parse_init(uin,'')
DO
stat=parse_getline(-1_4)
IF(stat.NE.0)EXIT
WRITE(out_unit,'(A)') line
ENDDO
CLOSE(out_unit)
ENDIF
CALL clover_barrier
g_in=get_unit(dummy)
OPEN(FILE='clover.in.tmp',ACTION='READ',STATUS='OLD',UNIT=g_in,IOSTAT=ios)
IF(ios.NE.0) CALL report_error('initialise','Error opening clover.in.tmp file')
CALL clover_barrier
IF(parallel%boss)THEN
REWIND(uin)
DO
READ(UNIT=uin,IOSTAT=ios,FMT='(a100)') ltmp ! Read in next line.
IF(ios.NE.0)EXIT
WRITE(g_out,FMT='(a100)') ltmp
ENDDO
ENDIF
IF(parallel%boss)THEN
WRITE(g_out,*)
WRITE(g_out,*) 'Initialising and generating'
WRITE(g_out,*)
ENDIF
CALL read_input()
CALL clover_barrier
step=0
CALL start
CALL clover_barrier
IF(parallel%boss)THEN
WRITE(g_out,*) 'Starting the calculation'
ENDIF
CLOSE(g_in)
END SUBROUTINE initialise
FUNCTION get_unit(dummy)
INTEGER :: get_unit,dummy
INTEGER :: u
LOGICAL :: used
DO u=7,99
INQUIRE(UNIT=u,OPENED=used)
IF(.NOT.used)THEN
EXIT
ENDIF
ENDDO
get_unit=u
END FUNCTION get_unit