From c5213c2a8a16053c0f3c6494f05cb944d36f3d92 Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Mon, 6 Mar 2023 03:26:13 -0700 Subject: [PATCH] Cleaned up and renamed module --- PA003/Makefile | 23 ++++++++++++---------- PA003/gaussian_elimination.f90 | 23 +++++++++++++++++++++- PA003/{mymodule.f90 => string_to_real.f90} | 4 ++-- 3 files changed, 37 insertions(+), 13 deletions(-) rename PA003/{mymodule.f90 => string_to_real.f90} (96%) diff --git a/PA003/Makefile b/PA003/Makefile index 866620c..b8b6906 100644 --- a/PA003/Makefile +++ b/PA003/Makefile @@ -1,24 +1,27 @@ FC = gfortran -std=gnu SRC = gaussian_elimination.f90 EXEC = gaussian_elimination -MODULE = mymodule.mod -MODF = mymodule.f90 +MODULE = string_to_real.mod +MODF = string_to_real.f90 RM = rm -f +OBJMAIN = gaussian_elimination.o +OBJMOD = string_to_real.o + +# Variables so its easy to make changes if I need to (it ended up being helpful) all: $(EXEC) -$(EXEC): $(SRC) $(MODULE) - $(FC) -c $(SRC) - gfortran mymodule.o gaussian_elimination.o -o gaussian_elimination - # $(FC) -o $(EXEC) $(SRC) +$(EXEC): $(SRC) $(MODULE) $(OBJMOD) $(OBJMAIN) + $(FC) $(OBJMOD) $(OBJMAIN) -o $(EXEC) +$(OBJMAIN): $(SRC) + $(FC) -c $(SRC) $(MODULE): $(MODF) $(FC) -c $(MODF) clean: - $(RM) *.o *.mod + $(RM) $(OBJMAIN) $(OBJMOD) $(MODULE) $(EXEC) -test: clean gaussian_elimination - # ./gaussian_elimination 3 4 1 2 3 4 5 6 7 8 9 10 11 12 - ./gaussian_elimination 3 4 "matrix.txt" +test: clean $(EXEC) + ./$(EXEC) 3 4 "matrix.txt" diff --git a/PA003/gaussian_elimination.f90 b/PA003/gaussian_elimination.f90 index 2745c54..ec4218d 100644 --- a/PA003/gaussian_elimination.f90 +++ b/PA003/gaussian_elimination.f90 @@ -1,7 +1,28 @@ +! Ziad Arafat +! 2023-03-06 + +! The performance of compiled and interpreted languages has been a topic of +! interest in programming languages research for decades. While compiled languages +! are generally known for their faster runtime performance, interpreted languages +! offer advantages in terms of ease of use and portability. In this experiment, +! we aimed to explore the practical performance of compiled and interpreted +! languages in implementing Gaussian elimination with back substitution, a widely +! used numerical algorithm. We implemented the algorithm in Python and FORTRAN, +! and tested their runtime performance on matrices of varying size, with and +! without the use of numpy. The experiment provides insights into the practical +! trade-offs between compiled and interpreted languages in the context of +! numerical algorithms. + +! This program takes the height and width of the matrix as input. +! It also takes a filename for a file containing the items in the matrix on one +! line separated by spaces. They must be floats. + +! Usage: ./gaussian_elimination height width filename + program gaussian_elimination ! Module with a function for reading a string of floats - use mymodule + use string_to_real implicit none integer :: i, j, n, m, index_of_input, s diff --git a/PA003/mymodule.f90 b/PA003/string_to_real.f90 similarity index 96% rename from PA003/mymodule.f90 rename to PA003/string_to_real.f90 index 5cd14a7..2efce28 100644 --- a/PA003/mymodule.f90 +++ b/PA003/string_to_real.f90 @@ -1,4 +1,4 @@ -module mymodule +module string_to_real implicit none ! Define the string_to_real_array function @@ -37,5 +37,5 @@ pure function string_to_real_array(str, n) result(arr) end function string_to_real_array -end module mymodule +end module string_to_real