Re: Malloc (the most portable way)

From: Tim Prince (tprince_at_nospamcomputer.org)
Date: 11/26/04


Date: Fri, 26 Nov 2004 19:05:04 GMT


"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.



Relevant Pages

  • Re: A few syntax questions
    ... I think putting them in the 'action-stmt' syntax rule ... If I were to redo the bnf from scratch, ... I guess that means that a standard conforming compiler is supposed to overflow. ... I am hoping that F2003 features will regain some respect for Fortran in CS departments,, and not just be coinsidered an old archaic language for old programs, but such strong support of archaic Fortran standards is a major reason why Fortran popularity continues to dwindle. ...
    (comp.lang.fortran)
  • Re: Form k = i + j and test for overflow.
    ... Last night you suggested I was forgetting that overflow violates ... the Fortran standard. ... test that wouldn't work on the most common of implementations. ... that conforms to the Fortran standard. ...
    (comp.lang.fortran)
  • Re: conditional compile for gFortran (GCC?): newbie question
    ... The official standard for a Fortran pre-processor is Part 3, "Conditional Compilation", informally known as CoCo. ... As I mentioned in a message in this thread yesterday, there are free implementations of CoCo available on the Internet. ... Obviously, CPP and its derivatives are widely used for Fortran, but I am not sure that the usage is so universal that it counts as a "de-facto standard", except perhaps in the Unix world. ... the capabilities and behavior of the Fortran pre-processor would be under the control of either the C or C++ committee. ...
    (comp.lang.fortran)
  • Re: FOR070.DAT files appearing
    ... IMPLICIT NONE has been Standard Fortran since 1993 when the Fortran 90 ... When F90 was approved, it became the ... I'd also challenge you to find a commercial Fortran 77 compiler ...
    (comp.os.vms)
  • Re: Any F2003 help translating C++ map syntax?
    ... >>part of the standard language, but makes a mockery of comparing ... > I sometimes miss convenient containers in the standard Fortran. ... That means that the standard STL might not be as ... > a hash table, if I remember correctly. ...
    (comp.lang.fortran)