gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master ecadcaa: Check for the existence of CFITSIO's


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master ecadcaa: Check for the existence of CFITSIO's fits_is_reentrant
Date: Sun, 15 Jul 2018 05:14:28 -0400 (EDT)

branch: master
commit ecadcaa7fb3546cedf3dcdbfd7f5a3f4d5c1b760
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Check for the existence of CFITSIO's fits_is_reentrant
    
    CFITSIO's `fits_is_reentrant' function is only available after version 3.30
    (April 2012). So if the system has an older version, Gnuastro's build will
    crash. A configuration check has been added in `configure.ac' to do the
    check and not call the function if its not present.
    
    Also, when multiple threads are called, but CFITSIO wasn't configured to be
    run in multiple threads, Crop won't abort with an error, but the number of
    threads will be set to 1.
    
    Finally in `tests/mkprof/mosaic1.sh', we were running MakeProfiles
    separately from the `mv' command. So even if MakeProfiles crashed, the test
    would succeed, causing really hard to interpret situtations!!!
    
    This bug was reported by Oryna Ivashtenko.
    
    This fixes bug #54312.
---
 NEWS                              |  1 +
 THANKS                            |  1 +
 bin/crop/ui.c                     | 35 ++++++++++++++++++++++++++---------
 configure.ac                      | 13 +++++++++++++
 doc/announce-acknowledge.txt      |  1 +
 doc/gnuastro.texi                 |  8 ++++++++
 lib/gnuastro-internal/config.h.in | 33 +++++++++++++++++----------------
 tests/mkprof/mosaic1.sh           |  3 +--
 8 files changed, 68 insertions(+), 27 deletions(-)

diff --git a/NEWS b/NEWS
index b59edc8..dd12541 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,7 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   bug #54286: BuildProgram's configuration file, not built by default.
   bug #54297: No Match output when --notmatched called and no match.
   bug #54298: Table not writing array when there are no rows.
+  bug #54312: Crash when CFITSIO doesn't have fits_is_reentrant function.
 
 
 
diff --git a/THANKS b/THANKS
index 1213412..41a23e7 100644
--- a/THANKS
+++ b/THANKS
@@ -34,6 +34,7 @@ support in Gnuastro. The list is ordered alphabetically (by 
family name).
     Takashi Ichikawa                     address@hidden
     Raúl Infante Sainz                   address@hidden
     Brandon Invergo                      address@hidden
+    Oryna Ivashtenko                     address@hidden
     Aurélien Jarno                       address@hidden
     Geoffry Krouchi                      address@hidden
     Lee Kelvin                           address@hidden
diff --git a/bin/crop/ui.c b/bin/crop/ui.c
index ce6c83b..fde8c46 100644
--- a/bin/crop/ui.c
+++ b/bin/crop/ui.c
@@ -404,16 +404,33 @@ ui_check_options_and_arguments(struct cropparams *p)
   if(p->catname)
     {
       /* When multiple threads need to access a file, CFITSIO needs to be
-         configured with the `--enable-reentrant` option. */
+         configured with the `--enable-reentrant` option and we can only
+         know from the `fits_is_reentrant' function that came from CFITSIO
+         version 3.30. */
+#if GAL_CONFIG_HAVE_FITS_IS_REENTRANT == 1
       if(p->cp.numthreads>1 && fits_is_reentrant()==0)
-        error(EXIT_FAILURE, 0, "CFITSIO was not configured with the "
-              "`--enable-reentrant` option but you have asked to crop "
-              "on %zu threads.\n\nPlease configure, make and install CFITSIO "
-              "again with this flag. Alternatively, to avoid this error "
-              "you can set the number of threads to 1 by adding the "
-              "`--numthreads=1` or `-N1` options. Please run the following "
-              "command to learn more about configuring CFITSIO:\n\n"
-              "    $ info gnuastro CFITSIO", p->cp.numthreads);
+        {
+          fprintf(stderr, "WARNING: CFITSIO was not configured with the "
+                  "`--enable-reentrant' option but you have asked to crop "
+                  "on %zu threads. Therefore only one thread will be used.\n\n"
+                  "Please run the following command to learn more about "
+                  "configuring CFITSIO:\n\n"
+                  "    $ info gnuastro CFITSIO", p->cp.numthreads);
+          p->cp.numthreads=1;
+        }
+#else
+      if(p->cp.numthreads>1)
+        {
+          fprintf(stderr, "WARNING: the installed CFITSIO version doesn't "
+                  "have `fits_is_reentrant' function (it is older than "
+                  "version 3.30). But you have asked to crop on %zu threads."
+                  "Therefore only one thread will be used.\n\n"
+                  "To avoid this warning, you can set the number of threads "
+                  "to one with `-N1' or update your installation of CFITSIO.",
+                  p->cp.numthreads);
+          p->cp.numthreads=1;
+        }
+#endif
 
       /* Make sure the given output is a directory. */
       gal_checkset_check_dir_write_add_slash(&p->cp.output);
diff --git a/configure.ac b/configure.ac
index a5694db..afdd986 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,6 +235,7 @@ AC_CHECK_DECLS(gsl_interp_steffen,
                [ gsl_version_old=yes; anywarnings=yes ],
                [[#include <gsl/gsl_interp.h>]])
 
+
 # Since version 0.42, if `libcurl' is installed, CFITSIO will link with it
 # and thus it will be necessary to explicitly link with libcurl also. If it
 # doesn't exist on the system, then CFITSIO won't link with it and there is
@@ -246,10 +247,21 @@ AC_SEARCH_LIBS([ffopen], [cfitsio], [],
 AC_SEARCH_LIBS([wcspih], [wcs], [],
     [AC_MSG_ERROR([WCSLIB not found, cannot continue.])])
 
+
 # These are secondary tests for more fine-grained control in libraries that
 # have already been checked. We don't need to add them to the LIBS
 # variable, so we are using AC_CHECK_LIB for these tests.
 
+# If the CFITSIO library has the `fits_is_reentrant' function (it was added
+# since version 3.30 of April 2012).
+AC_CHECK_LIB([cfitsio], [fits_is_reentrant], [has_fits_is_reentrant=1],
+             [has_fits_is_reentrant=0], [-lm])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_HAVE_FITS_IS_REENTRANT],
+                   [$has_fits_is_reentrant],
+                   [CFITSIO has the fits_is_reentrant function])
+AC_SUBST(HAVE_FITS_IS_REENTRANT, [$has_fits_is_reentrant])
+
+
 # If the WCS library has the `wcslib_version' function.
 AC_CHECK_LIB([wcs], [wcslib_version], [has_wcslib_version=1],
              [has_wcslib_version=0], [-lcfitsio -lm])
@@ -257,6 +269,7 @@ AC_DEFINE_UNQUOTED([GAL_CONFIG_HAVE_WCSLIB_VERSION], 
[$has_wcslib_version],
                    [WCSLIB comes with wcslib_version])
 AC_SUBST(HAVE_WCSLIB_VERSION, [$has_wcslib_version])
 
+
 # If the pthreads library has `pthread_barrier_wait'.
 AC_CHECK_LIB([pthread], [pthread_barrier_wait], [has_pthread_barrier=1],
              [has_pthread_barrier=0])
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index baac507..3f0d563 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -4,6 +4,7 @@ Valentina Abril-melgarejo
 Leindert Boogaard
 Nushkia Chamba
 Takashi Ichikawa
+Oryna Ivashtenko
 Geoffry Krouchi
 Alan Lefor
 Dmitrii Oparin
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 4693243..98c6f86 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -21738,6 +21738,14 @@ of @code{0} (zero). Gnuastro also comes with some 
wrappers to make it
 easier to use libgit2 (see @ref{Git wrappers}).
 @end deffn
 
address@hidden Macro GAL_CONFIG_HAVE_FITS_IS_REENTRANT
address@hidden CFITSIO
+This macro will have a value of 1 when the CFITSIO of the host system has
+the @code{fits_is_reentrant} function (available from CFITSIO version
+3.30). This function is used to see if CFITSIO was configured to read a
+FITS file simultaneously on different threads.
address@hidden deffn
+
 
 @deffn Macro GAL_CONFIG_HAVE_WCSLIB_VERSION
 WCSLIB is the reference library for world coordinate system transformation
diff --git a/lib/gnuastro-internal/config.h.in 
b/lib/gnuastro-internal/config.h.in
index 47a3b96..67c1383 100644
--- a/lib/gnuastro-internal/config.h.in
+++ b/lib/gnuastro-internal/config.h.in
@@ -34,27 +34,28 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 
 /* Configuration macros: */
 
-#define GAL_CONFIG_VERSION              "@VERSION@"
+#define GAL_CONFIG_VERSION                  "@VERSION@"
 
-#define GAL_CONFIG_HAVE_LIBGIT2         @HAVE_LIBGIT2@
+#define GAL_CONFIG_HAVE_LIBGIT2             @HAVE_LIBGIT2@
 
-#define GAL_CONFIG_HAVE_WCSLIB_VERSION  @HAVE_WCSLIB_VERSION@
+#define GAL_CONFIG_HAVE_FITS_IS_REENTRANT   @HAVE_FITS_IS_REENTRANT@
+#define GAL_CONFIG_HAVE_WCSLIB_VERSION      @HAVE_WCSLIB_VERSION@
 
-#define GAL_CONFIG_HAVE_PTHREAD_BARRIER @HAVE_PTHREAD_BARRIER@
+#define GAL_CONFIG_HAVE_PTHREAD_BARRIER     @HAVE_PTHREAD_BARRIER@
 
-#define GAL_CONFIG_BIN_OP_UINT8         @HAVE_BIN_OP_UINT8@
-#define GAL_CONFIG_BIN_OP_INT8          @HAVE_BIN_OP_INT8@
-#define GAL_CONFIG_BIN_OP_UINT16        @HAVE_BIN_OP_UINT16@
-#define GAL_CONFIG_BIN_OP_INT16         @HAVE_BIN_OP_INT16@
-#define GAL_CONFIG_BIN_OP_UINT32        @HAVE_BIN_OP_UINT32@
-#define GAL_CONFIG_BIN_OP_INT32         @HAVE_BIN_OP_INT32@
-#define GAL_CONFIG_BIN_OP_UINT64        @HAVE_BIN_OP_UINT64@
-#define GAL_CONFIG_BIN_OP_INT64         @HAVE_BIN_OP_INT64@
-#define GAL_CONFIG_BIN_OP_FLOAT32       @HAVE_BIN_OP_FLOAT32@
-#define GAL_CONFIG_BIN_OP_FLOAT64       @HAVE_BIN_OP_FLOAT64@
+#define GAL_CONFIG_BIN_OP_UINT8             @HAVE_BIN_OP_UINT8@
+#define GAL_CONFIG_BIN_OP_INT8              @HAVE_BIN_OP_INT8@
+#define GAL_CONFIG_BIN_OP_UINT16            @HAVE_BIN_OP_UINT16@
+#define GAL_CONFIG_BIN_OP_INT16             @HAVE_BIN_OP_INT16@
+#define GAL_CONFIG_BIN_OP_UINT32            @HAVE_BIN_OP_UINT32@
+#define GAL_CONFIG_BIN_OP_INT32             @HAVE_BIN_OP_INT32@
+#define GAL_CONFIG_BIN_OP_UINT64            @HAVE_BIN_OP_UINT64@
+#define GAL_CONFIG_BIN_OP_INT64             @HAVE_BIN_OP_INT64@
+#define GAL_CONFIG_BIN_OP_FLOAT32           @HAVE_BIN_OP_FLOAT32@
+#define GAL_CONFIG_BIN_OP_FLOAT64           @HAVE_BIN_OP_FLOAT64@
 
-#define GAL_CONFIG_SIZEOF_LONG          @SIZEOF_LONG@
-#define GAL_CONFIG_SIZEOF_SIZE_T        @SIZEOF_SIZE_T@
+#define GAL_CONFIG_SIZEOF_LONG              @SIZEOF_LONG@
+#define GAL_CONFIG_SIZEOF_SIZE_T            @SIZEOF_SIZE_T@
 
 
 /* C++ Preparations */
diff --git a/tests/mkprof/mosaic1.sh b/tests/mkprof/mosaic1.sh
index b968da7..c51fbe7 100755
--- a/tests/mkprof/mosaic1.sh
+++ b/tests/mkprof/mosaic1.sh
@@ -50,5 +50,4 @@ if [ ! -f $cat      ]; then echo "$cat does not exist.";   
exit 77; fi
 
 # Actual test script
 # ==================
-$execname $cat --naxis=100,100
-mv 0_mkprofcat1.fits psf.fits
+$execname $cat --naxis=100,100 && mv 0_mkprofcat1.fits psf.fits



reply via email to

[Prev in Thread] Current Thread [Next in Thread]