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

Data Structure IO

dannycat
New Contributor I
1,400 Views

The following data structure is used inan application, that was originally written in CVF, and is written out to a binary file using a single write statement WRITE(IUNIT) cf(1) .

! Data Structure
type CORD_FRAME
sequence
character*50 :: dsc = ' ' ! Title
integer :: id = 0 ! Id Number
integer(2) :: on = 0 ! Active Flag
integer :: type = CF_RECTANGULAR ! System type ! 1=Rect, 2=Cylindrical, 3=Spherical
integer :: cid = 0 ! Reference Co-Ordinate System
logical :: resolved = .false. ! Transformation resolved
union
map
real*8 :: ax(18) ! Axis Data
end map
map
real*8 :: org(3) ! Origin
real*8 :: za(3) ! Z axis point
real*8 :: zx(3) ! ZX plane point
real*8 :: t(3,3) ! Transformation Matrix
end map
end union
real*8 :: gorg(3) ! Global Origin
integer(2) :: flg(NMSIZ) = 0 ! Group Flags
end type

type(CORD_FRAME) :: cf(100)

When I attempt to read the data back inusing the IVF version when savedusing theCVF version the cf()%ax array is corrupted. A similar problem occurs when the roles are reversed. I suspect the problem is in data alignment settings as there are two variables that don't fall on the four byte boundaries (dsc and on) within the data structure.The IVFconfiguration of the applicationwas created by converting the CVF so should be set up the same.
I'm not surewhether or notthis problem has only cropped up since upgrading to 11.1 butI have recently made achange to the code was to increase the %dsc character variable from 30 to 50. I have checked that both IVF and CVFuse the same definition of data structures.

Has any change been made in 11.1 that will cause this behaviour?

0 Kudos
9 Replies
bmchenry
New Contributor II
1,400 Views

In the event you are a weekend warrier and don't want to wait until Monday for an Intel response, my 1st guess is that you need to investigate the settings for compatibility.
In there you will find choices for unformatted file conversion.
Project-> Properties->Configuration Properties->Fortran Compatibility->Unformatted File Conversion
I'd suspect that CVF has a different default then IVF and toying with those options should assist.
Likewise i wonder: why not convert the CVF program to IVF? That would avoid any issues between compiler defaults?
0 Kudos
dannycat
New Contributor I
1,400 Views
I would very muchlike to leave CVF behind but there are a few issues I need to resolve:

Firstly the CVF version of my application is fully tested and validated and until I am happy with the IVF version I need to keep both configuarations alive;

secondlyI find the Visual Studio 9.0/IVF environment very unstable, for example if you right click source windowwhen the pointer is positioned to the left of a variable it invariably crashes. This is something I do regularly in Visual Studio 6 when setting up awatch or interrogating the contents of variables. On another machine I cannot use the search feature in VS9otherwise it crashes.
In VS6/CVF you can use the F1 key to get help on any function including WIndows API. I can't get this with VS9/IVF.

finally I need the unformatted binary 'database' files to be identical while I complete my testing. There was no problem with this until I upgraded to 11.1.35. I hope it just a compiler setting issue as you suggested.

Perhaps some of these issues are down to my ignorance but I don't have the time to dig around too much for solutions.
0 Kudos
Paul_Curtis
Valued Contributor I
1,400 Views
Quoting - dannycat
I would very muchlike to leave CVF behind but there are a few issues I need to resolve:

Firstly the CVF version of my application is fully tested and validated and until I am happy with the IVF version I need to keep both configuarations alive;

secondlyI find the Visual Studio 9.0/IVF environment very unstable, for example if you right click source windowwhen the pointer is positioned to the left of a variable it invariably crashes. This is something I do regularly in Visual Studio 6 when setting up awatch or interrogating the contents of variables. On another machine I cannot use the search feature in VS9otherwise it crashes.
In VS6/CVF you can use the F1 key to get help on any function including WIndows API. I can't get this with VS9/IVF.

finally I need the unformatted binary 'database' files to be identical while I complete my testing. There was no problem with this until I upgraded to 11.1.35. I hope it just a compiler setting issue as you suggested.

Perhaps some of these issues are down to my ignorance but I don't have the time to dig around too much for solutions.

I use IVF 11.1.038 with VS2008, of which the current release is version 9 (presumably that's what you mean by "VS9"?), with many projects formerly developed with CVF, with none of the cited problems. First, I strongly suggest you create a new IVF project and import all the resources directly (which you can do by tagging files in bulk, so this is easy and quick). The automatic Fortran project upgrade tool (DevStudio to VS) introduced many problems in my projects, especially with build order and the dependency checker, which all went away when the project was rebuilt as native IVF/VS. Also, many compilation defaults are very different; in particular, CVF defaulted to /Qsave, which you may or may not want to invoke with IVF (add SAVEs where needed instead).

Fortran help setup seems to require user action, as the default Fortran VS integration doesn't always do the job. This is discussed in several recent threads in this forum, but basically you need to follow the help instructions to select the Intel content, which has to be done several times in different menus, but when done produces exactly the desired results, in which F1 keys directly to Fortran keywords, and can also bring up all of the Win32 API help as well.

Many of my programs use file i/o with binary files containing UDTs, and I have not seen any differences or had any compatibility problems between files created with CVF and IVF program versions. Perhaps a detailed bytewise comparison of your data files created by different compiler versions might shed light on what's going wrong.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,400 Views

Explicitly state the size of all integers and thelogical. IOW assure that they are explicitly stated to be the same size (on both sides).

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
1,400 Views
Well, this is interesting. ifort is definitely doing it different from CVF in that padding is being inserted before the UNION even in the presence of SEQUENCE. I will note, though, that SEQUENCE doesn't claim to prevent padding, only reordering. Nevertheless, SEQUENCE is supposed to prevent padding in our implementation (and does, other than for UNIONs.) I will report this to the developers (issue ID DPD200138527).

Here's how you fix it (this will be accepted by CVF too.)

Bracket the TYPE declaration as follows:

!DEC$ OPTIONS /NOALIGN
TYPE CORD_FRAME
...
END TYPE CORD_FRAME
! Other types if you want
!DEC$ END OPTIONS
0 Kudos
dannycat
New Contributor I
1,400 Views
Well, this is interesting. ifort is definitely doing it different from CVF in that padding is being inserted before the UNION even in the presence of SEQUENCE. I will note, though, that SEQUENCE doesn't claim to prevent padding, only reordering. Nevertheless, SEQUENCE is supposed to prevent padding in our implementation (and does, other than for UNIONs.) I will report this to the developers (issue ID DPD200138527).

Here's how you fix it (this will be accepted by CVF too.)

Bracket the TYPE declaration as follows:

!DEC$ OPTIONS /NOALIGN
TYPE CORD_FRAME
...
END TYPE CORD_FRAME
! Other types if you want
!DEC$ END OPTIONS

Thanks Steve, I will try this. Does the Structure Member Alignment setting /align:recnbyte override the sequence behaviour? In my project it is set to Default (which I assume is 4 bytes). In CVF it is set to *Natural which should be the same.
0 Kudos
Steven_L_Intel1
Employee
1,400 Views

Yes, /align:rec1byte is another solution.
0 Kudos
Steven_L_Intel1
Employee
1,400 Views
This bug has been fixed in our sources. The fix should appear in 11.1 Update 3, currently planned for late October.
0 Kudos
Steven_L_Intel1
Employee
1,400 Views
This problem is corrected in 11.1 Update 3, available now.
0 Kudos
Reply