The file to be read by fortran shows that it does not exist

Updated on technology 2024-03-16
7 answers
  1. Anonymous users2024-02-06

    Check if the file exists.

  2. Anonymous users2024-02-05

    You can use the inquire statement.

    50 inquire(file=name of the file to be found, exist=alive).

    if( then !Files exist.

    The statement to be executed.

    goto 50

    elsegoto 50

    end if

  3. Anonymous users2024-02-04

    Alive is logical, not integer

    So the judgment statement is: if(alive) then

  4. Anonymous users2024-02-03

    unit = 10 is optional to distinguish between different files.

    If your program needs to read and write multiple files, choose different channel numbers (e.g. 10, 11, 12, 55) to distinguish them.

    The file is placed in the directory where the project is located or the directory where the exe is located. It depends on what compiler and compilation environment you use. Depending on the build environment, after you click the run button, you may set a different folder to the current active path.

  5. Anonymous users2024-02-02

    The file is either in the same directory as the executable file, or in the system path, or you need to specify it;

    If your FORTRAN executable file is not on the desktop, you need to specify the path where the desktop file is located; The desktop is also a special folder (path) in the system environment variable %userprofile% desktop. fortran is obtained by the getenv function.

    Demo program: Program Getenv Demo

    character(len=255) :userprofile_path, desktop_path, file_name

    logical ::does_file_exist

    file_name = ''

    call getenv("userprofile", userprofile_path)

    desktop_path = userprofile_path(:len_trim(userprofile_path))//'\'//'desktop'

    write(*,trim(desktop_path)

    file_name = desktop_path(:len_trim(desktop_path))//'\'//file_name

    write(*,trim(file_name)

    inquire(file=trim(file_name), exist=does_file_exist)

    if (does_file_exist) then

    write(*,'file exists!'

    elsewrite(*,'ooops,~'

    end if

    end program getenv_demo

    Run: C: Users Current Login User Name Desktop

    c:\users\current_login_user_name\desktop\

    file exists!

  6. Anonymous users2024-02-01

    Use read(12,*) to read in

    In most cases, read is OK with *. In rare cases, formatting is required.

    Check if yours is ANSI encoded? Could it be that I accidentally switched to Unicode encoding?

  7. Anonymous users2024-01-31

    I would like to ask how you solved it later, thank you

    Related questions
    9 answers2024-03-16

    I think it works, I did it once when I first started working, and I don't remember it very well, but you can try it with the seek function, locate it first, read it later, and I remember when I was doing this, I read the book The C Programmer, which is about 234 pages.

    5 answers2024-03-16

    Open a random folder. There is a tool option below the title bar. Then select. >>>More

    8 answers2024-03-16

    I have a way to make the file an ISO image and then change the file size to a larger size, but there is no way to make it smaller. Or hide it. >>>More

    4 answers2024-03-16

    Method. 1. Check the properties of the USB flash drive, if the used space is not 0, then you can use the following methods: Create a new txt file directly in your USB flash drive, and enter attrib -s -h s d to save it. >>>More

    8 answers2024-03-16

    One of the easiest ways is to extract the ISO and run the installer, which is how some computers can install the system. You try.