Fortran: output format dependent on a variable
Posted
by
Flux Capacitor
on Stack Overflow
See other posts from Stack Overflow
or by Flux Capacitor
Published on 2012-03-26T23:07:27Z
Indexed on
2012/03/26
23:29 UTC
Read the original article
Hit count: 263
I would like to have a FORTRAN write statement formatted to depend on some variable.
For example, I could write:
write(*,'(3f15.3,3f9.2)') x,y,z,(var(i),i=1,nvari)
where nvari = 3
But, what if, in some cases, I actually have 4 variables (i.e. nvari = 4)
I would like to write something like this:
write(*,'(3f15.3,nvari(f9.2))') x,y,z,(var(i),i=1,nvari)
Now, nvari can be anything and the output will work as I like.
How can I make something like this work?
© Stack Overflow or respective owner