Exercise_1/0000755€í4H€L¨x 0000000000011462026462014645 5ustar tcluneNDC\domain usersExercise_1/1-A/0000755€í4H€L¨x 0000000000011462016061015155 5ustar tcluneNDC\domain usersExercise_1/1-A/GNUmakefile0000644€í4H€L¨x 0000000047011462015125017230 0ustar tcluneNDC\domain usersSRC_DIR = src TESTS_DIR = tests LIB_DIR = lib MOD_DIR = mod .PHONY= all all: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ tests: all clean: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ distclean: clean $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ rm -rf $(LIB_DIR) $(MOD_DIR) Exercise_1/1-A/src/0000755€í4H€L¨x 0000000000011462016044015745 5ustar tcluneNDC\domain usersExercise_1/1-A/src/GNUmakefile0000644€í4H€L¨x 0000000077711462015125020031 0ustar tcluneNDC\domain usersROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod LIB = libsuminverse.a MOD = suminverse_mod.mod F90 ?= ifort F90FLAGS += -I. -I$(MOD_DIR) SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) .PHONY= all all: $(LIB) tests tests: mkdir -p $(LIB_DIR) mkdir -p $(MOD_DIR) cp $(LIB) $(LIB_DIR)/. cp $(MOD) $(MOD_DIR)/. $(LIB): $(OBJS) ar -cr $@ $? %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(LIB) $(RM) *.mod distclean: clean $(RM) $(LIB_DIR)/$(LIB) $(MOD_DIR)/$(MOD) Exercise_1/1-A/src/SumInverse_mod.F900000644€í4H€L¨x 0000000035011462015277021171 0ustar tcluneNDC\domain usersmodule SumInverse_mod implicit none private public :: sumInverse contains real function sumInverse(array) real, intent(in) :: array(:) sumInverse = -1. end function sumInverse end module SumInverse_mod Exercise_1/1-A/tests/0000755€í4H€L¨x 0000000000011462022143016315 5ustar tcluneNDC\domain usersExercise_1/1-A/tests/GNUmakefile0000644€í4H€L¨x 0000000163411462016406020400 0ustar tcluneNDC\domain users# Check for the PFUNIT environment variable ifndef PFUNIT $(error The environment variable "PFUNIT" must be given a value which is the \ path for the installation of pFUnit.) endif ROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod F90 ?= ifort PFUNIT_LIBDIR ?=$(PFUNIT)/lib PFUNIT_INCDIR ?=$(PFUNIT)/include PFUNIT_MODDIR ?=$(PFUNIT)/mod PFUNIT_BINDIR ?=$(PFUNIT)/bin F90FLAGS += -I. -I$(MOD_DIR) F90FLAGS += -I$(PFUNIT_MODDIR) LDFLAGS += -L$(LIB_DIR) -lsuminverse LDFLAGS += -L$(PFUNIT_LIBDIR) -lpfunit SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) EXECUTABLE = test.x COMMAND = ./$(EXECUTABLE) .PHONY= all all: $(EXECUTABLE) tests tests: @$(COMMAND) VPATH += ../src $(EXECUTABLE): $(OBJS) libsuminverse.a $(F90) $(OBJS) -o $@ $(LDFLAGS) %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(RM) *.mod distclean: clean $(RM) $(EXECUTABLE) TestDriver.o: TestSumInverse_mod.o Exercise_1/1-A/tests/TestDriver.F900000644€í4H€L¨x 0000000117711462015341020700 0ustar tcluneNDC\domain usersprogram TestDriver use pFUnit use TestSumInverse_mod implicit none type (TestSuite_type) :: suite type (TestResult_type) :: result character(len=100) :: summary_statement call pFUnit_init() ! Build suite from test procedures: suite = TestSuite('Sum Inverse tests') call add(suite,TestCase1Step('testSumInverseOneElement',testSumInverseOneElement)) result = newTestResult(mode=MODE_USE_STDOUT) call Run(suite,result) summary_statement = Summary(result) print* print *, trim(summary_statement) call clean(result) call clean(suite) call pFUnit_finalize() end program TestDriver Exercise_1/1-A/tests/TestSumInverse_mod.F900000644€í4H€L¨x 0000000057711462020353022406 0ustar tcluneNDC\domain usersmodule TestSumInverse_mod use pFUnit, only : assertEqual use SumInverse_mod implicit none public :: testSumInverseOneElement contains subroutine testSumInverseOneElement() integer, parameter :: N = 1 real :: array(N) array(1) = 1. call assertEqual(1., sumInverse(array)) end subroutine testSumInverseOneElement end module TestSumInverse_mod Exercise_1/1-B/0000755€í4H€L¨x 0000000000011462020767015166 5ustar tcluneNDC\domain usersExercise_1/1-B/GNUmakefile0000644€í4H€L¨x 0000000047011462016073017234 0ustar tcluneNDC\domain usersSRC_DIR = src TESTS_DIR = tests LIB_DIR = lib MOD_DIR = mod .PHONY= all all: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ tests: all clean: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ distclean: clean $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ rm -rf $(LIB_DIR) $(MOD_DIR) Exercise_1/1-B/src/0000755€í4H€L¨x 0000000000011462022205015742 5ustar tcluneNDC\domain usersExercise_1/1-B/src/GNUmakefile0000644€í4H€L¨x 0000000077711462016073020035 0ustar tcluneNDC\domain usersROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod LIB = libsuminverse.a MOD = suminverse_mod.mod F90 ?= ifort F90FLAGS += -I. -I$(MOD_DIR) SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) .PHONY= all all: $(LIB) tests tests: mkdir -p $(LIB_DIR) mkdir -p $(MOD_DIR) cp $(LIB) $(LIB_DIR)/. cp $(MOD) $(MOD_DIR)/. $(LIB): $(OBJS) ar -cr $@ $? %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(LIB) $(RM) *.mod distclean: clean $(RM) $(LIB_DIR)/$(LIB) $(MOD_DIR)/$(MOD) Exercise_1/1-B/src/SumInverse_mod.F900000644€í4H€L¨x 0000000035011462016231021161 0ustar tcluneNDC\domain usersmodule SumInverse_mod implicit none private public :: sumInverse contains real function sumInverse(array) real, intent(in) :: array(:) sumInverse = +1. end function sumInverse end module SumInverse_mod Exercise_1/1-B/tests/0000755€í4H€L¨x 0000000000011462022205016315 5ustar tcluneNDC\domain usersExercise_1/1-B/tests/GNUmakefile0000644€í4H€L¨x 0000000163411462016321020375 0ustar tcluneNDC\domain users# Check for the PFUNIT environment variable ifndef PFUNIT $(error The environment variable "PFUNIT" must be given a value which is the \ path for the installation of pFUnit.) endif ROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod F90 ?= ifort PFUNIT_LIBDIR ?=$(PFUNIT)/lib PFUNIT_INCDIR ?=$(PFUNIT)/include PFUNIT_MODDIR ?=$(PFUNIT)/mod PFUNIT_BINDIR ?=$(PFUNIT)/bin F90FLAGS += -I. -I$(MOD_DIR) F90FLAGS += -I$(PFUNIT_MODDIR) LDFLAGS += -L$(LIB_DIR) -lsuminverse LDFLAGS += -L$(PFUNIT_LIBDIR) -lpfunit SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) EXECUTABLE = test.x COMMAND = ./$(EXECUTABLE) .PHONY= all all: $(EXECUTABLE) tests tests: @$(COMMAND) VPATH += ../src $(EXECUTABLE): $(OBJS) libsuminverse.a $(F90) $(OBJS) -o $@ $(LDFLAGS) %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(RM) *.mod distclean: clean $(RM) $(EXECUTABLE) TestDriver.o: TestSumInverse_mod.o Exercise_1/1-B/tests/TestDriver.F900000644€í4H€L¨x 0000000117711462016073020704 0ustar tcluneNDC\domain usersprogram TestDriver use pFUnit use TestSumInverse_mod implicit none type (TestSuite_type) :: suite type (TestResult_type) :: result character(len=100) :: summary_statement call pFUnit_init() ! Build suite from test procedures: suite = TestSuite('Sum Inverse tests') call add(suite,TestCase1Step('testSumInverseOneElement',testSumInverseOneElement)) result = newTestResult(mode=MODE_USE_STDOUT) call Run(suite,result) summary_statement = Summary(result) print* print *, trim(summary_statement) call clean(result) call clean(suite) call pFUnit_finalize() end program TestDriver Exercise_1/1-B/tests/TestSumInverse_mod.F900000644€í4H€L¨x 0000000057711462020342022405 0ustar tcluneNDC\domain usersmodule TestSumInverse_mod use pFUnit, only : assertEqual use SumInverse_mod implicit none public :: testSumInverseOneElement contains subroutine testSumInverseOneElement() integer, parameter :: N = 1 real :: array(N) array(1) = 1. call assertEqual(1., sumInverse(array)) end subroutine testSumInverseOneElement end module TestSumInverse_mod Exercise_1/1-C/0000755€í4H€L¨x 0000000000011462020763015163 5ustar tcluneNDC\domain usersExercise_1/1-C/GNUmakefile0000644€í4H€L¨x 0000000047011462017102017227 0ustar tcluneNDC\domain usersSRC_DIR = src TESTS_DIR = tests LIB_DIR = lib MOD_DIR = mod .PHONY= all all: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ tests: all clean: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ distclean: clean $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ rm -rf $(LIB_DIR) $(MOD_DIR) Exercise_1/1-C/src/0000755€í4H€L¨x 0000000000011462022205015743 5ustar tcluneNDC\domain usersExercise_1/1-C/src/GNUmakefile0000644€í4H€L¨x 0000000077711462017102020030 0ustar tcluneNDC\domain usersROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod LIB = libsuminverse.a MOD = suminverse_mod.mod F90 ?= ifort F90FLAGS += -I. -I$(MOD_DIR) SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) .PHONY= all all: $(LIB) tests tests: mkdir -p $(LIB_DIR) mkdir -p $(MOD_DIR) cp $(LIB) $(LIB_DIR)/. cp $(MOD) $(MOD_DIR)/. $(LIB): $(OBJS) ar -cr $@ $? %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(LIB) $(RM) *.mod distclean: clean $(RM) $(LIB_DIR)/$(LIB) $(MOD_DIR)/$(MOD) Exercise_1/1-C/src/SumInverse_mod.F900000644€í4H€L¨x 0000000035711462017470021177 0ustar tcluneNDC\domain usersmodule SumInverse_mod implicit none private public :: sumInverse contains real function sumInverse(array) real, intent(in) :: array(:) sumInverse = 1/array(1) end function sumInverse end module SumInverse_mod Exercise_1/1-C/tests/0000755€í4H€L¨x 0000000000011462022205016316 5ustar tcluneNDC\domain usersExercise_1/1-C/tests/GNUmakefile0000644€í4H€L¨x 0000000163411462017102020374 0ustar tcluneNDC\domain users# Check for the PFUNIT environment variable ifndef PFUNIT $(error The environment variable "PFUNIT" must be given a value which is the \ path for the installation of pFUnit.) endif ROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod F90 ?= ifort PFUNIT_LIBDIR ?=$(PFUNIT)/lib PFUNIT_INCDIR ?=$(PFUNIT)/include PFUNIT_MODDIR ?=$(PFUNIT)/mod PFUNIT_BINDIR ?=$(PFUNIT)/bin F90FLAGS += -I. -I$(MOD_DIR) F90FLAGS += -I$(PFUNIT_MODDIR) LDFLAGS += -L$(LIB_DIR) -lsuminverse LDFLAGS += -L$(PFUNIT_LIBDIR) -lpfunit SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) EXECUTABLE = test.x COMMAND = ./$(EXECUTABLE) .PHONY= all all: $(EXECUTABLE) tests tests: @$(COMMAND) VPATH += ../src $(EXECUTABLE): $(OBJS) libsuminverse.a $(F90) $(OBJS) -o $@ $(LDFLAGS) %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(RM) *.mod distclean: clean $(RM) $(EXECUTABLE) TestDriver.o: TestSumInverse_mod.o Exercise_1/1-C/tests/TestDriver.F900000644€í4H€L¨x 0000000132711462017303020677 0ustar tcluneNDC\domain usersprogram TestDriver use pFUnit use TestSumInverse_mod implicit none type (TestSuite_type) :: suite type (TestResult_type) :: result character(len=100) :: summary_statement call pFUnit_init() ! Build suite from test procedures: suite = TestSuite('Sum Inverse tests') call add(suite,TestCase1Step('testSumInverseOneElement',testSumInverseOneElement)) call add(suite,TestCase1Step('testSumInverseOneElementB',testSumInverseOneElementB)) result = newTestResult(mode=MODE_USE_STDOUT) call Run(suite,result) summary_statement = Summary(result) print* print *, trim(summary_statement) call clean(result) call clean(suite) call pFUnit_finalize() end program TestDriver Exercise_1/1-C/tests/TestSumInverse_mod.F900000644€í4H€L¨x 0000000116211462020324022375 0ustar tcluneNDC\domain usersmodule TestSumInverse_mod use pFUnit, only : assertEqual use SumInverse_mod implicit none public :: testSumInverseOneElement public :: testSumInverseOneElementB contains subroutine testSumInverseOneElement() integer, parameter :: N = 1 real :: array(N) array(1) = 1. call assertEqual(1., sumInverse(array)) end subroutine testSumInverseOneElement subroutine testSumInverseOneElementB() integer, parameter :: N = 1 real :: array(N) array(1) = 0.5 call assertEqual(2., sumInverse(array)) end subroutine testSumInverseOneElementB end module TestSumInverse_mod Exercise_1/1-D/0000755€í4H€L¨x 0000000000011462020744015163 5ustar tcluneNDC\domain usersExercise_1/1-D/GNUmakefile0000644€í4H€L¨x 0000000047011462017505017237 0ustar tcluneNDC\domain usersSRC_DIR = src TESTS_DIR = tests LIB_DIR = lib MOD_DIR = mod .PHONY= all all: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ tests: all clean: $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ distclean: clean $(MAKE) -C $(SRC_DIR) $@ $(MAKE) -C $(TESTS_DIR) $@ rm -rf $(LIB_DIR) $(MOD_DIR) Exercise_1/1-D/src/0000755€í4H€L¨x 0000000000011462022205015744 5ustar tcluneNDC\domain usersExercise_1/1-D/src/GNUmakefile0000644€í4H€L¨x 0000000077711462017505020040 0ustar tcluneNDC\domain usersROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod LIB = libsuminverse.a MOD = suminverse_mod.mod F90 ?= ifort F90FLAGS += -I. -I$(MOD_DIR) SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) .PHONY= all all: $(LIB) tests tests: mkdir -p $(LIB_DIR) mkdir -p $(MOD_DIR) cp $(LIB) $(LIB_DIR)/. cp $(MOD) $(MOD_DIR)/. $(LIB): $(OBJS) ar -cr $@ $? %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(LIB) $(RM) *.mod distclean: clean $(RM) $(LIB_DIR)/$(LIB) $(MOD_DIR)/$(MOD) Exercise_1/1-D/src/SumInverse_mod.F900000644€í4H€L¨x 0000000050711462020542021167 0ustar tcluneNDC\domain usersmodule SumInverse_mod implicit none private public :: sumInverse contains real function sumInverse(array) real, intent(in) :: array(:) integer :: i sumInverse = 0 do i = 1, size(array) sumInverse = sumInverse + 1/array(i) end do end function sumInverse end module SumInverse_mod Exercise_1/1-D/tests/0000755€í4H€L¨x 0000000000011462022205016317 5ustar tcluneNDC\domain usersExercise_1/1-D/tests/GNUmakefile0000644€í4H€L¨x 0000000163411462017505020404 0ustar tcluneNDC\domain users# Check for the PFUNIT environment variable ifndef PFUNIT $(error The environment variable "PFUNIT" must be given a value which is the \ path for the installation of pFUnit.) endif ROOT_DIR = .. LIB_DIR = $(ROOT_DIR)/lib MOD_DIR = $(ROOT_DIR)/mod F90 ?= ifort PFUNIT_LIBDIR ?=$(PFUNIT)/lib PFUNIT_INCDIR ?=$(PFUNIT)/include PFUNIT_MODDIR ?=$(PFUNIT)/mod PFUNIT_BINDIR ?=$(PFUNIT)/bin F90FLAGS += -I. -I$(MOD_DIR) F90FLAGS += -I$(PFUNIT_MODDIR) LDFLAGS += -L$(LIB_DIR) -lsuminverse LDFLAGS += -L$(PFUNIT_LIBDIR) -lpfunit SRC = $(wildcard *.F90) OBJS = $(SRC:.F90=.o) EXECUTABLE = test.x COMMAND = ./$(EXECUTABLE) .PHONY= all all: $(EXECUTABLE) tests tests: @$(COMMAND) VPATH += ../src $(EXECUTABLE): $(OBJS) libsuminverse.a $(F90) $(OBJS) -o $@ $(LDFLAGS) %.o:%.F90 $(F90) -c $(F90FLAGS) $< clean: $(RM) $(OBJS) $(RM) *.mod distclean: clean $(RM) $(EXECUTABLE) TestDriver.o: TestSumInverse_mod.o Exercise_1/1-D/tests/TestDriver.F900000644€í4H€L¨x 0000000144111462020473020677 0ustar tcluneNDC\domain usersprogram TestDriver use pFUnit use TestSumInverse_mod implicit none type (TestSuite_type) :: suite type (TestResult_type) :: result character(len=100) :: summary_statement call pFUnit_init() ! Build suite from test procedures: suite = TestSuite('Sum Inverse tests') call add(suite,TestCase1Step('testSumInverseOneElement',testSumInverseOneElement)) call add(suite,TestCase1Step('testSumInverseOneElementB',testSumInverseOneElementB)) call add(suite,TestCase1Step('testSumInverseMany',testSumInverseMany)) result = newTestResult(mode=MODE_USE_STDOUT) call Run(suite,result) summary_statement = Summary(result) print* print *, trim(summary_statement) call clean(result) call clean(suite) call pFUnit_finalize() end program TestDriver Exercise_1/1-D/tests/TestSumInverse_mod.F900000644€í4H€L¨x 0000000156211462020451022403 0ustar tcluneNDC\domain usersmodule TestSumInverse_mod use pFUnit, only : assertEqual use SumInverse_mod implicit none public :: testSumInverseOneElement public :: testSumInverseOneElementB public :: testSumInverseMany contains subroutine testSumInverseOneElement() integer, parameter :: N = 1 real :: array(N) array(1) = 1. call assertEqual(1., sumInverse(array)) end subroutine testSumInverseOneElement subroutine testSumInverseOneElementB() integer, parameter :: N = 1 real :: array(N) array(1) = 0.5 call assertEqual(2., sumInverse(array)) end subroutine testSumInverseOneElementB subroutine testSumInverseMany() integer, parameter :: N = 3 real :: array(N) array = 1. / (/ 2., 3., 5. /) ! test data call assertEqual(2.+3.+5., sumInverse(array)) end subroutine testSumInverseMany end module TestSumInverse_mod Exercise_1/README0000644€í4H€L¨x 0000000531311462026462015527 0ustar tcluneNDC\domain usersExercise 1: Sum Inverse In this exercise you will construct a function which computes the sum of the inverses (reciprocals) of an array of single precision numbers. Be sure that you are logged into "dali", and have loaded the appropriate modules. Also, be sure to set you PFUNIT environment variable: export PFUNIT=/usr/local/other/pFUnit/Intel-11.1.038-Impi-3.2.1.009 Step 1-A: Change directory into ./Exercise_1/1-A. In this directory we have started a project and have added only one test: testSumInverseOneElement() which is currently failing. This very simple test ensures that the sum of the invereses of an array with just one element is merely the inverse of that one element. Build ("make tests") to demonstrate that 1 test is indeed failing, then correct the implementation in src/SumInverse_mod.F90 so that the test will pass. Remember to be minimal and not anticipate the ultimate implementation. Step 1-B: (If you were successful in step 1-A, you can continue from within the same directory. Otherwise, proceed to directory 1-B.) The minimal implementation in step 1-A is unsatisfactory for at least 2 reasons. Of these, the most glaring at the moment is that the implementation will only work for 1 special input value. (But do not forget the test has allowed us to establish a nice clean interface - not a trivial thing in itself.) In this step you will add a 2nd test that still only inputs an array of size 1, but now with a different value. Once you can run that test and get it to fail. Don't forget to "add" the new test in the TestDriver program. Once the test is clearly failing, extend the implementation so that both tests pass. Step 1-C (If you were successful in step 1-B, you can continue from within the same directory. Otherwise, proceed to directory 1-C.) At this stage our implementation can plausibly handle any input array with only one element correctly. If you doubt this, feel free to add a few more tests with different values until you are convinced that the implementation works for this these cases. (Let us ignore for now what do do about division-by-zero possibilities.) For this step, you are to add a new test that computes the sum of the inverses of an array with 3 elements. Choose them to be simple, so that the result is trivial to "see" when someone else reads your test. E.g. {1./2, 1./3, 1./5} with an expected result of 2+3+5. Once the test is "successfully" failing, extend the implementation to pass all the tests. If you are not confident that the routine will work for any arrays (except those with elements equal to zero), feel free to add a few more tests. (Or as a shortcut, just additional assertions within your existing tests.) Directory 1-D has an example solution.