Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

GETLOG bug (linux)?

Thomas_F_1
Beginner
487 Views

GETLOG produces nothing on Linux when stdin is redirected.

$ cat main.f90 

!===============================================================================
PROGRAM MAIN
USE IFPORT
CHARACTER(16) :: user
CALL GETLOG(user)
PRINT *, "User: ",user
END
!===============================================================================

$ ifort main.f90
$ ./a.out
 User: fanning         
$ ./a.out < /dev/null
 User:                 
$ ifort -V
Intel(R) Fortran Compiler XE for applications running on IA-32, Version 15.0.5.223 Build 20150805
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

Also fails under:

Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.5.223 Build 20150805
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

0 Kudos
10 Replies
Kevin_D_Intel
Employee
487 Views

Thank you for your post. I will look into this.

0 Kudos
Kevin_D_Intel
Employee
487 Views

Thank you again for reporting this and for the convenient reproducer. Turns out this is reproducible on IA32 Linux only. I submitted this to Development for investigation/repair.

(Internal tracking id: DPD200377513)

(Resolution Update on 05/26/2016): This defect is fixed in the Intel® Parallel Studio XE 2016 Update 3 Release (ifort Version 16.0.3.210 Build 20160415 - PSXE 2016.3.067 / CnL 2016.3.210- Linux)

0 Kudos
Thomas_F_1
Beginner
487 Views

Glad it's being looked into. However I do see it on both ia32 and intel64. Hopefully the fix will apply to both.

Thanks!

 

0 Kudos
Kevin_D_Intel
Employee
487 Views

I see you noted that but I cannot reproduce this on intel64 even having tried multiple compilers. I will add a note in the internal tracking id to ensure Development is aware of your findings and ensure they consider that during their investigation.

What version of Linux do you use with intel64?

0 Kudos
Thomas_F_1
Beginner
487 Views

$ uname -a
Linux <hostname> 2.6.18-406.el5 #1 SMP Tue Jun 2 17:25:57 EDT 2015 x86_64 x86_64 x86_64 GNU/Linux

and

$ cat /etc/redhat-release 
CentOS release 5.11 (Final)

Let me know if you need other information.

0 Kudos
Thomas_F_1
Beginner
487 Views

I did a little more experimentation, and the issue may reside within Linux, not Intel Fortran. For example:

$ cat getlogin.cc
#include <iostream>
#include <unistd.h>
int main()
{
    std::cout << "Hello, World!" << std::endl;
    std::cout << "Login: " << getlogin() << std::endl;
}

$ c++ getlogin.cc
$ ./a.out
Hello, World!
Login: <mylogin>

but

$ ./a.out < /dev/null
Hello, World!
Login: $ (No login presented. Prompt appears here.)

It turns out that when using input redirection, the system call "getlogin" returns NULL.

 

 

 

 

0 Kudos
Kevin_D_Intel
Employee
487 Views

Appreciate the added details/insight. I'll relay this to Development. 

0 Kudos
Kevin_D_Intel
Employee
487 Views

I confirmed this defect is fixed in the Intel® Parallel Studio XE 2016 Update 3 release available from the Intel® Software Development Products Registration Center (IRC). Thank you for reporting this. The underlying defect with our Fortran compiler did relate to calling getlogin. Also, my confirmation of this fix was on IA-32 only. I was never able to reproduce this on Intel® 64; however, the fix does apply to both.

0 Kudos
Harald
Beginner
487 Views

Thomas,

for portable code I recommend

  call getenv ("LOGNAME", user)


instead of GETLOG.

Hope this helps,

Harald

 

0 Kudos
Steven_L_Intel1
Employee
487 Views

Or even more portable:

call GET_ENVIRONMENT_VARIABLE("LOGNAME",user)

0 Kudos
Reply