Code Comments
Programming Forum and web based access to our favorite programming groups.Greetings all, I am looking for the most portable way to perform a malloc. As far as I know, fortran malloc/free is not standard in all fortran compilers. I was thinking to link fortran code with some C code that takes care for the malloc/free task. Any comments are very welcome, Kaci
Post Follow-up to this message"Kaci Tizi Ouzou" <kaci_tizi_ouzou2000@yahoo.ca> wrote in message news:68599ccc.0411261033.5519f0df@posting.google.com... > Greetings all, > > I am looking for the most portable way to perform a malloc. As far as > I know, fortran malloc/free is not standard in all fortran compilers. > > I was thinking to link fortran code with some C code that takes care > for the malloc/free task. That most often means using Cray pointers. Look up the documentation of the compilers you wish to support which have such a feature. It was the "most portable" way, prior to f90. There are reasons for Fortran having its own ways to allocate and free memory, which are portable to any Fortran of the last 10 years. Among them: Cray pointers involve finding out which integer types on the Fortran side work with pointer and size_t types on the C side. There are several combinations in current use, at least 2 common varieties each for Windows and linux. There may be more, if people persist in using Cray pointers in f2003. "Most portable" doesn't measure up to standard.
Post Follow-up to this messagekaci_tizi_ouzou2000@yahoo.ca (Kaci Tizi Ouzou) wrote: >Greetings all, > >I am looking for the most portable way to perform a malloc. As far as >I know, fortran malloc/free is not standard in all fortran compilers. > >I was thinking to link fortran code with some C code that takes care >for the malloc/free task. Can you use the ALLOCATABLE arrays or POINTERs of Fortran 90/95 to do what you need? ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==-- -- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 News groups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption = ---
Post Follow-up to this messagekaci_tizi_ouzou2000@yahoo.ca (Kaci Tizi Ouzou) writes: > I am looking for the most portable way to perform a malloc. As far as > I know, fortran malloc/free is not standard in all fortran compilers. > > I was thinking to link fortran code with some C code that takes care > for the malloc/free task. You don't mention what version of Fortran. It makes a huge difference; dynamic allocation features were among the most significant features added in Fortran 90. If you need to do dynamic allocation in new code, then I *STRONGLY* recommend using a Fortran 90 or later compiler. In Fortran 90, there are several standard-conforming and portable ways, depending on the details of your needs. The inlude allocatable arrays, pointer array allocation, and automatic arrays. In Fortran 77, there really isn't a good portable way. There are *LOTS* of issues. Frankly, my position is that it is not worth my time to tutor people on all the intricacies of how to do this in f77. If you are stuck maintaining existing code, then I can understand that. But for new code use f90. The cost in time to figure out how to do it well in f77 is greater than the cost of even the most expensive of the commercial f90 compilers (and there are some free f90 compiler alternatives, depending on details) And this is so even if you value your own time at zero and just include the cost of my time. I'm not very receptive to arguments that amount to saying that my time isn't as valuable as other people's money. If you do jump into f77 approaches anyway, be aware that many widely used compilers do not support Cray pointers. Thus any approach that involves using Cray pointers to interface with C allocation routines takes a pretty big portability hit from the start. Yes, people do it, but portability suffers pretty significantly. Note thet the set of compilers that don't support Cray pointers includes g77... which is getting to be a pretty significant fraction of the current f77-only compilers. The more portable f77 approaches tend to be a pain; they end up forcing program architecture in sometimes unnatural ways. -- Richard Maine email: my last name at domain domain: summertriangle dot net
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.