6 if test -z "$NETCDF" ; then
7 for p
in /usr
/local
/netcdf
16 if test -z "$NETCDF" ; then
18 if [ `hostname | cut -c 1-2` = "bs" -o \
19 `hostname | cut -c 1-2` = "bv" -o \
20 `hostname` = "tempest" -o `hostname` = "lightning" ] ; then
21 echo 'Compiling on an NCAR system with weird paths to NetCDF'
22 echo 'Setting up a local NetCDF directory with symlinks'
23 if ( test -d .
/netcdf_links
) ; then
24 echo 'A directory ./netcdf_links already exists. Continuing.'
27 if [ -z "$OBJECT_MODE" ] ; then
31 if [ $OBJECT_MODE -ne 64 -a \
( `hostname | cut -c 1-2` = "bs" \
) ] ; then
32 ( cd .
/netcdf_links
; ln -s /usr
/local
/lib32
/r4i4 .
/lib
; \
33 ln -s /usr
/local
/include .
/include
)
35 ( cd .
/netcdf_links
; ln -s /usr
/local
/lib64
/r4i4 .
/lib
; \
36 ln -s /usr
/local
/include .
/include
)
39 NETCDF
=`pwd`/netcdf_links
45 if [ -d .
/netcdf_links
] ; then
46 echo '** There is an existing ./netcdf_links file. Should I use? [y]'
48 if [ "$resp" = "y" ] ; then
49 NETCDF
=`pwd`/netcdf_links
52 echo 'Removing existing ./netcdf_links directory'
53 /bin
/rm -fr .
/netcdf_links
56 echo '** WARNING: No path to NETCDF and environment variable NETCDF not set.'
57 echo '** would you like me to try to fix? [y]'
61 while [ -z "$bedone" ] ; do
63 if [ "$resp" = "y" -o -z "$resp" ] ; then
64 if [ -d .
/netcdf_links
] ; then
65 echo 'There is already a ./netcdf_links directory. Okay to use links'
66 echo 'in this directory for NetCDF include and lib dirs? [y]'
68 if [ "$resp" = "y" ] ; then
69 NETCDF
=`pwd`/netcdf_links
75 if [ -z "$netcdfipath" ] ; then
76 echo 'Enter full path to NetCDF include directory on your system'
78 if [ ! -d "$resp" ] ; then
79 echo "invalid path: $resp. Try again? [y]" ; continue
83 if [ -z "$netcdflpath" ] ; then
84 echo 'Enter full path to NetCDF library directory on your system'
86 if [ ! -d "$resp" ] ; then
87 echo "invalid path: $resp. Try again? [y]" ; continue
92 if [ -n "$netcdflpath" -a -n "$netcdfipath" ] ; then
93 if [ -d .
/netcdf_links
] ; then
94 echo 'Existing ./netcdf_links directory. Okay to remove. [y]'
96 if [ "$resp" = "y" ] ; then
97 /bin
/rm -fr .
/netcdf_links
102 ln -s "$netcdfipath" include
103 ln -s "$netcdflpath" lib
105 echo created new .
/netcdf_links directory
106 /bin
/ls -lF .
/netcdf_links
107 NETCDF
=`pwd`/netcdf_links
118 if [ -n "$NETCDF" ] ; then
119 echo "Will use NETCDF in dir: $NETCDF"
120 # for 3.6.2 and greater there might be a second library, libnetcdff.a . Check for this and use
123 if [ -f "$NETCDF/lib/libnetcdff.a" ] ; then
127 echo "Will configure for use without NetCDF"
130 # if the uname command exists, give it a shot and see if
131 # we can narrow the choices; otherwise, spam 'em
134 type uname
> /dev
/null
135 if [ $?
-eq 0 ] ; then
137 if [ "$os" = "AIX" -o "$os" = "IRIX" -o "$os" = "IRIX64" -o "$os" = "SunOS" -o "$os" = "HP-UX" -o "$os" = "Darwin" ] ; then
140 xxx
=`expr "$os" : '\(.........\).*'`
141 if [ "$xxx" = "CYGWIN_NT" ] ; then
144 if [ "$os" = "OSF1" -o "$os" = "Linux" -o "$os" = "UNICOS/mp" -o "$os" = "UNIX_System_V" -o "$os" = "CYGWIN_NT" ] ; then
153 # Found perl, so proceed with configuration
154 perl arch
/Config.pl
-perl=$PERL -netcdf=$NETCDF -netcdff=$NETCDFF -os=$os -mach=$mach
157 #Checking cross-compiling capability for some particular environment
158 #on Linux and Mac box
160 if [ $os = "Linux" -o $os = "Darwin" ]; then
162 SFC
=`grep '^SFC' configure.wps | awk '{print $3}'`
163 SCC
=`grep '^SCC' configure.wps | awk '{print $3}'`
165 SFC
="`type $SFC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
166 SCC
="`type $SCC 2>/dev/null | awk '{print $NF}' | sed -e 's/(//g;s/)//g'`"
168 if [ -e $NETCDF/lib
/libnetcdf.a
-a "$SFC" != "" -a "$SCC" != "" ]; then
177 echo Testing
for NetCDF
, C and Fortran compiler
181 int main(int argc, char ** argv)
189 integer :: STATUS = 0
191 end program test_exit
194 ar p
$NETCDF/lib
/libnetcdf.a nc.o
> ${foo}.o
195 netcdf_arch
="`file ${foo}.o | grep -o -E '[0-9]{2}-bit|i386'`"
198 $SFC -o ${foo} ${foo}.f
> /dev
/null
2>&1
199 SFC_arch
="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
200 rm ${foo} ${foo}.o
2> /dev
/null
202 $SCC -o ${foo} ${foo}.c
> /dev
/null
2>&1
203 SCC_arch
="`file ${foo} | grep -o -E '[0-9]{2}-bit|i386'`"
204 rm ${foo} ${foo}.o
2> /dev
/null
206 if [ "$SFC_arch" = "" -o "$SCC_arch" = "" ]; then
207 echo " One of compilers testing failed!"
208 echo " Please check your compiler"
210 rm -f ${foo} ${foo}.
[cfo
] 2> /dev
/null
213 cp configure.wps configure.wps.edit
220 if [ "$SFC_arch" = "64-bit" ] ; then
222 $SFC -m32 -o ${foo} ${foo}.f
> /dev
/null
2>&1
225 sed '/^SFC.*=/s/$/ -m32/' configure.wps.edit
> configure.wps.tmp
226 mv configure.wps.tmp configure.wps.edit
229 if [ "$SCC_arch" = "64-bit" ] ; then
231 $SCC -m32 -o ${foo} ${foo}.c
> /dev
/null
2>&1
234 sed '/^SCC.*=/s/$/ -m32/' configure.wps.edit
> configure.wps.tmp
235 mv configure.wps.tmp configure.wps.edit
239 if [ $CROSS_COMPILING -eq 1 ] ; then
241 echo This installation NetCDF is
32-bit
242 if [ \
( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" = "64-bit" \
) \
243 -o \
( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" = "64-bit" \
) ] ; then
244 rm configure.wps.edit
245 echo One of compilers is
64-bit and doesn
\'t support cross-compiling.
246 echo Please check your NETCDF lib and compiler
248 echo -m32 is appended to configure.wps
249 echo It will be forced to build
in 32-bit.
250 echo If you don
\'t want
32-bit binaries
, please use
64-bit NetCDF
, and re-run the configure
script.
257 if [ "$SFC_arch" = "32-bit" -o "$SFC_arch" = "i386" ] ; then
259 $SFC -m64 -o ${foo} ${foo}.f
> /dev
/null
2>&1
262 sed '/^SFC.*=/s/$/ -m64/' configure.wps.edit
> configure.wps.tmp
263 mv configure.wps.tmp configure.wps.edit
266 if [ "$SCC_arch" = "32-bit" -o "$SCC_arch" = "i386" ] ; then
268 $SCC -m64 -o ${foo} ${foo}.c
> /dev
/null
2>&1
271 sed '/^SCC.*=/s/$/ -m64/' configure.wps.edit
> configure.wps.tmp
272 mv configure.wps.tmp configure.wps.edit
276 if [ $CROSS_COMPILING -eq 1 ] ; then
278 echo This installation NetCDF is
64-bit
279 if [ \
( $SFC_MULTI_ABI -ne 1 -a "$SFC_arch" != "64-bit" \
) \
280 -o \
( $SCC_MULTI_ABI -ne 1 -a "$SCC_arch" != "64-bit" \
) ]; then
281 rm configure.wps.edit
282 echo One of Compilers is
32-bit and doesn
\'t support cross-compiling.
283 echo Please check your NetCDF lib and compiler
285 echo -m64 is appended to configure.wps
286 echo It will be forced to build
in 64-bit.
287 echo If you don
\'t want
64-bit binaries
, please use
32-bit NetCDF
, and re-run the configure
script.
292 rm -f ${foo} ${foo}.
[cfo
] 2> /dev
/null
294 if [ -e configure.wps.edit
]; then
295 mv configure.wps.edit configure.wps
298 if [ $CROSS_COMPILING -eq 0 ] ; then
299 echo This installation NetCDF is
$netcdf_arch
300 echo C compiler is
$SCC_arch
301 echo Fortran compiler is
$SFC_arch
305 # Does our Fortran work with the given NETCDF library.
307 if [ -f "fort_netcdf.f" ] ; then
308 /bin
/rm fort_netcdf.f
310 if [ -f "fort_netcdf" ] ; then
313 cat > fort_netcdf.f
<<EOF
316 integer ncid , status
317 status = nf_open ( 'foo.nc' , 0 , ncid )
318 print *,'status = ',status
321 FFLAGS
=`grep ^FFLAGS configure.wps | cut -d"=" -f2-`
322 cp $NETCDF/include
/netcdf.inc .
323 FC
=`grep ^SFC configure.wps | cut -d"=" -f2-`
324 $FC ${FFLAGS} fort_netcdf.f
-o fort_netcdf
-L${NETCDF}/lib
-lnetcdf $NETCDFF > /dev
/null
2>&1
325 if [ -f "fort_netcdf" ] ; then
326 fort_netcdf
> /dev
/null
2>&1
328 /bin
/rm fort_netcdf.f fort_netcdf netcdf.inc
331 echo "Your Fortran + NETCDF did not run successfully."
336 echo "Your versions of Fortran and NETCDF are not consistent."
343 # define C_TEST c_test
345 # if defined ( F2CSTYLE ) || defined ( _DOUBLEUNDERSCORE )
346 # define C_TEST c_test__
348 # define C_TEST c_test_
354 int C_TEST ( float *xx, int *ii )
357 printf("OK print in C function. \n" ) ;
358 printf("Values are xx = %5.2f and ii = %d \n", *xx, *ii ) ;
362 CFLAGS
=`grep ^CFLAGS configure.wps | cut -d"=" -f2-`
363 CPPFLAGS
=`grep ^CPPFLAGS configure.wps | cut -d"=" -f2-`
364 CC
=`grep ^SCC configure.wps | cut -d"=" -f2-`
365 ${CC} -c ${CFLAGS} ${CPPFLAGS} c_test.c
367 cat > f_test.f90
<<EOF
375 CALL c_test ( xx , ii )
379 $FC ${FFLAGS} f_test.f90
-o cf_test c_test.o
> /dev
/null
2>&1
380 if [ -f "cf_test" ] ; then
381 cf_test
> /dev
/null
2>&1
383 /bin
/rm -f cf_test c_test.c c_test.o f_test.f90 f_test.o
386 echo "Your Fortran + C did not run successfully."
391 echo "Your versions of Fortran and C are not consistent."