| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| In the following subroutine, an array (arrin) is taken its real values and then operated on with other stuff. Is this a valid F90/F95 construct? Gfortran 4.3 doesn't like it for some reason: it compiled but crashed. ! test array func: is it possible? subroutine test_array1_proc(arrin, arrout) implicit none complex*16 :: arrin(:, ![]() real*8 :: arrout(:, ![]() ! For some reason gfortran 4.3 causes segfault below. ! It tries to read in array with pointer address zero. ! I had no time to verify why --- let's forget this for now. arrout = arrout + real(arrin) * 2.d0 end subroutine Wirawan |
|
#2
| |||
| |||
| Ugh...I have to reply to my own question. It IS. My own mistake is that I did not declare this procedure within a module, and therefore the caller cannot know whether to pass the array content (F77 style) or the array descriptor (the correct, F90 way). :-< Wirawan |
|
#3
| |||
| |||
| Wirawan Purwanto wrote: > In the following subroutine, an array (arrin) is taken its real values > and then operated on with other stuff. Is this a valid F90/F95 > construct? Gfortran 4.3 doesn't like it for some reason: it compiled > but crashed. > > ! test array func: is it possible? > subroutine test_array1_proc(arrin, arrout) > implicit none > complex*16 :: arrin(:, ![]() > real*8 :: arrout(:, ![]() > > ! For some reason gfortran 4.3 causes segfault below. > ! It tries to read in array with pointer address zero. > ! I had no time to verify why --- let's forget this for now. > arrout = arrout + real(arrin) * 2.d0 > end subroutine > > > Wirawan It's reasonably standard. The *8 and *16 aren't standard, but Gfortran surely will do the right thing. The first thing to remember when you get some sort of memory access error when using assumed shape arrays is that you need an explicit interface on the calling side. Is test_array1_proc a module subroutine? If so, are you USEing the module? Otherwise, it should be an internal subroutine, or, as a last resort, write an explicit interface yourself. Or, are either arrin or arrout either allocatable or pointer arrays on the calling side? If so, have they been allocated or associated with an array? Dick Hendrickson |
|
#4
| |||
| |||
| Dick Hendrickson <dick.hendrickson@att.net> wrote: > The first thing to remember when you get some sort of > memory access error when using assumed shape arrays is > that you need an explicit interface on the calling side. Good call (as noted in the OP's followup to himself). Another thing to check in things like this is that the array shapes are conformable. That was the first thing that occurred to me here, but apparently Dick's first thing was the better starting point. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.