On 27-04-2010, at 20:28, Andreas Noack Jensen wrote:

> Thank you so much for looking at it. Initially my code was in the "free"
> F95 format but partly because of the error and partly because of portability
> concerns I chose to translate it to strict F77 even thought it is ugly and
> annoying with the line width limit.
> 
> Indeed I think something is going wrong with the initial values but I cannot
> figure out why. Maybe because of missing Fortran skills but I am puzzled
> because the code works fine on Windows and Linux.
> 

Indeed, that is what I have found. See below.

> I think the "-mtune=core2" problem has disappeared in the latest 4.2.3
> gfortran at r.research because I had the error in the beginning but after
> reinstall of gfortran it was gone (right now, however,  I am on gfortran
> 4.2.4 aka gcc 4.2.1).
> 
> Thank you once again and hope some new ideas to isolate the problem will
> appear.


The error is in the fortran line

     double precision, intent(in) :: coef(ndim(1),ndim(2),ndim(3)),   
init(ndim(3),ndim(nl(2)))

The dimensions of init are wrong.
The line should read:

     double precision, intent(in) :: coef(ndim(1),ndim(2),ndim(3)),   
init(ndim(3),nl(2))

I have attached the corrected rmfilter.f90, a slightly modified rmfilter.R that 
I used to print various stuff
the test1.R and the output.

In the test case your code declares init(2,2)
In the corrected code it is declared as init(2,3)
The actual dimension is init(2,3)

Berend


Attachment: rmfilter.f90
Description: Binary data

Attachment: test1.R
Description: Binary data

Attachment: rmfilter.R
Description: Binary data

> 
> dyn.load('rmfilter.so')
> source("rmfilter.R")   
> 
> set.seed(407)
> 
> eps <- matrix(rnorm(30), ncol = 3)
> eps
              [,1]       [,2]       [,3]
 [1,]  0.841081288  1.7100891  0.9161884
 [2,]  1.072881139  1.1351244 -0.4314795
 [3,] -0.543593265 -1.0828613 -0.6333517
 [4,]  0.441951763 -1.0539372 -1.8468529
 [5,]  0.004920633 -0.9635668  0.6060301
 [6,] -0.731256023  0.4951620 -1.9168646
 [7,] -1.216400546 -1.5097126  1.1407077
 [8,] -0.210674189 -1.1110270 -0.3563495
 [9,] -0.378021236 -1.5624664 -2.5094364
[10,] -0.939183015 -0.2886860  2.1596868
> 
> z <-  rmfilter(eps, array(diag(3)*0.5, c(3,3,2)))
[1] 10  3
[1] 3 3 2
[1] 2 3
     [,1] [,2] [,3]
[1,]    0    0    0
[2,]    0    0    0
[1] 2
[1] 2
> z
            [,1]       [,2]        [,3]
 [1,]  0.8410813  1.7100891  0.91618843
 [2,]  1.4934218  1.9901689  0.02661472
 [3,]  0.6236583  0.7672677 -0.16195012
 [4,]  1.5004918  0.3247811 -1.91452060
 [5,]  1.0669957 -0.4175424 -0.43220526
 [6,]  0.5524877  0.4487814 -3.09022752
 [7,] -0.4066589 -1.4940931 -0.62050867
 [8,] -0.1377598 -1.6336829 -2.21171758
 [9,] -0.6502306 -3.1263543 -3.92554948
[10,] -1.3331782 -2.6687046 -0.90894674
attr(,"tsp")
[1]  1 10  1
> 

_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to