diff --git a/test/fileread/getp.f90 b/test/fileread/getp.f90 index 088b68fc..e9ddf7d2 100644 --- a/test/fileread/getp.f90 +++ b/test/fileread/getp.f90 @@ -50,20 +50,35 @@ contains real(psb_dpk_) :: eps character :: afmt*5 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) 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(psb_inp_unit,*) ip + read(inp_unit,*) ip if (ip >= 5) then - read(psb_inp_unit,*) mtrx_file - read(psb_inp_unit,*) rhs_file - read(psb_inp_unit,*) filefmt - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt - read(psb_inp_unit,*) part + read(inp_unit,*) mtrx_file + read(inp_unit,*) rhs_file + read(inp_unit,*) filefmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt + read(inp_unit,*) part call psb_bcast(ictxt,mtrx_file) @@ -75,27 +90,27 @@ contains call psb_bcast(ictxt,part) if (ip >= 7) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 8) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 9) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 10) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst = 1 endif if (ip >= 11) then - read(psb_inp_unit,*) eps + read(inp_unit,*) eps else eps=1.d-6 endif @@ -119,6 +134,9 @@ contains call psb_abort(ictxt) stop 1 end if + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if else ! Receive Parameters call psb_bcast(ictxt,mtrx_file) @@ -152,20 +170,35 @@ contains real(psb_spk_) :: eps character :: afmt*5 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) 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(psb_inp_unit,*) ip + read(inp_unit,*) ip if (ip >= 5) then - read(psb_inp_unit,*) mtrx_file - read(psb_inp_unit,*) rhs_file - read(psb_inp_unit,*) filefmt - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt - read(psb_inp_unit,*) ipart + read(inp_unit,*) mtrx_file + read(inp_unit,*) rhs_file + read(inp_unit,*) filefmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt + read(inp_unit,*) ipart call psb_bcast(ictxt,mtrx_file) @@ -177,27 +210,27 @@ contains call psb_bcast(ictxt,part) if (ip >= 7) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 8) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 9) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 10) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst = 1 endif if (ip >= 11) then - read(psb_inp_unit,*) eps + read(inp_unit,*) eps else eps=1.d-6 endif @@ -221,6 +254,9 @@ contains call psb_abort(ictxt) stop 1 end if + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if else ! Receive Parameters call psb_bcast(ictxt,mtrx_file) diff --git a/test/pargen/psb_d_pde2d.f90 b/test/pargen/psb_d_pde2d.f90 index a7c6a09d..3921780e 100644 --- a/test/pargen/psb_d_pde2d.f90 +++ b/test/pargen/psb_d_pde2d.f90 @@ -558,35 +558,50 @@ contains character(len=*) :: kmethd, ptype, afmt integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst 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) 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 - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt - read(psb_inp_unit,*) idim + read(inp_unit,*) idim if (ip >= 4) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 5) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 6) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 7) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst=1 endif @@ -604,8 +619,11 @@ contains call psb_abort(ictxt) stop 1 endif - end if + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if + end if ! broadcast parameters to all processors call psb_bcast(ictxt,kmethd) call psb_bcast(ictxt,afmt) @@ -616,7 +634,6 @@ contains call psb_bcast(ictxt,itrace) call psb_bcast(ictxt,irst) - return end subroutine get_parms diff --git a/test/pargen/psb_d_pde3d.f90 b/test/pargen/psb_d_pde3d.f90 index 2a541223..ebde0628 100644 --- a/test/pargen/psb_d_pde3d.f90 +++ b/test/pargen/psb_d_pde3d.f90 @@ -586,36 +586,50 @@ contains character(len=*) :: kmethd, ptype, afmt integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst 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) 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 - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt - - read(psb_inp_unit,*) idim + read(inp_unit,*) idim if (ip >= 4) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 5) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 6) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 7) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst=1 endif @@ -637,6 +651,10 @@ contains call psb_abort(ictxt) stop 1 endif + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if + end if ! broadcast parameters to all processors call psb_bcast(ictxt,kmethd) diff --git a/test/pargen/psb_s_pde2d.f90 b/test/pargen/psb_s_pde2d.f90 index fd22479c..ae670c51 100644 --- a/test/pargen/psb_s_pde2d.f90 +++ b/test/pargen/psb_s_pde2d.f90 @@ -543,35 +543,50 @@ contains character(len=*) :: kmethd, ptype, afmt integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst 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) 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 - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt - read(psb_inp_unit,*) idim + read(inp_unit,*) idim if (ip >= 4) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 5) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 6) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 7) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst=1 endif @@ -589,6 +604,10 @@ contains call psb_abort(ictxt) stop 1 endif + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if + end if ! broadcast parameters to all processors call psb_bcast(ictxt,kmethd) @@ -600,7 +619,6 @@ contains call psb_bcast(ictxt,itrace) call psb_bcast(ictxt,irst) - return end subroutine get_parms diff --git a/test/pargen/psb_s_pde3d.f90 b/test/pargen/psb_s_pde3d.f90 index ef350faf..e8055d7c 100644 --- a/test/pargen/psb_s_pde3d.f90 +++ b/test/pargen/psb_s_pde3d.f90 @@ -570,38 +570,55 @@ contains character(len=*) :: kmethd, ptype, afmt integer(psb_ipk_) :: idim, istopc,itmax,itrace,irst 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) 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 - read(psb_inp_unit,*) kmethd - read(psb_inp_unit,*) ptype - read(psb_inp_unit,*) afmt + read(inp_unit,*) kmethd + read(inp_unit,*) ptype + read(inp_unit,*) afmt - read(psb_inp_unit,*) idim + read(inp_unit,*) idim if (ip >= 4) then - read(psb_inp_unit,*) istopc + read(inp_unit,*) istopc else istopc=1 endif if (ip >= 5) then - read(psb_inp_unit,*) itmax + read(inp_unit,*) itmax else itmax=500 endif if (ip >= 6) then - read(psb_inp_unit,*) itrace + read(inp_unit,*) itrace else itrace=-1 endif if (ip >= 7) then - read(psb_inp_unit,*) irst + read(inp_unit,*) irst else irst=1 endif + ! broadcast parameters to all processors + write(psb_out_unit,'("Solving matrix : ell1")') write(psb_out_unit,& @@ -618,6 +635,10 @@ contains call psb_abort(ictxt) stop 1 endif + if (inp_unit /= psb_inp_unit) then + close(inp_unit) + end if + end if ! broadcast parameters to all processors call psb_bcast(ictxt,kmethd) @@ -652,7 +673,6 @@ contains write(iout,*)' >= 1 do tracing every itrace' write(iout,*)' iterations ' end subroutine pr_usage - ! ! functions parametrizing the differential equation !