- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will start with I am new to Fortran and to this forum so if there are any suggestions. Thanks in advance.
My issue I that I keep coming across is error 6634 and 8284 when trying to use subroutines that operate on element operations. I have created a simple routine to hopefully illustrate my problem as my code is too large to include.
I have also included my workaround for Error 7710 related to passing a section of an array and wanted to know if there is a better workaround or best practice?
program Test_Scale_Array implicit none ! Variables REAL(KIND=8), Dimension(:), Allocatable :: var3 REAL(KIND=8), Dimension(1:10) :: var2,exponent REAL(KIND=8) :: var4 integer, Dimension(5) :: x integer :: i ! Body of Test_Scale_Array var2 = 4.0D0 var4 = 4.0D0 exponent = 2.0D0 !have routine that is meant mostly for this call simplesquare(var2,exponent) !Gives Error 8284 & 6634 call simplesquare(var4) !Gives Error 6634 call simplesquare(var2(2),exponent(2)) !Selection and calculation on a portion of array x = (/(2*i,i=1,5)/) !Gives error #7710 call simplesquare(var2(x)) !Is there a faster/better way for the workaround? Allocate( var3(1:5) ) var3 = var2(x) call simplesquare(var3) var2(x) = var3 deallocate( var3 ) contains subroutine simplesquare(x,y) ! Variables REAL(Kind=8), Dimension(:), INTENT(inout) :: x REAL(Kind=8), Dimension(:), OPTIONAL :: y ! Body of simplesquare if (present(Y)) then x = x**y else x = x**2 endif end subroutine simplesquare end program Test_Scale_Array
Thanks
Jim
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome to the forum! In the future, it is helpful if you show the actual text of the error messages as few (or none) of us have all the numbers memorized. It is also helpful to see the name of the identifier in the message.
Here's what I see:
t.f90(20): error #8284: If the actual argument is scalar, the dummy argument sha ll be scalar unless the actual argument is of type character or is an element of an array that is not assumed shape, pointer, or polymorphic.call simplesquare(var4) -----^ t.f90(20): error #6634: The shape matching rules of actual arguments and dummy a rguments have been violated. [VAR4] call simplesquare(var4) ------------------^ t.f90(23): error #6634: The shape matching rules of actual arguments and dummy a rguments have been violated. [VAR2] call simplesquare(var2(2),exponent(2)) ------------------^ t.f90(23): error #6634: The shape matching rules of actual arguments and dummy a rguments have been violated. [EXPONENT] call simplesquare(var2(2),exponent(2)) --------------------------^ t.f90(30): error #7710: An array section having a vector subscript is not permit ted if dummy argument has intent [IN]OUT. [VAR2] call simplesquare(var2(x)) ------------------^
Let's take these in order. simplesquare has two dummy arguments x and y, both deferred-shape arrays of rank (dimension) 1.
The call on line 20 is passing var4, which is a scalar, not an array. Fortran doesn't let you pass a scalar variable to an array (with an exception of passing a single array element, unless the array is a pointer array or the dummy is deferred-shape, which is the case here). This gets you both the errors 8824 (which tells you just what I said) and 6634 (complaining that the shapes of the arguments don't match).
A similar problem is in line 23 where you are passing an array element but the dummy argument is deferred-shape, so you're not allowed to use the exception.
Lastly, in line 30 you passed an array with a subscript being another array ("vector subscript"). This is allowed only if the corresponding dummy argument is INTENT(IN).
I covered some of these issues in a blog post I wrote - you might want to look through the others for interesting information about the Fortran language.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For what it is worth the Dimension statement hurts my eyes I dropped that with Fortran 77.
integer, Dimension(5) :: x integer :: y(5), z(0:22) ! more compact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James S. wrote:
I will start with I am new to Fortran and to this forum so if there are any suggestions. Thanks in advance.
..
Welcome! Is it possible for you to share what you plan to do with Fortran and how far you intend to take the Fortran experience (e.g., is it a one-time need for some specific task/goal or you have more development work and plans ahead in some application domain)? If you think you will be doing a fair bit of work with Fortran, please consider going through the books mentioned in Dr Fortran (Intel's own Steve Lionel) blog - see here: https://software.intel.com/en-us/blogs/2013/12/30/doctor-fortran-in-its-a-modern-fortran-world
All the best,

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