From 51079148ccfa421bb1a51e3426e900963dcf4870 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Sat, 24 Oct 2020 09:53:58 -0400 Subject: [PATCH] Get code working with gfortran --- src/Makefile | 5 +- src/elements.f90 | 132 ++++++++++++++++++++++++-------------------- src/mode_create.f90 | 2 +- src/opt_group.f90 | 5 +- 4 files changed, 78 insertions(+), 66 deletions(-) diff --git a/src/Makefile b/src/Makefile index feb933f..18881ae 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,7 @@ -FC=ifort -FFLAGS=-mcmodel=large -g -O0 -stand f08 -fpe0 -traceback -check bounds,uninit -warn all -implicitnone -no-wrap-margin -heap-arrays +FC=gfortran +#FFLAGS=-mcmodel=large -g -O0 -stand f08 -fpe0 -traceback -check bounds,uninit -warn all -implicitnone -no-wrap-margin -heap-arrays #FFLAGS=-mcmodel=large -Ofast -no-wrap-margin -heap-arrays +FFLAGS=-mcmodel=large -O3 -g MODES=mode_create.o mode_merge.o mode_convert.o OPTIONS=opt_disl.o opt_group.o opt_orient.o opt_delete.o opt_deform.o opt_redef_box.o OBJECTS=main.o elements.o io.o subroutines.o functions.o atoms.o call_mode.o box.o $(MODES) $(OPTIONS) call_option.o sorts.o diff --git a/src/elements.f90 b/src/elements.f90 index 6df859b..7ca48c8 100644 --- a/src/elements.f90 +++ b/src/elements.f90 @@ -198,64 +198,74 @@ module elements !The default size we grow the buffer_size = 1024 - !Figure out the size of the atom and element arrays - ele_size = size(size_ele) - atom_size = size(type_atom) - - !Check if we need to grow the ele_size, if so grow all the variables - if ( n+ele_num > size(size_ele)) then - - allocate(temp_int(n+ele_num+buffer_size)) - temp_int(1:ele_size) = lat_ele - temp_int(ele_size+1:) = 0 - call move_alloc(temp_int, lat_ele) - - allocate(temp_int(n+ele_num+buffer_size)) - temp_int(1:ele_size) = tag_ele - temp_int(ele_size+1:) = 0 - call move_alloc(temp_int, tag_ele) - - allocate(temp_int(n+ele_num+buffer_size)) - temp_int(1:ele_size) = size_ele - temp_int(ele_size+1:) = 0 - call move_alloc(temp_int, size_ele) - - allocate(temp_int(n+ele_num+buffer_size)) - temp_int(1:ele_size) = lat_ele - temp_int(ele_size+1:) = 0 - call move_alloc(temp_int, sbox_ele) - - allocate(char_temp(n+ele_num+buffer_size)) - char_temp(1:ele_size) = type_ele - call move_alloc(char_temp, type_ele) - - allocate(temp_ele_real(3, max_basisnum, max_ng_node, n+ele_num+buffer_size)) - temp_ele_real(:,:,:,1:ele_size) = r_node - temp_ele_real(:,:,:,ele_size+1:) = 0.0_dp - call move_alloc(temp_ele_real, r_node) + + !First check to make sure if it is allocated + if (allocated(size_ele)) then + !Figure out the size of the atom and element arrays + ele_size = size(size_ele) + + !Check if we need to grow the ele_size, if so grow all the variables + if ( n+ele_num > size(size_ele)) then + + allocate(temp_int(n+ele_num+buffer_size)) + temp_int(1:ele_size) = lat_ele + temp_int(ele_size+1:) = 0 + call move_alloc(temp_int, lat_ele) + + allocate(temp_int(n+ele_num+buffer_size)) + temp_int(1:ele_size) = tag_ele + temp_int(ele_size+1:) = 0 + call move_alloc(temp_int, tag_ele) + + allocate(temp_int(n+ele_num+buffer_size)) + temp_int(1:ele_size) = size_ele + temp_int(ele_size+1:) = 0 + call move_alloc(temp_int, size_ele) + + allocate(temp_int(n+ele_num+buffer_size)) + temp_int(1:ele_size) = lat_ele + temp_int(ele_size+1:) = 0 + call move_alloc(temp_int, sbox_ele) + + allocate(char_temp(n+ele_num+buffer_size)) + char_temp(1:ele_size) = type_ele + call move_alloc(char_temp, type_ele) + + allocate(temp_ele_real(3, max_basisnum, max_ng_node, n+ele_num+buffer_size)) + temp_ele_real(:,:,:,1:ele_size) = r_node + temp_ele_real(:,:,:,ele_size+1:) = 0.0_dp + call move_alloc(temp_ele_real, r_node) + end if + else + call alloc_ele_arrays(n,0) end if !Now grow atom arrays if needed - if (m+atom_num > atom_size) then - allocate(temp_int(m+atom_num+buffer_size)) - temp_int(1:atom_size) = type_atom - temp_int(atom_size+1:) = 0 - call move_alloc(temp_int, type_atom) - - allocate(temp_int(m+atom_num+buffer_size)) - temp_int(1:atom_size) = tag_atom - temp_int(atom_size+1:) = 0 - call move_alloc(temp_int, tag_atom) - - allocate(temp_int(m+atom_num+buffer_size)) - temp_int(1:atom_size) = sbox_atom - temp_int(atom_size+1:) = 0 - call move_alloc(temp_int, sbox_atom) - - allocate(temp_real(3,m+atom_num+buffer_size)) - temp_real(:,1:atom_size) = r_atom - temp_real(:, atom_size+1:) = 0.0_dp - call move_alloc(temp_real, r_atom) + if (allocated(type_atom)) then + atom_size = size(type_atom) + if (m+atom_num > atom_size) then + allocate(temp_int(m+atom_num+buffer_size)) + temp_int(1:atom_size) = type_atom + temp_int(atom_size+1:) = 0 + call move_alloc(temp_int, type_atom) + + allocate(temp_int(m+atom_num+buffer_size)) + temp_int(1:atom_size) = tag_atom + temp_int(atom_size+1:) = 0 + call move_alloc(temp_int, tag_atom) + + allocate(temp_int(m+atom_num+buffer_size)) + temp_int(1:atom_size) = sbox_atom + temp_int(atom_size+1:) = 0 + call move_alloc(temp_int, sbox_atom) + + allocate(temp_real(3,m+atom_num+buffer_size)) + temp_real(:,1:atom_size) = r_atom + temp_real(:, atom_size+1:) = 0.0_dp + call move_alloc(temp_real, r_atom) + end if + else + call alloc_ele_arrays(0,m) end if end subroutine @@ -669,17 +679,17 @@ module elements esize = size_ele(ie) select case(iface) case(1) - pos = (/ real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp, -10.0_dp**-2.0_dp /) + pos = (/ real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp, -10.0_dp**(-2.0_dp) /) case(2) - pos = (/ real(esize-1,dp)/2.0_dp, -10.0_dp**-2.0_dp, real(esize-1,dp)/2.0_dp /) + pos = (/ real(esize-1,dp)/2.0_dp, -10.0_dp**(-2.0_dp), real(esize-1,dp)/2.0_dp /) case(3) - pos = (/ (esize-1)+10.0_dp**-2.0_dp, real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp /) + pos = (/ (esize-1)+10.0_dp**(-2.0_dp), real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp /) case(4) - pos = (/ real(esize-1,dp)/2.0_dp, (esize-1)+10.0_dp**-2.0_dp, real(esize-1,dp)/2.0_dp /) + pos = (/ real(esize-1,dp)/2.0_dp, (esize-1)+10.0_dp**(-2.0_dp), real(esize-1,dp)/2.0_dp /) case(5) - pos = (/ -10.0_dp**-2.0_dp, real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp /) + pos = (/ -10.0_dp**(-2.0_dp), real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp /) case(6) - pos = (/ real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp, (esize-1)+10.0_dp**-2.0_dp /) + pos = (/ real(esize-1,dp)/2.0_dp, real(esize-1,dp)/2.0_dp, (esize-1)+10.0_dp**(-2.0_dp) /) end select !Now transform it to real space and adjust it to the position of the element in the first node. diff --git a/src/mode_create.f90 b/src/mode_create.f90 index bcec2d5..6f1ca28 100644 --- a/src/mode_create.f90 +++ b/src/mode_create.f90 @@ -135,7 +135,7 @@ module mode_create case('bcc') call build_with_rhomb(box_lat_vert, bcc_mat) case default - print *, "Element type ", trim(adjustl(element_type)), " not accepted in mode create, please specify a supported ", & + print *, "Element type ", trim(adjustl(element_type)), " not accepted in mode create, please specify a supported ",& "element type" stop 3 end select diff --git a/src/opt_group.f90 b/src/opt_group.f90 index 855e04e..0956677 100644 --- a/src/opt_group.f90 +++ b/src/opt_group.f90 @@ -300,7 +300,7 @@ module opt_group case('elements','element') if (group_ele_num > 0) then - print *, "Elements specifier used more than once in group id command with type both, either use type ", & + print *, "Elements specifier used more than once in group id command with type both, either use type ",& "elements or include atoms identifier" stop 3 @@ -824,7 +824,8 @@ module opt_group !Add the element, for the sbox we just set it to the same sbox that we get the orientation !from. In this case it is from the sbox of the first atom in the group. new_ele = new_ele+1 - call add_element(0,remesh_ele_type, working_esize, ilat, sbox_atom(atom_index(1)),r_new_node) + call add_element(0,remesh_ele_type, working_esize, ilat, & + sbox_atom(atom_index(1)),r_new_node) end if end if