Skip to content

Commit 504d32b

Browse files
committed
add iostat check
1 parent 5ce5d6a commit 504d32b

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/post_process/m_start_up.f90

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ subroutine s_read_input_file() ! ---------------------------------------
3232
!! Generic logical used for the purpose of asserting whether a file
3333
!! is or is not present in the designated location
3434

35+
integer :: iostatus
36+
!! Integer to check iostat of file read
37+
3538
! Namelist for all of the parameters to be inputed by the user
3639
namelist /user_inputs/ case_dir, m, n, p, t_step_start, &
3740
t_step_stop, t_step_save, model_eqns, &
@@ -60,7 +63,14 @@ subroutine s_read_input_file() ! ---------------------------------------
6063
if (file_check) then
6164
open (1, FILE=trim(file_loc), FORM='formatted', &
6265
STATUS='old', ACTION='read')
63-
read (1, NML=user_inputs)
66+
read (1, NML=user_inputs, iostat=iostatus)
67+
68+
if (iostatus /= 0) then
69+
print '(A)', 'Invalid line in post_process.inp. It is '// &
70+
'likely due to a datatype mismatch. Exiting ...'
71+
call s_mpi_abort()
72+
end if
73+
6474
close (1)
6575
! Store m,n,p into global m,n,p
6676
m_glb = m

src/pre_process/m_start_up.fpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ contains
8484
!! Generic logical used for the purpose of asserting whether a file
8585
!! is or is not present in the designated location
8686

87+
integer :: iostatus
88+
!! Integer to check iostat of file read
89+
8790
! Namelist for all of the parameters to be inputed by the user
8891
namelist /user_inputs/ case_dir, old_grid, old_ic, &
8992
t_step_old, m, n, p, x_domain, y_domain, z_domain, &
@@ -111,7 +114,12 @@ contains
111114
if (file_check) then
112115
open (1, FILE=trim(file_loc), FORM='formatted', &
113116
STATUS='old', ACTION='read')
114-
read (1, NML=user_inputs)
117+
read (1, NML=user_inputs, iostat=iostatus)
118+
if (iostatus /= 0) then
119+
print '(A)', 'Invalid line in pre_process.inp. It is '// &
120+
'likely due to a datatype mismatch. Exiting ...'
121+
call s_mpi_abort()
122+
end if
115123
close (1)
116124
! Store m,n,p into global m,n,p
117125
m_glb = m

src/simulation/m_start_up.fpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ contains
7272
logical :: file_exist !<
7373
!! Logical used to check the existence of the input file
7474

75+
integer :: iostatus
76+
!! Integer to check iostat of file read
77+
7578
! Namelist of the global parameters which may be specified by user
7679
namelist /user_inputs/ case_dir, run_time_info, m, n, p, dt, &
7780
t_step_start, t_step_stop, t_step_save, &
@@ -107,7 +110,15 @@ contains
107110
FORM='formatted', &
108111
ACTION='read', &
109112
STATUS='old')
110-
read (1, NML=user_inputs); close (1)
113+
read (1, NML=user_inputs, iostat=iostatus)
114+
115+
if (iostatus /= 0) then
116+
print '(A)', 'Invalid line in simulation.inp. It is '// &
117+
'likely due to a datatype mismatch. Exiting ...'
118+
call s_mpi_abort()
119+
end if
120+
121+
close (1)
111122

112123
! Store BC information into global BC
113124
bc_x_glb%beg = bc_x%beg

0 commit comments

Comments
 (0)