[ncl-talk] Using ncargf77/ncargf90 with compilers other than gfortran

Mary Haley haley at ucar.edu
Tue Jul 28 22:56:43 MDT 2015


Hi Craig,

The ncargf77/ncargcc/ncargf90 scripts are generated whenever NCAR Graphics
is built on a system, and the appropriate compilers used are inserted into
the scripts at compile time. These scripts actually start off with
variables with names like "SED_FC", much in the same way that you are using
"NCARG_F77_FORTRAN", and then the "Makefile" inserts the proper compiler
names and such, by replacing all SED_XXXX lines.

Since these scripts are shipped with specific versions of NCL/NCAR
Graphics, they really are meant to be used with a specific set of compilers
and a specific set of libraries.

It's certainly possible to modify these scripts to use a different
compiler, but if you are still linking to the NCAR Graphics libraries that
were compiled with a different compiler, then you will have to take care to
modify these scripts appropriately.  For example, I know people who have
taken a GNU version of these scripts that use gfortran and gcc, and changed
them to use pgf90 and pgcc. In order to do this, though, requires
hard-coding some GNU libraries to be linked, like "-lgfortran", and
sometimes it requires special PGI libraries to be linked as well.

Long story short: it is not straight forward to generically modify these
scripts so that they can be used with other compilers, without having to
customize them for a particular system. There's just too many combinations
of compilers and compile options.

What you've done sounds pretty reasonable to me. I've usually found that
you can link to GNU compiled libraries somewhat easily with other
compilers, but the reverse is not always true.

--Mary

On Wed, Jul 22, 2015 at 3:37 PM, Craig Tierney - NOAA Affiliate <
craig.tierney at noaa.gov> wrote:

> Hello all,
>
> We have users that use the wrapper scripts ncargf77 and ncargf90 with
> compilers other than gfortran.  The way we have handled this in the past
> was to make copies of the bin directory, one for each compiler (Intel and
> PGI).  For each compiler, we would hand edit the wrapper script to properly
> compile and link the ncl libraries.  Then depending on the compiler loaded,
> the path to the appropriate bin directory would be specified.
>
> As I was setting up version 6.3.0, I thought there might be a better
> generic way to do this.  Instead of a different wrapper script for each
> compiler, I changed the wrapper script to overload the variables like
> fortran, loadflags, and libextra so to allow those variables to be set in
> the environment and loaded as needed.   Several variables are defined
> specific to the language used:
>
> NCARG_F77 - Define the compiler
> NCARG_F77_LOADFLAGS - Define the compiler flags to be used
> NCARG_F77_EXTRALIB - Define any extra libraries necessary
>
> There are also versions above used in the ncargf90 script, but named with
> _F90_.
>
> There is also a generic variable that is not compiler specific (this was
> created so that I can point to a new Cairo build).
>
> NCARG_LIBPATH - Define the library path
>
> Am I missing something on how to properly support additional compilers?
> Is the method I implemented something than can be included in future
> versions of NCL?
>
> Here is the patch for ncargf77, but I have a similar patch for ncargf90
> and ncargcc.
>
> # diff -urN ncargf77.orig ncargf77
> --- ncargf77.orig 2015-07-22 15:25:49.245582280 +0000
> +++ ncargf77 2015-07-22 21:30:51.856202314 +0000
> @@ -23,13 +23,32 @@
>  set syslibdir = "-L/usr/X11R6/lib64"
>  set xlib     = "-lX11 -lXext"
>  set cairolib = "-lcairo -lfontconfig -lpixman-1 -lfreetype -lexpat -lpng
> -lz -lpthread -lXrender -lbz2"
> -set fortran  = "/usr/bin/gfortran"
> -set loadflags  = "-fPIC -fno-second-underscore -fno-range-check -fopenmp
>  -O   "
>  set libdir   = `ncargpath lib`
>  set ro       = "$libdir/ncarg/robj"
> -set libpath = "-L$libdir $syslibdir"
>
> -set libextra = ""
> +if ($?NCARG_F77_FORTRAN) then
> + set fortran = "$NCARG_F77_FORTRAN"
> +else
> + set fortran  = "/usr/bin/gfortran"
> +endif
> +
> +if ($?NCARG_F77_LOADFLAGS) then
> + set loadflags = "$NCARG_F77_LOADFLAGS"
> +else
> + set loadflags  = "-fPIC -fno-second-underscore -fno-range-check
> -fopenmp  -O   "
> +endif
> +
> +if ($?NCARG_LIBPATH) then
> + set libpath = "-L$libdir $syslibdir $NCARG_LIBPATH"
> +else
> + set libpath = "-L$libdir $syslibdir"
> +endif
> +
> +if ($?NCARG_F77_LIBEXTRA) then
> + set libextra = $NCARG_F77_LIBEXTRA
> +else
> + set libextra = ""
> +endif
>
>  if (! -d "$libdir") then
>    echo "Library directory <$libdir> does not exist."
>
> Thanks,
> Craig
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150728/55a2b982/attachment.html 


More information about the ncl-talk mailing list