-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod_read_molecule.f90
105 lines (81 loc) · 4.04 KB
/
mod_read_molecule.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
!---------------------------------------------------------------------------------------------------
! opd: a program to calculate the scaled Osipov-Pickup-Dunmur chirality index
!---------------------------------------------------------------------------------------------------
!
! Free software, licensed under GNU GPL v3
!
! Copyright (c) 2018 - 2024 Felippe M. Colombari
!
!---------------------------------------------------------------------------------------------------
!
! This is a 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.
!
! This program 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 this program. If
! not, see <https://www.gnu.org/licenses/>.
!
!---------------------------------------------------------------------------------------------------
!> @file mod_read_molecule.f90
!> @author Felippe M. Colombari
!> @brief This module reads coordinates for a given .xyz file and sets the vdW radii for each atom
!> @date - Mar, 2024
!> - independent module created
!---------------------------------------------------------------------------------------------------
module mod_read_molecule
use iso_fortran_env , only : stdout => output_unit
use mod_constants
implicit none
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
type atom
real( kind = dp ) :: xyz(3)
character( len = 2 ) :: label
end type atom
type molecule
type( atom ), allocatable,dimension(:) :: atoms
integer :: num_atoms
contains
procedure, pass :: Read_molecule
end type molecule
type( molecule ) :: mol
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
type atom_entry
character( len = 2 ) :: symbol
end type atom_entry
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
contains
!---------------------------------------------------------------------------
!> @brief This routine reads coordinates for xyz_files.
!> @author Felippe M. Colombari
!---------------------------------------------------------------------------
subroutine Read_molecule ( this, molecule_filename )
use mod_inquire, only: Inquire_file
use mod_error_handling
implicit none
class( molecule ), intent(inout) :: this
character( len = * ), intent(in) :: molecule_filename
integer :: i
integer :: ios = 0
integer :: file_unit = 10
character( len = 15 ) :: file_format = "formatted"
character( len = 15 ) :: file_access = "sequential"
integer :: ierr
type(error) :: err
call Inquire_file( file_unit, molecule_filename, file_format, file_access )
read(file_unit,*,iostat=ios) this % num_atoms
read(file_unit,*)
if ( allocated ( this % atoms ) ) deallocate ( this % atoms )
allocate( this % atoms( this % num_atoms ), stat=ierr )
if(ierr/=0) call err % error('e', err_message="abnormal memory allocation")
do i = 1, this % num_atoms
read(file_unit,*,iostat=ios) this % atoms(i) % label, this % atoms(i) % xyz(:)
enddo
close(file_unit)
write(stdout,'(/,T5, A, i0, A)') "Structure has ", this % num_atoms, " atoms"
return
end subroutine Read_molecule
end module mod_read_molecule