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!

Problem with format when compiling

Status
Not open for further replies.

enrique79

Programmer
Oct 27, 2009
2
US
Hi,

I have a little problem when compiling.

I have a very long fortran code from someone else and I need to compile it for linux. The code compiles ok in windows using the old Microsoft Developer Studio, but it does not compile with gfortran or g77.

The problem are these type of format lines:

FORMAT(' node',5X,<nmin>a12)

For example, in this case I want the code to write a certain string as many times as the value of the variable <nmin> with the format a12, but gfortran or g77 don´t like it.

How shall I do to be able to fix this problem and compile the script for linux?. It may be something easy, but I'm not a fortran expert.

Thanks a lot for your help.
 
Hi enrique79

You can do this in at least two ways. If "nmin" is a reasonable low figure, you can put a number before a12:

format (' node',5x,20a12)

You can also put a12 in paranthesis, but then the output will be a little bit different:

format (' node',5x,(a12))

Try this:
Code:
	program test

	character*5 str
	str = 'xxxxx'

	write(*,100) str,str,str,str,str
100	format (' node',5x,20a12)

	write(*,200) str,str,str,str,str
200	format (' node',5x,(a12))

	end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top