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

Craig Tierney - NOAA Affiliate craig.tierney at noaa.gov
Wed Jul 22 15:37:49 MDT 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150722/ad21a3bd/attachment.html 


More information about the ncl-talk mailing list