Re: initializing an array of user-defined data types



garylscott@xxxxxxxxxxxxx wrote:
On Nov 28, 1:12 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
Bart Vandewoestyne <MyFirstName.MyLastN...@xxxxxxxxxx> wrote:
I have a rank 2 array of a user-defined type as follows:
type(piece), dimension(:,:), allocatable, private :: board
After allocating it, I want to initialize it so that after
initialization, I can check whether board(i,j) contains a piece
or not.
I've tried things like
board = NULL
... assign some pieces to board positions and leave others empty ...
if (board(i,j) == NULL) then
... do something ...
end if
What is this NULL thing you seem to expect? There is no such thing. The
only thing named NULL in Fortran is an intrinsic function that returns a
pointer or allocatable. ...

....

In CVF, NULL is simply an integer variable of value zero imported from
one of the windows support modules. Used alot for c interperability.

And, of course, the usage notes to the NULL() intrinsic include the following warning --

Note: If you use module DFWIN or DFWINTY, you will have a name conflict if you use the NULL intrinsic. To avoid this problem, rename the integer parameter constant NULL to something else; for example:
USE DFWIN, NULL0 => NULL

--

.



Relevant Pages

  • Re: multiple definitions....
    ... > also i think with a GNU compiler) I get no errors or warnings. ... simply because i am allocating memory for it ... When a global is allocated by more than one translation unit, the linker (or ... When both tu initialize the global, ...
    (comp.lang.c)
  • Re: VirtualAlloc and new
    ... > would imagine this would be slower than just allocating the raw memory. ... allocate raw memory and manually initialize ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.language)
  • Re: initializing an array of user-defined data types
    ... Bart Vandewoestyne wrote: ... After allocating it, I want to initialize it so that after ... assign some pieces to board positions and leave others empty ... ...
    (comp.lang.fortran)
  • initializing an array of user-defined data types
    ... I have a rank 2 array of a user-defined type as follows: ... After allocating it, I want to initialize it so that after ... assign some pieces to board positions and leave others empty ... ...
    (comp.lang.fortran)
  • Re: initializer for array of struct
    ... > be a way to initialize each without allocating off the heap. ... Well, if it weren't in an array, it still wouldn't be allocating on the ...
    (microsoft.public.dotnet.languages.csharp)