I have tried to compile the working Fortran-90 routines (see attachment) to interface them with R. The compiler automatically caled by R CMD command line prints a bunch of error messages (as follows). I think I'm better off translating the Fortran implementation into R ... which is what I hoped I could avoid. Maura host705:Desktop mauede$ R CMD SHLIB ford.f90 gfortran -arch i386 -fno-common -g -O2 -c ford.f90 -o ford.o ford.f90:2: c ----------------------------------------------------------------------------- 1 Error: Unclassifiable statement at (1) ford.f90:3: c --- Choozing wavelet order from minimum enthropy of squared wavelet 1 Error: Unclassifiable statement at (1) ford.f90:4: c --- coefficients distribution on detail levels with numbers from LevMin up to 1 Error: Unclassifiable statement at (1) ford.f90:5: c --- Vocabulary of wavelets: the first 10 orthogonal Daubechies wavelets + 7 1 Error: Unclassifiable statement at (1) ford.f90:6: c --- If wavelet order is p>100 it means that it is a symlet of the order (p-10 1 Error: Unclassifiable statement at (1) ford.f90:7: c --- Input: X - real array of signal of the length N; 1 Error: Unclassifiable statement at (1) ford.f90:8: c --- Nfour=2**Kfour - the minimum integer of 2 in the power, which is 1 Error: Unclassifiable statement at (1) ford.f90:9: c --- LevMin, LevMax - numbers of working detail levels. 1 Error: Unclassifiable statement at (1) ford.f90:10: c --- Output: wavelet order NordOut. 1 Error: Unclassifiable statement at (1) ford.f90:11: c ----------------------------------------------------------------------------- 1 Error: Unclassifiable statement at (1) ford.f90:13.14: real*4 Y [allocatable] (:) 1 Error: Syntax error in data declaration at (1) ford.f90:15.16: allocate(Y(Nfour)) 1 Error: Syntax error in ALLOCATE statement at (1) ford.f90:41.17: Dw=abs(Y(j)) 1 Error: Syntax error in argument list at (1) ford.f90:56.15: Dw=abs(Y(j)) 1 Error: Syntax error in argument list at (1) ford.f90:22.7: Y=X 1 Error: Incompatible ranks 0 and 1 in assignment at (1) ford.f90:72.18: deallocate(Y) 1 Error: Expression in DEALLOCATE statement at (1) must be ALLOCATABLE or a POINTER ford.f90:79: c --------------------------------------------------- 1 Error: Unclassifiable statement at (1) ford.f90:80: c --- Fast wavelet transform of the signal array a(n) 1 Error: Unclassifiable statement at (1) ford.f90:81: c --- n must be = 2**m 1 Error: Unclassifiable statement at (1) ford.f90:82: c --- if isign= 1 then direct transform 1 Error: Unclassifiable statement at (1) ford.f90:83: c --- if isign=-1 then inverse transform 1 Error: Unclassifiable statement at (1) ford.f90:84: c --- The used orthogonal Daubechies wavelet is setting by preliminary 1 Error: Unclassifiable statement at (1) ford.f90:85: c --- call of the subroutine pwtset. 1 Error: Unclassifiable statement at (1) ford.f90:86: c ----------------------------------- 1 Error: Unclassifiable statement at (1) ford.f90:109: c ------------------------------------------------- 1 Error: Unclassifiable statement at (1) Fatal Error: Error count reached limit of 25. make: *** [ford.o] Error 1 host705:Desktop mauede$ -----Messaggio originale----- Da: John C Nash [mailto:nashjc at uottawa.ca] Inviato: ven 27/03/2009 16.14 A: mauede at alice.it Oggetto: Fortran 90 etc. Even though I'm a fairly experienced Fortran (77 actually) programmer and use R a lot, I too am having trouble interfacing the two. (If you do ?optim, you will see my codes are the NM, BFGS and CG codes from VERY long ago. I'm trying to update them.) However, for your problem, I think you will be happier in the short term by getting R to write out the data and then simply read it into Fortran. You can then get Fortran to output a file that is readable by R. I recommend using the CSV type (comma separated values) files -- they are tedious rather than difficult, and give very little problem for exchange between lots of programs (including spreadsheets -- I use Gnumeric as it has a very nice ssconvert function for use in command line scripts that can be automated. This would let you automate some of your work.) And I would make my intermediate files "verbose" i.e., with lots of labels etc. This will be more work to set up, but I think you will find you can debug things much quicker. And the files will be self-documenting too. I always have too many Test1.txt files around. This is not an elegant solution, but if your time is short, I think you will find you can make it work much, much faster than trying to package things within the R framework. Best wishes, JN e tutti i telefonini TIM! Vai su