- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use a structure constructor to initialize my variable. I couldn't get it working, so I tried an example I found on the IBM website (http://publib.boulder.ibm.com/infocenter/lnxpcomp/v101v121/index.jsp?topic=/com.ibm.xlf121.linux.doc/language_ref/structure_constructor.html):
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:\test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:\test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - ferrad01
I am trying to use a structure constructor to initialize my variable. I couldn't get it working, so I tried an example I found on the IBM website (http://publib.boulder.ibm.com/infocenter/lnxpcomp/v101v121/index.jsp?topic=/com.ibm.xlf121.linux.doc/language_ref/structure_constructor.html):
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
As the IBM page stresses, using keyword arguments in the constructor is a Fortran 2003 feature, which is not implemented in IVF 10.1. A quick check shows that it's not implemented in 11.0.061 either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Jugoslav Dujic
Quoting - ferrad01
I am trying to use a structure constructor to initialize my variable. I couldn't get it working, so I tried an example I found on the IBM website (http://publib.boulder.ibm.com/infocenter/lnxpcomp/v101v121/index.jsp?topic=/com.ibm.xlf121.linux.doc/language_ref/structure_constructor.html):
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
PROGRAM NEW_LOCAL
TYPE DT
INTEGER :: A = 20
INTEGER :: B = 80
END TYPE
TYPE(DT):: DT_VAR = DT()
TYPE(DT):: DT_VAR2 = DT(B=40)
TYPE(DT):: DT_VAR3 = DT(B=10, A=50)
PRINT *, 'DT_VAR =', DT_VAR
PRINT *, 'DT_VAR2=', DT_VAR2
PRINT *, 'DT_VAR3=', DT_VAR3
END PROGRAM NEW_LOCAL
However I get an error:
D:test>ifort test2.f90
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.1 Build 20080312 Package ID: w_fc_p_10.1.021
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
test2.f90(7) : Error: The number of expressions in a structure constructor differs from the number of components of the derived type [DT]
TYPE(DT):: DT_VAR = DT()
---------------------^
compilation aborted for test2.f90 (code 1)
What is the problem?
As the IBM page stresses, using keyword arguments in the constructor is a Fortran 2003 feature, which is not implemented in IVF 10.1. A quick check shows that it's not implemented in 11.0.061 either.
Thanks, yes I saw it was a Fortran 2003 feature. I had assumed that 2003 features would be available in IVF by now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Many are, but that particular feature is coming later this year.

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