CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Fortran Problem (https://www.cfd-online.com/Forums/main/13329-fortran-problem.html)

MM April 18, 2007 14:52

Fortran Problem
 
Hi everyone,

How can I assign a variable name to a character variable in fortran. I would like to make an output file for my program but the name of the file would be changed during running and I need to record all of them. I don't want to repeat whole commands for making the file. If someone knows how it could be happened in fortran, I appreciate to let me know.

Thanks MM

pc April 18, 2007 15:08

Re: Fortran Problem
 
Write the variable to a character string. For example, for an integer n:

write(filename,'(a5,i2.2)')'file-',n

then open(1,file=filename,....)

This will make files called "file-01","file-02", etc.

Is this what you meant?


MM April 18, 2007 15:59

Re: Fortran Problem
 
Thank you so much, it was exactly what I was looking for.


All times are GMT -4. The time now is 05:38.