INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do you arrange output data from Fortran into a text file with specified columns widths?

How do you arrange output data from Fortran into a text file with specified columns widths?

How do you arrange output data from Fortran into a text file with specified columns widths?

(OP)
Regarding thread214-1609970: How to output Fortran program into the text file?,
I would like to find out how to arrange the output data from Fortran into a text file with specified column widths?

My code is as follows:
write(3,*)'Model Parameters: '
write(3,*)'Column length :',int(RPAR(2)),' m'
write(3,*)'Mass transfer coeff N2 :',int(RPAR(3)),' 1/s'
write(3,*)'Mass transfer coeff O2 :',int(RPAR(4)),' 1/s'
write(3,*)'Saturation constants :',real(RPAR(7)),' kg/kgs'
write(3,*)'Overall heat transfer coeff:',int(RPAR(13)),' J/m2.s.K'
write(3,*)'Gas heat capacity :',int(RPAR(14)),' J/kg.K'
write(3,*)'Solid heat capacity :',int(RPAR(15)),' J/kg.K'
write(3,*)'Temperature ambient :',int(RPAR(16)),' K'
write(3,*)'Pressure atmospheric :',int(RPAR(29)),' Pa'
write(3,*)'Pressure feed :',int(RPAR(30)),' Pa'
write(3,*)'Heat of Adsorption :',int(RPAR(33)),' J/kg'


My output is not aligned in columns and looks untidy.
Please assist.

RE: How do you arrange output data from Fortran into a text file with specified columns widths?

Please visit any Fortran manual and read about the WRITE statement; in particular what it is that could go in place of the asterisk in "write(3,*)"...try something, experiment...the edit-compile-run cycle should be pretty short in this program.

If you really can't figure it out, show us what you got and then we can help you tweak it.

RE: How do you arrange output data from Fortran into a text file with specified columns widths?

implicit none
integer rpar(33),i

do i=1,33
rpar(i)=i
end do

write(*,900),'Model Parameters: '
write(*,900),'Column length :',int(RPAR(2)),' m'
write(*,900),'Mass transfer coeff N2 :',int(RPAR(3)),' 1/s'
write(*,900),'Mass transfer coeff O2 :',int(RPAR(4)),' 1/s'
write(*,910),'Saturation constants :',real(RPAR(7)),' kg/kgs'
write(*,900),'Overall heat transfer coeff:',int(RPAR(13)),
+' J/m2.s.K'
write(*,900),'Gas heat capacity :',int(RPAR(14)),' J/kg.K'
write(*,900),'Solid heat capacity :',int(RPAR(15)),' J/kg.K'
write(*,900),'Temperature ambient :',int(RPAR(16)),' K'
write(*,900),'Pressure atmospheric :',int(RPAR(29)),' Pa'
write(*,900),'Pressure feed :',int(RPAR(30)),' Pa'
write(*,900),'Heat of Adsorption :',int(RPAR(33)),' J/kg'
900 format (a28,i8,a)
910 format (a28,f8.2,a)
end

RE: How do you arrange output data from Fortran into a text file with specified columns widths?

In particular read about Fortran Format Specifiers.

RE: How do you arrange output data from Fortran into a text file with specified columns widths?

Same program but easier to read:

CODE --> 77

implicit none
      integer rpar(33),i
      
      do i=1,33
        rpar(i)=i
      end do
      
      write(*,900),'Model Parameters: '
      write(*,900),'Column length :',int(RPAR(2)),' m'
      write(*,900),'Mass transfer coeff N2 :',int(RPAR(3)),' 1/s'
      write(*,900),'Mass transfer coeff O2 :',int(RPAR(4)),' 1/s'
      write(*,910),'Saturation constants :',real(RPAR(7)),' kg/kgs'
      write(*,900),'Overall heat transfer coeff:',int(RPAR(13)),
     +' J/m2.s.K'
      write(*,900),'Gas heat capacity :',int(RPAR(14)),' J/kg.K'
      write(*,900),'Solid heat capacity :',int(RPAR(15)),' J/kg.K'
      write(*,900),'Temperature ambient :',int(RPAR(16)),' K'
      write(*,900),'Pressure atmospheric :',int(RPAR(29)),' Pa'
      write(*,900),'Pressure feed :',int(RPAR(30)),' Pa'
      write(*,900),'Heat of Adsorption :',int(RPAR(33)),' J/kg'
  900 format (a28,i8,a)
  910 format (a28,f8.2,a)
      end 

Output from th program:

CODE -->

Model Parameters:
             Column length :       2 m
    Mass transfer coeff N2 :       3 1/s
    Mass transfer coeff O2 :       4 1/s
      Saturation constants :    7.00 kg/kgs
Overall heat transfer coeff:      13 J/m2.s.K
         Gas heat capacity :      14 J/kg.K
       Solid heat capacity :      15 J/kg.K
       Temperature ambient :      16 K
      Pressure atmospheric :      29 Pa
             Pressure feed :      30 Pa
        Heat of Adsorption :      33 J/kg 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close