×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Intrensic error

Intrensic error

Intrensic error

(OP)
Hello everyone

I'm using gfortran on SUSE to compile my code and receive the following error:

CODE

       yr_step = sign(1,delta_yr)                             
                       1
Error: 'b' argument of 'sign' intrinsic at (1) must be the same type and kind as 'a'

Here's my code:

CODE

        subroutine solar_loc(yr,t1,mean_long,declination)
        implicit none
        

        integer*2 yr,yr_step,delta_yr,i,iyr
        integer*4 t1
        integer*4 index
        real*4 mean_long,declination
        real*8 d,lambda,g,eps,L
        real*8 L0(10)/279.642,279.403,279.165,278.926,279.673,279.434,
     1                279.196,278.957,279.704,279.465/
        real*8 DL/0.985647/
        real*8 G0(10)/356.892984,356.637087,356.381191,356.125295,
     1    356.854999,356.599102,356.343206,356.087308,356.817011,356.56/
        real*8 DG/0.98560028/
        real*8 EPS0(10)/23.440722,23.440592,23.440462,23.440332,
     1    23.440202,23.440072,23.439942,23.439811,23.439679,23.439548/
        real*8 DE/-0.00000036/
        real sind,asind
        save

        d = 0

        if (yr .lt. 1900) then
           index = yr - 88
        else
           index = yr - 1988
        endif

        if (index .le. 0) then   
           delta_yr = index - 1  
        else if (index .gt. 10) then
           delta_yr = index - 10
        else
           delta_yr = 0
        endif

        if (index .le. 0) index = 1
        if (index .gt. 10) index = 10

        yr_step = sign(1,delta_yr)
        delta_yr = abs(delta_yr)  


        do i = 1,delta_yr
          if (yr_step .gt. 0) then
            iyr = 98 + i - 1
          else
            iyr = 89 - i
          end if
          if (mod(iyr,4).eq.0)then
            d = d + 366*yr_step   
          else
            d = d + 365*yr_step
          end if
        end do  

        d = d + t1/86400.

        L = L0(index) + DL*d
        g = G0(index) + DG*d
        do while (L.lt.0)   
          L = L + 360.      
        end do
        do while (g.lt.0)
          g = g + 360.   
        end do

        L = mod(L,360.0d0)
        g = mod(g,360.0d0)

        lambda = L + 1.915*sind(g) + 0.020*sind(2*g)
        eps = EPS0(index) + DE*d

        declination = asind(sind(eps)*sind(lambda))
        mean_long = L
        return
        end

Any suggestions? Thanks in advance!   

 

RE: Intrensic error

sign(a, b) returns a with the sign of b.  Both must be of the same type.  In your case, you have a being INTEGER and b being INTEGER*2.  Try

CODE

yr_step = sign(1_2,delta_yr)
Alternatively

CODE

integer*2 yrpositive
...
yrpositive = 1
...
yr_step = sign(yrpositive, delta_yr)
I prefer the first method but people who don't know the notation will moan about it in code reviews.
 

RE: Intrensic error

(OP)
Good thinking! Thanks.

RE: Intrensic error

(OP)
Both of the methods work well, but I'm sticking with the first one.

Now however I receive the error:

CODE

Function 'sind' has no IMPLICIT type

My guess is to fix this with:

CODE

real sind

Agree?

RE: Intrensic error

Agreed.

sind is one of those routines that may be intrinsic on some compilers (eg IVF).  On others you have to define it.

RE: Intrensic error

(OP)
Right.

So I added

CODE

real sind

But now the compiler complains

CODE

undefined reference to sind

Why is that?

RE: Intrensic error

sind is an intrinsic on some compilers but not on others.  You can define it as

CODE

real function sind(angle_deg)
real angle_deg
sind = sin(angle_deg * 3.1415926535 / 180.0)
end function sind

RE: Intrensic error

(OP)
Thanks! That does the trick.

But what about...

CODE

 lambda = L + 1.915*sind(g) + 0.020*sind(2*g)             
1
Error: Unclassifiable statement at (1)

 

RE: Intrensic error

At a guess, it doesn't like mixing the types.  Why not just make everything real*8

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close