netcdf-fortran icon indicating copy to clipboard operation
netcdf-fortran copied to clipboard

cmake build fails using xlf compiler

Open jedwards4b opened this issue 9 years ago • 4 comments

the xlf compiler does not recognize the -D cpp flag and the nfconfig.inc file is full of cpp macros.

FC=xlf2003 CC=xlc cmake -D CMAKE_INSTALL_PREFIX=/u/b5p195aa -DENABLE_NETCDF_4=OFF -DENABLE_DAP=OFF -DHAVE_LIBM=/opt/ibm/xlmass/8.1.2/lib/libmass.a ../ -- The Fortran compiler identification is XL -- The C compiler identification is Clang 3.5.0 -- Check for working Fortran compiler: /usr/bin/xlf2003 -- Check for working Fortran compiler: /usr/bin/xlf2003 -- works -- Detecting Fortran compiler ABI info -- Detecting Fortran compiler ABI info - done -- Checking whether /usr/bin/xlf2003 supports Fortran 90 -- Checking whether /usr/bin/xlf2003 supports Fortran 90 -- yes -- Check for working C compiler: /usr/bin/xlc -- Check for working C compiler: /usr/bin/xlc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) -- Looking for nc_def_opaque in netcdf -- Looking for nc_def_opaque in netcdf - not found -- Looking for nccreate in netcdf -- Looking for nccreate in netcdf - found -- Looking for oc_open in netcdf -- Looking for oc_open in netcdf - not found -- Looking for nc_use_parallel_enabled in netcdf -- Looking for nc_use_parallel_enabled in netcdf - not found

-- CMake Summary:

-- Build Type: DEBUG -- Building Shared Libraries: ON -- Building netCDF-4:
-- Building DAP Support: OFF -- Using Parallel IO: OFF -- Linking against: netcdf;

-- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project:

ENABLE_NETCDF_4
HAVE_LIBM

-- Build files have been written to: /u/b5p195aa/Downloads/netcdf-fortran/bld b5p195aa@p10a603:~/Downloads/netcdf-fortran/bld$ make Scanning dependencies of target netcdff make[2]: Warning: File fortran/CMakeFiles/netcdff.dir/depend.make' has modification time 5.2 s in the future make[3]: Warning: Filefortran/CMakeFiles/netcdff.dir/depend.make' has modification time 5.2 s in the future [ 1%] Building Fortran object fortran/CMakeFiles/netcdff.dir/module_netcdf_nc_data.F90.o "/u/b5p195aa/Downloads/netcdf-fortran/bld/libsrc/nfconfig.inc", line 47.1: 1515-019 (S) Syntax is incorrect. "/u/b5p195aa/Downloads/netcdf-fortran/bld/libsrc/nfconfig.inc", line 47.4: 1515-018 (S) Incorrect character found in source at line 1-47 in column 4. Hexadecimal value of character is 23.

(followed by lots more errors of this nature).

jedwards4b avatar Dec 04 '15 18:12 jedwards4b

Unfortunately, we don't have access to a platform using the xlf compiler, so there isn't much we can do to debug this on our end. If you can suggest a fix and/or issue a pull request, we would be quite grateful.

WardF avatar Dec 04 '15 18:12 WardF

Ward,

Looking at this closer - the problem isn't the cpp macros in the file. It's the c-style comments /* */ which the compiler doesn't recognize. And in fact there is a note at the top of nfconfig.in that states:

Do not have C-style comments in here because this file is processed
by both the FORTRAN compiler (for the nf_test/ stuff) and the C
compiler (for the FORTRAN-callable interface routines) and some
FORTRAN preprocessors do not understand the /*...*/ syntax.

jedwards4b avatar Dec 04 '15 18:12 jedwards4b

From: Bob Walkup [email protected] Date: Fri, Dec 4, 2015 at 11:39 AM Subject: Re: c-style comments in fortran include files To: Jim Edwards [email protected]

I checked the doc, and tried a quick test ... and this worked for me :

program main implicit none /* C comment */ print *, 'hi' end

xlf90 junk.f90 -WF,-C! -qsuffix=cpp=f90

In my case the source file was "junk.f90", and the option -qsuffix=cpp=f90 tells the compiler to run it through the internal C-preprocessor, while the option -WF,-C! apparently tells the internal preprocessor to strip out the C-style comments. I think that is your best bet. The default action is apparently to preserve C-comments, which would make the Fortran compiler choke.

jedwards4b avatar Dec 04 '15 18:12 jedwards4b

Thanks for your diagnostic work with this; I'm going to flag this issue for the next release and will update our build files (autoconf, cmake) accordingly. Thanks again!

WardF avatar Dec 04 '15 19:12 WardF