Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
2 Views

IOSTAT 43 on OPEN

Hello,

i'm with an IOSTAT 43 on OPEN a .txt file containing the numbers 4.0 -9.0 2.0 2.0 -4.0 4.0 -1.0 2.0 2.0. Someone can help me? 

      program LU

      implicit none

      character*300 :: filename
      integer       :: ul,erro,dim,i,j,k
      real*8,dimension(:,:),allocatable :: a,l,u
      real*8,dimension(:),allocatable   :: x,y,b

      filename    = ''
      ul          = 3
      erro        = 0
      dim         = 0

      !matriz A
      write(*,'(A)') 'Informe o nome do arquivo que contém a matriz A:'
      read(*,'(A)') filename

      write(*,'(A)') 'Informe a dimensão da matriz:'
      read(*,'(I)') dim

      allocate(A(dim,dim))
      allocate(l(dim,dim))
      allocate(u(dim,dim))
      a = 0.0
      l = 0.0
      u = 0.0


      open(ul,file=filename,status='old',action='read',iostat=erro,
     +form='formatted')
      if(erro.gt.0) write(*,10)erro
      read(ul,'(F)') a

 

0 Kudos
6 Replies
Highlighted
Black Belt
2 Views

43 is "File name

43 is "File name specification error". The variable filename may not have a valid filespec in it. I'll also comment that Windows generally has a 256-byte limit on filespecs, though trailing blanks would be ignored. If the user entered Unicode characters that could cause a problem - Intel Fortran does not yet support non-ASCII characters in file specifications.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
Valued Contributor III
2 Views

Look into the facilities the

Look into the facilities the language provides with OPEN statement:

https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-and-reference-open

and try using IOMSG and look into what the processor tells you about IOSTAT error 43:

https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-and-reference-i/o-message-spe...

..
 character(len=XX) :: imsg  !<-- some suitable length, say XX=256
 ..
 open(ul,file=filename,status='old',action='read',iostat=erro,
+form='formatted', iomsg=imsg)
 if (erro > 0) then
    write(*,10) erro
    write(*,10) imsg
..

 

0 Kudos
Highlighted
Black Belt
2 Views

Or remove the IOSTAT= and

Or remove the IOSTAT= and look at the name in the full error message. Or print the contents of "filename" after it is read.

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
2 Views

I was using a folder with a

I was using a folder with a name containing space on it and don't realized that this is a problem on fortran! I put the iomsg= to, very useful and i didn't know about.

 

Thank you very much!!

0 Kudos
Highlighted
Black Belt
2 Views

Fortran doesn't have problems

Fortran doesn't have problems with spaces in folder names.

D:\Projects>type t.f90
character(50) :: fnam,fspec

fnam = "C:\Test Folder\test.txt"
open (unit=1,file=fnam)
inquire (1,name=fspec)
print *, fspec
end
D:\Projects>ifort t.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, 
Version 17.0.4.210 Build 20170411
Copyright (C) 1985-2017 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:t.exe
-subsystem:console
t.obj

D:\Projects>t.exe
 C:\Test Folder\test.txt

D:\Projects>

 

--
Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
2 Views

I will try it! Thak you very

I will try it! Thak you very much Steve!

0 Kudos