Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File operation question

Status
Not open for further replies.

rajabadsha

Programmer
May 4, 2006
11
CA
Hi,
I am new in Fortran and trying to convert the following Fortran program in C:


Program contbc

parameter (ndwgt=1000,ndpow=1000)

dimension cplot(ndwgt,ndpow)

character*80 project_name
character*80 control_file

open(10,file="setup.dat",form="formatted",
x status="old")

200 format(a)
read(10,200) project_name
write(6,200) project_name
read(10,200) control_file
write(6,200) control_file

read(10,*) nwgt_start,nwgt_end,nwgt_step
write(6,*) nwgt_start,nwgt_end,nwgt_step
read(10,*) pow_start,pow_end,pow_step
write(6,*) pow_start,pow_end,pow_step

close(10)

I have the following questions:
1) What does character*80 means? Why is there a * after the character?
2) What does dimension cplot means? Is cplot a keyword?
3) How does read and write works for:
a) read(10,*) nwgt_start,nwgt_end,nwgt_step
b) write(6,*) nwgt_start,nwgt_end,nwgt_step
How is nwgt_start, nwgt_end, and nwgt_step used without being initiated?

I need help...
 
1) character*80 = char[80]
2) cplot is not a keyword, dimension is and array declaration
i.e. float cplot[ndwgt,ndpow];
3) read = fscanf, write = fprintf
Use g format for *

nwgt etc are initialized - they are read in from a file.
 
It is open to question that this attempt to learn a programming language basic constructs (syntax and semantics) by the forum Q&A is the best way to go...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top