Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

problem with "if"

hamid_mosaddeghi
Beginner
1,065 Views
Dears

I need to insert if statement in "gofr" code, I inserted it in line 174:

if(zzz.ge.1d0.and.zzz.le.3d0)then

.
.
.
.
and insert "endif" in line 231

after compile i get this errors :

gofr.f(181): error #6099: An ENDDO statement occurred without a corresponding DO or DO WHILE statement.
enddo
^
gofr.f(189): error #8093: A do-variable within a DO body shall not appear in a variable definition context.
do i=1,9
-----------^
gofr.f(189): error #6511: This DO variable has already been used as an outer DO variable in the same nesting structure.
do i=1,9
-----------^
gofr.f(235): error #6317: An ENDIF occurred without a corresponding IF THEN or ELSE statement.
endif
------------^
gofr.f(241): error #6099: An ENDDO statement occurred without a corresponding DO or DO WHILE statement.
enddo
------^

why?

I attached two file, gofr.f original and gofr-edited. Please see and help me.
0 Kudos
4 Replies
Kevin_D_Intel
Employee
1,065 Views
With what you inserted, you've broken the if/then block at line 168.

Why are you inserting the endif way down at line 231? And not just at line 180?

[bash]   166         do i=1,natms
   167
   168           if(all.or.name(i).eq.atnam1.or.name(i).eq.atnam2)then
   169
   170             j=j+1
   171             name(j)=name(i)
   172             xxx=xyz(1,i)
   173             yyy=xyz(2,i)
   174          if(zzz.ge.1d0.and.zzz.le.3d0)then
   175             zzz=xyz(3,i)
   176             xyz(1,j)=xxx*rcell(1)+yyy*rcell(4)+zzz*rcell(7)
   177             xyz(2,j)=xxx*rcell(2)+yyy*rcell(5)+zzz*rcell(8)
   178             xyz(3,j)=xxx*rcell(3)+yyy*rcell(6)+zzz*rcell(9)
   179           endif
   180
   181         enddo[/bash]
0 Kudos
hamid_mosaddeghi
Beginner
1,065 Views
Dear Davis

if insert "endif" in line 180 , the result isnot acceptable. why?

what's your idea about it?

according the code you guess that if I insert "if" in line 174 and "endif" in line 180 is sufficient!!Ok?


0 Kudos
Kevin_D_Intel
Employee
1,065 Views
I'm sorry. I can't answer those questions. I have no understanding of this code (beyond reading comments). I was just addressing the reason for the compiler errors you caused by your changes.
0 Kudos
mecej4
Honored Contributor III
1,065 Views
> if insert "endif" in line 180 , the result isnot acceptable. why?
> what's your idea about it?


Questions of this type are not likely to be answered here. Asking why some result "is not acceptable" is itself not an acceptable question.

The questions relate to an application area about which most forum members may know nothing about. How are we to know whether results are acceptable or not? We do not even know the problem that your code is solving (nor am I, for one, interested in doing so).

Questions regarding Fortran and how to use the Intel compilers and libraries are appropriate, but you are responsible for developing and debugging the program.
0 Kudos
Reply