Commit f4d1d50a by Tobias Burnus Committed by Tobias Burnus

re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])

2010-04-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * array.c (gfc_match_array_spec): Add error for -fcoarray=none.
        * match.c (gfc_match_critical, sync_statement): Ditto.
        * gfortran.h (gfc_fcoarray): New enum.
        (gfc_option_t): Use it.
        * lang.opt (fcoarray): Add new flag.
        * invoke.texi (fcoarray): Document it.
        * options.c (gfc_init_options,gfc_handle_option): Handle
        * -fcoarray=.
        (gfc_handle_coarray_option): New function.

2010-04-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/18918
        * gfortran.dg/coarray_2.f90: Add dg-options -fcoarray=single.
        * gfortran.dg/coarray_3.f90: Ditto.
        * gfortran.dg/coarray_4.f90: Ditto.
        * gfortran.dg/coarray_5.f90: Ditto.
        * gfortran.dg/coarray_6.f90: Ditto.
        * gfortran.dg/coarray_7.f90: Ditto.
        * gfortran.dg/coarray_8.f90: Ditto.
        * gfortran.dg/coarray_9.f90: New -fcoarray=none test.

From-SVN: r158016
parent 37794981
2010-04-06 Tobias Burnus <burnus@net-b.de> 2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918 PR fortran/18918
* array.c (gfc_match_array_spec): Add error for -fcoarray=none.
* match.c (gfc_match_critical, sync_statement): Ditto.
* gfortran.h (gfc_fcoarray): New enum.
(gfc_option_t): Use it.
* lang.opt (fcoarray): Add new flag.
* invoke.texi (fcoarray): Document it.
* options.c (gfc_init_options,gfc_handle_option): Handle -fcoarray=.
(gfc_handle_coarray_option): New function.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* gfortran.h (gfc_array_spec): Add cotype. * gfortran.h (gfc_array_spec): Add cotype.
* array.c (gfc_match_array_spec,gfc_set_array_spec): Use it * array.c (gfc_match_array_spec,gfc_set_array_spec): Use it
and defer error diagnostic. and defer error diagnostic.
......
...@@ -458,6 +458,12 @@ coarray: ...@@ -458,6 +458,12 @@ coarray:
== FAILURE) == FAILURE)
goto cleanup; goto cleanup;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
goto cleanup;
}
for (;;) for (;;)
{ {
as->corank++; as->corank++;
......
...@@ -563,6 +563,13 @@ typedef enum ...@@ -563,6 +563,13 @@ typedef enum
} }
init_local_integer; init_local_integer;
typedef enum
{
GFC_FCOARRAY_NONE = 0,
GFC_FCOARRAY_SINGLE
}
gfc_fcoarray;
/************************* Structures *****************************/ /************************* Structures *****************************/
/* Used for keeping things in balanced binary trees. */ /* Used for keeping things in balanced binary trees. */
...@@ -2158,6 +2165,7 @@ typedef struct ...@@ -2158,6 +2165,7 @@ typedef struct
int fpe; int fpe;
int rtcheck; int rtcheck;
gfc_fcoarray coarray;
int warn_std; int warn_std;
int allow_std; int allow_std;
......
...@@ -166,8 +166,8 @@ and warnings}. ...@@ -166,8 +166,8 @@ and warnings}.
@gccoptlist{-fno-automatic -ff2c -fno-underscoring @gol @gccoptlist{-fno-automatic -ff2c -fno-underscoring @gol
-fwhole-file -fsecond-underscore @gol -fwhole-file -fsecond-underscore @gol
-fbounds-check -fcheck-array-temporaries -fmax-array-constructor =@var{n} @gol -fbounds-check -fcheck-array-temporaries -fmax-array-constructor =@var{n} @gol
-fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} -fcheck=@var{<all|array-temps|bounds|do|mem|pointer|recursion>} @gol
-fmax-stack-var-size=@var{n} @gol -fcoarray=@var{<none|single>} -fmax-stack-var-size=@var{n} @gol
-fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol -fpack-derived -frepack-arrays -fshort-enums -fexternal-blas @gol
-fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol -fblas-matmul-limit=@var{n} -frecursive -finit-local-zero @gol
-finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol -finit-integer=@var{n} -finit-real=@var{<zero|inf|-inf|nan|snan>} @gol
...@@ -1212,6 +1212,20 @@ is implemented as a reference to the link-time external symbol ...@@ -1212,6 +1212,20 @@ is implemented as a reference to the link-time external symbol
for compatibility with @command{g77} and @command{f2c}, and is implied for compatibility with @command{g77} and @command{f2c}, and is implied
by use of the @option{-ff2c} option. by use of the @option{-ff2c} option.
@item -fcoarray=@var{<keyword>}
@opindex @code{fcoarray}
@cindex coarrays
@table @asis
@item @samp{none}
Disable coarray support; using coarray declarations and image-control
statements will produce a compile-time error. (Default)
@item @samp{single}
Single-image mode, i.e. @code{num_images()} is always one.
@end table
@item -fcheck=@var{<keyword>} @item -fcheck=@var{<keyword>}
@opindex @code{fcheck} @opindex @code{fcheck}
@cindex array, bounds checking @cindex array, bounds checking
......
...@@ -348,6 +348,10 @@ frepack-arrays ...@@ -348,6 +348,10 @@ frepack-arrays
Fortran Fortran
Copy array sections into a contiguous block on procedure entry Copy array sections into a contiguous block on procedure entry
fcoarray=
Fortran RejectNegative JoinedOrMissing
-fcoarray=[...] Specify which coarray parallelization should be used
fcheck= fcheck=
Fortran RejectNegative JoinedOrMissing Fortran RejectNegative JoinedOrMissing
-fcheck=[...] Specify which runtime checks are to be performed -fcheck=[...] Specify which runtime checks are to be performed
......
...@@ -1743,6 +1743,12 @@ gfc_match_critical (void) ...@@ -1743,6 +1743,12 @@ gfc_match_critical (void)
== FAILURE) == FAILURE)
return MATCH_ERROR; return MATCH_ERROR;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
return MATCH_ERROR;
}
if (gfc_find_state (COMP_CRITICAL) == SUCCESS) if (gfc_find_state (COMP_CRITICAL) == SUCCESS)
{ {
gfc_error ("Nested CRITICAL block at %C"); gfc_error ("Nested CRITICAL block at %C");
...@@ -2138,6 +2144,12 @@ sync_statement (gfc_statement st) ...@@ -2138,6 +2144,12 @@ sync_statement (gfc_statement st)
== FAILURE) == FAILURE)
return MATCH_ERROR; return MATCH_ERROR;
if (gfc_option.coarray == GFC_FCOARRAY_NONE)
{
gfc_error ("Coarrays disabled at %C, use -fcoarray= to enable");
return MATCH_ERROR;
}
if (gfc_find_state (COMP_CRITICAL) == SUCCESS) if (gfc_find_state (COMP_CRITICAL) == SUCCESS)
{ {
gfc_error ("Image control statement SYNC at %C in CRITICAL block"); gfc_error ("Image control statement SYNC at %C in CRITICAL block");
......
...@@ -130,6 +130,7 @@ gfc_init_options (unsigned int argc, const char **argv) ...@@ -130,6 +130,7 @@ gfc_init_options (unsigned int argc, const char **argv)
gfc_option.fpe = 0; gfc_option.fpe = 0;
gfc_option.rtcheck = 0; gfc_option.rtcheck = 0;
gfc_option.coarray = GFC_FCOARRAY_NONE;
/* Argument pointers cannot point to anything but their argument. */ /* Argument pointers cannot point to anything but their argument. */
flag_argument_noalias = 3; flag_argument_noalias = 3;
...@@ -480,6 +481,18 @@ gfc_handle_fpe_trap_option (const char *arg) ...@@ -480,6 +481,18 @@ gfc_handle_fpe_trap_option (const char *arg)
static void static void
gfc_handle_coarray_option (const char *arg)
{
if (strcmp (arg, "none") == 0)
gfc_option.coarray = GFC_FCOARRAY_NONE;
else if (strcmp (arg, "single") == 0)
gfc_option.coarray = GFC_FCOARRAY_SINGLE;
else
gfc_fatal_error ("Argument to -fcoarray is not valid: %s", arg);
}
static void
gfc_handle_runtime_check_option (const char *arg) gfc_handle_runtime_check_option (const char *arg)
{ {
int result, pos = 0, n; int result, pos = 0, n;
...@@ -931,6 +944,9 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -931,6 +944,9 @@ gfc_handle_option (size_t scode, const char *arg, int value)
gfc_handle_runtime_check_option (arg); gfc_handle_runtime_check_option (arg);
break; break;
case OPT_fcoarray_:
gfc_handle_coarray_option (arg);
break;
} }
return result; return result;
......
2010-04-06 Tobias Burnus <burnus@net-b.de> 2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918 PR fortran/18918
* gfortran.dg/coarray_2.f90: Add dg-options -fcoarray=single.
* gfortran.dg/coarray_3.f90: Ditto.
* gfortran.dg/coarray_4.f90: Ditto.
* gfortran.dg/coarray_5.f90: Ditto.
* gfortran.dg/coarray_6.f90: Ditto.
* gfortran.dg/coarray_9.f90: New -fcoarray=none test.
2010-04-06 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
* gfortran.dg/coarray_4.f90: Fix test. * gfortran.dg/coarray_4.f90: Fix test.
* gfortran.dg/coarray_6.f90: Add more tests. * gfortran.dg/coarray_6.f90: Add more tests.
......
! { dg-do run } ! { dg-do run }
! { dg-options "-fcoarray=single" }
! { dg-shouldfail "error stop" } ! { dg-shouldfail "error stop" }
! !
! Coarray support ! Coarray support
......
! { dg-do compile } ! { dg-do compile }
! { dg-options "-fcoarray=single" }
! !
! Coarray support ! Coarray support
! PR fortran/18918 ! PR fortran/18918
......
! { dg-do compile } ! { dg-do compile }
! { dg-options "-fcoarray=single" }
! !
! Coarray support -- corank declarations ! Coarray support -- corank declarations
! PR fortran/18918 ! PR fortran/18918
......
! { dg-do compile } ! { dg-do compile }
! { dg-options "-fcoarray=single" }
! !
! Coarray support -- corank declarations ! Coarray support -- corank declarations
! PR fortran/18918 ! PR fortran/18918
......
! { dg-do compile }
!
! PR fortran/18918
!
! Check for error if no -fcoarray= option has been given
!
integer :: a
integer :: b[*] ! { dg-error "Coarrays disabled" }
error stop "Error"
sync all ! { dg-error "Coarrays disabled" }
critical ! { dg-error "Coarrays disabled" }
end critical ! { dg-error "Expecting END PROGRAM statement" }
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment