initializing an array of user-defined data types



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


but that doesn't seem to work.

What is the proper way to do this?

Thanks,
Bart

--
"Share what you know. Learn what you don't."
.



Relevant Pages

  • 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)
  • 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: initializing an array of user-defined data types
    ... After allocating it, I want to initialize it so that after ... And, of course, the usage notes to the NULLintrinsic include the following warning -- ... If you use module DFWIN or DFWINTY, you will have a name conflict if you use the NULL intrinsic. ...
    (comp.lang.fortran)
  • 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: 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)