- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I know that my compiler is licensed, but I am not sure if we are paid for support. I just got a compiler failure trying to use parameterized derived types. I am going to attach the build log, which is very short. This is just a proof of concept program.

Compiling with Intel(R) Visual Fortran Compiler 19.0.5.281 [IA-32]... ifort /nologo /debug:full /Od /fpp /extend_source:80 /warn:none /module:"Debug\\" /object:"Debug\\" /Fd"Debug\vc150.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86" /Qm32 "C:\Michael\params_test_2\Console1\Console1\bonddefinition.f90" C:\Michael\params_test_2\Console1\Console1\$OVERRIDE.fi(29): 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:\Michael\params_test_2\Console1\Console1\bonddefinition.f90 (code 1) test_params_2 - 1 error(s), 0 warning(s)

I could not attach the html file. So I just added the text.

Thanks.

Link Copied

- « Previous
- Next »

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

the support team is separate from the development team. I submitted the issue with appropriate tags, it's in 'the system' at high priority.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

```
@jimdempseyatthecove wrote:
.. I believe the parameters need to be parameters. ..
```

Jim,

For objects of parameterized derived types that are declared with the ALLOCATABLE attribute, the length-type parameters of the derived type can be deferred i.e., declared with the colon (":") token.

Readers,

For any one interested in a working example of a parameterized derived type, here's a simple one that encapsulates and "information hides" the operations toward a matrix 'class': the reader will notice how such a derived type definition allows one to think like a "library developer" and essentially "package" a "class" in a module that can work, in principle, with different data types with just a switch on the client side. In this example, that is shown with different floating-point types i.e., with REAL kinds in Fortran:

```
module kinds_m
integer, parameter :: R4 = selected_real_kind( p=6 )
integer, parameter :: R8 = selected_real_kind( p=12 )
end module
module matrix_m
use kinds_m, only : R4, R8
private
type, public :: matrix_t(k,rows,cols)
integer, kind :: k = R4
integer, len :: rows, cols
private
real(kind=k) :: m_dat(rows, cols)
contains
private
procedure, pass(this) :: getval_r4
procedure, pass(this) :: getval_r8
procedure, pass(this) :: setvals_r4
procedure, pass(this) :: setvals_r8
procedure, pass(lhs) :: mult_r4
procedure, pass(lhs) :: mult_r8
generic, public :: operator(*) => mult_r4, mult_r8
generic, public :: set => setvals_r4, setvals_r8
generic, public :: assignment(=) => setvals_r4, setvals_r8
generic, public :: val => getval_r4, getval_r8
end type
contains
function getval_r4( this, i, j ) result( r )
! Argument list
type(matrix_t(k=R4,rows=*,cols=*)), intent(in) :: this
integer, intent(in) :: i
integer, intent(in) :: j
! Function result
real(kind=R4) :: r
! Checks elided
r = this%m_dat(i, j)
end function
function getval_r8( this, i, j ) result( r )
! Argument list
type(matrix_t(k=R8,rows=*,cols=*)), intent(in) :: this
integer, intent(in) :: i
integer, intent(in) :: j
! Function result
real(kind=R8) :: r
! Checks elided
r = this%m_dat(i, j)
end function
subroutine setvals_r4( this, dat )
! Argument list
type(matrix_t(k=R4,rows=*,cols=*)), intent(inout) :: this
real(kind=R4), intent(in) :: dat(:,:)
! Checks elided
this%m_dat = dat
end subroutine
subroutine setvals_r8( this, dat )
! Argument list
type(matrix_t(k=R8,rows=*,cols=*)), intent(inout) :: this
real(kind=R8), intent(in) :: dat(:,:)
! Checks elided
this%m_dat = dat
end subroutine
function mult_r4( lhs, rhs ) result( r )
! Argument list
type(matrix_t(k=R4,rows=*,cols=*)), intent(in) :: lhs
type(matrix_t(k=R4,rows=lhs%rows,cols=*)), intent(in) :: rhs
! Function result
type(matrix_t(k=R4,rows=lhs%rows,cols=rhs%cols)) :: r
r%m_dat = matmul( lhs%m_dat, rhs%m_dat )
end function
function mult_r8( lhs, rhs ) result( r )
! Argument list
type(matrix_t(k=R8,rows=*,cols=*)), intent(in) :: lhs
type(matrix_t(k=R8,rows=lhs%rows,cols=*)), intent(in) :: rhs
! Function result
type(matrix_t(k=R8,rows=lhs%rows,cols=rhs%cols)) :: r
r%m_dat = matmul( lhs%m_dat, rhs%m_dat )
end function
end module
program matrix_multiply
use matrix_m, only : matrix_t
blk1: block
use kinds_m, only : WP => R4
real(WP), allocatable :: x(:,:), y(:,:), z(:,:)
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: A
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: B
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: C
integer, parameter :: L = 2, M = 3, N = 4
integer :: i, j
write ( *, * ) "Block 1: matrix operations with precision ", precision(x)
x = reshape(source=[( real(i, kind=WP), i=1, L*M )], shape=[L, M])
y = reshape(source=[( real(-i, kind=A%k), i=1, M*N )], shape=[M, N])
z = matmul( x, y )
allocate( matrix_t(k=WP,rows=L,cols=M) :: A )
allocate( matrix_t(k=WP,rows=M,cols=N) :: B )
allocate( matrix_t(k=WP,rows=L,cols=N) :: C )
A = x
B = y
C = A * B
print *, "Result of matrix multiplication: C = A * B"
print *, "C is a ", C%rows, " x ", C%cols, "matrix:"
do i = 1, C%rows
do j = 1, C%cols
write (*, fmt="(g0,1x)", advance="no" ) C%val(i,j)
end do
write (*, *)
end do
write( *, * ) "Expected values: "
do i = 1, L
do j = 1, N
write (*, fmt="(g0,1x)", advance="no" ) z(i,j)
end do
write (*, *)
end do
end block blk1
write ( *, * )
blk2: block
use kinds_m, only : WP => R8
real(WP), allocatable :: x(:,:), y(:,:), z(:,:)
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: A
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: B
type(matrix_t(k=WP,rows=:,cols=:)), allocatable :: C
integer, parameter :: L = 3, M = 4, N = 5
integer :: i, j
write ( *, * ) "Block 2: matrix operations with precision ", precision(x)
x = reshape(source=[( real(i, kind=WP), i=1, L*M )], shape=[L, M])
y = reshape(source=[( real(-i, kind=A%k), i=1, M*N )], shape=[M, N])
z = matmul( x, y )
allocate( matrix_t(k=WP,rows=L,cols=M) :: A )
allocate( matrix_t(k=WP,rows=M,cols=N) :: B )
allocate( matrix_t(k=WP,rows=L,cols=N) :: C )
A = x
B = y
C = A * B
print *, "Result of matrix multiplication: C = A * B"
print *, "C is a ", C%rows, " x ", C%cols, "matrix:"
do i = 1, C%rows
do j = 1, C%cols
write (*, fmt="(g0,1x)", advance="no" ) C%val(i,j)
end do
write (*, *)
end do
write( *, * ) "Expected values: "
do i = 1, L
do j = 1, N
write (*, fmt="(g0,1x)", advance="no" ) z(i,j)
end do
write (*, *)
end do
end block blk2
end program
```

Here's the expected output using Intel Fortran compiler 19.1 update 2:

```
C:\Temp>ifort /standard-semantics /warn:all /stand:f18 p.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.2.254 Build 20200623
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:p.exe
-subsystem:console
p.obj
C:\Temp>p.exe
Block 1: matrix operations with precision 6
Result of matrix multiplication: C = A * B
C is a 2 x 4 matrix:
-22.00000 -49.00000 -76.00000 -103.0000
-28.00000 -64.00000 -100.0000 -136.0000
Expected values:
-22.00000 -49.00000 -76.00000 -103.0000
-28.00000 -64.00000 -100.0000 -136.0000
Block 2: matrix operations with precision 15
Result of matrix multiplication: C = A * B
C is a 3 x 5 matrix:
-70.00000000000000 -158.0000000000000 -246.0000000000000 -334.0000000000000 -422.0000000000000
-80.00000000000000 -184.0000000000000 -288.0000000000000 -392.0000000000000 -496.0000000000000
-90.00000000000000 -210.0000000000000 -330.0000000000000 -450.0000000000000 -570.0000000000000
Expected values:
-70.00000000000000 -158.0000000000000 -246.0000000000000 -334.0000000000000 -422.0000000000000
-80.00000000000000 -184.0000000000000 -288.0000000000000 -392.0000000000000 -496.0000000000000
-90.00000000000000 -210.0000000000000 -330.0000000000000 -450.0000000000000 -570.0000000000000
C:\Temp>
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Fortran Fan,

I do not know if I have to set a compiler switch or it is just 19.1 update 1. I am getting errors 8363 and 6361 on the lines using the reshape function.

Is that something on my end I need to do.

Thanks,

Michael

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

```
Fortran Fan,
I do not know if I have to set a compiler switch or it is just 19.1 update 1. I am getting errors 8363 and 6361 on the lines using the reshape function.
Is that something on my end I need to do.
Thanks,
Michael
```

Michael,

Presuming you're trying out the code in my earlier post and that's why you have addressed your latest comment to me, technically you should not need anything special on your end. I just tried 19.1 Update 1 using the shortcut created by the installer i.e., Windows -> Start -> Programs -> Intel Parallel Studio XE 2020 -> Compiler 19.1 Update 1 for Intel (R) 64 .. and it worked ok. Please see the steps I followed below. Can you try the exact same and see if you get the same response as I do:

```
C:\Temp>ifort /standard-semantics /warn:all /stand:f18 p.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.1.216 Build 20200306
Copyright (C) 1985-2020 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:p.exe
-subsystem:console
p.obj
C:\Temp>p.exe
Block 1: matrix operations with precision 6
Result of matrix multiplication: C = A * B
C is a 2 x 4 matrix:
-22.00000 -49.00000 -76.00000 -103.0000
-28.00000 -64.00000 -100.0000 -136.0000
Expected values:
-22.00000 -49.00000 -76.00000 -103.0000
-28.00000 -64.00000 -100.0000 -136.0000
Block 2: matrix operations with precision 15
Result of matrix multiplication: C = A * B
C is a 3 x 5 matrix:
-70.00000000000000 -158.0000000000000 -246.0000000000000 -334.0000000000000 -422.0000000000000
-80.00000000000000 -184.0000000000000 -288.0000000000000 -392.0000000000000 -496.0000000000000
-90.00000000000000 -210.0000000000000 -330.0000000000000 -450.0000000000000 -570.0000000000000
Expected values:
-70.00000000000000 -158.0000000000000 -246.0000000000000 -334.0000000000000 -422.0000000000000
-80.00000000000000 -184.0000000000000 -288.0000000000000 -392.0000000000000 -496.0000000000000
-90.00000000000000 -210.0000000000000 -330.0000000000000 -450.0000000000000 -570.0000000000000
C:\Temp>
```

A quick comment on the compiler options you will see above:

- I prefer /
**standard-semantics**as a way to guard against any legacy considerations the compiler might bring into play. It's likely not the case here and this option may not be necessary, but that's what I had used so as a check you may want to do the same, - /
**warn:all**, as you would know, is just a diagnostic option and the intent here is to show the lack of any diagnostics being issued by the Intel Fortran compiler and thus to indicate to readers Intel compiler is unable to point out any flags with the code, should there be any. But this option is clearly not necessary, - /
**stand:f18**is along the same lines as /warn:all, a diagnostic option to flag the readers of any inconsistency with the current Fortran 2018 standard. The lack of any messages in the output can inform the readers the Intel Fortran compiler is unable to locate any nonstandard elements in the shown code. Again, not really needed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

" I am getting errors 8363 and 6361 on the lines using the reshape function.Is that something on my end I need to do."

well those would indicate syntax errors. show a code sample.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

```
@andrew_4619 wrote:
" I am getting errors 8363 and 6361 on the lines using the reshape function.Is that something on my end I need to do."
well those would indicate syntax errors. show a code sample.
```

Hmm.. I wonder if Michael had a copy-paste issue again with the code.

Michael, here's the example code I had **posted previously** but this time as an attachment. Can you please try downloading it and trying it out exactly (i.e., without any code changes) with the instructions I showed in my previous post?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Please don't simply cite error numbers. Show us the complete and exact text of the error messages.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

The down load worked much better and the code ran as expected.

Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

```
@kolber__Michael wrote:
The down load worked much better and the code ran as expected. ..
```

That's good.

Now if you review a book such as "**Modern Fortran Explained**" (this link for the book is for the prior edition but I give this because I think it's written much better than their latest one on Fortran 2018) with such a working example, you can familiarize yourself with standard Fortran facilities toward defined kinds, use of modules, derived types, type parameters, memory allocation, operator overloading, object-oriented aspects, etc. that you can consider for your code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

**Based on the comments that I have read, I am starting to wonder if we can really made the software changes that I am trying to do. Currently our application uses an include file that defines over 50 parameters. We build 2 versions of the application one that has full capacity and one that has limited capacity. We still want to keep the lower limits for certain type of work.**

**The software use compiler directives to determine which set of parameters to use. The parameters are used to set the size of arrays and defined types. Since we are using an include file the parameters are available where ever we need the size of the arrays and types defined.**

**If I try to use allocation I have to run a subroutine to set all the correct sizes. Parameter values cannot be changed in the executable part of the subroutine.**

**I am starting to believe that the standard does not support where I am trying to go with the software.**

**Thanks.**

**Michael**

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

```
asks of OP:
".. Check this syntax with your book. What book are you using? .."
```

It's unclear whether OP is referring to any "book" though I've oft suggested to OP to do so.

Re: SEQUENCE, current Fortran standard (Fortran 2018) disallows its use in a derived type with a type-parameter (aka parameterized derived type or PDT):

```
1 7.5.2.3 Sequence type
2 R731 sequence-stmt is SEQUENCE
3 C740 (R726) If SEQUENCE appears, the type shall have at least one component, each data component shall
4 be declared to be of an intrinsic type or of a sequence type, the derived type shall not have any type
5 parameter, and a type-bound-procedure-part shall not appear.
```

OP, if serious about refactoring old code and gain advantages with modern computing, would do well to **unlearn **all of nonstandard FORTRAN involving heavy compiler-specific extensions and spend the time and effort to get good familiarity with current standard Fortran before writing new code. Hacking away without such hard yards is a guaranteed exercise in futility.

Letting "sleeping dogs lie" with all the nonstandard stuff in code of running applications and "don't fix if ain't broken" are the "conventional" wisdom that program managers in for-profit orgs can force on staff when they appear unwilling or entirely unable to approach code modernization with any form of discipline or structure.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Ron,

The book is Guide to Fortran 2008 Programing . It is an example from the chapter on structures and derived types. The example is that you can pass variables in to derived types to allocate their lengths.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Even if you can do it - some things are not a good idea and assumed allocations -- it will turn and bite later on when you reuse the code perhaps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

`.. The book is Guide to Fortran 2008 Programing . It is an example from the chapter on structures and derived types. The example is that you can pass variables in to derived types to allocate their lengths.`

A few questions:

- Is the example you showed earlier in this thread the same as or similar to the one in this book?
- If not, did you try the example given in the book exactly as-is with Intel Fortran compiler and does that example work as explained in the book?
- Also, is the SEQUENCE attribute shown in the book with that derived type example?

Note the Fortran standard does not allow the use of SEQUENCE in a parameterized derived type:

```
1 7.5.2.3 Sequence type
2 R731 sequence-stmt is SEQUENCE
3 C740 (R726) If SEQUENCE appears, the type shall have at least one component, each data component shall
4 be declared to be of an intrinsic type or of a sequence type, the derived type shall not have any type
5 parameter, and a type-bound-procedure-part shall not appear.
```

You may also want to join the Fortran Discourse at https://fortran-lang.org/ for various Fortran language-specific learning and discussion: https://fortran-lang.discourse.group/. The section on books therein can also give you more options to consider: https://fortran-lang.discourse.group/t/books-for-the-learn-page/177

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

*I now have 2020 update 2 installed and I no longer have the ability to use the watch window. Everything I enter is undefined.*

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I have 2020 update 1 installed and have no intention of touching update 2 even with a very long stick

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

How do I get update 1. The link sent me to update 2.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- « Previous
- Next »