diff --git a/src/pyplot_module.F90 b/src/pyplot_module.F90 index fa5a767..68d05a7 100644 --- a/src/pyplot_module.F90 +++ b/src/pyplot_module.F90 @@ -1397,6 +1397,12 @@ subroutine execute(me, pyfile, istat, python) file = trim(pyfile) !use the user-specified name end if + if (file == '') then + if (present(istat)) istat = -1 + write(error_unit,'(A)') 'Error: filename is blank.' + return + end if + !open the file: open(newunit=iunit, file=file, status='REPLACE', iostat=iostat) if (iostat/=0) then @@ -1423,8 +1429,8 @@ subroutine execute(me, pyfile, istat, python) end if !run the file using python: - if (index(file,' ')>0) then - ! space in path, probably should enclose in quotes + if (file(1:1)/='"') then + ! if not already in quotes, should enclose in quotes call execute_command_line(python_//' "'//file//'"') else call execute_command_line(python_//' '//file) diff --git a/test/test.f90 b/test/test.f90 index 7f48b1d..1898554 100644 --- a/test/test.f90 +++ b/test/test.f90 @@ -201,5 +201,11 @@ program test dpi='200', & transparent=.true.,istat=istat, python='python') + ! also test one with spaces and () in the filename + call plt%savefig(testdir//'error bar (1).png', & + pyfile=testdir//'error bar (1).py', & + dpi='200', & + transparent=.true.,istat=istat, python='python') + end program test !*****************************************************************************************