OSDN Git Service

2004-07-23 Matthias Klose <doko@debian.org>
[pf3gnuchains/gcc-fork.git] / libgfortran / intrinsics / associated.c
1 /* Implementation of the ASSOCIATED intrinsic
2    Copyright 2003 Free Software Foundation, Inc.
3    Contributed by kejia Zhao (CCRG) <kejia_zh@yahoo.com.cn>
4
5 This file is part of the GNU Fortran 95 runtime library (libgfor).
6
7 Libgfor is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 Ligbfor is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with libgfor; see the file COPYING.LIB.  If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "libgfortran.h"
23
24 #define associated prefix(associated)
25
26
27 GFC_LOGICAL_4
28 associated (const gfc_array_void *pointer, const gfc_array_void *target)
29 {
30   int n, rank;
31
32   if (GFC_DESCRIPTOR_DATA (pointer) != GFC_DESCRIPTOR_DATA (target))
33     return 0;
34   if (GFC_DESCRIPTOR_DTYPE (pointer) != GFC_DESCRIPTOR_DTYPE (target))
35     return 0;
36
37   rank = GFC_DESCRIPTOR_RANK (pointer);
38   for (n = 0; n < rank; n++)
39     {
40       if (pointer->dim[n].stride != target->dim[n].stride)
41         return 0;
42       if ((pointer->dim[n].ubound - pointer->dim[n].lbound)
43           != (target->dim[n].ubound - target->dim[n].lbound))
44         return 0;
45     }
46
47   return 1;
48 }