- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[bash]SUBROUTINE GRID_GEN(GRID,L,H) USE VARIABLES TYPE(ND),INTENT(INOUT) ::GRID(-IM/2:IM/2-1,-JM/2:JM/2-1) REAL ::L,H,DX,DY INTEGER ::I,J DX = L/IM DY = H/JM DO I=-IM/2,IM/2-1 DO J=-JM/2,JM/2-1 GRID(I,J).X = I*DX GRID(I,J).Y = J*DY GRID(I,J).K1 = I*2*Pi/L GRID(I,J).K2 = J*2*Pi/H GRID(I,J).KK =(GRID(I,J).K1**2+GRID(I,J).K2**2) IF (I==IM/2+1.AND.J==JM/2+1) GRID(I,J).KK=1 END DO END DO RETURN END SUBROUTINE[/bash]This subroutine was working fine while the dimensions of grid was defined like: GRID(:,:) but I want to change the indexes for all the program like this to be easier with fourier series, when I run this program it hits a access violation and stops running once it get to the loop. When I checked it in debug the value has been assigned but program stops proceeding. IM and JM are defined as public variables in the VARIABLES module.
When I define another varibale like:
TYPE(ND)::G(-im/2:im/2-1,-jm/2:jm/2-1),GRID(:,:)
and replace it with GRID on entire subroutine it works, and finally I replace them by GRID=G.
Am I doing something against the standards here? in the main program dimensions of GRID has negative values too!
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Am I doing something against the standards here?
Indeed, you are. See Section 12.3.1.1 Explicit interface in the Fortran 2003 Standard. Assumed shape array arguments need an explicit interface. If you give the compiler a proper interface but then change the function without changing the interface, the compiler is unable to produce correct code.
In effect, you gave false information to the compiler, even if inadvertently.
Indeed, you are. See Section 12.3.1.1 Explicit interface in the Fortran 2003 Standard. Assumed shape array arguments need an explicit interface. If you give the compiler a proper interface but then change the function without changing the interface, the compiler is unable to produce correct code.
In effect, you gave false information to the compiler, even if inadvertently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesssss, that`s it, I corrected the interface and it`s done. Working with the compact has spoiled me, can I ask you to introduce me a good guide to learn the fortran 2003 by a deep understanding? I already have a basic knowledge of it but I need to learn more about the memory access and compiling options.
Thanks greately
Thanks greately
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A concise guide is the book by Metcalf, Reid and Cohen, Fortran 95/2003 Explained, OUP, 2005. There is a link to a draft version of the Fortran 2003 standard at the top of this forum, which is more useful as a reference than a guide. Then, there are the Intel compiler documents, as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, I got the book of Metcalf, of course explained one not simplified, but for the standard I'm having some problem with the j3-fortran.org, connection times out and it cannot be downloaded,
thanks anyway
thanks anyway
![](/skins/images/DF2E495CEC88D713A66401CF495CD875/responsive_peak/images/icon_anonymous_message.png)
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