Test programs can take input file on command line.

pull/6/head
Salvatore Filippone 7 years ago
parent 7c786c4bf1
commit e451af9621

@ -50,20 +50,35 @@ contains
real(psb_dpk_) :: eps real(psb_dpk_) :: eps
character :: afmt*5 character :: afmt*5
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: inparms(40), ip integer(psb_ipk_) :: inparms(40), ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt,iam,np) call psb_info(ictxt,iam,np)
if (iam == 0) then if (iam == 0) then
if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=psb_inp_unit
end if
! Read Input Parameters ! Read Input Parameters
read(psb_inp_unit,*) ip read(inp_unit,*) ip
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) mtrx_file read(inp_unit,*) mtrx_file
read(psb_inp_unit,*) rhs_file read(inp_unit,*) rhs_file
read(psb_inp_unit,*) filefmt read(inp_unit,*) filefmt
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(psb_inp_unit,*) part read(inp_unit,*) part
call psb_bcast(ictxt,mtrx_file) call psb_bcast(ictxt,mtrx_file)
@ -75,27 +90,27 @@ contains
call psb_bcast(ictxt,part) call psb_bcast(ictxt,part)
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 8) then if (ip >= 8) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 9) then if (ip >= 9) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 10) then if (ip >= 10) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst = 1 irst = 1
endif endif
if (ip >= 11) then if (ip >= 11) then
read(psb_inp_unit,*) eps read(inp_unit,*) eps
else else
eps=1.d-6 eps=1.d-6
endif endif
@ -119,6 +134,9 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
end if end if
if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
else else
! Receive Parameters ! Receive Parameters
call psb_bcast(ictxt,mtrx_file) call psb_bcast(ictxt,mtrx_file)
@ -152,20 +170,35 @@ contains
real(psb_spk_) :: eps real(psb_spk_) :: eps
character :: afmt*5 character :: afmt*5
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: inparms(40), ip integer(psb_ipk_) :: inparms(40), ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt,iam,np) call psb_info(ictxt,iam,np)
if (iam == 0) then if (iam == 0) then
if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=inp_unit
end if
! Read Input Parameters ! Read Input Parameters
read(psb_inp_unit,*) ip read(inp_unit,*) ip
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) mtrx_file read(inp_unit,*) mtrx_file
read(psb_inp_unit,*) rhs_file read(inp_unit,*) rhs_file
read(psb_inp_unit,*) filefmt read(inp_unit,*) filefmt
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(psb_inp_unit,*) ipart read(inp_unit,*) ipart
call psb_bcast(ictxt,mtrx_file) call psb_bcast(ictxt,mtrx_file)
@ -177,27 +210,27 @@ contains
call psb_bcast(ictxt,part) call psb_bcast(ictxt,part)
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 8) then if (ip >= 8) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 9) then if (ip >= 9) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 10) then if (ip >= 10) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst = 1 irst = 1
endif endif
if (ip >= 11) then if (ip >= 11) then
read(psb_inp_unit,*) eps read(inp_unit,*) eps
else else
eps=1.d-6 eps=1.d-6
endif endif
@ -221,6 +254,9 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
end if end if
if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
else else
! Receive Parameters ! Receive Parameters
call psb_bcast(ictxt,mtrx_file) call psb_bcast(ictxt,mtrx_file)

@ -558,35 +558,50 @@ contains
character(len=*) :: kmethd, ptype, afmt character(len=*) :: kmethd, ptype, afmt
integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: ip integer(psb_ipk_) :: ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt, iam, np) call psb_info(ictxt, iam, np)
if (iam == 0) then if (iam == 0) then
read(psb_inp_unit,*) ip if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=psb_inp_unit
end if
read(inp_unit,*) ip
if (ip >= 3) then if (ip >= 3) then
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(psb_inp_unit,*) idim read(inp_unit,*) idim
if (ip >= 4) then if (ip >= 4) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 6) then if (ip >= 6) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst=1 irst=1
endif endif
@ -604,8 +619,11 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
endif endif
end if if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
end if
! broadcast parameters to all processors ! broadcast parameters to all processors
call psb_bcast(ictxt,kmethd) call psb_bcast(ictxt,kmethd)
call psb_bcast(ictxt,afmt) call psb_bcast(ictxt,afmt)
@ -616,7 +634,6 @@ contains
call psb_bcast(ictxt,itrace) call psb_bcast(ictxt,itrace)
call psb_bcast(ictxt,irst) call psb_bcast(ictxt,irst)
return return
end subroutine get_parms end subroutine get_parms

@ -586,36 +586,50 @@ contains
character(len=*) :: kmethd, ptype, afmt character(len=*) :: kmethd, ptype, afmt
integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: ip integer(psb_ipk_) :: ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt, iam, np) call psb_info(ictxt, iam, np)
if (iam == 0) then if (iam == 0) then
read(psb_inp_unit,*) ip if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=psb_inp_unit
end if
read(inp_unit,*) ip
if (ip >= 3) then if (ip >= 3) then
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(inp_unit,*) idim
read(psb_inp_unit,*) idim
if (ip >= 4) then if (ip >= 4) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 6) then if (ip >= 6) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst=1 irst=1
endif endif
@ -637,6 +651,10 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
endif endif
if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
end if end if
! broadcast parameters to all processors ! broadcast parameters to all processors
call psb_bcast(ictxt,kmethd) call psb_bcast(ictxt,kmethd)

@ -543,35 +543,50 @@ contains
character(len=*) :: kmethd, ptype, afmt character(len=*) :: kmethd, ptype, afmt
integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: ip integer(psb_ipk_) :: ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt, iam, np) call psb_info(ictxt, iam, np)
if (iam == 0) then if (iam == 0) then
read(psb_inp_unit,*) ip if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=psb_inp_unit
end if
read(inp_unit,*) ip
if (ip >= 3) then if (ip >= 3) then
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(psb_inp_unit,*) idim read(inp_unit,*) idim
if (ip >= 4) then if (ip >= 4) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 6) then if (ip >= 6) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst=1 irst=1
endif endif
@ -589,6 +604,10 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
endif endif
if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
end if end if
! broadcast parameters to all processors ! broadcast parameters to all processors
call psb_bcast(ictxt,kmethd) call psb_bcast(ictxt,kmethd)
@ -600,7 +619,6 @@ contains
call psb_bcast(ictxt,itrace) call psb_bcast(ictxt,itrace)
call psb_bcast(ictxt,irst) call psb_bcast(ictxt,irst)
return return
end subroutine get_parms end subroutine get_parms

@ -570,38 +570,55 @@ contains
character(len=*) :: kmethd, ptype, afmt character(len=*) :: kmethd, ptype, afmt
integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst
integer(psb_ipk_) :: np, iam integer(psb_ipk_) :: np, iam
integer(psb_ipk_) :: ip integer(psb_ipk_) :: ip, inp_unit
character(len=1024) :: filename
call psb_info(ictxt, iam, np) call psb_info(ictxt, iam, np)
if (iam == 0) then if (iam == 0) then
read(psb_inp_unit,*) ip if (command_argument_count()>0) then
call get_command_argument(1,filename)
inp_unit = 30
open(inp_unit,file=filename,action='read',iostat=info)
if (info /= 0) then
write(psb_err_unit,*) 'Could not open file ',filename,' for input'
call psb_abort(ictxt)
stop
else
write(psb_err_unit,*) 'Opened file ',trim(filename),' for input'
end if
else
inp_unit=psb_inp_unit
end if
read(inp_unit,*) ip
if (ip >= 3) then if (ip >= 3) then
read(psb_inp_unit,*) kmethd read(inp_unit,*) kmethd
read(psb_inp_unit,*) ptype read(inp_unit,*) ptype
read(psb_inp_unit,*) afmt read(inp_unit,*) afmt
read(psb_inp_unit,*) idim read(inp_unit,*) idim
if (ip >= 4) then if (ip >= 4) then
read(psb_inp_unit,*) istopc read(inp_unit,*) istopc
else else
istopc=1 istopc=1
endif endif
if (ip >= 5) then if (ip >= 5) then
read(psb_inp_unit,*) itmax read(inp_unit,*) itmax
else else
itmax=500 itmax=500
endif endif
if (ip >= 6) then if (ip >= 6) then
read(psb_inp_unit,*) itrace read(inp_unit,*) itrace
else else
itrace=-1 itrace=-1
endif endif
if (ip >= 7) then if (ip >= 7) then
read(psb_inp_unit,*) irst read(inp_unit,*) irst
else else
irst=1 irst=1
endif endif
! broadcast parameters to all processors
write(psb_out_unit,'("Solving matrix : ell1")') write(psb_out_unit,'("Solving matrix : ell1")')
write(psb_out_unit,& write(psb_out_unit,&
@ -618,6 +635,10 @@ contains
call psb_abort(ictxt) call psb_abort(ictxt)
stop 1 stop 1
endif endif
if (inp_unit /= psb_inp_unit) then
close(inp_unit)
end if
end if end if
! broadcast parameters to all processors ! broadcast parameters to all processors
call psb_bcast(ictxt,kmethd) call psb_bcast(ictxt,kmethd)
@ -652,7 +673,6 @@ contains
write(iout,*)' >= 1 do tracing every itrace' write(iout,*)' >= 1 do tracing every itrace'
write(iout,*)' iterations ' write(iout,*)' iterations '
end subroutine pr_usage end subroutine pr_usage
! !
! functions parametrizing the differential equation ! functions parametrizing the differential equation
! !

Loading…
Cancel
Save