Skip to content

Commit

Permalink
Merge pull request #175 from RQC-HU/subprgrams-required-files-check
Browse files Browse the repository at this point in the history
add required files check routine
  • Loading branch information
kohei-noda-qcrg authored Nov 24, 2024
2 parents 9b392c4 + 176c543 commit 3a24038
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
57 changes: 53 additions & 4 deletions src/read_input_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,26 @@ subroutine print_input_file(unit_num)
end if
end subroutine print_input_file

subroutine read_input(unit_num)
subroutine read_input(unit_num, bypass_reqired_file_check)
!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!
! This subroutine is the entry point to read active.inp
!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!
use module_global_variables, only: ras1_size, ras2_size, ras3_size
use module_index_utils, only: set_global_index
implicit none
integer, intent(in) :: unit_num
logical, optional, intent(in) :: bypass_reqired_file_check ! It is used for unit test
integer :: iostat
character(len=max_str_length) :: string
logical :: is_comment
logical :: is_comment, do_reqired_file_check
is_end = .false.

if (present(bypass_reqired_file_check)) then
do_reqired_file_check = .not. bypass_reqired_file_check
else
do_reqired_file_check = .true.
end if

call print_input_file(unit_num)
rewind (unit_num)
call init_essential_variables
Expand All @@ -82,6 +89,7 @@ subroutine read_input(unit_num)
call set_global_index
call validate_nroot_selectroot
call set_mdcint_scheme
if (do_reqired_file_check) call check_reqired_files_exist
! Check the RAS configuration
if (ras1_size /= 0 .or. ras2_size /= 0 .or. ras3_size /= 0) call check_ras_is_valid

Expand Down Expand Up @@ -597,11 +605,11 @@ subroutine read_subprograms(unit_num)
end if

call uppercase(input)
allocate(trim_input, source=trim(adjustl(input)))
allocate (trim_input, source=trim(adjustl(input)))
if (index(trim_input, ".") == 1) then
! If the input starts with a dot, it is the end of the subprograms.
! Need to reset the file pointer to the beginning of the line.
backspace(unit_num)
backspace (unit_num)
return
end if

Expand Down Expand Up @@ -815,6 +823,47 @@ subroutine is_comment_line(string, is_comment)

end subroutine is_comment_line

subroutine check_reqired_files_exist
use module_global_variables
implicit none
logical :: is_exist, is_exist_mdcint

! Check the existence of MRCONEE file
inquire (file="MRCONEE", exist=is_exist)
if (.not. is_exist) then
if (rank == 0) print *, "ERROR: MRCONEE file is required, but it is not found."
call stop_with_errorcode(1)
end if

! Check the existence of MDCINT or MDCINTNEW file
inquire (file="MDCINT", exist=is_exist_mdcint)
is_exist = is_exist_mdcint
inquire (file="MDCINTNEW", exist=is_exist_mdcint)
is_exist = or(is_exist, is_exist_mdcint)
if (.not. is_exist) then
if (rank == 0) print *, "ERROR: MDCINT or MDCINTNEW file is required, but it is not found."
call stop_with_errorcode(1)
end if

if (doivo) then
! Check the existence of DFPCMO file
inquire (file="DFPCMO", exist=is_exist)
if (.not. is_exist) then
if (rank == 0) print *, "ERROR: DFPCMO file is required, but it is not found."
call stop_with_errorcode(1)
end if
end if

if (.not. docasci .and. docaspt2) then
! Check the existence of CIDATA file
inquire (file="CIDATA", exist=is_exist)
if (.not. is_exist) then
if (rank == 0) print *, "ERROR: CIDATA file is required, but it is not found."
call stop_with_errorcode(1)
end if
end if
end subroutine check_reqired_files_exist

subroutine validate_nroot_selectroot
use module_global_variables, only: rank, nroot, selectroot
implicit none
Expand Down
2 changes: 1 addition & 1 deletion test/unit_test/ras3_bitcheck/test_ras3_bitcheck.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ program ras3_bitcheck
logical :: is_allow

call open_formatted_file(unit=unit_new, file='active.inp', status="old", optional_action='read')
call read_input(unit_new)
call read_input(unit_new, .true.)
close (unit_new)

call open_formatted_file(unit=unit_new, file='result.out', status="replace", optional_action='write')
Expand Down

0 comments on commit 3a24038

Please sign in to comment.