- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I am having a problem with the return code from the SYSTEM intrinsic
function.
The code is question is simply attempting to rename a file:status=system("mv -f "//from_file//" "//to_file)if (status/=0) call io_abort('Error in renaming '//from_file//' to '//to_file)
On most systems this works perfectly well. But on just 3 systems the
status code returned is non-zero, although the rename apparently
succeeded. A slightly deeper investigation reveals a puzzle -
the code returned by "system" is greater than 256. In fact the least
significant byte is zero and the second-least significant byte is nonzero.
According the the "system" entry in the manual this is just the status
code returned by the shell, which according to the bash manpage must
be < 256. It looked as if the rename actually succeeded but that the
system is returning an unexpected status.
In all of the failing cases the file concerned is on a network file
system; one case is AFS, and the other two are panasus filesystems
mounted using NFS. All of the cases were of x86_64 architecture and
the 64-bit compilers were used (9.1.039).
How is it possible for SYSTEM() to return a 16-bit error code? And
if so how should it be interpreted to determine success or failure
of the called command?
Keith Refson
링크가 복사됨
1 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I think to be safe use IAND to produce a result containing the low 8 bits of the return code from SYSTEM.
result = (IAND(SYSTEM(string), 255)
if(result .NE. 0) then
write(*,*) "System error", IERRNO()
endif