diff --git a/problem1/IRPF90_man/fact.l b/problem1/IRPF90_man/fact.l new file mode 100644 index 0000000..630b304 --- /dev/null +++ b/problem1/IRPF90_man/fact.l @@ -0,0 +1,16 @@ +.TH "IRPF90 entities" l fact "IRPF90 entities" fact +.SH Declaration +.nf +integer, allocatable :: fact (nfact) +.ni +.SH Description +! enter the factors +.SH File +.P +fact.irp.f +.SH Needs +limit +.br +.SH Needed by +sum +.br diff --git a/problem1/IRPF90_man/limit.l b/problem1/IRPF90_man/limit.l new file mode 100644 index 0000000..b5d70f7 --- /dev/null +++ b/problem1/IRPF90_man/limit.l @@ -0,0 +1,16 @@ +.TH "IRPF90 entities" l limit "IRPF90 entities" limit +.SH Declaration +.nf +integer :: limit +integer :: nfact +.ni +.SH Description +! enter limit +.SH File +.P +limit.irp.f +.SH Needed by +fact +.br +sum +.br diff --git a/problem1/IRPF90_man/nfact.l b/problem1/IRPF90_man/nfact.l new file mode 100644 index 0000000..d13a898 --- /dev/null +++ b/problem1/IRPF90_man/nfact.l @@ -0,0 +1,16 @@ +.TH "IRPF90 entities" l nfact "IRPF90 entities" nfact +.SH Declaration +.nf +integer :: limit +integer :: nfact +.ni +.SH Description +! enter limit +.SH File +.P +limit.irp.f +.SH Needed by +fact +.br +sum +.br diff --git a/problem1/IRPF90_man/sum.l b/problem1/IRPF90_man/sum.l new file mode 100644 index 0000000..0c1a7f7 --- /dev/null +++ b/problem1/IRPF90_man/sum.l @@ -0,0 +1,16 @@ +.TH "IRPF90 entities" l sum "IRPF90 entities" sum +.SH Declaration +.nf +integer :: sum +.ni +.SH Description +! calculates the sum of the factors of +! two integers between 1 to limit +.SH File +.P +sum.irp.f +.SH Needs +fact +.br +limit +.br diff --git a/problem1/IRPF90_temp/Makefile b/problem1/IRPF90_temp/Makefile new file mode 100644 index 0000000..4602bb7 --- /dev/null +++ b/problem1/IRPF90_temp/Makefile @@ -0,0 +1,12 @@ +IRPF90 = irpf90 #-a -d +FC = gfortran +FCFLAGS= -O2 + +SRC= +OBJ= +LIB= + +include irpf90.make + +irpf90.make: $(wildcard *.irp.f) + $(IRPF90) diff --git a/problem1/IRPF90_temp/README.md b/problem1/IRPF90_temp/README.md new file mode 100644 index 0000000..2f685bb --- /dev/null +++ b/problem1/IRPF90_temp/README.md @@ -0,0 +1,7 @@ +PROBLEM 1 +---------- + +* If we list all the natural numbers below 10 that are multiples of 3 or 5, we + get 3, 5, 6 and 9. The sum of these multiples is 23. + + Find the sum of all the multiples of 3 or 5 below 1000. diff --git a/problem1/IRPF90_temp/fact.irp.F90 b/problem1/IRPF90_temp/fact.irp.F90 new file mode 100644 index 0000000..6fdae35 --- /dev/null +++ b/problem1/IRPF90_temp/fact.irp.F90 @@ -0,0 +1,62 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +subroutine provide_fact + use limit_mod + use fact_mod + implicit none + character*(12) :: irp_here = 'provide_fact' + integer :: irp_err + logical :: irp_dimensions_OK + if (.not.limit_is_built) then + call provide_limit + endif + if (allocated (fact) ) then + irp_dimensions_OK = .True. + irp_dimensions_OK = irp_dimensions_OK.AND.(SIZE(fact,1)==(nfact)) + if (.not.irp_dimensions_OK) then + deallocate(fact,stat=irp_err) + if (irp_err /= 0) then + print *, irp_here//': Deallocation failed: fact' + print *, ' size: (nfact)' + endif + if ((nfact>0)) then + allocate(fact(nfact),stat=irp_err) + if (irp_err /= 0) then + print *, irp_here//': Allocation failed: fact' + print *, ' size: (nfact)' + endif + endif + endif + else + if ((nfact>0)) then + allocate(fact(nfact),stat=irp_err) + if (irp_err /= 0) then + print *, irp_here//': Allocation failed: fact' + print *, ' size: (nfact)' + endif + endif + endif + if (.not.fact_is_built) then + call bld_fact + fact_is_built = .True. + + endif +end subroutine provide_fact + +subroutine bld_fact + use limit_mod + use fact_mod + implicit none ! fact.irp.f: 6 + character*(4) :: irp_here = 'fact' ! fact.irp.f: 1 + integer :: i ! fact.irp.f: 7 + write(6,*)'enter',nfact,'integers' ! fact.irp.f: 9 + do i=1,nfact ! fact.irp.f: 10 + read(5,*)fact(i) ! fact.irp.f: 11 + enddo ! fact.irp.f: 12 +end subroutine bld_fact diff --git a/problem1/IRPF90_temp/fact.irp.f b/problem1/IRPF90_temp/fact.irp.f new file mode 100644 index 0000000..9d6f82a --- /dev/null +++ b/problem1/IRPF90_temp/fact.irp.f @@ -0,0 +1,14 @@ +BEGIN_PROVIDER [integer, fact, (nfact)] + BEGIN_DOC + ! enter the factors + END_DOC + + implicit none + integer :: i + + write(6,*)'enter',nfact,'integers' + do i=1,nfact + read(5,*)fact(i) + enddo + +END_PROVIDER diff --git a/problem1/IRPF90_temp/fact.irp.module.F90 b/problem1/IRPF90_temp/fact.irp.module.F90 new file mode 100644 index 0000000..33916a2 --- /dev/null +++ b/problem1/IRPF90_temp/fact.irp.module.F90 @@ -0,0 +1,12 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +module fact_mod + integer, allocatable :: fact (:) + logical :: fact_is_built = .False. +end module fact_mod diff --git a/problem1/IRPF90_temp/fact.irp.module.o b/problem1/IRPF90_temp/fact.irp.module.o new file mode 100644 index 0000000..382bc0c Binary files /dev/null and b/problem1/IRPF90_temp/fact.irp.module.o differ diff --git a/problem1/IRPF90_temp/fact.irp.o b/problem1/IRPF90_temp/fact.irp.o new file mode 100644 index 0000000..8609381 Binary files /dev/null and b/problem1/IRPF90_temp/fact.irp.o differ diff --git a/problem1/IRPF90_temp/fact_mod.mod b/problem1/IRPF90_temp/fact_mod.mod new file mode 100644 index 0000000..f7b4e9a --- /dev/null +++ b/problem1/IRPF90_temp/fact_mod.mod @@ -0,0 +1,28 @@ +GFORTRAN module version '9' created from IRPF90_temp/fact.irp.module.F90 +MD5:39812aca873c55fd15ab2356e3e48575 -- If you edit this, you'll get what you deserve. + +(() () () () () () () () () () () () () () () () () () () () () () () () +() () ()) + +() + +() + +() + +() + +() + +(2 'fact' 'fact_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN +IMPLICIT-SAVE 0 0 ALLOCATABLE DIMENSION) (INTEGER 4 0 0 0 INTEGER ()) 0 +0 () (1 0 DEFERRED () ()) 0 () () () 0 0) +3 'fact_is_built' 'fact_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (LOGICAL 4 0 0 0 LOGICAL ()) 0 0 () () 0 () () +() 0 0) +4 'fact_mod' 'fact_mod' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 +0) +) + +('fact' 0 2 'fact_is_built' 0 3 'fact_mod' 0 4) diff --git a/problem1/IRPF90_temp/irp_stack.irp.F90 b/problem1/IRPF90_temp/irp_stack.irp.F90 new file mode 100644 index 0000000..5869495 --- /dev/null +++ b/problem1/IRPF90_temp/irp_stack.irp.F90 @@ -0,0 +1,38 @@ + +module irp_stack_mod + integer, parameter :: STACKMAX=1000 + character*(128),allocatable :: irp_stack(:,:) + double precision,allocatable :: irp_cpu(:,:) + integer,allocatable :: stack_index(:) + logical :: alloc = .False. + character*(128) :: white = '' +end module + +subroutine irp_enter(irp_where) + use irp_stack_mod + integer :: ithread + integer :: nthread + character*(*) :: irp_where + +!$OMP CRITICAL + ithread = 0 + nthread = 1 + +!$OMP END CRITICAL + + +end subroutine + +subroutine irp_leave (irp_where) + use irp_stack_mod + character*(*) :: irp_where + integer :: ithread + double precision :: cpu + +!$OMP CRITICAL + ithread = 0 + + +!$OMP END CRITICAL +end subroutine + diff --git a/problem1/IRPF90_temp/irp_stack.irp.o b/problem1/IRPF90_temp/irp_stack.irp.o new file mode 100644 index 0000000..9b8cb95 Binary files /dev/null and b/problem1/IRPF90_temp/irp_stack.irp.o differ diff --git a/problem1/IRPF90_temp/irp_stack_mod.mod b/problem1/IRPF90_temp/irp_stack_mod.mod new file mode 100644 index 0000000..4c7ba10 --- /dev/null +++ b/problem1/IRPF90_temp/irp_stack_mod.mod @@ -0,0 +1,42 @@ +GFORTRAN module version '9' created from IRPF90_temp/irp_stack.irp.F90 +MD5:f65ae2717456353521ba97c4b0936c36 -- If you edit this, you'll get what you deserve. + +(() () () () () () () () () () () () () () () () () () () () () () () () +() () ()) + +() + +() + +() + +() + +() + +(2 'alloc' 'irp_stack_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (LOGICAL 4 0 0 0 LOGICAL ()) 0 0 () () 0 () () +() 0 0) +3 'irp_cpu' 'irp_stack_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0 ALLOCATABLE DIMENSION) (REAL 8 0 0 0 REAL ()) +0 0 () (2 0 DEFERRED () () () ()) 0 () () () 0 0) +4 'irp_stack' 'irp_stack_mod' '' 1 ((VARIABLE UNKNOWN-INTENT +UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0 ALLOCATABLE DIMENSION) ( +CHARACTER 1 0 0 0 CHARACTER ((CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 +'128'))) 0 0 () (2 0 DEFERRED () () () ()) 0 () () () 0 0) +5 'irp_stack_mod' 'irp_stack_mod' '' 1 ((MODULE UNKNOWN-INTENT +UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () +0 () () () 0 0) +6 'stack_index' 'irp_stack_mod' '' 1 ((VARIABLE UNKNOWN-INTENT +UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0 ALLOCATABLE DIMENSION) (INTEGER 4 +0 0 0 INTEGER ()) 0 0 () (1 0 DEFERRED () ()) 0 () () () 0 0) +7 'stackmax' 'irp_stack_mod' '' 1 ((PARAMETER UNKNOWN-INTENT +UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0) (INTEGER 4 0 0 0 INTEGER ()) 0 0 +() (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1000') () 0 () () () 0 0) +8 'white' 'irp_stack_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (CHARACTER 1 0 0 0 CHARACTER ((CONSTANT ( +INTEGER 4 0 0 0 INTEGER ()) 0 '128'))) 0 0 () () 0 () () () 0 0) +) + +('alloc' 0 2 'irp_cpu' 0 3 'irp_stack' 0 4 'irp_stack_mod' 0 5 +'stack_index' 0 6 'stackmax' 0 7 'white' 0 8) diff --git a/problem1/IRPF90_temp/irp_touches.irp.F90 b/problem1/IRPF90_temp/irp_touches.irp.F90 new file mode 100644 index 0000000..89f5215 --- /dev/null +++ b/problem1/IRPF90_temp/irp_touches.irp.F90 @@ -0,0 +1,9 @@ +subroutine irp_finalize_367124922 + use fact_mod + use sum_mod + use limit_mod + if (allocated(fact)) then + fact_is_built = .False. + deallocate(fact) + endif +end diff --git a/problem1/IRPF90_temp/irp_touches.irp.o b/problem1/IRPF90_temp/irp_touches.irp.o new file mode 100644 index 0000000..1b96d83 Binary files /dev/null and b/problem1/IRPF90_temp/irp_touches.irp.o differ diff --git a/problem1/IRPF90_temp/irpf90.make b/problem1/IRPF90_temp/irpf90.make new file mode 100644 index 0000000..d4c7de5 --- /dev/null +++ b/problem1/IRPF90_temp/irpf90.make @@ -0,0 +1,43 @@ +SRC += IRPF90_temp/irp_stack.irp.F90 IRPF90_temp/irp_touches.irp.F90 IRPF90_temp/prob1.irp.F90 IRPF90_temp/prob1.irp.module.F90 IRPF90_temp/fact.irp.F90 IRPF90_temp/fact.irp.module.F90 IRPF90_temp/sum.irp.F90 IRPF90_temp/sum.irp.module.F90 IRPF90_temp/limit.irp.F90 IRPF90_temp/limit.irp.module.F90 +OBJ += IRPF90_temp/irp_stack.irp.o IRPF90_temp/fact.irp.o IRPF90_temp/fact.irp.module.o IRPF90_temp/sum.irp.o IRPF90_temp/sum.irp.module.o IRPF90_temp/limit.irp.o IRPF90_temp/limit.irp.module.o +OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(OBJ))) IRPF90_temp/irp_touches.irp.o +ALL = prob1 +ALL_OBJ = prob1.irp.module.o prob1.irp.o +ALL_OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(ALL_OBJ))) +all:$(ALL) + @$(MAKE) -s move +prob1: IRPF90_temp/prob1.irp.o IRPF90_temp/prob1.irp.module.o $(OBJ1) + $(FC) -o $@ IRPF90_temp/$@.irp.o IRPF90_temp/$@.irp.module.o $(OBJ1) $(LIB) + @$(MAKE) -s move +IRPF90_temp/prob1.irp.o: IRPF90_temp/prob1.irp.module.o IRPF90_temp/sum.irp.module.o +IRPF90_temp/fact.irp.o: IRPF90_temp/fact.irp.module.o IRPF90_temp/limit.irp.module.o +IRPF90_temp/sum.irp.o: IRPF90_temp/sum.irp.module.o IRPF90_temp/limit.irp.module.o IRPF90_temp/fact.irp.module.o +IRPF90_temp/limit.irp.o: IRPF90_temp/limit.irp.module.o +IRPF90_temp/irp_touches.irp.o: IRPF90_temp/fact.irp.o IRPF90_temp/fact.irp.o IRPF90_temp/sum.irp.o IRPF90_temp/sum.irp.o IRPF90_temp/limit.irp.o IRPF90_temp/limit.irp.o +IRPF90_temp/%.irp.module.o: IRPF90_temp/%.irp.module.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.module.F90 -o IRPF90_temp/$*.irp.module.o +IRPF90_temp/%.irp.o: IRPF90_temp/%.irp.module.o IRPF90_temp/%.irp.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.F90 -o IRPF90_temp/$*.irp.o +IRPF90_temp/%.irp.o: IRPF90_temp/%.irp.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.F90 -o IRPF90_temp/$*.irp.o +IRPF90_temp/%.o: %.F90 + $(FC) $(FCFLAGS) -c $*.F90 -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.f90 + $(FC) $(FCFLAGS) -c $*.f90 -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.f + $(FC) $(FCFLAGS) -c $*.f -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.F + $(FC) $(FCFLAGS) -c $*.F -o IRPF90_temp/$*.o +IRPF90_temp/%.irp.F90: irpf90.make + +move: + @mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING= + +clean: + rm -rf $(EXE) $(OBJ1) $(ALL_OBJ1) $(ALL) + +veryclean: + - $(MAKE) clean + + - rm -rf IRPF90_temp/ IRPF90_man/ irpf90.make irpf90_variables dist + diff --git a/problem1/IRPF90_temp/irpf90_entities b/problem1/IRPF90_temp/irpf90_entities new file mode 100644 index 0000000..2eb2510 --- /dev/null +++ b/problem1/IRPF90_temp/irpf90_entities @@ -0,0 +1,4 @@ +fact.irp.f : integer, allocatable :: fact (nfact) +limit.irp.f : integer :: limit +limit.irp.f : integer :: nfact +sum.irp.f : integer :: sum diff --git a/problem1/IRPF90_temp/limit.irp.F90 b/problem1/IRPF90_temp/limit.irp.F90 new file mode 100644 index 0000000..0d61371 --- /dev/null +++ b/problem1/IRPF90_temp/limit.irp.F90 @@ -0,0 +1,29 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +subroutine provide_limit + use limit_mod + implicit none + character*(13) :: irp_here = 'provide_limit' + integer :: irp_err + logical :: irp_dimensions_OK + if (.not.limit_is_built) then + call bld_limit + limit_is_built = .True. + + endif +end subroutine provide_limit + +subroutine bld_limit + use limit_mod + character*(5) :: irp_here = 'limit' ! limit.irp.f: 1 + write(6,*)'limit?' ! limit.irp.f: 6 + read(5,*)limit ! limit.irp.f: 7 + write(6,*)'nfact?' ! limit.irp.f: 8 + read(5,*)nfact ! limit.irp.f: 9 +end subroutine bld_limit diff --git a/problem1/IRPF90_temp/limit.irp.f b/problem1/IRPF90_temp/limit.irp.f new file mode 100644 index 0000000..d61342a --- /dev/null +++ b/problem1/IRPF90_temp/limit.irp.f @@ -0,0 +1,11 @@ +BEGIN_PROVIDER [integer, limit] +&BEGIN_PROVIDER [integer, nfact] + BEGIN_DOC + ! enter limit + END_DOC + write(6,*)'limit?' + read(5,*)limit + write(6,*)'nfact?' + read(5,*)nfact + +END_PROVIDER diff --git a/problem1/IRPF90_temp/limit.irp.module.F90 b/problem1/IRPF90_temp/limit.irp.module.F90 new file mode 100644 index 0000000..6d14170 --- /dev/null +++ b/problem1/IRPF90_temp/limit.irp.module.F90 @@ -0,0 +1,13 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +module limit_mod + integer :: limit + logical :: limit_is_built = .False. + integer :: nfact +end module limit_mod diff --git a/problem1/IRPF90_temp/limit.irp.module.o b/problem1/IRPF90_temp/limit.irp.module.o new file mode 100644 index 0000000..7e9170b Binary files /dev/null and b/problem1/IRPF90_temp/limit.irp.module.o differ diff --git a/problem1/IRPF90_temp/limit.irp.o b/problem1/IRPF90_temp/limit.irp.o new file mode 100644 index 0000000..d6f5be3 Binary files /dev/null and b/problem1/IRPF90_temp/limit.irp.o differ diff --git a/problem1/IRPF90_temp/limit_mod.mod b/problem1/IRPF90_temp/limit_mod.mod new file mode 100644 index 0000000..875daa4 --- /dev/null +++ b/problem1/IRPF90_temp/limit_mod.mod @@ -0,0 +1,31 @@ +GFORTRAN module version '9' created from IRPF90_temp/limit.irp.module.F90 +MD5:8353d8a4752d9f18be27e41075631cad -- If you edit this, you'll get what you deserve. + +(() () () () () () () () () () () () () () () () () () () () () () () () +() () ()) + +() + +() + +() + +() + +() + +(2 'limit' 'limit_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () +() 0 0) +3 'limit_is_built' 'limit_mod' '' 1 ((VARIABLE UNKNOWN-INTENT +UNKNOWN-PROC UNKNOWN IMPLICIT-SAVE 0 0) (LOGICAL 4 0 0 0 LOGICAL ()) 0 0 +() () 0 () () () 0 0) +4 'limit_mod' 'limit_mod' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 +0) +5 'nfact' 'limit_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () +() 0 0) +) + +('limit' 0 2 'limit_is_built' 0 3 'limit_mod' 0 4 'nfact' 0 5) diff --git a/problem1/IRPF90_temp/prob1 b/problem1/IRPF90_temp/prob1 new file mode 100644 index 0000000..39f128a Binary files /dev/null and b/problem1/IRPF90_temp/prob1 differ diff --git a/problem1/IRPF90_temp/prob1.irp.F90 b/problem1/IRPF90_temp/prob1.irp.F90 new file mode 100644 index 0000000..c633653 --- /dev/null +++ b/problem1/IRPF90_temp/prob1.irp.F90 @@ -0,0 +1,21 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +program irp_program ! prob1: 0 + call prob1 ! prob1.irp.f: 0 + call irp_finalize_367124922() ! prob1.irp.f: 0 +end program ! prob1.irp.f: 0 +subroutine prob1 ! prob1.irp.f: 1 + use sum_mod + implicit none ! prob1.irp.f: 3 + character*(5) :: irp_here = 'prob1' ! prob1.irp.f: 1 + if (.not.sum_is_built) then + call provide_sum + endif + write(6,*)sum ! prob1.irp.f: 5 +end ! prob1.irp.f: 7 diff --git a/problem1/IRPF90_temp/prob1.irp.f b/problem1/IRPF90_temp/prob1.irp.f new file mode 100644 index 0000000..547c1ce --- /dev/null +++ b/problem1/IRPF90_temp/prob1.irp.f @@ -0,0 +1,8 @@ + program prob1 + + implicit none + + write(6,*)sum + + end + diff --git a/problem1/IRPF90_temp/prob1.irp.module.F90 b/problem1/IRPF90_temp/prob1.irp.module.F90 new file mode 100644 index 0000000..80c64de --- /dev/null +++ b/problem1/IRPF90_temp/prob1.irp.module.F90 @@ -0,0 +1,10 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +module prob1_mod +end module prob1_mod diff --git a/problem1/IRPF90_temp/prob1.irp.module.o b/problem1/IRPF90_temp/prob1.irp.module.o new file mode 100644 index 0000000..c23d5af Binary files /dev/null and b/problem1/IRPF90_temp/prob1.irp.module.o differ diff --git a/problem1/IRPF90_temp/prob1.irp.o b/problem1/IRPF90_temp/prob1.irp.o new file mode 100644 index 0000000..455b7a9 Binary files /dev/null and b/problem1/IRPF90_temp/prob1.irp.o differ diff --git a/problem1/IRPF90_temp/prob1_mod.mod b/problem1/IRPF90_temp/prob1_mod.mod new file mode 100644 index 0000000..77b3ffd --- /dev/null +++ b/problem1/IRPF90_temp/prob1_mod.mod @@ -0,0 +1,22 @@ +GFORTRAN module version '9' created from IRPF90_temp/prob1.irp.module.F90 +MD5:9050a620cdb8ca62969d3e2239d45f60 -- If you edit this, you'll get what you deserve. + +(() () () () () () () () () () () () () () () () () () () () () () () () +() () ()) + +() + +() + +() + +() + +() + +(2 'prob1_mod' 'prob1_mod' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 +0) +) + +('prob1_mod' 0 2) diff --git a/problem1/IRPF90_temp/sum.irp.F90 b/problem1/IRPF90_temp/sum.irp.F90 new file mode 100644 index 0000000..ed69d9e --- /dev/null +++ b/problem1/IRPF90_temp/sum.irp.F90 @@ -0,0 +1,46 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +subroutine provide_sum + use sum_mod + use fact_mod + use limit_mod + implicit none + character*(11) :: irp_here = 'provide_sum' + integer :: irp_err + logical :: irp_dimensions_OK + if (.not.limit_is_built) then + call provide_limit + endif + if (.not.fact_is_built) then + call provide_fact + endif + if (.not.sum_is_built) then + call bld_sum + sum_is_built = .True. + + endif +end subroutine provide_sum + +subroutine bld_sum + use sum_mod + use fact_mod + use limit_mod + implicit none ! sum.irp.f: 2 + character*(3) :: irp_here = 'sum' ! sum.irp.f: 1 + integer :: i,j ! sum.irp.f: 8 + sum=0 ! sum.irp.f: 9 + do i=1,limit-1 ! sum.irp.f: 10 + do j=1,nfact ! sum.irp.f: 11 + if(MOD(i,fact(j)).eq.0)then ! sum.irp.f: 12 + sum=sum+(i) ! sum.irp.f: 13 + EXIT ! sum.irp.f: 14 + endif ! sum.irp.f: 15 + enddo ! sum.irp.f: 16 + enddo ! sum.irp.f: 17 +end subroutine bld_sum diff --git a/problem1/IRPF90_temp/sum.irp.f b/problem1/IRPF90_temp/sum.irp.f new file mode 100644 index 0000000..0daf114 --- /dev/null +++ b/problem1/IRPF90_temp/sum.irp.f @@ -0,0 +1,19 @@ +BEGIN_PROVIDER [integer, sum] + implicit none + BEGIN_DOC + ! calculates the sum of the factors of + ! two integers between 1 to limit + END_DOC + + integer :: i,j + sum=0 + do i=1,limit-1 + do j=1,nfact + if(MOD(i,fact(j)).eq.0)then + sum+=i + EXIT + endif + enddo + enddo + +END_PROVIDER diff --git a/problem1/IRPF90_temp/sum.irp.module.F90 b/problem1/IRPF90_temp/sum.irp.module.F90 new file mode 100644 index 0000000..961d405 --- /dev/null +++ b/problem1/IRPF90_temp/sum.irp.module.F90 @@ -0,0 +1,12 @@ +! -*- F90 -*- +! +!-----------------------------------------------! +! This file was generated with the irpf90 tool. ! +! ! +! DO NOT MODIFY IT BY HAND ! +!-----------------------------------------------! + +module sum_mod + integer :: sum + logical :: sum_is_built = .False. +end module sum_mod diff --git a/problem1/IRPF90_temp/sum.irp.module.o b/problem1/IRPF90_temp/sum.irp.module.o new file mode 100644 index 0000000..e77ce97 Binary files /dev/null and b/problem1/IRPF90_temp/sum.irp.module.o differ diff --git a/problem1/IRPF90_temp/sum.irp.o b/problem1/IRPF90_temp/sum.irp.o new file mode 100644 index 0000000..ba5bbce Binary files /dev/null and b/problem1/IRPF90_temp/sum.irp.o differ diff --git a/problem1/IRPF90_temp/sum_mod.mod b/problem1/IRPF90_temp/sum_mod.mod new file mode 100644 index 0000000..fec3c04 --- /dev/null +++ b/problem1/IRPF90_temp/sum_mod.mod @@ -0,0 +1,26 @@ +GFORTRAN module version '9' created from IRPF90_temp/sum.irp.module.F90 +MD5:2062756ca08c72ef516ad2ce64c3e19d -- If you edit this, you'll get what you deserve. + +(() () () () () () () () () () () () () () () () () () () () () () () () +() () ()) + +() + +() + +() + +() + +() + +(2 'sum' 'sum_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN +IMPLICIT-SAVE 0 0) (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) +3 'sum_is_built' 'sum_mod' '' 1 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC +UNKNOWN IMPLICIT-SAVE 0 0) (LOGICAL 4 0 0 0 LOGICAL ()) 0 0 () () 0 () () +() 0 0) +4 'sum_mod' 'sum_mod' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN +UNKNOWN 0 0) (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0) +) + +('sum' 0 2 'sum_is_built' 0 3 'sum_mod' 0 4) diff --git a/problem1/Makefile b/problem1/Makefile new file mode 100644 index 0000000..4602bb7 --- /dev/null +++ b/problem1/Makefile @@ -0,0 +1,12 @@ +IRPF90 = irpf90 #-a -d +FC = gfortran +FCFLAGS= -O2 + +SRC= +OBJ= +LIB= + +include irpf90.make + +irpf90.make: $(wildcard *.irp.f) + $(IRPF90) diff --git a/problem1/README.md b/problem1/README.md new file mode 100644 index 0000000..2f685bb --- /dev/null +++ b/problem1/README.md @@ -0,0 +1,7 @@ +PROBLEM 1 +---------- + +* If we list all the natural numbers below 10 that are multiples of 3 or 5, we + get 3, 5, 6 and 9. The sum of these multiples is 23. + + Find the sum of all the multiples of 3 or 5 below 1000. diff --git a/problem1/fact.irp.f b/problem1/fact.irp.f new file mode 100644 index 0000000..9d6f82a --- /dev/null +++ b/problem1/fact.irp.f @@ -0,0 +1,14 @@ +BEGIN_PROVIDER [integer, fact, (nfact)] + BEGIN_DOC + ! enter the factors + END_DOC + + implicit none + integer :: i + + write(6,*)'enter',nfact,'integers' + do i=1,nfact + read(5,*)fact(i) + enddo + +END_PROVIDER diff --git a/problem1/inp b/problem1/inp new file mode 100644 index 0000000..cfb7179 --- /dev/null +++ b/problem1/inp @@ -0,0 +1,4 @@ +10000 +2 +3 +5 diff --git a/problem1/irpf90.make b/problem1/irpf90.make new file mode 100644 index 0000000..d4c7de5 --- /dev/null +++ b/problem1/irpf90.make @@ -0,0 +1,43 @@ +SRC += IRPF90_temp/irp_stack.irp.F90 IRPF90_temp/irp_touches.irp.F90 IRPF90_temp/prob1.irp.F90 IRPF90_temp/prob1.irp.module.F90 IRPF90_temp/fact.irp.F90 IRPF90_temp/fact.irp.module.F90 IRPF90_temp/sum.irp.F90 IRPF90_temp/sum.irp.module.F90 IRPF90_temp/limit.irp.F90 IRPF90_temp/limit.irp.module.F90 +OBJ += IRPF90_temp/irp_stack.irp.o IRPF90_temp/fact.irp.o IRPF90_temp/fact.irp.module.o IRPF90_temp/sum.irp.o IRPF90_temp/sum.irp.module.o IRPF90_temp/limit.irp.o IRPF90_temp/limit.irp.module.o +OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(OBJ))) IRPF90_temp/irp_touches.irp.o +ALL = prob1 +ALL_OBJ = prob1.irp.module.o prob1.irp.o +ALL_OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(ALL_OBJ))) +all:$(ALL) + @$(MAKE) -s move +prob1: IRPF90_temp/prob1.irp.o IRPF90_temp/prob1.irp.module.o $(OBJ1) + $(FC) -o $@ IRPF90_temp/$@.irp.o IRPF90_temp/$@.irp.module.o $(OBJ1) $(LIB) + @$(MAKE) -s move +IRPF90_temp/prob1.irp.o: IRPF90_temp/prob1.irp.module.o IRPF90_temp/sum.irp.module.o +IRPF90_temp/fact.irp.o: IRPF90_temp/fact.irp.module.o IRPF90_temp/limit.irp.module.o +IRPF90_temp/sum.irp.o: IRPF90_temp/sum.irp.module.o IRPF90_temp/limit.irp.module.o IRPF90_temp/fact.irp.module.o +IRPF90_temp/limit.irp.o: IRPF90_temp/limit.irp.module.o +IRPF90_temp/irp_touches.irp.o: IRPF90_temp/fact.irp.o IRPF90_temp/fact.irp.o IRPF90_temp/sum.irp.o IRPF90_temp/sum.irp.o IRPF90_temp/limit.irp.o IRPF90_temp/limit.irp.o +IRPF90_temp/%.irp.module.o: IRPF90_temp/%.irp.module.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.module.F90 -o IRPF90_temp/$*.irp.module.o +IRPF90_temp/%.irp.o: IRPF90_temp/%.irp.module.o IRPF90_temp/%.irp.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.F90 -o IRPF90_temp/$*.irp.o +IRPF90_temp/%.irp.o: IRPF90_temp/%.irp.F90 + $(FC) $(FCFLAGS) -c IRPF90_temp/$*.irp.F90 -o IRPF90_temp/$*.irp.o +IRPF90_temp/%.o: %.F90 + $(FC) $(FCFLAGS) -c $*.F90 -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.f90 + $(FC) $(FCFLAGS) -c $*.f90 -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.f + $(FC) $(FCFLAGS) -c $*.f -o IRPF90_temp/$*.o +IRPF90_temp/%.o: %.F + $(FC) $(FCFLAGS) -c $*.F -o IRPF90_temp/$*.o +IRPF90_temp/%.irp.F90: irpf90.make + +move: + @mv -f *.mod IRPF90_temp/ 2> /dev/null | DO_NOTHING= + +clean: + rm -rf $(EXE) $(OBJ1) $(ALL_OBJ1) $(ALL) + +veryclean: + - $(MAKE) clean + + - rm -rf IRPF90_temp/ IRPF90_man/ irpf90.make irpf90_variables dist + diff --git a/problem1/irpf90_entities b/problem1/irpf90_entities new file mode 100644 index 0000000..2eb2510 --- /dev/null +++ b/problem1/irpf90_entities @@ -0,0 +1,4 @@ +fact.irp.f : integer, allocatable :: fact (nfact) +limit.irp.f : integer :: limit +limit.irp.f : integer :: nfact +sum.irp.f : integer :: sum diff --git a/problem1/limit.irp.f b/problem1/limit.irp.f new file mode 100644 index 0000000..d61342a --- /dev/null +++ b/problem1/limit.irp.f @@ -0,0 +1,11 @@ +BEGIN_PROVIDER [integer, limit] +&BEGIN_PROVIDER [integer, nfact] + BEGIN_DOC + ! enter limit + END_DOC + write(6,*)'limit?' + read(5,*)limit + write(6,*)'nfact?' + read(5,*)nfact + +END_PROVIDER diff --git a/problem1/prob1 b/problem1/prob1 new file mode 100755 index 0000000..12065c3 Binary files /dev/null and b/problem1/prob1 differ diff --git a/problem1/prob1.irp.f b/problem1/prob1.irp.f new file mode 100644 index 0000000..547c1ce --- /dev/null +++ b/problem1/prob1.irp.f @@ -0,0 +1,8 @@ + program prob1 + + implicit none + + write(6,*)sum + + end + diff --git a/problem1/sum.irp.f b/problem1/sum.irp.f new file mode 100644 index 0000000..0daf114 --- /dev/null +++ b/problem1/sum.irp.f @@ -0,0 +1,19 @@ +BEGIN_PROVIDER [integer, sum] + implicit none + BEGIN_DOC + ! calculates the sum of the factors of + ! two integers between 1 to limit + END_DOC + + integer :: i,j + sum=0 + do i=1,limit-1 + do j=1,nfact + if(MOD(i,fact(j)).eq.0)then + sum+=i + EXIT + endif + enddo + enddo + +END_PROVIDER