PLUME-MoM-TSM  1.0
VolcanicPlumeModel
inpout_2d.f90
Go to the documentation of this file.
1 !********************************************************************************
3 !
6 !
10 !
11 !********************************************************************************
12 
13 MODULE inpout_2d
14 
15  USE inpout, ONLY : run_name
16 
17  USE variables, ONLY : verbose_level , gi
18  USE variables, ONLY : wp
19 
20  USE parameters_2d, ONLY : n_vars
21 
22  ! -- Variables for the namelist RUN_PARAMETERS
23  USE parameters_2d, ONLY : t_start , t_end , dt_output
24 
25  ! -- Variables for the namelist NEWRUN_PARAMETERS
26  USE geometry_2d, ONLY : x0 , y0 , comp_cells_x , comp_cells_y , cell_size , dx , dy
27 
28  ! -- Variables for the namelists LEFT/RIGHT_BOUNDARY_CONDITIONS
29  USE parameters_2d, ONLY : bc
30 
31  ! -- Variables for the namelist NUMERIC_PARAMETERS
34 
35  ! -- Variables for the namelist SOURCE_PARAMETERS
38 
39  ! -- Variables for the namelist ATM_PARAMETERS
40  USE constitutive_2d, ONLY : grav , rho_nbl , drho_dz , n
41 
42  IMPLICIT NONE
43 
44  CHARACTER(LEN=40) :: output_file
45  CHARACTER(LEN=40) :: output_file_2d
46 
47  INTEGER, PARAMETER :: output_unit = 9
48  INTEGER, PARAMETER :: output_unit_2d = 12
49 
51  INTEGER :: output_idx
52 
57  LOGICAL :: output_phys_flag
58 
63  LOGICAL :: output_cons_flag
64 
65  ! -- Variables for the namelists WEST_BOUNDARY_CONDITIONS
66  TYPE(bc) :: h_bcw , hu_bcw , hv_bcw
67 
68  ! -- Variables for the namelists EAST_BOUNDARY_CONDITIONS
69  TYPE(bc) :: h_bce , hu_bce , hv_bce
70 
71  ! -- Variables for the namelists SOUTH_BOUNDARY_CONDITIONS
72  TYPE(bc) :: h_bcs , hu_bcs , hv_bcs
73 
74  ! -- Variables for the namelists NORTH_BOUNDARY_CONDITIONS
75  TYPE(bc) :: h_bcn , hu_bcn , hv_bcn
76 
77  ! parameters to read a dem file
78  INTEGER :: ncols, nrows, nodata_value
79 
81 
82  LOGICAL :: write_first_q
83 
84  INTEGER :: n_probes
85 
86  REAL(wp), ALLOCATABLE :: probes_coords(:,:)
87 
88  REAL(wp), ALLOCATABLE :: h_old(:,:)
89 
90 CONTAINS
91 
92  !******************************************************************************
94  !
98  !
102  !
103  !******************************************************************************
104 
105  SUBROUTINE init_param
107  USE parameters_2d, ONLY : n_vars , n_eqns
108  USE parameters_2d, ONLY : limiter
109  USE parameters_2d, ONLY : bcw , bce , bcs , bcn
110 
111  IMPLICIT none
112 
113  LOGICAL :: lexist
114 
115  n_vars = 3
116 
117  !-- Inizialization of the Variables for the namelist RUN_PARAMETERS
118  t_start = 0.0
119  output_phys_flag = .true.
120 
121  n_vars = 3
122  n_eqns = 3
123 
124  ALLOCATE( bcw(n_vars) , bce(n_vars) , bcs(n_vars) , bcn(n_vars) )
125 
126  h_bcw%FLAG= 1
127  h_bcw%VALUE= 0.0000000000000000
128  hu_bcw%FLAG= 1
129  hu_bcw%VALUE= 0.0000000000000000
130  hv_bcw%FLAG= 1
131  hv_bcw%VALUE= 0.0000000000000000
132 
133  bcw(1) = h_bcw
134  bcw(2) = hu_bcw
135  bcw(3) = hv_bcw
136 
137  h_bce%FLAG= 1
138  h_bce%VALUE= 0.0000000000000000
139  hu_bce%FLAG= 1
140  hu_bce%VALUE= 0.0000000000000000
141  hv_bce%FLAG= 1
142  hv_bce%VALUE= 0.0000000000000000
143 
144  bce(1) = h_bce
145  bce(2) = hu_bce
146  bce(3) = hv_bce
147 
148  h_bcs%FLAG= 1
149  h_bcs%VALUE= 0.0000000000000000
150  hu_bcs%FLAG= 1
151  hu_bcs%VALUE= 0.0000000000000000
152  hv_bcs%FLAG= 1
153  hv_bcs%VALUE= 0.0000000000000000
154 
155  bcs(1) = h_bcs
156  bcs(2) = hu_bcs
157  bcs(3) = hv_bcs
158 
159  h_bcn%FLAG= 1
160  h_bcn%VALUE= 0.0000000000000000
161  hu_bcn%FLAG= 1
162  hu_bcn%VALUE= 0.0000000000000000
163  hv_bcn%FLAG= 1
164  hv_bcn%VALUE= 0.0000000000000000
165 
166  bcn(1) = h_bcn
167  bcn(2) = hu_bcn
168  bcn(3) = hv_bcn
169 
170  time_param(1) = t_end
171  time_param(2) = t_end
172  time_param(3) = 0.0_wp
173  time_param(4) = t_end
174 
175  cell_size = r_source / rsource_cells
176  comp_cells_x = floor( 40.0_wp * r_source / cell_size )
178  x0 = x_source - 0.25_wp * comp_cells_x * cell_size
179  y0 = y_source - 0.25_wp * comp_cells_y * cell_size
180  dx = cell_size
181  dy = cell_size
182 
183  grav = gi
184  n = sqrt( - grav / rho_nbl * drho_dz )
185 
186  WRITE(*,*) 'x_source =',x_source
187  WRITE(*,*) 'y_source =',y_source
188  WRITE(*,*) 'r_source =',r_source
189  WRITE(*,*) 'grav =',grav
190  WRITE(*,*) 'rho_nbl =',rho_nbl
191  WRITE(*,*) 'drho_dz =',drho_dz
192 
193  WRITE(*,*) 'N',n
194 
195  END SUBROUTINE init_param
196 
197 
198  !******************************************************************************
200  !
205  !
207  !
211  !
212  !******************************************************************************
213 
214  SUBROUTINE output_solution(time,steady_state)
216  ! external procedures
217  USE constitutive_2d, ONLY : qc_to_qp
218 
219  USE geometry_2d, ONLY : comp_cells_x , comp_cells_y , x_comp, &
220  y_comp
221 
222  USE parameters_2d, ONLY : n_vars
223  USE parameters_2d, ONLY : t_output , dt_output
224 
225  USE solver_2d, ONLY : q
226 
227  IMPLICIT none
228 
229  REAL(wp), INTENT(IN) :: time
230  LOGICAL, INTENT(IN) :: steady_state
231 
232  CHARACTER(LEN=4) :: idx_string
233 
234  REAL(wp) :: qp(n_vars+2)
235 
236  REAL(wp) :: r_u , r_v , r_h
237 
238  INTEGER :: j,k
239  INTEGER :: i
240  INTEGER :: i_vars
241 
242  IF ( .NOT. steady_state ) THEN
243 
244  output_idx = output_idx + 1
245 
246  idx_string = lettera(output_idx-1)
247 
248  output_file_2d = trim(run_name)//'_'//idx_string//'.p_2d'
249 
250  ELSE
251 
252  output_file_2d = trim(run_name)//'_'//'std.p_2d'
253 
254  END IF
255 
256 
257  IF ( verbose_level .GE. 0 ) WRITE(*,*) 'WRITING ',output_file_2d
258 
259  OPEN(output_unit_2d,file=output_file_2d,status='unknown',form='formatted')
260 
261  DO k = 1,comp_cells_y
262 
263  DO j = 1,comp_cells_x
264 
265  CALL qc_to_qp(q(1:n_vars,j,k) , qp(1:n_vars+2))
266 
267  r_h = qp(1)
268  r_u = qp(n_vars+1)
269  r_v = qp(n_vars+2)
270 
271  IF ( abs( r_h ) .LT. 1e-20_wp) r_h = 0.0_wp
272  IF ( abs( r_u ) .LT. 1e-20_wp) r_u = 0.0_wp
273  IF ( abs( r_v ) .LT. 1e-20_wp) r_v = 0.0_wp
274 
275  WRITE(output_unit_2d,1010) x_comp(j), y_comp(k), r_h , r_u , r_v
276 
277  END DO
278 
279  WRITE(output_unit_2d,*) ' '
280 
281  ENDDO
282 
283  WRITE(output_unit_2d,*) ' '
284  WRITE(output_unit_2d,*) ' '
285 
286  CLOSE(output_unit_2d)
287 
288 
289 1010 FORMAT(100es15.7e2)
290 
291  t_output = time + dt_output
292 
293  END SUBROUTINE output_solution
294 
295 
296 
297  SUBROUTINE close_units
299  IMPLICIT NONE
300 
301  END SUBROUTINE close_units
302 
303  !******************************************************************************
305  !
308  !
310  !
314  !
315  !******************************************************************************
316 
317  CHARACTER*4 FUNCTION lettera(k)
318  IMPLICIT NONE
319  CHARACTER ones,tens,hund,thou
320  !
321  INTEGER :: k
322  !
323  INTEGER :: iten, ione, ihund, ithou
324  !
325  ithou=int(k/1000)
326  ihund=int((k-(ithou*1000))/100)
327  iten=int((k-(ithou*1000)-(ihund*100))/10)
328  ione=k-ithou*1000-ihund*100-iten*10
329  ones=char(ione+48)
330  tens=char(iten+48)
331  hund=char(ihund+48)
332  thou=char(ithou+48)
333  lettera=thou//hund//tens//ones
334  !
335  RETURN
336  END FUNCTION lettera
337 
338 END MODULE inpout_2d
339 
real(wp) h_source
integer n_rk
Runge-Kutta order.
integer comp_cells_x
Number of control volumes x in the comp. domain.
Definition: geometry_2d.f90:64
real(wp) cell_size
Definition: geometry_2d.f90:68
integer rsource_cells
real(wp) r_source
real(wp) dt0
Initial time step.
integer nodata_value
Definition: inpout_2d.f90:78
Parameters.
integer comp_cells_y
Number of control volumes y in the comp. domain.
Definition: geometry_2d.f90:66
Numerical solver.
Definition: solver_2d.f90:12
integer ncols
Definition: inpout_2d.f90:78
type(bc) hv_bcw
Definition: inpout_2d.f90:66
type(bc) h_bcs
Definition: inpout_2d.f90:72
type(bc), dimension(:), allocatable bcw
bcW&flag defines the west boundary condition:
real(wp) x0
Left of the physical domain.
Definition: geometry_2d.f90:57
Input/Output module.
Definition: inpout_2d.f90:13
type(bc) hv_bce
Definition: inpout_2d.f90:69
real(wp) t_output
time of the next output
type(bc) hv_bcn
Definition: inpout_2d.f90:75
Input/Output module.
Definition: inpout.f90:11
real(wp) cellsize
Definition: inpout_2d.f90:80
integer n_vars
Number of conservative variables.
real(wp), dimension(:), allocatable x_comp
Location of the centers (x) of the control volume of the domain.
Definition: geometry_2d.f90:15
real(wp) dt_output
time interval for the output of the solution
Constitutive equations.
type(bc) h_bcw
Definition: inpout_2d.f90:66
real(wp) cfl
Courant-Friedrichs-Lewy parameter.
integer nrows
Definition: inpout_2d.f90:78
type(bc) h_bce
Definition: inpout_2d.f90:69
character *4 function lettera(k)
Numeric to String conversion.
Definition: inpout_2d.f90:318
character(len=20) solver_scheme
Finite volume method: .
logical output_phys_flag
Flag to save the physical variables on file *.p_2d.
Definition: inpout_2d.f90:57
type(bc) h_bcn
Definition: inpout_2d.f90:75
integer, parameter output_unit_2d
Output data 2D unit.
Definition: inpout_2d.f90:48
integer, parameter output_unit
Output data unit.
Definition: inpout_2d.f90:47
Grid module.
Definition: geometry_2d.f90:7
type(bc) hu_bcs
Definition: inpout_2d.f90:72
logical output_cons_flag
Flag to save the conservative variables on file *.q_2d.
Definition: inpout_2d.f90:63
character(len=40) output_file
Name of the output files.
Definition: inpout_2d.f90:44
real(wp) yllcorner
Definition: inpout_2d.f90:80
subroutine qc_to_qp(qc, qp)
Conservative to physical variables.
real(wp) t_end
end time for the run
type(bc) hu_bce
Definition: inpout_2d.f90:69
real(wp) dx
Control volumes size.
Definition: geometry_2d.f90:56
real(wp) y_source
real(wp), dimension(:,:), allocatable probes_coords
Definition: inpout_2d.f90:86
type(bc) hu_bcw
Definition: inpout_2d.f90:66
integer, dimension(10) limiter
Limiter for the slope in the linear reconstruction: .
type(bc) hv_bcs
Definition: inpout_2d.f90:72
integer output_idx
Counter for the output files.
Definition: inpout_2d.f90:51
integer, parameter wp
working precision
Definition: variables.f90:21
subroutine close_units
Definition: inpout_2d.f90:298
type(bc), dimension(:), allocatable bcn
bcN&flag defines the north boundary condition:
type(bc) hu_bcn
Definition: inpout_2d.f90:75
real(wp) vol_flux_source
real(wp) vel_source
integer n_eqns
Number of equations.
character(len=40) output_file_2d
Name of the output files.
Definition: inpout_2d.f90:45
real(wp) max_dt
Largest time step allowed.
character(len=30) run_name
Name of the run (used for the output and backup files)
Definition: inpout.f90:69
subroutine init_param
Initialization of the variables read from the input file.
Definition: inpout_2d.f90:106
real(wp) t_start
initial time for the run
real(wp), dimension(:,:,:), allocatable q
Conservative variables.
Definition: solver_2d.f90:42
type(bc), dimension(:), allocatable bcs
bcS&flag defines the south boundary condition:
logical write_first_q
Definition: inpout_2d.f90:82
real *8 gi
Gravity acceleration.
Definition: variables.f90:24
integer n_probes
Definition: inpout_2d.f90:84
real(wp) y0
Bottom of the physical domain.
Definition: geometry_2d.f90:60
type(bc), dimension(:), allocatable bce
bcE&flag defines the east boundary condition:
real(wp), dimension(4) time_param
real(wp) u_source
real(wp) v_source
real(wp) theta
Van Leer limiter parameter.
real(wp) x_source
real(wp), dimension(:,:), allocatable h_old
Definition: inpout_2d.f90:88
real(wp) reconstr_coeff
Slope coefficient in the linear reconstruction.
Global variables.
Definition: variables.f90:10
subroutine output_solution(time, steady_state)
Write the solution on the output unit.
Definition: inpout_2d.f90:215
logical interfaces_relaxation
Flag to add the relaxation terms after the linear reconstruction: .
real(wp), dimension(:), allocatable y_comp
Location of the centers (y) of the control volume of the domain.
Definition: geometry_2d.f90:21
real(wp) xllcorner
Definition: inpout_2d.f90:80
integer verbose_level
Level of verbose output (0 = minimal output on screen)
Definition: variables.f90:33
real(wp) dy
Control volumes size.
Definition: geometry_2d.f90:59