Comando write read

Uso fortram no windows.
Quando dou read ou write nada acontece.
A tela pisca e volta ao editorbForce 2.0

@Octavio , welcome to the forum.

Unfortunately, my understanding of Portuguese is very limited and I guess this holds for most users of this forum. Could you translate your question into English?

I use fortran in windows.
When I read or write nothing happens.
The screen blinks and goes back to editor bForce 2.0
(deepl.com)

I guess @Octavio needs to give more details, source snippet …
Acho que @Octavio precisa de dar mais detalhes, trecho da fonte …

I guess the “b” in editorbForce 2.0 is a typo. I have found this:

If you are working with a good old Fortran program, the output goes to the console (or line printer, but few of us use those). If the program finishes running in, say, less than a second, and you are running from an IDE such as Force, the output window will be opened and closed in such a short period that you get the impression that “nothing happened”. Add a PAUSE statement at the end of your program, or move the main window of your IDE to the side so that you can see the output window.

Alternatively, build and run your program from the command line.

I’ll try to use Google translator. Sorry to bother you I’m 75 years old and I was a great Fortran programmer in the 70’s when I was young. I did many programs at the university and professionally in companies. Today I decided to go back to “playing” with Fortran, even to avoid the boredom of old age. I installed Force 2.0, which I found interesting because it has the editor and the compiler together. My operating system is Windows 10. I made my first very simple program to start playing:

program testing
implicit none
real*4 a,b,c
a=23
b=33
c=a + b
5 format (i3)
print 5 c
end

Ridiculous!

However, when I run it, it does not display the result on the screen, it just flashes the screen and returns to the editor. How do I display on the screen to see the result. Thanks

1 Like

Understood :slight_smile:

I think the easiest way is indeed using the PAUSE statement, another method might be to read from the standard input:

write(*,*) 'Enter a number ...'
read(*,*) a

IDEs often show this kind of behaviour. It is annoying.

That’s how it appears, because we humans are not capable of processing a picture that is shown for a very short period, say, 0.01 seconds. To see this, add a DO I = 1, 1000 loop around the executable statements in your program, along with a declaration for the integer variable I, and run it again.

As suggested earlier, add a PAUSE or a READ *,A statement before the end statement.

I changed the program a little so that it calculates the perimeter and area of a circle with radius r. Your Write (,) and Pause tips worked! The screen popped up with all the data! program testing

! Calcula o perimetro (P)e a rea (A) do circulo com raio r

implicit none
real4 r,P,A,pi
write(
,) ‘Entre com o raio …’
read(
,) r
pi=3.14159
P=2
pir
A= pi
r**2
Write(,)P,A
pause
end

Thank you!!!

1 Like

When you post code, please use the CODE button </> . If you do not do so, many characters, such as asterisks, will be removed or used to signify font face changes, etc., and your program will not work if a reader copies the code from the post and attempts to compile it.

Please, send me a exemple.

If you want

program pluto
implicit none
real :: a, b, c
read(*,*) a, b
c = a * b
print *, c
end program

You can use backticks: three backticks like in the following picture.

They are not always present in not English keyboards but you can add them to your keyboard, on windows, using “Microsoft keyboard layout creator”. I definitely added the backticks ` and the tilde ~ to my keyboard.

Like this

‘’'fortran
program testando
! Calcula o perimetro (P)e a rea (A) do circulo com raio r
implicit none
real4 r,P,A,pi
write(
,) ‘Entre com o raio …’
read(
,) r
pi=3.14159
P=2
pir
A= pi
r**2
Write(,)P,A
pause
end

‘’’

No, sorry, it is the grave accent: 96 decimal entry in the ASCII table, 60 in hexadecimal.

this ```

Yes!

Thank you!!!

@octavio The background for the three back ticks / accent grave to define a (fenced) code block is markdown, which is a markup language* - to some degree similar to e.g., LaTeX, or html. However, it is one of the lighter ones and the lesson on learnxinyminutes possibly provides you with most of the functionality you might want to use most of the time. Arguably, the constrained syntax is one reason why it can be engaged on so many platforms (including this discourse) like r/fortran, stackexchange/stackoverflow, issue reports on GitHub and GitLab, or is offered as (part of) editors/IDEs (e.g., geany), and programs (pandoc, obsidian).

* Actually, there are a couple of markdown dialects (Gruber’s version, GitHub, pandoc) with small variations in functionality - however it typically is not this much important for a post in a forum.

Thanks, I’ll check it out.

Another big question that I looked for an answer on google. I want to run my EXE program (created by the Fortran compiler) on my cell phone’s Android. That is, transform EXE into APK. Google just gave me mixed answers. It’s possible? Thanks