PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

[FORTRAN] Using builtin-function

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
HayatoKuniie64033



Joined: 30 May 2013
Posts: 2

PostPosted: Tue May 13, 2014 1:30 am    Post subject: [FORTRAN] Using builtin-function Reply with quote

Hi everyone.

I wrote following code which call buildin function signal. And I compiled this code by following command. But I failed compilation. Should I pass the any linker option to compiler ? Compiler version is 13.5. Please teach me.

Source (test.F)
Code:

       program test
       implicit none
       real a,b,c
       integer ret, sigNum, flg
       external divByZeroHdler
       flg = -1
       !! P;ease reference /usr/include/bits/signum.h
       sigNum = 8
       a = 3
       b = 0
       WRITE(*,*) 'Hello'
       ret = signal(sigNum, divByZeroHdler, flg)
       c = a/b;
       WRITE(*,*) 'Good bye'

       end program test

       subroutine divByZeroHdler()
         WRITE(*,*) 'divByZeroHdler is called'
       end subroutine divByZeroHdler


compile command
Code:

$ pgfortran --version

pgfortran 13.5-0 64-bit target on x86-64 Linux -tp sandybridge
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2013, STMicroelectronics, Inc.  All Rights Reserved.
$ pgfortran test.F
PGF90-S-0038-Symbol, signal, has not been explicitly declared (test.F)
  0 inform,   0 warnings,   1 severes, 0 fatal for test

[/code]
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Tue May 13, 2014 1:24 pm    Post subject: Reply with quote

Hi,

Eliminating the 'implicit none' statement should allow your program to compile with PGI Fortran. However, the code may generate a floating-point NaN value assigned to the variable c instead of raising SIGFPE, so you may not get the behavior you were expecting.

Hope this helps,

+chris
Back to top
View user's profile
HayatoKuniie64033



Joined: 30 May 2013
Posts: 2

PostPosted: Tue May 13, 2014 6:27 pm    Post subject: Reply with quote

Is there any solution except eliminating 'implicit none' ?
Back to top
View user's profile
frnkyl004



Joined: 06 Dec 2011
Posts: 50

PostPosted: Wed May 14, 2014 12:01 am    Post subject: Reply with quote

Hi,

I think you need to declare your function. Adding
Code:
integer signal
or changing
Code:
integer ret, sigNum, flg
to
Code:
integer ret, sigNum, flg, signal
should work.

Cheers,
Kyle
Back to top
View user's profile
cparrott



Joined: 02 May 2011
Posts: 146

PostPosted: Thu May 15, 2014 9:19 am    Post subject: Reply with quote

Thanks, Kyle. That's probably an even better solution than the one I suggested.

Best regards,

+chris
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group