- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am working on moving an old Fortran Windows MDI program from the Watcom compiler to use the Intel Fortran compiler with Visual Studio 2022. The software has numerous instances of allocate that seem to initialize the allocated memory to a specific location in memory. This functionality is not included in the Intel Fortran Compiler. Here is an example:
allocate( d(1), location=dwCurveAddress(DocNum))
where d is a custom structure used throughout the program and dwCurveAddress is an array of integers that appear to be functioning as pointers to specific instances of "d", e.g.
structure /MyDataType/
integer ID
character szTitle*128
integer cutoff
end structure
type(MyDataType), dimension(:), allocatable :: d
integer dwCurveAddress(MAX_DOCUMENTS)
In the cases where "d" is allocated this way, it is being accessed and used immediately after allocation, suggesting the location= argument is initializing it to a location in memory rather than actually creating a new instance, I think. See the following example:
allocate( d(1), location=dwCurveAddress(DocNum))
if (d(1).cutoff .eq. 0) then
UseAmpLimits = 0
else
UseAmpLimits = 1
endif
How would I go about doing this with the Intel Fortran Compiler? It seems like dwCurveAddress should instead be an array of pointers to the individual "d" structures when they are allocated, but I haven't figured out how I should properly set this up?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting but what this Watcom allocate instruction is doing is a Watcom creation, it is not standard Fortran and indeed I think predated allocate being added to the standard Fortran language.
what it seems to be doing is allocating the structure at a specific memory address and further that memory address appears to hold data. I will also note that "structure" is also not Fortran but that might be replicable with a derived type but that would rather depend on the functionally/rules of the Watcom Structure thing working in the same way. Intel also has a non-standard structure type but writing new code using non-standard extensions is not a recommended move IMO.
You might be able to replicate something similar with pointers but I suspect there lies a world of pain. I Think you will be to rethink and refactor this code, trying to replicate the functional directly will be difficult/impossible/undesirable
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Interesting but what this Watcom allocate instruction is doing is a Watcom creation, it is not standard Fortran and indeed I think predated allocate being added to the standard Fortran language.
what it seems to be doing is allocating the structure at a specific memory address and further that memory address appears to hold data. I will also note that "structure" is also not Fortran but that might be replicable with a derived type but that would rather depend on the functionally/rules of the Watcom Structure thing working in the same way. Intel also has a non-standard structure type but writing new code using non-standard extensions is not a recommended move IMO.
You might be able to replicate something similar with pointers but I suspect there lies a world of pain. I Think you will be to rethink and refactor this code, trying to replicate the functional directly will be difficult/impossible/undesirable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>You might be able to replicate something similar with pointers but I suspect there lies a world of pain.
I agree, pointers may work, the source array/location may need TARGET attribute, or you could use a combination of CLOC and C_TO_FPOINTER. And, if any deallocate of these (former) allocatables exists, replace it with NULLIFY(YourPointer).
Do not forget that ASSOCIATE might be an easier method as it won't require target on the section of source.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page