diff mbox series

Character length cleanup for Coarray Fortran library

Message ID 1518192646-9702-1-git-send-email-blomqvist.janne@gmail.com
State New
Headers show
Series Character length cleanup for Coarray Fortran library | expand

Commit Message

Janne Blomqvist Feb. 9, 2018, 4:10 p.m. UTC
Following the change to use size_t for Fortran character lengths (PR
78534), this patch modifies the Coarray ABI in a similar way. The
single-image implementation that is included in libgfortran is
updated, but this needs corresponding work in the OpenCoarray library
as well for multi-image support. Damian, can you look into that?

Regtested on x86_64-pc-linux-gnu, Ok for trunk?

gcc/fortran/ChangeLog:

2018-02-09  Janne Blomqvist  <blomqvist.janne@gmail.com>

	* gfortran.texi: Update Coarray API description.
	* trans-decl.c (gfc_build_builtin_function_decls): Use size_t for
	character lengths, int for exit codes.
	(generate_coarray_sym_init): Use size_t for character length.
	* trans-intrinsic.c (conv_co_collective): Likewise.
	* trans-stmt.c (gfc_trans_lock_unlock): Likewise.
	(gfc_trans_event_post_wait): Likewise.
	(gfc_trans_sync): Likewise.

libgfortran/ChangeLog:

2018-02-09  Janne Blomqvist  <blomqvist.janne@gmail.com>

	* caf/libcaf.h: Remove stdint.h include.
	(_gfortran_caf_register): Use size_t for character length.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Use int for exit code.
	(_gfortran_caf_stop_str): Use size_t for character length.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Use int for exit code.
	(_gfortran_caf_co_broadcast): Use size_t for character length.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	* caf/mpi.c (_gfortran_caf_register): Update implementation to
	match prototype.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	* caf/single.c (caf_internal_error): Likewise.
	(_gfortran_caf_register): Likewise.
	(_gfortran_caf_deregister): Likewise.
	(_gfortran_caf_sync_all): Likewise.
	(_gfortran_caf_sync_memory): Likewise.
	(_gfortran_caf_sync_images): Likewise.
	(_gfortran_caf_stop_numeric): Likewise.
	(_gfortran_caf_stop_str): Likewise.
	(_gfortran_caf_error_stop_str): Likewise.
	(_gfortran_caf_error_stop): Likewise.
	(_gfortran_caf_co_broadcast): Likewise.
	(_gfortran_caf_co_sum): Likewise.
	(_gfortran_caf_co_min): Likewise.
	(_gfortran_caf_co_max): Likewise.
	(_gfortran_caf_co_reduce): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.
---
 gcc/fortran/gfortran.texi     | 32 ++++++++++++-------------
 gcc/fortran/trans-decl.c      | 38 +++++++++++++++---------------
 gcc/fortran/trans-intrinsic.c |  4 ++--
 gcc/fortran/trans-stmt.c      | 12 +++++-----
 libgfortran/caf/libcaf.h      | 37 ++++++++++++++---------------
 libgfortran/caf/mpi.c         | 28 +++++++++++-----------
 libgfortran/caf/single.c      | 55 ++++++++++++++++++++++---------------------
 7 files changed, 103 insertions(+), 103 deletions(-)

Comments

Steve Kargl Feb. 9, 2018, 11:27 p.m. UTC | #1
On Fri, Feb 09, 2018 at 06:10:46PM +0200, Janne Blomqvist wrote:
> Following the change to use size_t for Fortran character lengths (PR
> 78534), this patch modifies the Coarray ABI in a similar way. The
> single-image implementation that is included in libgfortran is
> updated, but this needs corresponding work in the OpenCoarray library
> as well for multi-image support. Damian, can you look into that?
> 
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
> 

Janne, I've scanned the patch and it appears to a
fairly straight foward mechanical s/int/size_t
(and similar for nodes).  OK to commit (although
you may want to wait for a response from Damain
or Izaak Beekman).

As this breaks an ABI and we've broken it for 8.0,
I think this should go into trunk.  You may need
to ping Jakub or Richard for final approval.
Damian Rouson Feb. 10, 2018, 7:34 p.m. UTC | #2
I’ll try applying the patch and testing it.  I have about a 50% success rate with getting patches to apply cleanly.  Is this available on an svn or git branch that I can just checkout rather than attempting to apply the patch?  I find that process to be much more reliable. 

Going forward, please submit OpenCoarrays questions or issues via our issues page:

https://github.com/sourceryinstitute/OpenCoarrays/issues  

Most OpenCoarrays contributors don’t monitor the gfortran mailing list closely so we’re unlikely to see emails to the list in a timely manner.  

Also, when making changes that impact OpenCoarrays, please build OpenCoarrays and run our test suite.  We recently made several changes to our installation documentation and installer script based on feedback received from Steve Kargl.  One result is a set of instructions written by Zaak with GCC developers as an intended audience:  

https://github.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL  

Several other installation changes inspired by Steve’s feedback are listed here:  

https://github.com/sourceryinstitute/OpenCoarrays/issues/478  

and these will make it into a release shortly, but are already all available via git clone. I’m looking forward to hosting Oxford University Ph.D. student Daniel Garza, from March 17 to June 2, to work on finishing the integration of OpenCoarrays into the GCC autotools scripts so that OpenCoarrays will be built anytime gfortran is built so hopefully it will be even easier for everyone to build and test with OpenCoarrays soon.  

Damian 


On February 9, 2018 at 8:11:07 AM, Janne Blomqvist (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:

> Following the change to use size_t for Fortran character lengths (PR
> 78534), this patch modifies the Coarray ABI in a similar way. The
> single-image implementation that is included in libgfortran is
> updated, but this needs corresponding work in the OpenCoarray library
> as well for multi-image support. Damian, can you look into that?
>  
> Regtested on x86_64-pc-linux-gnu, Ok for trunk?
>  
> gcc/fortran/ChangeLog:
>  
> 2018-02-09 Janne Blomqvist  
>  
> * gfortran.texi: Update Coarray API description.
> * trans-decl.c (gfc_build_builtin_function_decls): Use size_t for
> character lengths, int for exit codes.
> (generate_coarray_sym_init): Use size_t for character length.
> * trans-intrinsic.c (conv_co_collective): Likewise.
> * trans-stmt.c (gfc_trans_lock_unlock): Likewise.
> (gfc_trans_event_post_wait): Likewise.
> (gfc_trans_sync): Likewise.
>  
> libgfortran/ChangeLog:
>  
> 2018-02-09 Janne Blomqvist  
>  
> * caf/libcaf.h: Remove stdint.h include.
> (_gfortran_caf_register): Use size_t for character length.
> (_gfortran_caf_deregister): Likewise.
> (_gfortran_caf_sync_all): Likewise.
> (_gfortran_caf_sync_memory): Likewise.
> (_gfortran_caf_sync_images): Likewise.
> (_gfortran_caf_stop_numeric): Use int for exit code.
> (_gfortran_caf_stop_str): Use size_t for character length.
> (_gfortran_caf_error_stop_str): Likewise.
> (_gfortran_caf_error_stop): Use int for exit code.
> (_gfortran_caf_co_broadcast): Use size_t for character length.
> (_gfortran_caf_co_sum): Likewise.
> (_gfortran_caf_co_min): Likewise.
> (_gfortran_caf_co_max): Likewise.
> (_gfortran_caf_co_reduce): Likewise.
> (_gfortran_caf_lock): Likewise.
> (_gfortran_caf_unlock): Likewise.
> (_gfortran_caf_event_post): Likewise.
> (_gfortran_caf_event_wait): Likewise.
> * caf/mpi.c (_gfortran_caf_register): Update implementation to
> match prototype.
> (_gfortran_caf_deregister): Likewise.
> (_gfortran_caf_sync_all): Likewise.
> (_gfortran_caf_sync_images): Likewise.
> (_gfortran_caf_error_stop_str): Likewise.
> (_gfortran_caf_error_stop): Likewise.
> * caf/single.c (caf_internal_error): Likewise.
> (_gfortran_caf_register): Likewise.
> (_gfortran_caf_deregister): Likewise.
> (_gfortran_caf_sync_all): Likewise.
> (_gfortran_caf_sync_memory): Likewise.
> (_gfortran_caf_sync_images): Likewise.
> (_gfortran_caf_stop_numeric): Likewise.
> (_gfortran_caf_stop_str): Likewise.
> (_gfortran_caf_error_stop_str): Likewise.
> (_gfortran_caf_error_stop): Likewise.
> (_gfortran_caf_co_broadcast): Likewise.
> (_gfortran_caf_co_sum): Likewise.
> (_gfortran_caf_co_min): Likewise.
> (_gfortran_caf_co_max): Likewise.
> (_gfortran_caf_co_reduce): Likewise.
> (_gfortran_caf_event_post): Likewise.
> (_gfortran_caf_event_wait): Likewise.
> (_gfortran_caf_lock): Likewise.
> (_gfortran_caf_unlock): Likewise.
> ---
> gcc/fortran/gfortran.texi | 32 ++++++++++++-------------
> gcc/fortran/trans-decl.c | 38 +++++++++++++++---------------
> gcc/fortran/trans-intrinsic.c | 4 ++--
> gcc/fortran/trans-stmt.c | 12 +++++-----
> libgfortran/caf/libcaf.h | 37 ++++++++++++++---------------
> libgfortran/caf/mpi.c | 28 +++++++++++-----------
> libgfortran/caf/single.c | 55 ++++++++++++++++++++++---------------------
> 7 files changed, 103 insertions(+), 103 deletions(-)
>  
> diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
> index 1124669..7c09bc4 100644
> --- a/gcc/fortran/gfortran.texi
> +++ b/gcc/fortran/gfortran.texi
> @@ -4458,7 +4458,7 @@ NULL.
>  
> @item @emph{Syntax}:
> @code{void caf_register (size_t size, caf_register_t type, caf_token_t *token,
> -gfc_descriptor_t *desc, int *stat, char *errmsg, int errmsg_len)}
> +gfc_descriptor_t *desc, int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -4510,7 +4510,7 @@ during a call to @code{_gfortran_caf_register}.
>  
> @item @emph{Syntax}:
> @code{void caf_deregister (caf_token_t *token, caf_deregister_t type,
> -int *stat, char *errmsg, int errmsg_len)}
> +int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -4936,7 +4936,7 @@ which has already been locked by the same image is an error.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index,
> -int *aquired_lock, int *stat, char *errmsg, int errmsg_len)}
> +int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -4971,7 +4971,7 @@ which is unlocked or has been locked by a different image is an error.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index,
> -int *stat, char *errmsg, int errmsg_len)}
> +int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5003,7 +5003,7 @@ Increment the event count of the specified event variable.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_event_post (caf_token_t token, size_t index,
> -int image_index, int *stat, char *errmsg, int errmsg_len)}
> +int image_index, int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5040,7 +5040,7 @@ amount and return.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_event_wait (caf_token_t token, size_t index,
> -int until_count, int *stat, char *errmsg, int errmsg_len)}
> +int until_count, int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5118,7 +5118,7 @@ current team. Additionally, it ensures that all pending data transfers of
> previous segment have completed.
>  
> @item @emph{Syntax}:
> -@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)}
> +@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5146,7 +5146,7 @@ transfers of previous segments have completed.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_sync_images (int count, int images[], int *stat,
> -char *errmsg, int errmsg_len)}
> +char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5174,7 +5174,7 @@ Acts as optimization barrier between different segments. It also ensures that
> all pending memory operations of this image have been completed.
>  
> @item @emph{Syntax}:
> -@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, int errmsg_len)}
> +@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5201,7 +5201,7 @@ function should terminate the program with the specified exit code.
>  
>  
> @item @emph{Syntax}:
> -@code{void _gfortran_caf_error_stop (int32_t error)}
> +@code{void _gfortran_caf_error_stop (int error)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5221,7 +5221,7 @@ Invoked for an @code{ERROR STOP} statement which has a string as argument. The
> function should terminate the program with a nonzero-exit code.
>  
> @item @emph{Syntax}:
> -@code{void _gfortran_caf_error_stop (const char *string, int32_t len)}
> +@code{void _gfortran_caf_error_stop (const char *string, size_t len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5399,7 +5399,7 @@ be called collectively.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_co_broadcast (gfc_descriptor_t *a,
> -int source_image, int *stat, char *errmsg, int errmsg_len)}
> +int source_image, int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5430,7 +5430,7 @@ strings.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image,
> -int *stat, char *errmsg, int a_len, int errmsg_len)}
> +int *stat, char *errmsg, int a_len, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5467,7 +5467,7 @@ strings.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image,
> -int *stat, char *errmsg, int a_len, int errmsg_len)}
> +int *stat, char *errmsg, int a_len, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5503,7 +5503,7 @@ specified image. This function operates on numeric values only.
>  
> @item @emph{Syntax}:
> @code{void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image,
> -int *stat, char *errmsg, int errmsg_len)}
> +int *stat, char *errmsg, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> @@ -5548,7 +5548,7 @@ string lengths shall be specified as hidden arguments;
> @item @emph{Syntax}:
> @code{void _gfortran_caf_co_reduce (gfc_descriptor_t *a,
> void * (*opr) (void *, void *), int opr_flags, int result_image,
> -int *stat, char *errmsg, int a_len, int errmsg_len)}
> +int *stat, char *errmsg, int a_len, size_t errmsg_len)}
>  
> @item @emph{Arguments}:
> @multitable @columnfractions .15 .70
> diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
> index 4fc07b6..1830856 100644
> --- a/gcc/fortran/trans-decl.c
> +++ b/gcc/fortran/trans-decl.c
> @@ -3635,12 +3635,12 @@ gfc_build_builtin_function_decls (void)
> gfor_fndecl_caf_register = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_register")), "RRWWWWR", void_type_node, 7,
> size_type_node, integer_type_node, ppvoid_type_node, pvoid_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_deregister = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_deregister")), "WRWWR", void_type_node, 5,
> ppvoid_type_node, integer_type_node, pint_type, pchar_type_node,
> - integer_type_node);
> + size_type_node);
>  
> gfor_fndecl_caf_get = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_get")), ".R.RRWRRRW", void_type_node, 10,
> @@ -3683,38 +3683,38 @@ gfc_build_builtin_function_decls (void)
>  
> gfor_fndecl_caf_sync_all = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_sync_all")), ".WW", void_type_node,
> - 3, pint_type, pchar_type_node, integer_type_node);
> + 3, pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_sync_memory = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_sync_memory")), ".WW", void_type_node,
> - 3, pint_type, pchar_type_node, integer_type_node);
> + 3, pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_sync_images = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_sync_images")), ".RRWW", void_type_node,
> 5, integer_type_node, pint_type, pint_type,
> - pchar_type_node, integer_type_node);
> + pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_error_stop = gfc_build_library_function_decl (
> get_identifier (PREFIX("caf_error_stop")),
> - void_type_node, 1, gfc_int4_type_node);
> + void_type_node, 1, integer_type_node);
> /* CAF's ERROR STOP doesn't return. */
> TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop) = 1;
>  
> gfor_fndecl_caf_error_stop_str = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_error_stop_str")), ".R.",
> - void_type_node, 2, pchar_type_node, gfc_int4_type_node);
> + void_type_node, 2, pchar_type_node, size_type_node);
> /* CAF's ERROR STOP doesn't return. */
> TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1;
>  
> gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_stop_numeric")), ".R.",
> - void_type_node, 1, gfc_int4_type_node);
> + void_type_node, 1, integer_type_node);
> /* CAF's STOP doesn't return. */
> TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1;
>  
> gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_stop_str")), ".R.",
> - void_type_node, 2, pchar_type_node, gfc_int4_type_node);
> + void_type_node, 2, pchar_type_node, size_type_node);
> /* CAF's STOP doesn't return. */
> TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1;
>  
> @@ -3743,22 +3743,22 @@ gfc_build_builtin_function_decls (void)
> gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_lock")), "R..WWW",
> void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node,
> - pint_type, pint_type, pchar_type_node, integer_type_node);
> + pint_type, pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_unlock = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_unlock")), "R..WW",
> void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_event_post = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_event_post")), "R..WW",
> void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_event_wait = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_event_wait")), "R..WW",
> void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_event_query = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_event_query")), "R..WW",
> @@ -3822,17 +3822,17 @@ gfc_build_builtin_function_decls (void)
> gfor_fndecl_co_broadcast = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_co_broadcast")), "W.WW",
> void_type_node, 5, pvoid_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_co_max = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_co_max")), "W.WW",
> void_type_node, 6, pvoid_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node, integer_type_node);
> + pint_type, pchar_type_node, integer_type_node, size_type_node);
>  
> gfor_fndecl_co_min = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_co_min")), "W.WW",
> void_type_node, 6, pvoid_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node, integer_type_node);
> + pint_type, pchar_type_node, integer_type_node, size_type_node);
>  
> gfor_fndecl_co_reduce = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_co_reduce")), "W.R.WW",
> @@ -3840,12 +3840,12 @@ gfc_build_builtin_function_decls (void)
> build_pointer_type (build_varargs_function_type_list (void_type_node,
> NULL_TREE)),
> integer_type_node, integer_type_node, pint_type, pchar_type_node,
> - integer_type_node, integer_type_node);
> + integer_type_node, size_type_node);
>  
> gfor_fndecl_co_sum = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_co_sum")), "W.WW",
> void_type_node, 5, pvoid_type_node, integer_type_node,
> - pint_type, pchar_type_node, integer_type_node);
> + pint_type, pchar_type_node, size_type_node);
>  
> gfor_fndecl_caf_is_present = gfc_build_library_function_decl_with_spec (
> get_identifier (PREFIX("caf_is_present")), "RRR",
> @@ -5348,7 +5348,7 @@ generate_coarray_sym_init (gfc_symbol *sym)
> token, gfc_build_addr_expr (pvoid_type_node, desc),
> null_pointer_node, /* stat. */
> null_pointer_node, /* errgmsg. */
> - integer_zero_node); /* errmsg_len. */
> + build_zero_cst (size_type_node)); /* errmsg_len. */
> gfc_add_expr_to_block (&caf_init_block, tmp);
> gfc_add_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl),
> gfc_conv_descriptor_data_get (desc)));
> diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
> index 337227d..b06afc6 100644
> --- a/gcc/fortran/trans-intrinsic.c
> +++ b/gcc/fortran/trans-intrinsic.c
> @@ -9817,12 +9817,12 @@ conv_co_collective (gfc_code *code)
> gfc_add_block_to_block (&block, &argse.pre);
> gfc_add_block_to_block (&post_block, &argse.post);
> errmsg = argse.expr;
> - errmsg_len = fold_convert (integer_type_node, argse.string_length);
> + errmsg_len = fold_convert (size_type_node, argse.string_length);
> }
> else
> {
> errmsg = null_pointer_node;
> - errmsg_len = integer_zero_node;
> + errmsg_len = build_zero_cst (size_type_node);
> }
>  
> /* Generate the function call. */
> diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
> index 573fd48..5953557 100644
> --- a/gcc/fortran/trans-stmt.c
> +++ b/gcc/fortran/trans-stmt.c
> @@ -913,12 +913,12 @@ gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
> gfc_conv_expr (&argse, code->expr3);
> gfc_add_block_to_block (&se.pre, &argse.pre);
> errmsg = argse.expr;
> - errmsg_len = fold_convert (integer_type_node, argse.string_length);
> + errmsg_len = fold_convert (size_type_node, argse.string_length);
> }
> else
> {
> errmsg = null_pointer_node;
> - errmsg_len = integer_zero_node;
> + errmsg_len = build_zero_cst (size_type_node);
> }
>  
> if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
> @@ -1112,12 +1112,12 @@ gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
> gfc_conv_expr (&argse, code->expr3);
> gfc_add_block_to_block (&se.pre, &argse.pre);
> errmsg = argse.expr;
> - errmsg_len = fold_convert (integer_type_node, argse.string_length);
> + errmsg_len = fold_convert (size_type_node, argse.string_length);
> }
> else
> {
> errmsg = null_pointer_node;
> - errmsg_len = integer_zero_node;
> + errmsg_len = build_zero_cst (size_type_node);
> }
>  
> if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
> @@ -1196,12 +1196,12 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
> gfc_conv_expr (&argse, code->expr3);
> gfc_conv_string_parameter (&argse);
> errmsg = gfc_build_addr_expr (NULL, argse.expr);
> - errmsglen = argse.string_length;
> + errmsglen = fold_convert (size_type_node, argse.string_length);
> }
> else if (flag_coarray == GFC_FCOARRAY_LIB)
> {
> errmsg = null_pointer_node;
> - errmsglen = build_int_cst (integer_type_node, 0);
> + errmsglen = build_int_cst (size_type_node, 0);
> }
>  
> /* Check SYNC IMAGES(imageset) for valid image index.
> diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h
> index 12c73de..34744ed 100644
> --- a/libgfortran/caf/libcaf.h
> +++ b/libgfortran/caf/libcaf.h
> @@ -28,7 +28,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>  
> #include  
> #include /* For size_t. */
> -#include /* For int32_t. */
>  
> #include "libgfortran.h"
>  
> @@ -190,29 +189,29 @@ int _gfortran_caf_this_image (int);
> int _gfortran_caf_num_images (int, int);
>  
> void _gfortran_caf_register (size_t, caf_register_t, caf_token_t *,
> - gfc_descriptor_t *, int *, char *, int);
> + gfc_descriptor_t *, int *, char *, size_t);
> void _gfortran_caf_deregister (caf_token_t *, caf_deregister_t, int *, char *,
> - int);
> + size_t);
>  
> -void _gfortran_caf_sync_all (int *, char *, int);
> -void _gfortran_caf_sync_memory (int *, char *, int);
> -void _gfortran_caf_sync_images (int, int[], int *, char *, int);
> +void _gfortran_caf_sync_all (int *, char *, size_t);
> +void _gfortran_caf_sync_memory (int *, char *, size_t);
> +void _gfortran_caf_sync_images (int, int[], int *, char *, size_t);
>  
> -void _gfortran_caf_stop_numeric (int32_t)
> +void _gfortran_caf_stop_numeric (int)
> __attribute__ ((noreturn));
> -void _gfortran_caf_stop_str (const char *, int32_t)
> +void _gfortran_caf_stop_str (const char *, size_t)
> __attribute__ ((noreturn));
> -void _gfortran_caf_error_stop_str (const char *, int32_t)
> +void _gfortran_caf_error_stop_str (const char *, size_t)
> __attribute__ ((noreturn));
> -void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
> +void _gfortran_caf_error_stop (int) __attribute__ ((noreturn));
> void _gfortran_caf_fail_image (void) __attribute__ ((noreturn));
>  
> -void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, int);
> -void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
> -void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
> -void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int);
> +void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, size_t);
> +void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, size_t);
> +void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, size_t);
> +void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, size_t);
> void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
> - int, int, int *, char *, int, int);
> + int, int, int *, char *, int, size_t);
>  
> void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
> caf_vector_t *, gfc_descriptor_t *, int, int, bool,
> @@ -245,10 +244,10 @@ void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
> void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
> int *, int, int);
>  
> -void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
> -void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
> -void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int);
> -void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, int);
> +void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, size_t);
> +void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, size_t);
> +void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, size_t);
> +void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, size_t);
> void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
>  
> void _gfortran_caf_failed_images (gfc_descriptor_t *,
> diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c
> index 0f7977f..14c10b5 100644
> --- a/libgfortran/caf/mpi.c
> +++ b/libgfortran/caf/mpi.c
> @@ -131,7 +131,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)),
>  
> void *
> _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
> - int *stat, char *errmsg, int errmsg_len,
> + int *stat, char *errmsg, size_t errmsg_len,
> int num_alloc_comps __attribute__ ((unused)))
> {
> void *local;
> @@ -189,8 +189,8 @@ error:
> *stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
> if (errmsg_len > 0)
> {
> - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
> - : (int) strlen (msg);
> + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
> + : strlen (msg);
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> @@ -205,7 +205,7 @@ error:
>  
>  
> void
> -_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
> +_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, size_t errmsg_len)
> {
> if (unlikely (caf_is_finalized))
> {
> @@ -217,8 +217,8 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
>  
> if (errmsg_len > 0)
> {
> - int len = ((int) sizeof (msg) - 1 > errmsg_len)
> - ? errmsg_len : (int) sizeof (msg) - 1;
> + size_t len = (sizeof (msg) - 1 > errmsg_len)
> + ? errmsg_len : sizeof (msg) - 1;
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> @@ -239,7 +239,7 @@ _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
>  
>  
> void
> -_gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
> +_gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)
> {
> int ierr;
>  
> @@ -261,8 +261,8 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
>  
> if (errmsg_len > 0)
> {
> - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
> - : (int) strlen (msg);
> + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
> + : strlen (msg);
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> @@ -278,7 +278,7 @@ _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
> is not equivalent to SYNC ALL. */
> void
> _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
> - int errmsg_len)
> + size_t errmsg_len)
> {
> int ierr;
> if (count == 0 || (count == 1 && images[0] == caf_this_image))
> @@ -329,8 +329,8 @@ _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
>  
> if (errmsg_len > 0)
> {
> - int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
> - : (int) strlen (msg);
> + size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
> + : strlen (msg);
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> @@ -358,7 +358,7 @@ error_stop (int error)
> /* ERROR STOP function for string arguments. */
>  
> void
> -_gfortran_caf_error_stop_str (const char *string, int32_t len)
> +_gfortran_caf_error_stop_str (const char *string, size_t len)
> {
> fputs ("ERROR STOP ", stderr);
> while (len--)
> @@ -372,7 +372,7 @@ _gfortran_caf_error_stop_str (const char *string, int32_t len)
> /* ERROR STOP function for numerical arguments. */
>  
> void
> -_gfortran_caf_error_stop (int32_t error)
> +_gfortran_caf_error_stop (int error)
> {
> fprintf (stderr, "ERROR STOP %d\n", error);
> error_stop (error);
> diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c
> index bead09a..d0c4b0b 100644
> --- a/libgfortran/caf/single.c
> +++ b/libgfortran/caf/single.c
> @@ -28,6 +28,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
> #include /* For exit and malloc. */
> #include /* For memcpy and memset. */
> #include /* For variadic arguments. */
> +#include  
> #include  
>  
> /* Define GFC_CAF_CHECK to enable run-time checking. */
> @@ -74,7 +75,7 @@ caf_runtime_error (const char *message, ...)
> /* Error handling is similar everytime. */
> static void
> caf_internal_error (const char *msg, int *stat, char *errmsg,
> - int errmsg_len, ...)
> + size_t errmsg_len, ...)
> {
> va_list args;
> va_start (args, errmsg_len);
> @@ -83,8 +84,8 @@ caf_internal_error (const char *msg, int *stat, char *errmsg,
> *stat = 1;
> if (errmsg_len > 0)
> {
> - size_t len = snprintf (errmsg, errmsg_len, msg, args);
> - if ((size_t)errmsg_len > len)
> + int len = snprintf (errmsg, errmsg_len, msg, args);
> + if (len >= 0 && errmsg_len > (size_t) len)
> memset (&errmsg[len], ' ', errmsg_len - len);
> }
> va_end (args);
> @@ -134,7 +135,7 @@ _gfortran_caf_num_images (int distance __attribute__ ((unused)),
> void
> _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
> gfc_descriptor_t *data, int *stat, char *errmsg,
> - int errmsg_len)
> + size_t errmsg_len)
> {
> const char alloc_fail_msg[] = "Failed to allocate coarray";
> void *local;
> @@ -195,7 +196,7 @@ _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
> void
> _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
> char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> caf_single_token_t single_token = TOKEN (*token);
>  
> @@ -221,7 +222,7 @@ _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
> void
> _gfortran_caf_sync_all (int *stat,
> char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> __asm__ __volatile__ ("":::"memory");
> if (stat)
> @@ -232,7 +233,7 @@ _gfortran_caf_sync_all (int *stat,
> void
> _gfortran_caf_sync_memory (int *stat,
> char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> __asm__ __volatile__ ("":::"memory");
> if (stat)
> @@ -245,7 +246,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
> int images[] __attribute__ ((unused)),
> int *stat,
> char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> #ifdef GFC_CAF_CHECK
> int i;
> @@ -266,7 +267,7 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
>  
>  
> void
> -_gfortran_caf_stop_numeric(int32_t stop_code)
> +_gfortran_caf_stop_numeric(int stop_code)
> {
> fprintf (stderr, "STOP %d\n", stop_code);
> exit (0);
> @@ -274,7 +275,7 @@ _gfortran_caf_stop_numeric(int32_t stop_code)
>  
>  
> void
> -_gfortran_caf_stop_str(const char *string, int32_t len)
> +_gfortran_caf_stop_str(const char *string, size_t len)
> {
> fputs ("STOP ", stderr);
> while (len--)
> @@ -286,7 +287,7 @@ _gfortran_caf_stop_str(const char *string, int32_t len)
>  
>  
> void
> -_gfortran_caf_error_stop_str (const char *string, int32_t len)
> +_gfortran_caf_error_stop_str (const char *string, size_t len)
> {
> fputs ("ERROR STOP ", stderr);
> while (len--)
> @@ -366,7 +367,7 @@ _gfortran_caf_stopped_images (gfc_descriptor_t *array,
>  
>  
> void
> -_gfortran_caf_error_stop (int32_t error)
> +_gfortran_caf_error_stop (int error)
> {
> fprintf (stderr, "ERROR STOP %d\n", error);
> exit (error);
> @@ -377,7 +378,7 @@ void
> _gfortran_caf_co_broadcast (gfc_descriptor_t *a __attribute__ ((unused)),
> int source_image __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> if (stat)
> *stat = 0;
> @@ -387,7 +388,7 @@ void
> _gfortran_caf_co_sum (gfc_descriptor_t *a __attribute__ ((unused)),
> int result_image __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> if (stat)
> *stat = 0;
> @@ -398,7 +399,7 @@ _gfortran_caf_co_min (gfc_descriptor_t *a __attribute__ ((unused)),
> int result_image __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> int a_len __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> if (stat)
> *stat = 0;
> @@ -409,7 +410,7 @@ _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)),
> int result_image __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> int a_len __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> if (stat)
> *stat = 0;
> @@ -424,7 +425,7 @@ _gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)),
> int result_image __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> int a_len __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> if (stat)
> *stat = 0;
> @@ -2870,7 +2871,7 @@ void
> _gfortran_caf_event_post (caf_token_t token, size_t index,
> int image_index __attribute__ ((unused)),
> int *stat, char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> uint32_t value = 1;
> uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
> @@ -2885,7 +2886,7 @@ void
> _gfortran_caf_event_wait (caf_token_t token, size_t index,
> int until_count, int *stat,
> char *errmsg __attribute__ ((unused)),
> - int errmsg_len __attribute__ ((unused)))
> + size_t errmsg_len __attribute__ ((unused)))
> {
> uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
> * sizeof (uint32_t));
> @@ -2912,7 +2913,7 @@ _gfortran_caf_event_query (caf_token_t token, size_t index,
> void
> _gfortran_caf_lock (caf_token_t token, size_t index,
> int image_index __attribute__ ((unused)),
> - int *aquired_lock, int *stat, char *errmsg, int errmsg_len)
> + int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)
> {
> const char *msg = "Already locked";
> bool *lock = &((bool *) MEMTOK (token))[index];
> @@ -2941,22 +2942,22 @@ _gfortran_caf_lock (caf_token_t token, size_t index,
> *stat = 1;
> if (errmsg_len > 0)
> {
> - int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
> - : (int) sizeof (msg);
> + size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
> + : sizeof (msg);
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> }
> return;
> }
> - _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
> + _gfortran_caf_error_stop_str (msg, strlen (msg));
> }
>  
>  
> void
> _gfortran_caf_unlock (caf_token_t token, size_t index,
> int image_index __attribute__ ((unused)),
> - int *stat, char *errmsg, int errmsg_len)
> + int *stat, char *errmsg, size_t errmsg_len)
> {
> const char *msg = "Variable is not locked";
> bool *lock = &((bool *) MEMTOK (token))[index];
> @@ -2974,15 +2975,15 @@ _gfortran_caf_unlock (caf_token_t token, size_t index,
> *stat = 1;
> if (errmsg_len > 0)
> {
> - int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
> - : (int) sizeof (msg);
> + size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
> + : sizeof (msg);
> memcpy (errmsg, msg, len);
> if (errmsg_len > len)
> memset (&errmsg[len], ' ', errmsg_len-len);
> }
> return;
> }
> - _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
> + _gfortran_caf_error_stop_str (msg, strlen (msg));
> }
>  
> int
> --
> 2.7.4
>
Janne Blomqvist Feb. 10, 2018, 9:20 p.m. UTC | #3
On Sat, Feb 10, 2018 at 9:34 PM, Damian Rouson
<damian@sourceryinstitute.org> wrote:
>
> I’ll try applying the patch and testing it.

As such, I'm sure that will fail as the patch changes the coarray API
and thus needs corresponding changes on the OpenCoarrays side as well.

>  I have about a 50% success rate with getting patches to apply cleanly.  Is this available on an svn or git branch that I can just checkout rather than attempting to apply the patch?  I find that process to be much more reliable.
>
> Going forward, please submit OpenCoarrays questions or issues via our issues page:
>
> https://github.com/sourceryinstitute/OpenCoarrays/issues

Ok, I just filed https://github.com/sourceryinstitute/OpenCoarrays/issues/497

> Most OpenCoarrays contributors don’t monitor the gfortran mailing list closely so we’re unlikely to see emails to the list in a timely manner.
>
> Also, when making changes that impact OpenCoarrays, please build OpenCoarrays and run our test suite.  We recently made several changes to our installation documentation and installer script based on feedback received from Steve Kargl.  One result is a set of instructions written by Zaak with GCC developers as an intended audience:
>
> https://github.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL
>
> Several other installation changes inspired by Steve’s feedback are listed here:
>
> https://github.com/sourceryinstitute/OpenCoarrays/issues/478
>
> and these will make it into a release shortly, but are already all available via git clone. I’m looking forward to hosting Oxford University Ph.D. student Daniel Garza, from March 17 to June 2, to work on finishing the integration of OpenCoarrays into the GCC autotools scripts so that OpenCoarrays will be built anytime gfortran is built so hopefully it will be even easier for everyone to build and test with OpenCoarrays soon.

Thanks; I should look into building opencoarrays at some point. For
this patch I was hoping that someone familiar with the OpenCoarrays
code base could do the equivalent fix there and test it, as it rather
mechanical and simple.
Janne Blomqvist Feb. 21, 2018, 7:35 p.m. UTC | #4
PING

Is anybody planning to work on this on the opencoarrays side? Or do
you prefer that this is just committed and you can sort it out on your
 own schedule?

On Sat, Feb 10, 2018 at 11:20 PM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> On Sat, Feb 10, 2018 at 9:34 PM, Damian Rouson
> <damian@sourceryinstitute.org> wrote:
>>
>> I’ll try applying the patch and testing it.
>
> As such, I'm sure that will fail as the patch changes the coarray API
> and thus needs corresponding changes on the OpenCoarrays side as well.
>
>>  I have about a 50% success rate with getting patches to apply cleanly.  Is this available on an svn or git branch that I can just checkout rather than attempting to apply the patch?  I find that process to be much more reliable.
>>
>> Going forward, please submit OpenCoarrays questions or issues via our issues page:
>>
>> https://github.com/sourceryinstitute/OpenCoarrays/issues
>
> Ok, I just filed https://github.com/sourceryinstitute/OpenCoarrays/issues/497
>
>> Most OpenCoarrays contributors don’t monitor the gfortran mailing list closely so we’re unlikely to see emails to the list in a timely manner.
>>
>> Also, when making changes that impact OpenCoarrays, please build OpenCoarrays and run our test suite.  We recently made several changes to our installation documentation and installer script based on feedback received from Steve Kargl.  One result is a set of instructions written by Zaak with GCC developers as an intended audience:
>>
>> https://github.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL
>>
>> Several other installation changes inspired by Steve’s feedback are listed here:
>>
>> https://github.com/sourceryinstitute/OpenCoarrays/issues/478
>>
>> and these will make it into a release shortly, but are already all available via git clone. I’m looking forward to hosting Oxford University Ph.D. student Daniel Garza, from March 17 to June 2, to work on finishing the integration of OpenCoarrays into the GCC autotools scripts so that OpenCoarrays will be built anytime gfortran is built so hopefully it will be even easier for everyone to build and test with OpenCoarrays soon.
>
> Thanks; I should look into building opencoarrays at some point. For
> this patch I was hoping that someone familiar with the OpenCoarrays
> code base could do the equivalent fix there and test it, as it rather
> mechanical and simple.
>
>
> --
> Janne Blomqvist
Damian Rouson Feb. 21, 2018, 8:18 p.m. UTC | #5
On February 21, 2018 at 11:35:47 AM, Janne Blomqvist (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:

> PING  
>  
> Is anybody planning to work on this on the opencoarrays side? Or do  
> you prefer that this is just committed and you can sort it out on your  
> own schedule?  

Hi Janne,

The trunk didn’t build for me the first time I tried soon after your initial email and it took me until yesterday to find time to try again.  Once I succeeded, the patch created three new test failures.  I’m wondering if Andre’s recent patch (r257813) helped reduce the number.  All new failures involve the failed-images features developed by Alessandro and Andre, both of whom now have new employment or contracts that prevent making significant contributions to OpenCoarrays (although I hope that will change and am working with Alessandro’s organization to attempt to get some of his time allocated to gfortran/OpenCoarrays development).

I think the most sustainable path forward is for me to assist any interested gfortran developer in building OpenCoarrays on your local system and running the test suite.  At least that eliminates the reliance on OpenCoarrays developers to run the tests every time a patch impacts OpenCoarrays.  If we can work together on building OpenCoarrays on your system, we can also look together at the requisite changes to see if we can eliminate the failures.

Oxford University Ph.D. student Daniel Garza visit Sourcery Institute March 17 - June 2 to integrate the building of OpenCoarrays into the GCC build system so I hope this will all be easier sooner.

Damian
Janne Blomqvist Feb. 21, 2018, 8:56 p.m. UTC | #6
On Wed, Feb 21, 2018 at 10:18 PM, Damian Rouson
<damian@sourceryinstitute.org> wrote:
>
>
>
>
> On February 21, 2018 at 11:35:47 AM, Janne Blomqvist (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:
>
>> PING
>>
>> Is anybody planning to work on this on the opencoarrays side? Or do
>> you prefer that this is just committed and you can sort it out on your
>> own schedule?
>
> Hi Janne,
>
> The trunk didn’t build for me the first time I tried soon after your initial email and it took me until yesterday to find time to try again.  Once I succeeded, the patch created three new test failures.  I’m wondering if Andre’s recent patch (r257813) helped reduce the number.  All new failures involve the failed-images features developed by Alessandro and Andre, both of whom now have new employment or contracts that prevent making significant contributions to OpenCoarrays (although I hope that will change and am working with Alessandro’s organization to attempt to get some of his time allocated to gfortran/OpenCoarrays development).
>
> I think the most sustainable path forward is for me to assist any interested gfortran developer in building OpenCoarrays on your local system and running the test suite.  At least that eliminates the reliance on OpenCoarrays developers to run the tests every time a patch impacts OpenCoarrays.  If we can work together on building OpenCoarrays on your system, we can also look together at the requisite changes to see if we can eliminate the failures.
>
> Oxford University Ph.D. student Daniel Garza visit Sourcery Institute March 17 - June 2 to integrate the building of OpenCoarrays into the GCC build system so I hope this will all be easier sooner.

Ok, I'll see if I find the time to get opencoarrays built.
Izaak Beekman Feb. 21, 2018, 8:59 p.m. UTC | #7
Reach out to Damian or me if you encounter any frustration. You should be
all set with a recent version of CMake and MPICH or OpenMPI installed. It
should look something like:

git clone https://github.com/sourceryinstitute/OpenCoarrays
cd OpenCoarrays
mkdir build
cd build
export FC=/path/to/gfortran/build/bin/gfortran
export CC=/path/to/gcc/build/bin/gcc
cmake ..
make -j
make check

Thanks,
Zaak

On Wed, Feb 21, 2018 at 3:56 PM Janne Blomqvist <blomqvist.janne@gmail.com>
wrote:

> On Wed, Feb 21, 2018 at 10:18 PM, Damian Rouson
> <damian@sourceryinstitute.org> wrote:
> >
> >
> >
> >
> > On February 21, 2018 at 11:35:47 AM, Janne Blomqvist (
> blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:
> >
> >> PING
> >>
> >> Is anybody planning to work on this on the opencoarrays side? Or do
> >> you prefer that this is just committed and you can sort it out on your
> >> own schedule?
> >
> > Hi Janne,
> >
> > The trunk didn’t build for me the first time I tried soon after your
> initial email and it took me until yesterday to find time to try again.
> Once I succeeded, the patch created three new test failures.  I’m wondering
> if Andre’s recent patch (r257813) helped reduce the number.  All new
> failures involve the failed-images features developed by Alessandro and
> Andre, both of whom now have new employment or contracts that prevent
> making significant contributions to OpenCoarrays (although I hope that will
> change and am working with Alessandro’s organization to attempt to get some
> of his time allocated to gfortran/OpenCoarrays development).
> >
> > I think the most sustainable path forward is for me to assist any
> interested gfortran developer in building OpenCoarrays on your local system
> and running the test suite.  At least that eliminates the reliance on
> OpenCoarrays developers to run the tests every time a patch impacts
> OpenCoarrays.  If we can work together on building OpenCoarrays on your
> system, we can also look together at the requisite changes to see if we can
> eliminate the failures.
> >
> > Oxford University Ph.D. student Daniel Garza visit Sourcery Institute
> March 17 - June 2 to integrate the building of OpenCoarrays into the GCC
> build system so I hope this will all be easier sooner.
>
> Ok, I'll see if I find the time to get opencoarrays built.
>
>
>
> --
> Janne Blomqvist
>
Damian Rouson Feb. 22, 2018, 12:36 a.m. UTC | #8
Hi Janne,

To be more specific, the new OpenCoarrays test failures after applying the patch are the following ones:

	 image_fail_test_1 (Timeout)
	 image_fail_and_sync_test_2 (Timeout)
	 image_fail_and_sync_test_3 (Timeout)
	 image_fail_and_get_test_1 (Timeout)

There are four.  I was mistaken when I wrote that there are three.

Damian

On February 21, 2018 at 12:56:05 PM, Janne Blomqvist (blomqvist.janne@gmail.com) wrote:

On Wed, Feb 21, 2018 at 10:18 PM, Damian Rouson  
<damian@sourceryinstitute.org> wrote:  
>  
>  
>  
>  
> On February 21, 2018 at 11:35:47 AM, Janne Blomqvist (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:  
>  
>> PING  
>>  
>> Is anybody planning to work on this on the opencoarrays side? Or do  
>> you prefer that this is just committed and you can sort it out on your  
>> own schedule?  
>  
> Hi Janne,  
>  
> The trunk didn’t build for me the first time I tried soon after your initial email and it took me until yesterday to find time to try again. Once I succeeded, the patch created three new test failures. I’m wondering if Andre’s recent patch (r257813) helped reduce the number. All new failures involve the failed-images features developed by Alessandro and Andre, both of whom now have new employment or contracts that prevent making significant contributions to OpenCoarrays (although I hope that will change and am working with Alessandro’s organization to attempt to get some of his time allocated to gfortran/OpenCoarrays development).  
>  
> I think the most sustainable path forward is for me to assist any interested gfortran developer in building OpenCoarrays on your local system and running the test suite. At least that eliminates the reliance on OpenCoarrays developers to run the tests every time a patch impacts OpenCoarrays. If we can work together on building OpenCoarrays on your system, we can also look together at the requisite changes to see if we can eliminate the failures.  
>  
> Oxford University Ph.D. student Daniel Garza visit Sourcery Institute March 17 - June 2 to integrate the building of OpenCoarrays into the GCC build system so I hope this will all be easier sooner.  

Ok, I'll see if I find the time to get opencoarrays built.  



--  
Janne Blomqvist
Janne Blomqvist Feb. 22, 2018, 9:46 a.m. UTC | #9
On Thu, Feb 22, 2018 at 2:36 AM, Damian Rouson
<damian@sourceryinstitute.org> wrote:
> Hi Janne,
>
> To be more specific, the new OpenCoarrays test failures after applying the
> patch are the following ones:
>
>  image_fail_test_1 (Timeout)
>  image_fail_and_sync_test_2 (Timeout)
>  image_fail_and_sync_test_3 (Timeout)
>  image_fail_and_get_test_1 (Timeout)
>
> There are four.  I was mistaken when I wrote that there are three.
>
> Damian
>
> On February 21, 2018 at 12:56:05 PM, Janne Blomqvist
> (blomqvist.janne@gmail.com) wrote:
>
> On Wed, Feb 21, 2018 at 10:18 PM, Damian Rouson
> <damian@sourceryinstitute.org> wrote:
>>
>>
>>
>>
>> On February 21, 2018 at 11:35:47 AM, Janne Blomqvist
>> (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:
>>
>>> PING
>>>
>>> Is anybody planning to work on this on the opencoarrays side? Or do
>>> you prefer that this is just committed and you can sort it out on your
>>> own schedule?
>>
>> Hi Janne,
>>
>> The trunk didn’t build for me the first time I tried soon after your
>> initial email and it took me until yesterday to find time to try again. Once
>> I succeeded, the patch created three new test failures. I’m wondering if
>> Andre’s recent patch (r257813) helped reduce the number. All new failures
>> involve the failed-images features developed by Alessandro and Andre, both
>> of whom now have new employment or contracts that prevent making significant
>> contributions to OpenCoarrays (although I hope that will change and am
>> working with Alessandro’s organization to attempt to get some of his time
>> allocated to gfortran/OpenCoarrays development).
>>
>> I think the most sustainable path forward is for me to assist any
>> interested gfortran developer in building OpenCoarrays on your local system
>> and running the test suite. At least that eliminates the reliance on
>> OpenCoarrays developers to run the tests every time a patch impacts
>> OpenCoarrays. If we can work together on building OpenCoarrays on your
>> system, we can also look together at the requisite changes to see if we can
>> eliminate the failures.
>>
>> Oxford University Ph.D. student Daniel Garza visit Sourcery Institute
>> March 17 - June 2 to integrate the building of OpenCoarrays into the GCC
>> build system so I hope this will all be easier sooner.
>
> Ok, I'll see if I find the time to get opencoarrays built.
>
>
>
> --
> Janne Blomqvist

Hi,

I managed to build and test OpenCoarrays. I committed a slightly
enlarged patch (I needed to fix STOP and ERROR STOP in libgfortran as
well to make everything consistent) as r257894. I'll shortly send out
the pull request with the corresponding changes needed in
OpenCoarrays.
Janne Blomqvist Feb. 22, 2018, 9:57 a.m. UTC | #10
On Thu, Feb 22, 2018 at 11:46 AM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> On Thu, Feb 22, 2018 at 2:36 AM, Damian Rouson
> <damian@sourceryinstitute.org> wrote:
>> Hi Janne,
>>
>> To be more specific, the new OpenCoarrays test failures after applying the
>> patch are the following ones:
>>
>>  image_fail_test_1 (Timeout)
>>  image_fail_and_sync_test_2 (Timeout)
>>  image_fail_and_sync_test_3 (Timeout)
>>  image_fail_and_get_test_1 (Timeout)
>>
>> There are four.  I was mistaken when I wrote that there are three.
>>
>> Damian
>>
>> On February 21, 2018 at 12:56:05 PM, Janne Blomqvist
>> (blomqvist.janne@gmail.com) wrote:
>>
>> On Wed, Feb 21, 2018 at 10:18 PM, Damian Rouson
>> <damian@sourceryinstitute.org> wrote:
>>>
>>>
>>>
>>>
>>> On February 21, 2018 at 11:35:47 AM, Janne Blomqvist
>>> (blomqvist.janne@gmail.com(mailto:blomqvist.janne@gmail.com)) wrote:
>>>
>>>> PING
>>>>
>>>> Is anybody planning to work on this on the opencoarrays side? Or do
>>>> you prefer that this is just committed and you can sort it out on your
>>>> own schedule?
>>>
>>> Hi Janne,
>>>
>>> The trunk didn’t build for me the first time I tried soon after your
>>> initial email and it took me until yesterday to find time to try again. Once
>>> I succeeded, the patch created three new test failures. I’m wondering if
>>> Andre’s recent patch (r257813) helped reduce the number. All new failures
>>> involve the failed-images features developed by Alessandro and Andre, both
>>> of whom now have new employment or contracts that prevent making significant
>>> contributions to OpenCoarrays (although I hope that will change and am
>>> working with Alessandro’s organization to attempt to get some of his time
>>> allocated to gfortran/OpenCoarrays development).
>>>
>>> I think the most sustainable path forward is for me to assist any
>>> interested gfortran developer in building OpenCoarrays on your local system
>>> and running the test suite. At least that eliminates the reliance on
>>> OpenCoarrays developers to run the tests every time a patch impacts
>>> OpenCoarrays. If we can work together on building OpenCoarrays on your
>>> system, we can also look together at the requisite changes to see if we can
>>> eliminate the failures.
>>>
>>> Oxford University Ph.D. student Daniel Garza visit Sourcery Institute
>>> March 17 - June 2 to integrate the building of OpenCoarrays into the GCC
>>> build system so I hope this will all be easier sooner.
>>
>> Ok, I'll see if I find the time to get opencoarrays built.
>>
>>
>>
>> --
>> Janne Blomqvist
>
> Hi,
>
> I managed to build and test OpenCoarrays. I committed a slightly
> enlarged patch (I needed to fix STOP and ERROR STOP in libgfortran as
> well to make everything consistent) as r257894. I'll shortly send out
> the pull request with the corresponding changes needed in
> OpenCoarrays.

OpenCoarrays pull request:
https://github.com/sourceryinstitute/OpenCoarrays/pull/508
diff mbox series

Patch

diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 1124669..7c09bc4 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -4458,7 +4458,7 @@  NULL.
 
 @item @emph{Syntax}:
 @code{void caf_register (size_t size, caf_register_t type, caf_token_t *token,
-gfc_descriptor_t *desc, int *stat, char *errmsg, int errmsg_len)}
+gfc_descriptor_t *desc, int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -4510,7 +4510,7 @@  during a call to @code{_gfortran_caf_register}.
 
 @item @emph{Syntax}:
 @code{void caf_deregister (caf_token_t *token, caf_deregister_t type,
-int *stat, char *errmsg, int errmsg_len)}
+int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -4936,7 +4936,7 @@  which has already been locked by the same image is an error.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_lock (caf_token_t token, size_t index, int image_index,
-int *aquired_lock, int *stat, char *errmsg, int errmsg_len)}
+int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -4971,7 +4971,7 @@  which is unlocked or has been locked by a different image is an error.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_unlock (caf_token_t token, size_t index, int image_index,
-int *stat, char *errmsg, int errmsg_len)}
+int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5003,7 +5003,7 @@  Increment the event count of the specified event variable.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_event_post (caf_token_t token, size_t index,
-int image_index, int *stat, char *errmsg, int errmsg_len)}
+int image_index, int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5040,7 +5040,7 @@  amount and return.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_event_wait (caf_token_t token, size_t index,
-int until_count, int *stat, char *errmsg, int errmsg_len)}
+int until_count, int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5118,7 +5118,7 @@  current team.  Additionally, it ensures that all pending data transfers of
 previous segment have completed.
 
 @item @emph{Syntax}:
-@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)}
+@code{void _gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5146,7 +5146,7 @@  transfers of previous segments have completed.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_sync_images (int count, int images[], int *stat,
-char *errmsg, int errmsg_len)}
+char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5174,7 +5174,7 @@  Acts as optimization barrier between different segments. It also ensures that
 all pending memory operations of this image have been completed.
 
 @item @emph{Syntax}:
-@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, int errmsg_len)}
+@code{void _gfortran_caf_sync_memory (int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5201,7 +5201,7 @@  function should terminate the program with the specified exit code.
 
 
 @item @emph{Syntax}:
-@code{void _gfortran_caf_error_stop (int32_t error)}
+@code{void _gfortran_caf_error_stop (int error)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5221,7 +5221,7 @@  Invoked for an @code{ERROR STOP} statement which has a string as argument.  The
 function should terminate the program with a nonzero-exit code.
 
 @item @emph{Syntax}:
-@code{void _gfortran_caf_error_stop (const char *string, int32_t len)}
+@code{void _gfortran_caf_error_stop (const char *string, size_t len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5399,7 +5399,7 @@  be called collectively.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_co_broadcast (gfc_descriptor_t *a,
-int source_image, int *stat, char *errmsg, int errmsg_len)}
+int source_image, int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5430,7 +5430,7 @@  strings.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_co_max (gfc_descriptor_t *a, int result_image,
-int *stat, char *errmsg, int a_len, int errmsg_len)}
+int *stat, char *errmsg, int a_len, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5467,7 +5467,7 @@  strings.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_co_min (gfc_descriptor_t *a, int result_image,
-int *stat, char *errmsg, int a_len, int errmsg_len)}
+int *stat, char *errmsg, int a_len, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5503,7 +5503,7 @@  specified image.  This function operates on numeric values only.
 
 @item @emph{Syntax}:
 @code{void _gfortran_caf_co_sum (gfc_descriptor_t *a, int result_image,
-int *stat, char *errmsg, int errmsg_len)}
+int *stat, char *errmsg, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
@@ -5548,7 +5548,7 @@  string lengths shall be specified as hidden arguments;
 @item @emph{Syntax}:
 @code{void _gfortran_caf_co_reduce (gfc_descriptor_t *a,
 void * (*opr) (void *, void *), int opr_flags, int result_image,
-int *stat, char *errmsg, int a_len, int errmsg_len)}
+int *stat, char *errmsg, int a_len, size_t errmsg_len)}
 
 @item @emph{Arguments}:
 @multitable @columnfractions .15 .70
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 4fc07b6..1830856 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -3635,12 +3635,12 @@  gfc_build_builtin_function_decls (void)
       gfor_fndecl_caf_register = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_register")), "RRWWWWR", void_type_node, 7,
 	size_type_node, integer_type_node, ppvoid_type_node, pvoid_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_deregister = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_deregister")), "WRWWR", void_type_node, 5,
 	ppvoid_type_node, integer_type_node, pint_type, pchar_type_node,
-	integer_type_node);
+	size_type_node);
 
       gfor_fndecl_caf_get = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_get")), ".R.RRWRRRW", void_type_node, 10,
@@ -3683,38 +3683,38 @@  gfc_build_builtin_function_decls (void)
 
       gfor_fndecl_caf_sync_all = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_sync_all")), ".WW", void_type_node,
-	3, pint_type, pchar_type_node, integer_type_node);
+	3, pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_sync_memory = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_sync_memory")), ".WW", void_type_node,
-	3, pint_type, pchar_type_node, integer_type_node);
+	3, pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_sync_images = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_sync_images")), ".RRWW", void_type_node,
 	5, integer_type_node, pint_type, pint_type,
-	pchar_type_node, integer_type_node);
+	pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_error_stop = gfc_build_library_function_decl (
 	get_identifier (PREFIX("caf_error_stop")),
-	void_type_node, 1, gfc_int4_type_node);
+	void_type_node, 1, integer_type_node);
       /* CAF's ERROR STOP doesn't return.  */
       TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop) = 1;
 
       gfor_fndecl_caf_error_stop_str = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_error_stop_str")), ".R.",
-	void_type_node, 2, pchar_type_node, gfc_int4_type_node);
+	void_type_node, 2, pchar_type_node, size_type_node);
       /* CAF's ERROR STOP doesn't return.  */
       TREE_THIS_VOLATILE (gfor_fndecl_caf_error_stop_str) = 1;
 
       gfor_fndecl_caf_stop_numeric = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_stop_numeric")), ".R.",
-	void_type_node, 1, gfc_int4_type_node);
+	void_type_node, 1, integer_type_node);
       /* CAF's STOP doesn't return.  */
       TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_numeric) = 1;
 
       gfor_fndecl_caf_stop_str = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_stop_str")), ".R.",
-	void_type_node, 2, pchar_type_node, gfc_int4_type_node);
+	void_type_node, 2, pchar_type_node, size_type_node);
       /* CAF's STOP doesn't return.  */
       TREE_THIS_VOLATILE (gfor_fndecl_caf_stop_str) = 1;
 
@@ -3743,22 +3743,22 @@  gfc_build_builtin_function_decls (void)
       gfor_fndecl_caf_lock = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_lock")), "R..WWW",
 	void_type_node, 7, pvoid_type_node, size_type_node, integer_type_node,
-	pint_type, pint_type, pchar_type_node, integer_type_node);
+	pint_type, pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_unlock = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_unlock")), "R..WW",
 	void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_event_post = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_event_post")), "R..WW",
 	void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_event_wait = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_event_wait")), "R..WW",
 	void_type_node, 6, pvoid_type_node, size_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_event_query = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_event_query")), "R..WW",
@@ -3822,17 +3822,17 @@  gfc_build_builtin_function_decls (void)
       gfor_fndecl_co_broadcast = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_co_broadcast")), "W.WW",
 	void_type_node, 5, pvoid_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_co_max = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_co_max")), "W.WW",
 	void_type_node, 6, pvoid_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node, integer_type_node);
+	pint_type, pchar_type_node, integer_type_node, size_type_node);
 
       gfor_fndecl_co_min = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_co_min")), "W.WW",
 	void_type_node, 6, pvoid_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node, integer_type_node);
+	pint_type, pchar_type_node, integer_type_node, size_type_node);
 
       gfor_fndecl_co_reduce = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_co_reduce")), "W.R.WW",
@@ -3840,12 +3840,12 @@  gfc_build_builtin_function_decls (void)
 	build_pointer_type (build_varargs_function_type_list (void_type_node,
 							      NULL_TREE)),
 	integer_type_node, integer_type_node, pint_type, pchar_type_node,
-	integer_type_node, integer_type_node);
+	integer_type_node, size_type_node);
 
       gfor_fndecl_co_sum = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_co_sum")), "W.WW",
 	void_type_node, 5, pvoid_type_node, integer_type_node,
-	pint_type, pchar_type_node, integer_type_node);
+	pint_type, pchar_type_node, size_type_node);
 
       gfor_fndecl_caf_is_present = gfc_build_library_function_decl_with_spec (
 	get_identifier (PREFIX("caf_is_present")), "RRR",
@@ -5348,7 +5348,7 @@  generate_coarray_sym_init (gfc_symbol *sym)
 			     token, gfc_build_addr_expr (pvoid_type_node, desc),
 			     null_pointer_node, /* stat.  */
 			     null_pointer_node, /* errgmsg.  */
-			     integer_zero_node); /* errmsg_len.  */
+			     build_zero_cst (size_type_node)); /* errmsg_len.  */
   gfc_add_expr_to_block (&caf_init_block, tmp);
   gfc_add_modify (&caf_init_block, decl, fold_convert (TREE_TYPE (decl),
 					  gfc_conv_descriptor_data_get (desc)));
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 337227d..b06afc6 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -9817,12 +9817,12 @@  conv_co_collective (gfc_code *code)
       gfc_add_block_to_block (&block, &argse.pre);
       gfc_add_block_to_block (&post_block, &argse.post);
       errmsg = argse.expr;
-      errmsg_len = fold_convert (integer_type_node, argse.string_length);
+      errmsg_len = fold_convert (size_type_node, argse.string_length);
     }
   else
     {
       errmsg = null_pointer_node;
-      errmsg_len = integer_zero_node;
+      errmsg_len = build_zero_cst (size_type_node);
     }
 
   /* Generate the function call.  */
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 573fd48..5953557 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -913,12 +913,12 @@  gfc_trans_lock_unlock (gfc_code *code, gfc_exec_op op)
 	  gfc_conv_expr (&argse, code->expr3);
 	  gfc_add_block_to_block (&se.pre, &argse.pre);
 	  errmsg = argse.expr;
-	  errmsg_len = fold_convert (integer_type_node, argse.string_length);
+	  errmsg_len = fold_convert (size_type_node, argse.string_length);
 	}
       else
 	{
 	  errmsg = null_pointer_node;
-	  errmsg_len = integer_zero_node;
+	  errmsg_len = build_zero_cst (size_type_node);
 	}
 
       if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
@@ -1112,12 +1112,12 @@  gfc_trans_event_post_wait (gfc_code *code, gfc_exec_op op)
       gfc_conv_expr (&argse, code->expr3);
       gfc_add_block_to_block (&se.pre, &argse.pre);
       errmsg = argse.expr;
-      errmsg_len = fold_convert (integer_type_node, argse.string_length);
+      errmsg_len = fold_convert (size_type_node, argse.string_length);
     }
   else
     {
       errmsg = null_pointer_node;
-      errmsg_len = integer_zero_node;
+      errmsg_len = build_zero_cst (size_type_node);
     }
 
   if (stat != null_pointer_node && TREE_TYPE (stat) != integer_type_node)
@@ -1196,12 +1196,12 @@  gfc_trans_sync (gfc_code *code, gfc_exec_op type)
       gfc_conv_expr (&argse, code->expr3);
       gfc_conv_string_parameter (&argse);
       errmsg = gfc_build_addr_expr (NULL, argse.expr);
-      errmsglen = argse.string_length;
+      errmsglen = fold_convert (size_type_node, argse.string_length);
     }
   else if (flag_coarray == GFC_FCOARRAY_LIB)
     {
       errmsg = null_pointer_node;
-      errmsglen = build_int_cst (integer_type_node, 0);
+      errmsglen = build_int_cst (size_type_node, 0);
     }
 
   /* Check SYNC IMAGES(imageset) for valid image index.
diff --git a/libgfortran/caf/libcaf.h b/libgfortran/caf/libcaf.h
index 12c73de..34744ed 100644
--- a/libgfortran/caf/libcaf.h
+++ b/libgfortran/caf/libcaf.h
@@ -28,7 +28,6 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include <stdbool.h>
 #include <stddef.h>	/* For size_t.  */
-#include <stdint.h>	/* For int32_t.  */
 
 #include "libgfortran.h"
 
@@ -190,29 +189,29 @@  int _gfortran_caf_this_image (int);
 int _gfortran_caf_num_images (int, int);
 
 void _gfortran_caf_register (size_t, caf_register_t, caf_token_t *,
-			     gfc_descriptor_t *, int *, char *, int);
+			     gfc_descriptor_t *, int *, char *, size_t);
 void _gfortran_caf_deregister (caf_token_t *, caf_deregister_t, int *, char *,
-			       int);
+			       size_t);
 
-void _gfortran_caf_sync_all (int *, char *, int);
-void _gfortran_caf_sync_memory (int *, char *, int);
-void _gfortran_caf_sync_images (int, int[], int *, char *, int);
+void _gfortran_caf_sync_all (int *, char *, size_t);
+void _gfortran_caf_sync_memory (int *, char *, size_t);
+void _gfortran_caf_sync_images (int, int[], int *, char *, size_t);
 
-void _gfortran_caf_stop_numeric (int32_t)
+void _gfortran_caf_stop_numeric (int)
      __attribute__ ((noreturn));
-void _gfortran_caf_stop_str (const char *, int32_t)
+void _gfortran_caf_stop_str (const char *, size_t)
      __attribute__ ((noreturn));
-void _gfortran_caf_error_stop_str (const char *, int32_t)
+void _gfortran_caf_error_stop_str (const char *, size_t)
      __attribute__ ((noreturn));
-void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
+void _gfortran_caf_error_stop (int) __attribute__ ((noreturn));
 void _gfortran_caf_fail_image (void) __attribute__ ((noreturn));
 
-void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, int);
-void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
-void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
-void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int);
+void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, size_t);
+void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, size_t);
+void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, size_t);
+void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, size_t);
 void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
-			      int, int, int *, char *, int, int);
+			      int, int, int *, char *, int, size_t);
 
 void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
 			caf_vector_t *, gfc_descriptor_t *, int, int, bool,
@@ -245,10 +244,10 @@  void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
 void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
 			      int *, int, int);
 
-void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
-void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
-void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, int);
-void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, int);
+void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, size_t);
+void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, size_t);
+void _gfortran_caf_event_post (caf_token_t, size_t, int, int *, char *, size_t);
+void _gfortran_caf_event_wait (caf_token_t, size_t, int, int *, char *, size_t);
 void _gfortran_caf_event_query (caf_token_t, size_t, int, int *, int *);
 
 void _gfortran_caf_failed_images (gfc_descriptor_t *,
diff --git a/libgfortran/caf/mpi.c b/libgfortran/caf/mpi.c
index 0f7977f..14c10b5 100644
--- a/libgfortran/caf/mpi.c
+++ b/libgfortran/caf/mpi.c
@@ -131,7 +131,7 @@  _gfortran_caf_num_images (int distance __attribute__ ((unused)),
 
 void *
 _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
-			int *stat, char *errmsg, int errmsg_len,
+			int *stat, char *errmsg, size_t errmsg_len,
 			int num_alloc_comps __attribute__ ((unused)))
 {
   void *local;
@@ -189,8 +189,8 @@  error:
 	*stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
 	if (errmsg_len > 0)
 	  {
-	    int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
-							: (int) strlen (msg);
+	    size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
+	      : strlen (msg);
 	    memcpy (errmsg, msg, len);
 	    if (errmsg_len > len)
 	      memset (&errmsg[len], ' ', errmsg_len-len);
@@ -205,7 +205,7 @@  error:
 
 
 void
-_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
+_gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, size_t errmsg_len)
 {
   if (unlikely (caf_is_finalized))
     {
@@ -217,8 +217,8 @@  _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
 	
 	  if (errmsg_len > 0)
 	    {
-	      int len = ((int) sizeof (msg) - 1 > errmsg_len)
-			? errmsg_len : (int) sizeof (msg) - 1;
+	      size_t len = (sizeof (msg) - 1 > errmsg_len)
+		? errmsg_len : sizeof (msg) - 1;
 	      memcpy (errmsg, msg, len);
 	      if (errmsg_len > len)
 		memset (&errmsg[len], ' ', errmsg_len-len);
@@ -239,7 +239,7 @@  _gfortran_caf_deregister (caf_token_t *token, int *stat, char *errmsg, int errms
 
 
 void
-_gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
+_gfortran_caf_sync_all (int *stat, char *errmsg, size_t errmsg_len)
 {
   int ierr;
 
@@ -261,8 +261,8 @@  _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
 
       if (errmsg_len > 0)
 	{
-	  int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
-						      : (int) strlen (msg);
+	  size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
+	    : strlen (msg);
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
@@ -278,7 +278,7 @@  _gfortran_caf_sync_all (int *stat, char *errmsg, int errmsg_len)
    is not equivalent to SYNC ALL. */
 void
 _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
-			   int errmsg_len)
+			   size_t errmsg_len)
 {
   int ierr;
   if (count == 0 || (count == 1 && images[0] == caf_this_image))
@@ -329,8 +329,8 @@  _gfortran_caf_sync_images (int count, int images[], int *stat, char *errmsg,
 
       if (errmsg_len > 0)
 	{
-	  int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
-						      : (int) strlen (msg);
+	  size_t len = (strlen (msg) > errmsg_len) ? errmsg_len
+	    : strlen (msg);
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
@@ -358,7 +358,7 @@  error_stop (int error)
 /* ERROR STOP function for string arguments.  */
 
 void
-_gfortran_caf_error_stop_str (const char *string, int32_t len)
+_gfortran_caf_error_stop_str (const char *string, size_t len)
 {
   fputs ("ERROR STOP ", stderr);
   while (len--)
@@ -372,7 +372,7 @@  _gfortran_caf_error_stop_str (const char *string, int32_t len)
 /* ERROR STOP function for numerical arguments.  */
 
 void
-_gfortran_caf_error_stop (int32_t error)
+_gfortran_caf_error_stop (int error)
 {
   fprintf (stderr, "ERROR STOP %d\n", error);
   error_stop (error);
diff --git a/libgfortran/caf/single.c b/libgfortran/caf/single.c
index bead09a..d0c4b0b 100644
--- a/libgfortran/caf/single.c
+++ b/libgfortran/caf/single.c
@@ -28,6 +28,7 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #include <stdlib.h> /* For exit and malloc.  */
 #include <string.h> /* For memcpy and memset.  */
 #include <stdarg.h> /* For variadic arguments.  */
+#include <stdint.h>
 #include <assert.h>
 
 /* Define GFC_CAF_CHECK to enable run-time checking.  */
@@ -74,7 +75,7 @@  caf_runtime_error (const char *message, ...)
 /* Error handling is similar everytime.  */
 static void
 caf_internal_error (const char *msg, int *stat, char *errmsg,
-		    int errmsg_len, ...)
+		    size_t errmsg_len, ...)
 {
   va_list args;
   va_start (args, errmsg_len);
@@ -83,8 +84,8 @@  caf_internal_error (const char *msg, int *stat, char *errmsg,
       *stat = 1;
       if (errmsg_len > 0)
 	{
-	  size_t len = snprintf (errmsg, errmsg_len, msg, args);
-	  if ((size_t)errmsg_len > len)
+	  int len = snprintf (errmsg, errmsg_len, msg, args);
+	  if (len >= 0 && errmsg_len > (size_t) len)
 	    memset (&errmsg[len], ' ', errmsg_len - len);
 	}
       va_end (args);
@@ -134,7 +135,7 @@  _gfortran_caf_num_images (int distance __attribute__ ((unused)),
 void
 _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
 			gfc_descriptor_t *data, int *stat, char *errmsg,
-			int errmsg_len)
+			size_t errmsg_len)
 {
   const char alloc_fail_msg[] = "Failed to allocate coarray";
   void *local;
@@ -195,7 +196,7 @@  _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
 void
 _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
 			  char *errmsg __attribute__ ((unused)),
-			  int errmsg_len __attribute__ ((unused)))
+			  size_t errmsg_len __attribute__ ((unused)))
 {
   caf_single_token_t single_token = TOKEN (*token);
 
@@ -221,7 +222,7 @@  _gfortran_caf_deregister (caf_token_t *token, caf_deregister_t type, int *stat,
 void
 _gfortran_caf_sync_all (int *stat,
 			char *errmsg __attribute__ ((unused)),
-			int errmsg_len __attribute__ ((unused)))
+			size_t errmsg_len __attribute__ ((unused)))
 {
   __asm__ __volatile__ ("":::"memory");
   if (stat)
@@ -232,7 +233,7 @@  _gfortran_caf_sync_all (int *stat,
 void
 _gfortran_caf_sync_memory (int *stat,
 			   char *errmsg __attribute__ ((unused)),
-			   int errmsg_len __attribute__ ((unused)))
+			   size_t errmsg_len __attribute__ ((unused)))
 {
   __asm__ __volatile__ ("":::"memory");
   if (stat)
@@ -245,7 +246,7 @@  _gfortran_caf_sync_images (int count __attribute__ ((unused)),
 			   int images[] __attribute__ ((unused)),
 			   int *stat,
 			   char *errmsg __attribute__ ((unused)),
-			   int errmsg_len __attribute__ ((unused)))
+			   size_t errmsg_len __attribute__ ((unused)))
 {
 #ifdef GFC_CAF_CHECK
   int i;
@@ -266,7 +267,7 @@  _gfortran_caf_sync_images (int count __attribute__ ((unused)),
 
 
 void
-_gfortran_caf_stop_numeric(int32_t stop_code)
+_gfortran_caf_stop_numeric(int stop_code)
 {
   fprintf (stderr, "STOP %d\n", stop_code);
   exit (0);
@@ -274,7 +275,7 @@  _gfortran_caf_stop_numeric(int32_t stop_code)
 
 
 void
-_gfortran_caf_stop_str(const char *string, int32_t len)
+_gfortran_caf_stop_str(const char *string, size_t len)
 {
   fputs ("STOP ", stderr);
   while (len--)
@@ -286,7 +287,7 @@  _gfortran_caf_stop_str(const char *string, int32_t len)
 
 
 void
-_gfortran_caf_error_stop_str (const char *string, int32_t len)
+_gfortran_caf_error_stop_str (const char *string, size_t len)
 {
   fputs ("ERROR STOP ", stderr);
   while (len--)
@@ -366,7 +367,7 @@  _gfortran_caf_stopped_images (gfc_descriptor_t *array,
 
 
 void
-_gfortran_caf_error_stop (int32_t error)
+_gfortran_caf_error_stop (int error)
 {
   fprintf (stderr, "ERROR STOP %d\n", error);
   exit (error);
@@ -377,7 +378,7 @@  void
 _gfortran_caf_co_broadcast (gfc_descriptor_t *a __attribute__ ((unused)),
 			    int source_image __attribute__ ((unused)),
 			    int *stat, char *errmsg __attribute__ ((unused)),
-			    int errmsg_len __attribute__ ((unused)))
+			    size_t errmsg_len __attribute__ ((unused)))
 {
   if (stat)
     *stat = 0;
@@ -387,7 +388,7 @@  void
 _gfortran_caf_co_sum (gfc_descriptor_t *a __attribute__ ((unused)),
 		      int result_image __attribute__ ((unused)),
 		      int *stat, char *errmsg __attribute__ ((unused)),
-		      int errmsg_len __attribute__ ((unused)))
+		      size_t errmsg_len __attribute__ ((unused)))
 {
   if (stat)
     *stat = 0;
@@ -398,7 +399,7 @@  _gfortran_caf_co_min (gfc_descriptor_t *a __attribute__ ((unused)),
 		      int result_image __attribute__ ((unused)),
 		      int *stat, char *errmsg __attribute__ ((unused)),
 		      int a_len __attribute__ ((unused)),
-		      int errmsg_len __attribute__ ((unused)))
+		      size_t errmsg_len __attribute__ ((unused)))
 {
   if (stat)
     *stat = 0;
@@ -409,7 +410,7 @@  _gfortran_caf_co_max (gfc_descriptor_t *a __attribute__ ((unused)),
 		      int result_image __attribute__ ((unused)),
 		      int *stat, char *errmsg __attribute__ ((unused)),
 		      int a_len __attribute__ ((unused)),
-		      int errmsg_len __attribute__ ((unused)))
+		      size_t errmsg_len __attribute__ ((unused)))
 {
   if (stat)
     *stat = 0;
@@ -424,7 +425,7 @@  _gfortran_caf_co_reduce (gfc_descriptor_t *a __attribute__ ((unused)),
                         int result_image __attribute__ ((unused)),
                         int *stat, char *errmsg __attribute__ ((unused)),
                         int a_len __attribute__ ((unused)),
-                        int errmsg_len __attribute__ ((unused)))
+                        size_t errmsg_len __attribute__ ((unused)))
  {
    if (stat)
      *stat = 0;
@@ -2870,7 +2871,7 @@  void
 _gfortran_caf_event_post (caf_token_t token, size_t index, 
 			  int image_index __attribute__ ((unused)), 
 			  int *stat, char *errmsg __attribute__ ((unused)), 
-			  int errmsg_len __attribute__ ((unused)))
+			  size_t errmsg_len __attribute__ ((unused)))
 {
   uint32_t value = 1;
   uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
@@ -2885,7 +2886,7 @@  void
 _gfortran_caf_event_wait (caf_token_t token, size_t index, 
 			  int until_count, int *stat,
 			  char *errmsg __attribute__ ((unused)), 
-			  int errmsg_len __attribute__ ((unused)))
+			  size_t errmsg_len __attribute__ ((unused)))
 {
   uint32_t *event = (uint32_t *) ((char *) MEMTOK (token) + index
 				  * sizeof (uint32_t));
@@ -2912,7 +2913,7 @@  _gfortran_caf_event_query (caf_token_t token, size_t index,
 void
 _gfortran_caf_lock (caf_token_t token, size_t index,
 		    int image_index __attribute__ ((unused)),
-		    int *aquired_lock, int *stat, char *errmsg, int errmsg_len)
+		    int *aquired_lock, int *stat, char *errmsg, size_t errmsg_len)
 {
   const char *msg = "Already locked";
   bool *lock = &((bool *) MEMTOK (token))[index];
@@ -2941,22 +2942,22 @@  _gfortran_caf_lock (caf_token_t token, size_t index,
       *stat = 1;
       if (errmsg_len > 0)
 	{
-	  int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
-						      : (int) sizeof (msg);
+	  size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
+						      : sizeof (msg);
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
 	}
       return;
     }
-  _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
+  _gfortran_caf_error_stop_str (msg, strlen (msg));
 }
 
 
 void
 _gfortran_caf_unlock (caf_token_t token, size_t index,
 		      int image_index __attribute__ ((unused)),
-		      int *stat, char *errmsg, int errmsg_len)
+		      int *stat, char *errmsg, size_t errmsg_len)
 {
   const char *msg = "Variable is not locked";
   bool *lock = &((bool *) MEMTOK (token))[index];
@@ -2974,15 +2975,15 @@  _gfortran_caf_unlock (caf_token_t token, size_t index,
       *stat = 1;
       if (errmsg_len > 0)
 	{
-	  int len = ((int) sizeof (msg) > errmsg_len) ? errmsg_len
-						      : (int) sizeof (msg);
+	  size_t len = (sizeof (msg) > errmsg_len) ? errmsg_len
+	    : sizeof (msg);
 	  memcpy (errmsg, msg, len);
 	  if (errmsg_len > len)
 	    memset (&errmsg[len], ' ', errmsg_len-len);
 	}
       return;
     }
-  _gfortran_caf_error_stop_str (msg, (int32_t) strlen (msg));
+  _gfortran_caf_error_stop_str (msg, strlen (msg));
 }
 
 int