Skip to content

Commit

Permalink
Merge pull request #1 from vijaygopalchilkuri/prob4
Browse files Browse the repository at this point in the history
Prob4
  • Loading branch information
v1j4y committed Jun 21, 2013
2 parents cdeb3ec + a2ceb2b commit fa5b2f6
Show file tree
Hide file tree
Showing 121 changed files with 1,916 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ PROJECT EULER
=============

* project euler problems with irpf90

PROBLEM2
--------

* Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms.
15 changes: 15 additions & 0 deletions problem2/IRPF90_man/limit.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.TH "IRPF90 entities" l limit "IRPF90 entities" limit
.SH Declaration
.nf
integer :: limit
integer :: term1
integer :: term2
.ni
.SH Description
! enter limit
.SH File
.P
limit.irp.f
.SH Needed by
sum
.br
14 changes: 14 additions & 0 deletions problem2/IRPF90_man/sum.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.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
limit
.br
15 changes: 15 additions & 0 deletions problem2/IRPF90_man/term1.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.TH "IRPF90 entities" l term1 "IRPF90 entities" term1
.SH Declaration
.nf
integer :: limit
integer :: term1
integer :: term2
.ni
.SH Description
! enter limit
.SH File
.P
limit.irp.f
.SH Needed by
sum
.br
15 changes: 15 additions & 0 deletions problem2/IRPF90_man/term2.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.TH "IRPF90 entities" l term2 "IRPF90 entities" term2
.SH Declaration
.nf
integer :: limit
integer :: term1
integer :: term2
.ni
.SH Description
! enter limit
.SH File
.P
limit.irp.f
.SH Needed by
sum
.br
12 changes: 12 additions & 0 deletions problem2/IRPF90_temp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IRPF90 = irpf90 #-a -d
FC = gfortran
FCFLAGS= -O2

SRC=
OBJ=
LIB=

include irpf90.make

irpf90.make: $(wildcard *.irp.f)
$(IRPF90)
10 changes: 10 additions & 0 deletions problem2/IRPF90_temp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PROBLEM 2
----------

* Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms.
38 changes: 38 additions & 0 deletions problem2/IRPF90_temp/irp_stack.irp.F90
Original file line number Diff line number Diff line change
@@ -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

Binary file added problem2/IRPF90_temp/irp_stack.irp.o
Binary file not shown.
42 changes: 42 additions & 0 deletions problem2/IRPF90_temp/irp_stack_mod.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions problem2/IRPF90_temp/irp_touches.irp.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
subroutine irp_finalize_1930907644
use sum_mod
use limit_mod
end
Binary file added problem2/IRPF90_temp/irp_touches.irp.o
Binary file not shown.
42 changes: 42 additions & 0 deletions problem2/IRPF90_temp/irpf90.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
SRC += IRPF90_temp/irp_stack.irp.F90 IRPF90_temp/irp_touches.irp.F90 IRPF90_temp/prob2.irp.F90 IRPF90_temp/prob2.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/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 = prob2
ALL_OBJ = prob2.irp.module.o prob2.irp.o
ALL_OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(ALL_OBJ)))
all:$(ALL)
@$(MAKE) -s move
prob2: IRPF90_temp/prob2.irp.o IRPF90_temp/prob2.irp.module.o $(OBJ1)
$(FC) -o $@ IRPF90_temp/$@.irp.o IRPF90_temp/$@.irp.module.o $(OBJ1) $(LIB)
@$(MAKE) -s move
IRPF90_temp/prob2.irp.o: IRPF90_temp/prob2.irp.module.o IRPF90_temp/sum.irp.module.o
IRPF90_temp/sum.irp.o: IRPF90_temp/sum.irp.module.o IRPF90_temp/limit.irp.module.o
IRPF90_temp/limit.irp.o: IRPF90_temp/limit.irp.module.o
IRPF90_temp/irp_touches.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

4 changes: 4 additions & 0 deletions problem2/IRPF90_temp/irpf90_entities
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
limit.irp.f : integer :: limit
sum.irp.f : integer :: sum
limit.irp.f : integer :: term1
limit.irp.f : integer :: term2
31 changes: 31 additions & 0 deletions problem2/IRPF90_temp/limit.irp.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
! -*- 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: 7
read(5,*)limit ! limit.irp.f: 8
write(6,*)'term1?' ! limit.irp.f: 9
read(5,*)term1 ! limit.irp.f: 10
write(6,*)'term2?' ! limit.irp.f: 11
read(5,*)term2 ! limit.irp.f: 12
end subroutine bld_limit
14 changes: 14 additions & 0 deletions problem2/IRPF90_temp/limit.irp.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BEGIN_PROVIDER [integer, limit]
&BEGIN_PROVIDER [integer, term1]
&BEGIN_PROVIDER [integer, term2]
BEGIN_DOC
! enter limit
END_DOC
write(6,*)'limit?'
read(5,*)limit
write(6,*)'term1?'
read(5,*)term1
write(6,*)'term2?'
read(5,*)term2

END_PROVIDER
14 changes: 14 additions & 0 deletions problem2/IRPF90_temp/limit.irp.module.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
! -*- 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 :: term2
integer :: term1
end module limit_mod
Binary file added problem2/IRPF90_temp/limit.irp.module.o
Binary file not shown.
Binary file added problem2/IRPF90_temp/limit.irp.o
Binary file not shown.
35 changes: 35 additions & 0 deletions problem2/IRPF90_temp/limit_mod.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added problem2/IRPF90_temp/prob2
Binary file not shown.
21 changes: 21 additions & 0 deletions problem2/IRPF90_temp/prob2.irp.F90
Original file line number Diff line number Diff line change
@@ -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 ! prob2.irp.f: 0
call irp_finalize_1930907644() ! prob2.irp.f: 0
end program ! prob2.irp.f: 0
subroutine prob1 ! prob2.irp.f: 1
use sum_mod
implicit none ! prob2.irp.f: 3
character*(5) :: irp_here = 'prob1' ! prob2.irp.f: 1
if (.not.sum_is_built) then
call provide_sum
endif
write(6,*)sum ! prob2.irp.f: 5
end ! prob2.irp.f: 7
8 changes: 8 additions & 0 deletions problem2/IRPF90_temp/prob2.irp.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
program prob1

implicit none

write(6,*)sum

end

10 changes: 10 additions & 0 deletions problem2/IRPF90_temp/prob2.irp.module.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
! -*- F90 -*-
!
!-----------------------------------------------!
! This file was generated with the irpf90 tool. !
! !
! DO NOT MODIFY IT BY HAND !
!-----------------------------------------------!

module prob2_mod
end module prob2_mod
Binary file added problem2/IRPF90_temp/prob2.irp.module.o
Binary file not shown.
Binary file added problem2/IRPF90_temp/prob2.irp.o
Binary file not shown.
22 changes: 22 additions & 0 deletions problem2/IRPF90_temp/prob2_mod.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fa5b2f6

Please sign in to comment.