1

I am doing my maser thesis on WIND turbine simulation On ANSYS CFX.To calculate a parameter I have to use a code written in FORTRAN. I am facing a very weird type of problem and need your help.The complete fortran code is quite long but I will only post the subroutine in the code that is causing problem.

I am using a subroutine to divide the blade in a no of radial elements.Two types of division is used and the radial positions of the elements are then stored in two 1-D arrays RI and RJ.

Later in the code, I got some error and I traced it back to this subroutine that it is not giving me correct values of RJ .The subroutine is giving correct values of RI. Then I displayed the results of RJ using the same loop in which it is calculated correct values of RJ. Fortunately the values of RJ were correct. Then in the same subroutine, immediately after that loop, I started another loop to display the values of RJ again and unfortunately this time they were not correct incorrect values of RJ even there is nothing between the two loops that could change the values of RJ. seemingly every element of RJ is replaced with the next element of RI. Hence I came to know that here is the error originating. I have rechecked the program and seemingly there is no error and the error is originating somewhere inside the subroutine. I am using another program on fortran without ANSYS CFX to calculate wind turbine performance using same subroutine and this problem is NOT coming in that program although the two subroutines in the two programs are exactly same. I need help in this matter as I am stuck in it for past few days. I am using Intel fortran compiler that comes with INTEL COMPOSER.

The subroutinea are as follows

CALL INIT(M,PI,PREC,R,HUBRAD,RI,RJ)

SUBROUTINE INIT(M,PI,PREC,R,HUBRAD,RI,RJ)


  INTEGER:: M
  REAL:: PI,PREC,R,HUBRAD
  REAL:: RI(41),RJ(41)
  !,RRI,RRJ)

    CALL LLPOINTS (PI,PREC,R,HUBRAD,M,RI,RJ)


    return
    End Subroutine

    SUBROUTINE LLPOINTS (PI,PREC,R,HUBRAD,M,RI,RJ)

  !Input arguments: M,Pi, PREC, R, HUBRAD 
  !Output arguments : RI, RJ

  INTEGER:: M
  REAL::PREC,R,HUBRAD
  REAL:: RI(41),RJ(41)
  INTEGER :: J
  character*100 ::string1, string2, string3

  CALL MESAGE( 'WRITE', 'subroutine INIT START' )  

  CALL MESAGE( 'WRITE', "RI   RJ    DJ")

  DO J=1,M+1   


        IF (J.LT.M+1) THEN   
        RI(J)=0.5E+00*(1.E+00+HUBRAD/R)-0.5E+00*(1.E+00-HUBRAD/R)
       &*COS((J-0.5E+00)*PI/M)

        RJ(J)=0.5E+00*(1.E+00+HUBRAD/R)-0.5E+00*(1.E+00-HUBRAD/R)
       &*COS((J-1.E+00)*PI/M)


        IF (ABS(RI(J)).LT.(1/PREC)) THEN

              STOP 
        ENDIF

        ELSE
           RJ(J)=1.E+00

          END IF


          write (string1,*) RI(J)
          write (string2,*) RJ(J)


          CALL MESAGE( 'WRITE', string1//' '//string2) 

      END DO

      CALL MESAGE( 'WRITE','ri     rj')
      do j =1,m

          write (string1,*) RI(J)
          write (string2,*) RJ(J)
          CALL MESAGE( 'WRITE', string1//' '//string2 ) 

      end do
      CALL MESAGE( 'WRITE', 'subroutine LLINE OK' )  

  END SUBROUTINE

You would be wondering why LLPOINTS is INSIDE INIT subroutine without any reason. Actually in the original program the subroutine INIT has a lot of other subroutines. I used only LLPOINTS and discarded rest of them as I did not need them

I have checked that my program does not have implicit none in any of the subroutines which according to my limited knowledge should be present. When I added implicit none to all subroutines, a number of compilation errors have occurred and seemingly in those errors, I have found that there were problems related to the declarations of a number of variables . I have resolved these issues and now when all issues are resolved, I have got the following error in compilation which was not coming before implicit none.

Error:unresolved external symbol LLINE referenced in function ACD_Dp.

I dont know how to deal with this error

8
  • 1
    You might want to try software.intel.com/en-us/forums/… Commented Jun 26, 2016 at 4:07
  • 1
    Could you show how this subroutine (LLPOINTS) is called, and how the actual arguments for RI and RJ are defined? The actual arguments may be incorrectly passed such that they point to memory regions with only a difference of by 1. Commented Jun 26, 2016 at 4:46
  • basically the argument "m" is the number into which the blade of the turbine is divided.The value of m is read from another input file and is passed on to this subroutine. I have already tested, the value of m is passed correctly to this subroutine. The size of RI and RJ are deliberately limited to 41. This is done to avoid allocatable arrays. By default this program can only work till m=40 elements ( the division into two arrays RI n RJ is such that the number of RI elements are equal to m and the number of RJ elements are equal to m+1) . Any value of m less than 40 should work. Commented Jun 26, 2016 at 10:12
  • check my edited question for calling of (LLifine) subroutine Commented Jun 26, 2016 at 10:13
  • 1
    Do you have any function (or subroutine) named LLINE somewhere? And how is LLINE used in your routine? The compiler thinks that LLINE is a function, while it cannot find its definition in any source code (at link time). Commented Jun 28, 2016 at 14:05

2 Answers 2

1

The weird behavior might originate from some (incorrect) actual arguments rather than subroutines themselves. To explain this, we first consider a simplified version of INIT() and LLPOINTS() as follows:

subroutine INIT ( a, b )
    implicit none
    real :: a( 5 ), b( 5 )

    call LLPOINTS ( a, b )
end subroutine

subroutine LLPOINTS ( a, b )
    implicit none
    real :: a( 5 ), b( 5 )
    integer :: i

    print *, "output (1):"
    do i = 1, 5
        a( i ) = i                !! set some values to a(:) and b(:)
        b( i ) = i * 100
        print *, a( i ), b( i )   !! check the values
    enddo

    print *, "output (2):"
    do i = 1, 4
        print *, a( i ), b( i )   !! check the values again
    enddo
end subroutine

This program sets some values to a(:) and b(:) and prints their values twice for double check (as in the OP's program). Now we consider the main program:

program main
    real :: a( 5 ), b( 5 )
    call INIT ( a, b )
end

which gives the expected result (with ifort test.f90 with v14.0):

 output (1):
   1.000000       100.0000
   2.000000       200.0000
   3.000000       300.0000
   4.000000       400.0000
   5.000000       500.0000
 output (2):
   1.000000       100.0000
   2.000000       200.0000
   3.000000       300.0000
   4.000000       400.0000

Next, let us suppose that a and b are declared erroneously as scalar variables

program main
    real :: a, b
    call INIT ( a, b )
end

or even with no declaration (i.e., with default implicit real(a-h,o-z) rule)

program main
    call INIT ( a, b )
end

We then obtain

 output (1):
   1.000000       100.0000
   2.000000       200.0000
   3.000000       300.0000
   4.000000       400.0000
   5.000000       500.0000
 output (2):
   1.000000       2.000000
   2.000000       3.000000
   3.000000       4.000000
   4.000000       5.000000

whose pattern seems to be very similar to that of the OP's output (i.e., all the elements are shifted by 1 in output (2)). That is, the reason for this weird behavior might be that we are passing scalars and accessing an invalid memory region (assuming that a and b are aligned contiguously in memory, with some trailing memory area). If so, memory mapping between main() and LLPOINTS() may look like this:

a       b      NG     NG     NG     NG
---------------------------------------
a(1)    a(2)   a(3)   a(4)   a(5)
        b(1)   b(2)   b(3)   b(4)   b(5)

If this is the case, since a(i+1) = b(i), we obtain the weird result in output (2) above. We can confirm this by inserting lines like

if ( loc( a(2) ) == loc( b(1) ) ) stop "trapped (ifort)"

in LLPOINTS(). And more importantly, if we attach

ifort -check test.f90

option, we can detect this automatically (with segmentation fault). So could you try this option to see whether this is the case...?

Sign up to request clarification or add additional context in comments.

Comments

0

Yes you are right. I have put the following lines

If ( loc( RJ(1) ) == loc( RI(2) ) ) then
call mesage ('write','trapped (ifort)')

stop

End If

and I have got the error , printing trapped (ifort). But the thing is , I have not declared scalar arguments RI, RJ anywhere. I have always declared them as vectors RI(41) and RJ(41)

5 Comments

Nice, I guess we are probably on the right track (i.e., some problem of actual arguments). There are several other possibilities for causing this error, but I believe attaching implicit none to relevant routines as well as attaching -check all (or /check:all) might be more useful (than guessing) to give some warning or error messages (hopefully!). Including relevant routines into a module is also useful for checking subroutine interfaces (e.g., whether the numbers and types of arguments are correct). I have added one more approach in my answer also.
so what do you suggest ? How should I proceed ? I am not a professional programmer and have little background in programming except knowing basic hings to work. A bit more explanation on how to solve the problem will be highly appreciated.
Hmm, did you try ifort -check all (or ifort /check:all) ? From this point on, we cannot go further until you get more information from warning or error message(s) with this kind of compiler opitons, or include more relevant codes into the question. Is it tricky to add this option in your compiler environment? (I've never used Windows for Intel fortran, so sorry in that case.)
One more try: Could you include the main program (with program statement), the routine including CALL INIT(...) statement, and all subroutines that connect these two program units into the Question (by editing it)? My guess is that there would be some problem in argument passing in these subroutines (the most likely case is that there's no declaration at some routine, resulting in scalars due to the implicit rule). Also, please try to include your "answer" as "Update" in your question (to gather all the info in one place).
Because this might also be some issue related to Intel + Windows , I think it would also be useful to ask the Intel forum also (see the first comment in your Question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.