PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

handling of exit status, bug or feature?

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



Joined: 08 Dec 2010
Posts: 2

PostPosted: Wed Dec 08, 2010 2:25 am    Post subject: handling of exit status, bug or feature? Reply with quote

Hi,

I have one problem with programs compiled with the pgf90 compiler that I cannot find any references to in the documentation or in this forum.
The point is that I need to adapt my program to certain interface guidelines, and one of them is the ability to generate non-zero exit status when a problem occurs.

In fortran I am used to code this using the stop command, and would expect a command like 'stop 132' to exit my program, maybe print a message to stderr and then set the status environment variable to a value of 132, so this can easily be tested in scripts calling this program.
This procedure works for all fortran 90 compilers I know of, except for pgf90.

Now I don't actually don't know if this behaviour is required by the Fortran language standard, but even if it is not, it would be a very usefull addition for those who need it.

A few lines of sample code to demonstrate this on my linux machine:

>cat teststop.F90
program teststop

print *,'just a test print'
stop 132

end program teststop

>pgf90 -o teststop teststop.F90
>./teststop
just a test print
132
>echo $status
0

For comparison, the ifort compiler behaves like this:

>ifort -o teststop teststop.F90
>./teststop
just a test print
132
>echo $status
132

For reference, the versions used for this test:

>pgf90 -V

pgf90 10.5-0 32-bit target on x86 Linux -tp penryn
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2010, STMicroelectronics, Inc. All Rights Reserved.

>ifort -V
Intel(R) Fortran Compiler for applications running on IA-32, Version 10.1 Build 20071116 Package ID: l_fc_p_10.1.011
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

Best regards,

Jos.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6215
Location: The Portland Group Inc.

PostPosted: Wed Dec 08, 2010 9:46 am    Post subject: Reply with quote

Hi Jos.

The F2003 standard only states that the digit or string after the STOP should be printed upon termination. The F2008 standard does recommend that if the stop code is an integer, then the value should be used as the exit status, however, it does not require it.

Though, it does make sense to add and shouldn't be too difficult. Hence I've added a feature request (TPR#17524). Though we'll need to determine what the behavior should be if the stop-code is greater than 255 or is a string.

For now, you can simply add a call to the C exit routine to set the exit status. For example:

Code:
% cat test.F90

program teststop
print *,'just a test print'
call exit(132)
end program teststop

% pgfortran test.F90 ; a.out ; echo $status
 just a test print
132
% ifort test.F90 ; a.out ; echo $status
 just a test print
132


Thanks,
Mat
Back to top
View user's profile
JdeKloe



Joined: 08 Dec 2010
Posts: 2

PostPosted: Fri Dec 10, 2010 8:21 am    Post subject: Reply with quote

Hi Mat,

thanks for your reply, and for giving me this workaround.
I'll see this new feature then in a future pgf90 version.

For integer numbers outside the valid range 0-255, the simplest thing probably is to issue a compiler error to warn the user.

Jos.
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 445

PostPosted: Mon Nov 25, 2013 5:12 pm    Post subject: 17524 - Feature rquest: Use STOP's stop-code as the exit sta Reply with quote

We have implemented this in the 13.9 release.

thanks,
dave
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