Initial commit with working atom and lattice type parsing
This commit is contained in:
parent
552dd3cada
commit
624886bbe9
9 changed files with 350 additions and 1 deletions
18
src/Makefile
Normal file
18
src/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
CC=ifort
|
||||
FC=ifort
|
||||
FFLAGS=-c -mcmodel=large -debug -O0 -stand f08 -fpe0 -traceback -check bounds,uninit -warn all -implicitnone
|
||||
|
||||
OBJECTS= main.o elements.o lattice.o subroutines.o precision_comm_module.o
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .f .f90 .F90 .o
|
||||
|
||||
builder: $(OBJECTS)
|
||||
$(FC) $(OBJECTS) -o $@
|
||||
|
||||
.f90.o:
|
||||
$(FC) $(FFLAGS) $<
|
||||
|
||||
main.o lattice.o elements.o region.o subroutines.o : precision_comm_module.o
|
||||
lattice.o : subroutines.o
|
||||
main.o : elements.o lattice.o region.o
|
32
src/elements.f90
Normal file
32
src/elements.f90
Normal file
|
@ -0,0 +1,32 @@
|
|||
module elements
|
||||
|
||||
use precision_comm_module
|
||||
|
||||
implicit none
|
||||
|
||||
!This is the data structure which is used to represent the CAC elements
|
||||
type element
|
||||
integer :: tag = 0 !Element tag (used to keep track of id's
|
||||
integer :: type = 0 !Lattice type of the element
|
||||
integer :: size = 0 !Element size
|
||||
!Nodal position array below only works for wedge or fcc elements
|
||||
real(kind=wp) :: r_node(3,8)
|
||||
end type
|
||||
|
||||
!Finite element array
|
||||
type(element), allocatable :: element_array(:)
|
||||
|
||||
integer :: ele_num
|
||||
|
||||
!Data structure used to represent atoms
|
||||
type atom
|
||||
integer :: tag = 0
|
||||
integer :: type = 0
|
||||
real(kind =wp) :: r
|
||||
end type
|
||||
|
||||
type(atom), allocatable :: atoms(:)
|
||||
|
||||
integer :: atom_num
|
||||
|
||||
end module elements
|
95
src/lattice.f90
Normal file
95
src/lattice.f90
Normal file
|
@ -0,0 +1,95 @@
|
|||
module lattice
|
||||
|
||||
use precision_comm_module
|
||||
use subroutines
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: atom_types
|
||||
|
||||
!Atom type variables
|
||||
character(len=2), dimension(10) :: atom_names
|
||||
real(kind=wp), dimension(10) :: atom_masses
|
||||
|
||||
!Lattice_type variables
|
||||
integer :: lat_num
|
||||
character(len=10), dimension(10) :: lattice_id, lattice_type
|
||||
real(kind=wp), dimension(10) :: lapa
|
||||
integer(kind=wp), dimension(10) :: basis_atom_num
|
||||
integer(kind=wp), dimension(10,10) :: basis_type
|
||||
real(kind=wp), dimension(3,10,10) ::basis_pos
|
||||
|
||||
!Unit Cell variables
|
||||
real(kind = wp) :: fcc_cell(3,8), fcc_mat(3,3)
|
||||
|
||||
public
|
||||
contains
|
||||
|
||||
subroutine lattice_init
|
||||
|
||||
!Initialize needed variables
|
||||
lat_num=0
|
||||
basis_atom_num(:) = 0
|
||||
|
||||
!Initialize finite element cells to be used
|
||||
|
||||
!First initialize the primitive fcc cell
|
||||
fcc_cell = reshape((/ 0.0_wp, 0.0_wp, 0.0_wp, &
|
||||
0.5_wp, 0.5_wp, 0.0_wp, &
|
||||
0.5_wp, 1.0_wp, 0.5_wp, &
|
||||
0.0_wp, 0.5_wp, 0.5_wp, &
|
||||
0.5_wp, 0.0_wp, 0.5_wp, &
|
||||
1.0_wp, 0.5_wp, 0.5_wp, &
|
||||
1.0_wp, 1.0_wp, 1.0_wp, &
|
||||
0.5_wp, 0.5_wp, 1.0_wp /), &
|
||||
shape(fcc_cell))
|
||||
|
||||
fcc_mat = reshape((/ 0.5_wp, 0.5_wp, 0.0_wp, &
|
||||
0.5_wp, 0.5_wp, 0.5_wp, &
|
||||
0.5_wp, 0.0_wp, 0.5_wp /), &
|
||||
shape(fcc_mat))
|
||||
end subroutine lattice_init
|
||||
!This subroutine defines the atom type arrays
|
||||
subroutine atom_type_parse(line)
|
||||
|
||||
character(len=100), intent(in) :: line
|
||||
character(len=100) :: errorloc
|
||||
integer :: ia, error
|
||||
character(len=20) :: label
|
||||
|
||||
read(line, *, iostat=error) label, atom_types, (atom_names(ia), atom_masses(ia), ia=1, atom_types)
|
||||
errorloc="lattice:22"
|
||||
call read_error_check(error,errorloc)
|
||||
|
||||
end subroutine atom_type_parse
|
||||
|
||||
!This subroutine defines the lattice types and the unit cells for the lattice types
|
||||
subroutine lattice_parse(line)
|
||||
character(len=100), intent(in) :: line
|
||||
integer :: ia, error
|
||||
character(len=20) :: label, kw
|
||||
character(len=100) :: errorloc
|
||||
|
||||
lat_num = lat_num + 1
|
||||
read(line, *, iostat=error) label, lattice_id(lat_num), lattice_type(lat_num), lapa(lat_num), kw
|
||||
errorloc="lattice:77"
|
||||
call read_error_check(error, errorloc)
|
||||
|
||||
select case(kw)
|
||||
case("type")
|
||||
read(line(scan(line, "type"):), *, iostat=error) label, basis_type(1,1)
|
||||
errorloc="lattice:56"
|
||||
call read_error_check(error,errorloc)
|
||||
case("basis")
|
||||
read(line(scan(line, "basis"):), *, iostat=error) label, basis_atom_num(lat_num), (basis_type(ia, lat_num) ,&
|
||||
basis_pos(1:3,ia,lat_num), ia = 1, basis_atom_num(lat_num))
|
||||
errorloc="lattice:59"
|
||||
call read_error_check(error,errorloc)
|
||||
case default
|
||||
print *, "Keyword ", kw, " is not accepted in the lattice command"
|
||||
stop "Exit with error"
|
||||
end select
|
||||
|
||||
|
||||
end subroutine lattice_parse
|
||||
end module lattice
|
52
src/main.f90
Normal file
52
src/main.f90
Normal file
|
@ -0,0 +1,52 @@
|
|||
program main
|
||||
|
||||
use precision_comm_module
|
||||
use elements
|
||||
use lattice
|
||||
use region
|
||||
|
||||
integer :: iosline, iospara
|
||||
logical :: flags(4)
|
||||
character(len=100) :: line, command, errorloc
|
||||
|
||||
iosline = 0
|
||||
iospara = 0
|
||||
flags(:) = .false.
|
||||
|
||||
call lattice_init
|
||||
|
||||
!Main command loop
|
||||
do while (iosline == 0)
|
||||
|
||||
read(*, '(a)', iostat=iosline) line
|
||||
errorloc="read_input:line"
|
||||
call read_error_check(iosline, errorloc)
|
||||
|
||||
!Check for comment character (#)
|
||||
if ((scan(line, '#')/= 1).and.(line/='')) then
|
||||
read(line, *, iostat = iospara) command
|
||||
errorloc="read_input:command"
|
||||
call read_error_check(iosline, errorloc)
|
||||
|
||||
select case(command)
|
||||
case('atom_types')
|
||||
call atom_type_parse(line)
|
||||
flags(1) = .true.
|
||||
case('lattice')
|
||||
if(flags(1).eqv..false.) then
|
||||
print *, "Please define atom types before defining lattice types"
|
||||
stop 3
|
||||
end if
|
||||
call lattice_parse(line)
|
||||
flags(2) =.true.
|
||||
! case('region')
|
||||
! call build_region(line)
|
||||
! case('write')
|
||||
! call write_parse(line)
|
||||
case default
|
||||
print *, "The command ", trim(command), " is not currently accepted",&
|
||||
" please check input script and try again."
|
||||
end select
|
||||
end if
|
||||
end do
|
||||
end program main
|
13
src/precision_comm_module.f90
Normal file
13
src/precision_comm_module.f90
Normal file
|
@ -0,0 +1,13 @@
|
|||
module precision_comm_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer, parameter :: &
|
||||
dp = selected_real_kind(15, 307), & ! double real
|
||||
qp = selected_real_kind(33, 4931), & ! quadrupole real
|
||||
wp = dp
|
||||
|
||||
integer, save :: &
|
||||
mpi_wp
|
||||
|
||||
end module precision_comm_module
|
14
src/region.f90
Normal file
14
src/region.f90
Normal file
|
@ -0,0 +1,14 @@
|
|||
module region
|
||||
use precision_comm_module
|
||||
|
||||
implicit none
|
||||
|
||||
public
|
||||
contains
|
||||
|
||||
subroutine build_region(line)
|
||||
|
||||
character(len=100), intent(in) :: line
|
||||
|
||||
end subroutine build_region
|
||||
end module region
|
24
src/subroutines.f90
Normal file
24
src/subroutines.f90
Normal file
|
@ -0,0 +1,24 @@
|
|||
module subroutines
|
||||
|
||||
use precision_comm_module
|
||||
|
||||
implicit none
|
||||
|
||||
public
|
||||
contains
|
||||
|
||||
|
||||
!This subroutine is just used to break the code and exit on an error
|
||||
subroutine read_error_check(para, loc)
|
||||
|
||||
integer, intent(in) :: para
|
||||
character(len=100), intent(in) :: loc
|
||||
|
||||
if (para > 0) then
|
||||
print *, "Read error in ", trim(loc), " because of ", para
|
||||
stop "Exit with error"
|
||||
end if
|
||||
end subroutine
|
||||
|
||||
|
||||
end module subroutines
|
Loading…
Add table
Add a link
Reference in a new issue