diff --git a/src/Makefile b/src/Makefile index 2068b93..158d9db 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,53 +1,49 @@ -FC=gfortran +.SUFFIXES: .c .f .f90 .F90 .o +.DEFAULT_GOAL := all -#Ifort flags -#FFLAGS=-mcmodel=large -g -O0 -stand f08 -fpe0 -traceback -check bounds,uninit -warn all -implicitnone -no-wrap-margin -heap-arrays +FC=mpif90 +FFLAGS=-Wall -mcmodel=large -O0 -g -fbacktrace -fcheck=all -ffpe-trap=invalid,zero,overflow,underflow,denormal -#FFLAGS=-mcmodel=large -Ofast -no-wrap-margin -heap-arrays +OBJDIR=obj +SRCS := $(wildcard *.f90) +OBJECTS := $(addprefix $(OBJDIR)/,$(SRCS:%.f90=%.o)) -#gfortran flags -FFLAGS=-mcmodel=large -O3 -g -#FFLAGS=-mcmodel=large -O0 -g -fbacktrace -fcheck=all -MODES=mode_create.o mode_merge.o mode_convert.o mode_metric.o mode_calc.o -OPTIONS=opt_disl.o opt_group.o opt_orient.o opt_delete.o opt_deform.o opt_redef_box.o opt_slip_plane.o -OBJECTS=main.o elements.o io.o subroutines.o functions.o atoms.o call_mode.o box.o neighbors.o $(MODES) $(OPTIONS) call_option.o sorts.o -.SUFFIXES: -.SUFFIXES: .c .f .f90 .F90 .o +#----------------- DEPENDENCIES -----------------# +# GENERATED USING https://github.com/ZedThree/fort_depend.py **requires python3** +# > pip install fortdepend +# > fortdepend -o Makefile.dep -i mpi -b obj/ +include Makefile.dep + +#----------------- DEFAULTS -----------------# +all: cacmb -cacmb: $(OBJECTS) - $(FC) $(FFLAGS) $(OBJECTS) parameters.o -o $@ +.PHONY: deps +cacmb: $(OBJECTS) $(OBJDIR)/main.o + $(FC) $(FFLAGS) $(OBJECTS) -o $@ + +$(OBJDIR)/%.o: %.f90 + @mkdir -p $(@D) + $(FC) $(FFLAGS) -c -o $@ $< -J$(OBJDIR) .f90.o: $(FC) $(FFLAGS) -c $< + +deps: + @fortdepend -o Makefile.dep -i mpi -b obj -w + +#----------------- CLEAN UP -----------------# + .PHONY: clean -clean: - $(RM) cacmb *.o *.mod *genmod* - -testfuncs: testfuncs.o functions.o subroutines.o - $(FC) testfuncs.o functions.o subroutines.o box.o elements.o -o $@ - -.PHONY: cleantest -cleantest: - $(RM) testfuncs testfuncs.o - -.PHONY: test -test: testfuncs - ./testfuncs - -.PHONY: install -install: cacmb - cp ./cacmb /usr/local/bin - -$(OBJECTS) : parameters.o -atoms.o subroutines.o testfuncs.o box.o : functions.o -main.o io.o $(MODES) $(OPTIONS) : elements.o -call_mode.o : $(MODES) -call_option.o : $(OPTIONS) -elements.o : sorts.o -$(MODES) $(OPTIONS) subroutines.o io.o : atoms.o box.o -$(MODES) main.o : io.o -testfuncs.o elements.o mode_create.o $(OPTIONS) $(MODES): subroutines.o -opt_delete.o mode_metric.o : neighbors.o +clean: + $(RM) *.mod *.o + $(RM) $(OBJDIR)/*.mod $(OBJDIR)/*.o CAC + @$(RM) -rf obj/ + +.PHONY: clean-all +clean-all: clean + +# DEBUGGING VARIABLE PRINT +print-% : ; @echo $* = $($*) diff --git a/src/Makefile.dep b/src/Makefile.dep new file mode 100644 index 0000000..55f461d --- /dev/null +++ b/src/Makefile.dep @@ -0,0 +1,175 @@ +# This file is generated automatically. DO NOT EDIT! + +obj/main : \ + obj/atoms.o \ + obj/box.o \ + obj/caller.o \ + obj/elements.o \ + obj/functions.o \ + obj/io.o \ + obj/main.o \ + obj/mode_calc.o \ + obj/mode_check.o \ + obj/mode_convert.o \ + obj/mode_create.o \ + obj/mode_merge.o \ + obj/mode_metric.o \ + obj/neighbors.o \ + obj/opt_deform.o \ + obj/opt_delete.o \ + obj/opt_disl.o \ + obj/opt_group.o \ + obj/opt_orient.o \ + obj/opt_redef_box.o \ + obj/opt_slip_plane.o \ + obj/parameters.o \ + obj/sorts.o \ + obj/subroutines.o + +obj/atoms.o : \ + obj/functions.o \ + obj/parameters.o + +obj/box.o : \ + obj/functions.o \ + obj/parameters.o + +obj/caller.o : \ + obj/box.o \ + obj/mode_calc.o \ + obj/mode_check.o \ + obj/mode_convert.o \ + obj/mode_create.o \ + obj/mode_merge.o \ + obj/mode_metric.o \ + obj/opt_deform.o \ + obj/opt_delete.o \ + obj/opt_disl.o \ + obj/opt_group.o \ + obj/opt_orient.o \ + obj/opt_redef_box.o \ + obj/opt_slip_plane.o \ + obj/parameters.o + +obj/elements.o : \ + obj/box.o \ + obj/functions.o \ + obj/parameters.o \ + obj/sorts.o \ + obj/subroutines.o + +obj/functions.o : \ + obj/parameters.o + +obj/io.o : \ + obj/atoms.o \ + obj/box.o \ + obj/elements.o \ + obj/parameters.o + +obj/main.o : \ + obj/caller.o \ + obj/elements.o \ + obj/io.o \ + obj/parameters.o + +obj/mode_calc.o : \ + obj/box.o \ + obj/elements.o \ + obj/io.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/mode_check.o : \ + obj/atoms.o \ + obj/box.o \ + obj/elements.o \ + obj/functions.o \ + obj/io.o \ + obj/neighbors.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/mode_convert.o : \ + obj/box.o \ + obj/elements.o \ + obj/io.o \ + obj/parameters.o + +obj/mode_create.o : \ + obj/atoms.o \ + obj/box.o \ + obj/elements.o \ + obj/io.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/mode_merge.o : \ + obj/atoms.o \ + obj/elements.o \ + obj/io.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/mode_metric.o : \ + obj/elements.o \ + obj/io.o \ + obj/neighbors.o \ + obj/parameters.o + +obj/neighbors.o : \ + obj/elements.o \ + obj/functions.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_deform.o : \ + obj/box.o \ + obj/elements.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_delete.o : \ + obj/elements.o \ + obj/neighbors.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_disl.o : \ + obj/box.o \ + obj/elements.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_group.o : \ + obj/box.o \ + obj/elements.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_orient.o : \ + obj/box.o \ + obj/elements.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/opt_redef_box.o : \ + obj/box.o \ + obj/elements.o \ + obj/subroutines.o + +obj/opt_slip_plane.o : \ + obj/elements.o \ + obj/functions.o \ + obj/parameters.o \ + obj/subroutines.o + +obj/parameters.o : + +obj/sorts.o : \ + obj/parameters.o + +obj/subroutines.o : \ + obj/box.o \ + obj/functions.o \ + obj/parameters.o diff --git a/src/call_mode.f90 b/src/call_mode.f90 deleted file mode 100644 index b933751..0000000 --- a/src/call_mode.f90 +++ /dev/null @@ -1,34 +0,0 @@ -subroutine call_mode(arg_pos) - !This code is used to parse the command line argument for the mode information and calls the required - !mode module. - - use mode_create - use mode_convert - use mode_merge - use mode_metric - use mode_calc - use parameters - - implicit none - - integer, intent(out) :: arg_pos - - select case(mode) - case('--create') - call create(arg_pos) - case('--convert') - call convert(arg_pos) - case('--merge') - call merge(arg_pos) - case('--metric') - call metric(arg_pos) - case('--calc') - call calc(arg_pos) - case default - print *, "Mode ", trim(adjustl(mode)), " currently not accepted. Please check documentation for ", & - "accepted modes and rerun." - - stop 3 - - end select -end subroutine call_mode diff --git a/src/call_option.f90 b/src/call_option.f90 deleted file mode 100644 index dd8abc9..0000000 --- a/src/call_option.f90 +++ /dev/null @@ -1,53 +0,0 @@ -subroutine call_option(option, arg_pos) - use parameters - use opt_disl - use opt_group - use opt_orient - use opt_deform - use opt_delete - use opt_redef_box - use opt_slip_plane - use box - implicit none - - integer, intent(inout) :: arg_pos - character(len=100), intent(in) :: option - - select case(trim(adjustl(option))) - case('-disl','-dislgen', '-disloop','-vacancydisloop') - call dislocation(option, arg_pos) - case('-group') - call group(arg_pos) - case('-ow') - arg_pos = arg_pos + 1 - case('-wrap') - arg_pos = arg_pos + 1 - case('-orient') - call orient(arg_pos) - case('-unorient') - call unorient - arg_pos = arg_pos + 1 - case('-boundary') - arg_pos=arg_pos+1 - call get_command_argument(arg_pos, box_bc) - arg_pos=arg_pos+1 - bound_called = .true. - case('-sbox_ori') - call sbox_ori(arg_pos) - case('-deform') - call deform(arg_pos) - case('-delete') - call run_delete(arg_pos) - case('-set_cac') - arg_pos=arg_pos +3 - case('-set_types') - arg_pos = arg_pos + 2 + atom_types - case('-redef_box') - call redef_box(arg_pos) - case('-slip_plane') - call run_slip_plane(arg_pos) - case default - print *, 'Option ', trim(adjustl(option)), ' is not currently accepted.' - stop 3 - end select -end subroutine call_option diff --git a/src/caller.f90 b/src/caller.f90 new file mode 100644 index 0000000..df29501 --- /dev/null +++ b/src/caller.f90 @@ -0,0 +1,91 @@ +module caller + !this module just calls modes and options + + use mode_create + use mode_convert + use mode_merge + use mode_metric + use mode_calc + use parameters + use opt_disl + use opt_group + use opt_orient + use opt_deform + use opt_delete + use opt_redef_box + use opt_slip_plane + use box + + + implicit none + public + contains + subroutine call_mode(arg_pos) + !This code is used to parse the command line argument for the mode information and calls the required + !mode module. + + integer, intent(out) :: arg_pos + + select case(mode) + case('--create') + call create(arg_pos) + case('--convert') + call convert(arg_pos) + case('--merge') + call merge(arg_pos) + case('--metric') + call metric(arg_pos) + case('--calc') + call calc(arg_pos) + case default + print *, "Mode ", trim(adjustl(mode)), " currently not accepted. Please check documentation for ", & + "accepted modes and rerun." + + stop 3 + end select + end subroutine call_mode + + subroutine call_option(option, arg_pos) + integer, intent(inout) :: arg_pos + character(len=100), intent(in) :: option + + select case(trim(adjustl(option))) + case('-disl','-dislgen', '-disloop','-vacancydisloop') + call dislocation(option, arg_pos) + case('-group') + call group(arg_pos) + case('-ow') + arg_pos = arg_pos + 1 + case('-wrap') + arg_pos = arg_pos + 1 + case('-orient') + call orient_opt(arg_pos) + case('-unorient') + call unorient + arg_pos = arg_pos + 1 + case('-boundary') + arg_pos=arg_pos+1 + call get_command_argument(arg_pos, box_bc) + arg_pos=arg_pos+1 + bound_called = .true. + case('-sbox_ori') + call sbox_ori(arg_pos) + case('-deform') + call deform(arg_pos) + case('-delete') + call run_delete(arg_pos) + case('-set_cac') + arg_pos=arg_pos +3 + case('-set_types') + arg_pos = arg_pos + 3 + atom_types + case('-redef_box') + call redef_box(arg_pos) + case('-slip_plane') + call run_slip_plane(arg_pos) + case default + print *, 'Option ', trim(adjustl(option)), ' is not currently accepted.' + stop 3 + end select + end subroutine call_option + +end module caller diff --git a/src/main.f90 b/src/main.f90 index d73270f..e508ece 100644 --- a/src/main.f90 +++ b/src/main.f90 @@ -15,6 +15,7 @@ program main use parameters use elements use io + use caller integer :: i, end_mode_arg, arg_num, arg_pos diff --git a/src/opt_orient.f90 b/src/opt_orient.f90 index e60049b..fd42cb1 100644 --- a/src/opt_orient.f90 +++ b/src/opt_orient.f90 @@ -16,7 +16,7 @@ module opt_orient public contains - subroutine orient(arg_pos) + subroutine orient_opt(arg_pos) integer, intent(inout) :: arg_pos @@ -82,7 +82,7 @@ module opt_orient end do call def_new_box - end subroutine orient + end subroutine orient_opt subroutine parse_orient(arg_pos) !This parses the orient option