- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, i am trying to put a derived type within another derived type and pass down the length of some arrays inside the types. My code looks like this
program Console2
USE module_sub
implicit none
TYPE(fortran_forum(1000)) :: forum
forum%users%age=30
WRITE(*,*) 'The Fortran Forum contains',forum%n_users, '. They are', forum%users%age, 'years old'
forum%age=30
WRITE(*,*) 'The Fortran Forum contains',forum%n_users, '. They are', forum%age, 'years old'
end program Console2
MODULE module_sub
TYPE user(n_users)
INTEGER, LEN :: n_users=1
INTEGER, DIMENSION(n_users) :: age
end type user
TYPE fortran_forum(n_users)
INTEGER, LEN :: n_users=1
TYPE(user(n_users)) :: users
INTEGER, DIMENSION(n_users) :: age
end type fortran_forum
end module module_sub
The first variant with the nested Types doesn't even compile (Compilation Aborted - code 1) while the second varaint works fine. The problem seems to be that i am passing down the size of the arrays that i want in the nested derived type (n_users), is that illegal? Is there another way to achieve this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe this code is valid - NAG Fortran compiles and executes it OK. I haven't found any words in the standard to suggest otherwise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@TD5 ,
As fed back to you upthread by @Steve_Lionel , your code conforms to the standard as far as I can tell.
Readers can help you better if you illustrate with relevant details as to the compiler error (and the compiler version) with your first variant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had not tried it with ifort - when I do, with the 2021.6.0 compiler, it works fine. My guess is that you are using an old compiler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That may be the reason, i tried it with Intel(R) Visual Fortran Compiler 19.1.3.311 [Intel(R) 64] and Intel(R) Visual Fortran Compiler 19.1.0.166 [Intel(R) 64].
Both compilers dont give me much to work with, the error reads
1>------ Erstellen gestartet: Projekt: Console2, Konfiguration: Debug x64 ------
1>Compiling with Intel(R) Visual Fortran Compiler 19.1.3.311 [Intel(R) 64]...
1>Console2.f90
1>C:\Users\...\Desktop\Console2\Console2\Console2.f90: catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error.
1>Internal error store_pdtlen_data_space: Cannot find record
1>compilation aborted for C:\Users\...\Desktop\Console2\Console2\Console2.f90 (code 1)
1>
1>Build log written to "file://C:\Users\...\Desktop\Console2\Console2\x64\Debug\BuildLog.htm"
1>Console2 - 1 error(s), 0 warning(s)
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
and the build log:
Compiling with Intel(R) Visual Fortran Compiler 19.1.3.311 [Intel(R) 64]...
ifort /nologo /debug:full /Od /warn:interfaces /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc160.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64" /Qm64 "C:\Users\...\Desktop\Console2\Console2\Console2.f90"
C:\Users\...\Desktop\Console2\Console2\Console2.f90: catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error.
Internal error store_pdtlen_data_space: Cannot find record
compilation aborted for C:\Users\...\Desktop\Console2\Console2\Console2.f90 (code 1)
Console2 - 1 error(s), 0 warning(s)
The code line that is responsible is definitely
INTEGER, DIMENSION(n_users) :: age
inside the user type. As soon as i comment that line out, it works fine.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page