Fortran What Is the Meaning of This Fortran Error Message?

  • Thread starter Thread starter selmayda
  • Start date Start date
  • Tags Tags
    Fortran Program
AI Thread Summary
The discussion centers around an error encountered while running a Fortran program. The error message indicates issues with the use of the `float` function and the concatenation of write statements. It suggests that the calculation of `float(accept) / (accept + reject)` should be assigned to a variable before being printed, rather than being included directly in the write statement. Additionally, it emphasizes the importance of proper line continuation in Fortran, recommending that each write statement be on its own line or use the continuation character to avoid syntax errors. The overall focus is on resolving the coding errors to ensure successful execution of the program.
selmayda
Messages
9
Reaction score
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
It would be helpful to see the entire program.
 
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.
 
I'm reasoably sure that the errors are cause by these lines of code:
Code:
write(6, *) 'after warmups, accept ratio = ',
1 float( accept ) / (accept+reject)[/color]
write(46,*)
write(46,*) 'after warmups, accept ratio = ',
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 +.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top