I’m a bit stuck on using hostnm to print the hostname. This is my program:
program main implicit none character(20) :: name integer :: status call HostNm(name, status) print*, "status = ", status print*, "name = ", name end program main
The problem is that when I compile this with pgf90, sometimes I get a load of gibberish at the end of the hostname because the character length is too long:
status = 32767
name = larchkC’Z
and at other times I just get a segmentation fault.
If I compile with gfortran I get this:
status = 0
name = larch
Which shows no error. What’s the correct way to use hostnm?