NOAA-EMC / wgrib2

Provides functionality for interacting with, reading, writing, and manipulating GRIB2 files.
38 stars 14 forks source link

Fortran language should be required and enabled only if needed #270

Closed DusanJovic-NOAA closed 4 weeks ago

DusanJovic-NOAA commented 1 month ago

Currently, Fortran language is enabled (and required) unconditionally, even though it is required only if MAKE_FTN_API or USE_IPOLATES are turned on. Both MAKE_FTN_API and USE_IPOLATES are off by default. So by default, Fortran is not required. I suggest this change to be made:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07168a5..5cfda44 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15)
 file(STRINGS "VERSION" pVersion)

 # Set up project with version number from VERSION file.
-project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C)
+project(wgrib2 VERSION ${pVersion} LANGUAGES C)

 # Handle user build options.
 option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)
@@ -39,6 +39,10 @@ option(BUILD_LIB "Build wgrib2 library?" on)
 option(BUILD_SHARED_LIB "Build shared library?" off)
 option(BUILD_WGRIB "Build wgrib code?" off)

+if(MAKE_FTN_API OR USE_IPOLATES)
+  enable_language(Fortran)
+endif()
+
 # Developers can use this option to specify a local directory which
 # holds the test files. They will be copied instead of fetching the
 # files via FTP.
webisu commented 1 month ago

Makes sense that fortran only be required of MAKE_FTN_API or USE_IPOLATES.

The ftn_api requires a fortran-95+TR-15581/fortran-2003 compiler, Anyway to enforce that restriction?

On Fri, Oct 11, 2024 at 10:57 AM Dusan Jovic @.***> wrote:

Currently, Fortran language is enabled (and required) unconditionally, even though it is required only if MAKE_FTN_API or USE_IPOLATES are turned on. Both MAKE_FTN_API and USE_IPOLATES are off by default. So by default, Fortran is not required. I suggest this change to be made:

diff --git a/CMakeLists.txt b/CMakeLists.txt index 07168a5..5cfda44 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15) file(STRINGS "VERSION" pVersion)

Set up project with version number from VERSION file.-project(wgrib2 VERSION ${pVersion} LANGUAGES Fortran C)+project(wgrib2 VERSION ${pVersion} LANGUAGES C)

Handle user build options.

option(ENABLE_DOCS "Enable generation of doxygen-based documentation." OFF)@@ -39,6 +39,10 @@ option(BUILD_LIB "Build wgrib2 library?" on) option(BUILD_SHARED_LIB "Build shared library?" off) option(BUILD_WGRIB "Build wgrib code?" off) +if(MAKE_FTN_API OR USE_IPOLATES)+ enable_language(Fortran)+endif()+

Developers can use this option to specify a local directory which

holds the test files. They will be copied instead of fetching the

files via FTP.

— Reply to this email directly, view it on GitHub https://github.com/NOAA-EMC/wgrib2/issues/270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIB7ZTRNEQQDNDKKGAJKMDZ27RNVAVCNFSM6AAAAABPZDB7K2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4DCNJYHA2TMMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

edwardhartnett commented 1 month ago

All fortran compilers will be 2003 compatible.

In GNU you can set fortran dialect options, so you can check dialect stuff exactly if you want.