optional assumed-shape array



Hi

In the following program, error message shows "access violation" after
complied by CVF6.6c:

module mA
contains
real function aaa(ai)
real, optional :: ai(:)
if(present(ai))then
aaa=0.0
do i=1,size(ai)
aaa=aaa+ai(i)
end do
endif

ai(1)=3 <==="access violation"

end function aaa
end module mA
program main
use mA
real :: ai(3)
ai=(/3.,2.,53./)
print *,aaa()
END program main

I need ai to be optional argument. So how do I "access" ai?
Thank you in advance.

Mike
.



Relevant Pages

  • Re: Access violation before startup in debug mode
    ... mode I get an access violation before the program starts. ... error message is "Unhandled exception in ModelTest.exe: ... I put breakpoints at ... dynamic and static linking to MFC to ...
    (microsoft.public.vc.mfc)
  • Re: Hotkey keyboard error on shutdown
    ... Robert L. Rauch wrote: ... > Access violation at address 00433396 ...
    (microsoft.public.windowsxp.general)
  • Access violation
    ... I have this error message: "Access violation at address 011789D2 in ... occuring when I do compilation and it is not occuring all the time. ... a few who face messages of 'access violation'. ...
    (borland.public.delphi.ide)
  • xp_msadenabled
    ... I keep getting this error message sent to me periodically ... (serverity 20 errors automatically forwarded to me): ... Stored function 'xp_msadenabled' in the ... library 'xp_star.dll' generated an access violation. ...
    (microsoft.public.sqlserver.server)
  • Re: Xnews error message
    ... Ahoyhoy wrote in ... "Access violation at address 00050D2D in module 'Xnews.exe'. ... error message, different numbers). ... "three fingered salute" to get back to the desktop. ...
    (news.software.readers)