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
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.
Look into the facilities the language provides with OPEN statement:
and try using IOMSG and look into what the processor tells you about IOSTAT error 43:
.. 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 ..
Or remove the IOSTAT= and look at the name in the full error message. Or print the contents of "filename" after it is read.
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!!
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 184.108.40.206 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>