Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
37 Views

I/O bug when linking Fortran with C libraries

Some time ago I submitted an issue with Intel's ifort Beta version16 Fortran compiler that still does not seem to be resolved. I find that when I link a fortran code with a library that was written in C, I cannot open I/O units for formatted output. I get the error: forrtl: severe (257): formatted I/O to unit open for unformatted transfers. This error will appear no matter what unit number I try to use. I found at the time if I revert to ifort 15.0.2, the error goes away. Now, I am still getting the error with ifort version 16.0.2. Is there any hope to fix or resolve this bug?

0 Kudos
7 Replies
Highlighted
37 Views

Do you have a Premier Support issue number or a link to another forum thread where you reported this? I haven't been able to locate your earlier report and am not familiar with this issue. (I have written many mixed-language programs that don't have this problem.)

Also, note that your name shows here as "(name withheld)" because you have not selected a "display name" that is not an email address. You can change this by clicking on your name in the upper right and going to the Dashboard, then edit your profile.

0 Kudos
Highlighted
Beginner
37 Views

Hi Steve, Thanks for the response. I believe I've fixed the "(name withheld issue)".  Here's a link from one of the last e-mails (8/10/2015) I had from you on this issue. I presume the last number is the Premier issue number. By the way another problem I'm having is since you changed around your web-site, I haven't found a way to get back to this issue to remind myself what was done on it. If I click on this link it doesn't get me anywhere helpful. Is there still a way to get back to one's past Premier Support issue postings?

  https://businessportal.intel.com/irj/portal/MyIssue2?issueNum=6000117858

 

0 Kudos
Highlighted
37 Views

Don,

Yes, you fixed the name.

You should be able to log in to Premier Support at https://premier.intel.com/ The customer side of this looks very different than the Intel side, so I am unsure what the appearance is to you or what you need to do to see your issues. I do note that the name associated with that issue isn't yours (which is why I couldn't find it), but it is clear that you were the one communicating.

I looked up that issue and the last I see is a note from you last October saying that everything was working. Are you now saying the problem has returned?

0 Kudos
Highlighted
Beginner
37 Views

Steve,

I can log into Premier Support at https://premier.intel.com/, but don't find anyway to get from there to records of my earlier issue postings.  Anyway, the problem has returned and I don't recall how it was resolved earlier, other than reverting back to ifort 15.0.2. If you can see what was advised earlier or have other suggestions that would help.

0 Kudos
Highlighted
Black Belt
37 Views

Parallel to the forensic work on your Premier Support submission, would you please post a summary of the issue here? I tried to reproduce the problem with the code below using the description in #1, and did not observe an error with Parallel Studio 15.0.5 or 16.0.2 (OpenSuse Linux, and on Windows, with "csub_" replaced by "CSUB" in the C code). My test code simply reads the source code of the Fortran part (file ptest.f90) and prints it out with line numbers added, based on a line count that it gets from the C subroutine, which obtains the count by scanning the same file.

! test I/O to text files when C subprograms in lib are linked
! https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/628780
!
program ptest
implicit none
integer i,nln
character(len=132) line
open(11,file='ptest.lst',status='replace',action='write')
call csub(nln) ! C library routine returns number of lines in ptest.f90
open(10,file='ptest.f90',status='old',action='read')
!
do i=1,nln
   read(10,'(A)')line
   write(11,'(I4,2x,A)')i,trim(line)
end do
close(10)
close(11)
end program

The C subprogram:

#include <stdio.h>

void csub_(int *nln){
char lin[132];
FILE *fil=fopen("ptest.f90","r");
*nln=0;
while(fgets(lin,132,fil))(*nln)++;
fclose(fil);
}

 

0 Kudos
Highlighted
37 Views

The account you used to submit this wasn't under your name - I'm home right now and don't have access to that, but my recollection was that the email address ended in .nl. If I recall, it wasn't reproducible with 16.0 and had to do with some plotting library (PGPLOT?)

I'll look it up again when I get in tomorrow and send you an email about it.

0 Kudos
Highlighted
Beginner
37 Views

Steve, mecej4,

As inferred from Steve's recovery of my earlier Intel Premier submission record, the I/O issue was resolved by my reinstalling/rebuilding the Plplot graphics library (the C code I was linking to). This now works fine with ifort ver. 16.

Thanks for your help, Don

 

0 Kudos