-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
577 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
PROBLEM 3 | ||
---------- | ||
|
||
* A palindromic number reads the same both ways. The largest palindrome made | ||
from the product of two 2-digit numbers is 9009 = 91 99. | ||
|
||
Find the largest palindrome made from the product of two 3-digit numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
subroutine irp_finalize_1703613751 | ||
use is_palindrome_mod | ||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
SRC += IRPF90_temp/irp_stack.irp.F90 IRPF90_temp/irp_touches.irp.F90 IRPF90_temp/prob4.irp.F90 IRPF90_temp/prob4.irp.module.F90 IRPF90_temp/is_palindrome.irp.F90 IRPF90_temp/is_palindrome.irp.module.F90 | ||
OBJ += IRPF90_temp/irp_stack.irp.o IRPF90_temp/is_palindrome.irp.o IRPF90_temp/is_palindrome.irp.module.o | ||
OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(OBJ))) IRPF90_temp/irp_touches.irp.o | ||
ALL = prob4 | ||
ALL_OBJ = prob4.irp.module.o prob4.irp.o | ||
ALL_OBJ1 = $(patsubst %, IRPF90_temp/%,$(notdir $(ALL_OBJ))) | ||
all:$(ALL) | ||
@$(MAKE) -s move | ||
prob4: IRPF90_temp/prob4.irp.o IRPF90_temp/prob4.irp.module.o $(OBJ1) | ||
$(FC) -o $@ IRPF90_temp/$@.irp.o IRPF90_temp/$@.irp.module.o $(OBJ1) $(LIB) | ||
@$(MAKE) -s move | ||
IRPF90_temp/prob4.irp.o: IRPF90_temp/prob4.irp.module.o | ||
IRPF90_temp/is_palindrome.irp.o: IRPF90_temp/is_palindrome.irp.module.o | ||
IRPF90_temp/irp_touches.irp.o: IRPF90_temp/is_palindrome.irp.o IRPF90_temp/is_palindrome.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 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
! -*- F90 -*- | ||
! | ||
!-----------------------------------------------! | ||
! This file was generated with the irpf90 tool. ! | ||
! ! | ||
! DO NOT MODIFY IT BY HAND ! | ||
!-----------------------------------------------! | ||
|
||
subroutine is_palindrome(number,palin) ! is_palindrome.irp.f: 1 | ||
implicit none ! is_palindrome.irp.f: 3 | ||
character*(13) :: irp_here = 'is_palindrome' ! is_palindrome.irp.f: 1 | ||
logical :: palin ! is_palindrome.irp.f: 4 | ||
integer :: number,digit(1000),i,n1,j ! is_palindrome.irp.f: 5 | ||
palin=.FALSE. ! is_palindrome.irp.f: 7 | ||
do i=1,1000 ! is_palindrome.irp.f: 8 | ||
digit(i)=10 ! is_palindrome.irp.f: 9 | ||
enddo ! is_palindrome.irp.f: 10 | ||
i=0 ! is_palindrome.irp.f: 12 | ||
do while (number.gt.0) ! is_palindrome.irp.f: 13 | ||
n1=number-10*(number/10) ! is_palindrome.irp.f: 15 | ||
digit(i)=n1 ! is_palindrome.irp.f: 16 | ||
number=number/10 ! is_palindrome.irp.f: 17 | ||
i=i+(1) ! is_palindrome.irp.f: 18 | ||
enddo ! is_palindrome.irp.f: 19 | ||
palin=.TRUE. ! is_palindrome.irp.f: 22 | ||
do j=0,int((i-1)/2) ! is_palindrome.irp.f: 23 | ||
if(digit(j).ne.digit((i-1)-j))then ! is_palindrome.irp.f: 24 | ||
palin=.FALSE. ! is_palindrome.irp.f: 25 | ||
EXIT ! is_palindrome.irp.f: 26 | ||
endif ! is_palindrome.irp.f: 27 | ||
enddo ! is_palindrome.irp.f: 28 | ||
return ! is_palindrome.irp.f: 30 | ||
end ! is_palindrome.irp.f: 31 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
subroutine is_palindrome(number,palin) | ||
|
||
implicit none | ||
logical :: palin | ||
integer :: number,digit(1000),i,n1,j | ||
|
||
palin=.FALSE. | ||
do i=1,1000 | ||
digit(i)=10 | ||
enddo | ||
|
||
i=0 | ||
do while (number.gt.0) | ||
|
||
n1=number-10*(number/10) | ||
digit(i)=n1 | ||
number=number/10 | ||
i+=1 | ||
enddo | ||
|
||
! write(6,*)(digit(j),j=i-1,0,-1) | ||
palin=.TRUE. | ||
do j=0,int((i-1)/2) | ||
if(digit(j).ne.digit((i-1)-j))then | ||
palin=.FALSE. | ||
EXIT | ||
endif | ||
enddo | ||
|
||
return | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 is_palindrome_mod | ||
end module is_palindrome_mod |
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
861168 | ||
888888 | ||
861168 | ||
828828 | ||
886688 | ||
824428 | ||
906609 | ||
819918 | ||
824428 | ||
819918 | ||
828828 | ||
855558 | ||
840048 | ||
737737 | ||
853358 | ||
809908 | ||
793397 | ||
749947 | ||
821128 | ||
801108 | ||
749947 | ||
828828 | ||
802208 | ||
780087 | ||
737737 | ||
807708 | ||
698896 | ||
678876 | ||
804408 | ||
906609 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
! -*- F90 -*- | ||
! | ||
!-----------------------------------------------! | ||
! This file was generated with the irpf90 tool. ! | ||
! ! | ||
! DO NOT MODIFY IT BY HAND ! | ||
!-----------------------------------------------! | ||
|
||
program irp_program ! prob4: 0 | ||
call prob4 ! prob4.irp.f: 0 | ||
call irp_finalize_1703613751() ! prob4.irp.f: 0 | ||
end program ! prob4.irp.f: 0 | ||
subroutine prob4 ! prob4.irp.f: 1 | ||
implicit none ! prob4.irp.f: 3 | ||
character*(5) :: irp_here = 'prob4' ! prob4.irp.f: 1 | ||
integer :: i,j,number,k,ilim,jlim,palin(10000),maxpalin,cp,lim ! prob4.irp.f: 5 | ||
logical :: palindrome ! prob4.irp.f: 6 | ||
palindrome=.FALSE. ! prob4.irp.f: 8 | ||
maxpalin=0 ! prob4.irp.f: 9 | ||
cp=0 ! prob4.irp.f: 10 | ||
do i=999,100,-1 ! prob4.irp.f: 11 | ||
do j=999,i,-1 ! prob4.irp.f: 12 | ||
number=i*j ! prob4.irp.f: 13 | ||
call is_palindrome(number,palindrome) ! prob4.irp.f: 15 | ||
if(palindrome)then ! prob4.irp.f: 17 | ||
EXIT ! prob4.irp.f: 19 | ||
endif ! prob4.irp.f: 20 | ||
if(palindrome) then ! prob4.irp.f: 21 | ||
EXIT ! prob4.irp.f: 21 | ||
endif ! prob4.irp.f: 21 | ||
enddo ! prob4.irp.f: 22 | ||
if(palindrome) then ! prob4.irp.f: 23 | ||
EXIT ! prob4.irp.f: 23 | ||
endif ! prob4.irp.f: 23 | ||
enddo ! prob4.irp.f: 24 | ||
ilim=i ! prob4.irp.f: 25 | ||
jlim=j ! prob4.irp.f: 26 | ||
palindrome=.FALSE. ! prob4.irp.f: 27 | ||
lim=MIN(ilim,jlim) ! prob4.irp.f: 29 | ||
lim=lim-100 ! prob4.irp.f: 30 | ||
do i=999,lim,-1 ! prob4.irp.f: 31 | ||
do j=999,j,-1 ! prob4.irp.f: 32 | ||
number=i*j ! prob4.irp.f: 33 | ||
call is_palindrome(number,palindrome) ! prob4.irp.f: 34 | ||
if(palindrome)then ! prob4.irp.f: 35 | ||
cp=cp+(1) ! prob4.irp.f: 36 | ||
palin(cp)=i*j ! prob4.irp.f: 37 | ||
endif ! prob4.irp.f: 38 | ||
enddo ! prob4.irp.f: 39 | ||
enddo ! prob4.irp.f: 40 | ||
do i=1,cp ! prob4.irp.f: 42 | ||
if(maxpalin.le.palin(i)) then ! prob4.irp.f: 43 | ||
maxpalin=palin(i) ! prob4.irp.f: 43 | ||
endif ! prob4.irp.f: 43 | ||
enddo ! prob4.irp.f: 44 | ||
write(6,*)maxpalin ! prob4.irp.f: 46 | ||
end ! prob4.irp.f: 49 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
program prob4 | ||
|
||
implicit none | ||
|
||
integer :: i,j,number,k,ilim,jlim,palin(10000),maxpalin,cp,lim | ||
logical :: palindrome | ||
|
||
palindrome=.FALSE. | ||
maxpalin=0 | ||
cp=0 | ||
do i=999,100,-1 | ||
do j=999,i,-1 | ||
number=i*j | ||
! write(6,*)number | ||
call is_palindrome(number,palindrome) | ||
! write(6,*)palindrome | ||
if(palindrome)then | ||
! write(6,*)i*j | ||
EXIT | ||
endif | ||
if(palindrome)EXIT | ||
enddo | ||
if(palindrome)EXIT | ||
enddo | ||
ilim=i | ||
jlim=j | ||
palindrome=.FALSE. | ||
|
||
lim=MIN(ilim,jlim) | ||
lim=lim-100 | ||
do i=999,lim,-1 | ||
do j=999,j,-1 | ||
number=i*j | ||
call is_palindrome(number,palindrome) | ||
if(palindrome)then | ||
cp+=1 | ||
palin(cp)=i*j | ||
endif | ||
enddo | ||
enddo | ||
|
||
do i=1,cp | ||
if(maxpalin.le.palin(i))maxpalin=palin(i) | ||
enddo | ||
|
||
write(6,*)maxpalin | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 prob4_mod | ||
end module prob4_mod |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.