Hi, I am 'translating' R functions in FORTRAN subroutines. Very often, an R function gives an 'array' as result and you don't have to bother with the dimension of the array : R creates automatically an array with the good length. It's not really the case with FORTRAN. Until now, I create an array with the 'max' dimensions in R, give it to FORTRAN; FORTRAN updates the array and R retrieves it. But calculating the 'max' before calling the FORTRAN subroutine can be complicated. Is it possible to create a 'new' array in a FORTRAN subroutine and to make it be read by R ? In my humble opinion, the answer is NO but as I am new to R ... The other solution, is to work with dummies dimension in FORTRAN but can R work with that ? TIA Jean -------------- next part -------------- Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free.
> On 3 Mar 2016, at 13:57, MAURICE Jean - externe <jean-externe.maurice at edf.fr> wrote: > > Hi, > I am 'translating' R functions in FORTRAN subroutines. > > Very often, an R function gives an 'array' as result and you don't have to bother with the dimension of the array : R creates automatically an array with the good length. It's not really the case with FORTRAN. > > Until now, I create an array with the 'max' dimensions in R, give it to FORTRAN; FORTRAN updates the array and R retrieves it. But calculating the 'max' before calling the FORTRAN subroutine can be complicated. Is it possible to create a 'new' array in a FORTRAN subroutine and to make it be read by R ? In my humble opinion, the answer is NO but as I am new to R ... > > The other solution, is to work with dummies dimension in FORTRAN but can R work with that ? >The question belongs on the R-devel mailinglist. I do not think you can do what you describe, if I read your question correctly. You are calling your Fortran routines directly from an R file with .Fortran, I presume? Your other solution: I don't really understand what you are implying. Declare them with (:,:) or (*,*), allocate and the return the array? A Fortran95 pointer? I think all of that is just a no no. Is it possible to calculate the required size of the array in a separate routine given some parameters (as can often be done with Lapack routines) before calling the main subroutine? If so, call the sizing routine and then declare the correctly sized array in your R code and pass it to the main subroutine. Berend> TIA > Jean > > > > Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. > > Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. > > Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. > ____________________________________________________ > > This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. > > If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. > > E-mail communication cannot be guaranteed to be timely secure, error or virus-free. > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Berend,>The question belongs on the R-devel mailinglist.I try to find this mailing-list ...>You are calling your Fortran routines directly from an R file with .Fortran, I presume?Yes. Is there another solution (possibility ?)>Declare them with (:,:) or (*,*), allocate and the return the array? A Fortran95 pointer?That was what I wanted to do ...>I think all of that is just a no no.It would be a big problem with memory management but R could copy the result before the memory attached to the FORTRAN subroutine is cleared at the end of the routine. R does so strange things (for an old programmer as I am).>Is it possible to calculate the required size of the array in a separate routine given some parameters (as can often be done with >Lapack routines) before calling the main subroutine? >If so, call the sizing routine and then declare the correctly sized array in your R code and pass it to the main subroutine.It's a good idea : a 'two shots' routine. I'll dig that (I'll work in this direction). Thanks Jean Ce message et toutes les pi?ces jointes (ci-apr?s le 'Message') sont ?tablis ? l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme ? sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse. Si vous n'?tes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez re?u ce Message par erreur, merci de le supprimer de votre syst?me, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions ?galement d'en avertir imm?diatement l'exp?diteur par retour du message. Il est impossible de garantir que les communications par messagerie ?lectronique arrivent en temps utile, sont s?curis?es ou d?nu?es de toute erreur ou virus. ____________________________________________________ This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message. E-mail communication cannot be guaranteed to be timely secure, error or virus-free.