[open-coarrays] 46/80: New upstream 1.8.6

Alastair McKinstry mckinstry at moszumanska.debian.org
Wed Oct 25 13:45:48 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository open-coarrays.

commit 95c4d634ef6ae620fa2c796a028d9f408946829b
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Thu Apr 20 12:03:20 2017 +0100

    New upstream 1.8.6
---
 AUTHORS.md                                         |  98 ++-
 Brewfile                                           |   3 +-
 CAF_ABI.md                                         |  18 +-
 CMakeLists.txt                                     | 315 ++++++-
 CONTRIBUTING.md                                    |  61 +-
 GETTING_STARTED.md                                 |  21 +-
 INSTALL.md                                         | 301 ++++---
 LICENSE                                            |  46 +-
 README.md                                          |  66 +-
 STATUS.md                                          | 201 -----
 cmake/AddInstallationScriptTest.cmake              |  17 +
 install.sh                                         |  38 +-
 install.sh-usage                                   |   7 +-
 prerequisites/build-functions/build_and_install.sh |  57 +-
 .../build-functions/download_if_necessary.sh       |  80 +-
 .../edit_GCC_download_prereqs_file_if_necessary.sh |  44 +
 prerequisites/build-functions/ftp-url.sh           |  43 -
 prerequisites/build-functions/ftp_url.sh           |  46 ++
 .../build-functions/set_or_print_downloader.sh     |  26 +-
 prerequisites/build-functions/set_or_print_url.sh  |   6 +-
 prerequisites/build.sh                             |   6 +
 prerequisites/build.sh-usage                       |   1 +
 prerequisites/check_version.sh                     |   5 +-
 .../install-functions/build_opencoarrays.sh        |  36 +-
 .../download-all-prerequisites.sh                  |  33 +
 prerequisites/install-functions/find_or_install.sh |   2 +-
 prerequisites/install-functions/report_results.sh  | 108 ++-
 prerequisites/stack.sh                             |  29 +-
 src/CMakeLists.txt                                 |   4 +
 src/extensions/caf-foot                            |   6 +-
 src/extensions/caf-head                            |   2 +-
 src/extensions/cafrun-foot                         |   6 +-
 src/extensions/cafrun-head                         |   2 +-
 src/extensions/opencoarrays.F90                    |  35 +
 src/libcaf.h                                       |  27 +-
 src/make.inc                                       |  68 +-
 src/mpi/CMakeLists.txt                             |  69 +-
 src/mpi/mpi_caf.c                                  | 908 ++++++++++++---------
 src/single/CMakeLists.txt                          |   2 +-
 src/tests/CMakeLists.txt                           |   6 +-
 src/tests/installation/CMakeLists.txt              |   1 +
 src/tests/installation/installation-scripts.sh     | 129 +++
 .../installation/installation-scripts.sh-usage     |   0
 src/tests/installation/test-stack.sh               | 158 ++++
 .../coarray_distributed_transpose.F90              |  12 +-
 src/tests/integration/events/CMakeLists.txt        |   2 +-
 .../events/{async-hello.f90 => async-hello.F90}    |   2 +-
 src/tests/integration/pde_solvers/README.md        |   2 +-
 .../pde_solvers/navier-stokes/CMakeLists.txt       |   3 +-
 .../navier-stokes/coarray-shear_coll.F90           |  12 +-
 src/tests/performance/BurgersMPI/shared.F90        |   4 +
 .../mpi_distributed_transpose.F90                  |  12 +-
 src/tests/regression/CMakeLists.txt                |   1 +
 src/tests/regression/open/issue-172                |   1 +
 src/tests/regression/open/issue-292                |   1 +
 src/tests/regression/reported/CMakeLists.txt       |  18 +
 .../reported/issue-172-wrong-co_reduce-int64.f90   |  65 ++
 .../reported/issue-172-wrong-co_reduce-int8.f90    |  65 ++
 .../reported/issue-172-wrong-co_reduce.f90         |  63 ++
 .../issue-243-source-allocation-no-sync.f90        |  50 ++
 .../reported/issue-292-convert-type-before-put.f90 |  58 ++
 .../reported/issue-293-silent-event-failure.F90    |  46 ++
 src/tests/unit/collectives/CMakeLists.txt          |   6 +
 src/tests/unit/collectives/co_reduce_res_im.f90    |  62 ++
 src/tests/unit/collectives/co_reduce_string.f90    |  80 ++
 src/tests/unit/extensions/CMakeLists.txt           |  10 +-
 src/tests/unit/init_register/CMakeLists.txt        |  24 +-
 src/tests/unit/init_register/async_comp_alloc.f90  | 121 +++
 .../{initialize_mpi.f90 => initialize_mpi.F90}     |  11 +
 .../unit/init_register/register_alloc_comp_1.f90   |  74 ++
 .../unit/init_register/register_alloc_comp_2.f90   |  74 ++
 .../unit/init_register/register_alloc_comp_3.f90   |  75 ++
 ...rename_me_too.f90 => register_alloc_vector.f90} |   0
 ...{register_rename_me.f90 => register_vector.f90} |   0
 src/tests/unit/send-get/CMakeLists.txt             |   3 +
 src/tests/unit/send-get/get_array_test.f90         |  30 +-
 src/tests/unit/send-get/get_with_offset_1d.f90     |   6 +-
 src/tests/unit/send-get/old_get_array_test.f90     |  18 +-
 src/tests/unit/send-get/sameloc.f90                |  49 +-
 src/tests/unit/send-get/send_array_test.f90        |  24 +-
 src/tests/unit/send-get/strided_get.f90            |   6 +-
 src/tests/unit/send-get/strided_sendget.f90        | 109 +++
 src/tests/unit/send-get/whole_get_array.f90        |  15 +-
 src/tests/unit/simple/CMakeLists.txt               |   5 -
 src/tests/unit/simple/syncimages.f90               |  58 --
 src/tests/unit/simple/syncimages2.f90              |  44 -
 src/tests/unit/simple/test1Caf.f90                 |   4 +
 src/tests/unit/simple/testAtomics.f90              |   8 +-
 src/tests/unit/sync/CMakeLists.txt                 |   6 +
 .../sync_image_ring_abort_on_stopped_image.f90     |  33 +
 src/tests/unit/sync/syncimages_status.f90          |   1 -
 windows-install.sh                                 | 301 +++++++
 windows-install.sh-usage                           |  13 +
 93 files changed, 3611 insertions(+), 1213 deletions(-)

diff --git a/AUTHORS.md b/AUTHORS.md
index 34ac3fa..ea1cae6 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -1,22 +1,96 @@
+<a name="top"> </a>
+
+
+[This document is formatted with GitHub-Flavored Markdown.               ]:#
+[For better viewing, including hyperlinks, read it online at             ]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/blob/master/AUTHORS.md]:#
+
 Contributors to OpenCoarrays
 ============================
 
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/AUTHORS.pdf)
+[![CLA assistant][CLA img]](https://cla-assistant.io/sourceryinstitute/OpenCoarrays)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/AUTHORS.pdf)
 
 Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/AUTHORS.pdf).
+[here][pdfloc].
+
+ - [X] Alessandro Fanfarillo  <elfanfa at ucar.edu> @afanfa
+ - [X] Damian Rouson  <damian at sourceryinstitute.org> @rouson
+ - [X] Izaak "Zaak" Beekman  <https://izaakbeekman.com> @zbeekman
+ - [X] Tobias Burnus  <burnus at net-b.de> @tob2
+ - [X] Andre Vehreschild <vehre at gmx.de> @vehre
+ - [X] Craig Rasmussen <rasmus at uoregon.edu> @rasmussn
+ - [X] Jeff Hammond  <jeff.science at gmail.com> @jeffhammond
+ - [ ] Salvatore Filippone <Salvatore.Filippone at cranfield.ac.uk> @sfilippone
+ - [ ] Raul Laasner <raullaasner at gmail.com> @raullaasner
+ - [X] Naveen Ravi <nravi at cray.com> @naveen-rn
+ - [X] Soren Rasmussen <s.c.rasmussen at gmail.com> @scrasmussen
+ - [X] Götz Waschk <goetz.waschk at desy.de> @LaHaine
+ - [ ] John C. Linford <jlinford at paratools.com>
+ - [ ] Daniel Carrera  <dcarrera at gmail.com>
+
+[top]
+
+Linux Foundation Contributor License Agreement (CLA)
+----------------------------------------------------
+
+All contributors are expected to sign the [Linux Foundation Contributor
+License Agreement (CLA), the "Developer Certificate of Origin",
+Version 1.1.](https://gist.github.com/zbeekman/0a5d60a1cbd1f6a8cfa5)
+using the [CLA-Assistant]
+
+```
+Developer Certificate of Origin
+Version 1.1
+
+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
+660 York Street, Suite 102,
+San Francisco, CA 94110 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+
+Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+(a) The contribution was created in whole or in part by me and I
+    have the right to submit it under the open source license
+    indicated in the file; or
+
+(b) The contribution is based upon previous work that, to the best
+    of my knowledge, is covered under an appropriate open source
+    license and I have the right under that license to submit that
+    work with modifications, whether created in whole or in part
+    by me, under the same open source license (unless I am
+    permitted to submit under a different license), as indicated
+    in the file; or
+
+(c) The contribution was provided directly to me by some other
+    person who certified (a), (b) or (c) and I have not modified
+    it.
+
+(d) I understand and agree that this project and the contribution
+    are public and that a record of the contribution (including all
+    personal information I submit with it, including my sign-off) is
+    maintained indefinitely and may be redistributed consistent with
+    this project or the open source license(s) involved.
+```
+
+[top]
 
- - Alessandro Fanfarillo  <fanfarillo at ing.uniroma2.it>
- - Damian Rouson  <damian at rouson.net>
- - Izaak Beekman  <http://izaakbeekman.com>
- - Daniel Carrera  <dcarrera at gmail.com>
- - Jeff Hammond  <jeff.science at gmail.com>
- - Tobias Burnus  <burnus at net-b.de>
+---
 
-[I think we're missing a number of people here]:#
-[@naveen-rn?]:#
-[@raul-nasner?]:#
-[Others:]:#
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
 
 [Links]:#
 [pdf img]: https://img.shields.io/badge/PDF-AUTHORS.md-6C2DC7.svg?style=flat-square "Download as PDF"
+[contributor img]: https://img.shields.io/github/contributors/sourceryinstitute/OpenCoarrays.svg?style=flat-square "Contributors"
+[CLA img]: https://cla-assistant.io/readme/badge/sourceryinstitute/OpenCoarrays "CLA signees"
+[pdfloc]: http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/AUTHORS.pdf "Get this file as a PDF document"
+[CLA-Assistant]: https://cla-assistant.io/sourceryinstitute/OpenCoarrays "CLA-Assistant"
+[top]: #top
diff --git a/Brewfile b/Brewfile
index c3610f4..4a0d1c1 100644
--- a/Brewfile
+++ b/Brewfile
@@ -10,12 +10,11 @@
 # Once Homebrew/Linuxbrew is installed, execute the following commands to install the required prerequisites:
 # `brew tap homebrew/bundle && brew bundle`
 #
-# NOTE: Until Linuxbrew upgrades to GCC 6.1 or later, you will have to edit the `mpich` line to:
-#    `brew 'mpich', args: ['cc=gcc-5', 'cxx=g++-5']`
 
 brew 'cmake'
 brew 'gcc'
 brew 'mpich', args: ['cc=gcc-6', 'cxx=g++-6']
+brew 'opencoarrays'
 
 # [Homebrew]: http://brew.sh
 # [Linuxbrew]: http://linuxbrew.sh
diff --git a/CAF_ABI.md b/CAF_ABI.md
index 342af4d..bd59cea 100644
--- a/CAF_ABI.md
+++ b/CAF_ABI.md
@@ -1,14 +1,14 @@
 [This document is formatted with GitHub-Flavored Markdown.              ]:#
 [For better viewing, including hyperlinks, read it online at            ]:#
-[https://github.com/sourceryinstitute/opencoarrays/blob/master/CAF_API.md]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/blob/master/CAF_API.md]:#
 
 OpenCoarrays Application Binary Interface (ABI)
 ===============================================
 
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/CAF_ABI.pdf)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/CAF_ABI.pdf)
 
 Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/CAF_ABI.pdf).
+[here](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/CAF_ABI.pdf).
 
 * [To Do](#to-do)
 * [Implementation status](#implementation-status)
@@ -24,6 +24,10 @@ standard-conforming Fortran 2008 or 2015 and compile their code with the OpenCoa
 The actual function names in this document have a PREFIX in the source code to avoid
 name clashes.  The prefix can be vendor-specific.
 
+### Warning ###
+
+*This document may be out of date.*
+
 To Do
 -----
 
@@ -560,6 +564,14 @@ __GCC__:
 __TODO__:
    Change `errmsg_len` to `size_t`
 
+---
+
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+
+
 [Hyperlinks]:#
 
 [TS29113]: ftp://ftp.nag.co.uk/sc22wg5/n1901-n1950/n1942.pdf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c293b0..ebd59ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,8 +6,13 @@ set ( CMAKE_BUILD_TYPE "Release"
   CACHE STRING "Select which configuration to build." )
 set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
 
-#Name project and specify source languages
-project(opencoarrays VERSION 1.7.4 LANGUAGES C Fortran)
+# Name project and specify source languages
+# Parse version from .VERSION file so that more info can be added and easier to get from scripts
+file( STRINGS ".VERSION" OpenCoarraysVersion
+  REGEX "[0-9]+\\.[0-9]+\\.[0-9]+"
+)
+project(opencoarrays VERSION "${OpenCoarraysVersion}" LANGUAGES C Fortran)
+message( STATUS "Building OpenCoarrays version: ${OpenCoarraysVersion}" )
 
 #Print an error message on an attempt to build inside the source directory tree:
 if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
@@ -15,7 +20,7 @@ if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
     "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
     " == CMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
     "\nThis archive does not support in-source builds:\n"
-    "You must now delete the CMakeCache.txt file and the CMakeFiles/ directory under"
+    "You must now delete the CMakeCache.txt file and the CMakeFiles/ directory under "
     "the 'src' source directory or you will not be able to configure correctly!"
     "\nYou must now run something like:\n"
     "  $ rm -r CMakeCache.txt CMakeFiles/"
@@ -45,8 +50,48 @@ else()
   )
 endif()
 
-if (NOT (CMAKE_VERSION VERSION_LESS 3.3.1))
-  # Detect Fortran compiler version directly
+#-----------------------------------------------------------------
+# Set CMAKE_Fortran_COMPILER_VERSION if CMake doesn't do it for us
+#-----------------------------------------------------------------
+if (  NOT CMAKE_Fortran_COMPILER_VERSION )
+  if ( NOT (CMAKE_VERSION VERSION_LESS 3.3.1) )
+    message( AUTHOR_WARNING
+     "CMake ${CMAKE_VERSION} should know about Fortran compiler versions but is missing CMAKE_Fortran_COMPILER_VERSION variable."
+    )
+  endif()
+  # No CMAKE_Fortran_COMPILER_VERSION set, build our own
+  # Try extracting it directly from ISO_FORTRAN_ENV's compiler_version
+  # Write program for introspection
+  file( WRITE "${CMAKE_BINARY_DIR}/get_compiler_ver.f90"
+    "program main
+     use iso_fortran_env, only: compiler_version, output_unit
+     write(output_unit,'(a)') compiler_version()
+end program"
+  )
+  try_run( PROG_RAN COMPILE_SUCCESS
+    "${CMAKE_BINARY_DIR}" "${CMAKE_BINARY_DIR}/get_compiler_ver.f90"
+    RUN_OUTPUT_VARIABLE VER_STRING
+  )
+  if ( COMPILE_SUCCESS )
+    string( REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?"
+      DETECTED_VER "${VER_STRING}"
+    )
+    message( STATUS "Detected Fortran compiler as ${VER_STRING}" )
+    message( STATUS "Extracted version number: ${DETECTED_VER}" )
+  endif()
+  if( ( NOT COMPILE_SUCCESS ) OR ( NOT DETECTED_VER ) )
+    message( WARNING "Could not reliably detect Fortran compiler version. We'll infer it from
+the C compiler if it matches the Fortran compiler ID." )
+  endif()
+  if( "${CMAKE_C_COMPILER_ID}" MATCHES "${CMAKE_Fortran_COMPILER_ID}" )
+    set( DETECTED_VER "${CMAKE_C_COMPILER_VERSION}" )
+  else()
+    message( FATAL_ERROR "Exhausted all possible means of detecting the Fortran compiler version, cannot proceed!" )
+  endif()
+  set( CMAKE_Fortran_COMPILER_VERSION "${DETECTED_VER}" )
+endif()
+  
+  # We have populated CMAKE_Fortran_COMPILER_VERSION if it was missing
   if(gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 5.0.0))
     set(opencoarrays_aware_compiler true)
     add_definitions(-DPREFIX_NAME=_gfortran_caf_)
@@ -65,29 +110,12 @@ if (NOT (CMAKE_VERSION VERSION_LESS 3.3.1))
       CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
     set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0")
   endif()
-else()
-  # Use the C compiler version as a proxy for the Fortran compiler version (won't work with NAG)
-  if(gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0.0))
-    set(opencoarrays_aware_compiler true)
-    add_definitions(-DPREFIX_NAME=_gfortran_caf_)
-  else()
-    set(opencoarrays_aware_compiler false)
-    add_definitions(-DPREFIX_NAME=_caf_extensions_)
-  endif()
-  if(gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.4))
-    # GCC patch to fix issue accepted for the 5.4 release
-    # See https://github.com/sourceryinstitute/opencoarrays/issues/28 and
-    # https://groups.google.com/forum/#!msg/opencoarrays/RZOwwYTqG80/46S9eL696dgJ
-    message( STATUS "Disabling optimization flags due to GCC < 5.4 bug")
-    set(CMAKE_Fortran_FLAGS_RELEASE -O0
-      CACHE STRING "Flags used by the compiler during release builds." FORCE)
-    set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -O0"
-      CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
-    set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0")
+  if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0 ) )
+    add_definitions(-DGCC_GE_7) # Tell library to build against GFortran 7.x bindings b/c we might be using clang for C
   endif()
-endif()
 
 if(gfortran_compiler)
+  set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
   set(CMAKE_REQUIRED_FLAGS "-fcoarray=single -ffree-form")
 endif()
 include(CheckFortranSourceCompiles)
@@ -99,9 +127,185 @@ CHECK_Fortran_SOURCE_COMPILES("
   end program
 " Check_Simple_Coarray_Fortran_Source_Compiles)
 if(gfortran_compiler)
-  unset(CMAKE_REQUIRED_FLAGS)
+  set (CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+  unset(OLD_REQUIRED_FLAGS)
+endif()
+
+
+#----------------------------------------------------------------------------
+# Find MPI and set some flags so that FC and CC can point to gfortran and gcc
+#----------------------------------------------------------------------------
+
+# If the user passes FC=mpif90 etc. check and prefer that location
+get_filename_component( FTN_COMPILER_NAME "${CMAKE_Fortran_COMPILER}"
+  NAME )
+get_filename_component( C_COMPILER_NAME "${CMAKE_C_COMPILER}"
+  NAME )
+get_filename_component( FTN_COMPILER_DIR "${CMAKE_Fortran_COMPILER}"
+  REALPATH )
+get_filename_component( C_COMPILER_DIR "${CMAKE_C_COMPILER}"
+  REALPATH )
+
+if (FTN_COMPILER_NAME MATCHES "^[mM][pP][iI]")
+  set (MPI_Fortran_COMPILER "${CMAKE_Fortran_COMPILER}")
+endif()
+if (C_COMPILER_NAME MATCHES "^[mM][pP][iI]")
+  set (MPI_C_COMPILER "${CMAKE_C_COMPILER}")
+endif()
+
+find_package( MPI )
+
+if ( (NOT MPI_C_FOUND) OR (NOT MPI_Fortran_FOUND) )
+  find_program (MY_MPI_EXEC NAMES mpirun mpiexec lamexec srun
+    PATHS "${CMAKE_SOURCE_DIR/prerequisites/installations/mpich/3.1.4}" "${CMAKE_SOURCE_DIR}/prerequisites/installations/mpich/*" ENV PATH
+    HINTS "${FTN_COMPILER_DIR}" "${C_COMPILER_DIR}"
+    PATH_SUFFIXES bin)
+  set ( MPI_HOME "${MPI_HOME}" "${MY_MPI_EXEC}" "${MY_MPI_EXEC}/.." )
+  find_package( MPI REQUIRED )
+endif()
+
+#--------------------------------------------------------
+# Make sure a simple "hello world" C mpi program compiles
+#--------------------------------------------------------
+set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_FLAGS ${MPI_C_COMPILE_FLAGS} ${MPI_C_LINK_FLAGS})
+set(OLD_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
+set(CMAKE_REQUIRED_INCLUDES ${MPI_C_INCLUDE_PATH})
+set(OLD_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+set(CMAKE_REQUIRED_LIBRARIES ${MPI_C_LIBRARIES})
+include (CheckCSourceCompiles)
+CHECK_C_SOURCE_COMPILES("
+#include <mpi.h>
+#include <stdio.h>
+int main(int argc, char** argv) {
+  MPI_Init(NULL, NULL);
+  int world_size;
+  MPI_Comm_size(MPI_COMM_WORLD, &world_size);
+  int world_rank;
+  MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
+  char processor_name[MPI_MAX_PROCESSOR_NAME];
+  int name_len;
+  MPI_Get_processor_name(processor_name, &name_len);
+  printf('Hello world from processor %s, rank %d out of %d processors',
+         processor_name, world_rank, world_size);
+  MPI_Finalize();
+}"
+MPI_C_COMPILES)
+set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_INCLUDES ${OLD_INCLUDES})
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_LIBRARIES})
+unset(OLD_REQUIRED_FLAGS)
+unset(OLD_INCLUDES)
+unset(OLD_LIBRARIES)
+
+if (NOT MPI_C_COMPILES)
+  message(FATAL_ERROR "MPI_C is missing! "
+    "Try setting MPI_C_COMPILER to the appropriate C compiler wrapper script and reconfigure. "
+    "i.e., `cmake -DMPI_C_COMPILER=/path/to/mpicc ..` or set it by editing the cache using "
+    "cmake-gui or ccmake."
+    )
+endif()
+
+#--------------------------------------------------------------
+# Make sure a simple "hello world" Fortran mpi program compiles
+# Try using mpi.mod first then fall back on includ 'mpif.h'
+#--------------------------------------------------------------
+set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_FLAGS "-ffree-form" ${MPI_Fortran_COMPILE_FLAGS} ${MPI_Fortran_LINK_FLAGS})
+set(OLD_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
+set(CMAKE_REQUIRED_INCLUDES ${MPI_Fortran_INCLUDE_PATH})
+set(OLD_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+set(CMAKE_REQUIRED_LIBRARIES ${MPI_Fortran_LIBRARIES})
+include (CheckFortranSourceCompiles)
+CHECK_Fortran_SOURCE_COMPILES("
+program mpi_hello
+use mpi
+implicit none
+integer :: ierr, mpi_world_size, mpi_world_rank, res_len
+character*(MPI_MAX_PROCESSOR_NAME) :: proc
+call mpi_init(ierr)
+call mpi_comm_size(MPI_COMM_WORLD,mpi_world_size,ierr)
+call mpi_comm_rank(MPI_COMM_WORLD,mpi_world_rank,ierr)
+call mpi_get_processor_name(proc,res_len,ierr)
+write(*,*) 'Hello from processor ', trim(proc), ' rank ', mpi_world_rank, ' out of ', mpi_world_size, '.'
+call mpi_finalize(ierr)
+end program
+"
+MPI_Fortran_MODULE_COMPILES)
+set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_INCLUDES ${OLD_INCLUDES})
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_LIBRARIES})
+unset(OLD_REQUIRED_FLAGS)
+unset(OLD_INCLUDES)
+unset(OLD_LIBRARIES)
+
+#--------------------------------
+# If that failed try using mpif.h
+#--------------------------------
+set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_FLAGS "-ffree-form" ${MPI_Fortran_COMPILE_FLAGS} ${MPI_Fortran_LINK_FLAGS})
+set(OLD_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
+set(CMAKE_REQUIRED_INCLUDES ${MPI_Fortran_INCLUDE_PATH})
+set(OLD_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+set(CMAKE_REQUIRED_LIBRARIES ${MPI_Fortran_LIBRARIES})
+include (CheckFortranSourceCompiles)
+CHECK_Fortran_SOURCE_COMPILES("
+program mpi_hello
+implicit none
+include 'mpif.h'
+integer :: ierr, mpi_world_size, mpi_world_rank, res_len
+character*(MPI_MAX_PROCESSOR_NAME) :: proc
+call mpi_init(ierr)
+call mpi_comm_size(MPI_COMM_WORLD,mpi_world_size,ierr)
+call mpi_comm_rank(MPI_COMM_WORLD,mpi_world_rank,ierr)
+call mpi_get_processor_name(proc,res_len,ierr)
+write(*,*) 'Hello from processor ', trim(proc), ' rank ', mpi_world_rank, ' out of ', mpi_world_size, '.'
+call mpi_finalize(ierr)
+end program
+"
+  MPI_Fortran_INCLUDE_COMPILES)
+set(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_INCLUDES ${OLD_INCLUDES})
+set(CMAKE_REQUIRED_LIBRARIES ${OLD_LIBRARIES})
+unset(OLD_REQUIRED_FLAGS)
+unset(OLD_INCLUDES)
+unset(OLD_LIBRARIES)
+
+if ( (NOT MPI_Fortran_MODULE_COMPILES) AND (NOT MPI_Fortran_INCLUDE_COMPILES) )
+  message ( WARNING "It appears that the Fortran MPI compiler is not working. "
+    "For OpenCoarrays Aware compilers, this may be irrelavent: "
+    "  The src/extensions/opencoarrays.F90 module will be disabled, but it is "
+    "  possible that the build will succeed, despite this fishy circumstance."
+    )
+endif()
+
+if ( MPI_Fortran_MODULE_COMPILES )
+  add_definitions(-DMPI_WORKING_MODULE)
+else()
+  message ( WARNING "It appears that MPI was built with a different Fortran compiler. "
+    "It is possible that this may cause unpredictable behavior. The build will continue "
+    "using `mpif.h` BUT please report any suspicious behavior to the OpenCoarrays "
+    "developers."
+    )
 endif()
 
+#----------------
+# Setup MPI flags
+#----------------
+set(CMAKE_C_COMPILE_FLAGS ${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS})
+set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS})
+set(CMAKE_Fortran_COMPILE_FLAGS ${CMAKE_Fortran_COMPILE_FLAGS} ${MPI_Fortran_COMPILE_FLAGS})
+set(CMAKE_Fortran_LINK_FLAGS ${CMAKE_Fortran_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS})
+include_directories(BEFORE ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH})
+
+#---------------------------------------------------
+# Use standardized GNU install directory conventions
+#---------------------------------------------------
+include(GNUInstallDirs)
+
+#-------------------------------
+# Recurse into the src directory
+#-------------------------------
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
 
 add_subdirectory(src)
@@ -113,7 +317,7 @@ install(EXPORT OpenCoarraysTargets
   NAMESPACE
     OpenCoarrays::
   DESTINATION
-    lib/cmake/opencoarrays
+    "${CMAKE_INSTALL_LIBDIR}/cmake/opencoarrays"
 )
 include(CMakePackageConfigHelpers) # standard CMake module
 write_basic_package_version_file(
@@ -129,15 +333,13 @@ install(
     "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/OpenCoarraysConfig.cmake"
     "${CMAKE_CURRENT_BINARY_DIR}/OpenCoarraysConfigVersion.cmake"
   DESTINATION
-    lib/cmake/opencoarrays
+    "${CMAKE_INSTALL_LIBDIR}/cmake/opencoarrays"
 )
 
 add_library(OpenCoarrays INTERFACE)
 target_compile_options(OpenCoarrays INTERFACE -fcoarray=lib)
 target_link_libraries(OpenCoarrays INTERFACE caf_mpi)
 
-install(DIRECTORY  ${CMAKE_BINARY_DIR}/mod DESTINATION .)
-
 #------------------------------------------
 # Add portable unistall command to makefile
 #------------------------------------------
@@ -148,9 +350,12 @@ configure_file ( "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_
 add_custom_target ( uninstall
   COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/uninstall.cmake" )
 
-
 enable_testing()
 
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
+# See JSON-Fortran's CMakeLists.txt file to find out how to get the check target to depend
+# on the test executables
+
 # Determine if we're using Open MPI
 execute_process(COMMAND ${MPIEXEC} --version
   OUTPUT_VARIABLE mpi_version_out)
@@ -167,7 +372,7 @@ function(add_mpi_test name num_mpi_proc path)
      if ( openmpi )
        if ( N LESS 2 )
 	 set( num_mpi_proc 2 )
-	 set (test_parameters --oversubscribed)
+	 set (test_parameters --oversubscribe)
        else()
 	 set ( num_mpi_proc ${N} )
        endif()
@@ -181,40 +386,67 @@ endfunction(add_mpi_test)
 
 set(tests_root ${CMAKE_CURRENT_BINARY_DIR}/src/tests)
 
+
 if(opencoarrays_aware_compiler)
   # Unit tests targeting each libcaf_mpi function, argument, and branch of code
   add_mpi_test(initialize_mpi 2 ${tests_root}/unit/init_register/initialize_mpi)
   add_mpi_test(register 2 ${tests_root}/unit/init_register/register)
-  add_mpi_test(register_rename_me 2 ${tests_root}/unit/init_register/register_rename_me)
-  add_mpi_test(register_rename_me_too 2 ${tests_root}/unit/init_register/register_rename_me_too)
+  add_mpi_test(register_vector 2 ${tests_root}/unit/init_register/register_vector)
+  add_mpi_test(register_alloc_vector 2 ${tests_root}/unit/init_register/register_alloc_vector)
   add_mpi_test(allocate_as_barrier 2 ${tests_root}/unit/init_register/allocate_as_barrier)
   add_mpi_test(allocate_as_barrier_proc 32 ${tests_root}/unit/init_register/allocate_as_barrier_proc)
+  if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7))
+    add_mpi_test(register_alloc_comp_1 2 ${tests_root}/unit/init_register/register_alloc_comp_1)
+    add_mpi_test(register_alloc_comp_2 2 ${tests_root}/unit/init_register/register_alloc_comp_2)
+    add_mpi_test(register_alloc_comp_3 2 ${tests_root}/unit/init_register/register_alloc_comp_3)
+    add_mpi_test(async_comp_alloc 6 ${tests_root}/unit/init_register/async_comp_alloc)
+    # Timeout async_comp_alloc test after 3 seconds to progess past the known failure
+    set_property(TEST async_comp_alloc PROPERTY TIMEOUT_AFTER_MATCH 3 "known failure")
+    set_property(TEST async_comp_alloc PROPERTY TIMEOUT 6) # in the event old CMake is being used
+  endif()
   add_mpi_test(get_array 2 ${tests_root}/unit/send-get/get_array)
+  add_mpi_test(get_self 2 ${tests_root}/unit/send-get/get_self)
   add_mpi_test(send_array 2 ${tests_root}/unit/send-get/send_array)
   add_mpi_test(get_with_offset_1d 2 ${tests_root}/unit/send-get/get_with_offset_1d)
   add_mpi_test(whole_get_array 2 ${tests_root}/unit/send-get/whole_get_array)
   add_mpi_test(strided_get 2 ${tests_root}/unit/send-get/strided_get)
+  add_mpi_test(strided_sendget 3 ${tests_root}/unit/send-get/strided_sendget)
   add_mpi_test(co_sum 4 ${tests_root}/unit/collectives/co_sum_test)
   add_mpi_test(co_broadcast 4 ${tests_root}/unit/collectives/co_broadcast_test)
   add_mpi_test(co_min 4 ${tests_root}/unit/collectives/co_min_test)
   add_mpi_test(co_max 4 ${tests_root}/unit/collectives/co_max_test)
   add_mpi_test(syncall 32 ${tests_root}/unit/sync/syncall)
   add_mpi_test(syncimages 32 ${tests_root}/unit/sync/syncimages)
+  add_mpi_test(syncimages2 32 ${tests_root}/unit/sync/syncimages2)
   add_mpi_test(duplicate_syncimages 8 ${tests_root}/unit/sync/duplicate_syncimages)
   add_mpi_test(co_reduce 4 ${tests_root}/unit/collectives/co_reduce_test)
+  add_mpi_test(co_reduce_res_im 4 ${tests_root}/unit/collectives/co_reduce_res_im)
   add_mpi_test(syncimages_status 32 ${tests_root}/unit/sync/syncimages_status)
+  add_mpi_test(sync_ring_abort_np3 3 ${tests_root}/unit/sync/sync_image_ring_abort_on_stopped_image)
+  add_mpi_test(sync_ring_abort_np7 7 ${tests_root}/unit/sync/sync_image_ring_abort_on_stopped_image)
+  add_mpi_test(simpleatomics 32 ${tests_root}/unit/simple/atomics)
+  # possible logic error in the following test
+#  add_mpi_test(increment_my_neighbor 32 ${tests_root}/unit/simple/increment_my_neighbor)
 
   # Integration tests verifying the use of libcaf_mpi in applications
   add_mpi_test(hello_multiverse 2 ${tests_root}/integration/coarrayHelloWorld/hello_multiverse)
   add_mpi_test(coarray_burgers_pde 2 ${tests_root}/integration/pde_solvers/coarrayBurgers/coarray_burgers_pde)
   add_mpi_test(co_heat 2 ${tests_root}/integration/pde_solvers/coarrayHeatSimplified/co_heat)
-  add_mpi_test(asynchronous_hello_world 2 ${tests_root}/integration/events/asynchronous_hello_world)
-  if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") )
-    if ( NOT (DEFINED ENV{TRAVIS}))
-      add_mpi_test(coarray_navier_stokes 2 ${tests_root}/integration/pde_solvers/navier-stokes/coarray_navier_stokes)
-      set_property(TEST coarray_navier_stokes PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
-    endif()
+  add_mpi_test(asynchronous_hello_world 3 ${tests_root}/integration/events/asynchronous_hello_world)
+
+  # Regression tests based on reported issues
+  if(gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0))
+    # GFortran PR 78505 only fixed on trunk/gcc 7
+    add_mpi_test(source-alloc-no-sync 8 ${tests_root}/regression/reported/source-alloc-sync)
   endif()
+  add_mpi_test(convert-before-put 3 ${tests_root}/regression/reported/convert-before-put)
+  add_mpi_test(event-post 3 ${tests_root}/regression/reported/event-post)
+  add_mpi_test(co_reduce-factorial 4 ${tests_root}/regression/reported/co_reduce-factorial)
+  add_mpi_test(co_reduce-factorial-int8 4 ${tests_root}/regression/reported/co_reduce-factorial-int8)
+  add_mpi_test(co_reduce-factorial-int64 4 ${tests_root}/regression/reported/co_reduce-factorial-int64)
+  add_mpi_test(co_reduce_string 4 ${tests_root}/unit/collectives/co_reduce_string)
+  # remove this before merging into master
+#  set_property(TEST co_reduce-factorial PROPERTY WILL_FAIL TRUE)
 else()
   add_test(co_sum_extension ${tests_root}/unit/extensions/test-co_sum-extension.sh)
   set_property(TEST co_sum_extension PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
@@ -231,3 +463,6 @@ else()
   add_test(co_reduce_extension ${tests_root}/unit/extensions/test-co_reduce-extension.sh)
   set_property(TEST co_reduce_extension PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
 endif()
+
+include(cmake/AddInstallationScriptTest.cmake )
+add_installation_script_test(installation-scripts.sh src/tests/installation/)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6be2668..4153cde 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,10 +3,14 @@
 Contributing to OpenCoarrays
 ============================
 
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/CONTRIBUTING.pdf)
+[![](https://img.shields.io/github/issues-closed-raw/sourceryinstitute/OpenCoarrays.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Issue Stats](https://img.shields.io/issuestats/i/github/sourceryinstitute/OpenCoarrays.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/issues)
+[![](https://img.shields.io/github/issues-pr-closed-raw/sourceryinstitute/OpenCoarrays.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/pulls)
+[![Issue Stats](https://img.shields.io/issuestats/p/github/sourceryinstitute/OpenCoarrays.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/pulls)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/CONTRIBUTING.pdf)
 
 Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/CONTRIBUTING.pdf).
+[here](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/CONTRIBUTING.pdf).
 
 - [Reporting Defects](#reporting-defects)
 - [Requesting Enhancements](#requesting-enhancements)
@@ -33,7 +37,12 @@ If you encounter problems during the course of [Installing] OpenCoarrays or [usi
      - Number of MPI ranks/processing elements/coarray images being run on
      - How the code was compiled, including all flags and commands
      - Minimal reproducer code (a few lines) required to trigger the bug
-  4. Any help you can provide diagnosing, isolating and fixing the problem is appreciated! Please see the [helping out] section for more information.
+ 4. Any help you can provide diagnosing, isolating and fixing the
+    problem is appreciated! Please see the [helping out] section for
+    more information.
+
+An [issue template] is in the `.github` folder to help ensure
+compliance, and adequate information is provided.
 
 Requesting Enhancements
 -----------------------
@@ -66,7 +75,7 @@ Here is a checklist to help you get started contributing to OpenCoarrays and wal
      - [ ] Next line, if necessary is blank
      - [ ] Following lines are all wrapped at 72 characters and can include additional paragraphs, bulleted lists, etc.
      - [ ] Use [Github keywords] where appropriate, to indicate the commit resolves an open issue.
- - [ ] Please do you best to keep a [clean and coherent history]. `git add -p ...`, `git commit --amend` and `git rebase --interactive <root-ref>` can be helpful to rework your commits into a cleaner, clearer state.
+ - [ ] Please do your best to keep a [clean and coherent history]. `git add -p ...`, `git commit --amend` and `git rebase --interactive <root-ref>` can be helpful to rework your commits into a cleaner, clearer state.
  - [ ] Next, [open up a pull request] where the base branch is [`master`] or [`devel`] as appropriate
  - [ ] Please be patient and responsive to requests and comments from SourceryInstitute (SI) team members. You may be asked to amend or otherwise alter commits, or push new commits to your branch.
  - [ ] Make sure that all the automated [Travis-CI tests] pass
@@ -86,29 +95,53 @@ The `master` branch should remain in pristine, stable condition all of the time.
 
 This is the development branch, akin to GCC's `trunk`. Both of `devel` and `master` branches are protected, but `devel` will eventually be merged into `master` when the next major release happens, but until then it is a stable, forward looking branch where experimental features and major changes or enhancements may be applied and tested. Just as with `master` all changes are applied atomically as pull requests.
 
+## Through put ##
+
+[![Waffle.io](https://img.shields.io/waffle/label/sourceryinstitute/OpenCoarrays/blocked.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/labels/blocked)
+[![Waffle.io](https://img.shields.io/waffle/label/sourceryinstitute/OpenCoarrays/ready.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/labels/ready)
+[![Waffle.io](https://img.shields.io/waffle/label/sourceryinstitute/OpenCoarrays/in-progress.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/labels/in-progress)
+[![Waffle.io](https://img.shields.io/waffle/label/sourceryinstitute/OpenCoarrays/needs%20review.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/labels/needs-review)
+
+[![Throughput Graph](https://graphs.waffle.io/sourceryinstitute/OpenCoarrays/throughput.svg)](https://waffle.io/sourceryinstitute/OpenCoarrays/metrics/throughput)
+
+## Coverage ##
+
+[![Codecov branch](https://img.shields.io/codecov/c/github/sourceryinstitute/OpenCoarrays/master.svg?style=flat-square)](https://codecov.io/gh/sourceryinstitute/OpenCoarrays)
+
+[![coverage history](https://codecov.io/gh/sourceryinstitute/OpenCoarrays/branch/master/graphs/commits.svg)](https://codecov.io/gh/sourceryinstitute/OpenCoarrays)
+
+---
+
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+
+
 [Links]: #
+[issue template]: https://github.com/sourceryinstitute/OpenCoarrays/blob/master/.github/ISSUE_TEMPLATE.md
 [video]: https://youtu.be/EwWZbyjDs9c?list=PLg7s6cbtAD17uAwaZwiykDci_q3te3CTY
 [a number of resources]: http://scottchacon.com/2011/08/31/github-flow.html
 [Github flow]: https://guides.github.com/introduction/flow/
-[Travis-CI tests]: https://travis-ci.org/sourceryinstitute/opencoarrays/pull_requests
-[Contributor License Agreement (CLA)]: https://cla-assistant.io/sourceryinstitute/opencoarrays
-[`master`]: https://github.com/sourceryinstitute/opencoarrays
-[`devel`]: https://github.com/sourceryinstitute/opencoarrays/tree/devel
-[open up a pull request]: https://github.com/sourceryinstitute/opencoarrays/compare
+[Travis-CI tests]: https://travis-ci.org/sourceryinstitute/OpenCoarrays/pull_requests
+[Contributor License Agreement (CLA)]: https://cla-assistant.io/sourceryinstitute/OpenCoarrays
+[`master`]: https://github.com/sourceryinstitute/OpenCoarrays
+[`devel`]: https://github.com/sourceryinstitute/OpenCoarrays/tree/devel
+[open up a pull request]: https://github.com/sourceryinstitute/OpenCoarrays/compare
 [clean and coherent history]: https://www.reviewboard.org/docs/codebase/dev/git/clean-commits/
 [Github keywords]: https://help.github.com/articles/closing-issues-via-commit-messages/#closing-an-issue-in-a-different-repository
 [commit message]: https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message
 [these guidelines]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
-[an open issue]: https://github.com/sourceryinstitute/opencoarrays/issues
+[an open issue]: https://github.com/sourceryinstitute/OpenCoarrays/issues
 [Create a branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
-[OpenCoarrays repo]: https://github.com/sourceryinstitute/opencoarrays/fork
+[OpenCoarrays repo]: https://github.com/sourceryinstitute/OpenCoarrays/fork
 [Pull Request]: https://help.github.com/articles/using-pull-requests/
 [Fork]: https://help.github.com/articles/fork-a-repo/
 [helping out]: #helping-out
-[closed issues]: https://github.com/sourceryinstitute/opencoarrays/issues?q=is%3Aissue+is%3Aclosed
+[closed issues]: https://github.com/sourceryinstitute/OpenCoarrays/issues?q=is%3Aissue+is%3Aclosed
 [Installing]: ./INSTALLING.md
-[issues]: https://github.com/sourceryinstitute/opencoarrays/issues
+[issues]: https://github.com/sourceryinstitute/OpenCoarrays/issues
 [mailing list]: https://groups.google.com/forum/#!forum/opencoarrays
 [using OpenCoarrays]: ./GETTING_STARTED.md
-[new issue]: https://github.com/sourceryinstitute/opencoarrays/issues/new
+[new issue]: https://github.com/sourceryinstitute/OpenCoarrays/issues/new
 [pdf img]: https://img.shields.io/badge/PDF-CONTRIBUTING.md-6C2DC7.svg?style=flat-square "Download as PDF"
diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md
index f023edb..1b45ed4 100644
--- a/GETTING_STARTED.md
+++ b/GETTING_STARTED.md
@@ -2,15 +2,15 @@
 
 [This document is formatted with GitHub-Flavored Markdown.                       ]:#
 [For better viewing, including hyperlinks, read it online at                     ]:#
-[https://github.com/sourceryinstitute/opencoarrays/blob/master/GETTING_STARTED.md]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/blob/master/GETTING_STARTED.md]:#
 
 Getting Started
 ===============
 
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/GETTING_STARTED.pdf)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/GETTING_STARTED.pdf)
 
 Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/GETTING_STARTED.pdf).
+[here](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/GETTING_STARTED.pdf).
 
 * [The caf compiler wrapper]
 * [A sample basic workflow]
@@ -59,7 +59,7 @@ the use of an OCA compiler (e.g., gfortran 5.1.0 or later) in a Linux bash shell
 with the `bin` directory of the chosen installation path in the user's PATH
 environment variable:
 
-```
+```fortran
 $ cat tally.f90
       program main
         use iso_c_binding, only : c_int
@@ -106,16 +106,23 @@ name clashes with the compiler's or programs existing capabilities.
 If the `caf` compiler wrapper cannot process the source code in question, invoke
 the underlying communication library directly:
 
-```
+```bash
 mpif90 -fcoarray=lib -L/opt/opencoarrays/ tally.f90 \ -lcaf_mpi -o htally-I<OpenCoarrays-install-path>/mod
 ```
 
 and also run the program with the lower-level communication library:
 
-```
+```bash
 mpirun -np <number-of-images> ./tally
 ```
 
+---
+
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+
 [Hyperlinks]:#
 
 [The caf compiler wrapper]: #the-caf-compiler-wrapper
@@ -123,7 +130,7 @@ mpirun -np <number-of-images> ./tally
 [An advanced workflow]:  #an-advanced-workflow
 
 [Sourcery Store]: http://www.sourceryinstitute.org/store
-[Issues]: https://github.com/sourceryinstitute/opencoarrays/issues
+[Issues]: https://github.com/sourceryinstitute/OpenCoarrays/issues
 [opencoarrays module]: ./src/extensions/opencoarrays.F90
 [GCC]: http://gcc.gnu.org
 [TS 18508]: http://isotc.iso.org/livelink/livelink?func=ll&objId=17181227&objAction=Open
diff --git a/INSTALL.md b/INSTALL.md
index 9010ac5..e9c1112 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -2,116 +2,168 @@
 
 [This document is formatted with GitHub-Flavored Markdown.               ]:#
 [For better viewing, including hyperlinks, read it online at             ]:#
-[https://github.com/sourceryinstitute/opencoarrays/blob/master/INSTALL.md]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL.md]:#
 
 Installing OpenCoarrays
 =======================
 
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/INSTALL.pdf)
+[![GitHub release](https://img.shields.io/github/release/sourceryinstitute/OpenCoarrays.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/releases/latest)
+[![Github All Releases](https://img.shields.io/github/downloads/sourceryinstitute/OpenCoarrays/total.svg?style=flat-square)](https://github.com/sourceryinstitute/OpenCoarrays/releases/latest)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL.pdf)
 
 Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/INSTALL.pdf).
+[here](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/INSTALL.pdf).
 
  *  [End-User Installation]
-     * [Installation Script]
-     * [OS X]
+     * [macOS]
      * [Windows]
      * [Linux]
+     * [Virtual machine]
+     * [Installation Script]
  *  [Advanced Installation from Source]
      *  [Prerequisites]
-     *  [CMake]
+     *  [CMake scripts]
      *  [Make]
- *  [Obtaining GCC]
+ *  [Obtaining GCC, MPICH, and CMake]
 
 End-User Installation
 ---------------------
 
-### Installation Script###
+Most users will find it easiest and fastest to use package management software to install OpenCoarrays.
+Package management options for macOS (formerly known as OS X), Windows, and Linux are described first
+below. Also described below are options for installing via the Sourcery Institute virtual machine or
+the OpenCoarrays installation script.
 
-As of release 1.2.0, users might consider installing by downloading and uncompressing
-a file from our [Releases] page and running the installation script in the top-level
-source directory:
+[top]
 
-```
-tar xvzf opencoarrays-x.y.z.tar.gz
-cd opencoarrays
-./install.sh
-```
+### macOS ###
 
-Before installing OpenCoarrays, the above bash script will attempt to detect the presence
-of the default prequisite packages: [GCC], [MPICH] , and [CMake].  For additional details, see the [Prerequisites] section. If any of the
-aforementioned packages appear to be absent from the user's PATH environment variable,
-the [install.sh] script will attempt to download, build, and install any missing packages
-after asking permission to do so.  The script has been tested on Linux and OS X.  Please
-submit any related problems or questions to our [Issues] page.
+[![homebrew](https://img.shields.io/homebrew/v/opencoarrays.svg?style=flat-square)](http://braumeister.org/formula/opencoarrays)
 
-A complete installation should result in the creation of the following directories
-inside the installation path (.e.g, inside `build` in the above example):
-
-* `bin`: contains the compiler wrapper (`caf`), program launcher (`cafun`), and prerequisites builder (`build`)
-* `mod`: contains the `opencoarrays.mod` module file for use with non-OpenCoarrays-aware compilers
-* `lib`: contains the `libcaf_mpi.a` static library to which codes link for CAF support
+OS X users may use the [Homebrew] or [MacPorts] package management systems to install OpenCoarrays.
+We recommend [Homebrew].
 
-The remainder of this document explains other options that many end users will find
-simplest to obtain OpenCoarrays on OS X, Windows, or Linux without building OpenCoarrays
-from its source code.
+Basic Homebrew installation steps:
+```
+brew update
+brew install opencoarrays
+```
 
-### OS X ###
+OpenCoarrays also ships with a
+[`Brewfile`](https://github.com/sourceryinstitute/OpenCoarrays/blob/master/Brewfile)
+that will make it easier to install opencoarrays using MPICH built
+with GCC. To install using the
+[`Brewfile`](https://github.com/sourceryinstitute/OpenCoarrays/blob/master/Brewfile)
+with MPICH wrapping GCC, follow these steps:
 
-OS X users might find it easiest to install OpenCoarrays using the [MacPorts]
-package management system.  After installing [MacPorts], type the following:
+```
+brew tap homebrew/bundle
+brew update
+brew bundle
+```
 
+MacPorts installation steps:
 ```
 sudo port selfupdate
 sudo port upgrade outdated
 sudo port install opencoarrays
 ```
+where the `sudo` command requires administrator privileges.  If you install using MacPorts, please
+also install the `mpstats` port as follows:
+```
+sudo port install mpstats
+```
+which supports future OpenCoarrays development by providing download data the OpenCoarrays team
+uses in proposals for research grants and development contracts.
 
-where the `sudo` command requires administrator privileges and where the first
-two steps above are required only if the [MacPorts] ports were last updated prior
-to 30 September 2015, when the OpenCoarrays port was incorporated into [MacPorts].
-Repeating the first two steps above will also update OpenCoarrays to the latest
-release.
+[top]
 
-Please also install the `mpstats` port as follows:
+### Windows ###
+
+Windows users may run the windows-install.sh script inside the Windows Subsystem for Linux (WSL).
 
+Requirements:
+* WSL release 14936 or later,
+* Windows Insider Preview, and
+* "Fast" updates option.
+
+Steps:
 ```
-sudo port install mpstats
+ do-release-upgrade
+./windows-install.sh
 ```
+where the first command above updates the default Ubuntu 14.04 to 16.04 and the second command must
+be executed with the present working directory set to the top level of the OpenCoarrays source tree.
 
-which supports future OpenCoarrays development by providing download data the
-OpenCoarrays team can use in proposals for research grants and development
-contracts.
+The `windows-install.sh` installation script uses Ubuntu's `apt-get` package manager to build
+[GCC] 5.4.0, [CMake], and [MPICH].  Windows users who desire a newer version of GCC are welcome to
+submit a request via our [Issues] page and suggest a method for updating.  Previously attempted
+upgrade methods are described in the discussion thread starting with [commit comment 20539810].
 
-### Windows ###
+[top]
+
+### Linux ###
+
+The [Arch Linux] distribution provides an [aur package] for installing OpenCoarrays.  Users of
+other Linux distributions may install the [Virtual machine] or use the [Installation Script].
+Alternatively, if you desire to install using other Linux package Linux package management
+software such as [dnf] or [apt-get], please submit a feature request via our [Issues] page.
 
-Windows users will find it easiest to download the Lubuntu Linux virtual
-machine from the [Sourcery Institute Store].  The virtual machine boots inside
-the open-source [VirtualBox] virtualization package.  In addition to containing
-GCC 4.9, 5.2, and 6.0, MPICH, OpenMPI, and OpenCoarrays, the virtual machine
-contains dozens of other open-source software packages that support software
-development in modern Fortran.  See the [download and installation instructions]
+[top]
+
+## Virtual machine ##
+
+Users of macOS, Windows, or Linux have the option to use OpenCoarrays by installing the Lubuntu
+Linux virtual machine from the [Sourcery Institute Store].  The virtual machine boots inside
+the open-source [VirtualBox] virtualization package.  In addition to containing [GCC], [MPICH],
+and OpenCoarrays, the virtual machine contains dozens of other open-source software packages
+that support modern Fortran software development.  See the [download and installation instructions]
 for a partial list of the included packages.
 
-Alternatively, if you desire to use OpenCoarrays under Cygwin, please submit a
-feature request via our [Issues] page.
+[top]
 
-### Linux ###
+## Installation Script ##
+
+If the above package management or virtualization options are infeasible or unavailable,
+Linux and macOS users may also install OpenCoarrays by downloading and uncompressing our
+[latest release] and running our installation script in the top-level OpenCoarrays source
+directory (see above for the corresponding [Windows] script):
+```
+tar xvzf OpenCoarrays-x.y.z.tar.gz
+cd OpenCoarrays-x.y.z
+./install.sh
+```
+where `x.y.z` should be replaced with the appropriate version numbers.  For a scripted or unattended build, use
+`./install.sh -y` or equivalently `./install.sh --yes-to-all`, which will assume affirmative answers
+to all user prompts and will only prompt the user if an installation directory is chosen that requires
+`sudo` privelenges (by passing `-i` or equivalently `--install-prefix`).
+
+Before installing OpenCoarrays, the above bash script will attempt to detect the presence of the
+default prerequisite packages: [GCC], [MPICH] , and [CMake].  For additional details, see the
+[Prerequisites] section. If any of the installation script cannot find the prerequisite packages,
+the [install.sh] script will attempt to download, build, and install any missing packages
+after asking permission to do so.  The script has been tested on Linux and OS X.  Please
+submit any related problems or questions to our [Issues] page.
 
-The [Arch Linux] distribution provides an [aur package] for installing OpenCoarrays.
-Users of other Linux distributions who prefer not to build OpenCoarrays from source might
-access OpenCoarrays via the the Lubuntu Linux virtual machine from the
-[Sourcery Institute Store] after installing the version of [VirtualBox] that is suitable
-for the relevant Linux distribution.  Alternatively, if you desire to install using other
-Linux package management software such as [yum] or [apt-get], please submit a feature
-request via our [Issues] page.
+A complete installation should result in the creation of the following directories
+inside the installation path (.e.g, inside `build` in the above example):
+
+* `bin`: contains the compiler wrapper (`caf`) and program launcher (`cafun`).
+* `mod`: contains the `opencoarrays.mod` module file for use with non-OpenCoarrays-aware compilers
+* `lib`: contains the `libcaf_mpi.a` static library to which codes link for CAF support
+
+[top]
 
 Advanced Installation from Source
---------------------
+---------------------------------
 
 ### Prerequisites: ###
 
-The prerequisites below and their dependencies are recommended for the broadest coverage of CAF features. If a prerequisite is missing or outdated, the [install.sh] script will prompt the user for permission to download, compile, and install it. Before doing so, [install.sh] will verify whether that prerequisite's prerequisites are present and will recursively traverse the dependency tree until reaching an acceptable prerequisite or reaching the end of a branch.
+The prerequisites below and their dependencies are recommended for the broadest coverage of CAF features.
+If a prerequisite is missing or outdated, the [install.sh] script will prompt the user for permission to
+download, compile, and install it. Before doing so, [install.sh] will verify whether that prerequisite's
+prerequisites are present and will recursively traverse the dependency tree until reaching an acceptable
+prerequisite or reaching the end of a branch.
 
 ```
 opencoarrays
@@ -128,10 +180,23 @@ opencoarrays
 
 If using the advanced [CMake] or [Make] builds detailed below, please ensure that these dependencies are met before attempting to build and install OpenCoarrays.
 
-### CMake ###
+[top]
+
+### CMake scripts ###
+
+#### N.B.: ####
+
+__As of OpenCoarrays 1.7.6, passing `FC=mpi_fortran_wrapper` and
+`CC=mpi_c_wrapper` is *DEPRECATED*. Please pass `FC=/path/to/gfortran`
+and `CC=/path/to/gcc`. If you are experimenting with the source to
+source translation capabilities, then please point `FC` and `CC` to
+your Fortran and C compilers of choice. In the case of Cray, or a
+compiler in which MPI is *built-in* to the compiler, you still pass
+the `FC` and `CC` as the Fortran and C compiler, even though MPI is
+built-in.__
 
 [CMake] is the preferred build system.   CMake is a cross-platform Makefile generator that
-includes with the testing tool CTest.  To avoid cluttering or clobbering the source tree,
+includes the testing tool CTest.  To avoid cluttering or clobbering the source tree,
 our CMake setup requires that your build directory be any directory other than the top-level
 OpenCoarrays source directory.  In a bash shell, the following steps should build
 OpenCoarrays, install OpenCoarrays, build the tests, run the tests, and report the test results:
@@ -141,29 +206,43 @@ tar xvzf opencoarrays.tar.gz
 cd opencoarrays
 mkdir opencoarrays-build
 cd opencoarrays-build
-CC=mpicc FC=mpif90 cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}
+CC=gcc FC=gfortran cmake .. -DCMAKE_INSTALL_PREFIX=${HOME}/packages/
 make
 ctest
 make install
 ```
 
 where the the first part of the cmake line sets the CC and FC environment variables
-and the final part of the same line defines the installation path as the present
-working directory (`opencoarrays-build`).  Please report any test failures via the
-OpenCoarrays [Issues] page.
+and the final part of the same line defines the installation path as
+the `packages` directory in the current user's `$HOME` directory.  Please report any test failures via the
+OpenCoarrays [Issues] page. Please note that you need a recent
+GCC/GFortran, and a recent MPI-3 implementation. If CMake is having
+trouble finding the MPI implementation, or is finding the wrong MPI
+implementation, you can try setting the `MPI_HOME` environment
+variable to point to the installation you wish to use. If that fails,
+you can also try passing the
+`-DMPI_Fortran_COMPILER=/path/to/mpi/fortran/wrapper/script` and
+`-DMP_C_COMPILER=/path/to/mpi/c/wrapper/script` options to CMake.
 
 Advanced options (most users should not use these):
 
-    -DLEGACY_ARCHITECTURE=OFF enables the use of FFT libraries that employ AVX instructions
-    -DHIGH_RESOLUTION_TIMER=ON enables timers that tick once per clock cycle
-    -DCOMPILER_SUPPORTS_ATOMICS enables support for the proposed Fortran 2015 events feature
-    -DUSE_EXTENSIONS builds the [opencoarrays] module for use with non-OpenCoarrays-aware compilers
-    -DCOMPILER_PROVIDES_MPI is set automatically when building with the Cray Compiler Environment
+    -DMPI_HOME=/path/to/mpi/dir  # try to force CMake to find your preferred MPI implementation
+        # OR
+    -DMPI_C_COMPILER=/path/to/c/wrapper
+    -DMPI_Fortran_COMPILER=/path/to/fortran/wrapper
 
-The first two flags above are not portable and the third enables code that is incomplete as
-of release 1.0.0.  The fourth is set automatically by the CMake scripts based on the compiler
+    -DLEGACY_ARCHITECTURE=OFF    # enables the use of FFT libraries that employ AVX instructions
+    -DHIGH_RESOLUTION_TIMER=ON   # enables timers that tick once per clock cycle
+    -DCOMPILER_SUPPORTS_ATOMICS  # enables support for the proposed Fortran 2015 events feature
+    -DUSE_EXTENSIONS             # builds the opencoarrays module for use with non-OpenCoarrays-aware compilers
+    -DCOMPILER_PROVIDES_MPI      # is set automatically when building with the Cray Compiler Environment
+
+The fourth and fifth flags above are not portable and the sixth enables code that is incomplete as
+of release 1.0.0.  The eighth is set automatically by the CMake scripts based on the compiler
 identity and version.
 
+[top]
+
 ### Make ###
 
 Unlike the Makefiles that CMake generates automatically for the chosen platform, static
@@ -190,52 +269,77 @@ system settings.  For example, you might need to remove the `-Werror` option fro
 compiler flags or name a different compiler.  In order to activate efficient strided-array
 transfer support, uncomment the `-DSTRIDED` flag inside the [make.inc] file.
 
+[top]
+
 Obtaining GCC, MPICH, and CMake
 -------------------------------
 
-[GFortran Binaries] 5 binary builds are available at <https://gcc.gnu.org/wiki/GFortranBinaries>.  Also,
-the Lubuntu Linux virtual machine available for download in the [Sourcery Store] includes
-builds of GCC 4.9, 5.2, and 6.0.
+[GFortran Binaries] binary builds are available at <https://gcc.gnu.org/wiki/GFortranBinaries>.
 
 To build all prerequisites from source, including the current development branch of GCC,
 you might first try the running the provided [install.sh] script as described above in
-the [Installation Script] section.  Or try building each prerequisite from source as
-follows:
+the [Installation Script] section or try building each prerequisite from source inside
+a bash shell as follows:
 
 ```
-cd prerequisites
-CC=gcc FC=gfortran CXX=g++ ./build flex
-./build gcc
-CC=gcc FC=gfortran CXX=g++ ./build mpich
-./build cmake
+export gcc_install_path=/desired/installation/destination
+./install.sh --package gcc --install-prefix "${gcc_install_path}"
+./install.sh --package mpich \
+   --with-fortran "${gcc_install_path}"/bin/gfortran \
+   --with-c       "${gcc_install_path}"/bin/gcc      \
+   --with-cxx     "${gcc_install_path}"/bin/g++
+./install.sh --pacakge cmake \
+   --with-fortran "${gcc_install_path}"/bin/gfortran \
+   --with-c       "${gcc_install_path}"/bin/gcc      \
+   --with-cxx     "${gcc_install_path}"/bin/g++
 ```
 
-where the second line builds the flex package that is required for building gcc from source.
+[top]
+
+---
+
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+
 
-[Links]: #
+[Internal document links]: #
 
+[top]: #top
 [End-User Installation]: #end-user-installation
-[Installation Script]: #installation-script
-[install.sh]: ./install.sh
-[OS X]: #os-x
-[ticket]: https://trac.macports.org/ticket/47806
+[macOS]: #macos
 [Windows]: #windows
 [Linux]: #linux
+[Virtual machine]: #virtual-machine
+[Installation Script]: #installation-script
+
 [Advanced Installation from Source]: #advanced-installation-from-source
 [Prerequisites]: #prerequisites
-[CMake]: #cmake
+[CMake scripts]: #cmake-scripts
 [Make]: #make
-[Obtaining GCC]: #obtaining-gcc
+
+[Obtaining GCC, MPICH, and CMake]: #obtaining-gcc-mpich-and-cmake
+
+
+[Links to source]: #
+
+[install.sh]: ./install.sh
+
+
+[URLs]: #
+
+[CMake]: http://www.cmake.org
 [Sourcery Store]: http://www.sourceryinstitute.org/store
 [Sourcery Institute Store]: http://www.sourceryinstitute.org/store
 [VirtualBox]: http://www.virtualbox.org
 [download and installation instructions]: http://www.sourceryinstitute.org/uploads/4/9/9/6/49967347/overview.pdf
 [yum]: http://yum.baseurl.org
 [apt-get]: https://en.wikipedia.org/wiki/Advanced_Packaging_Tool
-[Issues]: https://github.com/sourceryinstitute/opencoarrays/issues
+[Issues]: https://github.com/sourceryinstitute/OpenCoarrays/issues
 [make.inc]: ./src/make.inc
 [opencoarrays]: ./src/extensions/opencoarrays.F90
-[prerequisites]: ./prerequisites
+[prerequisites]: #prerequisites
 [MPICH]: http://www.mpich.org
 [MVAPICH]:http://mvapich.cse.ohio-state.edu
 [MacPorts]: http://www.macports.org
@@ -245,5 +349,8 @@ where the second line builds the flex package that is required for building gcc
 [Installing GCC]: https://gcc.gnu.org/install/
 [Arch Linux]: https://www.archlinux.org
 [aur package]: https://aur.archlinux.org/packages/opencoarrays/
-[Releases]: https://github.com/sourceryinstitute/opencoarrays/releases
+[latest release]: https://github.com/sourceryinstitute/OpenCoarrays/releases/latest
 [pdf img]: https://img.shields.io/badge/PDF-INSTALL.md-6C2DC7.svg?style=flat-square "Download as PDF"
+[commit comment 20539810]: https://github.com/sourceryinstitute/OpenCoarrays/commit/26e99919fe732576f7277a0e1b83f43cc7c9d749#commitcomment-20539810
+[Homebrew]: http://brew.sh
+[dnf]: https://github.com/rpm-software-management/dnf
diff --git a/LICENSE b/LICENSE
index fc4bd0d..294d719 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,35 +1,29 @@
-OpenCoarrays
+BSD 3-Clause License
 
--- A Coarray Fortran application binary interface, application programmer
-    interface, and compiler wrapper.
-
-Copyright (c) 2015-2016, Sourcery Institute
-Copyright (c) 2015-2016, Sourcery, Inc.
+Copyright (c) 2016, Sourcery Institute
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
+modification, are permitted provided that the following conditions are met:
 
-1. Redistributions of source code must retain the above copyright
-notice, this list of conditions and the following disclaimer.
+* Redistributions of source code must retain the above copyright notice, this
+  list of conditions and the following disclaimer.
 
-2. Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
 
-3. Neither the name of the copyright holder nor the names of its
-contributors may be used to endorse or promote products derived from
-this software without specific prior written permission.
+* Neither the name of the copyright holder nor the names of its
+  contributors may be used to endorse or promote products derived from
+  this software without specific prior written permission.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
index 2501743..fde9213 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,22 @@
 
 [This document is formatted with GitHub-Flavored Markdown.              ]:#
 [For better viewing, including hyperlinks, read it online at            ]:#
-[https://github.com/sourceryinstitute/opencoarrays/blob/master/README.md]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/blob/master/README.md]:#
+
+
+[![Sourcery Institute][sourcery-institute logo]](https://www.sourceryinstitute.org)
 
 OpenCoarrays
 ============
 
-[![CI Build Status][build img]](https://travis-ci.org/sourceryinstitute/opencoarrays)
+[![CI Build Status][build img]](https://travis-ci.org/sourceryinstitute/OpenCoarrays)
+[![Gitter](https://img.shields.io/gitter/room/sourceryinstitute/opencoarrays.svg?style=flat-square)](https://gitter.im/sourceryinstitute/opencoarrays)
 [![GitHub license][license img]](./LICENSE)
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/README.pdf)
-<!-- [![GitHub release][release img]](https://github.com/sourceryinstitute/opencoarrays/releases/latest) -->
-<!-- [![Release Downloads][download img]](https://github.com/sourceryinstitute/opencoarrays/releases) -->
-
-Download this file as a PDF document [here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/README.pdf).
+[![GitHub release][release img]](https://github.com/sourceryinstitute/OpenCoarrays/releases/latest)
+[![homebrew](https://img.shields.io/homebrew/v/opencoarrays.svg?style=flat-square)](http://braumeister.org/formula/opencoarrays)
+[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/OpenCoarrays/blob/master/README.pdf)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+<!-- [![Release Downloads][download img]](https://github.com/sourceryinstitute/OpenCoarrays/releases) -->
 
 * [Overview](#overview)
 * [Downloads](#downloads)
@@ -25,6 +29,7 @@ Download this file as a PDF document [here](http://md2pdf.herokuapp.com/sourcery
 * [Status](#status)
 * [Support](#support)
 * [Acknowledgements](#acknowledgements)
+* [Donate](#donate)
 
 Overview
 --------
@@ -38,7 +43,7 @@ OpenCoarrays enables CAF application developers to express parallel algorithms w
 
 Downloads
 ---------
-<!--[![Release Downloads][download img]](https://github.com/sourceryinstitute/opencoarrays/releases/latest)-->
+<!--[![Release Downloads][download img]](https://github.com/sourceryinstitute/OpenCoarrays/releases/latest)-->
 
 Please see our [Releases] page.
 
@@ -70,7 +75,8 @@ Please see the [CONTRIBUTING.md] file.
 Status
 ------
 
-Please see the [STATUS.md] file.
+A list of open issues can be viewed on the
+[issues page](https://github.com/sourcery institute/opencoarrays/issues).
 
 Support
 -------
@@ -88,6 +94,21 @@ We gratefully acknowledge support from the following institutions:
 * The National Energy Research Scientific Computing Center ([NERSC]), which is supported by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC02-05CH11231, for access to the Hopper and Edison supercomputers under the OpenCoarrays project start allocation.
 * [Sourcery, Inc.], for financial support for the domain registration, web hosting, advanced development, and conference travel.
 
+Donate
+------
+If you find this software useful, please consider donating
+[your time](CONTRIBUTING.md) or
+[your money](http://www.sourceryinstitute.org/store/p5/Donation.html)
+to aid in development efforts.
+
+---
+
+[![GitHub forks](https://img.shields.io/github/forks/sourceryinstitute/OpenCoarrays.svg?style=social&label=Fork)](https://github.com/sourceryinstitute/OpenCoarrays/fork)
+[![GitHub stars](https://img.shields.io/github/stars/sourceryinstitute/OpenCoarrays.svg?style=social&label=Star)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![GitHub watchers](https://img.shields.io/github/watchers/sourceryinstitute/OpenCoarrays.svg?style=social&label=Watch)](https://github.com/sourceryinstitute/OpenCoarrays)
+[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?hashtags=HPC,Fortran,PGAS&related=zbeekman,gnutools,HPCwire,HPC_Guru,hpcprogrammer,SciNetHPC,DegenerateConic,jeffdotscience,travisci&text=Stop%20programming%20w%2F%20the%20%23MPI%20docs%20in%20your%20lap%2C%20try%20Coarray%20Fortran%20w%2F%20OpenCoarrays%20%26%20GFortran!&url=https%3A//github.com/sourceryinstitute/OpenCoarrays)
+
+
 [Hyperlinks]:#
 
 [Overview]: #overview
@@ -98,7 +119,7 @@ We gratefully acknowledge support from the following institutions:
 [Contributing]: #contributing
 [Acknowledgements]: #acknowledgements
 
-
+[sourcery-institute logo]: http://www.sourceryinstitute.org/uploads/4/9/9/6/49967347/sourcery-logo-rgb-hi-rez-1.png
 [OpenCoarrays]: http://www.opencoarrays.org
 [ABI]: https://gcc.gnu.org/onlinedocs/gfortran/Coarray-Programming.html#Coarray-Programming
 [TS 18508]: http://isotc.iso.org/livelink/livelink?func=ll&objId=16769292&objAction=Open
@@ -107,7 +128,7 @@ We gratefully acknowledge support from the following institutions:
 [gfortran]: https://gcc.gnu.org/wiki/GFortran
 [opencoarrays module]: ./src/extensions/opencoarrays.F90
 [MPICH]: http://www.mpich.org
-[MVAPICH]: http://mvapich.cse.ohio-state.edu/)
+[MVAPICH]: http://mvapich.cse.ohio-state.edu
 [OpenMPI]: http://www.open-mpi.org
 [Sourcery, Inc.]: http://www.sourceryinstitute.org
 [Google]: http://google.com
@@ -117,20 +138,23 @@ We gratefully acknowledge support from the following institutions:
 [INSTALL.md]: ./INSTALL.md
 [GASNet]: http://gasnet.lbl.gov
 [CONTRIBUTING.md]: ./CONTRIBUTING.md
-[STATUS.md]: ./STATUS.md
 [GETTING_STARTED.md]: ./GETTING_STARTED.md
 [Google Groups]: https://groups.google.com
 [Google Group]: https://groups.google.com/forum/#!forum/opencoarrays
 [subscribing]: https://groups.google.com/forum/#!forum/opencoarrays/join
 [opencoarrays at googlegroups.com]: mailto:opencoarrays at googlegroups.com
-[Google Summer of Code]: https://www.google-melange.com/gsoc/org2/google/gsoc2014/gcc
+[Google Summer of Code]: https://www.google-melange.com/archive/gsoc/2014/orgs/gcc/projects/afanfa.html
+
+[try this GSoC link? https://www.google-melange.com/archive/gsoc/2014/orgs/gcc]:#
+[old GSoC link: https://www.google-melange.com/gsoc/org2/google/gsoc2014/gcc]:#
+
 [OpenCoarrays Google Group]: https://groups.google.com/forum/#!forum/opencoarrays)
-[Issues]: https://github.com/sourceryinstitute/opencoarrays/issues
-[Releases]: https://github.com/sourceryinstitute/opencoarrays/releases
-
-[build img]: https://img.shields.io/travis-ci/sourceryinstitute/opencoarrays/master.svg?style=flat-square "View Travis-CI builds"
-[CI Master Branch]: https://travis-ci.org/sourceryinstitute/opencoarrays?branch=master "View Travis-CI builds"
-[download img]: https://img.shields.io/github/downloads/sourceryinstitute/opencoarrays/total.svg?style=flat-square "Download count image source"
-[license img]: https://img.shields.io/badge/License-BSD--3-blue.svg?style=flat-square "View BSD-3 License"
-[release img]: https://img.shields.io/github/release/sourceryinstitute/opencoarrays.svg?style=flat-square "View latest release"
+[Issues]: https://github.com/sourceryinstitute/OpenCoarrays/issues
+[Releases]: https://github.com/sourceryinstitute/OpenCoarrays/releases
+
+[build img]: https://img.shields.io/travis-ci/sourceryinstitute/OpenCoarrays/master.svg?style=flat-square "View Travis-CI builds"
+[CI Master Branch]: https://travis-ci.org/sourceryinstitute/OpenCoarrays?branch=master "View Travis-CI builds"
+[download img]: https://img.shields.io/github/downloads/sourceryinstitute/OpenCoarrays/total.svg?style=flat-square "Download count image source"
+[license img]: https://img.shields.io/badge/license-BSD--3-blue.svg?style=flat-square "View BSD-3 License"
+[release img]: https://img.shields.io/github/release/sourceryinstitute/OpenCoarrays.svg?style=flat-square "View latest release"
 [pdf img]: https://img.shields.io/badge/PDF-README.md-6C2DC7.svg?style=flat-square "Download as PDF"
diff --git a/STATUS.md b/STATUS.md
deleted file mode 100644
index 0946993..0000000
--- a/STATUS.md
+++ /dev/null
@@ -1,201 +0,0 @@
-<a name="top"> </a>
-
-[This document is formatted with GitHub-Flavored Markdown.              ]:#
-[For better viewing, including hyperlinks, read it online at            ]:#
-[https://github.com/sourceryinstitute/opencoarrays/blob/master/STATUS.md]:#
-
-OpenCoarrays Status
-===================
-
-[![Download as PDF][pdf img]](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/STATUS.pdf)
-
-Download this file as a PDF document
-[here](http://md2pdf.herokuapp.com/sourceryinstitute/opencoarrays/blob/master/STATUS.pdf).
-
- *  [Feature Coverage](#feature-coverage)
- *  [Compiler Status](#compiler-status)
-     * [OpenCoarrays-Aware (OCA) Coarray Fortran (CAF) Compilers]
-     * [Non-OCA CAF Compilers]
-     * [Non-CAF Compilers]
- *  [Library Status](#libary-status)
-     *  [libcaf_mpi]
-     *  [libcaf_x]
-     *  [libcaf_gasnet]
-     *  [libcaf_single]
- *  [Known Issues](#known-issues)
-     * [Library Issues](#library-issues)
-     * [Compiler Issues](#compiler-issues)
-         * [GNU (gfortran)]
-         * [Cray (ftn)]
-         * [Intel (ifort)]
-         * [Numerical Algorithms Group (nagfor)]
-         * [Portland Group (pgfortran)]
-         * [IBM (xlf)]
- *  [To-Do List](#to-do-list)
-
-Feature Coverage
-----------------
-
- * Except as noted under [Known Issues], [libcaf_mpi] supports the following features as described
-   in the Fortran 2008 standard:
-     * allocatable and non-allocatable coarrays of intrinsic or derived type
-     * synchronization statements
-     * atomics
-     * locks
-     * critical
- * Except as noted under [Known Issues], [libcaf_mpi] supports the collective
-   subroutines proposed for Fortran 2015 in the draft Technical Specification
-   [TS 18508] _Additional Parallel Features in Fortra_ subroutines for a limited
-   set of intrinsic types and kinds.  Adding additional types and kinds is
-   straightforward.  Please submit a request via the [Issues] page or consider
-   adding the requisite code by [forking the OpenCoarrays repository] and submitting
-   [pull request via GitHub]. Also see [CONTRIBUTING.md] for more information.
-
-Compiler Status
----------------
-
-The OpenCoarrays CMake build and test scripts detect the compiler identity, version, and operating system (OS).  The scripts use this information to build and test the approproiate functionality for the compiler and OS. Each current compilers' status falls into one of three categories:
-
-<a name="oca-caf-compilers">
- * **OpenCoarrays-Aware (OCA) Coarray Fortran (CAF) Compilers**</a>
-     * _Definition:_ The compiler translates CAF statements into OpenCoarrays application binary interface ([ABI]) calls.
-     * _Example_: GNU Fortran 5.1 or later (see <https://gcc.gnu.org/wiki/Coarray> for the compiler's CAF status..)
-     * _Use case_: compile most Fortran 2008 coarray programs and some programs that use proposed Fortran 2015 features.
-<a name="non-oca-caf-compilers">
- * **Non-OCA CAF Compilers**</a>
-     * _Definition:_ The compiler supports CAF but does not generate calls to the OpenCoarrays [ABI].
-     * _Examples_: Cray compiler (except on CS Series clusters), Intel compiler (except on OS X).
-     * _Use case_: extend the compiler's native CAF using the [opencoarrays module] types and procedures.
-<a name="non-caf-compilers">
- * **Non-CAF Compilers**</a>
-     * _Definition_: The compiler provides no direct support for CAF, but the user can access a subset of CAF features via use association with the [opencoarrays module], e.g., `use opencoarrays, only : co_sum`.
-     * _Examples_: GNU Fortran 4.9 or any compiler not mentioned above.
-     * _Use case_: Use the OpenCoarrays `caf` compiler wrapper to compile those CAF  programs for which the proposed Fortran 2015 collective subroutines cover all of the application's communication requirements.
-
-We have encountered several research applications that match the latter use case.  If you encounter difficulties, please submit a bug report or feature request via the [Issues] page. Also submit a feature request to the relevant compiler technical support.
-
-The OpenCoarrays team offers contract development and support for making compilers OpenCoarrays-aware.  If this is of interest, please inform the compiler's technical support as well as the OpenCoarrays team.   To contribute code, including documentation and tests, see the [CONTRIBUTING.md] file.  To contribute funding, including funding in support of feature reqeusts, see the [Sourcery Store].
-
-Library Status
---------------
-
-<a name="libcaf-mpi">
-* **libcaf_mpi**</a> (Default CMake build): Production transport layer that uses
-  the Message Passing Interface ([MPI]) 3.0 one-sided communication, which
-  exploits a hardware platform's native support for Remote Direct Memory
-  Access (RDMA) if available.
-<a name="libcaf-x">
-* **libcaf_x**</a> (where x = [CUDA], [OpenMP], [Pthreads], [OpenSHMEM], etc.): the
-  OpenCoarrays [ABI] design facilitates implementation atop any one of several
-  low-level parallel programming models, vectorization APIs, or combination
-  thereof. We have performed limited evaluations and research development of
-  versions based on multiple APIs.  Please email the [OpenCoarrays Google Group]
-  for support with targeting other APIs and hardware, including, for example,
-  graphics processing units (GPUs) and heterogeneous CPU/GPU platforms.
-<a name="libcaf-gasnet">
-* **libcaf_gasnet**</a> (Advanced Make build): Experimental transport layer that
-  is currently out-of-date but might exhibit higher performance than [MPI] on
-  platforms for which [GASNet] provides a tuned conduit.  Contact the
-  [OpenCoarrays Google Group] for further information.
-<a name="libcaf-single">
-* **libcaf_single**</a> (Unsupported): developed to mirror the like-named library that
-  is included in GNU Fortran to facilitate compiling single-image (sequential)
-  executables from CAF programs in the absence of a parallel communication library.
-
-Known Issues
-------------
-
-### Library Issues ###
-
-* The [opencoarrays module] and `caf` compiler wrapper do not support the square-bracket
-  syntax required for point-to-point communication.  This limitation only impacts
-  [non-CAF compilers]. For a list of other limitations with non-CAF compilers, execute
-  the `caf` bash script with no arguments.  The `caf` script is installed in the `bin`
-  subdirectory of the installation path.
-* Efficient strided array transfer works only for intrinsic types.
-* Efficient strided array transfer is not supported for remote-to-remote transfers.
-* Overwriting a coarray with itself is not managed efficiently for strided transfers.
-* Communication
-     * Vector subscripts are not yet supported
-     * For character assignments, some issues with padding and character kind conversions exist.
-     * For array assignments, some issues with numeric type conversion exist.
-
-
-### Compiler Issues ###
-
-<a name="compiler-issues-gnu">
-* **GNU** (gfortran)</a>
-     * Derived-type coarrays with allocatable/pointer components are not yet handled
-       properly.
-     * Problems exist with combining array access to a corray with a scalar component
-        access as in `coarray(:,:)[i]%comp`.
-     * An internal compiler error (ICE) occurs with non-allocatable, polymorphic coarrays
-       in `associate` or `select type` statements.
-     * `co_reduce` requires GCC 5.4.0 or later.
-     * `co_reduce` only supports arguments of intrinsic type.
-     * Proper execution of `stop` when `this_image()>1` requires GCC 5.4.0 or later.
-     * No support for type finalization or allocatable components of derived-type coarrays
-       passed to the collective subroutines (e.g., `co_sum`, `co_reduce`, etc.).
-     * Optimization levels other than `-O0` require GCC 5.3.0 or later. 
-     * Using `stop` to halt an individual image without halting all images requires GCC 5.4.0 or later. 
-<a name="compiler-issues-intel">
-* **Intel** (ifort)</a>
-     * Supported via the [opencoarrays module]  only.
-<a name="compiler-issues-cray">
-* **Cray** (ftn) </a>
-     * Supported via the [opencoarrays module] only.
-<a name="compiler-issues-nag">
-* **Numerical Algorithms Group** (nagfor)</a>
-     * Supported via the [opencoarrays module] only.
-<a name="compiler-issues-pg">
-* **Portland Group** (pgfortran)</a>
-     * Supported via the [opencoarrays module] only.
-<a name="compiler-issues-ibm">
-* **IBM** (xlf)</a>
-     * Supported via the [opencoarrays module] only.
-
-To-Do List
-----------
-
-* [ ] Additional tests and documentation.
-* [ ] Improvement of error handling and diagnostics, including but not
-      limited to filling the `ERRMSG=` variable in case of errors.
-* [ ] Providing a diagnostic mode with run-time consistency checks.
-* [ ] Better integration with the test cases of GCC.  For more information,
-      see the GCC source code files in `gcc/testsuite/gfortran.dg/`,
-      in particular, the `dg-do run` tests in `coarray*f90` and `coarray/`).
-
-
-[Hyperlinks]:#
-   [OpenMP]: http://openmp.org
-   [CUDA]: http://www.nvidia.com/object/cuda_home_new.html
-   [Pthreads]: https://computing.llnl.gov/tutorials/pthreads/
-   [MPI]: http://www.mpi-forum.org
-   [OpenSHMEM]: http://openshmem.org
-   [GASNet]: https://gasnet.lbl.gov
-   [CONTRIBUTING.md]: ./CONTRIBUTING.md
-   [OpenCoarrays-Aware (OCA) Coarray Fortran (CAF) Compilers]: #oca-caf-compilers
-   [Known Issues]: #known-issues
-   [Non-OCA CAF Compilers]: #non-oca-caf-compilers
-   [Non-CAF Compilers]: #non-caf-compilers
-   [libcaf_mpi]: #libcaf-mpi
-   [libcaf_x]: #libcaf-x
-   [libcaf_gasnet]:  #libcaf-gasnet
-   [libcaf_single]: #libcaf-single
-  [GNU (gfortran)]: #compiler-issues-gnu
-  [Cray (ftn)]: #compiler-issues-cray
-  [Intel (ifort)]: #compiler-issues-intel
-  [Numerical Algorithms Group (nagfor)]: #compiler-issues-nag
-  [Portland Group (pgfortran)]: #compiler-issues-pg
-  [IBM (xlf)]: #compiler-issues-ibm
-  [forking the OpenCoarrays repository]: https://github.com/sourceryinstitute/opencoarrays/fork
-
-[TS 18508]: http://isotc.iso.org/livelink/livelink?func=ll&objId=17181227&objAction=Open
-[opencoarrays module]: ./src/extensions/opencoarrays.F90
-[ABI]: https://gcc.gnu.org/onlinedocs/gfortran/Function-ABI-Documentation.html#Function-ABI-Documentation
-[pull requests via GitHub]: https://github.com/sourceryinstitute/opencoarrays/compare
-[pull request via GitHub]: https://github.com/sourceryinstitute/opencoarrays/compare
-[OpenCoarrays Google Group]: https://groups.google.com/forum/#!forum/opencoarrays
-[Sourcery Store]: http://www.sourceryinstitute.org/store
-[Issues]: https://github.com/sourceryinstitute/opencoarrays/issues
-[pdf img]: https://img.shields.io/badge/PDF-STATUS.md-6C2DC7.svg?style=flat-square "Download as PDF"
diff --git a/cmake/AddInstallationScriptTest.cmake b/cmake/AddInstallationScriptTest.cmake
new file mode 100644
index 0000000..b470680
--- /dev/null
+++ b/cmake/AddInstallationScriptTest.cmake
@@ -0,0 +1,17 @@
+macro(add_installation_script_test name path)
+
+  # Copy the source to the binary tree
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}
+    ${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}
+    COPYONLY
+  )
+  configure_file(
+    ${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}-usage
+    ${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}-usage
+    COPYONLY
+  )
+  add_test(NAME test-${name} COMMAND "${CMAKE_BINARY_DIR}/${path}/${name}")
+  set_property(TEST test-${name} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${path}")
+  set_property(TEST test-${name} PROPERTY ENVIRONMENT "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR}")
+endmacro(add_installation_script_test)
diff --git a/install.sh b/install.sh
index a764b92..ba57592 100755
--- a/install.sh
+++ b/install.sh
@@ -161,6 +161,7 @@ info  "-l (--list-packages):    ${arg_l}"
 info  "-m (--with-cmake):       ${arg_m}"
 info  "-M (--with-mpi):         ${arg_M}"
 info  "-n (--no-color):         ${arg_n}"
+info  "-o (--only-download):    ${arg_o}"
 info  "-p (--package):          ${arg_p}"
 info  "-P (--print-path):       ${arg_P}"
 info  "-U (--print-url):        ${arg_U}"
@@ -240,10 +241,7 @@ source $opencoarrays_src_dir/prerequisites/install-functions/report_results.sh
 if [[ "${arg_v}" == "${__flag_present}" || "${arg_V}" == "opencoarrays" ]]; then
 
   # Print script copyright if invoked with -v, -V, or --version argument
-  cmake_project_line="$(grep project "${opencoarrays_src_dir}/CMakeLists.txt" | grep VERSION)"
-  text_after_version_keyword="${cmake_project_line##*VERSION}"
-  text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
-  opencoarrays_version=$text_before_language_keyword
+  opencoarrays_version=$(sed -n 's/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)/\1/p' "${opencoarrays_src_dir%/}/.VERSION")
   if [[ "${arg_v}" == "${__flag_present}" ]]; then
     echo "OpenCoarrays ${opencoarrays_version}"
     echo ""
@@ -290,15 +288,31 @@ elif [[ ! -z "${arg_D:-${arg_P:-${arg_U:-${arg_V:-${arg_B}}}}}" ||  "${arg_l}" =
   fi
 
 elif [[ "${arg_p:-}" == "opencoarrays" ]]; then
+
+  if [[ "${arg_o}" == "${__flag_present}" ]]; then
+    
+    # Download all prerequisites and exit
+    info "source ${OPENCOARRAYS_SRC_DIR}/prerequisites/install-functions/download-all-prerequisites.sh"
+    source "${OPENCOARRAYS_SRC_DIR}/prerequisites/install-functions/download-all-prerequisites.sh"
+    info "download_all_prerequisites"
+    download_all_prerequisites
+
+  else 
+
+    # Install OpenCoarrays
+    cd prerequisites || exit 1
+    installation_record=install-opencoarrays.log
+    # shellcheck source=./prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh
+    source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
+    version="$("${opencoarrays_src_dir}/install.sh" -V opencoarrays)"
+    set_SUDO_if_needed_to_write_to_directory "${install_path}"
   
-  cd prerequisites || exit 1
-  installation_record=install-opencoarrays.log
-  # shellcheck source=./prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh
-  source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
-  version="$("${opencoarrays_src_dir}/install.sh" -V opencoarrays)"
-  set_SUDO_if_needed_to_write_to_directory "${install_path}"
-  build_opencoarrays 2>&1 | tee ../"${installation_record}"
-  report_results 2>&1 | tee -a ../"${installation_record}"
+    # Using process substitution "> >(...) -" instead of piping to tee via "2>&1 |" ensures that
+    # report_results gets the FC value set in build_opencoarrays
+    # Source: http://stackoverflow.com/questions/8221227/bash-variable-losing-its-value-strange
+    build_opencoarrays > >( tee ../"${installation_record}" ) -
+    report_results 2>&1 | tee -a ../"${installation_record}"
+  fi
 
 elif [[ "${arg_p:-}" == "ofp" ]]; then
 
diff --git a/install.sh-usage b/install.sh-usage
index bcd5c1d..7c97a90 100644
--- a/install.sh-usage
+++ b/install.sh-usage
@@ -1,11 +1,11 @@
   -b --install-branch [arg]   Install the specified repository development branch.
   -B --list-branches [arg]    List the available branches in the specified package's repository.
-  -c --with-c [arg]           Use specified C compiler. 
-  -C --with-cxx [arg]         Use specified C++ compiler. 
+  -c --with-c [arg]           Use specified C compiler.
+  -C --with-cxx [arg]         Use specified C++ compiler.
   -d --debug                  Enable debug mode.
   -D --print-downloader [arg] Print download program for package specified in argument.
   -e --verbose                Enable verbose mode, print script as it is executed.
-  -f --with-fortran [arg]     Use specified Fortran compiler. 
+  -f --with-fortran [arg]     Use specified Fortran compiler.
   -h --help                   Print this page.
   -i --install-prefix [arg]   Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/${version_to_build:-}"
   -I --install-version [arg]  Install package version.
@@ -14,6 +14,7 @@
   -m --with-cmake [arg]       Use specified CMake installation. Default="cmake"
   -M --with-mpi [arg]         Use specified MPI installation.
   -n --no-color               Disable color output.
+  -o --only-download          Download (without building) the source for the package specified by -p or --package.
   -p --package [arg]          Install specified package. Default="opencoarrays"
   -P --print-path [arg]       Print installation directory for specified package.
   -U --print-url [arg]        Print download location for specified package.
diff --git a/prerequisites/build-functions/build_and_install.sh b/prerequisites/build-functions/build_and_install.sh
index 211118f..1dc1ec9 100644
--- a/prerequisites/build-functions/build_and_install.sh
+++ b/prerequisites/build-functions/build_and_install.sh
@@ -1,5 +1,8 @@
 # Make the build directory, configure, and build
 # shellcheck disable=SC2154
+
+source ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh
+
 build_and_install()
 {
   num_threads=${arg_j}
@@ -14,17 +17,37 @@ build_and_install()
   mkdir -p "${build_path}"
   info "pushd ${build_path}"
   pushd "${build_path}"
-  if [[ "${package_to_build}" == "gcc" ]]; then
+
+  if [[ "${package_to_build}" != "gcc" ]]; then
+
+    info "Configuring ${package_to_build} ${version_to_build} with the following command:"
+    info "FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" \"${download_path}/${package_source_directory}\"/configure --prefix=\"${install_path}\""
+    FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" "${download_path}/${package_source_directory}"/configure --prefix="${install_path}"
+    info "Building with the following command:"
+    info "FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" make -j\"${num_threads}\""
+    FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" make "-j${num_threads}"
+    info "Installing ${package_to_build} in ${install_path}"
+    if [[ ! -z "${SUDO:-}" ]]; then
+      info "You do not have write permissions to the installation path ${install_path}"
+      info "If you have administrative privileges, enter your password to install ${package_to_build}"
+    fi
+    info "Installing with the following command: ${SUDO:-} make install"
+    ${SUDO:-} make install
+
+  else # ${package_to_build} == "gcc"
+
+    # Use GCC's contrib/download_prerequisites script after modifying it, if necessary, to use the
+    # the preferred download mechanism set in prerequisites/build-functions/set_or_print_downloader.sh
+
     info "pushd ${download_path}/${package_source_directory} "
     pushd "${download_path}/${package_source_directory}"
-    arg_string="${args[@]:-}"
-    if [[ "$(uname)" == "Linux" ]]; then
-      sed -i'' "s/wget/${fetch} ${arg_string}/g" "${PWD}/contrib/download_prerequisites"
-    else
-      # This works on OS X and other POSIX-compliant operating systems:
-      sed -i '' "s/wget/${fetch} ${arg_string}/g" "${PWD}/contrib/download_prerequisites"
-    fi 
+
+    # Switch download mechanism, if wget is not available
+    edit_GCC_download_prereqs_file_if_necessary
+   
+    # Download GCC prerequisities
     "${PWD}"/contrib/download_prerequisites
+
     info "popd"
     popd
     info "Configuring gcc/g++/gfortran builds with the following command:"
@@ -38,21 +61,9 @@ build_and_install()
     fi
     info "Installing with the following command: ${SUDO:-} make install"
     ${SUDO:-} make install
-  else
-    info "Configuring ${package_to_build} ${version_to_build} with the following command:"
-    info "FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" \"${download_path}/${package_source_directory}\"/configure --prefix=\"${install_path}\""
-    FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" "${download_path}/${package_source_directory}"/configure --prefix="${install_path}"
-    info "Building with the following command:"
-    info "FC=\"${FC:-'gfortran'}\" CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" make -j\"${num_threads}\""
-    FC="${FC:-'gfortran'}" CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" make "-j${num_threads}"
-    info "Installing ${package_to_build} in ${install_path}"
-    if [[ ! -z "${SUDO:-}" ]]; then
-      info "You do not have write permissions to the installation path ${install_path}"
-      info "If you have administrative privileges, enter your password to install ${package_to_build}"
-    fi
-    info "Installing with the following command: ${SUDO:-} make install"
-    ${SUDO:-} make install
-  fi
+
+  fi # end if [[ "${package_to_build}" != "gcc" ]]; then
+  
   info "popd"
   popd
 }
diff --git a/prerequisites/build-functions/download_if_necessary.sh b/prerequisites/build-functions/download_if_necessary.sh
index 3eac265..9cfd39b 100644
--- a/prerequisites/build-functions/download_if_necessary.sh
+++ b/prerequisites/build-functions/download_if_necessary.sh
@@ -1,6 +1,6 @@
 # shellcheck shell=bash disable=SC2148
-# shellcheck source=./ftp-url.sh
-source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp-url.sh"
+# shellcheck source=./ftp_url.sh
+source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"
 # shellcheck source=./set_SUDO_if_needed_to_write_to_directory.sh
 source "${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
 
@@ -13,29 +13,61 @@ download_if_necessary()
 
   # We set args regardless of whether this function performs a download because
   # GCC builds will need this to modify GCC's contrib/download_prerequisites script
-  if [[ "${fetch}" == "svn" ]]; then
-    if [[ "${arg_B:-}" == "gcc" ]]; then
-      args=("ls")
-    else
-      args=("checkout")
-    fi
-  elif [[ "${fetch}" == "wget" ]]; then
-    args=("--no-check-certificate")
-  elif [[ "${fetch}" == "ftp-url" ]]; then
-    args=("-n")
-  elif [[ "${fetch}" == "git" ]]; then
-    args=("clone")
-  elif [[ "${fetch}" == "curl" ]]; then
-    first_three_characters=$(echo "${package_url}" | cut -c1-3)
-    if [[ "${first_three_characters}" == "ftp"  ]]; then
-      args=("-LO" "-u" "anonymous:")
-    elif [[ "${first_three_characters}" == "htt"  ]]; then
-      args=("-LO")
-    else
-      emergency "download_if_necessary.sh: Unrecognized URL."
-    fi
-  fi
 
+  case "${fetch}" in
+    "wget" )
+      args=("--no-check-certificate")
+      ;;
+    "ftp_url" )
+      args=("-n")
+      ;;
+    "git" )
+      args=("clone")
+      ;;
+    "svn" )
+       case "${arg_B:-}" in 
+         "gcc") 
+           args=("ls")
+           ;; 
+         *) 
+           args=("checkout")
+         ;;
+       esac
+       ;;
+    "curl" )
+      first_three_characters=$(echo "${package_url}" | cut -c1-3)
+      case "${first_three_characters}" in
+        "ftp"  )
+           args=("-LO" "-u" "anonymous: ")
+        ;; 
+        "htt"  )
+           args=("-LO")
+        ;; 
+        *)
+          emergency "download_if_necessary.sh: Unrecognized URL."
+        ;;
+      esac
+      ;;
+    *)
+      emergency "download_if_necessary.sh: Unrecognized \${fetch}=${fetch}."
+      ;; 
+  esac
+
+  case "${gcc_prereqs_fetch}" in
+    "wget" )
+      gcc_prereqs_fetch_args=("--no-check-certificate")
+      ;;
+    "ftp_url" )
+      gcc_prereqs_fetch_args=("-n")
+      ;;
+    "curl" )
+      gcc_prereqs_fetch_args=("-LO" "-u" "anonymous: ")
+      ;; 
+    *)
+      emergency "download_if_necessary.sh: Unrecognized \${gcc_prereqs_fetch}=${gcc_prereqs_fetch}."
+      ;;
+   esac
+  
   if  [[ -f "${download_path}/${url_tail}" || -d "${download_path}/${url_tail}" ]] ; then
     info "Found '${url_tail}' in ${download_path}."
     info "If it resulted from an incomplete download, building ${package_name} could fail."
diff --git a/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh b/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh
new file mode 100644
index 0000000..e49dcd8
--- /dev/null
+++ b/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh
@@ -0,0 +1,44 @@
+# shellcheck disable=SC2154
+replace_wget()
+{
+  # Define a file extension for the download_prerequisites backup
+  backup_extension=".original"
+  backup_file="${download_prereqs_file}${backup_extension}"
+  if [[ -f ${backup_file}  ]]; then
+    # Prevent overwriting an existing backup:
+    backup_extension=""
+  fi
+
+  if [[ "${gcc_prereqs_fetch}" == "ftp_url" ]]; then
+    # Insert a new line after line 2 to include ftp_url.sh as a download option
+    sed -i${backup_extension} -e '2 a\'$'\n'". ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/ftp_url.sh"$'\n' "${download_prereqs_file}"
+  fi
+
+  arg_string="${gcc_prereqs_fetch_args[@]:-}"
+
+  info "Using the following command to replace wget in the GCC download_prerequisites file:"
+  info "sed -i${backup_extension} s/\"${wget_command}\"/\"${gcc_prereqs_fetch} ${arg_string} \"/ \"${download_prereqs_file}\""
+  if [[ "${__operating_system}" == "Linux" ]]; then
+    sed -i"${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
+  else
+    sed -i "${backup_extension}" s/wget/"${gcc_prereqs_fetch} ${arg_string} "/ "${download_prereqs_file}"
+  fi
+}
+
+edit_GCC_download_prereqs_file_if_necessary()
+{
+  __operating_system=$(uname)
+  download_prereqs_file="${PWD}/contrib/download_prerequisites"
+
+  # Grab the line with the first occurence of 'wget'
+  wget_line=`grep wget "${download_prereqs_file}" | head -1` || true
+  wget_command="${wget_line%%ftp*}" # grab everything before ftp
+
+  # Check for wget format used before GCC 7
+  if [[ ! -z "${wget_command}" ]]; then
+    # Check whether wget is available on this system
+    if ! type wget &> /dev/null; then
+      replace_wget
+    fi
+  fi
+}
diff --git a/prerequisites/build-functions/ftp-url.sh b/prerequisites/build-functions/ftp-url.sh
deleted file mode 100644
index 0ac426c..0000000
--- a/prerequisites/build-functions/ftp-url.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-# Download a file from an anonymous ftp site
-#
-# Usage:
-#    ftp-url  <ftp-mode>  ftp://<fully-qualified-domain>:/<path-to-file>/<file-name>
-#
-# Example:
-#    ftp-url -n ftp://ftp.gnu.org:/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
-ftp-url()
-{
-  ftp_mode="${1}"
-  url="${2}"
-
-  if [[ "${ftp_mode}" != "-n" ]]; then
-    emergency "Unexpected ftp mode received by ftp-url.sh: ${ftp_mode}"
-  fi
-
-  protocol="${url%%:*}" # grab text_before_first_colon
-  if [[ "${protocol}" != "ftp" ]]; then
-    emergency "URL with unexpected protocol received by ftp-url.sh: ${text_before_first_colon}"
-  fi
-
-  text_after_double_slash="${url##*//}"
-  FTP_SERVER="${text_after_double_slash%:*}" # grab remaining text before colon
-  
-  text_after_final_colon="${url##*:}"
-  FILE_NAME="${url##*/}" # grab text after final slash
-  FILE_PATH="${text_after_final_colon%/*}" # grab remaining text before final slash
-
-  USERNAME=anonymous
-  PASSWORD=""
-  info "starting anonymous download: ${protocol} ${ftp_mode} ${FTP_SERVER}... cd ${FILE_PATH}... get ${FILE_NAME}"
-
-ftp "${ftp_mode}" "${FTP_SERVER}" <<Done-ftp
-user "${USERNAME}" "${PASSWORD}"
-cd "${FILE_PATH}"
-passive
-binary
-get "${FILE_NAME}"
-bye
-Done-ftp
-
-info "finished anonymous ftp"
-}
diff --git a/prerequisites/build-functions/ftp_url.sh b/prerequisites/build-functions/ftp_url.sh
new file mode 100644
index 0000000..8b15b08
--- /dev/null
+++ b/prerequisites/build-functions/ftp_url.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Download a file from an anonymous ftp site
+#
+# Usage:
+#    ftp_url  <ftp-mode>  ftp://<fully-qualified-domain>:/<path-to-file>/<file-name>
+#
+# Example:
+#    ftp_url -n ftp://ftp.gnu.org:/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.bz2
+ftp_url()
+{
+  ftp_mode="${1}"
+  url="${2}"
+
+  if [ "${ftp_mode}" != "-n" ]; then
+    echo "Unexpected ftp mode received by ftp_url.sh: ${ftp_mode}"
+  fi
+
+  protocol="${url%%:*}" # grab text_before_first_colon
+  if [ "${protocol}" != "ftp" ]; then
+    echo "URL with unexpected protocol received by ftp_url.sh: ${text_before_first_colon}"
+  fi
+
+  text_after_double_slash="${url##*//}"
+  FTP_SERVER="${text_after_double_slash%%/*}" # grab remaining text before first slash
+  FILE_NAME="${url##*/}" # grab text after final slash
+
+  text_after_final_colon="${url##*:}"
+  FILE_PATH="${text_after_final_colon#*//}"
+  FILE_PATH="${FILE_PATH#*/}" 
+  FILE_PATH="${FILE_PATH%/*}" 
+
+  USERNAME=anonymous
+  PASSWORD="noone at nowhere.com"
+  echo "starting anonymous download: ${protocol} ${ftp_mode} ${FTP_SERVER};... cd ${FILE_PATH}; ...; get ${FILE_NAME}"
+
+ftp "${ftp_mode}" "${FTP_SERVER}" <<Done-ftp
+user "${USERNAME}" "${PASSWORD}"
+cd "${FILE_PATH}"
+passive
+binary
+get "${FILE_NAME}"
+bye
+Done-ftp
+
+echo "finished anonymous ftp"
+}
diff --git a/prerequisites/build-functions/set_or_print_downloader.sh b/prerequisites/build-functions/set_or_print_downloader.sh
index fc6d8b8..3efda92 100644
--- a/prerequisites/build-functions/set_or_print_downloader.sh
+++ b/prerequisites/build-functions/set_or_print_downloader.sh
@@ -21,27 +21,29 @@ set_or_print_downloader()
   info "Checking available download mechanisms: ftp, wget, and curl."
   info "\${package_name}=${package_name}  \${arg_b:-\${arg_B:-}}=${arg_b:-${arg_B:-}}"
 
-  if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then
-
-    if type svn &> /dev/null; then
-      fetch=svn
-    else
-      tried="svn"
-    fi
-
-  elif type curl &> /dev/null; then
-    fetch=curl
+  if type curl &> /dev/null; then
+    gcc_prereqs_fetch=curl
   elif type wget &> /dev/null; then
-    fetch=wget
+    gcc_prereqs_fetch=wget
   elif type ftp &> /dev/null; then
     if [[ "${package_name}" == "gcc"   || "${package_name}" == "wget" || "${package_name}" == "make" ||
           "${package_name}" == "bison" || "${package_name}" == "m4"   ]]; then
-      fetch=ftp-url
+      gcc_prereqs_fetch=ftp_url
     fi
   else
     tried="curl, wget, and ftp"
   fi
 
+  if [[ "${package_name}" == "gcc" && ! -z "${arg_b:-${arg_B:-}}" ]]; then
+    if type svn &> /dev/null; then
+      fetch=svn
+    else
+      tried="svn"
+    fi
+  else
+    fetch=${gcc_prereqs_fetch}
+  fi
+
   if [[ -z "${fetch:-}" ]]; then
     if [[ -z "${arg_B:-}" ]]; then
       warning "No available download mechanism. Options tried: ${tried}"
diff --git a/prerequisites/build-functions/set_or_print_url.sh b/prerequisites/build-functions/set_or_print_url.sh
index 139178c..24163c1 100644
--- a/prerequisites/build-functions/set_or_print_url.sh
+++ b/prerequisites/build-functions/set_or_print_url.sh
@@ -46,7 +46,11 @@ set_or_print_url()
   # Set differing tails for GCC release downloads versus development branch checkouts
   if [[ "${package_to_build}" == 'gcc' ]]; then
     if [[ "${fetch}" == 'svn' ]]; then
-      gcc_tail=${version_to_build-branches}
+      if [[ "${version_to_build}" == "trunk" ]]; then
+        gcc_tail="${version_to_build}"
+      else
+        gcc_tail="branches/${version_to_build}"
+      fi
     else
       gcc_tail="gcc-${version_to_build}.tar.bz2"
     fi
diff --git a/prerequisites/build.sh b/prerequisites/build.sh
index 7d6364d..019ea25 100755
--- a/prerequisites/build.sh
+++ b/prerequisites/build.sh
@@ -141,6 +141,12 @@ fi
 source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/download_if_necessary.sh"
 download_if_necessary
 
+# Exit if -o or --only-download was specified when invoking this script
+if [[ ${arg_o:-} == "${__flag_present}" ]]; then
+   info "No installation to perform: -o or --only-download specified.  Exiting."
+   exit 0
+fi
+
 if [[ -z "${arg_B}" ]]; then
   # shellcheck source=./build-functions/unpack_if_necessary.sh
   source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/unpack_if_necessary.sh"
diff --git a/prerequisites/build.sh-usage b/prerequisites/build.sh-usage
index ed08869..3920c17 100644
--- a/prerequisites/build.sh-usage
+++ b/prerequisites/build.sh-usage
@@ -14,6 +14,7 @@
   -m --with-cmake [arg]       Use the specified CMake installation. Default="cmake"
   -M --with-mpi [arg]         Use the specified MPI installation. 
   -n --no-color               Disable color output.
+  -o --only-download          Download (without building) the package source specified by -p or --package.
   -p --package [arg]          Package to install. 
   -P --print-path [arg]       Print installation path for package specified in argument.
   -t --with-tau [arg]         Use the specified TAU parallel performance utilities installation. Default="tauf90"
diff --git a/prerequisites/check_version.sh b/prerequisites/check_version.sh
index 69f6c4d..7a7dffe 100755
--- a/prerequisites/check_version.sh
+++ b/prerequisites/check_version.sh
@@ -82,10 +82,7 @@ elif [[ $1 == '--list' || $1 == '-l' ]]; then
 
 elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
   # Print script copyright if invoked with -v, -V, or --version argument
-  cmake_project_line=$(grep project ../CMakeLists.txt | grep VERSION)
-  text_after_version_keyword="${cmake_project_line##*VERSION}"
-  text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
-  opencoarrays_version=$text_before_language_keyword
+  opencoarrays_version=$(sed -n 's/\([0-9]\{1,\}\(\.[0-9]\{1,\}\)\{1,\}\)/\1/p' ../.VERSION)
   echo "opencoarrays $opencoarrays_version"
   echo ""
   echo "OpenCoarrays prerequisite version verifier"
diff --git a/prerequisites/install-functions/build_opencoarrays.sh b/prerequisites/install-functions/build_opencoarrays.sh
index 42dbe80..5e3a745 100644
--- a/prerequisites/install-functions/build_opencoarrays.sh
+++ b/prerequisites/install-functions/build_opencoarrays.sh
@@ -1,3 +1,4 @@
+#shellcheck shell=bash
 # shellcheck disable=SC2154
 build_opencoarrays()
 {
@@ -9,18 +10,27 @@ build_opencoarrays()
   build_path="${build_path}"/opencoarrays/$("${opencoarrays_src_dir}"/install.sh -V opencoarrays)
   mkdir -p "$build_path"
   pushd "$build_path"
-  if [[ -z "${MPICC:-}" || -z "${MPIFC:-}" || -z "${CMAKE:-}" ]]; then
-    emergency "Empty MPICC=$MPICC or MPIFC=$MPIFC or CMAKE=$CMAKE [exit 90]"
-  else
-    info "Configuring OpenCoarrays in ${PWD} with the command:"
-    info "CC=\"${MPICC}\" FC=\"${MPIFC}\" $CMAKE \"${opencoarrays_src_dir}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\""
-    CC="${MPICC}" FC="${MPIFC}" $CMAKE "${opencoarrays_src_dir}" -DCMAKE_INSTALL_PREFIX="${install_path}"
-    info "Building OpenCoarrays in ${PWD} with the command make -j${num_threads}"
-    make "-j${num_threads}"
-    if [[ ! -z ${SUDO:-} ]]; then
-      printf "\nThe chosen installation path requires sudo privileges. Please enter password if prompted.\n"
-    fi
-    info "Installing OpenCoarrays in ${install_path} with the command ${SUDO:-} make install"
-    ${SUDO:-} make install
+  if [[ -z ${MPIFC:-} || -z ${MPICC:-} ]]; then
+    emergency "build_opencoarrays.sh: empty \${MPIFC}=${MPIFC:-} or \${MPICC}=${MPICC:-}"
   fi
+  MPIFC_show=($($MPIFC -show))
+  MPICC_show=($($MPICC -show))
+  if [[ "${MPIFC_show[0]}" != *gfortran* || "${MPICC_show[0]}" != *gcc* ]]; then
+    emergency "build_opencoarrays.sh: MPI doesn't wrap gfortran/gcc: \${MPIFC_show}=${MPIFC_show[*]}, \${MPICC_show}=${MPICC_show[*]}"
+  fi
+  # Set FC to the MPI implementation's gfortran command with any preceding path but without any subsequent arguments:
+  FC="${MPIFC_show[0]}"
+  # Set CC to the MPI implementation's gcc command...
+  CC="${MPICC_show[0]}"
+  info "Configuring OpenCoarrays in ${PWD} with the command:"
+  info "CC=\"${CC}\" FC=\"${FC}\" $CMAKE \"${opencoarrays_src_dir}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\" -DMPI_C_COMPILER=\"${MPICC}\" -DMPI_Fortran_COMPILER=\"${MPIFC}\""
+  CC="${CC}" FC="${FC}" $CMAKE "${opencoarrays_src_dir}" -DCMAKE_INSTALL_PREFIX="${install_path}" -DMPI_C_COMPILER="${MPICC}" -DMPI_Fortran_COMPILER="${MPIFC}"
+  info "Building OpenCoarrays in ${PWD} with the command make -j${num_threads}"
+  make "-j${num_threads}"
+  if [[ ! -z ${SUDO:-} ]]; then
+    printf "\nThe chosen installation path requires sudo privileges. Please enter password if prompted.\n"
+  fi
+  info "Installing OpenCoarrays in ${install_path} with the command ${SUDO:-} make install"
+  ${SUDO:-} make install
 }
+
diff --git a/prerequisites/install-functions/download-all-prerequisites.sh b/prerequisites/install-functions/download-all-prerequisites.sh
new file mode 100755
index 0000000..862b9e5
--- /dev/null
+++ b/prerequisites/install-functions/download-all-prerequisites.sh
@@ -0,0 +1,33 @@
+function download_all_prerequisites() 
+{
+  pushd ${OPENCOARRAYS_SRC_DIR}
+
+  download_list=( "m4" "bison" "flex" "mpich" "cmake" )
+
+  for package_to_download in "${download_list[@]}" ;
+  do
+    ./install.sh --package ${package_to_download} --only-download
+  done
+  
+  if [[ ! -z ${arg_b:-}  ]]; then
+    ./install.sh --package gcc  --only-download --install-branch "${arg_b}"
+    cd prerequisites/downloads/${arg_b:-}
+  else  # Download default version
+    ./install.sh --package gcc  --only-download
+    gcc_version=$(./install.sh -V gcc)
+    cd prerequisites/downloads/
+    tar xf gcc-${gcc_version}.tar.bz2 || emergency "tar didn't work"
+    listing=$(ls -lt)
+    cd gcc-${gcc_version}
+  fi
+
+  source ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/set_or_print_downloader.sh
+  set_or_print_downloader
+  
+  source ${OPENCOARRAYS_SRC_DIR}/prerequisites/build-functions/edit_GCC_download_prereqs_file_if_necessary.sh
+  edit_GCC_download_prereqs_file_if_necessary
+  
+  ./contrib/download_prerequisites
+  
+  popd
+}
diff --git a/prerequisites/install-functions/find_or_install.sh b/prerequisites/install-functions/find_or_install.sh
index 5229677..60b8b02 100644
--- a/prerequisites/install-functions/find_or_install.sh
+++ b/prerequisites/install-functions/find_or_install.sh
@@ -266,7 +266,7 @@ find_or_install()
       info "$this_script: Checking whether $executable in PATH is version $(./build.sh -V gcc) or later..."
       $executable -o acceptable_compiler acceptable_compiler.f90 || true;
       $executable -o print_true print_true.f90 || true;
-      if [[ -f ./accepatable_compiler && -f ./print_true ]]; then
+      if [[ -f ./acceptable_compiler && -f ./print_true ]]; then
         is_true=$(./print_true)
         acceptable=$(./acceptable_compiler)
         rm acceptable_compiler print_true
diff --git a/prerequisites/install-functions/report_results.sh b/prerequisites/install-functions/report_results.sh
index 7830591..dac3c39 100644
--- a/prerequisites/install-functions/report_results.sh
+++ b/prerequisites/install-functions/report_results.sh
@@ -1,17 +1,33 @@
 # shellcheck shell=bash disable=SC2154,SC2129,SC2148
 report_results()
 {
-  # Report installation success or failure:
-  if [[ -x "$install_path/bin/caf" && -x "$install_path/bin/cafrun" ]]; then
+  type_FC=`type ${FC}`
+  fully_qualified_FC="/${type_FC#*/}"
+  if [[ ${fully_qualified_FC} != *gfortran* ]]; then
+    emergency "report_results.sh: non-gfortran compiler: \${fully_qualified_FC}=${fully_qualified_FC}"
+  fi  
+  # Set path_to_FC fully-qualified gfortran location
+  compiler_install_root="${fully_qualified_FC%%bin/gfortran*}"
+
+  type_MPIFC=`type ${MPIFC}`
+  fully_qualified_MPIFC="/${type_MPIFC#*/}"
+  mpi_install_root="${fully_qualified_MPIFC%%bin/mpif90*}"
+
+  type_CMAKE=`type ${CMAKE}`
+  fully_qualified_CMAKE="/${type_CMAKE#*/}"
+  cmake_install_path="${fully_qualified_CMAKE%%/cmake*}"
+
+  # Report installation success or failure and record locations for software stack:
+  if [[ -x "${install_path%/}/bin/caf" && -x "${install_path%/}/bin/cafrun" ]]; then
 
     # Installation succeeded
-    echo "$this_script: Done."
-    echo ""
-    echo "*** The OpenCoarrays compiler wrapper (caf) and program  ***"
-    echo "*** launcher (cafrun) are in the following directory:    ***"
-    echo ""
-    echo "$install_path/bin."
-    echo ""
+    info "$this_script: Done."
+    info ""
+    info "*** The OpenCoarrays compiler wrapper (caf) and program  ***"
+    info "*** launcher (cafrun) are in the following directory:    ***"
+    info ""
+    info "${install_path%/}/bin."
+    info ""
     if [[ -f setup.sh ]]; then
       ${SUDO:-} rm setup.sh
     fi
@@ -25,47 +41,51 @@ report_results()
     while IFS='' read -r line || [[ -n "$line" ]]; do
         echo "# $line" >> setup.csh
     done < "${opencoarrays_src_dir}/LICENSE"
-    echo "#                                                                      " | tee -a setup.csh setup.sh
-    echo "# Execute this script via the following command:                       " | tee -a setup.csh setup.sh
-    echo "# source $install_path/setup.sh                                        " | tee -a setup.csh setup.sh
-    echo "                                                                       " | tee -a setup.csh setup.sh
-    gcc_install_path=$("${build_script}" -P gcc)
-    if [[ -x "$gcc_install_path/bin/gfortran" ]]; then
-      echo "if [[ -z \"\$PATH\" ]]; then                                         " >> setup.sh
-      echo "  export PATH=\"$gcc_install_path/bin\"                              " >> setup.sh
-      echo "else                                                                 " >> setup.sh
-      echo "  export PATH=\"$gcc_install_path/bin:\$PATH\"                       " >> setup.sh
-      echo "fi                                                                   " >> setup.sh
-      echo "set path = (\"$gcc_install_path\"/bin \"\$path\")                    " >> setup.csh
+    echo "#                                                                               " | tee -a setup.csh setup.sh
+    echo "# Execute this script via the following command:                                " | tee -a setup.csh setup.sh
+    echo "# source ${install_path%/}/setup.sh                                             " | tee -a setup.csh setup.sh
+    echo "                                                                                " | tee -a setup.csh setup.sh
+    if [[ -x "$fully_qualified_FC" ]]; then
+      echo "if [[ -z \"\$PATH\" ]]; then                                                  " >> setup.sh
+      echo "  export PATH=\"${compiler_install_root%/}/bin\"                              " >> setup.sh
+      echo "else                                                                          " >> setup.sh
+      echo "  export PATH=\"${compiler_install_root%/}/bin:\$PATH\"                       " >> setup.sh
+      echo "fi                                                                            " >> setup.sh
+      echo "set path = (\"${compiler_install_root%/}\"/bin \"\$path\")                    " >> setup.csh
     fi
-    if [[ -d "$gcc_install_path/lib" || -d "$gcc_install_path/lib64" ]]; then
-      gfortran_lib_paths="$gcc_install_path/lib64/:$gcc_install_path/lib"
-      echo "if [[ -z \"\$LD_LIBRARY_PATH\" ]]; then                              " >> setup.sh
-      echo "  export LD_LIBRARY_PATH=\"$gfortran_lib_paths\"                     " >> setup.sh
-      echo "else                                                                 " >> setup.sh
-      echo "  export LD_LIBRARY_PATH=\"$gfortran_lib_paths:\$LD_LIBRARY_PATH\"   " >> setup.sh
-      echo "fi                                                                   " >> setup.sh
-      echo "set LD_LIBRARY_PATH = (\"$gfortran_lib_paths\"/bin \"\$LD_LIBRARY_PATH\")                      " >> setup.csh
+    if [[ -d "${compiler_install_root%/}/lib" || -d "${compiler_install_root%/}/lib64" ]]; then
+      compiler_lib_paths="${compiler_install_root%/}/lib64/:${compiler_install_root%/}/lib"
+      echo "if [[ -z \"\$LD_LIBRARY_PATH\" ]]; then                                       " >> setup.sh
+      echo "  export LD_LIBRARY_PATH=\"${compiler_lib_paths%/}\"                          " >> setup.sh
+      echo "else                                                                          " >> setup.sh
+      echo "  export LD_LIBRARY_PATH=\"${compiler_lib_paths%/}:\$LD_LIBRARY_PATH\"        " >> setup.sh
+      echo "fi                                                                            " >> setup.sh
+      echo "set LD_LIBRARY_PATH = (\"${compiler_lib_paths%/}\"/bin \"\$LD_LIBRARY_PATH\") " >> setup.csh
     fi
     echo "                                                                       " >> setup.sh
-    mpich_install_path=$("${build_script}" -P mpich)
-    if [[ -x "$mpich_install_path/bin/mpif90" ]]; then
+    if [[ -x "$mpi_install_root/bin/mpif90" ]]; then
       echo "if [[ -z \"\$PATH\" ]]; then                                         " >> setup.sh
-      echo "  export PATH=\"$mpich_install_path/bin\"                            " >> setup.sh
+      echo "  export PATH=\"${mpi_install_root%/}/bin\"                        " >> setup.sh
       echo "else                                                                 " >> setup.sh
-      echo "  export PATH=\"$mpich_install_path/bin\":\$PATH                     " >> setup.sh
+      echo "  export PATH=\"${mpi_install_root%/}/bin\":\$PATH                 " >> setup.sh
       echo "fi                                                                   " >> setup.sh
-      echo "set path = (\"$mpich_install_path\"/bin \"\$path\")                      " >> setup.csh
+      echo "set path = (\"${mpi_install_root%/}\"/bin \"\$path\")              " >> setup.csh
     fi
-    cmake_install_path=$("${build_script}" -P cmake)
-    if [[ -x "$cmake_install_path/bin/cmake" ]]; then
+    if [[ -x "$cmake_install_path/cmake" ]]; then
       echo "if [[ -z \"\$PATH\" ]]; then                                         " >> setup.sh
-      echo "  export PATH=\"$cmake_install_path/bin\"                            " >> setup.sh
+      echo "  export PATH=\"${cmake_install_path%/}/\"                            " >> setup.sh
       echo "else                                                                 " >> setup.sh
-      echo "  export PATH=\"$cmake_install_path/bin\":\$PATH                     " >> setup.sh
+      echo "  export PATH=\"${cmake_install_path%/}/\":\$PATH                     " >> setup.sh
       echo "fi                                                                   " >> setup.sh
-      echo "set path = (\"$cmake_install_path\"/bin \"\$path\")                      " >> setup.csh
+      echo "set path = (\"${cmake_install_path%/}\"/\"\$path\")                      " >> setup.csh
     fi
+    # In all likelihood, the following paths are only needed if OpenCoarrays built them,
+    # In by far the most common such use case, they would have been built in a recursive
+    # build of all the OpenCoarrays dependency tree (rather than built indvidually via
+    # ./install --package) so we only need check the default location in which OpenCoarrays
+    # would install them.  If they are not there, then it is very likely the case that the 
+    # the system versions of these packages are present and in the user's path or that the
+    # user doesn't need them at all (e.g. there was no need to build gfortran from source).
     flex_install_path=$("${build_script}" -P flex)
     if [[ -x "$flex_install_path/bin/flex" ]]; then
       echo "if [[ -z \"\$PATH\" ]]; then                                         " >> setup.sh
@@ -96,11 +116,11 @@ report_results()
     opencoarrays_install_path="${install_path}"
     if [[ -x "$opencoarrays_install_path/bin/caf" ]]; then
       echo "if [[ -z \"\$PATH\" ]]; then                                         " >> setup.sh
-      echo "  export PATH=\"$opencoarrays_install_path/bin\"                     " >> setup.sh
+      echo "  export PATH=\"${opencoarrays_install_path%/}/bin\"                     " >> setup.sh
       echo "else                                                                 " >> setup.sh
-      echo "  export PATH=\"$opencoarrays_install_path/bin\":\$PATH              " >> setup.sh
+      echo "  export PATH=\"${opencoarrays_install_path%/}/bin\":\$PATH              " >> setup.sh
       echo "fi                                                                   " >> setup.sh
-      echo "set path = (\"$opencoarrays_install_path\"/bin \"\$path\")                      " >> setup.csh
+      echo "set path = (\"${opencoarrays_install_path%/}\"/bin \"\$path\")                      " >> setup.csh
     fi
     if ${SUDO:-} mv setup.sh "$opencoarrays_install_path"; then
        setup_sh_location=$opencoarrays_install_path
@@ -117,8 +137,8 @@ report_results()
     echo "*** setup.csh in a C-shell or add one of the following statements ***"
     echo "*** to your login file:                                           ***"
     echo ""
-    echo " source $setup_sh_location/setup.sh"
-    echo " source $setup_csh_location/setup.csh"
+    echo " source ${setup_sh_location%/}/setup.sh"
+    echo " source ${setup_csh_location%/}/setup.csh"
     echo ""
     echo "*** Installation complete.                                        ***"
 
diff --git a/prerequisites/stack.sh b/prerequisites/stack.sh
index 5f73525..3ad59a9 100644
--- a/prerequisites/stack.sh
+++ b/prerequisites/stack.sh
@@ -41,6 +41,13 @@
 function stack_destroy
 {
     : "${1?'Missing stack name'}"
+
+    if no_such_stack "$1"
+    then
+        echo "No such stack -- $1" >&2
+        return 1
+    fi
+
     eval "unset _stack_$1 _stack_$1_i"
     return 0
 }
@@ -51,7 +58,7 @@ function stack_destroy
 function stack_push
 {
     : "${1?'Missing stack name'}"
-    : "${2?'Missing item(s) to push'}"
+    : "${2?'Missing variable name in stack_push'}"
 
     if no_such_stack "$1"
     then
@@ -91,6 +98,11 @@ function stack_size
         echo "No such stack -- $1" >&2
         return 1
     fi
+    # TODO: revise the eval below to eliminate the need for this pop/push
+    # sequene, which is a workaround to prevent an error that occurs with 
+    # if the stack is new and has not been the target of a stack_push. 
+    stack_push $1 __push_junk
+    stack_pop $1 __pop_trash
     eval "$2"='$'"{#_stack_$1[*]}"
 }
 
@@ -125,9 +137,7 @@ function no_such_stack
 function stack_pop
 {
     : "${1?'Missing stack name'}"
-    : "${2?'Missing name of variable for popped result'}"
-
-    eval 'let _i=$'"_stack_$1_i"
+    : "${2?'Missing variable name in stack_pop'}"
 
     if no_such_stack "$1"
     then
@@ -135,6 +145,8 @@ function stack_pop
         return 1
     fi
 
+    eval 'let _i=$'"_stack_$1_i"
+
     if [[ "$_i" -eq 0 ]]
     then
         echo "Empty stack -- $1" >&2
@@ -247,6 +259,15 @@ function stack_exists
 #    echo "Got $top"
 function stack_peek
 {
+  : "${1?'Missing stack name'}"
+  : "${2?'Missing variable name in stack_peek'}"
+
+  if no_such_stack "$1"
+  then
+      echo "No such stack -- $1" >&2
+      return 1
+  fi
+
   stack_pop "$1" "$2"
   eval argument_name="\$$2"
   # shellcheck disable=SC2154
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d878158..874ead2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,3 +2,7 @@ set(directories_to_build mpi tests)
 foreach(directory ${directories_to_build})
   add_subdirectory(${directory})
 endforeach()
+
+install( FILES libcaf.h libcaf-gfortran-descriptor.h
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+)
diff --git a/src/extensions/caf-foot b/src/extensions/caf-foot
index f3c1a24..1327ae9 100755
--- a/src/extensions/caf-foot
+++ b/src/extensions/caf-foot
@@ -63,7 +63,7 @@ fi
 # Default to "mpif90" Fortran compiler if environment variable CAFC is empty or unset:
 CAFC=${CAFC:-mpif90}
 
-# TODO -- improve the syntax of the "set" command below to accepted an unlimited number of arguments
+# TODO -- refactor this script to use the bash3boilerplate use case
 max_arguments=100
 link_args="-fcoarray=lib -lcaf_mpi"
 
@@ -77,8 +77,10 @@ if [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
     echo "BSD 3-Clause License.  For more information about these matters, see"
     echo "the file named LICENSE."
     echo ""
-elif [[ $1 == '-w' || $1 == '--wrapping' || $1 == '--wraps' ]]; then
+elif [[ $1 == '-w' || $1 == '--wraps' || $1 == '--wrapping' ]]; then
   echo "caf wraps CAFC=$CAFC"
+elif [[ $1 == '-s' || $1 == '--show' ]]; then
+  $CAFC -show
 elif [[ $1 == '-h' || $1 == '--help' ]]; then
   # Print usage information
   usage | less
diff --git a/src/extensions/caf-head b/src/extensions/caf-head
index 0ac67e7..f6274c2 100755
--- a/src/extensions/caf-head
+++ b/src/extensions/caf-head
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Coarray Fortran (CAF) Compiler Wrapper
 #
diff --git a/src/extensions/cafrun-foot b/src/extensions/cafrun-foot
index 8715308..d8b0b0c 100644
--- a/src/extensions/cafrun-foot
+++ b/src/extensions/cafrun-foot
@@ -1,4 +1,4 @@
-Usage()
+usage()
 {
     cmd=$(basename "$0")
     echo ""
@@ -39,9 +39,9 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
   echo "the file named LICENSE."
   echo ""
 elif [[ $1 == '-w' || $1 == '--wraps' ]]; then
-  mpirun -v
+  "${CAFRUN}"-v
 elif [[ $1 == '-h' || $1 == '--help' ]]; then
   usage
 else
-  mpirun "$@"
+  "${CAFRUN}" "$@"
 fi
diff --git a/src/extensions/cafrun-head b/src/extensions/cafrun-head
index cb43b8d..3f4afec 100755
--- a/src/extensions/cafrun-head
+++ b/src/extensions/cafrun-head
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 #
 # Coarray Fortran (CAF) Executable Launcher
 #
diff --git a/src/extensions/opencoarrays.F90 b/src/extensions/opencoarrays.F90
index e6d1e7f..88c533a 100644
--- a/src/extensions/opencoarrays.F90
+++ b/src/extensions/opencoarrays.F90
@@ -32,6 +32,10 @@ module opencoarrays
   use iso_c_binding, only : c_int,c_char,c_ptr,c_loc,c_double,c_int32_t,c_ptrdiff_t,c_sizeof,c_bool,c_funloc
   implicit none
 
+#ifndef MPI_WORKING_MODULE
+  include 'mpif.h'
+#endif
+
   private
   public :: co_reduce
   public :: co_broadcast
@@ -51,6 +55,10 @@ module opencoarrays
     integer(atomic_int_kind), allocatable :: atom[:]
   end type
 #endif
+#ifdef EXPOSE_INIT_FINALIZE
+  public :: caf_init
+  public :: caf_finalize
+#endif
 
   ! Generic interface to co_broadcast with implementations for various types, kinds, and ranks
   interface co_reduce
@@ -198,6 +206,29 @@ module opencoarrays
 
     ! C function signature from ../mpi/mpi_caf.c:
     ! void
+    ! PREFIX (init) (int *argc, char ***argv)
+#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
+    subroutine caf_init(argc,argv) bind(C,name="_caf_extensions_init")
+#else
+    subroutine caf_init(argc,argv) bind(C,name="_gfortran_caf_init")
+#endif
+      import :: c_int,c_ptr
+      type(c_ptr), value :: argc
+      type(c_ptr), value :: argv
+    end subroutine
+
+    ! C function signature from ../mpi/mpi_caf.c:
+    ! void
+    ! PREFIX (finalize) (void)
+#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
+    subroutine caf_finalize() bind(C,name="_caf_extensions_finalize")
+#else
+    subroutine caf_finalize() bind(C,name="_gfortran_caf_finalize")
+#endif
+    end subroutine
+
+    ! C function signature from ../mpi/mpi_caf.c:
+    ! void
     ! PREFIX (co_min) (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg,
     !                  int src_len, int errmsg_len)
 #ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
@@ -699,7 +730,9 @@ contains
 
   ! Return the image number (MPI rank + 1)
   function this_image()  result(image_num)
+#ifdef MPI_WORKING_MODULE
     use mpi, only : MPI_Comm_rank
+#endif
     integer(c_int) :: image_num,ierr
    !image_num = opencoarrays_this_image(unused)
     call MPI_Comm_rank(CAF_COMM_WORLD,image_num,ierr)
@@ -709,7 +742,9 @@ contains
 
   ! Return the total number of images
   function num_images()  result(num_images_)
+#ifdef MPI_WORKING_MODULE
     use mpi, only : MPI_Comm_size
+#endif
     integer(c_int) :: num_images_,ierr
    !num_images_ = opencoarrays_num_images(unused_coarray,unused_scalar)
     call MPI_Comm_size(CAF_COMM_WORLD,num_images_,ierr)
diff --git a/src/libcaf.h b/src/libcaf.h
index cd7edbd..166c618 100644
--- a/src/libcaf.h
+++ b/src/libcaf.h
@@ -73,10 +73,20 @@ typedef enum caf_register_t {
   CAF_REGTYPE_LOCK_ALLOC,
   CAF_REGTYPE_CRITICAL,
   CAF_REGTYPE_EVENT_STATIC,
-  CAF_REGTYPE_EVENT_ALLOC
+  CAF_REGTYPE_EVENT_ALLOC,
+  CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY,
+  CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
 }
 caf_register_t;
 
+/* Describes the action to take on _caf_deregister. Keep in sync with
+   gcc/fortran/trans.h.  */
+typedef enum caf_deregister_t {
+  CAF_DEREGTYPE_COARRAY_DEREGISTER,
+  CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY
+}
+caf_deregister_t;
+
 typedef void* caf_token_t;
 
 
@@ -187,6 +197,13 @@ typedef struct caf_reference_t {
 #endif
 
 
+/* The following defines give the bits in the opr_flags argument to CO_REDUCE.
+  Keep in sync with the libgfortran.h file of gcc/fortran.  */
+#define GFC_CAF_BYREF      (1<<0)
+#define GFC_CAF_HIDDENLEN  (1<<1)
+#define GFC_CAF_ARG_VALUE  (1<<2)
+#define GFC_CAF_ARG_DESC   (1<<3)
+
 /* Common auxiliary functions: caf_auxiliary.c.  */
 
 bool PREFIX (is_contiguous) (gfc_descriptor_t *);
@@ -203,11 +220,12 @@ int PREFIX (num_images) (int, int);
 #ifdef GCC_GE_7
 void PREFIX (register) (size_t, caf_register_t, caf_token_t *,
 						gfc_descriptor_t *, int *, char *, int);
+void PREFIX (deregister) (caf_token_t *, int, int *, char *, int);
 #else
 void * PREFIX (register) (size_t, caf_register_t, caf_token_t *,
 						  int *, char *, int);
-#endif
 void PREFIX (deregister) (caf_token_t *, int *, char *, int);
+#endif
 
 void PREFIX (caf_get) (caf_token_t, size_t, int, gfc_descriptor_t *,
 		       caf_vector_t *, gfc_descriptor_t *, int, int, int);
@@ -231,14 +249,19 @@ void PREFIX(sendget_by_ref) (caf_token_t dst_token, int dst_image_index,
 		caf_reference_t *dst_refs, caf_token_t src_token, int src_image_index,
 		caf_reference_t *src_refs, int dst_kind, int src_kind,
 		bool may_require_tmp, int *dst_stat, int *src_stat);
+int PREFIX(is_present) (caf_token_t, int, caf_reference_t *refs);
 #endif
 
+void PREFIX (co_broadcast) (gfc_descriptor_t *, int, int *, char *, int);
 void PREFIX (co_max) (gfc_descriptor_t *, int, int *, char *, int, int);
 void PREFIX (co_min) (gfc_descriptor_t *, int, int *, char *, int, int);
+void PREFIX (co_reduce) (gfc_descriptor_t *, void *(*opr) (void *, void *),
+			 int, int, int *, char *, int , int);
 void PREFIX (co_sum) (gfc_descriptor_t *, int, int *, char *, int);
 
 void PREFIX (sync_all) (int *, char *, int);
 void PREFIX (sync_images) (int, int[], int *, char *, int);
+void PREFIX (sync_memory) (int *, char *, int);
 
 void PREFIX (error_stop_str) (const char *, int32_t)
      __attribute__ ((noreturn));
diff --git a/src/make.inc b/src/make.inc
index 1ac5322..73a1e0b 100644
--- a/src/make.inc
+++ b/src/make.inc
@@ -1,11 +1,62 @@
+# make.inc
+#
+# -- This make include file defines variables for use in the OpenCoarrays 
+#    static Makefile.  Please edit this file before using the Makefile.)
+#
+# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
+# Copyright (c) 2015-2016, Sourcery, Inc.
+# Copyright (c) 2015-2016, Sourcery Institute
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice, this
+#    list of conditions and the following disclaimer in the documentation and/or
+#    other materials provided with the distribution.
+# 3. Neither the names of the copyright holders nor the names of their contributors
+#    may be used to endorse or promote products derived from this software without
+#    specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+# Edit the following line to choose the compiler (Options: gnu, cray)
+compiler=gnu
+
+ifeq ($(compiler),gnu)
+  FC=gfortran
+  CC=gcc
+  MPFC = mpif90
+  MPICC = mpicc
+  FFLAGS_EXTRA = -fcoarray=lib
+  MPI_EXTRA_FLAGS = -Wall -Wextra -Wno-error=cpp -Wno-error=unused-parameter -DSTRIDED#-DNONBLOCKING_PUT -DCAF_MPI_LOCK_UNLOCK
+  MPI_RUN = mpirun -np 2
+else
+  ifeq ($(compiler),cray)
+    FC=ftn
+    CC=cc
+    MPFC=ftn
+    MPICC = cc
+  endif
+endif
+
 PREFIX_NAME=_gfortran_caf_
-FC=gfortran
-CC=gcc
-MPFC=mpifort
 
 FFLAGS = -O2 -g
 CFLAGS = -O2 -g
-FFLAGS_EXTRA = -fcoarray=lib
+
 CFLAGS_EXTRA = -DPREFIX_NAME=$(PREFIX_NAME) -DHAVE_INT128_T
 FFLAGS += $(FFLAGS_EXTRA)
 CFLAGS += $(CFLAGS_EXTRA)
@@ -13,12 +64,11 @@ LDFLAGS +=
 
 SINGLE_CFLAGS += -Wall -Wextra
 
-MPI_EXTRA_FLAGS = -Wall -Wextra -Wno-error=cpp -Wno-error=unused-parameter -DSTRIDED#-DNONBLOCKING_PUT -DCAF_MPI_LOCK_UNLOCK
+MPI_EXTRA_FLAGS = -DSTRIDED # -DNONBLOCKING_PUT -DCAF_MPI_LOCK_UNLOCK
 MPI_CFLAGS += $(MPI_EXTRA_FLAGS)
-#MPICC =
-MPI_RUN = mpirun -np 2
 
-GASNET_CFLAGS += #-DSTRIDED
-GASNET_MAK = /home/rouson/Downloads/GASNet-1.22.4/smp-conduit/smp-par.mak
+GASNET_CFLAGS += # -DSTRIDED
+GASNET_PATH =
+GASNET_MAK = $(GASNET_PATH)/GASNet-1.22.4/smp-conduit/smp-par.mak
 GASNET_LDFLAGS +=$(GASNET_LIBS)
 GASNET_RUN = mpirun -np 2
diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt
index 029991e..6f4490b 100644
--- a/src/mpi/CMakeLists.txt
+++ b/src/mpi/CMakeLists.txt
@@ -1,6 +1,14 @@
 set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod)
 
-find_package(MPI REQUIRED)
+if (NOT MPI_C_FOUND)
+  find_package(MPI REQUIRED)
+
+  set(CMAKE_C_COMPILE_FLAGS ${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS})
+  set(CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS})
+  set(CMAKE_Fortran_COMPILE_FLAGS ${CMAKE_Fortran_COMPILE_FLAGS} ${MPI_Fortran_COMPILE_FLAGS})
+  set(CMAKE_Fortran_LINK_FLAGS ${CMAKE_Fortran_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS})
+  include_directories(BEFORE ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH})
+endif()
 
 if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
   set(gfortran_compiler true)
@@ -15,9 +23,29 @@ if(gfortran_compiler AND (NOT opencoarrays_aware_compiler))
   add_definitions(-DCOMPILER_SUPPORTS_CAF_INTRINSICS)
 endif()
 
-add_library(caf_mpi mpi_caf.c ../common/caf_auxiliary.c ../extensions/opencoarrays.F90)
+option(CAF_EXPOSE_INIT_FINALIZE "Expose caf_init and caf_finalize in opencoarrays module" FALSE)
+if(CAF_EXPOSE_INIT_FINALIZE)
+  add_definitions(-DEXPOSE_INIT_FINALIZE)
+endif()
+
+# Determine whether and how to include OpenCoarrays module based on if the Fortran MPI compiler:
+#   - workds
+#   - is compatible with the fortran compiler used to build the MPI implementation
+if (MPI_Fortran_MODULE_COMPILES)
+  # likely the same compiler compiled MPI
+  set(MPI_CAF_FORTRAN_FILES ../extensions/opencoarrays.F90)
+endif()
+
+add_library(caf_mpi mpi_caf.c ../common/caf_auxiliary.c ${MPI_CAF_FORTRAN_FILES})
+target_link_libraries(caf_mpi PRIVATE ${MPI_C_LIBRARIES} ${MPI_Fortran_LIBRARIES})
+
+set_target_properties ( caf_mpi
+  PROPERTIES
+  SOVERSION ${PROJECT_VERSION.MAJOR}.${PROJECT_VERSION.MINOR}
+  VERSION ${PROJECT_VERSION}
+  )
+
 
-target_include_directories(caf_mpi PRIVATE ${MPI_C_INCLUDE_PATH})
 if (gfortran_compiler)
   target_compile_options(caf_mpi INTERFACE -fcoarray=lib)
 endif()
@@ -25,9 +53,22 @@ endif()
 include_directories(${CMAKE_BINARY_DIR}/mod)
 
 install(TARGETS caf_mpi EXPORT OpenCoarraysTargets
-  ARCHIVE DESTINATION lib
+  ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+)
+
+# Install modules to standard include dir, but namespace them with compiler/version
+set (mod_install "OpenCoarrays/${CMAKE_Fortran_COMPILER_ID}/${CMAKE_Fortran_COMPILER_VERSION}")
+install(DIRECTORY  "${CMAKE_BINARY_DIR}/mod/"
+  DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${mod_install}"
+  FILES_MATCHING PATTERN "*.mod"
 )
-install(DIRECTORY  ${CMAKE_BINARY_DIR}/mod DESTINATION .)
+
+# Now add a link in standard include dir so that compilers will find by default... this may or may not actually be a good idea...
+if ( "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU" )
+  INSTALL(CODE "execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${mod_install}/opencoarrays.mod \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_INCLUDEDIR}/opencoarrays.mod )"
+  )
+endif ()
 
 # Now we write the script that passes CAF source to the compiler with the necessary arguments
 # and, if necessary, performs some code transformations prior to invoking the compiler.
@@ -35,13 +76,13 @@ set(exe_dir ${CMAKE_BINARY_DIR}/bin_staging)
 set(compiler_wrapper ${exe_dir}/caf)
 install(
     FILES "${compiler_wrapper}"
-    PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
-    DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/
+    PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ
+    DESTINATION "${CMAKE_INSTALL_BINDIR}"
 )
 file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/caf-head CAF_HEADER)
 file(WRITE  "${compiler_wrapper}" "${CAF_HEADER}\n")
-file(APPEND "${compiler_wrapper}"  "caf_mod_dir=${CMAKE_INSTALL_PREFIX}/mod\n")
-file(APPEND "${compiler_wrapper}"  "caf_lib_dir=${CMAKE_INSTALL_PREFIX}/lib\n")
+file(APPEND "${compiler_wrapper}"  "caf_mod_dir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}/mod\"\n")
+file(APPEND "${compiler_wrapper}"  "caf_lib_dir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n")
 file(APPEND "${compiler_wrapper}"  "caf_version=${PROJECT_VERSION}\n")
 if(gfortran_compiler)
   file(APPEND "${compiler_wrapper}"  "link_args='-fcoarray=lib -lcaf_mpi'\n")
@@ -55,7 +96,7 @@ else()
 endif()
 
 if ( DEFINED ENV{FC} )
-  file(APPEND "${compiler_wrapper}"  "CAFC=$ENV{FC}\n")
+  file(APPEND "${compiler_wrapper}"  "CAFC=${MPI_Fortran_COMPILER}\n")
 endif ()
 
 if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
@@ -68,17 +109,15 @@ file(APPEND "${compiler_wrapper}" "${FOOTER}")
 set(caf_launcher ${exe_dir}/cafrun)
 install(
     FILES "${caf_launcher}"
-    PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
-    DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
+    PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ
+    DESTINATION "${CMAKE_INSTALL_BINDIR}"
 )
 file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/cafrun-head CAFRUN_HEADER)
 file(WRITE  "${caf_launcher}" "${CAFRUN_HEADER}\n")
 file(APPEND "${caf_launcher}"  "caf_version=${PROJECT_VERSION}\n")
+file(APPEND "${caf_launcher}"  "CAFRUN=${MPIEXEC}\n")
 
 file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../extensions/cafrun-foot FOOTER)
 file(APPEND "${caf_launcher}" "${FOOTER}")
 
-# This could be needed to produce shared libraries:
-#target_link_libraries(caf_mpi PRIVATE ${MPI_C_LIBRARIES})
-
 #set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${exe_dir}/cafrun;${exe_dir}/caf;${exe_dir}/test-caf-tally.sh")
diff --git a/src/mpi/mpi_caf.c b/src/mpi/mpi_caf.c
index f1316e2..a0f496f 100644
--- a/src/mpi/mpi_caf.c
+++ b/src/mpi/mpi_caf.c
@@ -49,10 +49,32 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */
 
 
 #ifdef GCC_GE_7
+/** The caf-token of the mpi-library.
+
+Objects of this data structure are owned by the library and are treated as a
+black box by the compiler.  In the coarray-program the tokens are opaque
+pointers, i.e. black boxes.
+
+For each coarray (allocatable|save|pointer) (scalar|array|event|lock) a token
+needs to be present.  For components of derived type coarrays a token is
+needed only when the component has the allocatable or pointer attribute.
+*/
 typedef struct mpi_caf_token_t
 {
+  /** The pointer to memory associated to this token's data on the local image.
+  The compiler uses the address for direct access to the memory of the object
+  this token is assocated to, i.e., the memory pointed to be local_memptr is
+  the scalar or array.
+  When the library is responsible for deleting the memory, then this is the one
+  to free.  */
   void *local_memptr;
+  /** The MPI window to associated to the object's data.
+  The window is used to access the data on other images. In pre GCC_GE_7
+  installations this was the token.  */
   MPI_Win memptr;
+  /** When the object this token is associated to is an array, than this
+  window gives access to the descriptor on remote images. When the object is
+  scalar, then this is NULL.  */
   MPI_Win *desc;
 } mpi_caf_token_t;
 #define TOKEN(X) &(((mpi_caf_token_t *) (X))->memptr)
@@ -75,8 +97,8 @@ static int caf_is_finalized = 0;
 /*Sync image part*/
 
 static int *orders;
-MPI_Request *handlers;
 static int *images_full;
+MPI_Request *sync_handles;
 static int *arrived;
 
 /* Pending puts */
@@ -96,8 +118,8 @@ caf_static_t *caf_tot = NULL;
 
 /* Image status variable */
 
-static int *img_status = NULL;
-MPI_Win *stat_tok;
+static int img_status = 0;
+static MPI_Win *stat_tok;
 
 /* Active messages variables */
 
@@ -119,10 +141,38 @@ MPI_Comm CAF_COMM_WORLD;
    (and thus finalization) of MPI. */
 bool caf_owns_mpi = false;
 
-/* Foo function pointers for coreduce */
-int (*foo_int32_t)(void *, void *);
-float (*foo_float)(void *, void *);
-double (*foo_double)(void *, void *);
+/* Foo function pointers for coreduce.
+  The handles when arguments are passed by reference.  */
+int (*int32_t_by_reference)(void *, void *);
+float (*float_by_reference)(void *, void *);
+double (*double_by_reference)(void *, void *);
+/* Strings are always passed by reference.  */
+void (*char_by_reference)(void *, int, void *, void *, int, int);
+/* The handles when arguments are passed by value.  */
+int (*int32_t_by_value)(int32_t, int32_t);
+float (*float_by_value)(float, float);
+double (*double_by_value)(double, double);
+
+/* Define shortcuts for Win_lock and _unlock depending on whether the primitives
+   are available in the MPI implementation.  When they are not available the
+   shortcut is expanded to nothing by the preprocessor else to the API call.
+   This prevents having #ifdef #else #endif constructs strewn all over the code
+   reducing its readability.  */
+#ifdef CAF_MPI_LOCK_UNLOCK
+#define CAF_Win_lock(type, img, win) MPI_Win_lock (type, img, 0, win)
+#define CAF_Win_unlock(img, win) MPI_Win_unlock (img, win)
+#define CAF_Win_lock_all(win)
+#define CAF_Win_unlock_all(win)
+#else //CAF_MPI_LOCK_UNLOCK
+#define CAF_Win_lock(type, img, win)
+#define CAF_Win_unlock(img, win) MPI_Win_flush (img, win)
+#if MPI_VERSION >= 3
+#define CAF_Win_lock_all(win) MPI_Win_lock_all (MPI_MODE_NOCHECK, win)
+#else
+#define CAF_Win_lock_all(win)
+#endif
+#define CAF_Win_unlock_all(win) MPI_Win_unlock_all (win)
+#endif //CAF_MPI_LOCK_UNLOCK
 
 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
 
@@ -218,16 +268,10 @@ caf_runtime_error (const char *message, ...)
 /* inline */ void locking_atomic_op(MPI_Win win, int *value, int newval,
 			      int compare, int image_index, int index)
 {
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, win);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, win);
       MPI_Compare_and_swap (&newval,&compare,value, MPI_INT,image_index-1,
                             index*sizeof(int), win);
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image_index-1, win);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image_index-1, win);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock (image_index-1, win);
 }
 
 void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
@@ -290,15 +334,9 @@ void mutex_unlock(MPI_Win win, int image_index, int index, int *stat,
 
   /* locking_atomic_op(win, &value, newval, compare, image_index, index); */
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, win);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, win);
   MPI_Fetch_and_op(&newval, &value, MPI_INT, image_index-1, index*sizeof(int), MPI_REPLACE, win);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image_index-1, win);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image_index-1, win);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image_index-1, win);
 
   if(value == 0)
     goto stat_error;
@@ -386,7 +424,7 @@ PREFIX (init) (int *argc, char ***argv)
       orders = calloc (caf_num_images, sizeof (int));
       arrived = calloc (caf_num_images, sizeof (int));
 
-      handlers = malloc(caf_num_images * sizeof(MPI_Request));
+      sync_handles = malloc(caf_num_images * sizeof(MPI_Request));
 
       stat_tok = malloc (sizeof(MPI_Win));
 
@@ -394,19 +432,20 @@ PREFIX (init) (int *argc, char ***argv)
       MPI_Info_create (&mpi_info_same_size);
       MPI_Info_set (mpi_info_same_size, "same_size", "true");
       /* Setting img_status */
-      MPI_Win_allocate(sizeof(int), 1, mpi_info_same_size, CAF_COMM_WORLD, &img_status, stat_tok);
-# ifndef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock_all(MPI_MODE_NOCHECK, *stat_tok);
-# endif // CAF_MPI_LOCK_UNLOCK
+      MPI_Win_create(&img_status, sizeof(int), 1, mpi_info_same_size, CAF_COMM_WORLD, stat_tok);
+      CAF_Win_lock_all (*stat_tok);
 #else
-      MPI_Alloc_mem(sizeof(int), MPI_INFO_NULL, &img_status, stat_tok);
-      MPI_Win_create(img_status, sizeof(int), 1, MPI_INFO_NULL, CAF_COMM_WORLD, stat_tok);
+      MPI_Win_create(&img_status, sizeof(int), 1, MPI_INFO_NULL, CAF_COMM_WORLD, stat_tok);
 #endif // MPI_VERSION
-      *img_status = 0;
     }
   /* MPI_Barrier(CAF_COMM_WORLD); */
 }
 
+/* Forward declaration of sync_images.  */
+
+void
+sync_images_internal (int count, int images[], int *stat, char *errmsg,
+                      int errmsg_len, bool internal);
 
 /* Finalize coarray program.   */
 
@@ -417,10 +456,17 @@ _gfortran_caf_finalize (void)
 PREFIX (finalize) (void)
 #endif
 {
-  *img_status = STAT_STOPPED_IMAGE; /* GFC_STAT_STOPPED_IMAGE = 6000 */
-  MPI_Win_sync(*stat_tok);
+  /* For future security enclose setting img_status in a lock.  */
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, caf_this_image - 1, *stat_tok);
+  img_status = STAT_STOPPED_IMAGE; /* GFC_STAT_STOPPED_IMAGE = 6000 */
+  CAF_Win_unlock (caf_this_image - 1, *stat_tok);
+
+  /* Announce to all other images, that this one is stopped.  */
+  for (int i = 0; i < caf_num_images - 1; ++i)
+    MPI_Send (&img_status, 1, MPI_INT, images_full[i] - 1, 0, CAF_COMM_WORLD);
 
-  MPI_Barrier(CAF_COMM_WORLD);
+  /* Add a conventional barrier to prevent images from quitting to early.  */
+  MPI_Barrier (CAF_COMM_WORLD);
 
   while (caf_static_list != NULL)
     {
@@ -437,25 +483,18 @@ PREFIX (finalize) (void)
     {
       prev = tmp_tot->prev;
       p = TOKEN(tmp_tot->token);
+      CAF_Win_unlock_all (*p);
 #ifdef GCC_GE_7
-# ifndef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock_all(*p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      /* Unregister the window to the descriptors when freeing the token.  */
       if (((mpi_caf_token_t *)tmp_tot->token)->desc)
 	{
 	  mpi_caf_token_t *mpi_token = (mpi_caf_token_t *)tmp_tot->token;
-# ifndef CAF_MPI_LOCK_UNLOCK
-	  MPI_Win_unlock_all(*(mpi_token->desc));
-# endif // CAF_MPI_LOCK_UNLOCK
+	  CAF_Win_unlock_all(*(mpi_token->desc));
 	  MPI_Win_free (mpi_token->desc);
 	  free (mpi_token->desc);
 	}
-#else
-# ifndef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock_all(*p);
-# endif // CAF_MPI_LOCK_UNLOCK
+#endif // GCC_GE_7
       MPI_Win_free(p);
-#endif
       free(tmp_tot);
       tmp_tot = prev;
     }
@@ -463,6 +502,8 @@ PREFIX (finalize) (void)
   MPI_Info_free (&mpi_info_same_size);
 #endif // MPI_VERSION
 
+  CAF_Win_unlock_all (*stat_tok);
+  MPI_Win_free (stat_tok);
   MPI_Comm_free(&CAF_COMM_WORLD);
 
   /* Only call Finalize if CAF runtime Initialized MPI. */
@@ -472,7 +513,7 @@ PREFIX (finalize) (void)
   pthread_mutex_lock(&lock_am);
   caf_is_finalized = 1;
   pthread_mutex_unlock(&lock_am);
-  exit(0);
+  free (sync_handles);
 }
 
 
@@ -492,25 +533,153 @@ PREFIX (num_images)(int distance __attribute__ ((unused)),
 
 
 #ifdef GCC_GE_7
-#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
-void
-  _gfortran_caf_register (size_t size, caf_register_t type, caf_token_t *token,
-                gfc_descriptor_t *desc, int *stat, char *errmsg, int errmsg_len)
-#else
+/** Register an object with the coarray library creating a token where
+    necessary/requested.
+
+    See the ABI-documentation of gfortran for the expected behavior.
+    Contrary to this expected behavior is this routine not registering memory
+    in the descriptor, that is already present.  I.e., when the compiler
+    expects the library to allocate the memory for an object in desc, then
+    its data_ptr is NULL. This is still missing here.  At the moment the
+    compiler also does not make use of it, but it is contrary to the
+    documentation.
+    */
 void
-  PREFIX (register) (size_t size, caf_register_t type, caf_token_t *token,
-                gfc_descriptor_t *desc, int *stat, char *errmsg, int errmsg_len)
-#endif
-#else
+PREFIX (register) (size_t size, caf_register_t type, caf_token_t *token,
+                   gfc_descriptor_t *desc, int *stat, char *errmsg,
+		   int errmsg_len)
+{
+  /* int ierr; */
+  void *mem;
+  size_t actual_size;
+  int l_var=0, *init_array=NULL;
+
+  if (unlikely (caf_is_finalized))
+    goto error;
+
+  /* Start GASNET if not already started.  */
+  if (caf_num_images == 0)
+    PREFIX (init) (NULL, NULL);
+
+  if(type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC ||
+     type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC ||
+     type == CAF_REGTYPE_EVENT_ALLOC)
+    {
+      actual_size = size * sizeof(int);
+      l_var = 1;
+    }
+  else
+    actual_size = size;
+
+  mpi_caf_token_t *mpi_token;
+  MPI_Win *p;
+  /* The token has to be present, when COARRAY_ALLOC_ALLOCATE_ONLY is
+     specified.  */
+  if (type != CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY)
+    *token = malloc (sizeof (mpi_caf_token_t));
+
+  mpi_token = (mpi_caf_token_t *) *token;
+  p = TOKEN(mpi_token);
+
+  if ((type == CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
+       || type == CAF_REGTYPE_COARRAY_ALLOC
+       || type == CAF_REGTYPE_COARRAY_STATIC)
+      && GFC_DESCRIPTOR_RANK (desc) != 0)
+    {
+      /* Add a window for the descriptor when an array is registered.  */
+      int ierr;
+      size_t desc_size = sizeof (gfc_descriptor_t) + /*GFC_DESCRIPTOR_RANK (desc)*/
+	  GFC_MAX_DIMENSIONS * sizeof (descriptor_dimension);
+      mpi_token->desc = (MPI_Win *)malloc (sizeof (MPI_Win));
+      ierr = MPI_Win_create (desc, desc_size, 1, mpi_info_same_size,
+			     CAF_COMM_WORLD, mpi_token->desc);
+      CAF_Win_lock_all (*(mpi_token->desc));
+    }
+  else
+    mpi_token->desc = NULL;
+
+#if MPI_VERSION >= 3
+  if (type != CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY)
+    {
+      // Note, MPI_Win_allocate implicitly synchronizes.
+      MPI_Win_allocate (actual_size, 1, MPI_INFO_NULL, CAF_COMM_WORLD, &mem, p);
+      CAF_Win_lock_all (*p);
+    }
+  else
+    mem = NULL;
+#else // MPI_VERSION
+  MPI_Alloc_mem(actual_size, MPI_INFO_NULL, &mem);
+  MPI_Win_create(mem, actual_size, 1, MPI_INFO_NULL, CAF_COMM_WORLD, p);
+#endif // MPI_VERSION
+
+  if(l_var)
+    {
+      init_array = (int *)calloc(size, sizeof(int));
+      CAF_Win_lock (MPI_LOCK_EXCLUSIVE, caf_this_image - 1, *p);
+      MPI_Put (init_array, size, MPI_INT, caf_this_image-1,
+                      0, size, MPI_INT, *p);
+      CAF_Win_unlock (caf_this_image - 1, *p);
+      free(init_array);
+    }
+
+  if (type != CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY)
+    {
+      caf_static_t *tmp = malloc (sizeof (caf_static_t));
+      tmp->prev  = caf_tot;
+      tmp->token = *token;
+      caf_tot = tmp;
+    }
+
+  if (type == CAF_REGTYPE_COARRAY_STATIC)
+    {
+      caf_static_t *tmp = malloc (sizeof (caf_static_t));
+      tmp->prev  = caf_static_list;
+      tmp->token = *token;
+      caf_static_list = tmp;
+    }
+
+  if (stat)
+    *stat = 0;
+
+  /* The descriptor will be initialized only after the call to register.  */
+  mpi_token->local_memptr = mem;
+  desc->base_addr = mem;
+  return;
+
+error:
+  {
+    char *msg;
+
+    if (caf_is_finalized)
+      msg = "Failed to allocate coarray - there are stopped images";
+    else
+      msg = "Failed to allocate coarray";
+
+    if (stat)
+      {
+        *stat = caf_is_finalized ? STAT_STOPPED_IMAGE : 1;
+        if (errmsg_len > 0)
+          {
+            int len = ((int) strlen (msg) > errmsg_len) ? errmsg_len
+                                                        : (int) strlen (msg);
+            memcpy (errmsg, msg, len);
+            if (errmsg_len > len)
+              memset (&errmsg[len], ' ', errmsg_len-len);
+          }
+      }
+    else
+      caf_runtime_error (msg);
+  }
+}
+#else // GCC_GE_7
 #ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
 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, int errmsg_len)
 #else
 void *
   PREFIX (register) (size_t size, caf_register_t type, caf_token_t *token,
-                int *stat, char *errmsg, int errmsg_len)
-#endif
+                     int *stat, char *errmsg, int errmsg_len)
 #endif
 {
   /* int ierr; */
@@ -539,39 +708,13 @@ void *
   else
     actual_size = size;
 
-#ifdef GCC_GE_7
-  *token = malloc (sizeof (mpi_caf_token_t));
-  mpi_caf_token_t *mpi_token = (mpi_caf_token_t *) *token;
-  MPI_Win *p = TOKEN(mpi_token);
-  if (GFC_DESCRIPTOR_RANK (desc) == 0)
-    mpi_token->desc = NULL;
-  else
-    {
-      int ierr;
-      size_t desc_size = sizeof (gfc_descriptor_t) + /*GFC_DESCRIPTOR_RANK (desc)*/
-	  GFC_MAX_DIMENSIONS * sizeof (descriptor_dimension);
-      mpi_token->desc = (MPI_Win *)malloc (sizeof (MPI_Win));
-      ierr = MPI_Win_create (desc, desc_size, 1, mpi_info_same_size,
-		             CAF_COMM_WORLD, mpi_token->desc);
-#if MPI_VERSION >= 3 && !defined(CAF_MPI_LOCK_UNLOCK)
-      MPI_Win_lock_all(MPI_MODE_NOCHECK, *(mpi_token->desc));
-# endif
-    }
-#else
   /* Token contains only a list of pointers.  */
   *token = malloc (sizeof(MPI_Win));
   MPI_Win *p = *token;
-#endif
 
 #if MPI_VERSION >= 3
-#ifdef GCC_GE_7
-  MPI_Win_allocate(actual_size, 1, MPI_INFO_NULL, CAF_COMM_WORLD, &mem, p);
-#else
   MPI_Win_allocate(actual_size, 1, mpi_info_same_size, CAF_COMM_WORLD, &mem, p);
-#endif
-# ifndef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock_all(MPI_MODE_NOCHECK, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock_all (*p);
 #else // MPI_VERSION
   MPI_Alloc_mem(actual_size, MPI_INFO_NULL, &mem);
   MPI_Win_create(mem, actual_size, 1, MPI_INFO_NULL, CAF_COMM_WORLD, p);
@@ -580,16 +723,10 @@ void *
   if(l_var)
     {
       init_array = (int *)calloc(size, sizeof(int));
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock(MPI_LOCK_EXCLUSIVE, caf_this_image-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_lock(MPI_LOCK_EXCLUSIVE, caf_this_image-1, *p);
       MPI_Put (init_array, size, MPI_INT, caf_this_image-1,
                       0, size, MPI_INT, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock(caf_this_image-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush(caf_this_image-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock(caf_this_image-1, *p);
       free(init_array);
     }
 
@@ -602,7 +739,7 @@ void *
 
   if (type == CAF_REGTYPE_COARRAY_STATIC)
     {
-      tmp = malloc (sizeof (caf_static_t));
+      caf_static_t *tmp = malloc (sizeof (caf_static_t));
       tmp->prev  = caf_static_list;
       tmp->token = *token;
       caf_static_list = tmp;
@@ -611,14 +748,7 @@ void *
   if (stat)
     *stat = 0;
 
-#ifdef GCC_GE_7
-  /* The descriptor will be initialized only after the call to register.  */
-  mpi_token->local_memptr = mem;
-  desc->base_addr = mem;
-  return;
-#else
   return mem;
-#endif
 
 error:
   {
@@ -644,14 +774,19 @@ error:
     else
       caf_runtime_error (msg);
   }
-#ifndef GCC_GE_7
   return NULL;
-#endif
 }
+#endif
 
 
+#ifdef GCC_GE_7
+void
+PREFIX (deregister) (caf_token_t *token, int type, int *stat, char *errmsg,
+		     int errmsg_len)
+#else
 void
 PREFIX (deregister) (caf_token_t *token, int *stat, char *errmsg, int errmsg_len)
+#endif
 {
   /* int ierr; */
 
@@ -688,20 +823,23 @@ PREFIX (deregister) (caf_token_t *token, int *stat, char *errmsg, int errmsg_len
       if(tmp->token == *token)
         {
           p = TOKEN(*token);
-# ifndef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_unlock_all(*p);
-# endif // CAF_MPI_LOCK_UNLOCK
-          MPI_Win_free(p);
+          CAF_Win_unlock_all(*p);
 #ifdef GCC_GE_7
-	  if ((*(mpi_caf_token_t **)token)->desc)
+	  mpi_caf_token_t *mpi_token = *(mpi_caf_token_t **)token;
+	  if (mpi_token->local_memptr)
+	    {
+	      MPI_Win_free(p);
+	      mpi_token->local_memptr = NULL;
+	    }
+	  if ((*(mpi_caf_token_t **)token)->desc
+	      && type != CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY)
 	    {
-	      mpi_caf_token_t *mpi_token = *(mpi_caf_token_t **)token;
-# ifndef CAF_MPI_LOCK_UNLOCK
-	      MPI_Win_unlock_all(*(mpi_token->desc));
-# endif // CAF_MPI_LOCK_UNLOCK
+	      CAF_Win_unlock_all(*(mpi_token->desc));
 	      MPI_Win_free (mpi_token->desc);
 	      free (mpi_token->desc);
 	    }
+#else
+          MPI_Win_free(p);
 #endif
 
           if(prev)
@@ -865,23 +1003,15 @@ PREFIX (sendget) (caf_token_t token_s, size_t offset_s, int image_index_s,
     {
       tmp = (char *) calloc (size, dst_size);
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_SHARED, image_index_g-1, 0, *p_g);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index_g - 1, *p_g);
       ierr = MPI_Get (tmp, dst_size*size, MPI_BYTE,
                       image_index_g-1, offset_g, dst_size*size, MPI_BYTE, *p_g);
       if (pad_str)
         memcpy ((char *) tmp + src_size, pad_str,
                 dst_size-src_size);
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image_index_g-1, *p_g);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image_index_g-1, *p_g);
-# endif // CAF_MPI_LOCK_UNLOCK
-
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index_s-1, 0, *p_s);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock (image_index_g-1, *p_g);
+
+      CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index_s - 1, *p_s);
       if (GFC_DESCRIPTOR_TYPE (dest) == GFC_DESCRIPTOR_TYPE (src)
           && dst_kind == src_kind)
         ierr = MPI_Put (tmp, dst_size*size, MPI_BYTE,
@@ -891,11 +1021,7 @@ PREFIX (sendget) (caf_token_t token_s, size_t offset_s, int image_index_s,
       if (pad_str)
         ierr = MPI_Put (pad_str, dst_size-src_size, MPI_BYTE, image_index_s-1,
                         offset_s, dst_size - src_size, MPI_BYTE, *p_s);
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image_index_s-1, *p_s);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image_index_s-1, *p_s);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock (image_index_s - 1, *p_s);
 
       if (ierr != 0)
         error_stop (ierr);
@@ -912,18 +1038,19 @@ PREFIX (sendget) (caf_token_t token_s, size_t offset_s, int image_index_s,
           ptrdiff_t array_offset_dst = 0;
           ptrdiff_t stride = 1;
           ptrdiff_t extent = 1;
+	  ptrdiff_t tot_ext = 1;
           for (j = 0; j < rank-1; j++)
             {
-              array_offset_dst += ((i / (extent*stride))
+              array_offset_dst += ((i / tot_ext)
                                    % (dest->dim[j]._ubound
                                       - dest->dim[j].lower_bound + 1))
                 * dest->dim[j]._stride;
               extent = (dest->dim[j]._ubound - dest->dim[j].lower_bound + 1);
               stride = dest->dim[j]._stride;
+	      tot_ext *= extent;
             }
 
-	  extent = (dest->dim[rank-1]._ubound - dest->dim[rank-1].lower_bound + 1);
-          array_offset_dst += (i / extent) * dest->dim[rank-1]._stride;
+	  array_offset_dst += (i / tot_ext) * dest->dim[rank-1]._stride;
           dst_offset = offset_s + array_offset_dst*GFC_DESCRIPTOR_SIZE (dest);
 
           ptrdiff_t array_offset_sr = 0;
@@ -931,50 +1058,35 @@ PREFIX (sendget) (caf_token_t token_s, size_t offset_s, int image_index_s,
             {
               stride = 1;
               extent = 1;
+	      tot_ext = 1;
               for (j = 0; j < GFC_DESCRIPTOR_RANK (src)-1; j++)
                 {
-                  array_offset_sr += ((i / (extent*stride))
+                  array_offset_sr += ((i / tot_ext)
                                       % (src->dim[j]._ubound
                                          - src->dim[j].lower_bound + 1))
                     * src->dim[j]._stride;
                   extent = (src->dim[j]._ubound - src->dim[j].lower_bound + 1);
                   stride = src->dim[j]._stride;
+		  tot_ext *= extent;
                 }
 
-	      extent = (src->dim[rank-1]._ubound - src->dim[rank-1].lower_bound + 1);
-              array_offset_sr += (i / extent) * src->dim[rank-1]._stride;
+              array_offset_sr += (i / tot_ext) * src->dim[rank-1]._stride;
               array_offset_sr *= GFC_DESCRIPTOR_SIZE (src);
             }
           src_offset = offset_g + array_offset_sr;
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_lock (MPI_LOCK_SHARED, image_index_g-1, 0, *p_g);
-# endif // CAF_MPI_LOCK_UNLOCK
-
+          CAF_Win_lock (MPI_LOCK_SHARED, image_index_g - 1, *p_g);
           ierr = MPI_Get (tmp, dst_size, MPI_BYTE,
                           image_index_g-1, src_offset, src_size, MPI_BYTE, *p_g);
+          CAF_Win_unlock (image_index_g - 1, *p_g);
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_unlock (image_index_g-1, *p_g);
-# else // CAF_MPI_LOCK_UNLOCK
-          MPI_Win_flush (image_index_g-1, *p_g);
-# endif // CAF_MPI_LOCK_UNLOCK
-
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index_s-1, 0, *p_s);
-# endif // CAF_MPI_LOCK_UNLOCK
-
+          CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index_s - 1, *p_s);
           ierr = MPI_Put (tmp, GFC_DESCRIPTOR_SIZE (dest), MPI_BYTE, image_index_s-1,
                           dst_offset, GFC_DESCRIPTOR_SIZE (dest), MPI_BYTE, *p_s);
           if (pad_str)
             ierr = MPI_Put (pad_str, dst_size - src_size, MPI_BYTE, image_index_s-1,
                             dst_offset, dst_size - src_size, MPI_BYTE, *p_s);
-
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_unlock (image_index_s-1, *p_s);
-# else // CAF_MPI_LOCK_UNLOCK
-          MPI_Win_flush (image_index_s-1, *p_s);
-# endif // CAF_MPI_LOCK_UNLOCK
+          CAF_Win_unlock (image_index_s - 1, *p_s);
 
           if (ierr != 0)
             {
@@ -1050,9 +1162,7 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
         }
       else
         {
-#ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, *p);
-#endif // CAF_MPI_LOCK_UNLOCK
+          CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index - 1, *p);
           if (GFC_DESCRIPTOR_TYPE (dest) == GFC_DESCRIPTOR_TYPE (src)
               && dst_kind == src_kind)
             ierr = MPI_Put (src->base_addr, (dst_size > src_size ? src_size : dst_size)*size, MPI_BYTE,
@@ -1183,15 +1293,9 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
 
       dst_offset = offset;
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index - 1, *p);
       ierr = MPI_Put (sr, 1, dt_s, image_index-1, dst_offset, 1, dt_d, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image_index-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image_index-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock (image_index - 1, *p);
 
       if (ierr != 0)
         {
@@ -1260,9 +1364,7 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
           buff_map = calloc(size,sizeof(bool));
         }
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index - 1, *p);
       for (i = 0; i < size; i++)
         {
           ptrdiff_t array_offset_dst = 0;
@@ -1364,11 +1466,7 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
           free(t_buff);
           free(buff_map);
         }
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image_index-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image_index-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+      CAF_Win_unlock (image_index - 1, *p);
 #endif
     }
 }
@@ -1435,19 +1533,13 @@ PREFIX (get) (caf_token_t token, size_t offset,
         }
       else
         {
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_lock (MPI_LOCK_SHARED, image_index-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+          CAF_Win_lock (MPI_LOCK_SHARED, image_index - 1, *p);
           ierr = MPI_Get (dest->base_addr, dst_size*size, MPI_BYTE,
                           image_index-1, offset, dst_size*size, MPI_BYTE, *p);
           if (pad_str)
             memcpy ((char *) dest->base_addr + src_size, pad_str,
                     dst_size-src_size);
-# ifdef CAF_MPI_LOCK_UNLOCK
-          MPI_Win_unlock (image_index-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-          MPI_Win_flush (image_index-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+          CAF_Win_unlock (image_index - 1, *p);
         }
       if (ierr != 0)
         error_stop (ierr);
@@ -1539,17 +1631,9 @@ PREFIX (get) (caf_token_t token, size_t offset,
 
   //sr_off = offset;
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_SHARED, image_index-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
-
+  CAF_Win_lock (MPI_LOCK_SHARED, image_index - 1, *p);
   ierr = MPI_Get (dst, 1, dt_d, image_index-1, offset, 1, dt_s, *p);
-
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image_index-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image_index-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image_index - 1, *p);
 
   if (ierr != 0)
     error_stop (ierr);
@@ -1564,9 +1648,7 @@ PREFIX (get) (caf_token_t token, size_t offset,
       buff_map = calloc(size,sizeof(bool));
     }
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_SHARED, image_index-1, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_SHARED, image_index - 1, *p);
   for (i = 0; i < size; i++)
     {
       ptrdiff_t array_offset_dst = 0;
@@ -1663,11 +1745,7 @@ PREFIX (get) (caf_token_t token, size_t offset,
       free(t_buff);
       free(buff_map);
     }
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image_index-1, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image_index-1, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image_index - 1, *p);
 #endif
 }
 
@@ -1676,6 +1754,9 @@ PREFIX (get) (caf_token_t token, size_t offset,
 /* Emitted when a theorectically unreachable part is reached.  */
 const char unreachable[] = "Fatal error: unreachable alternative found.\n";
 
+/** Convert kind 4 characters into kind 1 one.
+    Copied from the gcc:libgfortran/caf/single.c.
+*/
 static void
 assign_char4_from_char1 (size_t dst_size, size_t src_size, uint32_t *dst,
 			 unsigned char *src)
@@ -1689,6 +1770,9 @@ assign_char4_from_char1 (size_t dst_size, size_t src_size, uint32_t *dst,
 }
 
 
+/** Convert kind 1 characters into kind 4 one.
+    Copied from the gcc:libgfortran/caf/single.c.
+*/
 static void
 assign_char1_from_char4 (size_t dst_size, size_t src_size, unsigned char *dst,
 			 uint32_t *src)
@@ -1701,6 +1785,10 @@ assign_char1_from_char4 (size_t dst_size, size_t src_size, unsigned char *dst,
     memset (&dst[n], ' ', dst_size - n);
 }
 
+
+/** Convert convertable types.
+    Copied from the gcc:libgfortran/caf/single.c. Can't say much about it.
+*/
 static void
 convert_type (void *dst, int dst_type, int dst_kind, void *src, int src_type,
 	      int src_kind, int *stat)
@@ -1963,15 +2051,11 @@ error:
 }
 
 
-#ifdef CAF_MPI_LOCK_UNLOCK
-#define CAF_Win_lock(img, win) MPI_Win_lock (MPI_LOCK_SHARED, img, 0, win)
-#define CAF_Win_unlock(img, win) MPI_Win_unlock (img, win)
-#else //CAF_MPI_LOCK_UNLOCK
-#define CAF_Win_lock(img, win)
-#define CAF_Win_unlock(img, win) MPI_Win_flush (img, win)
-#endif //CAF_MPI_LOCK_UNLOCK
-
+/** Copy a chunk of data from one image to the current one, with type
+    conversion.
 
+    Copied from the gcc:libgfortran/caf/single.c. Can't say much about it.
+*/
 static void
 copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
 	   int src_type, int dst_kind, int src_kind, size_t dst_size,
@@ -1981,7 +2065,7 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
   if (dst_type == src_type && dst_kind == src_kind)
     {
       size_t sz = (dst_size > src_size ? src_size : dst_size) * num;
-      CAF_Win_lock (image_index, token->memptr);
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index, token->memptr);
       MPI_Get (ds, sz, MPI_BYTE, image_index, offset, sz, MPI_BYTE,
 	       token->memptr);
       CAF_Win_unlock (image_index, token->memptr);
@@ -1999,7 +2083,7 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
     {
       /* Get the required amount of memory on the stack.  */
       void *srh = alloca (src_size);
-      CAF_Win_lock (image_index, token->memptr);
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index, token->memptr);
       MPI_Get (srh, src_size, MPI_BYTE, image_index, offset,
 	       src_size, MPI_BYTE, token->memptr);
       CAF_Win_unlock (image_index, token->memptr);
@@ -2009,7 +2093,7 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
     {
       /* Get the required amount of memory on the stack.  */
       void *srh = alloca (src_size);
-      CAF_Win_lock (image_index, token->memptr);
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index, token->memptr);
       MPI_Get (srh, src_size, MPI_BYTE, image_index, offset,
 	       src_size, MPI_BYTE, token->memptr);
       CAF_Win_unlock (image_index, token->memptr);
@@ -2019,7 +2103,7 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
     {
       /* Get the required amount of memory on the stack.  */
       void *srh = alloca (src_size * num);
-      CAF_Win_lock (image_index, token->memptr);
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index, token->memptr);
       MPI_Get (srh, src_size * num, MPI_BYTE, image_index, offset,
 	       src_size * num, MPI_BYTE, token->memptr);
       CAF_Win_unlock (image_index, token->memptr);
@@ -2033,6 +2117,10 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
 }
 
 
+/** Compute the number of items referenced.
+
+    Computes the number of items between lower bound (lb) and upper bound (ub)
+    with respect to the stride taking corner cases into account.  */
 #define COMPUTE_NUM_ITEMS(num, stride, lb, ub) \
   do { \
     ptrdiff_t abs_stride = (stride) > 0 ? (stride) : -(stride); \
@@ -2042,17 +2130,24 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
   } while (0)
 
 
+/** Convenience macro to get the extent of a descriptor in a certain dimension.
+
+    Copied from gcc:libgfortran/libgfortran.h. */
 #define GFC_DESCRIPTOR_EXTENT(desc,i) ((desc)->dim[i]._ubound + 1 \
 				      - (desc)->dim[i].lower_bound)
 
 
+/** Get a copy of the remote descriptor.
+
+    The copy of the remote descriptor is placed into memory which has to be
+    provided in src_desc_data. The pointer to the descriptor is set in src.  */
 #define GET_REMOTE_DESC(mpi_token, src, src_desc_data, image_index) \
   if (mpi_token->desc) \
     { \
       size_t desc_size = sizeof (gfc_descriptor_t) + GFC_MAX_DIMENSIONS /* rank */ \
 	* sizeof (descriptor_dimension); \
       int err; \
-      CAF_Win_lock (image_index, *(mpi_token->desc)); \
+      CAF_Win_lock (MPI_LOCK_SHARED, image_index, *(mpi_token->desc)); \
       MPI_Get (&src_desc_data, desc_size, MPI_BYTE, \
 	       image_index, 0, desc_size, MPI_BYTE, *(mpi_token->desc)); \
       err = CAF_Win_unlock (image_index, *(mpi_token->desc)); \
@@ -2062,6 +2157,10 @@ copy_data (void *ds, mpi_caf_token_t *token, ptrdiff_t offset, int dst_type,
     src = NULL
 
 
+/** Define the descriptor of max rank.
+
+    This typedef is made to allow storing a copy of a remote descriptor on the
+    stack without having to care about the rank.  */
 typedef struct gfc_max_dim_descriptor_t {
   void *base_addr;
   size_t offset;
@@ -2183,8 +2282,8 @@ get_for_ref (caf_reference_t *ref, size_t *i, size_t dst_index,
 		KINDCASE (2, int16_t);
 		KINDCASE (4, int32_t);
 		KINDCASE (8, int64_t);
-#ifdef HAVE_INT128_T
-		KINDCASE (16, int128_t);
+#ifdef HAVE_GFC_INTEGER_16
+		KINDCASE (16, __int128);
 #endif
 		default:
 		  caf_runtime_error (unreachable);
@@ -2325,8 +2424,8 @@ get_for_ref (caf_reference_t *ref, size_t *i, size_t dst_index,
 		KINDCASE (2, int16_t);
 		KINDCASE (4, int32_t);
 		KINDCASE (8, int64_t);
-#ifdef HAVE_INT128_T
-		KINDCASE (16, int128_t);
+#ifdef HAVE_GFC_INTEGER_16
+		KINDCASE (16, __int128);
 #endif
 		default:
 		  caf_runtime_error (unreachable);
@@ -2484,8 +2583,8 @@ _gfortran_caf_get_by_ref (caf_token_t token, int image_index,
 		    KINDCASE (2, int16_t);
 		    KINDCASE (4, int32_t);
 		    KINDCASE (8, int64_t);
-#if HAVE_INT128_T
-		    KINDCASE (16, int128_t);
+#if HAVE_GFC_INTEGER_16
+		    KINDCASE (16, __int128);
 #endif
 		    default:
 		      caf_runtime_error (vecrefunknownkind, stat, NULL, 0);
@@ -2671,8 +2770,8 @@ _gfortran_caf_get_by_ref (caf_token_t token, int image_index,
 		    KINDCASE (2, int16_t);
 		    KINDCASE (4, int32_t);
 		    KINDCASE (8, int64_t);
-#if HAVE_INT128_T
-		    KINDCASE (16, int128_t);
+#if HAVE_GFC_INTEGER_16
+		    KINDCASE (16, __int128);
 #endif
 		    default:
 		      caf_runtime_error (vecrefunknownkind, stat, NULL, 0);
@@ -2868,6 +2967,14 @@ PREFIX(sendget_by_ref) (caf_token_t dst_token, int dst_image_index,
   fprintf (stderr, "COARRAY ERROR: caf_sendget_by_ref() not implemented yet ");
   error_stop (1);
 }
+
+
+int
+PREFIX(is_present) (caf_token_t token, int image_index, caf_reference_t *refs)
+{
+  fprintf (stderr, "COARRAY ERROR: caf_is_present() not implemented yet ");
+  error_stop (1);
+}
 #endif
 
 
@@ -2878,7 +2985,14 @@ void
 PREFIX (sync_images) (int count, int images[], int *stat, char *errmsg,
                      int errmsg_len)
 {
-  int ierr = 0, i = 0, remote_stat = 0, j = 0;
+  sync_images_internal (count, images, stat, errmsg, errmsg_len, false);
+}
+
+void
+sync_images_internal (int count, int images[], int *stat, char *errmsg,
+                      int errmsg_len, bool internal)
+{
+  int ierr = 0, i = 0, j = 0, int_zero = 0, done_count = 0;
   MPI_Status s;
 
   if (count == 0 || (count == 1 && images[0] == caf_this_image))
@@ -2932,59 +3046,54 @@ PREFIX (sync_images) (int count, int images[], int *stat, char *errmsg,
       explicit_flush();
 #endif
 
+      /* A rather simple way to synchronice:
+	 - expect all images to sync with receiving an int,
+	 - on the other side, send all processes to sync with an int,
+	 - when the int received is STAT_STOPPED_IMAGE the return immediately,
+	   else wait until all images in the current set of images have send
+	   some data, i.e., synced.
+
+	 This approach as best as possible implements the syncing of different
+	 sets of images and figuring that an image has stopped.  MPI does not
+	 provide any direct means of syncing non-coherent sets of images.
+	 The groups/communicators of MPI always need to be consistent, i.e.,
+	 have the same members on all images participating.  This is
+	 contradictiory to the sync images statement, where syncing, e.g., in a
+	 ring pattern is possible.
+
+	 This implementation guarantees, that as long as no image is stopped
+	 an image only is allowed to continue, when all its images to sync to
+	 also have reached a sync images statement.  This implementation makes
+	 no assumption when the image continues or in which order synced
+	 images continue.  */
       for(i = 0; i < count; ++i)
 	/* Need to have the request handlers contigously in the handlers
 	   array or waitany below will trip about the handler as illegal.  */
 	ierr = MPI_Irecv (&arrived[images[i] - 1], 1, MPI_INT, images[i] - 1, 0,
-	    CAF_COMM_WORLD, &handlers[i]);
+			  CAF_COMM_WORLD, &sync_handles[i]);
       for(i = 0; i < count; ++i)
+	MPI_Send (&int_zero, 1, MPI_INT, images[i] - 1, 0, CAF_COMM_WORLD);
+      done_count = 0;
+      while (done_count < count)
 	{
-# ifdef CAF_MPI_LOCK_UNLOCK
-	  MPI_Win_lock (MPI_LOCK_SHARED, images[i] - 1, 0, *stat_tok);
-# endif // CAF_MPI_LOCK_UNLOCK
-	  ierr = MPI_Get (&remote_stat, 1, MPI_INT,
-			  images[i] - 1, 0, 1, MPI_INT, *stat_tok);
-# ifdef CAF_MPI_LOCK_UNLOCK
-	  MPI_Win_unlock (images[i] - 1, *stat_tok);
-# else // CAF_MPI_LOCK_UNLOCK
-	  MPI_Win_flush (images[i] - 1, *stat_tok);
-# endif // CAF_MPI_LOCK_UNLOCK
-	  if(remote_stat != 0)
-	    {
-	      ierr = STAT_STOPPED_IMAGE;
-	      /* Let the other images know, that at least one image is
-		  stopped by sending STAT_STOPPED_IMAGE instead of our id.  */
-	      for(i = 0; i < count; ++i)
-		MPI_Send (&ierr, 1, MPI_INT, images[i] - 1, 0, CAF_COMM_WORLD);
-	      break;
-	    }
-	}
-      if (ierr == 0)
-	{
-	  int done_count = 0;
-	  for(i = 0; i < count; ++i)
-	    {
-	      if (arrived[images[i] - 1] != STAT_STOPPED_IMAGE)
-		/* Only send, when no stopped images have been found.  */
-		ierr = MPI_Send (&caf_this_image, 1, MPI_INT, images[i] - 1, 0,
-				 CAF_COMM_WORLD);
-	      else
-		ierr = STAT_STOPPED_IMAGE;
-	    }
-
-	  while (ierr != STAT_STOPPED_IMAGE && done_count < count)
+	  ierr = MPI_Waitany (count, sync_handles, &i, &s);
+	  if (i != MPI_UNDEFINED)
 	    {
-	      ierr = MPI_Waitany (count, handlers, &i, &s);
-	      if (i != MPI_UNDEFINED)
-		++done_count;
-	      if (i != MPI_UNDEFINED && arrived[i] == STAT_STOPPED_IMAGE)
-		ierr = STAT_STOPPED_IMAGE;
-	      else if (ierr != MPI_SUCCESS)
-		break;
+	      ++done_count;
+	      if (ierr == MPI_SUCCESS && arrived[s.MPI_SOURCE] == STAT_STOPPED_IMAGE)
+		{
+		  /* Possible future extension: Abort pending receives.  At the
+		     moment the receives are discarded by the program
+		     termination.  For the tested mpi-implementation this is ok.
+		   */
+		  ierr = STAT_STOPPED_IMAGE;
+		  break;
+		}
 	    }
+	  else if (ierr != MPI_SUCCESS)
+	    /* Abort receives here, too, when implemented above.  */
+	    break;
 	}
-
-      memset(arrived, 0, sizeof(int) * caf_num_images);
     }
 
 sync_images_err_chk:
@@ -3007,7 +3116,7 @@ sync_images_err_chk:
           if (errmsg_len > len)
             memset (&errmsg[len], ' ', errmsg_len-len);
         }
-      else
+      else if (!internal)
         caf_runtime_error (msg);
     }
 }
@@ -3023,17 +3132,29 @@ name (datatype *invec, datatype *inoutvec, int *len, \
     operator; \
 }
 
-#define FOOFUNC(TYPE) foo_ ## TYPE
+#define REFERENCE_FUNC(TYPE) TYPE ## _by_reference
+#define VALUE_FUNC(TYPE) TYPE ## _by_value
 
 #define GEN_COREDUCE(name, dt)			\
 static void \
-name (void *invec, void *inoutvec, int *len, \
+name##_by_reference_adapter (void *invec, void *inoutvec, int *len, \
+      MPI_Datatype *datatype)		     \
+{ \
+  int i;	     \
+  for(i=0;i<*len;i++)				\
+    {								\
+      *((dt*)inoutvec) = (dt)(REFERENCE_FUNC(dt)((dt *)invec, (dt *)inoutvec));	\
+     invec+=sizeof(dt); inoutvec+=sizeof(dt);	\
+   } \
+} \
+static void \
+name##_by_value_adapter (void *invec, void *inoutvec, int *len, \
       MPI_Datatype *datatype)		     \
 { \
   int i;	     \
   for(i=0;i<*len;i++)				\
     {								\
-      *((dt*)inoutvec) = (dt)(FOOFUNC(dt)((dt *)invec,(dt *)inoutvec));	\
+      *((dt*)inoutvec) = (dt)(VALUE_FUNC(dt)(*(dt *)invec, *(dt *)inoutvec));	\
      invec+=sizeof(dt); inoutvec+=sizeof(dt);	\
    } \
 }
@@ -3042,6 +3163,22 @@ GEN_COREDUCE (redux_int32, int32_t)
 GEN_COREDUCE (redux_real32, float)
 GEN_COREDUCE (redux_real64, double)
 
+static void \
+redux_char_by_reference_adapter (void *invec, void *inoutvec, int *len,
+      MPI_Datatype *datatype)
+{
+  long int string_len;
+  MPI_Type_extent(*datatype, &string_len);
+  for(int i = 0; i < *len; i++)
+    {
+      /* The length of the result is fixed, i.e., no deferred string length is
+       * allowed there.  */
+      REFERENCE_FUNC(char)((char *)inoutvec, string_len, (char *)invec, (char *)inoutvec, string_len, string_len);
+      invec += sizeof(char) * string_len;
+      inoutvec += sizeof(char) * string_len;
+    }
+}
+
 #ifndef MPI_INTEGER1
 GEN_REDUCTION (do_sum_int1, int8_t, inoutvec[i] += invec[i])
 GEN_REDUCTION (do_min_int1, int8_t,
@@ -3096,7 +3233,7 @@ GEN_REDUCTION (do_max_complex10, _Complex __float128,
 
 
 static MPI_Datatype
-get_MPI_datatype (gfc_descriptor_t *desc)
+get_MPI_datatype (gfc_descriptor_t *desc, int char_len)
 {
   /* FIXME: Better check whether the sizes are okay and supported;
      MPI3 adds more types, e.g. MPI_INTEGER1.  */
@@ -3153,7 +3290,14 @@ get_MPI_datatype (gfc_descriptor_t *desc)
    GFC_DTYPE_TYPE_SIZE == GFC_TYPE_CHARACTER + 64*strlen
 */
   if ( (GFC_DTYPE_TYPE_SIZE(desc)-GFC_DTYPE_CHARACTER)%64==0 )
-      return MPI_CHARACTER;
+    {
+      MPI_Datatype string;
+      if (char_len == 0)
+	char_len = GFC_DESCRIPTOR_SIZE (desc);
+      MPI_Type_contiguous(char_len, MPI_CHARACTER, &string);
+      MPI_Type_commit(&string);
+      return string;
+    }
 
   caf_runtime_error ("Unsupported data type in collective: %ld\n",GFC_DTYPE_TYPE_SIZE (desc));
   return 0;
@@ -3161,14 +3305,14 @@ get_MPI_datatype (gfc_descriptor_t *desc)
 
 
 static void
-co_reduce_1 (MPI_Op op, gfc_descriptor_t *source, int result_image, int *stat,
-             char *errmsg, int src_len __attribute__ ((unused)), int errmsg_len)
+internal_co_reduce (MPI_Op op, gfc_descriptor_t *source, int result_image, int *stat,
+	     char *errmsg, int src_len, int errmsg_len)
 {
   size_t i, size;
   int j, ierr;
   int rank = GFC_DESCRIPTOR_RANK (source);
 
-  MPI_Datatype datatype = get_MPI_datatype (source);
+  MPI_Datatype datatype = get_MPI_datatype (source, src_len);
 
   size = 1;
   for (j = 0; j < rank; j++)
@@ -3183,17 +3327,17 @@ co_reduce_1 (MPI_Op op, gfc_descriptor_t *source, int result_image, int *stat,
   if (rank == 0 || PREFIX (is_contiguous) (source))
     {
       if (result_image == 0)
-        ierr = MPI_Allreduce (MPI_IN_PLACE, source->base_addr, size, datatype,
+	ierr = MPI_Allreduce (MPI_IN_PLACE, source->base_addr, size, datatype,
                               op, CAF_COMM_WORLD);
       else if (result_image == caf_this_image)
-        ierr = MPI_Reduce (MPI_IN_PLACE, source->base_addr, size, datatype, op,
+	ierr = MPI_Reduce (MPI_IN_PLACE, source->base_addr, size, datatype, op,
                            result_image-1, CAF_COMM_WORLD);
       else
-        ierr = MPI_Reduce (source->base_addr, NULL, size, datatype, op,
+	ierr = MPI_Reduce (source->base_addr, NULL, size, datatype, op,
                            result_image-1, CAF_COMM_WORLD);
       if (ierr)
         goto error;
-      return;
+      goto co_reduce_cleanup;
     }
 
   for (i = 0; i < size; i++)
@@ -3214,18 +3358,21 @@ co_reduce_1 (MPI_Op op, gfc_descriptor_t *source, int result_image, int *stat,
       void *sr = (void *)((char *) source->base_addr
                           + array_offset_sr*GFC_DESCRIPTOR_SIZE (source));
       if (result_image == 0)
-        ierr = MPI_Allreduce (MPI_IN_PLACE, sr, 1, datatype, op,
+	ierr = MPI_Allreduce (MPI_IN_PLACE, sr, 1, datatype, op,
                               CAF_COMM_WORLD);
       else if (result_image == caf_this_image)
-        ierr = MPI_Reduce (MPI_IN_PLACE, sr, 1, datatype, op,
+	ierr = MPI_Reduce (MPI_IN_PLACE, sr, 1, datatype, op,
                            result_image-1, CAF_COMM_WORLD);
       else
-        ierr = MPI_Reduce (sr, NULL, 1, datatype, op, result_image-1,
+	ierr = MPI_Reduce (sr, NULL, 1, datatype, op, result_image-1,
                            CAF_COMM_WORLD);
       if (ierr)
         goto error;
     }
 
+co_reduce_cleanup:
+  if (GFC_DESCRIPTOR_TYPE (source) == BT_CHARACTER)
+    MPI_Type_free (&datatype);
   if (stat)
     *stat = 0;
   return;
@@ -3258,7 +3405,7 @@ PREFIX (co_broadcast) (gfc_descriptor_t *a, int source_image, int *stat, char *e
   int j, ierr;
   int rank = GFC_DESCRIPTOR_RANK (a);
 
-  MPI_Datatype datatype = get_MPI_datatype (a);
+  MPI_Datatype datatype = get_MPI_datatype (a, 0);
 
   size = 1;
   for (j = 0; j < rank; j++)
@@ -3273,7 +3420,7 @@ PREFIX (co_broadcast) (gfc_descriptor_t *a, int source_image, int *stat, char *e
   if (rank == 0)
     {
       if (datatype != MPI_CHARACTER)
-        ierr = MPI_Bcast(a->base_addr, size, datatype, source_image-1, CAF_COMM_WORLD);
+	ierr = MPI_Bcast(a->base_addr, size, datatype, source_image-1, CAF_COMM_WORLD);
       else
       {
         int a_length;
@@ -3284,12 +3431,12 @@ PREFIX (co_broadcast) (gfc_descriptor_t *a, int source_image, int *stat, char *e
         if (ierr)
           goto error;
         /* Broadcast the string itself */
-        ierr = MPI_Bcast(a->base_addr, a_length, datatype, source_image-1, CAF_COMM_WORLD);
+	ierr = MPI_Bcast(a->base_addr, a_length, datatype, source_image-1, CAF_COMM_WORLD);
       }
 
       if (ierr)
         goto error;
-      return;
+      goto co_broadcast_exit;
     }
     else if (datatype == MPI_CHARACTER) /* rank !=0  */
     {
@@ -3320,6 +3467,11 @@ PREFIX (co_broadcast) (gfc_descriptor_t *a, int source_image, int *stat, char *e
         goto error;
     }
 
+co_broadcast_exit:
+  if (stat)
+    *stat = 0;
+  if (GFC_DESCRIPTOR_TYPE(a) == BT_CHARACTER)
+    MPI_Type_free(&datatype);
   return;
 
 error:
@@ -3343,47 +3495,83 @@ error:
     memset (&errmsg[len], '\0', errmsg_len - len);
 }
 
+/** The front-end function for co_reduce functionality.  It sets up the MPI_Op
+ * for use in MPI_*Reduce functions. */
 void
 PREFIX (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)
 {
   MPI_Op op;
-  if(GFC_DESCRIPTOR_TYPE(a) == BT_INTEGER)
+  /* Integers and logicals can be treated the same. */
+  if(GFC_DESCRIPTOR_TYPE(a) == BT_INTEGER
+     || GFC_DESCRIPTOR_TYPE(a) == BT_LOGICAL)
     {
-      foo_int32_t = (typeof(foo_int32_t))opr;
-      MPI_Op_create(redux_int32, 1, &op);
+      /* When the ARG_VALUE opr_flag is set, then the user-function expects its
+       * arguments to be passed by value. */
+      if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
+	{
+	  int32_t_by_value = (typeof (VALUE_FUNC(int32_t)))opr;
+	  MPI_Op_create(redux_int32_by_value_adapter, 1, &op);
+	}
+      else
+	{
+	  int32_t_by_reference = (typeof (REFERENCE_FUNC(int32_t)))opr;
+	  MPI_Op_create(redux_int32_by_reference_adapter, 1, &op);
+	}
     }
+  /* Treat reals/doubles. */
   else if(GFC_DESCRIPTOR_TYPE(a) == BT_REAL)
     {
+      /* When the ARG_VALUE opr_flag is set, then the user-function expects its
+       * arguments to be passed by value. */
       if(GFC_DESCRIPTOR_SIZE(a) == sizeof(float))
   	{
-  	  foo_float = (typeof(foo_float))opr;
-  	  MPI_Op_create(redux_real32, 1, &op);
+	  if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
+	    {
+	      float_by_value = (typeof (VALUE_FUNC(float)))opr;
+	      MPI_Op_create(redux_real32_by_value_adapter, 1, &op);
+	    }
+	  else
+	    {
+	      float_by_reference = (typeof (REFERENCE_FUNC(float)))opr;
+	      MPI_Op_create(redux_real32_by_reference_adapter, 1, &op);
+	    }
   	}
       else
-  	{
-  	  foo_double = (typeof(foo_double))opr;
-  	  MPI_Op_create(redux_real64, 1, &op);
+	{
+	  /* When the ARG_VALUE opr_flag is set, then the user-function expects its
+	   * arguments to be passed by value. */
+	  if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
+	    {
+	      double_by_value = (typeof (VALUE_FUNC(double)))opr;
+	      MPI_Op_create(redux_real64_by_value_adapter, 1, &op);
+	    }
+	  else
+	    {
+	      double_by_reference = (typeof (REFERENCE_FUNC(double)))opr;
+	      MPI_Op_create(redux_real64_by_reference_adapter, 1, &op);
+	    }
   	}
     }
-  else if(GFC_DESCRIPTOR_TYPE(a) == BT_LOGICAL)
+  else if (GFC_DESCRIPTOR_TYPE(a) == BT_CHARACTER)
     {
-      foo_int32_t = (typeof(foo_int32_t))opr;
-      MPI_Op_create(redux_int32, 1, &op);
+      /* Char array functions always pass by reference. */
+      char_by_reference = (typeof (REFERENCE_FUNC(char)))opr;
+      MPI_Op_create(redux_char_by_reference_adapter, 1, &op);
     }
   else
     {
       caf_runtime_error ("Data type not yet supported for co_reduce\n");
     }
 
-  co_reduce_1 (op, a, result_image, stat, errmsg, 0, errmsg_len);
+  internal_co_reduce (op, a, result_image, stat, errmsg, a_len, errmsg_len);
 }
 
 void
 PREFIX (co_sum) (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg,
                  int errmsg_len)
 {
-  co_reduce_1 (MPI_SUM, a, result_image, stat, errmsg, 0, errmsg_len);
+  internal_co_reduce (MPI_SUM, a, result_image, stat, errmsg, 0, errmsg_len);
 }
 
 
@@ -3391,7 +3579,7 @@ void
 PREFIX (co_min) (gfc_descriptor_t *a, int result_image, int *stat, char *errmsg,
                  int src_len, int errmsg_len)
 {
-  co_reduce_1 (MPI_MIN, a, result_image, stat, errmsg, src_len, errmsg_len);
+  internal_co_reduce (MPI_MIN, a, result_image, stat, errmsg, src_len, errmsg_len);
 }
 
 
@@ -3399,7 +3587,7 @@ void
 PREFIX (co_max) (gfc_descriptor_t *a, int result_image, int *stat,
                  char *errmsg, int src_len, int errmsg_len)
 {
-  co_reduce_1 (MPI_MAX, a, result_image, stat, errmsg, src_len, errmsg_len);
+  internal_co_reduce (MPI_MAX, a, result_image, stat, errmsg, src_len, errmsg_len);
 }
 
 
@@ -3457,19 +3645,13 @@ PREFIX (atomic_define) (caf_token_t token, size_t offset,
   selectType(kind, &dt);
 
 #if MPI_VERSION >= 3
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Accumulate (value, 1, dt, image, offset, 1, dt, MPI_REPLACE, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
 #else // MPI_VERSION
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Put (value, 1, dt, image, offset, 1, dt, *p);
-  MPI_Win_unlock (image, *p);
+  CAF_Win_unlock (image, *p);
 #endif // MPI_VERSION
 
   if (stat)
@@ -3499,19 +3681,13 @@ PREFIX(atomic_ref) (caf_token_t token, size_t offset,
   selectType(kind, &dt);
 
 #if MPI_VERSION >= 3
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Fetch_and_op(NULL, value, dt, image, offset, MPI_NO_OP, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
 #else // MPI_VERSION
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Get (value, 1, dt, image, offset, 1, dt, *p);
-  MPI_Win_unlock (image, *p);
+  CAF_Win_unlock (image, *p);
 #endif // MPI_VERSION
 
   if (stat)
@@ -3542,16 +3718,10 @@ PREFIX(atomic_cas) (caf_token_t token, size_t offset,
   selectType (kind, &dt);
 
 #if MPI_VERSION >= 3
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Compare_and_swap (new_val, compare, old, dt, image,
                                offset, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
 #else // MPI_VERSION
 #warning atomic_cas for MPI-2 is not yet implemented
   printf ("We apologize but atomic_cas for MPI-2 is not yet implemented\n");
@@ -3588,37 +3758,31 @@ PREFIX (atomic_op) (int op, caf_token_t token ,
 
   selectType (kind, &dt);
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   /* Atomic_add */
-      switch(op) {
-          case 1:
-              ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_SUM, *p);
-              break;
-          case 2:
-              ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BAND, *p);
-              break;
-          case 4:
-              ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BOR, *p);
-              break;
-          case 5:
-              ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BXOR, *p);
-              break;
-          default:
-              printf ("We apologize but the atomic operation requested for MPI is not yet implemented\n");
-              break;
-      }
-# ifdef CAF_MPI_LOCK_UNLOCK
-      MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-      MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  switch(op) {
+    case 1:
+      ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_SUM, *p);
+      break;
+    case 2:
+      ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BAND, *p);
+      break;
+    case 4:
+      ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BOR, *p);
+      break;
+    case 5:
+      ierr = MPI_Fetch_and_op(value, old, dt, image, offset, MPI_BXOR, *p);
+      break;
+    default:
+      printf ("We apologize but the atomic operation requested for MPI < 3 is not yet implemented\n");
+      break;
+    }
+  CAF_Win_unlock (image, *p);
 
   free(old);
 #else // MPI_VERSION
- #warning atomic_op for MPI is not yet implemented
-   printf ("We apologize but atomic_op for MPI is not yet implemented\n");
+  #warning atomic_op for MPI is not yet implemented
+  printf ("We apologize but atomic_op for MPI < 3 is not yet implemented\n");
 #endif // MPI_VERSION
   if (stat)
     *stat = ierr;
@@ -3647,16 +3811,10 @@ PREFIX (event_post) (caf_token_t token, size_t index,
   if(stat != NULL)
     *stat = 0;
 
-  #if MPI_VERSION >= 3
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+#if MPI_VERSION >= 3
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Accumulate (&value, 1, MPI_INT, image, index*sizeof(int), 1, MPI_INT, MPI_SUM, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
 #else // MPI_VERSION
   #warning Events for MPI-2 are not implemented
   printf ("Events for MPI-2 are not supported, please update your MPI implementation\n");
@@ -3712,15 +3870,9 @@ PREFIX (event_wait) (caf_token_t token, size_t index,
 
   newval = -until_count;
 
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Fetch_and_op(&newval, &old, MPI_INT, image, index*sizeof(int), MPI_SUM, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
   if(ierr != MPI_SUCCESS)
     {
       if(stat != NULL)
@@ -3749,15 +3901,9 @@ PREFIX (event_query) (caf_token_t token, size_t index,
     *stat = 0;
 
 #if MPI_VERSION >= 3
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image, 0, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image, *p);
   ierr = MPI_Fetch_and_op(NULL, count, MPI_INT, image, index*sizeof(int), MPI_NO_OP, *p);
-# ifdef CAF_MPI_LOCK_UNLOCK
-  MPI_Win_unlock (image, *p);
-# else // CAF_MPI_LOCK_UNLOCK
-  MPI_Win_flush (image, *p);
-# endif // CAF_MPI_LOCK_UNLOCK
+  CAF_Win_unlock (image, *p);
 #else // MPI_VERSION
 #warning Events for MPI-2 are not implemented
   printf ("Events for MPI-2 are not supported, please update your MPI implementation\n");
diff --git a/src/single/CMakeLists.txt b/src/single/CMakeLists.txt
index 4b40609..013ba7a 100644
--- a/src/single/CMakeLists.txt
+++ b/src/single/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_library(caf_single single.c ../common/caf_auxiliary.c)
 target_compile_options(caf_single INTERFACE -fcoarray=lib)
 install(TARGETS caf_single EXPORT OpenCoarraysTargets
-  ARCHIVE DESTINATION lib
+  ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 )
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 6464617..7405d73 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -1,6 +1,9 @@
 if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
   option(HIGH_RESOLUTION_TIMER "use the walltime.o wallclock timer" FALSE)
   option(LEGACY_ARCHITECTURE "use the SSE-enabled FFT library" FALSE)
+
+  # Let package maintainers disable fft library written in assembly
+  option ( SKIP_ASSEMBLY_DEPS "Skip buidling/running tests that depend on files written in assembly" FALSE )
 endif()
 
 if (HIGH_RESOLUTION_TIMER)
@@ -14,4 +17,5 @@ endif()
 
 add_subdirectory(integration)
 add_subdirectory(unit)
-#add_subdirectory(performance)
+add_subdirectory(installation)
+add_subdirectory(regression)
diff --git a/src/tests/installation/CMakeLists.txt b/src/tests/installation/CMakeLists.txt
new file mode 100644
index 0000000..c35a476
--- /dev/null
+++ b/src/tests/installation/CMakeLists.txt
@@ -0,0 +1 @@
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/installation-scripts.sh ${CMAKE_CURRENT_BINARY_DIR}/installation-scripts.sh COPYONLY)
diff --git a/src/tests/installation/installation-scripts.sh b/src/tests/installation/installation-scripts.sh
new file mode 100755
index 0000000..177f9ce
--- /dev/null
+++ b/src/tests/installation/installation-scripts.sh
@@ -0,0 +1,129 @@
+#!/usr/bin/env bash
+#
+# installation-scripts.sh
+#
+# -- This script tests the bash scripts that install OpenCoarrays and its prerequisites.
+#
+# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
+# Copyright (c) 2015-2016, Sourcery, Inc.
+# Copyright (c) 2015-2016, Sourcery Institute
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice, this
+#    list of conditions and the following disclaimer in the documentation and/or
+#    other materials provided with the distribution.
+# 3. Neither the names of the copyright holders nor the names of their contributors
+#    may be used to endorse or promote products derived from this software without
+#    specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Portions of this script derive from BASH3 Boilerplate and are distributed under
+# the following license:
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Kevin van Zonneveld
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+#
+#  - https://github.com/kvz/bash3boilerplate
+#  - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
+#
+# Version: 2.0.0
+#
+# Authors:
+#
+#  - Kevin van Zonneveld (http://kvz.io)
+#  - Izaak Beekman (https://izaakbeekman.com/)
+#  - Alexander Rathai (Alexander.Rathai at gmail.com)
+#  - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation)
+#
+# Licensed under MIT
+# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
+
+# The invocation of bootstrap.sh below performs the following tasks:
+# (1) Import several bash3boilerplate helper functions & default settings.
+# (2) Set several variables describing the current file and its usage page.
+# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
+# (4) Parse the command line using the usage information.
+
+set -o errtrace
+
+# requires `set -o errtrace`
+__b3bp_err_report() {
+    local error_code
+    error_code=${?}
+    error "Error in ${__file} in function ${1} on line ${2}"
+    exit ${error_code}
+}
+# Uncomment the following line for always providing an error backtrace
+trap '__b3bp_err_report "${FUNCNAME:-.}" ${LINENO}' ERR
+
+### Start of boilerplate -- do not edit this block #######################
+export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%/}/../../..}"
+if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
+  echo "Please run this script inside the OpenCoarrays source sudirectory src/tests/instsallation"
+  echo "or set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
+  exit 1
+fi
+export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
+if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
+  echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
+  exit 2
+else
+    # shellcheck source=../../../prerequisites/use-case/bootstrap.sh
+    source "${B3B_USE_CASE}/bootstrap.sh" "$@"
+fi
+### End of boilerplate -- start user edits below #########################
+
+# Set expected value of present flags that take no arguments
+export __flag_present=1
+
+# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if
+# not needed. Other signals can be trapped too, like SIGINT and SIGTERM.
+function cleanup_before_exit () {
+  info "Cleaning up. Done"
+}
+trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc.
+
+
+pushd "${OPENCOARRAYS_SRC_DIR}"/src/tests/installation
+
+# shellcheck source=../../../prerequisites/stack.sh
+source "${OPENCOARRAYS_SRC_DIR}"/prerequisites/stack.sh
+source test-stack.sh
+test_stack
+
+popd
diff --git a/install.sh-usage b/src/tests/installation/installation-scripts.sh-usage
similarity index 100%
copy from install.sh-usage
copy to src/tests/installation/installation-scripts.sh-usage
diff --git a/src/tests/installation/test-stack.sh b/src/tests/installation/test-stack.sh
new file mode 100644
index 0000000..09ae41b
--- /dev/null
+++ b/src/tests/installation/test-stack.sh
@@ -0,0 +1,158 @@
+functions_exist()
+{
+ : "${1?'Missing function name list'}"
+
+ for function_name
+ do
+   if [[ "`type -t $function_name`" != "function" ]]; then
+      emergency "function ${function_name} does not exist"
+   fi
+ done 
+}
+
+detect_missing_variable_name()
+{
+ : "${1?'detect_missing_variable name: Missing function name'}"
+
+ stack_new __dummy_stack
+
+ for function_name
+ do
+   expected_error="Missing variable name in ${function_name}"
+   error_message="$($function_name _dummy_stack_name 2>&1 > /dev/null)" || true
+   error_message="${error_message##*: }" # grab text after final colon/space sequence
+   if [[ "${error_message}" != ${expected_error} ]]; then
+     emergency "$function_name failed to detect '${expected_error}'"
+   fi
+  done
+ stack_destroy __dummy_stack
+}
+
+detect_missing_stack_name()
+{
+ : "${1?'detect_missing_name: Missing function name'}"
+
+ expected_error="Missing stack name"
+ debug "detect_missing_stack_name: \${expected_error}=${expected_error}"
+
+ for function_name
+ do
+   debug "detect_missing_stack_name: executing \"\$($function_name 2>&1 > /dev/null)\" || true"
+   error_message="$($function_name 2>&1 > /dev/null)" || true
+   error_message="${error_message##*: }" # grab text after final colon/space sequence
+   debug "detect_missing_stack_name: \${error_message}=${error_message}"
+   if [[ "${error_message}" != ${expected_error} ]]; then
+     emergency "$function_name failed to detect '${expected_error}'"
+   fi
+ done
+}
+
+detect_no_such_stack()
+{
+ : "${1?'detect_no_such_name: Missing function name'}"
+
+ stack_name="__nonexistent_stack"
+ expected_error="No such stack -- "
+ debug "detect_no_such_stack: \${expected_error}=${expected_error}"
+
+ dummy_variable=""
+
+ for function_name
+ do
+   debug "detect_no_such_stack: executing \"\$($function_name $stack_name dummy_variable 2>&1 > /dev/null)\" || true"
+   error_message="$($function_name $stack_name dummy_variable 2>&1 > /dev/null)" || true
+   missing_stack="${error_message##${expected_error}}" # grab text after final colon/space sequence
+   debug "detect_no_such_stack: \${missing_stack}=${missing_stack}"
+   if [[ "${missing_stack}" != ${stack_name} ]]; then
+     emergency "$function_name failed to detect missing '${stack_name}'"
+   fi
+ done
+}
+
+detect_duplicate_stack_creation()
+{
+ : "${1?'detect_duplicate_stack_creation: Missing function name'}"
+
+ stack_name="__dummy_stack"
+ stack_new "${stack_name}"
+
+ expected_error="Stack already exists -- "
+ debug "detect_duplicate_stack_creation: \${expected_error}=${expected_error}"
+ function_name="stack_new"
+
+ debug "detect_duplicate_stack_creation: executing \"\$($function_name $stack_name 2>&1 > /dev/null)\" || true"
+ error_message="$($function_name $stack_name dummy_variable 2>&1 > /dev/null)" || true
+ duplicate_stack="${error_message##${expected_error}}" # grab text after final colon/space sequence
+ debug "detect_no_such_stack: \${duplicate_stack}=${duplicate_stack}"
+ if [[ "${duplicate_stack}" != ${stack_name} ]]; then
+   emergency "$function_name failed to detect duplicate '${stack_name}'"
+ fi
+ stack_destroy ${stack_name}
+}
+
+verify_stack_size_changes()
+{
+  stack_new foobar
+  stack_size foobar __foobar_size
+  expected_size=0
+  if [[  "${__foobar_size}" != "${expected_size}" ]]; then 
+    emergency "verify_stack_size_changes: size=${__foobar_size} (expected ${expected_size})"
+  fi
+
+  stack_push foobar kernel
+  stack_size foobar __foobar_new_size
+  (( expected_size += 1 ))
+  if [[  "${__foobar_new_size}" != "${expected_size}" ]]; then 
+    emergency "verify_stack_size_changes: size=${__foobar_new_size} (expected 1)"
+  fi
+
+  stack_peek foobar tmp
+  if [[  "${tmp}" != "kernel" ]]; then 
+    emergency "verify_stack_size_changes: peeked item ('${tmp}') mismatch with pushed item ('kernel')"
+  fi
+
+  stack_size foobar __should_be_unchanged
+  if [[  "${__should_be_unchanged}" != "${expected_size}" ]]; then 
+    emergency "verify_stack_size_changes: size=${__should_be_unchanged} (expected ${expected_size})"
+  fi
+
+  stack_pop foobar popped
+  if [[  "${popped}" != "kernel" ]]; then 
+    emergency "verify_stack_size_changes: popped item ('${popped}') mismatch with pushed item ('kernel')"
+  fi
+  (( expected_size -= 1 )) || true
+
+  stack_size foobar __final_size
+  if [[  "${__final_size}" != "${expected_size}" ]]; then 
+    emergency "verify_stack_size_changes: size=${__final_size} (expected ${expected_size})"
+  fi
+}
+
+test_stack()
+{
+  # Verify availability of expected functions:
+  functions_exist \
+    stack_new stack_exists stack_print stack_push stack_peek stack_pop stack_size stack_destroy
+  
+  # Verify that each named function detects missing stack-name arguments:
+  detect_missing_stack_name \
+    stack_new stack_exists stack_print stack_push stack_peek stack_pop stack_size stack_destroy
+
+  # Verify that each named function detects missing names of the variable to push, pop, or peek:
+  detect_missing_variable_name \
+    stack_pop stack_push stack_peek
+
+  # Verify that each named function detects non-existent stacks:
+  detect_no_such_stack \
+    stack_destroy stack_peek stack_print stack_pop stack_push stack_size
+
+  # Verify that duplicate creation generates the expected error:
+  detect_duplicate_stack_creation \
+     stack_new
+
+  # Verify that push, peek, and pop yield correct size changes or lack thereof:
+  verify_stack_size_changes
+
+  info "test-stack.sh: All tests passed."
+
+}
diff --git a/src/tests/integration/dist_transpose/coarray_distributed_transpose.F90 b/src/tests/integration/dist_transpose/coarray_distributed_transpose.F90
index 7341ac4..a06692a 100644
--- a/src/tests/integration/dist_transpose/coarray_distributed_transpose.F90
+++ b/src/tests/integration/dist_transpose/coarray_distributed_transpose.F90
@@ -35,9 +35,17 @@
 module run_size
     use iso_fortran_env
 #ifndef HAVE_WALLTIME
-    use MPI, only : WALLTIME=>MPI_WTIME
+#  ifdef MPI_WORKING_MODULE
+     use MPI, only : WALLTIME=>MPI_WTIME
+     implicit none
+#  else
+     implicit none
+     include 'mpif.h'
+#    define WALLTIME MPI_WTIME
+#  endif
+#else
+  implicit none
 #endif
-    implicit none
         integer(int64), codimension[*] :: nx, ny, nz
         integer(int64), codimension[*] :: my, mx, first_y, last_y, first_x, last_x
         integer(int64) :: my_node, num_nodes
diff --git a/src/tests/integration/events/CMakeLists.txt b/src/tests/integration/events/CMakeLists.txt
index 757a115..db38a98 100644
--- a/src/tests/integration/events/CMakeLists.txt
+++ b/src/tests/integration/events/CMakeLists.txt
@@ -1,2 +1,2 @@
-add_executable(asynchronous_hello_world async-hello.f90)
+add_executable(asynchronous_hello_world async-hello.F90)
 target_link_libraries(asynchronous_hello_world OpenCoarrays)
diff --git a/src/tests/integration/events/async-hello.f90 b/src/tests/integration/events/async-hello.F90
similarity index 97%
rename from src/tests/integration/events/async-hello.f90
rename to src/tests/integration/events/async-hello.F90
index 869c01f..26f754d 100644
--- a/src/tests/integration/events/async-hello.f90
+++ b/src/tests/integration/events/async-hello.F90
@@ -48,7 +48,7 @@ program main
                 work_if_ready: select case(ready_count-previous_count(image))
                   case(0) ! keep spinning until greeting is ready
                   case(1) ! event posted so get and print greeting
-                    write(greeting,"(2(a,i2))") greeting[image]
+                    write(greeting,"(a)") greeting[image]
                     associate(expected_location=>23)
                       ! Verify that the greetings of images 1-9 have their image number at the expected location:
                       if (scan(greeting,set="123456789")/=expected_location) error stop "Test failed."
diff --git a/src/tests/integration/pde_solvers/README.md b/src/tests/integration/pde_solvers/README.md
index 0709f97..52db409 100644
--- a/src/tests/integration/pde_solvers/README.md
+++ b/src/tests/integration/pde_solvers/README.md
@@ -1,6 +1,6 @@
 [This document is formatted with GitHub-Flavored Markdown.   ]:#
 [For better viewing, including hyperlinks, read it online at ]:#
-[https://github.com/sourceryinstitute/opencoarrays/edit/master/src/tests/integration/pde_solvers/README.txt]:#
+[https://github.com/sourceryinstitute/OpenCoarrays/edit/master/src/tests/integration/pde_solvers/README.txt]:#
 
 Partial Differential Equation (PDE) Solvers
 ===========================================
diff --git a/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt b/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
index 6fdb52f..bb02a91 100644
--- a/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
+++ b/src/tests/integration/pde_solvers/navier-stokes/CMakeLists.txt
@@ -1,7 +1,7 @@
 # checking whether the machine is of type 64-bit before proceeding further
 if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") )
   # Default to older SSE-instruction-based FFT library
-  if (NOT (DEFINED ENV{TRAVIS}))
+  if (NOT (DEFINED ENV{TRAVIS}) AND (NOT SKIP_ASSEMBLY_DEPS) )
     if (LEGACY_ARCHITECTURE OR (NOT DEFINED(LEGACY_ARCHITECTURE)))
       set(fft_library ${CMAKE_CURRENT_SOURCE_DIR}/libfft_sse.a )
     else()
@@ -9,6 +9,7 @@ if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}"
       set(fft_library ${CMAKE_CURRENT_SOURCE_DIR}/libfft_avx.a )
     endif()
     add_executable( coarray_navier_stokes
+      EXCLUDE_FROM_ALL
       coarray-shear_coll.F90
       ${walltime_o}
     )
diff --git a/src/tests/integration/pde_solvers/navier-stokes/coarray-shear_coll.F90 b/src/tests/integration/pde_solvers/navier-stokes/coarray-shear_coll.F90
index 86ffe67..6d91d36 100644
--- a/src/tests/integration/pde_solvers/navier-stokes/coarray-shear_coll.F90
+++ b/src/tests/integration/pde_solvers/navier-stokes/coarray-shear_coll.F90
@@ -112,9 +112,17 @@ module run_size
     use iso_fortran_env, only : int64,real64 ! 64-bit integer and real kind parameters
     use constants_module, only : one         ! 64-bit unit to ensure argument kind match
 #ifndef HAVE_WALLTIME
-    use MPI, only : WALLTIME=>MPI_WTIME
+#  ifdef MPI_WORKING_MODULE
+     use MPI, only : WALLTIME=>MPI_WTIME
+     implicit none
+#  else
+     implicit none
+     include 'mpif.h'
+#    define WALLTIME MPI_WTIME
+#  endif
+#else
+  implicit none
 #endif
-    implicit none
         real, codimension[*] ::  viscos, shear, b11, b22, b33, b12, velmax
         integer(int64), codimension[*] ::  nx, ny, nz, nsteps, output_step
         integer(int64), codimension[*] :: my, mx, first_y, last_y, first_x, last_x
diff --git a/src/tests/performance/BurgersMPI/shared.F90 b/src/tests/performance/BurgersMPI/shared.F90
index d35d7ef..d9fa60b 100644
--- a/src/tests/performance/BurgersMPI/shared.F90
+++ b/src/tests/performance/BurgersMPI/shared.F90
@@ -26,7 +26,11 @@
 
 module shared
   !module for sharing mpi functionality/variables with other modules/main
+#ifdef MPI_WORKING_MODULE
   use mpi !non-native mpi functionality
+#else
+  include 'mpif.h'
+#endif
   integer :: tag, status(MPI_STATUS_SIZE)
   integer :: MPI_COMM_CART
   integer :: my_id, num_procs, ierr, local_grid_resolution, left_id, right_id
diff --git a/src/tests/performance/mpi_dist_transpose/mpi_distributed_transpose.F90 b/src/tests/performance/mpi_dist_transpose/mpi_distributed_transpose.F90
index 1a1cd0a..e16fc74 100644
--- a/src/tests/performance/mpi_dist_transpose/mpi_distributed_transpose.F90
+++ b/src/tests/performance/mpi_dist_transpose/mpi_distributed_transpose.F90
@@ -38,9 +38,17 @@
 module mpi_run_size
     use iso_fortran_env
 #ifndef HAVE_WALLTIME
-    use MPI, only : WALLTIME=>MPI_WTIME
+#  ifdef MPI_WORKING_MODULE
+     use MPI, only : WALLTIME=>MPI_WTIME
+     implicit none
+#  else
+     implicit none
+     include 'mpif.h'
+#    define WALLTIME MPI_WTIME
+#  endif
+#else
+  implicit none
 #endif
-    implicit none
         integer(int64) :: nx, ny, nz
         integer(int64) :: my, mx, first_y, last_y, first_x, last_x
         integer(int64) :: my_node, num_nodes
diff --git a/src/tests/regression/CMakeLists.txt b/src/tests/regression/CMakeLists.txt
new file mode 100644
index 0000000..d70bb9d
--- /dev/null
+++ b/src/tests/regression/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(reported)
diff --git a/src/tests/regression/open/issue-172 b/src/tests/regression/open/issue-172
new file mode 120000
index 0000000..364883a
--- /dev/null
+++ b/src/tests/regression/open/issue-172
@@ -0,0 +1 @@
+../reported/issue-172-wrong-co_reduce.f90
\ No newline at end of file
diff --git a/src/tests/regression/open/issue-292 b/src/tests/regression/open/issue-292
new file mode 120000
index 0000000..a3103a8
--- /dev/null
+++ b/src/tests/regression/open/issue-292
@@ -0,0 +1 @@
+../reported/issue-292-convert-type-before-put.f90
\ No newline at end of file
diff --git a/src/tests/regression/reported/CMakeLists.txt b/src/tests/regression/reported/CMakeLists.txt
new file mode 100644
index 0000000..7797235
--- /dev/null
+++ b/src/tests/regression/reported/CMakeLists.txt
@@ -0,0 +1,18 @@
+add_executable(co_reduce-factorial issue-172-wrong-co_reduce.f90)
+target_link_libraries(co_reduce-factorial OpenCoarrays)
+
+add_executable(co_reduce-factorial-int8 issue-172-wrong-co_reduce-int8.f90)
+target_link_libraries(co_reduce-factorial-int8 OpenCoarrays)
+
+add_executable(co_reduce-factorial-int64 issue-172-wrong-co_reduce-int64.f90)
+target_link_libraries(co_reduce-factorial-int64 OpenCoarrays)
+
+add_executable(source-alloc-sync issue-243-source-allocation-no-sync.f90)
+target_link_libraries(source-alloc-sync OpenCoarrays)
+
+add_executable(convert-before-put issue-292-convert-type-before-put.f90)
+target_link_libraries(convert-before-put OpenCoarrays)
+
+add_executable(event-post issue-293-silent-event-failure.F90)
+target_link_libraries(event-post OpenCoarrays)
+
diff --git a/src/tests/regression/reported/issue-172-wrong-co_reduce-int64.f90 b/src/tests/regression/reported/issue-172-wrong-co_reduce-int64.f90
new file mode 100644
index 0000000..30f36aa
--- /dev/null
+++ b/src/tests/regression/reported/issue-172-wrong-co_reduce-int64.f90
@@ -0,0 +1,65 @@
+program co_reduce_factorial_int64
+  !! author: Daniel Topa & Izaak Beekman
+  !! category: regression
+  !!
+  !! [issue #172](https://github.com/sourceryinstitute/opencoarrays/issues/172)
+  !! wherein co-reduce gets junk in the first image when binary
+  !! operator's (pure function) arguments have `value` attribute
+  !! instead of `intent(in)`
+
+  implicit none
+  integer(kind=8) :: value[ * ] !! Each image stores their image number here
+  integer :: k
+  integer(kind=8) :: np
+  value = this_image ( )
+  np = num_images ( )
+  call co_reduce ( value, result_image = 1, operator = myProd )
+  !! value[k /= 1] undefined, value[ k == 1 ] should equal $n!$ where $n$ is `num_images()`
+  if ( this_image ( ) == 1 ) then
+     write ( * , '( "Number of images = ", g0 )' ) num_images ( )
+     do k = 1, num_images ( )
+        write ( * , '( 2( a, i0 ) )' ) 'value [ ', k, ' ] is ', value [ k ]
+        write ( * , '(a)' ) 'since RESULT_IMAGE is present, value on other images is undefined by the standard'
+     end do
+     write ( * , '( "Product  value = ", g0 )' ) value  !! should print num_images() factorial
+     write ( * , 100 )
+     if ( value == factorial( np ) ) then
+        write ( * , '(a)' ) 'Test passed.'
+     else
+        write ( * , '(a, I0)') 'Answer should have been num_images()! = ', factorial( np )
+        error stop 'Wrong answer for n! using co_reduce'
+     end if
+  end if
+100 format ( "Expected value = num_images()!", /, " 2! = 2, 3! = 6, 4! = 24, ..." )
+
+contains
+
+  pure function myProd ( a, b ) result ( rslt )
+    !! Product function to be used in `co_reduce` reduction for
+    !! computing factorials. When `value` attribute is changed to
+    !! `intent(in)` tests pass, and expected behavior is observed.
+    integer(kind=8), value :: a, b
+    !! multiply two inputs together.  If we change `value` to
+    !! `intent(in)` the test passes and the issue goes away and
+    !! according to C1276 of F2008:
+    !!
+    !! > C1276 The specification-part of a pure function subprogram
+    !! > shall specify that all its nonpointer dummy data objects have
+    !! > the INTENT (IN) or the VALUE attribute.
+    !!
+    !! Thanks to @LadaF for pointing this out.
+    integer(kind=8)        :: rslt !! product of a*b
+    rslt = a * b
+  end function
+
+  pure function factorial ( n ) result ( rslt )
+    !! Compute $n!$
+    integer(kind=8), intent(in) :: n
+    integer(kind=8) :: rslt
+    integer :: i
+    rslt = 1
+    do i = 1, n
+      rslt = rslt*i
+   end do
+ end function
+end program
diff --git a/src/tests/regression/reported/issue-172-wrong-co_reduce-int8.f90 b/src/tests/regression/reported/issue-172-wrong-co_reduce-int8.f90
new file mode 100644
index 0000000..6599f46
--- /dev/null
+++ b/src/tests/regression/reported/issue-172-wrong-co_reduce-int8.f90
@@ -0,0 +1,65 @@
+program co_reduce_factorial_int8
+  !! author: Daniel Topa & Izaak Beekman
+  !! category: regression
+  !!
+  !! [issue #172](https://github.com/sourceryinstitute/opencoarrays/issues/172)
+  !! wherein co-reduce gets junk in the first image when binary
+  !! operator's (pure function) arguments have `value` attribute
+  !! instead of `intent(in)`
+
+  implicit none
+  integer(kind=1) :: value[ * ] !! Each image stores their image number here
+  integer :: k
+  integer(kind=1) :: np
+  np = num_images ( )
+  value = this_image ( )
+  call co_reduce ( value, result_image = 1, operator = myProd )
+  !! value[k /= 1] undefined, value[ k == 1 ] should equal $n!$ where $n$ is `num_images()`
+  if ( this_image ( ) == 1 ) then
+     write ( * , '( "Number of images = ", g0 )' ) num_images ( )
+     do k = 1, num_images ( )
+        write ( * , '( 2( a, i0 ) )' ) 'value [ ', k, ' ] is ', value [ k ]
+        write ( * , '(a)' ) 'since RESULT_IMAGE is present, value on other images is undefined by the standard'
+     end do
+     write ( * , '( "Product  value = ", g0 )' ) value  !! should print num_images() factorial
+     write ( * , 100 )
+     if ( value == factorial( np ) ) then
+        write ( * , '(a)' ) 'Test passed.'
+     else
+        write ( * , '(a, I0)') 'Answer should have been num_images()! = ', factorial( np )
+        error stop 'Wrong answer for n! using co_reduce'
+     end if
+  end if
+100 format ( "Expected value = num_images()!", /, " 2! = 2, 3! = 6, 4! = 24, ..." )
+
+contains
+
+  pure function myProd ( a, b ) result ( rslt )
+    !! Product function to be used in `co_reduce` reduction for
+    !! computing factorials. When `value` attribute is changed to
+    !! `intent(in)` tests pass, and expected behavior is observed.
+    integer(kind=1), value :: a, b
+    !! multiply two inputs together.  If we change `value` to
+    !! `intent(in)` the test passes and the issue goes away and
+    !! according to C1276 of F2008:
+    !!
+    !! > C1276 The specification-part of a pure function subprogram
+    !! > shall specify that all its nonpointer dummy data objects have
+    !! > the INTENT (IN) or the VALUE attribute.
+    !!
+    !! Thanks to @LadaF for pointing this out.
+    integer(kind=1)        :: rslt !! product of a*b
+    rslt = a * b
+  end function
+
+  pure function factorial ( n ) result ( rslt )
+    !! Compute $n!$
+    integer(kind=1), intent(in) :: n
+    integer(kind=1) :: rslt
+    integer :: i
+    rslt = 1
+    do i = 1, n
+      rslt = rslt*i
+   end do
+ end function
+end program
diff --git a/src/tests/regression/reported/issue-172-wrong-co_reduce.f90 b/src/tests/regression/reported/issue-172-wrong-co_reduce.f90
new file mode 100644
index 0000000..15d55fc
--- /dev/null
+++ b/src/tests/regression/reported/issue-172-wrong-co_reduce.f90
@@ -0,0 +1,63 @@
+program co_reduce_factorial
+  !! author: Daniel Topa & Izaak Beekman
+  !! category: regression
+  !!
+  !! [issue #172](https://github.com/sourceryinstitute/opencoarrays/issues/172)
+  !! wherein co-reduce gets junk in the first image when binary
+  !! operator's (pure function) arguments have `value` attribute
+  !! instead of `intent(in)`
+
+  implicit none
+  integer :: value[ * ] !! Each image stores their image number here
+  integer :: k
+  value = this_image ( )
+  call co_reduce ( value, result_image = 1, operator = myProd )
+  !! value[k /= 1] undefined, value[ k == 1 ] should equal $n!$ where $n$ is `num_images()`
+  if ( this_image ( ) == 1 ) then
+     write ( * , '( "Number of images = ", g0 )' ) num_images ( )
+     do k = 1, num_images ( )
+        write ( * , '( 2( a, i0 ) )' ) 'value [ ', k, ' ] is ', value [ k ]
+        write ( * , '(a)' ) 'since RESULT_IMAGE is present, value on other images is undefined by the standard'
+     end do
+     write ( * , '( "Product  value = ", g0 )' ) value  !! should print num_images() factorial
+     write ( * , 100 )
+     if ( value == factorial( num_images() ) ) then
+        write ( * , '(a)' ) 'Test passed.'
+     else
+        write ( * , '(a, I0)') 'Answer should have been num_images()! = ', factorial( num_images() )
+        error stop 'Wrong answer for n! using co_reduce'
+     end if
+  end if
+100 format ( "Expected value = num_images()!", /, " 2! = 2, 3! = 6, 4! = 24, ..." )
+
+contains
+
+  pure function myProd ( a, b ) result ( rslt )
+    !! Product function to be used in `co_reduce` reduction for
+    !! computing factorials. When `value` attribute is changed to
+    !! `intent(in)` tests pass, and expected behavior is observed.
+    integer, value :: a, b
+    !! multiply two inputs together.  If we change `value` to
+    !! `intent(in)` the test passes and the issue goes away and
+    !! according to C1276 of F2008:
+    !!
+    !! > C1276 The specification-part of a pure function subprogram
+    !! > shall specify that all its nonpointer dummy data objects have
+    !! > the INTENT (IN) or the VALUE attribute.
+    !!
+    !! Thanks to @LadaF for pointing this out.
+    integer        :: rslt !! product of a*b
+    rslt = a * b
+  end function
+
+  pure function factorial ( n ) result ( rslt )
+    !! Compute $n!$
+    integer, intent(in) :: n
+    integer :: rslt
+    integer :: i
+    rslt = 1
+    do i = 1, n
+      rslt = rslt*i
+   end do
+ end function
+end program
diff --git a/src/tests/regression/reported/issue-243-source-allocation-no-sync.f90 b/src/tests/regression/reported/issue-243-source-allocation-no-sync.f90
new file mode 100644
index 0000000..2bdff83
--- /dev/null
+++ b/src/tests/regression/reported/issue-243-source-allocation-no-sync.f90
@@ -0,0 +1,50 @@
+program source_allocation_no_sync
+  !! author: Damian Rouson and Izaak Beekman
+  !! category: regression
+  !!
+  !! [Issue #243](https://github.com/sourceryinstitute/opencoarrays/issues/243)
+  !!
+  !! [GFortran PR 78505](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78505):
+  !!
+  !! @note The test must be run with less than or equal to 32 images,
+  !! and the number of images must be a power of two. Valid numbers of
+  !! images are: 2, 4, 8, 16, or 32
+  !!
+  !! Sourced allocation of a coarray object performs a synchronization
+  !! after the allocation, BUT *before* the assignment of
+  !! `source`. This violates the
+  !! [standard](http://open-std.org/JTC1/SC22/WG5/5559) Section
+  !! 9.7.1.2, paragraph 4:
+  !!
+  !! > When an ALLOCATE statement is executed for which an
+  !! > allocate-object is a coarray, there is an implicit
+  !! > synchronization of all active images in the current team. On
+  !! > those images, if no error condition other than
+  !! > STAT_STOPPED_IMAGE or STAT_FAILED_IMAGE occurs, execution of
+  !! > the segment (11.6.2) following the statement is delayed until
+  !! > all other active images in the current team have executed the
+  !! > same statement the same number of times in this team. The
+  !! > coarray shall not become allocated on an image unless it is
+  !! > successfully allocated on all active images in this team.
+  !!
+
+  implicit none
+  integer, allocatable :: f(:)[:]
+  integer, parameter :: num_points=32
+  integer :: me,ni,my_num_points,neighbor_last_element
+  me = this_image()
+  if (mod(num_points,num_images())/=0) error stop "num_points not evenly divisible by num_images()"
+  my_num_points = num_points/num_images()
+  allocate( f(my_num_points)[*], source = 1 )
+  if (me>1) then
+     neighbor_last_element = f(my_num_points)[me-1]
+     if (neighbor_last_element /=1) then
+        print *,"Image ",me," gets ",neighbor_last_element
+        error stop "Synchronization did not happen after assignment in sourced allocation!"
+     end if 
+  end if
+  sync all
+  if ( me == 1 ) then
+     write(*,'(a)') "Test passed."
+  end if
+end program source_allocation_no_sync
diff --git a/src/tests/regression/reported/issue-292-convert-type-before-put.f90 b/src/tests/regression/reported/issue-292-convert-type-before-put.f90
new file mode 100644
index 0000000..de14e45
--- /dev/null
+++ b/src/tests/regression/reported/issue-292-convert-type-before-put.f90
@@ -0,0 +1,58 @@
+! BSD 3-Clause License
+!
+! Copyright (c) 2016, Sourcery Institute
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!
+! * Redistributions of source code must retain the above copyright notice, this
+!   list of conditions and the following disclaimer.
+!
+! * Redistributions in binary form must reproduce the above copyright notice,
+!   this list of conditions and the following disclaimer in the documentation
+!   and/or other materials provided with the distribution.
+!
+! * Neither the name of the copyright holder nor the names of its
+!   contributors may be used to endorse or promote products derived from
+!   this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+! Comments preceded by "!!" are formatted for the FORD docoumentation generator
+program main
+  !! author: Damian Rouson
+  !! date: 2016-12-21
+  !! category: regression
+  !! Test whether implicit type conversion occurs before coarray put
+  !! OpenCoarrays issue #292
+  use iso_fortran_env, only : error_unit
+  implicit none
+  real :: a[*]
+  integer :: receiver
+  associate(me=>this_image(),ni=>num_images())
+    if (me == 1) then
+      put_realme_on_remote_image: do receiver= 2, ni
+        a[receiver] = receiver ! implicit real(receiver) needed here
+        sync images (receiver) ! notify remote image that data has been put
+      end do put_realme_on_remote_image
+    else
+      sync images (1) ! await notification of data put by image 1
+      if (a/=real(me)) then
+        write(error_unit,*) "Test failed on image ",me,": received ",a,", expected ",real(me)
+        error stop
+      end if
+    end if
+    sync all ! wait for every image to pass the test
+    if (me==1) print *,"Test passed."
+  end associate
+end program
diff --git a/src/tests/regression/reported/issue-293-silent-event-failure.F90 b/src/tests/regression/reported/issue-293-silent-event-failure.F90
new file mode 100644
index 0000000..facb940
--- /dev/null
+++ b/src/tests/regression/reported/issue-293-silent-event-failure.F90
@@ -0,0 +1,46 @@
+! BSD 3-Clause License
+!
+! Copyright (c) 2016, Sourcery Institute
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!
+! * Redistributions of source code must retain the above copyright notice, this
+!   list of conditions and the following disclaimer.
+!
+! * Redistributions in binary form must reproduce the above copyright notice,
+!   this list of conditions and the following disclaimer in the documentation
+!   and/or other materials provided with the distribution.
+!
+! * Neither the name of the copyright holder nor the names of its
+!   contributors may be used to endorse or promote products derived from
+!   this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+! Comments preceded by "!!" are formatted for the FORD docoumentation generator
+program main
+  !! author: Damian Rouson
+  !! date: 2016-12-22
+  !! category: regression
+  !! Test posting a static event_type coarray
+  !! OpenCoarrays issue [#293](https://github.com/sourceryinstitute/opencoarrays/issues/293)
+  use iso_fortran_env, only : event_type
+  implicit none
+  type(event_type) :: test_post[*]
+
+  if (num_images()<3) error stop "exposing issue 293 requires num_images()>=3"
+  event post(test_post)
+  if (this_image()==1) print *,"Test passed."
+
+end program
diff --git a/src/tests/unit/collectives/CMakeLists.txt b/src/tests/unit/collectives/CMakeLists.txt
index c58127c..d565cf6 100644
--- a/src/tests/unit/collectives/CMakeLists.txt
+++ b/src/tests/unit/collectives/CMakeLists.txt
@@ -12,3 +12,9 @@ target_link_libraries(co_max_test OpenCoarrays)
 
 add_executable(co_reduce_test co_reduce.F90)
 target_link_libraries(co_reduce_test OpenCoarrays)
+
+add_executable(co_reduce_res_im co_reduce_res_im.f90)
+target_link_libraries(co_reduce_res_im OpenCoarrays)
+
+add_executable(co_reduce_string co_reduce_string.f90)
+target_link_libraries(co_reduce_string OpenCoarrays)
diff --git a/src/tests/unit/collectives/co_reduce_res_im.f90 b/src/tests/unit/collectives/co_reduce_res_im.f90
new file mode 100644
index 0000000..1dda635
--- /dev/null
+++ b/src/tests/unit/collectives/co_reduce_res_im.f90
@@ -0,0 +1,62 @@
+program co_reduce_res_im
+  !! author: Daniel Topa & Izaak Beekman
+  !! category: unit test
+  !!
+  !! This test is derived from
+  !! [issue #172](https://github.com/sourceryinstitute/opencoarrays/issues/172)
+  !! but tweaks the binary operator's (pure function) arguments have
+  !! `intent(in)` which results in a working/passing test
+
+  implicit none
+  integer :: value[ * ] !! Each image stores their image number here
+  integer :: k
+  value = this_image ( )
+  call co_reduce ( value, result_image = 1, operator = myProd )
+  !! value[k /= 1] undefined, value[ k == 1 ] should equal $n!$ where $n$ is `num_images()`
+  if ( this_image ( ) == 1 ) then
+     write ( * , '( "Number of images = ", g0 )' ) num_images ( )
+     do k = 1, num_images ( )
+        write ( * , '( 2( a, i0 ) )' ) 'value [ ', k, ' ] is ', value [ k ]
+        write ( * , '(a)' ) 'since RESULT_IMAGE is present, value on other images is undefined by the standard'
+     end do
+     write ( * , '( "Product  value = ", g0 )' ) value  !! should print num_images() factorial
+     if ( value == factorial( num_images() ) ) then
+        write ( * , '(a)' ) 'Test passed.'
+     else
+        write ( * , '(a, I0)') 'Answer should have been num_images()! = ', factorial( num_images() )
+        error stop 'Wrong answer for n! using co_reduce'
+     end if
+  end if
+
+
+contains
+
+  pure function myProd ( a, b ) result ( rslt )
+    !! Product function to be used in `co_reduce` reduction for
+    !! computing factorials. When `intent(in)` attribute is changed
+    !! to `value` tests fail
+    integer, intent(in) :: a, b
+    !! multiply two inputs together.  If we change `intent(in)` to
+    !! `value` the test fails despite being correct according to C1276
+    !! of F2008:
+    !!
+    !! > C1276 The specification-part of a pure function subprogram
+    !! > shall specify that all its nonpointer dummy data objects have
+    !! > the INTENT (IN) or the VALUE attribute.
+    !!
+    !! Thanks to @LadaF for pointing this out.
+    integer        :: rslt !! product of a*b
+    rslt = a * b
+  end function
+
+  pure function factorial ( n ) result ( rslt )
+    !! Compute $n!$
+    integer, intent(in) :: n
+    integer :: rslt
+    integer :: i
+    rslt = 1
+    do i = 1, n
+      rslt = rslt*i
+   end do
+ end function
+end program
diff --git a/src/tests/unit/collectives/co_reduce_string.f90 b/src/tests/unit/collectives/co_reduce_string.f90
new file mode 100644
index 0000000..ad094f9
--- /dev/null
+++ b/src/tests/unit/collectives/co_reduce_string.f90
@@ -0,0 +1,80 @@
+! Implement a usecase for co_reduce on char arrays.
+!
+! Copyright (c) 2012-2017, Sourcery, Inc.
+! All rights reserved.
+!
+! Unit tests for co_min: verify parallel, collective minimum
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!     * Redistributions of source code must retain the above copyright
+!       notice, this list of conditions and the following disclaimer.
+!     * Redistributions in binary form must reproduce the above copyright
+!       notice, this list of conditions and the following disclaimer in the
+!       documentation and/or other materials provided with the distribution.
+!     * Neither the name of Sourcery, Inc., nor the
+!       names of any other contributors may be used to endorse or promote products
+!       derived from this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE
+! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+program co_reduce_strings
+ 
+  implicit none
+
+  integer, parameter :: numstrings = 10, strlen = 6
+  character(len=strlen), dimension(:), allocatable :: strarr[:]
+  character(len=strlen) :: expect
+  integer :: i
+
+  ! Construct the strings by postfixing foo by a number.
+  associate (me => this_image())
+    allocate(strarr(numstrings)[*])
+    do i = 1, numstrings
+      write(strarr(i), "('foo'I02)") i * me
+    end do
+    ! Collectively reduce the maximum string.
+    call co_reduce(strarr, strmax)
+  end associate
+
+  ! No sync should be needed here, because the collective (reduce_all)
+  ! implicitly synchronizes.
+  associate (np => num_images())
+    do i = 1, np
+      write (expect, "('foo'I02)") i * np
+      if (strarr(i) /= expect) then
+        ! On errror print what we got and what we expected.
+        print *, "Got: ", strarr(i), ", expected: ", expect
+        error stop "Didn't get expected string."
+      end if
+    end do
+  end associate
+  sync all
+  if (this_image() == 1) print *, "Test passed."
+contains
+
+  !! Compare two strings and return the maximum one. In a co_reduce no deferred-
+  !! length strings are allowed, therefore fixed length had to be used.
+  !! For identical strings the LHS is returned.
+  pure function strmax(lhs, rhs) result(maxstr) bind(C,name="strmax")
+    character(len=strlen), intent(in) :: lhs,rhs
+    character(len=strlen) :: maxstr
+
+    if (lhs > rhs) then
+      maxstr = lhs 
+    else 
+      maxstr = rhs
+    end if
+  end function
+
+end program co_reduce_strings
+
diff --git a/src/tests/unit/extensions/CMakeLists.txt b/src/tests/unit/extensions/CMakeLists.txt
index f6fbf5e..452c0c2 100644
--- a/src/tests/unit/extensions/CMakeLists.txt
+++ b/src/tests/unit/extensions/CMakeLists.txt
@@ -16,11 +16,6 @@ function(generate_test_script base_name num_images)
   )
   # Now we write the script that compiles and runs the test
   set(harness "${CMAKE_BINARY_DIR}/bin_staging/test-${base_name}-extension.sh")
-  install(
-      FILES "${harness}"
-      PERMISSIONS WORLD_EXECUTE WORLD_READ WORLD_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ GROUP_WRITE
-      DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
-  )
   file(WRITE  "${harness}" "#!/bin/bash\n")
   file(APPEND "${harness}" "cd ${CMAKE_CURRENT_BINARY_DIR}\n")
   set(executable "${base_name}_extension")
@@ -35,6 +30,11 @@ function(generate_test_script base_name num_images)
     file(APPEND "${harness}" "FC=mpif90 ${CMAKE_INSTALL_PREFIX}/bin/caf ${source} -o ${executable} -DUSE_EXTENSIONS\n")
   endif()
   file(APPEND "${harness}" "${CMAKE_INSTALL_PREFIX}/bin/cafrun -np ${num_images} ./${executable}\n")
+  file( INSTALL "${harness}"
+    PERMISSIONS WORLD_EXECUTE WORLD_READ OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ
+    DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+  )
+
 endfunction(generate_test_script)
 
 generate_test_script(co_sum 4)
diff --git a/src/tests/unit/init_register/CMakeLists.txt b/src/tests/unit/init_register/CMakeLists.txt
index 90fb3c2..10cff66 100644
--- a/src/tests/unit/init_register/CMakeLists.txt
+++ b/src/tests/unit/init_register/CMakeLists.txt
@@ -1,17 +1,31 @@
-add_executable(initialize_mpi initialize_mpi.f90)
+add_executable(initialize_mpi initialize_mpi.F90)
 target_link_libraries(initialize_mpi OpenCoarrays)
 
 add_executable(register register.f90)
 target_link_libraries(register OpenCoarrays)
 
-add_executable(register_rename_me register_rename_me.f90)
-target_link_libraries(register_rename_me OpenCoarrays)
+add_executable(register_vector register_vector.f90)
+target_link_libraries(register_vector OpenCoarrays)
 
-add_executable(register_rename_me_too register_rename_me_too.f90)
-target_link_libraries(register_rename_me_too OpenCoarrays)
+add_executable(register_alloc_vector register_alloc_vector.f90)
+target_link_libraries(register_alloc_vector OpenCoarrays)
 
 add_executable(allocate_as_barrier allocate_as_barrier.f90)
 target_link_libraries(allocate_as_barrier OpenCoarrays)
 
 add_executable(allocate_as_barrier_proc allocate_as_barrier_proc.f90)
 target_link_libraries(allocate_as_barrier_proc OpenCoarrays)
+
+if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7))
+  add_executable(async_comp_alloc async_comp_alloc.f90)
+  target_link_libraries(async_comp_alloc OpenCoarrays)
+
+  add_executable(register_alloc_comp_1 register_alloc_comp_1.f90)
+  target_link_libraries(register_alloc_comp_1 OpenCoarrays)
+
+  add_executable(register_alloc_comp_2 register_alloc_comp_2.f90)
+  target_link_libraries(register_alloc_comp_2 OpenCoarrays)
+
+  add_executable(register_alloc_comp_3 register_alloc_comp_3.f90)
+  target_link_libraries(register_alloc_comp_3 OpenCoarrays)
+endif()
diff --git a/src/tests/unit/init_register/async_comp_alloc.f90 b/src/tests/unit/init_register/async_comp_alloc.f90
new file mode 100644
index 0000000..8895684
--- /dev/null
+++ b/src/tests/unit/init_register/async_comp_alloc.f90
@@ -0,0 +1,121 @@
+! async_comp_alloc.f90 
+
+! Unit test for register procedure and remote allocated test:
+! Test that scalar allocatable component in a derived typed coarray is
+! registered correctly, its allocation is deferred until the program
+! allocates it specifically, and it is deregisterable. The component 
+! allocation checks are done on remote images.
+!
+! Copyright (c) 2012-2016, Sourcery, Inc.
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!     * Redistributions of source code must retain the above copyright
+!       notice, this list of conditions and the following disclaimer.
+!     * Redistributions in binary form must reproduce the above copyright
+!       notice, this list of conditions and the following disclaimer in the
+!       documentation and/or other materials provided with the distribution.
+!     * Neither the name of the Sourcery, Inc., nor the
+!       names of its contributors may be used to endorse or promote products
+!       derived from this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
+! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+program async_comp_alloc
+  implicit none
+
+  type dt
+    integer, allocatable :: i
+  end type dt
+  type(dt), allocatable :: obj[:]
+    !! Container object for testing component allocation status
+
+  logical, parameter :: verbose=.true. 
+    !! Toggle verbose output for debugging purposes
+
+  integer :: allocation_status
+  integer, parameter :: success=0
+    !! Successful allocation status value
+
+
+  associate(me=>this_image(),np=>num_images())
+    !! Make me & np locally immutable by associating them with function results
+
+    call assert( np > 1, "num_images()>1")
+      !! Ensure at least two images to simplify the test 
+
+    allocate(obj[*],stat=allocation_status)
+      !! Allocate only the container. obj%i must not be allocated hereafter.
+
+    call assert(allocation_status == success, "allocated(obj)")
+    call assert(.not. allocated(obj%i)      , ".not. allocated(obj%i)")
+
+    if (me==1) print *,"known failure -- ctest will timeout (see https://github.com/sourceryinstitute/opencoarrays/issues/260)."
+
+    block 
+      integer :: allocating_image, test_image
+      character(len=8) :: image_number
+
+      loop_over_all_image_numbers: do allocating_image = 1, np
+        !! Check that all allocations have been performed up to allocating_image and
+        !! that no other allocations have been performed
+  
+        if (verbose) print *, me, "/", np, ": allocating_image=", allocating_image
+  
+        if (allocating_image /= me) then
+          sync all
+           !! Order allocations sequentially by image number: arrival of image 'allocating_image' 
+           !! at the sync all in the alternate branch launches the following test loop.
+          test_allocation_status: do test_image = 1, np
+            if (verbose) print *, me, "/", np, ": Checking", test_image, " for allocation status."
+            write(image_number,*) test_image
+            if (test_image <= allocating_image) then
+              call assert(allocated(obj[test_image]%i), " allocated(obj["//image_number//"]%i)" )
+                !! Enforce that image numbers up to mine have allocated their components
+            else
+              call assert(.not. allocated(obj[test_image]%i), ".not. allocated(obj["//image_number//"]%i) on image ")
+                !! Enforce that image numbers higher than 'image' should not have allocated their components yet
+            end if
+          end do test_allocation_status 
+        else
+          if (verbose) print *, me, "/", np, ": allocating..."
+          allocate(obj%i, source = me)
+            !! TODO: should we also ensure that implicit (re)allocation upon assignment works here?
+          if (verbose) print *, me, "/", np, ": allocated"
+          ! Enforce that object has been allocated and obj%i is this_image():
+          call assert( allocated(obj)  , "allocated(obj)")
+          call assert( allocated(obj%i), "allocated(obj%i)")
+          call assert( obj%i == me     , "obj%i == this_image()")
+          sync all
+        end if
+      end do loop_over_all_image_numbers
+    end block
+  end associate
+contains
+  subroutine assert(assertion,description,stat)
+    logical, intent(in) :: assertion 
+    character(len=*), intent(in) :: description
+    integer, intent(out), optional:: stat
+    integer, parameter :: failure=1
+    if (assertion) then
+       if (present(stat)) stat=success
+    else
+      if (present(stat)) then
+        stat=failure
+      else
+        error stop "Assertion "// description //" failed."
+      end if
+    end if
+  end subroutine
+end program
+
diff --git a/src/tests/unit/init_register/initialize_mpi.f90 b/src/tests/unit/init_register/initialize_mpi.F90
similarity index 89%
rename from src/tests/unit/init_register/initialize_mpi.f90
rename to src/tests/unit/init_register/initialize_mpi.F90
index 88dba1f..074b754 100644
--- a/src/tests/unit/init_register/initialize_mpi.f90
+++ b/src/tests/unit/init_register/initialize_mpi.F90
@@ -26,8 +26,19 @@
 ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 !
 program initialize_mpi
+#ifdef MPI_WORKING_MODULE
   use mpi, only : MPI_COMM_SIZE,MPI_COMM_WORLD
   implicit none
+#else
+  implicit none
+  include 'mpif.h'
+  interface
+     subroutine MPI_COMM_SIZE(mpi_comm,nranks,ierr)
+       integer, intent(in)  :: mpi_comm
+       integer, intent(out) :: nranks, ierr
+     end subroutine
+  end interface
+#endif
 
   ! Set invalid default image number and number of ranks
   integer :: me=-1,np=-1,ierr
diff --git a/src/tests/unit/init_register/register_alloc_comp_1.f90 b/src/tests/unit/init_register/register_alloc_comp_1.f90
new file mode 100644
index 0000000..576f047
--- /dev/null
+++ b/src/tests/unit/init_register/register_alloc_comp_1.f90
@@ -0,0 +1,74 @@
+! Unit test for register and allocated procedure.
+!
+! Test that scalar allocatable component in a derived typed coarray is
+! registered correctly, delayed allocatable and deregisterable. The checks
+! whether a component is allocated are done on this_image only.
+!
+! Copyright (c) 2012-2016, Sourcery, Inc.
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!     * Redistributions of source code must retain the above copyright
+!       notice, this list of conditions and the following disclaimer.
+!     * Redistributions in binary form must reproduce the above copyright
+!       notice, this list of conditions and the following disclaimer in the
+!       documentation and/or other materials provided with the distribution.
+!     * Neither the name of the Sourcery, Inc., nor the
+!       names of its contributors may be used to endorse or promote products
+!       derived from this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
+! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+program register_alloc_comp_1
+  implicit none
+
+  type dt
+    integer, allocatable :: i
+  end type dt
+
+  integer :: np = -2
+  type(dt), allocatable :: obj[:]
+
+  np = num_images()
+
+  ! Allocate only the container. obj%i must not be allocated hereafter.
+  allocate(obj[*])
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (allocated(obj%i)) error stop "Test failed. 'obj%i' is allocated."
+
+  ! Allocate the component.
+  allocate(obj%i, source=this_image())
+
+  ! Now both objects have to be allocated and obj%i set to this_image()
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (.not. allocated(obj%i)) error stop "Test failed. 'obj%i' not allocated."
+  if (obj%i /= this_image()) error stop "Test failed. obj%i /= this_image()."
+
+  ! Deallocate the component.
+  deallocate(obj%i)
+
+  ! and test, that only the component is deallocated, but not the container.
+  if (allocated(obj%i)) error stop "Test failed. 'obj%i' still allocated."
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' no longer allocated."
+
+  ! Now deallocate the container, too.
+  deallocate(obj)
+
+  ! and check, that it worked.
+  if (allocated(obj)) error stop "Test failed. 'obj' still allocated."
+
+  ! Failing tests would make whole program error out.  Therefore it is save
+  ! to print the pass message on image one, only.
+  if (this_image() == 1) print *, "Test passed."
+end program
+
diff --git a/src/tests/unit/init_register/register_alloc_comp_2.f90 b/src/tests/unit/init_register/register_alloc_comp_2.f90
new file mode 100644
index 0000000..a3acd07
--- /dev/null
+++ b/src/tests/unit/init_register/register_alloc_comp_2.f90
@@ -0,0 +1,74 @@
+! Unit test for register and allocated procedure.
+!
+! Test that vector valued allocatable components in a derived typed coarray is
+! registered correctly, delayed allocatable and deregisterable. The checks
+! whether a component is allocated are done on this_image only.
+!
+! Copyright (c) 2012-2016, Sourcery, Inc.
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!     * Redistributions of source code must retain the above copyright
+!       notice, this list of conditions and the following disclaimer.
+!     * Redistributions in binary form must reproduce the above copyright
+!       notice, this list of conditions and the following disclaimer in the
+!       documentation and/or other materials provided with the distribution.
+!     * Neither the name of the Sourcery, Inc., nor the
+!       names of its contributors may be used to endorse or promote products
+!       derived from this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
+! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+program register_alloc_comp_2
+  implicit none
+
+  type dt
+    integer, allocatable, dimension(:) :: v
+  end type dt
+
+  integer :: np = -2
+  type(dt), allocatable :: obj[:]
+
+  np = num_images()
+
+  ! Allocate only the container. obj%v must not be allocated hereafter.
+  allocate(obj[*])
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (allocated(obj%v)) error stop "Test failed. 'obj%v' is allocated."
+
+  ! Allocate the component and initialize it with this_image()
+  allocate(obj%v(5), source=this_image())
+
+  ! Now both objects have to be allocated and obj%v(1:5) set to this_image()
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (.not. allocated(obj%v)) error stop "Test failed. 'obj%v' not allocated."
+  if (any (obj%v(:) /= this_image())) error stop "Test failed. obj%v(:) /= this_image()."
+
+  ! Deallocate the component.
+  deallocate(obj%v)
+
+  ! and test, that only the component is deallocated, but not the container.
+  if (allocated(obj%v)) error stop "Test failed. 'obj%v' still allocated."
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' no longer allocated."
+
+  ! Now deallocate the container, too.
+  deallocate(obj)
+
+  ! and check, that it worked.
+  if (allocated(obj)) error stop "Test failed. 'obj' still allocated."
+
+  ! Failing tests would make whole program error out.  Therefore it is save
+  ! to print the pass message on image one, only.
+  if (this_image() == 1) print *, "Test passed."
+end program
+
diff --git a/src/tests/unit/init_register/register_alloc_comp_3.f90 b/src/tests/unit/init_register/register_alloc_comp_3.f90
new file mode 100644
index 0000000..45894b6
--- /dev/null
+++ b/src/tests/unit/init_register/register_alloc_comp_3.f90
@@ -0,0 +1,75 @@
+! Unit test for register and allocated procedure.
+!
+! Test that matrix valued allocatable components in a derived typed coarray is
+! registered correctly, delayed allocatable and deregisterable. The checks
+! whether a component is allocated are done on this_image only.
+!
+! Copyright (c) 2012-2016, Sourcery, Inc.
+! All rights reserved.
+!
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+!     * Redistributions of source code must retain the above copyright
+!       notice, this list of conditions and the following disclaimer.
+!     * Redistributions in binary form must reproduce the above copyright
+!       notice, this list of conditions and the following disclaimer in the
+!       documentation and/or other materials provided with the distribution.
+!     * Neither the name of the Sourcery, Inc., nor the
+!       names of its contributors may be used to endorse or promote products
+!       derived from this software without specific prior written permission.
+!
+! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
+! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+program register_alloc_comp_3
+  implicit none
+
+  type dt
+    integer, allocatable, dimension(:,:) :: m
+  end type dt
+
+  integer :: np = -2
+  type(dt), allocatable :: obj[:]
+
+  np = num_images()
+
+  ! Allocate only the container. obj%i must not be allocated hereafter.
+  allocate(obj[*])
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (allocated(obj%m)) error stop "Test failed. 'obj%m' is allocated."
+ 
+  ! Allocate the component.
+  allocate(obj%m(3,6), source=this_image())
+
+  ! Now both objects have to be allocated and obj%m(1:3,1:6) set to this_image()
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' not allocated."
+  if (.not. allocated(obj%m)) error stop "Test failed. 'obj%m' not allocated."
+  if (any( ubound(obj%m) /= [3, 6])) error stop "Test failed. ubound(obj%m) /= [3, 6]."
+  if (any (obj%m(:,:) /= this_image())) error stop "Test failed. obj%m(:) /= this_image()."
+
+  ! Deallocate the component.
+  deallocate(obj%m)
+
+  ! and test, that only the component is deallocated, but not the container.
+  if (allocated(obj%m)) error stop "Test failed. 'obj%m' still allocated."
+  if (.not. allocated(obj)) error stop "Test failed. 'obj' no longer allocated."
+
+  ! Now deallocate the container, too.
+  deallocate(obj)
+
+  ! and check, that it worked.
+  if (allocated(obj)) error stop "Test failed. 'obj' still allocated."
+
+  ! Failing tests would make whole program error out.  Therefore it is save
+  ! to print the pass message on image one, only.
+  if (this_image() == 1) print *, "Test passed."
+end program
+
diff --git a/src/tests/unit/init_register/register_rename_me_too.f90 b/src/tests/unit/init_register/register_alloc_vector.f90
similarity index 100%
rename from src/tests/unit/init_register/register_rename_me_too.f90
rename to src/tests/unit/init_register/register_alloc_vector.f90
diff --git a/src/tests/unit/init_register/register_rename_me.f90 b/src/tests/unit/init_register/register_vector.f90
similarity index 100%
rename from src/tests/unit/init_register/register_rename_me.f90
rename to src/tests/unit/init_register/register_vector.f90
diff --git a/src/tests/unit/send-get/CMakeLists.txt b/src/tests/unit/send-get/CMakeLists.txt
index 308408f..9717bff 100644
--- a/src/tests/unit/send-get/CMakeLists.txt
+++ b/src/tests/unit/send-get/CMakeLists.txt
@@ -18,3 +18,6 @@ target_link_libraries(whole_get_array OpenCoarrays)
 
 add_executable(strided_get strided_get.f90)
 target_link_libraries(strided_get OpenCoarrays)
+
+add_executable(strided_sendget strided_sendget.f90)
+target_link_libraries(strided_sendget OpenCoarrays)
diff --git a/src/tests/unit/send-get/get_array_test.f90 b/src/tests/unit/send-get/get_array_test.f90
index db4e27a..e8d7dd2 100644
--- a/src/tests/unit/send-get/get_array_test.f90
+++ b/src/tests/unit/send-get/get_array_test.f90
@@ -14,8 +14,8 @@ program main
   call one(0, -11)
 
   ! Static coarrays
-!  call two()
-!  call three()
+  call two()
+  call three()
   write(*,*) 'Test passed'
 contains
   subroutine one(lb1, lb2)
@@ -42,7 +42,7 @@ contains
     end if
     sync all
     if(this_image()==1) then
-       if(any (a /= c))   call abort()
+       if(any (a /= c)) error stop "ARRAY = SCALAR failed in get_array_test"
     endif
 
     ! Whole array: ARRAY = ARRAY
@@ -59,7 +59,7 @@ contains
           print *, a
           print *, c
           ! FIXME: Without the print lines above, it always fails. Why?
-          call abort()
+          error stop "ARRAY = ARRAY failed in get_array_test"
        end if
     endif
 
@@ -98,7 +98,7 @@ contains
           print *, this_image(), ': ', a
           print *, this_image(), ': ', c
           ! FIXME: Without the print lines above, it always fails. Why?
-          call abort()
+          error stop "scalar assignment failed in get_array_test"
        end if
     endif
     ! Array sections with different ranges and pos/neg strides
@@ -130,7 +130,7 @@ contains
                                   print *, a
                                   print *, c
                                   print *, a-c
-                                  call abort()
+                                  error stop "array sections with ranges and strides failed in get_array_test"
                                endif
                             end if
                             ! ARRAY = ARRAY
@@ -155,7 +155,7 @@ contains
                                   print *, a
                                   print *, c
                                   print *, a-c
-                                  call abort()
+                                  error stop "array sections with ranges and strides failed in get_array_test"
                                endif
                             end if
                          end do
@@ -189,7 +189,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "Array = scalar failed in subroutine two get_array_test"
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -203,7 +203,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "Array = array failed in subroutine two get_array_test"
     end if
 
     ! Scalar assignment
@@ -235,7 +235,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "scalar assignment failed in subroutine two get_array_test"
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -280,7 +280,7 @@ contains
                         print *, a
                         print *, caf
                         print *, a-caf
-                        call abort()
+                        error stop "arrays with ranges and strides failed sub. two get_array_test failed"
                       endif
                     end if
                   end do
@@ -314,7 +314,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "Array = scalar subroutine three get_array_test failed"
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -328,7 +328,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "Array = array subroutine three get_array_test failed"
     end if
 
     ! Scalar assignment
@@ -360,7 +360,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop "scalar assignment subroutine three get_array_test failed"
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -405,7 +405,7 @@ contains
                         print *, a
                         print *, caf
                         print *, a-caf
-                        call abort()
+                        error stop "range stride in subroutine three get_array_test failed"
                       endif
                     end if
                   end do
diff --git a/src/tests/unit/send-get/get_with_offset_1d.f90 b/src/tests/unit/send-get/get_with_offset_1d.f90
index c26d2ea..417d20d 100644
--- a/src/tests/unit/send-get/get_with_offset_1d.f90
+++ b/src/tests/unit/send-get/get_with_offset_1d.f90
@@ -23,9 +23,9 @@ program get_offset_1d
 
   if(me == 1) then
     do i=1,10
-      if(b(i) /= 20+i+me+1) call abort()
+      if(b(i) /= 20+i+me+1) error stop "get offset 1d failed"
     enddo
-    write(*,*) 'Test passed.'
   endif
-sync all
+  sync all
+  if(me ==1) write(*,*) 'Test passed.'
 end program
diff --git a/src/tests/unit/send-get/old_get_array_test.f90 b/src/tests/unit/send-get/old_get_array_test.f90
index 3493466..3775119 100644
--- a/src/tests/unit/send-get/old_get_array_test.f90
+++ b/src/tests/unit/send-get/old_get_array_test.f90
@@ -45,7 +45,7 @@ contains
       if (any (a /= b(lb1,lb2))) then
 ! FIXME: ABORTS UNLESS THERE IS SOME OTHER CODE
 print *, 'HELLO!!!!!!!!!!!!!!!!!'
-        call abort()
+        error stop
       end if
     end if
 
@@ -63,7 +63,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
         print *, a
         print *, b
         print *, 'WRONG:', any (a /= b)
-        call abort()
+        error stop
       end if
     end if
 
@@ -114,7 +114,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
  !                       print *, a
  !                       print *, caf
  !                       print *, a-caf
- !                       call abort()
+ !                       error stop
  !                     endif
                     end if
                   end do
@@ -152,7 +152,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
     sync all
     if (this_image() == 1) then
       if (any (a /= b)) &
-           call abort()
+           error stop
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -170,7 +170,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
     sync all
     if (this_image() == 1) then
       if (any (a /= b)) &
-           call abort()
+           error stop
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -221,7 +221,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
  !                       print *, a
  !                       print *, caf
  !                       print *, a-caf
- !                       call abort()
+ !                       error stop
  !                     endif
                     end if
                   end do
@@ -259,7 +259,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
     sync all
     if (this_image() == 1) then
       if (any (a /= b)) &
-           call abort()
+           error stop
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -277,7 +277,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
     sync all
     if (this_image() == 1) then
       if (any (a /= b)) &
-           call abort()
+           error stop
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -329,7 +329,7 @@ print *, 'HELLO!!!!!!!!!!!!!!!!!'
 !                        print *, a
 !                        print *, caf
 !                        print *, a-caf
-!                        call abort()
+!                        error stop
 !                      endif
                     end if
                   end do
diff --git a/src/tests/unit/send-get/sameloc.f90 b/src/tests/unit/send-get/sameloc.f90
index c511c69..46dc299 100644
--- a/src/tests/unit/send-get/sameloc.f90
+++ b/src/tests/unit/send-get/sameloc.f90
@@ -12,6 +12,9 @@ program sameloc
   integer,dimension(9,10),codimension[*] :: m
   integer,dimension(10) :: t
   integer :: i,j
+  logical :: tests_passed
+
+  tests_passed = .true.
 
   a = 10
   b(1:5) = 1
@@ -36,9 +39,11 @@ program sameloc
   if(this_image() == 1) then
     c = m(1,:)[1]
     if(any(c(:) /= t(:))) then
-      call abort()
+      tests_passed = .false.
+      error stop "get row failed"
     else
-      write(*,*) 'ok get row'
+     tests_passed = tests_passed .and. .true.
+     write(*,*) 'ok get row'
     endif
   endif
 
@@ -48,12 +53,15 @@ program sameloc
     do i=1,10
       if(m(9,i)[1] /= t(i)) then
 	write(*,*) 'pos',i,'value get',m(9,i)[1],'value t',t(i)
-	call abort()
+        tests_passed = .false.
+        error stop "get element from matrix failed"
+      else
+        tests_passed = tests_passed .and. .true.
       endif
     enddo
   endif
 
-  if(this_image() == 1) write(*,*) 'Ok get element from matrix'
+  if (this_image() == 1) write(*,*) 'Ok get element from matrix'
 
   sync all
 
@@ -64,12 +72,15 @@ program sameloc
       m(9,i)[1] = i
       if(m(9,i)[1] /= t(i)) then
         write(*,*) 'pos',i,'value get',m(9,i)[1],'value t',t(i)
-        call abort()
+        tests_passed = .false.
+        error stop "put element from matrix failed"
+      else
+        tests_passed = tests_passed .and. .true.
       endif
     enddo
   endif
 
-  if(this_image() == 1 ) write(*,*) 'Ok put element from matrix'
+  if (this_image() == 1) write(*,*) 'Ok put element from matrix'
 
   t(:) = b(:)
   t(1:5) = b(2:6)
@@ -82,8 +93,10 @@ program sameloc
   if(this_image() == 1) then
     b(1:5)[1] = b(2:6)
     if(any(b(:) /= t(:))) then
-      call abort()
+      tests_passed = .false.
+      error stop "put overlapped failed"
     else
+      tests_passed = tests_passed .and. .true.
       write(*,*) 'OK put overlapped'
     endif
   endif
@@ -96,8 +109,10 @@ program sameloc
   if(this_image() == 1) then
     b(1:5)[1] = b(2:6)[1]
     if(any(b(:) /= t(:))) then
-      call abort()
+      tests_passed = .false.
+      error stop "putget overlapped failed"
     else
+      tests_passed = tests_passed .and. .true.
       write(*,*) 'OK putget overlapped'
     endif
   endif
@@ -110,11 +125,13 @@ program sameloc
   if(this_image() == 1) then
     c(10:1:-1)[1] = c(:)
     if(any(t(:) /= c(:))) then
+      tests_passed = .false.
       write(*,*) 'Error in put reversed'
       write(*,*) c
       write(*,*) t
-      call abort()
+      error stop "put reversed failed"
     else
+      tests_passed = tests_passed .and. .true.
       write(*,*) 'OK put reversed'
     endif
   endif
@@ -128,12 +145,24 @@ program sameloc
   if(this_image() == 1) then
     c(:) = c(10:1:-1)[1]
     if(any(t(:) /= c(:))) then
+      tests_passed = .false.
       write(*,*) c
       write(*,*) t
-      call abort()
+      error stop "get reversed failed"
     else
+      tests_passed = tests_passed .and. .true.
       write(*,*) 'OK get reversed'
     endif
   endif
 
+  if ( .not. tests_passed ) then
+     error stop "Test failures exist!"
+  end if
+
+  sync all
+
+  if ( tests_passed ) then
+    if (this_image() == 1) write(*,*) 'Test passed'
+  end if
+
 end program
diff --git a/src/tests/unit/send-get/send_array_test.f90 b/src/tests/unit/send-get/send_array_test.f90
index 997b7af..9872c1f 100644
--- a/src/tests/unit/send-get/send_array_test.f90
+++ b/src/tests/unit/send-get/send_array_test.f90
@@ -42,7 +42,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -56,7 +56,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Scalar assignment
@@ -88,7 +88,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -133,7 +133,7 @@ contains
                         print *, a
                         print *, caf
                         print *, a-caf
-                        call abort()
+                        error stop
                       endif
                     end if
                   end do
@@ -167,7 +167,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -181,7 +181,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Scalar assignment
@@ -213,7 +213,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -258,7 +258,7 @@ contains
                         print *, a
                         print *, caf
                         print *, a-caf
-                        call abort()
+                        error stop
                       endif
                     end if
                   end do
@@ -292,7 +292,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Whole array: ARRAY = ARRAY
@@ -306,7 +306,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Scalar assignment
@@ -338,7 +338,7 @@ contains
     sync all
     if (this_image() == num_images()) then
       if (any (a /= caf)) &
-           call abort()
+           error stop
     end if
 
     ! Array sections with different ranges and pos/neg strides
@@ -383,7 +383,7 @@ contains
                         print *, a
                         print *, caf
                         print *, a-caf
-                        call abort()
+                        error stop
                       endif
                     end if
                   end do
diff --git a/src/tests/unit/send-get/strided_get.f90 b/src/tests/unit/send-get/strided_get.f90
index 6ed732f..83089eb 100644
--- a/src/tests/unit/send-get/strided_get.f90
+++ b/src/tests/unit/send-get/strided_get.f90
@@ -18,8 +18,10 @@ program strided_get
 
   if(me == 2) then
     bc(1:2,:,:,:) = ac(0:1,:,:,:)[me-1]
-    if(any(bc(1:2,:,:,:) /= 1)) call abort()
-    write(*,*) 'Test passed.'
+    if(any(bc(1:2,:,:,:) /= 1)) error stop "strided get test failed"
   endif
 
+  sync all
+
+  if (me == 2) write(*,*) 'Test passed.'
 end program
diff --git a/src/tests/unit/send-get/strided_sendget.f90 b/src/tests/unit/send-get/strided_sendget.f90
new file mode 100644
index 0000000..fd8c6ed
--- /dev/null
+++ b/src/tests/unit/send-get/strided_sendget.f90
@@ -0,0 +1,109 @@
+! Test that sendget with strides on either side (of the assignment) works
+! as expected.
+!
+! This test needs at least three images, because sendget has the potential
+! to check whether on image used in the communication is the current one.
+! More than three images do not pay, because there is no general code in
+! this test.
+!
+! Written by Andre Vehreschild
+
+program stridedsendgettest
+
+  implicit none
+
+  integer, parameter :: src_image = 2, dst_image = 3, master_image = 1
+  integer, save, dimension(4,6) :: srcmat[*], dstmat[*]
+  integer, save, dimension(6) :: srcvec[*], dstvec[*]
+  integer :: i
+  logical :: test_passed = .true.
+
+  ! Make sure that enough images are available for this test.
+  ! Everything less than dst_image == 3 may make sendget use an
+  ! optimized version saving a part of the communication, which is
+  ! not what the test should test.
+  if (num_images() < dst_image) then
+     print*, "Pretend that the test was run and passed, even though there are too few images to perform test:"
+     print*, "Test passed"
+     error stop "Need at least three images."
+  end if
+
+  ! On the src_image, set some defined values, to be able to distinguish
+  ! strides going wrong.
+  if (this_image() == src_image) then
+    srcvec = [(2 * i, i = 1, 6)]
+    srcmat = reshape([(i * 2, i = 1, 4*6)], [4,6])
+  ! On the dst_image set values that enable to recognize unset values.
+  elseif (this_image() == dst_image) then
+    dstmat = -1
+    dstvec = -2
+  end if
+
+  ! Make sure data is valid on all images.
+  sync all
+
+  ! master_image is the controller in this communication and therefore needs
+  ! to initiate the communication.
+  if (this_image() == master_image) then
+    ! Transfer data from the src-vector to the dst-vector on image
+    ! dst_image.  This is a transfer of a contingous block of data and here for
+    ! completeness only.
+    dstvec(:)[dst_image] = srcvec(:)[src_image]
+    ! This statement uses a stride in the send phase of the communication.
+    dstmat(3,:)[dst_image] = srcvec(:)[src_image]
+  end if
+
+  ! Make sure the communication has completed.
+  sync all
+
+  ! Check the result of communication on the dst_image.
+  if (this_image() == dst_image) then
+    ! Check that transfering to the vector has succeeded.
+    if (any(dstvec /= [2, 4, 6, 8, 10, 12])) error stop "SendGet vec/vec does not match."
+
+    ! Check that transfering a vector into a matrix changes only the
+    ! values desired.
+    if (any(dstmat /= reshape([-1, -1,  2, -1, &
+                               -1, -1,  4, -1, &
+                               -1, -1,  6, -1, &
+                               -1, -1,  8, -1, &
+                               -1, -1, 10, -1, &
+                               -1, -1, 12, -1], [4, 6]))) then
+      error stop "SendGet matrow/vec does not match."
+    end if
+    ! Reset the dst-buffers to enable new test.
+    dstvec = -2
+    dstmat = -1
+  end if
+
+  ! Wait for dst having done its tests.
+  sync all
+  if (this_image() == master_image) then
+    ! Execute strided get in sendget and store in a vector to just
+    ! test the get.
+    dstvec(:)[dst_image] = srcmat(2,:)[src_image]
+    ! Test both strided get and strided send at once.
+    dstmat(3,:)[dst_image] = srcmat(2,:)[src_image]
+  end if
+
+  ! Ensure that the communication is all done.
+  sync all
+  if (this_image() == dst_image) then
+    ! Check, that the strided get has the expected result.
+    if (any(dstvec /= [4, 12, 20, 28, 36, 44])) error stop "SendGet vec/matrow does not match."
+
+    ! And that both communications with stride work as expected.
+    if (any(dstmat /= reshape([-1, -1,  4, -1, &
+                               -1, -1, 12, -1, &
+                               -1, -1, 20, -1, &
+                               -1, -1, 28, -1, &
+                               -1, -1, 36, -1, &
+                               -1, -1, 44, -1], [4, 6]))) then
+      error stop "SendGet matrow/matrow does not match."
+    end if
+
+    ! Above checks would stop with an error on failure, so its save
+    ! to unguardedly print here, when all tests pass.
+    print *, "Test passed"
+  end if
+end program
diff --git a/src/tests/unit/send-get/whole_get_array.f90 b/src/tests/unit/send-get/whole_get_array.f90
index e90e9bf..d2a43e2 100644
--- a/src/tests/unit/send-get/whole_get_array.f90
+++ b/src/tests/unit/send-get/whole_get_array.f90
@@ -20,8 +20,7 @@ program whole_array_get
   if(me == 1) then
      y1 = x1(:)[me+1]
      if(any(y1 /= 2)) then
-        write(*,*) 'Test 1 fails'
-        call abort()
+        error stop 'Test 1 fails'
      end if
   end if
 
@@ -35,8 +34,7 @@ program whole_array_get
   if(me == 1) then
      y2 = x2(:,:)[np]
      if(any(y2 /= np)) then
-        write(*,*) 'Test 2 fails'
-        call abort()
+        error stop 'Test 2 fails'
      end if
   end if
 
@@ -49,8 +47,7 @@ program whole_array_get
   if(me == 1) then
      y1 = x2(:,n/2)[me+1]
      if(any(y1 /= 2+n/2)) then
-        write(*,*) 'Test 3 fails'
-        call abort()
+        error stop 'Test 3 fails'
      end if
   end if
 
@@ -64,8 +61,7 @@ program whole_array_get
   if(me == 1) then
      y3 = x3(:,:,:)[me+1]
      if(any(y3 /= me+1)) then
-        write(*,*) 'Test 4 fails'
-        call abort()
+        error stop 'Test 4 fails'
      end if
   endif
 
@@ -79,8 +75,7 @@ program whole_array_get
   if(me == 1) then
      y3(:,n/2,:) = x3(:,:,n/2)[me+1]
      if(any(y3(:,n/2,:) /= me+1+n/2)) then
-        write(*,*) 'Test 5 fails'
-        call abort()
+        error stop 'Test 5 fails'
      end if
   endif
 
diff --git a/src/tests/unit/simple/CMakeLists.txt b/src/tests/unit/simple/CMakeLists.txt
index e216fbb..85159af 100644
--- a/src/tests/unit/simple/CMakeLists.txt
+++ b/src/tests/unit/simple/CMakeLists.txt
@@ -1,9 +1,4 @@
 # Fortran tests
-add_executable(sync_images syncimages.f90)
-target_link_libraries(sync_images OpenCoarrays)
-
-add_executable(is_there_a_better_name syncimages2.f90)
-target_link_libraries(is_there_a_better_name OpenCoarrays)
 
 add_executable(increment_my_neighbor test1Caf.f90)
 target_link_libraries(increment_my_neighbor OpenCoarrays)
diff --git a/src/tests/unit/simple/syncimages.f90 b/src/tests/unit/simple/syncimages.f90
deleted file mode 100644
index 33309f8..0000000
--- a/src/tests/unit/simple/syncimages.f90
+++ /dev/null
@@ -1,58 +0,0 @@
-! syncimages test
-!
-! Copyright (c) 2012-2014, Sourcery, Inc.
-! All rights reserved.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!     * Redistributions of source code must retain the above copyright
-!       notice, this list of conditions and the following disclaimer.
-!     * Redistributions in binary form must reproduce the above copyright
-!       notice, this list of conditions and the following disclaimer in the
-!       documentation and/or other materials provided with the distribution.
-!     * Neither the name of the Sourcery, Inc., nor the
-!       names of its contributors may be used to endorse or promote products
-!       derived from this software without specific prior written permission.
-!
-! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
-! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-!
-program syncimages
-  implicit none
-
-  integer :: me,ne,i
-  integer :: p[*] = 0
-  logical :: test[*] = .true.
-
-  me = this_image()
-  ne = num_images()
-
-  if(me == 1) then
-    p = 1
-  else
-    sync images( me-1 )
-    p = p[me-1] +1
-  endif
-
-  if(me<ne) sync images( me+1 )
-
-  if(me /= p) test = .false.
-
-  sync all
-
-  if(me == 1) then
-    do i=1,ne
-      if(test[i].eqv..false.) error stop "Test failed."
-    enddo
-  endif
-
-  if(me==1) print *,"Test passed."
-
-end program
diff --git a/src/tests/unit/simple/syncimages2.f90 b/src/tests/unit/simple/syncimages2.f90
deleted file mode 100644
index 5674181..0000000
--- a/src/tests/unit/simple/syncimages2.f90
+++ /dev/null
@@ -1,44 +0,0 @@
-! syncimages2 test
-!
-! Copyright (c) 2012-2014, Sourcery, Inc.
-! All rights reserved.
-!
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-!     * Redistributions of source code must retain the above copyright
-!       notice, this list of conditions and the following disclaimer.
-!     * Redistributions in binary form must reproduce the above copyright
-!       notice, this list of conditions and the following disclaimer in the
-!       documentation and/or other materials provided with the distribution.
-!     * Neither the name of the Sourcery, Inc., nor the
-!       names of its contributors may be used to endorse or promote products
-!       derived from this software without specific prior written permission.
-!
-! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-! DISCLAIMED. IN NO EVENT SHALL SOURCERY, INC., BE LIABLE FOR ANY
-! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-!
-
-! The test passes if it terminates
-! If the test fails you will get an error or a non-termination.
-
-program syncimages2
-  implicit none
-
-  if(this_image() == 1) then
-    sync images(*)
-  else
-    sync images(1)
-  endif
-
-  sync all
-
-  if(this_image()==1) print *,"Test passed."
-
-end program
diff --git a/src/tests/unit/simple/test1Caf.f90 b/src/tests/unit/simple/test1Caf.f90
index fea1905..f458995 100644
--- a/src/tests/unit/simple/test1Caf.f90
+++ b/src/tests/unit/simple/test1Caf.f90
@@ -52,12 +52,16 @@ program test1caf
 
   if(me < np) sync images(me+1)
 
+  sync all
+
   if (mod(me,2).eq.0) then
     if ( any(a(:)[right]/=a_initial+me)) error stop "Test failed."
   else
     if ( any(b(:)[left]/=b_initial+me)) error stop "Test failed."
   end if
 
+  sync all
+
   if (me==1) print *,"Test passed."
 
 end program test1caf
diff --git a/src/tests/unit/simple/testAtomics.f90 b/src/tests/unit/simple/testAtomics.f90
index ebf00bf..a496e37 100644
--- a/src/tests/unit/simple/testAtomics.f90
+++ b/src/tests/unit/simple/testAtomics.f90
@@ -20,9 +20,15 @@ if(me == 1) then
   call atomic_ref(res,atom[1])
   if(res /= (np*(np+1))/2) then
     write(*,*) 'res',res
-    call abort()
+    error stop "Atomic ref failed"
   endif
   write(*,*) 'OK'
 endif
 
+sync all
+
+if (me == 1) then
+   write(*,*) "Test passed"
+end if
+
 end program
diff --git a/src/tests/unit/sync/CMakeLists.txt b/src/tests/unit/sync/CMakeLists.txt
index 5b5926d..c6b4bb4 100644
--- a/src/tests/unit/sync/CMakeLists.txt
+++ b/src/tests/unit/sync/CMakeLists.txt
@@ -4,8 +4,14 @@ target_link_libraries(syncall OpenCoarrays)
 add_executable(syncimages syncimages.f90)
 target_link_libraries(syncimages OpenCoarrays)
 
+add_executable(syncimages2 syncimages2.f90)
+target_link_libraries(syncimages2 OpenCoarrays)
+
 add_executable(duplicate_syncimages duplicate_syncimages.f90)
 target_link_libraries(duplicate_syncimages OpenCoarrays)
 
 add_executable(syncimages_status syncimages_status.f90)
 target_link_libraries(syncimages_status OpenCoarrays)
+
+add_executable(sync_image_ring_abort_on_stopped_image sync_image_ring_abort_on_stopped_image.f90)
+target_link_libraries(sync_image_ring_abort_on_stopped_image OpenCoarrays)
diff --git a/src/tests/unit/sync/sync_image_ring_abort_on_stopped_image.f90 b/src/tests/unit/sync/sync_image_ring_abort_on_stopped_image.f90
new file mode 100644
index 0000000..153f610
--- /dev/null
+++ b/src/tests/unit/sync/sync_image_ring_abort_on_stopped_image.f90
@@ -0,0 +1,33 @@
+program sync_image_ring_abort_on_stopped_image
+  !! `SYNC IMAGES([this_image - 1, this_image + 1])` with
+  !! `STAT=STAT_STOPPED_IMAGE` specifier on a periodic ring.  The test
+  !! checks that syncing in a ring with a stopped image still
+  !! terminates all images. All images other than image 1 participate
+  !! in the `sync images()` call
+
+  use, intrinsic:: iso_fortran_env
+  implicit none
+
+  integer :: stat_var = 0
+
+  if (num_images() .lt. 2) error stop "Need at least two images to test."
+
+  associate (me => this_image())
+    if (me == 1) then
+       continue !! image 1 does not participate and exits, creating a stopped image
+    else
+       associate (lhs => merge(me - 1, num_images(), me /= 1), &
+              rhs => merge(me + 1, 1, me /= num_images()))
+         sync images([lhs, rhs], STAT=stat_var)
+         !! Only images bordering image 1 (i.e., 2 and `num_images()`) can
+         !! accurately test whether a stopped image is present. All other
+         !! images could be up ahead.
+         if (stat_var /= STAT_STOPPED_IMAGE .and. me == 2) &
+              error stop "Error: stat_var /= STAT_STOPPED_IMAGE: "
+         if (stat_var /= STAT_STOPPED_IMAGE .and. me == num_images()) &
+              error stop "Error: stat_var /= STAT_STOPPED_IMAGE: "
+         if(me == 2) print *, 'Test passed.'
+       end associate
+    end if
+  end associate
+end program
diff --git a/src/tests/unit/sync/syncimages_status.f90 b/src/tests/unit/sync/syncimages_status.f90
index 52a2a4b..a90e6d9 100644
--- a/src/tests/unit/sync/syncimages_status.f90
+++ b/src/tests/unit/sync/syncimages_status.f90
@@ -10,7 +10,6 @@ program sync_images_stat
   me = this_image()
 
   if (me /= 1 ) then
-     call sleep(1)
      sync images(*,STAT=stat_var)
      if ( stat_var /= STAT_STOPPED_IMAGE) then
         print *, "Error:stat_var /= STAT_STOPPED_IMAGE: ", me
diff --git a/windows-install.sh b/windows-install.sh
new file mode 100755
index 0000000..1ee1c87
--- /dev/null
+++ b/windows-install.sh
@@ -0,0 +1,301 @@
+#/usr/bin/env bash
+#
+# windows-install.sh
+#
+# -- This script installs OpenCoarrays and its prerequisites.
+#
+# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
+# Copyright (c) 2015-2016, Sourcery, Inc.
+# Copyright (c) 2015-2016, Sourcery Institute
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+#    list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice, this
+#    list of conditions and the following disclaimer in the documentation and/or
+#    other materials provided with the distribution.
+# 3. Neither the names of the copyright holders nor the names of their contributors
+#    may be used to endorse or promote products derived from this software without
+#    specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Portions of this script derive from BASH3 Boilerplate and are distributed under
+# the following license:
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2014 Kevin van Zonneveld
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+#
+#  - https://github.com/kvz/bash3boilerplate
+#  - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
+#
+# Version: 2.0.0
+#
+# Authors:
+#
+#  - Kevin van Zonneveld (http://kvz.io)
+#  - Izaak Beekman (https://izaakbeekman.com/)
+#  - Alexander Rathai (Alexander.Rathai at gmail.com)
+#  - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation)
+#
+# Licensed under MIT
+# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
+
+# The invocation of bootstrap.sh below performs the following tasks:
+# (1) Import several bash3boilerplate helper functions & default settings.
+# (2) Set several variables describing the current file and its usage page.
+# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
+# (4) Parse the command line using the usage information.
+
+### Start of boilerplate -- do not edit this block #######################
+export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%/}}"
+if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
+  echo "Please run this script inside the top-level OpenCoarrays source directory or "
+  echo "set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
+  exit 1
+fi
+export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
+if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
+  echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
+  exit 2
+else
+    # shellcheck source=./prerequisites/use-case/bootstrap.sh
+    source "${B3B_USE_CASE}/bootstrap.sh" "$@"
+fi
+### End of boilerplate -- start user edits below #########################
+
+# Set expected value of present flags that take no arguments
+export __flag_present=1
+
+# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if
+# not needed. Other signals can be trapped too, like SIGINT and SIGTERM.
+function cleanup_before_exit () {
+  info "Cleaning up. Done"
+}
+trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc.
+
+### Validation (decide what's required for running your script and error out)
+#####################################################################
+
+[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. "
+
+# shellcheck disable=SC2154
+if [[ "${arg_d}" == "${__flag_present}" ]]; then 
+   print_debug_only=7
+   if [ "$(( LOG_LEVEL < print_debug_only ))" -ne 0 ]; then
+     debug "Supressing info and debug messages: one of {-l, -v, -P, -U, -V, -D} present."
+     suppress_info_debug_messages
+   fi
+fi
+
+# Get linux_distribution name
+{
+info "__file: ${__file}"
+info "__dir: ${__dir}"
+info "__base: ${__base}"
+info "__os: ${__os}"
+info "__usage: ${__usage}"
+info "LOG_LEVEL: ${LOG_LEVEL}"
+
+info  "-c (--with-c):     [arg] ${arg_c}"
+info  "-C (--with-cxx):   [arg] ${arg_C}"
+info  "-d (--debug):            ${arg_d}"
+info  "-e (--verbose):          ${arg_e}"
+info  "-f (--with-fortran):     ${arg_e}"
+info  "-i (--install-prefix):   ${arg_i}"
+info  "-j (--num-threads):      ${arg_j}"
+info  "-m (--with-cmake): [arg] ${arg_m}"
+info  "-n (--no-color):         ${arg_n}"
+info  "-v (--version):          ${arg_v}"
+info  "-V (--version-number):   ${arg_V}"
+}
+
+# __________ Process command-line arguments and environment variables _____________
+
+export this_script="$(basename "$0")"
+debug "this_script=\"${this_script}\""
+
+export install_prefix="${arg_i%/:-${PWD}/prerequisites/installations}"
+info "install_prefix=\"${install_prefix}\""
+
+export num_threads="${arg_j}"
+info "num_threads=\"${arg_j}\""
+
+set_opencoarrays_version()
+{
+  cmake_project_line="$(grep project "${OPENCOARRAYS_SRC_DIR}/CMakeLists.txt" | grep VERSION)"
+  text_after_version_keyword="${cmake_project_line##*VERSION}"
+  text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
+  opencoarrays_version=$text_before_language_keyword
+  export opencoarrays_version="${opencoarrays_version//[[:space:]]/}"
+}
+set_opencoarrays_version
+
+export build_path="${OPENCOARRAYS_SRC_DIR%/}"/prerequisites/builds/opencoarrays/$opencoarrays_version
+info "build_path=\"${build_path}\""
+
+export CMAKE="${arg_m:-cmake}"
+
+verify_this_is_ubuntu()
+{
+  if [[ ${__os} != "Linux"  ]]; then
+    emergency "${__os} not supported: this script is intended for use in Windows Subsystem for Linux "
+  fi
+  linux_standard_base_i=`lsb_release -i`
+  untrimmed_name=${linux_standard_base_i##*Distributor ID:}
+  linux_distribution="${untrimmed_name//[[:space:]]/}"
+  info "Linux distribution: ${linux_distribution}"
+  if [[ "${linux_distribution:-}" != "Ubuntu" ]]; then
+    info "Please run this script inside the Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later,"
+    info "which might require joining the Windows Insider Preview program and selecting 'Fast' updates."
+    emergency "Error: see above."
+  fi
+}
+verify_this_is_ubuntu
+
+# Ubuntu 16.04 apt-get installs gfortran 5.4.0 or later, which is acceptable for many uses of OpenCoarrays
+verify_acceptable_release_number()
+{
+  linux_standard_base_r=`lsb_release -r`
+  untrimmed_name=${linux_standard_base_r##*Release:}
+  release_number="${untrimmed_name//[[:space:]]/}"
+  major_release="${release_number%%.*}"
+  minor_release="${release_number##*.}"
+  info "Release: ${major_release}.${minor_release}"
+  if [[ $major_release -lt 16  ]]; then
+    emergency "Please upgrade to Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later."
+  elif [[ $major_release -eq 16  ]]; then
+    if [[ $minor_release -lt "04"  ]]; then
+      emergency "Please upgrade to Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later."
+    fi
+  fi
+}
+verify_acceptable_release_number
+
+if [[ "${arg_V}" == "${__flag_present}" ]]; then
+    # Print just the version number
+    info "$opencoarrays_version"
+
+elif [[ "${arg_v}" == "${__flag_present}" ]]; then
+
+    # Print copyright info and version number
+    info "OpenCoarrays ${opencoarrays_version}"
+    info ""
+    info "OpenCoarrays installer"
+    info "Copyright (C) 2015-2017 Sourcery, Inc."
+    echo "Copyright (C) 2015-2017 Sourcery Institute"
+    info ""
+    info "OpenCoarrays comes with NO WARRANTY, to the extent permitted by law."
+    info "You may redistribute copies of ${this_script} under the terms of the"
+    echo "BSD 3-Clause License.  For more information about these matters, see"
+    info "http://www.sourceryinstitute.org/license.html"
+    info ""
+else
+
+  export FC=${arg_f:-gfortran}
+  export CC=${arg_c:-gcc}
+  export CXX=${arg_C:-g++}
+ 
+  # Check for and, if necessary, install OpenCoarrays prerequisites
+
+  if ! type "$CMAKE" >& /dev/null; then
+    sudo apt-get install cmake
+  fi
+  if ! type "$CXX" >& /dev/null; then
+    sudo apt-get install g++
+  fi
+  if ! type "$FC" >& /dev/null; then
+    sudo apt-get install gfortran
+  fi
+  
+  if ! type mpif90 >& /dev/null; then
+    sudo apt-get install mpich
+  fi
+
+  set_SUDO_if_needed_to_write_to_install_dir()
+  {
+    info "Checking whether the directory ${install_prefix} exists... "
+    if [[ -d "${install_prefix}" ]]; then
+      info "yes"
+      info "Checking whether I have write permissions to ${install_prefix} ... "
+      if [[ -w "${install_prefix}" ]]; then
+        info "yes"
+      else
+        info "no"
+        SUDO="sudo"
+      fi
+    else
+      info "no"
+      info "Checking whether I can create ${install_prefix} ... "
+      if mkdir -p "${install_prefix}" >& /dev/null; then
+        info "yes."
+      else
+        info "no."
+        SUDO="sudo"
+      fi
+    fi
+  }
+  set_SUDO_if_needed_to_write_to_install_dir
+  
+  # Install OpenCoarrays
+
+  if [[ -d "$build_path" ]]; then
+    rm -rf "$build_path"
+  fi
+  mkdir -p "$build_path"
+  cd "$build_path"
+  info "Configuring OpenCoarrays with the following command:"
+  info "FC=\"$FC\" CC=\"$CC\"  \"$CMAKE\" \"$OPENCOARRAYS_SRC_DIR\" -DCMAKE_INSTALL_PREFIX=\"$install_prefix\""
+  FC="$FC" CC="$CC" "$CMAKE" "$OPENCOARRAYS_SRC_DIR" -DCMAKE_INSTALL_PREFIX="$install_prefix"
+  info "Building OpenCoarrays with the following command:"
+  info "make -j $arg_j"
+  make -j $arg_j
+  info "Installing OpenCoarrays with the following command:"
+  info "${SUDO:-} make install"
+  ${SUDO:-} make install
+  if [[ -f "$install_prefix"/lib/libcaf_mpi.a && -f "${install_prefix}/bin/caf"  && -f "${install_prefix}/bin/cafrun"  ]]; then
+    info "OpenCoarrays has been installed in"
+    info "$install_prefix"
+  else
+    info "Something went wrong. OpenCoarrays is not in the expected location:"
+    emergency "$install_prefix"
+  fi
+  # See http://stackoverflow.com/questions/31057694/gethostbyname-fail-after-switching-internet-connections/31222970
+  loopback_line=`grep $NAME /etc/hosts`
+  if [[ -z "${loopback_line:-}" ]]; then
+    info "To ensure the correct functioning of MPI, please add the following line to your /etc/hosts file:"
+    info "127.0.0.1 $NAME"
+  fi
+fi
diff --git a/windows-install.sh-usage b/windows-install.sh-usage
new file mode 100644
index 0000000..7d4c48a
--- /dev/null
+++ b/windows-install.sh-usage
@@ -0,0 +1,13 @@
+  -c --with-c [arg]           Use specified C compiler. Default="gcc"
+  -C --with-cxx [arg]         Use specified C++ compiler. Default="g++"
+  -d --debug                  Enable debug mode.
+  -e --verbose                Enable verbose mode, print script as it is executed.
+  -f --with-fortran [arg]     Use specified Fortran compiler. Default="gfortran"
+  -h --help                   Print this page.
+  -i --install-prefix [arg]   Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/opencoarrays/${version_to_build:-}"
+  -j --num-threads [arg]      Number of threads to use when invoking make. Default="1"
+  -m --with-cmake [arg]       Use specified CMake installation. Default="cmake"
+  -n --no-color               Disable color output.
+  -v --version                Print OpenCoarrays version number and copyright.
+  -V --version-number         Print OpenCoarrays version number.
+  -y --yes-to-all             Build non-interactively by assuming affirmative user responses.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/open-coarrays.git



More information about the debian-science-commits mailing list