[PGI Visual Fortran] Basic Questions on Printing Output

I’ve rather recently migrated to PGI Visual Fortran, so please be generous to my questions while it looks sily.

  1. With intel compiler, such a thing as write(4,’(F12.4)’) with n predefined is allowed. But with PGI compiler, it is not. Could anyone give me any suggestion?

  2. Also, when specifying the file name, not having the entire address results in some error; for example,
    open(4,file=‘C:\quant_new4\output\result.txt’, status =‘unknown’) is okay, but open(4,file=‘output\result.txt’, status =‘unknown’) delivers an error message. How would I be able to fix this issue?

Thanks a lot, in advance for you response :)

Hi,

With regard to the two issues you asked about here:

  1. PGI Visual Fortran does not support the variable format extension in pgf90/pgfortran – this is only supported in pgf77. You should use the recommended Fortran 90 method (internal I/O) to create the edit string when compiling with pgf90/pgfortran.

  2. Could you post the error message you are seeing here for this case?

Thanks in advance.

Best regards,

+chris

  1. … You should use the recommended Fortran 90 method (internal I/O) to create the edit string when compiling with pgf90/pgfortran.
    Does this mean there’s no getting around to use the variable format extension?

  2. The error message is shown:

PGFIO/stdio: No such file or directory
PGFIO-F-/OPEN/unit=4/error code returned by host stdio - 2.
 File name = output\zG_zT.txt
 In source file C:\quant\pgi\pgi\init_mod.f90, at line number 163

Thanks a lot

+Taejun

Hi Taejun,

This is an error message we would expect to see if the ‘output’ directory did not exist in the current working directory where the program is being run. Are you saying this is the case for you?

We tried a small experiment here. First, without the output directory in the current working directory, we see the same error you saw:

PGI$ z.exe
PGFIO/stdio: No such file or directory
PGFIO-F-/OPEN/unit=4/error code returned by host stdio - 2.
 File name = output\result.txt
 In source file z.f, at line number 1

Now, create the directory and notice the difference:

PGI$ mkdir output
PGI$ z.exe
PGI$

Best regards,

+chris

Just an aside, but this is a good reason to always use IOSTAT= and IOMSG= whenever you open a file in Fortran. I have been bitten enough with odd Fortran error messages with file handling that I do by default:

   open(unit=10, &
      file='input/moist_internal_rst', &
      status='old', &
      iostat=istat, &
      iomsg=iomsg, &
      access='sequential',&
      form='unformatted',&
      action='read')

   if (istat /= 0) then
      write (*,*) 'IOSTAT: ', istat
      write (*,*) 'IOMSG : ', trim(iomsg)
   end if

The IOMSG output is actually pretty helpful in most cases. In the case of a directory not existing I get (with an added stop):

(421) $ ./a.out
 IOSTAT:             2
 IOMSG : 
 No such file or directory
FORTRAN STOP

If you know you’re creating a file, then the only option is the directory doesn’t exist.