Problem with a fortran program

In summary, the conversation involves a person trying to run a program and encountering an error message. The error is caused by the code not being split properly and the suggestion is to either put each write statement on its own line or use the continuation character. Additionally, it is suggested to make the calculation of the accept ratio and assign it to a variable before printing it out.
  • #1
selmayda
9
0
Hi;
I am trying to run a program which includes;

call AB
write(6,*) 'finished AB'
c---------
call ABp(Vup,gup)
call ABp(Vdn,gdn)
write(6,*) 'finished ABp'
c------------------------------------------------------------------
c do warmup sweeps
c-----

accept = 1
reject = 0

do 410 i = 1, iwarm
call sweep(i)
if (mod(i,10).eq.0) then
write(6,*) 'warmup sweep = ',i
endif
410 continue
write(6, *) 'after warmups, accept ratio = ',
1 float( accept ) / (accept+reject)
write(46,*)
write(46,*) 'after warmups, accept ratio = ',
1 float(accept)/(accept+reject)
c--------------------------------------------------------------------------

but I see an error message ;
multi0.f: In program `multi':
multi0.f:97:
write(6,*) 'accept ratio ='
1
multi0.f:98: (continued):
1 float(accept) / (accept+reject)
2
Invalid radix specifier `float' at (2) for typeless constant at (1)
multi0.f:98:
1 float(accept) / (accept+reject)
1 2
Concatenation operator at (1) must operate on two subexpressions of character type, but the subexpression at (2) is not of character type
mv: cannot stat `a.out': No such file or directory
c----------------------------------------------------------------------

what is the meaning of this message?

thanks.
 
Technology news on Phys.org
  • #2
It would be helpful to see the entire program.
 
  • #3
You may want to make your calculation of float(accept)/(accept+reject) previous to the write statement, assign the results to a single variable and print out such variable without any typecasting or anything.
 
  • #4
I'm reasoably sure that the errors are cause by these lines of code:
Code:
write(6, *) 'after warmups, accept ratio = ',
[color="red"]1 float( accept ) / (accept+reject)[/color]
write(46,*)
write(46,*) 'after warmups, accept ratio = ',
[color="red"]1 float(accept)/(accept+reject)[/color]

Fortran is very picky about splitting lines of code. Either put each write statement on its own line for the entire statement, or use the continuation character, & or +.
 
  • #5


Hello,

Based on the error message, it seems like there is an issue with the syntax of your code. Specifically, the use of the "float" keyword in line 98 is causing an error. Please double check the syntax for this line and make sure it is correct. Additionally, the error message mentions that there is no file called "a.out" which could also be a problem with the code or how it is being compiled. I would recommend carefully reviewing the code and checking for any syntax or compilation errors. If you are still having trouble, it may be helpful to consult with a colleague or a programming expert for further assistance.
 

What is a Fortran program?

A Fortran program is a computer program written in the Fortran programming language. Fortran, short for Formula Translation, was developed in the 1950s for scientific and engineering applications. It is still used today for high-performance computing and scientific research.

What are some common problems with Fortran programs?

Some common problems with Fortran programs include syntax errors, logic errors, and runtime errors. Syntax errors occur when the code is not written correctly and the compiler cannot understand it. Logic errors occur when the code does not produce the expected results, usually due to a mistake in the algorithm. Runtime errors occur during program execution and can be caused by various factors such as invalid input or memory issues.

How can I debug a Fortran program?

To debug a Fortran program, you can use a debugger tool or add print statements to your code to track the values of variables at different points in the program. You can also use error-checking features such as compiler warnings and runtime checks to identify potential issues in your code.

What are some best practices for writing Fortran programs?

Some best practices for writing Fortran programs include using meaningful variable names, organizing your code into modules and subroutines, and commenting your code to make it more readable. It is also important to follow Fortran coding conventions and to use compiler optimization options to improve the performance of your program.

Where can I find resources for learning and troubleshooting Fortran?

There are many online resources available for learning and troubleshooting Fortran, including tutorials, forums, and documentation from the Fortran language committee. You can also consult with other Fortran programmers and seek help from your colleagues or professors who have experience with the language.

Similar threads

  • Programming and Computer Science
Replies
4
Views
602
  • Programming and Computer Science
Replies
22
Views
3K
  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
19
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
26
Views
3K
Back
Top