1 | #!/bin/sh |
---|
2 | |
---|
3 | # ======================================================= |
---|
4 | # Compiler script for newdiag.F90 interpol_soil.F90 |
---|
5 | # Liam Steele June 2014 |
---|
6 | # ======================================================= |
---|
7 | |
---|
8 | # Determine which Fortran compiler to use |
---|
9 | fcomp=0 |
---|
10 | echo "Which Fortran compiler do you want to use?" |
---|
11 | echo "1. ifort" |
---|
12 | echo "2. g95" |
---|
13 | echo "3. pgf90" |
---|
14 | while [ $fcomp != 1 -a $fcomp != 2 -a $fcomp != 3 ] ; do |
---|
15 | read fcomp |
---|
16 | if [ $fcomp != 1 -a $fcomp != 2 -a $fcomp != 3 ] ; then |
---|
17 | echo "Not a valid compiler choice. Please try again:" |
---|
18 | fi |
---|
19 | done |
---|
20 | |
---|
21 | # Look for NetCDF libraries |
---|
22 | if [ -n "$NETCDF" ] ; then |
---|
23 | echo "Will use NetCDF in directory: $NETCDF" |
---|
24 | else |
---|
25 | success="" |
---|
26 | while [ -z "$success" ] ; do |
---|
27 | echo "Cannot find NetCDF library. Please enter full path:" |
---|
28 | read ncdfpath |
---|
29 | if [ ! -d "$ncdfpath" ] ; then |
---|
30 | echo "invalid path: $ncdfpath" ; continue |
---|
31 | success="" |
---|
32 | else |
---|
33 | success="yes" |
---|
34 | fi |
---|
35 | netcdfipath=$ncdfpath |
---|
36 | done |
---|
37 | echo "For future use you should put this path into your bash profile, i.e." |
---|
38 | echo "export NETCDF="$ncdfpath |
---|
39 | fi |
---|
40 | |
---|
41 | # Check diagfi.nc exists for conversion |
---|
42 | if ! [ -e "diagfi.nc" ] ; then |
---|
43 | echo 'Please link a valid diagfi.nc file' |
---|
44 | exit |
---|
45 | fi |
---|
46 | |
---|
47 | # Check we are in the ukv_newdiag directory |
---|
48 | thispwd=`echo $(pwd)` |
---|
49 | length=${#thispwd} |
---|
50 | substr=`echo $thispwd | cut -c$((length-10))-$((length))` |
---|
51 | if [ $substr != "ukv_newdiag" ] ; then |
---|
52 | echo 'Not in ukv_newdiag directory' |
---|
53 | exit |
---|
54 | fi |
---|
55 | |
---|
56 | # Since all checks are complete, create new diagfi. If you want to use a |
---|
57 | # compiler other than ifort you'll have to change the compiler flags |
---|
58 | echo 'Compiling executable...' |
---|
59 | if [ -e "newdiag.exe" ] ; then |
---|
60 | rm newdiag.exe |
---|
61 | fi |
---|
62 | if [ $fcomp == 1 ] ; then |
---|
63 | ifort -convert big_endian -I$NETCDF newdiag.F90 interpol_soil.F90 -o newdiag.exe -L$NETCDF -lnetcdf |
---|
64 | elif [ $fcomp == 2 ] ; then |
---|
65 | g95 -fno-second-underscore -I$NETCDF newdiag.F90 interpol_soil.F90 -o newdiag.exe -L$NETCDF -lnetcdf |
---|
66 | elif [ $fcomp == 3 ] ; then |
---|
67 | pgf90 -byteswapio -I$NETCDF newdiag.F90 interpol_soil.F90 -o newdiag.exe -L$NETCDF -lnetcdf |
---|
68 | fi |
---|
69 | chmod u+x newdiag.exe |
---|
70 | ./newdiag.exe |
---|
71 | |
---|
72 | # Create link in PREP_MARS |
---|
73 | echo 'Linking new diagfi to PREP_MARS' |
---|
74 | cd .. |
---|
75 | ln -sf ukv_newdiag/diagfi_new.nc input_diagfi.nc |
---|
76 | |
---|
77 | echo 'Done!' |
---|
78 | |
---|
79 | exit |
---|