diff -Naur cdat-4.0b3/libcdms/configure cdat-4.0b3-pp/libcdms/configure --- cdat-4.0b3/libcdms/configure 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/configure 2004-11-04 16:57:55.000000000 +0000 @@ -18,6 +18,8 @@ ac_help="$ac_help --enable-dods Compile with the DODS interface [default=no]" ac_help="$ac_help + --enable-pp Compile the PP interface [default=yes]" +ac_help="$ac_help --enable-ql Compile the QL interface [default=yes]" ac_help="$ac_help --with-ncinc=DIR netcdf.h is in DIR (default [NCINC])" @@ -564,7 +566,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:568: checking for $ac_word" >&5 +echo "configure:570: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -614,7 +616,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:618: checking for $ac_word" >&5 +echo "configure:620: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -673,7 +675,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:677: checking for $ac_word" >&5 +echo "configure:679: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -708,7 +710,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:712: checking for $ac_word" >&5 +echo "configure:714: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -756,7 +758,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:760: checking for $ac_word" >&5 +echo "configure:762: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -791,7 +793,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:795: checking for $ac_word" >&5 +echo "configure:797: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -843,7 +845,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:847: checking for $ac_word" >&5 +echo "configure:849: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -899,7 +901,7 @@ ;; *) echo $ac_n "checking for C compiler""... $ac_c" 1>&6 -echo "configure:903: checking for C compiler" >&5 +echo "configure:905: checking for C compiler" >&5 echo "$ac_t""$CC" 1>&6 ;; esac @@ -923,7 +925,7 @@ rm -f conftest* echo $ac_n "checking type of operating system""... $ac_c" 1>&6 -echo "configure:927: checking type of operating system" >&5 +echo "configure:929: checking type of operating system" >&5 if test -z "$OS"; then OS=`uname -s | tr '[A-Z]' '[a-z]' | sed 's;/;;g'` if test -z "$OS"; then @@ -1020,7 +1022,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1024: checking for $ac_word" >&5 +echo "configure:1026: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1070,7 +1072,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1074: checking for $ac_word" >&5 +echo "configure:1076: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1129,7 +1131,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1133: checking for $ac_word" >&5 +echo "configure:1135: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1164,7 +1166,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1168: checking for $ac_word" >&5 +echo "configure:1170: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1212,7 +1214,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1216: checking for $ac_word" >&5 +echo "configure:1218: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1247,7 +1249,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1251: checking for $ac_word" >&5 +echo "configure:1253: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1299,7 +1301,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1303: checking for $ac_word" >&5 +echo "configure:1305: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1355,7 +1357,7 @@ ;; *) echo $ac_n "checking for C compiler""... $ac_c" 1>&6 -echo "configure:1359: checking for C compiler" >&5 +echo "configure:1361: checking for C compiler" >&5 echo "$ac_t""$CC" 1>&6 ;; esac @@ -1386,7 +1388,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1390: checking for $ac_word" >&5 +echo "configure:1392: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1439,7 +1441,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1443: checking for $ac_word" >&5 +echo "configure:1445: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1476,7 +1478,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1480: checking for $ac_word" >&5 +echo "configure:1482: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1513,7 +1515,7 @@ fi else echo $ac_n "checking for FORTRAN compiler""... $ac_c" 1>&6 -echo "configure:1517: checking for FORTRAN compiler" >&5 +echo "configure:1519: checking for FORTRAN compiler" >&5 echo "$ac_t""$FC" 1>&6 fi @@ -1521,7 +1523,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1525: checking for $ac_word" >&5 +echo "configure:1527: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1579,7 +1581,7 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1583: checking for a BSD compatible install" >&5 +echo "configure:1585: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1643,7 +1645,7 @@ fi echo $ac_n "checking if DRS is enabled""... $ac_c" 1>&6 -echo "configure:1647: checking if DRS is enabled" >&5 +echo "configure:1649: checking if DRS is enabled" >&5 # Check whether --enable-drs or --disable-drs was given. if test "${enable_drs+set}" = set; then enableval="$enable_drs" @@ -1661,7 +1663,7 @@ echo $ac_n "checking if HDF is enabled""... $ac_c" 1>&6 -echo "configure:1665: checking if HDF is enabled" >&5 +echo "configure:1667: checking if HDF is enabled" >&5 # Check whether --enable-hdf or --disable-hdf was given. if test "${enable_hdf+set}" = set; then enableval="$enable_hdf" @@ -1679,7 +1681,7 @@ echo $ac_n "checking if DODS is enabled""... $ac_c" 1>&6 -echo "configure:1683: checking if DODS is enabled" >&5 +echo "configure:1685: checking if DODS is enabled" >&5 # Check whether --enable-dods or --disable-dods was given. if test "${enable_dods+set}" = set; then enableval="$enable_dods" @@ -1696,8 +1698,29 @@ fi +echo $ac_n "checking if PP is enabled""... $ac_c" 1>&6 +echo "configure:1703: checking if PP is enabled" >&5 +# Check whether --enable-pp or --disable-pp was given. +if test "${enable_pp+set}" = set; then + enableval="$enable_pp" + ENABLE_PP=$enableval +else + ENABLE_PP=yes +fi + + +if test "X$ENABLE_PP" = "Xyes"; then + echo "$ac_t""yes" 1>&6 + PPOPTS="-DHAVE_PP" +else + echo "$ac_t""no" 1>&6 + PPOPTS="" +fi + + + echo $ac_n "checking if QL is enabled""... $ac_c" 1>&6 -echo "configure:1701: checking if QL is enabled" >&5 +echo "configure:1724: checking if QL is enabled" >&5 # Check whether --enable-ql or --disable-ql was given. if test "${enable_ql+set}" = set; then enableval="$enable_ql" @@ -1718,7 +1741,7 @@ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1722: checking how to run the C preprocessor" >&5 +echo "configure:1745: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1733,13 +1756,13 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1743: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1766: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1750,13 +1773,13 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1760: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1783: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1767,13 +1790,13 @@ rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1777: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1800: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1808,17 +1831,17 @@ echo "checking that netcdf.h is in $NCINC (modify with --with-ncinc=DIR)" ac_safe=`echo "$NCINC/netcdf.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $NCINC/netcdf.h""... $ac_c" 1>&6 -echo "configure:1812: checking for $NCINC/netcdf.h" >&5 +echo "configure:1835: checking for $NCINC/netcdf.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1822: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1845: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1870,17 +1893,17 @@ echo "checking that $HDF_HEADER_OPTIONS is in $HDFINC (modify with --with-hdfinc=DIR)" ac_safe=`echo "$HDFINC/$HDF_HEADER_OPTIONS" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $HDFINC/$HDF_HEADER_OPTIONS""... $ac_c" 1>&6 -echo "configure:1874: checking for $HDFINC/$HDF_HEADER_OPTIONS" >&5 +echo "configure:1897: checking for $HDFINC/$HDF_HEADER_OPTIONS" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1884: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1925,17 +1948,17 @@ echo "checking that drscdf.h is in $DRSINC (modify with --with-drsinc=DIR)" ac_safe=`echo "$DRSINC/drscdf.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $DRSINC/drscdf.h""... $ac_c" 1>&6 -echo "configure:1929: checking for $DRSINC/drscdf.h" >&5 +echo "configure:1952: checking for $DRSINC/drscdf.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1939: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1962: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1980,7 +2003,7 @@ fi echo "checking that netcdf.inc is in $NCINCF (modify with --with-ncincf=DIR)" echo $ac_n "checking for netcdf.inc""... $ac_c" 1>&6 -echo "configure:1984: checking for netcdf.inc" >&5 +echo "configure:2007: checking for netcdf.inc" >&5 if test -r "$NCINCF/netcdf.inc"; then for arg in -I$NCINCF; do case "$FFLAGS" in @@ -2008,7 +2031,7 @@ fi echo "checking that drsdef.h is in $DRSINCF (modify with --with-drsincf=DIR)" echo $ac_n "checking for drsdef.h""... $ac_c" 1>&6 -echo "configure:2012: checking for drsdef.h" >&5 +echo "configure:2035: checking for drsdef.h" >&5 if test -r "$DRSINCF/drsdef.h"; then for arg in -I$DRSINCF; do case "$FFLAGS" in @@ -2053,7 +2076,7 @@ fi echo "checking that libmfhdf.a is in $HDFLIB (modify with --with-hdflib=DIR)" echo $ac_n "checking for libmfhdf.a""... $ac_c" 1>&6 -echo "configure:2057: checking for libmfhdf.a" >&5 +echo "configure:2080: checking for libmfhdf.a" >&5 LIBS_save=$LIBS CPPFLAGS_save=$CPPFLAGS LIBS= @@ -2093,14 +2116,14 @@ CPPFLAGS=$CPPFLAGS" -Dt=MAIN_" fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -2137,7 +2160,8 @@ DODS_LIB_OPTIONS="netcdf" if test "X$ENABLE_DODS" = "Xyes"; then - #DODS_LIB_OPTIONS="nc-dods -ldap++ -lnc-dods -ldap++ -lstdc++ -lcurl -lz -lssl -lcrypto -ldl -lz -lrx -lz" + #DODS_LIB_OPTIONS="nc-dods -ldap++ -lnc-dods -ldap++ -lwww -lrx -lz -lstdc++ " + #DODS_LIB_OPTIONS="nc-dods -ldap++ -lnc-dods -ldap++ -lstdc++ -lcurl -lz -lssl -lcrypto -ldl -lz -lrx -lz " case "${OS}$OS_MAJOR" in darwin*) DODS_LIB_OPTIONS="nc-dods -ldap++ -lstdc++ -lcurl -lz -lssl -lpthread -lxml2 -lrx -lz" @@ -2174,7 +2198,7 @@ fi echo "checking that libnetcdf.a is in $NCLIB (modify with --with-nclib=DIR)" echo $ac_n "checking for libnetcdf.a""... $ac_c" 1>&6 -echo "configure:2169: checking for libnetcdf.a" >&5 +echo "configure:2202: checking for libnetcdf.a" >&5 LIBS_save=$LIBS CPPFLAGS_save=$CPPFLAGS LIBS= @@ -2214,14 +2238,14 @@ CPPFLAGS=$CPPFLAGS" -Dt=MAIN_" fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -2269,7 +2293,7 @@ PC_FORT_EXTRA_LIBS=$PC_FORT_EXTRA_LIBS" -lF77 -lm -lU77 -lI77 -lisam -lc" ;; linux*) - PC_FORT_EXTRA_LIBS=$PC_FORT_EXTRA_LIBS" -L/usr/pgi/linux86/$PGI_VERSION/lib -lpgftnrtl -lpgc -lm" + PC_FORT_EXTRA_LIBS=$PC_FORT_EXTRA_LIBS" -L/usr/pgi/linux86/lib -lpgftnrtl -lpgc -lm" ;; osf*) PC_FORT_EXTRA_LIBS=$PC_FORT_EXTRA_LIBS" -lfor -lc -lm" @@ -2299,7 +2323,7 @@ case "$OS" in aix) echo $ac_n "checking for libdrs.a""... $ac_c" 1>&6 -echo "configure:2294: checking for libdrs.a" >&5 +echo "configure:2327: checking for libdrs.a" >&5 if test -r "$DRSLIB/libdrs.a"; then for arg in -L$DRSLIB -ldrs; do case "$LIBS" in @@ -2338,7 +2362,7 @@ ;; osf*) echo $ac_n "checking for libdrs.a""... $ac_c" 1>&6 -echo "configure:2333: checking for libdrs.a" >&5 +echo "configure:2366: checking for libdrs.a" >&5 if test -r "$DRSLIB/libdrs.a"; then for arg in -L$DRSLIB -ldrs; do case "$LIBS" in @@ -2377,7 +2401,7 @@ ;; linux*) echo $ac_n "checking for libdrs.a on linux""... $ac_c" 1>&6 -echo "configure:2372: checking for libdrs.a on linux" >&5 +echo "configure:2405: checking for libdrs.a on linux" >&5 if test -r "$DRSLIB/libdrs.a"; then for arg in -L$DRSLIB -ldrs; do case "$LIBS" in @@ -2416,7 +2440,7 @@ ;; *) echo $ac_n "checking for libdrs.a""... $ac_c" 1>&6 -echo "configure:2411: checking for libdrs.a" >&5 +echo "configure:2444: checking for libdrs.a" >&5 LIBS_save=$LIBS CPPFLAGS_save=$CPPFLAGS LIBS= @@ -2456,14 +2480,14 @@ CPPFLAGS=$CPPFLAGS" -Dt=MAIN_" fi cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -2706,7 +2730,7 @@ ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo " Makefile src/cddrs/Makefile src/cddrs/test/Makefile src/cdunif/Makefile src/cdunif/test/Makefile src/db_util/Makefile src/api/Makefile src/api/test/Makefile +trap 'rm -fr `echo " Makefile src/cddrs/Makefile src/cddrs/test/Makefile src/cdunif/Makefile src/cdunif/cdunifpp/Makefile src/cdunif/test/Makefile src/db_util/Makefile src/api/Makefile src/api/test/Makefile " | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF diff -Naur cdat-4.0b3/libcdms/configure.in cdat-4.0b3-pp/libcdms/configure.in --- cdat-4.0b3/libcdms/configure.in 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/configure.in 2004-11-04 16:57:55.000000000 +0000 @@ -66,7 +66,26 @@ else AC_MSG_RESULT(no) fi -AC_SUBST(ENABLE_HDF) +AC_SUBST(ENABLE_DODS) +dnl ---------------------------------------------------------------------- +dnl Check if PP is enabled +dnl + +AC_MSG_CHECKING(if PP is enabled) +AC_ARG_ENABLE(pp, + [ --enable-pp Compile the PP interface [default=yes]], + ENABLE_PP=$enableval, + ENABLE_PP=yes) + +if test "X$ENABLE_PP" = "Xyes"; then + AC_MSG_RESULT(yes) + PPOPTS="-DHAVE_PP" +else + AC_MSG_RESULT(no) + PPOPTS="" +fi +AC_SUBST(ENABLE_PP) +AC_SUBST(PPOPTS) dnl ---------------------------------------------------------------------- dnl Check if QL is enabled dnl @@ -264,6 +283,7 @@ src/cddrs/Makefile dnl src/cddrs/test/Makefile dnl src/cdunif/Makefile dnl + src/cdunif/cdunifpp/Makefile dnl src/cdunif/test/Makefile dnl src/db_util/Makefile dnl src/api/Makefile dnl diff -Naur cdat-4.0b3/libcdms/include/cdunif.h cdat-4.0b3-pp/libcdms/include/cdunif.h --- cdat-4.0b3/libcdms/include/cdunif.h 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunif.h 2004-11-04 16:57:55.000000000 +0000 @@ -90,7 +90,7 @@ * valid formats must begin at 0 and increase * sequentially, with CuNumberOfFormats the last entry. */ -typedef enum CuFileType {CuUnknown = -1, CuDrs=0, CuGrads=1, CuNetcdf=2, CuHdf=3, CuQL=4, CuPop=5, CuNumberOfFormats} CuFileType; +typedef enum CuFileType {CuUnknown = -1, CuDrs=0, CuGrads=1, CuNetcdf=2, CuHdf=3, CuQL=4, CuPop=5, CuPP=6, CuNumberOfFormats} CuFileType; typedef enum CuDimType {CuGlobalDim = 1, CuLocalDim} CuDimType; typedef struct { diff -Naur cdat-4.0b3/libcdms/include/cdunifint.h cdat-4.0b3-pp/libcdms/include/cdunifint.h --- cdat-4.0b3/libcdms/include/cdunifint.h 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifint.h 2004-11-04 16:57:55.000000000 +0000 @@ -339,6 +339,16 @@ extern int cuopenread_stub_pop(const char* controlpath, const char* datapath); #endif + /* PP functions */ +#ifdef HAVE_PP +extern int cuopenread_pp(const char* controlpath, const char* datapath); +extern int cuclose_pp(CuFile* file); +extern int cudimget_pp(CuFile* file, int dimid, void* values); +extern int cuvarget_pp(CuFile* file, int varid, const long start[], const long count[], void* value); +#else +extern int cuopenread_stub_pp(const char* controlpath, const char* datapath); +#endif + /* Globals */ extern int cuLastDrsErr; /* Most recent DRS error number */ diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/cdunifpp_frename.h cdat-4.0b3-pp/libcdms/include/cdunifpp/cdunifpp_frename.h --- cdat-4.0b3/libcdms/include/cdunifpp/cdunifpp_frename.h 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifpp/cdunifpp_frename.h 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,60 @@ +/* including this header file will rename all the functions in the library + * used for WGDOS unpacking within cdunifpp, in order to avoid potential + * namespace conflicts + */ + +#define bit_test pp_unwgdos__bit_test +#define extrin pp_unwgdos__extrin +#define move_bits pp_unwgdos__move_bits +#define read_wgdos_header pp_unwgdos__read_wgdos_header +#define unwgdos pp_unwgdos__unwgdos +#define xpnd pp_unwgdos__xpnd +#define c8_to_i4 pp_unwgdos__c8_to_i4 +#define c8toi4_ pp_unwgdos__c8toi4_ +#define c8_to_i8 pp_unwgdos__c8_to_i8 +#define c8toi8_ pp_unwgdos__c8toi8_ +#define c8_to_l4 pp_unwgdos__c8_to_l4 +#define c8tol4_ pp_unwgdos__c8tol4_ +#define c8_to_l8 pp_unwgdos__c8_to_l8 +#define c8tol8_ pp_unwgdos__c8tol8_ +#define c8_to_r4 pp_unwgdos__c8_to_r4 +#define c8tor4_ pp_unwgdos__c8tor4_ +#define c8_to_r8 pp_unwgdos__c8_to_r8 +#define c8tor8_ pp_unwgdos__c8tor8_ +#define cos_backspace pp_unwgdos__cos_backspace +#define cosbackspace_ pp_unwgdos__cosbackspace_ +#define cos_close pp_unwgdos__cos_close +#define cosclose_ pp_unwgdos__cosclose_ +#define cos_open pp_unwgdos__cos_open +#define cosopen_ pp_unwgdos__cosopen_ +#define cos_read pp_unwgdos__cos_read +#define cosread_ pp_unwgdos__cosread_ +#define cos_rewind pp_unwgdos__cos_rewind +#define cosrewind_ pp_unwgdos__cosrewind_ +#define expand21_ pp_unwgdos__expand21_ +#define expand21_r4_ pp_unwgdos__expand21_r4_ +#define expand21_r8_ pp_unwgdos__expand21_r8_ +#define i4_to_i8 pp_unwgdos__i4_to_i8 +#define i8_to_i4 pp_unwgdos__i8_to_i4 +#define ibmi2_to_i4 pp_unwgdos__ibmi2_to_i4 +#define ibmi2toi4_ pp_unwgdos__ibmi2toi4_ +#define ibmi2_to_i8 pp_unwgdos__ibmi2_to_i8 +#define ibmi2toi8_ pp_unwgdos__ibmi2toi8_ +#define ibmi4_to_i4 pp_unwgdos__ibmi4_to_i4 +#define ibmi4toi4_ pp_unwgdos__ibmi4toi4_ +#define ibmi4_to_i8 pp_unwgdos__ibmi4_to_i8 +#define ibmi4toi8_ pp_unwgdos__ibmi4toi8_ +#define ibmr4_to_r4 pp_unwgdos__ibmr4_to_r4 +#define ibmr4tor4_ pp_unwgdos__ibmr4tor4_ +#define ibmr4_to_r8 pp_unwgdos__ibmr4_to_r8 +#define ibmr4tor8_ pp_unwgdos__ibmr4tor8_ +#define ibmr8_to_r8 pp_unwgdos__ibmr8_to_r8 +#define ibmr8tor8_ pp_unwgdos__ibmr8tor8_ +#define ii4toi8_ pp_unwgdos__ii4toi8_ +#define ii8toi4_ pp_unwgdos__ii8toi4_ +#define r4_to_r8 pp_unwgdos__r4_to_r8 +#define r4tor8_ pp_unwgdos__r4tor8_ +#define r8_to_r4 pp_unwgdos__r8_to_r4 +#define r8tor4_ pp_unwgdos__r8tor4_ +#define swap_bytes pp_unwgdos__swap_bytes +#define swapbytes_ pp_unwgdos__swapbytes_ diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/cdunifpp.h cdat-4.0b3-pp/libcdms/include/cdunifpp/cdunifpp.h --- cdat-4.0b3/libcdms/include/cdunifpp/cdunifpp.h 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifpp/cdunifpp.h 2004-11-04 17:11:44.000000000 +0000 @@ -0,0 +1,711 @@ +/* Header file for stuff used internally by cdunif_pp */ + + +/* all the headers we use */ +#include "cdunif.h" +#include "cdunifint.h" +#include +#include +#include +#include +#include +#include +#include + +/*---------------------------------------------------------*/ + +#define CDUNIFPP_VERSION "0.3" + +/*---------------------------------------------------------*/ + +/* Data types for internal calculations: + * + * NOTE: Fint and Freal must be the same length as each other + * and inttype and realtype must be set accordingly + * + * Currently, this *must* be four-byte, because there is NO CuType + * corresponding to 8-byte integer on Linux/gcc (would need to be + * long long, but CuLong corresponds to a long) + * sizes: int = 4, long = 4, long long = 8 + * + */ + +typedef int Fint; +typedef float Freal; + +static const CuType inttype = CuInt; +static const CuType realtype = CuFloat; + +static const int wordsize = sizeof(Fint); + +/* for float comparisons - related to word size */ +static const float tolerance = 1e-4; + + +/* data types of exact length -- may need to change according to platform + * (these are double-checked at run-time in pp_check_sizes() + */ + +typedef int Fint4; +typedef long long Fint8; +typedef float Freal4; +typedef double Freal8; + +/*---------------------------------------------------------*/ + +/* endian-ness - set or clear LITTLE_ENDIAN_MACHINE * + * currently seems that BYTESWAP is set for us, so use that, + * but could change to include endian.h and then + * test using #if (__BYTE_ORDER == __LITTLE_ENDIAN) + */ +#ifdef BYTESWAP +#define LITTLE_ENDIAN_MACHINE +#else +#undef LITTLE_ENDIAN_MACHINE +#endif + +/*---------------------------------------------------------*/ + +/*longest string attribute value */ +#define MAX_ATT_LEN 120 + +/*---------------------------------------------------------*/ +/* constants */ + +static const int n_int_hdr = 45; +static const int n_real_hdr = 19; +/* static const int n_hdr = n_int_hdr + n_real_hdr; */ +static const int n_hdr = 64; + +static const int int_fill_value = -32768; + +static const Freal reference_pressure = 1e5; /* Pa */ + +/* origin time */ +static const int default_year_orig = 1970; +static const int default_month_orig = 1; +static const int default_day_orig = 1; +static const int default_hour_orig = 0; +static const int default_minute_orig = 0; +static const int default_second_orig = 0; + +/*---------------------------------------------------------*/ + +/* first, for convenience, typedefs for all the structs */ +typedef struct pp_file PPfile; +typedef struct pp_var PPvar; +typedef struct pp_dim PPdim; +typedef struct pp_rec PPrec; +typedef struct pp_hdr PPhdr; +typedef struct pp_stashmeta PPstashmeta; +typedef struct pp_data PPdata; +typedef struct pp_list PPlist; +typedef struct pp_listel PPlistel; +typedef struct pp_listpos PPlistpos; + +typedef struct pp_fieldvar PPfieldvar; +typedef struct pp_axis PPaxis; +typedef struct pp_regaxis PPregaxis; +typedef struct pp_zaxis PPzaxis; +typedef struct pp_level PPlevel; +typedef struct pp_taxis PPtaxis; +typedef struct pp_time PPtime; +typedef struct pp_date PPdate; +typedef struct pp_landmask PPlandmask; + +typedef enum pp_convert PPconvert; +typedef enum pp_filetype PPfiletype; +typedef enum pp_axistype PPaxistype; +typedef enum pp_lev_val_type PPlevvaltype; +typedef enum pp_calendartype PPcalendartype; + +enum pp_calendartype { + gregorian, + cal360day, + model +}; + +enum pp_filetype { + pp_type, + um_type +}; + +enum pp_convert { + convert_none, + convert_int, + convert_real +}; + +enum pp_axistype { + xaxistype, + yaxistype, + zaxistype, + taxistype, + num_axistype +}; +enum pp_lev_val_type { + lev_type, + hybrid_a_type, + hybrid_b_type +}; + + +/* Structures for all sorts of things. */ + +/* (In the rare case where structures are included in another directly, + * not as a pointer, need to be defined in correct order. This currently + * only affects struct pp_date) + */ + +/* --- these three are internal structures we will hang off the internp + * elements of CuFile, CuVar, CuDim + */ +struct pp_file { + FILE *fh; /* stdio FILE handle */ + int nrec; /* number of PP records */ + PPrec **recs; /* records */ + PPlist *heaplist; /* heap memory */ + PPfiletype type; /* PP or UM */ + int swap; /* true if byte swap */ + int wordsize; /* in bytes */ + PPlandmask *landmask; +}; +struct pp_var { + int startrec; /* for fieldvar */ + int endrec; /* for fieldvar */ + PPdata *data; /* for dim var */ + + PPlist *atts; /* temporary place to store attributes + * until the number is known and they can be + * added properly + */ +}; + +struct pp_dim { +}; + +/*------------------------------------------------------*/ + +/* structure for temporary use while scanning fieldvars */ +struct pp_fieldvar { + int startrec; /* for fieldvar */ + int endrec; /* for fieldvar */ + PPregaxis *xaxis; + PPregaxis *yaxis; + PPzaxis *zaxis; + PPtaxis *taxis; +}; + +/* metadata which is not contained in the header but looked up + * as a function of the stash codes + */ +#define SM_MAX_LEN MAX_ATT_LEN +struct pp_stashmeta { + char longname[SM_MAX_LEN+1]; + char units[SM_MAX_LEN+1]; + char shortname[SM_MAX_LEN+1]; + char stdname[SM_MAX_LEN+1]; + + /* "source" is where the lookup comes from. + * + * Quite deliberately there is only one "source", rather than separate sources + * for the various names and units (even though the STASHmaster file has long + * name but not units in a usable form). These have to go together. It is + * no good using a STASHmaster file to override some diagnostics and then using + * compiled-in units lookup. Therefore the means of overriding the lookup + * with table-driven input is going to have to be something better than + * STASHmaster files. + */ + char source[SM_MAX_LEN+1]; +}; + +struct pp_data { + CuType type; + int n; + void *values; +}; + +/* for linked list */ +struct pp_list { + int n; + PPlistel *first; + PPlistel *last; +}; +struct pp_listel { + void *ptr; + PPlistel *prev; + PPlistel *next; +}; + +struct pp_listpos { + /* This is a little structure which stores the current list position. + * Its purpose is simply to store this outside the list structure itself, + * so that for read-only scanning of the list, the PPlist* can be declared + * as const. + */ + PPlistel *current; + const PPlist *list; /* store also (read-only) list ptr to enable sanity checking + * between pp_list_startwalk and pp_list_walk */ +}; + +/* land mask */ +struct pp_landmask { + PPregaxis *xaxis; + PPregaxis *yaxis; + PPdata *data; +}; + +/* regaxis used for x or y axes */ +struct pp_regaxis { + int dimid; + Fint n; + Freal start; + Freal interval; +}; +struct pp_zaxis { + int dimid; + Fint type; + PPlist *values; +}; + +struct pp_level { + Fint type; + Freal level; + Freal ref_level; + Freal hybrid_a; + Freal hybrid_ref_a; +}; + +struct pp_date { + /* this is a generic date */ + Fint year; + Fint month; + Fint day; + Fint hour; + Fint minute; + Fint second; +}; + +struct pp_taxis { + int dimid; + Fint type; + PPlist *values; + PPdate time_orig; +}; +struct pp_time { + /* this is a value on time axis */ + Fint type; + PPdate time1; + PPdate time2; +}; + +/* These #defines control which of the PP header elements are to be stored in memory. + * To reduce memory use, comment out the ones which are not required. + * If you comment out one which is needed, the error should be at compile time. + */ + +#define PP_STORE_LBYR +#define PP_STORE_LBMON +#define PP_STORE_LBDAT +#define PP_STORE_LBHR +#define PP_STORE_LBMIN +#define PP_STORE_LBDAY +#define PP_STORE_LBYRD +#define PP_STORE_LBMOND +#define PP_STORE_LBDATD +#define PP_STORE_LBHRD +#define PP_STORE_LBMIND +#define PP_STORE_LBDAYD +#define PP_STORE_LBTIM +#define PP_STORE_LBFT +#define PP_STORE_LBLREC +#define PP_STORE_LBCODE +#define PP_STORE_LBHEM +#define PP_STORE_LBROW +#define PP_STORE_LBNPT +#define PP_STORE_LBEXT +#define PP_STORE_LBPACK +#define PP_STORE_LBREL +#define PP_STORE_LBFC +#define PP_STORE_LBCFC +#define PP_STORE_LBPROC +#define PP_STORE_LBVC +#define PP_STORE_LBRVC +#define PP_STORE_LBEXP +#define PP_STORE_LBBEGIN +#define PP_STORE_LBNREC +#define PP_STORE_LBPROJ +#define PP_STORE_LBTYP +#define PP_STORE_LBLEV +#define PP_STORE_LBRSVD1 +#define PP_STORE_LBRSVD2 +#define PP_STORE_LBRSVD3 +#define PP_STORE_LBRSVD4 +#define PP_STORE_LBSRCE +#define PP_STORE_LBUSER1 +#define PP_STORE_LBUSER2 +#define PP_STORE_LBUSER3 +#define PP_STORE_LBUSER4 +#define PP_STORE_LBUSER5 +#define PP_STORE_LBUSER6 +#define PP_STORE_LBUSER7 +#define PP_STORE_BRSVD1 +#define PP_STORE_BRSVD2 +#define PP_STORE_BRSVD3 +#define PP_STORE_BRSVD4 +#define PP_STORE_BDATUM +#define PP_STORE_BACC +#define PP_STORE_BLEV +#define PP_STORE_BRLEV +#define PP_STORE_BHLEV +#define PP_STORE_BHRLEV +#define PP_STORE_BPLAT +#define PP_STORE_BPLON +#define PP_STORE_BGOR +#define PP_STORE_BZY +#define PP_STORE_BDY +#define PP_STORE_BZX +#define PP_STORE_BDX +#define PP_STORE_BMDI +#define PP_STORE_BMKS + + +struct pp_hdr { +#ifdef PP_STORE_LBYR + Fint LBYR; +#endif +#ifdef PP_STORE_LBMON + Fint LBMON; +#endif +#ifdef PP_STORE_LBDAT + Fint LBDAT; +#endif +#ifdef PP_STORE_LBHR + Fint LBHR; +#endif +#ifdef PP_STORE_LBMIN + Fint LBMIN; +#endif +#ifdef PP_STORE_LBDAY + Fint LBDAY; +#endif +#ifdef PP_STORE_LBYRD + Fint LBYRD; +#endif +#ifdef PP_STORE_LBMOND + Fint LBMOND; +#endif +#ifdef PP_STORE_LBDATD + Fint LBDATD; +#endif +#ifdef PP_STORE_LBHRD + Fint LBHRD; +#endif +#ifdef PP_STORE_LBMIND + Fint LBMIND; +#endif +#ifdef PP_STORE_LBDAYD + Fint LBDAYD; +#endif +#ifdef PP_STORE_LBTIM + Fint LBTIM; +#endif +#ifdef PP_STORE_LBFT + Fint LBFT; +#endif +#ifdef PP_STORE_LBLREC + Fint LBLREC; +#endif +#ifdef PP_STORE_LBCODE + Fint LBCODE; +#endif +#ifdef PP_STORE_LBHEM + Fint LBHEM; +#endif +#ifdef PP_STORE_LBROW + Fint LBROW; +#endif +#ifdef PP_STORE_LBNPT + Fint LBNPT; +#endif +#ifdef PP_STORE_LBEXT + Fint LBEXT; +#endif +#ifdef PP_STORE_LBPACK + Fint LBPACK; +#endif +#ifdef PP_STORE_LBREL + Fint LBREL; +#endif +#ifdef PP_STORE_LBFC + Fint LBFC; +#endif +#ifdef PP_STORE_LBCFC + Fint LBCFC; +#endif +#ifdef PP_STORE_LBPROC + Fint LBPROC; +#endif +#ifdef PP_STORE_LBVC + Fint LBVC; +#endif +#ifdef PP_STORE_LBRVC + Fint LBRVC; +#endif +#ifdef PP_STORE_LBEXP + Fint LBEXP; +#endif +#ifdef PP_STORE_LBBEGIN + Fint LBBEGIN; +#endif +#ifdef PP_STORE_LBNREC + Fint LBNREC; +#endif +#ifdef PP_STORE_LBPROJ + Fint LBPROJ; +#endif +#ifdef PP_STORE_LBTYP + Fint LBTYP; +#endif +#ifdef PP_STORE_LBLEV + Fint LBLEV; +#endif +#ifdef PP_STORE_LBRSVD1 + Fint LBRSVD1; +#endif +#ifdef PP_STORE_LBRSVD2 + Fint LBRSVD2; +#endif +#ifdef PP_STORE_LBRSVD3 + Fint LBRSVD3; +#endif +#ifdef PP_STORE_LBRSVD4 + Fint LBRSVD4; +#endif +#ifdef PP_STORE_LBSRCE + Fint LBSRCE; +#endif +#ifdef PP_STORE_LBUSER1 + Fint LBUSER1; +#endif +#ifdef PP_STORE_LBUSER2 + Fint LBUSER2; +#endif +#ifdef PP_STORE_LBUSER3 + Fint LBUSER3; +#endif +#ifdef PP_STORE_LBUSER4 + Fint LBUSER4; +#endif +#ifdef PP_STORE_LBUSER5 + Fint LBUSER5; +#endif +#ifdef PP_STORE_LBUSER6 + Fint LBUSER6; +#endif +#ifdef PP_STORE_LBUSER7 + Fint LBUSER7; +#endif +#ifdef PP_STORE_BRSVD1 + Freal BRSVD1; +#endif +#ifdef PP_STORE_BRSVD2 + Freal BRSVD2; +#endif +#ifdef PP_STORE_BRSVD3 + Freal BRSVD3; +#endif +#ifdef PP_STORE_BRSVD4 + Freal BRSVD4; +#endif +#ifdef PP_STORE_BDATUM + Freal BDATUM; +#endif +#ifdef PP_STORE_BACC + Freal BACC; +#endif +#ifdef PP_STORE_BLEV + Freal BLEV; +#endif +#ifdef PP_STORE_BRLEV + Freal BRLEV; +#endif +#ifdef PP_STORE_BHLEV + Freal BHLEV; +#endif +#ifdef PP_STORE_BHRLEV + Freal BHRLEV; +#endif +#ifdef PP_STORE_BPLAT + Freal BPLAT; +#endif +#ifdef PP_STORE_BPLON + Freal BPLON; +#endif +#ifdef PP_STORE_BGOR + Freal BGOR; +#endif +#ifdef PP_STORE_BZY + Freal BZY; +#endif +#ifdef PP_STORE_BDY + Freal BDY; +#endif +#ifdef PP_STORE_BZX + Freal BZX; +#endif +#ifdef PP_STORE_BDX + Freal BDX; +#endif +#ifdef PP_STORE_BMDI + Freal BMDI; +#endif +#ifdef PP_STORE_BMKS + Freal BMKS; +#endif +}; + +struct pp_rec { + int recno; /* record number */ + PPhdr hdr; /* header structure */ + long datapos; /* file pos data start (after any fortran record length int) in bytes */ + long disklen; /* length on disks (words) -- including padding + before unpacking */ + long datalen; /* data length (words) */ +}; + + +/*---------------------------------------------------------*/ + +/* prototypes */ + +/* in cdunifpp_attribute.c: */ +CuAtt *pp_att_new(const char *, CuType, long, const void *, PPlist *); +int pp_add_att(PPlist *, const char *, CuType, long, const void *, PPlist *); +CuAtt *pp_string_att_new(const char *, const char *, PPlist *); +int pp_add_string_att(PPlist *, const char *, const char *, PPlist *); +int pp_copy_and_free_atts(CuFile *, CuVar *, PPlist *, PPlist *); + +/* in cdunifpp_axisvals.c: */ +PPdata *pp_data_new(CuType,int,PPlist *); +PPdata *pp_regaxis_to_values(const PPregaxis *, PPlist *); +PPdata *pp_zaxis_to_values(const PPzaxis *, PPlevvaltype, PPlist *); +int pp_is_hybrid_levels(Fint); +PPdata *pp_taxis_to_values(const PPtaxis *, PPlist *); +PPdata *pp_taxis_to_boundary_values(const PPtaxis *, PPlist *); +int pp_is_time_mean(Fint); +Freal pp_time_diff(Fint, const PPdate *, const PPdate *); +PPcalendartype pp_calendar_type(Fint); +long long pp_gregorian_to_secs(const PPdate *); +char *pp_t_units(const PPtaxis *, PPlist *); + +/* in cdunifpp_check.c: */ +int pp_check_sizes(); + + +/* in cdunifpp_compare.c: */ +/* int pp_compare_ints(Fint, Fint); */ +/* int pp_compare_reals(Freal, Freal); */ +int pp_compare_records(const void *, const void *); +int pp_records_from_different_vars(const PPrec *, const PPrec *); +int pp_compare_regaxes(const void *, const void *); +int pp_compare_lists(const PPlist *, const PPlist *, int (*)(const void*, const void*)); +int pp_compare_levels(const void *, const void *); +int pp_compare_zaxes(const void *, const void *); +int pp_compare_times(const void *, const void *); +int pp_compare_dates(const PPdate *, const PPdate *); +int pp_compare_taxes(const void *, const void *); + +/* in cdunifpp_data.c: */ +int pp_data_copy(const CuFile *, const CuVar *, const long [], const long [], void *); +int pp_data_read(const CuFile *, const CuVar *, const long [], const long [], void *); + +/* in cdunifpp_error.c: */ +int pp_switch_bug(); +int pp_error(const char*); +int pp_errorhandle_init(); + +/* in cdunifpp_filetype.c: */ +int pp_determine_file_type(PPfile *, const char *, int); +int pp_determine_file_type_by_name(PPfile *, const char *); +int pp_is_ppum_file(const char *, FILE *); +int pp_determine_file_type_by_contents(PPfile *); +int pp_valid_um_word2(Fint8); +int pp_valid_pp_word1(Fint8,int); + + +int pp_string_ends_with(const char *, const char *); + +/* in cdunifpp_linklist.c: */ +void *pp_list_new(PPlist *); +int pp_list_free(PPlist *, int, PPlist *); +int pp_list_size(const PPlist *); +int pp_list_add(PPlist *, void *, PPlist *); +int pp_list_del(PPlist *, void *, PPlist *); +int pp_list_del_by_listel(PPlist *, PPlistel *, PPlist *); +int pp_list_startwalk(const PPlist *, PPlistpos *); +void *pp_list_walk(const PPlist *,int, PPlistpos *); +void *pp_list_find(PPlist *, const void *, int (*)(const void *, const void *), int); + +/* in cdunifpp_malloc.c: */ +void *pp_malloc(size_t, PPlist *); +int pp_free(void *, PPlist *); +int pp_free_all(PPlist *); + +/* in cdunifpp_ppcode.c: */ +char *pp_pplongname(int); +char *pp_ppshortname(int); +char *pp_ppunit(int); + +/* in cdunifpp_process.c: */ +int pp_process(CuFile *); + +/* in cdunifpp_read.c: */ +size_t pp_read_words(void *, size_t, PPconvert, const PPfile *); +int pp_swapbytes(void *, int, int); +void * pp_read_data_record(const PPrec *, const PPfile *, PPlist *); +int pp_swap32couplets(char *,int); +int pp_skip_fortran_record(const PPfile *); +int pp_skip_word(const PPfile *); +void *pp_read_header(const PPfile *, PPlist *); +int pp_read_all_headers(CuFile *); +int pp_store_header(PPhdr *, const void *); +int pp_evaluate_lengths (const PPhdr *, const PPfile *, long *, long *); + +/* in cdunifpp_stashname.c: */ +char *pp_stashname(int, int, int); + +/* in cdunifpp_stash2pp.c: */ +int pp_stashpp(int, int, int); + +/* in cdunifpp_struct.c: */ +CuFile *pp_create_file(const char *); +int pp_delete_file(CuFile *); + +/* in cdunifpp_unwgdoswrap.c: */ +int pp_unwgdos_wrap(const void *, int, void *, long, Freal, PPlist *); + +/* in cdunifpp_varinfo.c: */ +int pp_var_lookup(const PPhdr *, PPstashmeta *) ; +int pp_get_var_default_shortname(const PPhdr *, char *, int); +int pp_get_var_default_longname(const PPhdr *, char *, int); +int pp_get_var_default_units(const PPhdr *, char *, int); +int pp_get_var_stash_model(const PPhdr *); +int pp_get_var_stash_section(const PPhdr *); +int pp_get_var_stash_item(const PPhdr *); +int pp_get_var_packing(const PPhdr *); +int pp_get_var_compression(const PPhdr *); +int pp_get_var_processing(const PPhdr *hdr); +int pp_get_var_gridcode(const PPhdr *hdr); +int pp_get_var_name(int varid, const char *, CuVar *) ; +void *pp_get_var_fill_value(const PPhdr *); +int pp_var_is_land_mask(const PPhdr *); +CuType pp_get_var_type(const PPhdr *); +int pp_var_is_time_mean(const PPhdr *hdr); +int pp_var_is_time_min(const PPhdr *hdr); +int pp_var_is_time_max(const PPhdr *hdr); +int pp_var_is_zonal_mean(const PPhdr *hdr); + +/* in cdunifpp_debug.c: */ +void pp_dump_header(const PPhdr *); + +#define D(x) {printf("debug: %d\n",x);} diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/crayio.h cdat-4.0b3-pp/libcdms/include/cdunifpp/crayio.h --- cdat-4.0b3/libcdms/include/cdunifpp/crayio.h 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifpp/crayio.h 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,396 @@ +#if !defined(COS_HDR) +#define COS_HDR + +#ifdef _CRAY +#include +typedef _fcd fpchar; +#else +typedef char *fpchar; +#endif + +#if defined _CRAY +#if defined _CRAYMPP +#define SHORT32 +#define INT64 +#define FLOAT32 +#else +#define SHORT64 +#define INT64 +#define FLOAT64 +#endif +#else +#define SHORT16 +#define INT32 +#define FLOAT32 +#endif + +#define DOUBLE64 +#if defined _CRAY || defined __alpha || _MIPS_SZLONG == 64 || defined __64BIT__ +#define LONG64 +#else +#define LONG32 +#define LONGLONG64 +#endif + +#ifdef _IBM + +#ifdef SHORT16 +typedef unsigned short int uint16; +#endif +#ifdef INT32 +typedef unsigned int uint32; +#endif +#ifdef SHORT32 +typedef unsigned short int uint32; +#endif +#ifdef FLOAT32 +typedef float float32; +#endif +#ifdef DOUBLE64 +typedef double float64; +#endif +#ifdef LONG64 +typedef unsigned long int uint64; +#else +typedef unsigned long long int uint64; +#endif + +#else + +#ifdef SHORT16 +typedef short int int16; +typedef unsigned short int uint16; +#endif +#ifdef INT32 +typedef int int32; +typedef unsigned int uint32; +#endif +#ifdef SHORT32 +typedef short int int32; +typedef unsigned short int uint32; +#endif +#ifdef FLOAT32 +typedef float float32; +#endif +#ifdef DOUBLE64 +typedef double float64; +#endif +#ifdef LONG64 +typedef long int int64; +typedef unsigned long int uint64; +#else +typedef long long int int64; +typedef unsigned long long int uint64; +#endif + +#endif + +#define _IEEE4 0 +#define _IEEE8 1 +#define _CRAY8 2 + +#ifndef _FLT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _FLT_TYPE _CRAY8 +#else +#define _FLT_TYPE _IEEE8 +#endif +#else +#define _FLT_TYPE _IEEE4 +#endif +#endif + +#ifndef _INT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _INT_TYPE _CRAY8 +#else +#define _INT_TYPE _IEEE8 +#endif +#else +#define _INT_TYPE _IEEE4 +#endif +#endif + +#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8 +#define _FLT_SIZE 8 +#else +#define _FLT_SIZE 4 +#endif + +#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8 +#define _INT_SIZE 8 +#else +#define _INT_SIZE 4 +#endif + +#if _FLT_SIZE == 8 +#ifdef FLOAT32 +#define REAL double +#else +#define REAL float +#endif +#else +#define REAL float +#endif + +#if _INT_SIZE == 8 +#ifdef INT32 +#ifdef LONG64 +#define INTEGER long +#else +#define INTEGER long long +#endif +#else +#define INTEGER int +#endif +#else +#define INTEGER int +#endif + +#if defined __alpha || defined __i386 +#define LITTLE__ENDIAN +#else +#define BIG__ENDIAN +#endif + +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _CRAYNONIEEE +#endif +#endif + +#ifdef _CRAY +#ifndef _CRAYMPP +#define _CRAYPVP +#endif +#endif + +#define CBCW 0 /* COS block control word */ +#define CEOR 010 /* COS end of record */ +#define CEOF 016 /* COS end of file */ +#define CEOD 017 /* COS end of data */ + +#define CRAYWORD 8 /* Size of Cray word in bytes */ +#define BLOCKSIZE 4096 /* Size of Cray block in bytes */ + +#define MINSEXP32 0x3f6b /* min valid (translatable subnormal) + Cray masked exponent for IEEE 32 bit f.p. */ +#define MINEXP32 0x3f83 /* min valid (translatable normal) + Cray masked exponent for IEEE 32 bit f.p. */ +#define MAXEXP32 0x4080 /* max valid (translatable) + Cray masked exponent for IEEE 32 bit f.p. */ +#define MINSEXP64 0x3bce /* min valid (translatable subnormal) + Cray masked exponent for IEEE 64 bit f.p. */ +#define MINEXP64 0x3c03 /* min valid (translatable normal) + Cray masked exponent for IEEE 64 bit f.p. */ +#define MAXEXP64 0x4400 /* max valid (translatable) + Cray masked exponent for IEEE 64 bit f.p. */ + +#define MINCEXP 0x2003 /* min valid Cray masked exponent */ +#define MAXCEXP 0x5ffe /* max valid Cray masked exponent */ + +#define MINI32EXP 1 /* min valid 32 bit IEEE masked exponent */ +#define MAXI32EXP 254 /* max valid 32 bit IEEE masked exponent */ +#define MINI64EXP 1 /* min valid 64 bit IEEE masked exponent */ +#define MAXI64EXP 2046 /* max valid 64 bit IEEE masked exponent */ + +#define CBIAS 040000 /* Cray f.p. exponent bias */ +#define I32BIAS 0177 /* IEEE 32 bit f.p. exponent bias */ +#define I64BIAS 01777 /* IEEE 64 bit f.p. exponent bias */ + +#define CSIGNMASK 0x80 /* Mask to get 1st of 8 bits */ +#define CSIGNMASK1 0x80000000 /* Mask to get 1st of 32 bits */ +#define I32_NAN 0x7fffffff +#define I32_INFP 0x7f800000 +#define I32_INFN 0xff800000 +#define I32_ZEROP 0x00000000 +#define I32_ZERON 0x80000000 +#ifdef LONG64 +#define CSIGNMASK2 0x8000000000000000l /* Mask to get 1st of 64 bits */ +#define I64_NAN 0x7fffffffffffffffl +#define I64_INFP 0x7ff0000000000000l +#define I64_INFN 0xfff0000000000000l +#else +#define CSIGNMASK2 0x8000000000000000ll /* Mask to get 1st of 64 bits */ +#define I64_NAN 0x7fffffffffffffffll +#define I64_INFP 0x7ff0000000000000ll +#define I64_INFN 0xfff0000000000000ll +#endif + +#if defined _CRAY +#define cosopen COSOPEN +#define cosclose COSCLOSE +#define cosrewind COSREWIND +#define cosbackspace COSBACKSPACE +#define cosread COSREAD +#define swapbytes SWAPBYTES +#define c8tor4 C8TOR4 +#define c8toi4 C8TOI4 +#define c8tol4 C8TOL4 +#define c8tor8 C8TOR8 +#define c8toi8 C8TOI8 +#define c8tol8 C8TOL8 +#define r8tor4 R8TOR4 +#define ii8toi4 II8TOI4 +#define r4tor8 R4TOR8 +#define ii4toi8 II4TOI8 +#define r4toc8 R4TOC8 +#define i4toc8 I4TOC8 +#define l4toc8 L4TOC8 +#define r8toc8 R8TOC8 +#define i8toc8 I8TOC8 +#define l8toc8 L8TOC8 +#define ibmi4toi4 IBMI4TOI4 +#define ibmi2toi4 IBMI2TOI4 +#define ibmr4tor4 IBMR4TOR4 +#define ibmi4toi8 IBMI4TOI8 +#define ibmi2toi8 IBMI2TOI8 +#define ibmr4tor8 IBMR4TOR8 +#define ibmr8tor8 IBMR8TOR8 +#ifdef _CRAYPVP +#define ibmi4toc8 IBMI4TOC8 +#define ibmi2toc8 IBMI2TOC8 +#define ibmr4toc8 IBMR4TOC8 +#define ibmr8toc8 IBMR8TOC8 +#endif +#define expand21 EXPAND21 +#ifndef _CRAYPVP +#define expand21_r4 EXPAND21_R4_ +#define expand21_r8 EXPAND21_R8_ +#endif +#elif defined __sun || defined __sgi || defined __osf__ || defined __uxpv__ || defined __linux || defined _SX +#define cosopen cosopen_ +#define cosclose cosclose_ +#define cosrewind cosrewind_ +#define cosbackspace cosbackspace_ +#define cosread cosread_ +#define swapbytes swapbytes_ +#define c8tor4 c8tor4_ +#define c8toi4 c8toi4_ +#define c8tol4 c8tol4_ +#define c8tor8 c8tor8_ +#define c8toi8 c8toi8_ +#define c8tol8 c8tol8_ +#define r8tor4 r8tor4_ +#define ii8toi4 ii8toi4_ +#define r4tor8 r4tor8_ +#define ii4toi8 ii4toi8_ +#define ibmi4toi4 ibmi4toi4_ +#define ibmi2toi4 ibmi2toi4_ +#define ibmr4tor4 ibmr4tor4_ +#define ibmi4toi8 ibmi4toi8_ +#define ibmi2toi8 ibmi2toi8_ +#define ibmr4tor8 ibmr4tor8_ +#define ibmr8tor8 ibmr8tor8_ +#define expand21 expand21_ +#define expand21_r4 expand21_r4_ +#define expand21_r8 expand21_r8_ +#endif + +/* definition of a cosfile */ + +typedef struct { + char *fname; /* file name */ + FILE *fp; /* current file */ + unsigned long fwi; /* forward index of current bcw/rcw */ + unsigned long pri; /* backward index of current bcw/rcw */ +} COSFILE; + +/* Routines callable from C */ + +COSFILE *cos_open (char *, char *); +int cos_close (COSFILE *); +int cos_rewind (COSFILE *); +int cos_backspace (COSFILE *); +int cos_read (COSFILE *, void *, int, int *); +void swap_bytes(void *, int, int); +int c8_to_r4(void *, void *, int); +int c8_to_i4(void *, void *, int); +int c8_to_l4(void *, void *, int); +int c8_to_r8(void *, void *, int); +int c8_to_i8(void *, void *, int); +int c8_to_l8(void *, void *, int); +int r8_to_r4(void *, void *, int); +int i8_to_i4(void *, void *, int); +int r4_to_r8(void *, void *, int); +int i4_to_i8(void *, void *, int); +#ifdef _CRAY +int r4_to_c8(void *, void *, int); +int i4_to_c8(void *, void *, int); +int l4_to_c8(void *, void *, int); +int r8_to_c8(void *, void *, int); +int i8_to_c8(void *, void *, int); +int l8_to_c8(void *, void *, int); +#endif +int ibmi4_to_i4(void *, void *, int); +int ibmi2_to_i4(void *, void *, int, int); +int ibmr4_to_r4(void *, void *, int); +int ibmi4_to_i8(void *, void *, int, int); +int ibmi2_to_i8(void *, void *, int, int); +int ibmr4_to_r8(void *, void *, int, int); +int ibmr8_to_r8(void *, void *, int); +#ifdef _CRAYPVP +int ibmi4_to_c8(void *, void *, int, int); +int ibmi2_to_c8(void *, void *, int, int); +int ibmr4_to_c8(void *, void *, int, int); +int ibmr8_to_c8(void *, void *, int); +#endif + +/* Routines callable from Fortran */ + +void cosopen (COSFILE **, fpchar, fpchar, INTEGER *, long, long); +void cosclose (COSFILE **, INTEGER *); +void cosrewind (COSFILE **, INTEGER *); +void cosbackspace (COSFILE **, INTEGER *); +void cosread (COSFILE **, void *, INTEGER *, INTEGER *, INTEGER *); +void swapbytes(void *, INTEGER *, INTEGER *); +void c8tor4(void *, void *, INTEGER *, INTEGER *); +void c8toi4(void *, void *, INTEGER *, INTEGER *); +void c8tol4(void *, void *, INTEGER *, INTEGER *); +void c8tor8(void *, void *, INTEGER *, INTEGER *); +void c8toi8(void *, void *, INTEGER *, INTEGER *); +void c8tol8(void *, void *, INTEGER *, INTEGER *); +void expand21(INTEGER *, void *, void *, INTEGER *); +#ifndef _CRAYPVP +void expand21_r4(INTEGER *, void *, void *, INTEGER *); +void expand21_r8(INTEGER *, void *, void *, INTEGER *); +#endif +void r8tor4(void *, void *, INTEGER *, INTEGER *); +void ii8toi4(void *, void *, INTEGER *, INTEGER *); +void r4tor8(void *, void *, INTEGER *, INTEGER *); +void ii4toi8(void *, void *, INTEGER *, INTEGER *); +#ifdef _CRAY +void r4toc8(void *, void *, INTEGER *, INTEGER *); +void i4toc8(void *, void *, INTEGER *, INTEGER *); +void l4toc8(void *, void *, INTEGER *, INTEGER *); +void r8toc8(void *, void *, INTEGER *, INTEGER *); +void i8toc8(void *, void *, INTEGER *, INTEGER *); +void l8toc8(void *, void *, INTEGER *, INTEGER *); +#endif +void ibmi4toi4 (void *, void *, INTEGER *, INTEGER *); +void ibmi2toi4 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmr4tor4 (void *, void *, INTEGER *, INTEGER *); +void ibmi4toi8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmi2toi8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmr4tor8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmr8tor8 (void *, void *, INTEGER *, INTEGER *); +#ifdef _CRAYPVP +void ibmi4toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmi2toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmr4toc8 (void *, void *, INTEGER *, INTEGER *, INTEGER *); +void ibmr8toc8 (void *, void *, INTEGER *, INTEGER *); +#endif +#ifdef _CRAY +int CRY2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +int CRI2CRY(int *, int *, void *, int *, void *, int *, int *, int *); +int IEG2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +int CRI2IEG(int *, int *, void *, int *, void *, int *, int *, int *); +int IBM2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +#endif +#ifdef _CRAYPVP +int IBM2CRAY(int *, int *, void *, int *, void *); +#endif + +#endif diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/util.h cdat-4.0b3-pp/libcdms/include/cdunifpp/util.h --- cdat-4.0b3/libcdms/include/cdunifpp/util.h 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifpp/util.h 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,251 @@ +#if !defined(UTIL_HDR) +#define UTIL_HDR + +#include + +#if defined _CRAY +#if defined _CRAYMPP +#define SHORT32 +#define INT64 +#define FLOAT32 +#else +#define SHORT64 +#define INT64 +#define FLOAT64 +#endif +#else +#define SHORT16 +#define INT32 +#define FLOAT32 +#endif + +#define DOUBLE64 +#if defined _CRAY || defined __alpha || _MIPS_SZLONG == 64 || defined __64BIT__ +#define LONG64 +#else +#define LONG32 +#define LONGLONG64 +#endif + +#ifdef _IBM + +#ifdef SHORT16 +typedef unsigned short int uint16; +#endif +#ifdef INT32 +typedef unsigned int uint32; +#endif +#ifdef SHORT32 +typedef unsigned short int uint32; +#endif +#ifdef FLOAT32 +typedef float float32; +#endif +#ifdef DOUBLE64 +typedef double float64; +#endif +#ifdef LONG64 +typedef unsigned long int uint64; +#else +typedef unsigned long long int uint64; +#endif + +#else + +#ifdef SHORT16 +typedef short int int16; +typedef unsigned short int uint16; +#endif +#ifdef INT32 +typedef int int32; +typedef unsigned int uint32; +#endif +#ifdef SHORT32 +typedef short int int32; +typedef unsigned short int uint32; +#endif +#ifdef FLOAT32 +typedef float float32; +#endif +#ifdef DOUBLE64 +typedef double float64; +#endif +#ifdef LONG64 +typedef long int int64; +typedef unsigned long int uint64; +#else +typedef long long int int64; +typedef unsigned long long int uint64; +#endif + +#endif + +#define _IEEE4 0 +#define _IEEE8 1 +#define _CRAY8 2 + +#ifndef _FLT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _FLT_TYPE _CRAY8 +#else +#define _FLT_TYPE _IEEE8 +#endif +#else +#define _FLT_TYPE _IEEE4 +#endif +#endif + +#ifndef _INT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _INT_TYPE _CRAY8 +#else +#define _INT_TYPE _IEEE8 +#endif +#else +#define _INT_TYPE _IEEE4 +#endif +#endif + +#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8 +#define _FLT_SIZE 8 +#else +#define _FLT_SIZE 4 +#endif + +#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8 +#define _INT_SIZE 8 +#else +#define _INT_SIZE 4 +#endif + +#if _FLT_SIZE == 8 +#ifdef FLOAT32 +#define REAL double +#else +#define REAL float +#endif +#else +#define REAL float +#endif + +#if _INT_SIZE == 8 +#ifdef INT32 +#ifdef LONG64 +#define INTEGER long +#else +#define INTEGER long long +#endif +#else +#define INTEGER int +#endif +#else +#define INTEGER int +#endif + +#if defined __alpha || defined __i386 +#define LITTLE__ENDIAN +#else +#define BIG__ENDIAN +#endif + +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _CRAYNONIEEE +#endif +#endif + +#ifdef _CRAY +#ifndef _CRAYMPP +#define _CRAYPVP +#endif +#endif + +#if defined _CRAY +#define swapbytes SWAPBYTES +#define expand21 EXPAND21 +#ifndef _CRAYPVP +#define expand21_r4 EXPAND21_R4_ +#define expand21_r8 EXPAND21_R8_ +#endif +#elif defined __sun || defined __sgi || defined __osf__ || defined __uxpv__ || defined __linux || defined _SX +#define swapbytes swapbytes_ +#define expand21 expand21_ +#define expand21_r4 expand21_r4_ +#define expand21_r8 expand21_r8_ +#endif + +/* definition of a cosfile */ + +typedef struct { + char *fname; /* file name */ + FILE *fp; /* current file */ + unsigned long fwi; /* forward index of current bcw/rcw */ + unsigned long pri; /* backward index of current bcw/rcw */ +} COSFILE; + +/* Routines callable from C */ + +COSFILE *cos_open (char *, char *); +int cos_close (COSFILE *); +int cos_rewind (COSFILE *); +int cos_backspace (COSFILE *); +int cos_read (COSFILE *, void *, int, int *); +int c8_to_r4(void *, void *, int); +int c8_to_i4(void *, void *, int); +int c8_to_l4(void *, void *, int); +int c8_to_r8(void *, void *, int); +int c8_to_i8(void *, void *, int); +int c8_to_l8(void *, void *, int); +int r8_to_r4(void *, void *, int); +int i8_to_i4(void *, void *, int); +int r4_to_r8(void *, void *, int); +int i4_to_i8(void *, void *, int); +#ifdef _CRAY +int r4_to_c8(void *, void *, int); +int i4_to_c8(void *, void *, int); +int l4_to_c8(void *, void *, int); +int r8_to_c8(void *, void *, int); +int i8_to_c8(void *, void *, int); +int l8_to_c8(void *, void *, int); +#endif +int ibmi4_to_i4(void *, void *, int); +int ibmi2_to_i4(void *, void *, int, int); +int ibmr4_to_r4(void *, void *, int); +int ibmi4_to_i8(void *, void *, int, int); +int ibmi2_to_i8(void *, void *, int, int); +int ibmr4_to_r8(void *, void *, int, int); +int ibmr8_to_r8(void *, void *, int); +#ifdef _CRAYPVP +int ibmi4_to_c8(void *, void *, int, int); +int ibmi2_to_c8(void *, void *, int, int); +int ibmr4_to_c8(void *, void *, int, int); +int ibmr8_to_c8(void *, void *, int); +#endif +void swap_bytes(void *, INTEGER, INTEGER); + +/* Routines callable from Fortran and C */ + +void expand21(INTEGER *, void *, void *, INTEGER *); +#ifndef _CRAYPVP +void expand21_r4(INTEGER *, void *, void *, INTEGER *); +void expand21_r8(INTEGER *, void *, void *, INTEGER *); +#endif +#ifdef _CRAY +int CRY2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +int CRI2CRY(int *, int *, void *, int *, void *, int *, int *, int *); +int IEG2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +int CRI2IEG(int *, int *, void *, int *, void *, int *, int *, int *); +int IBM2CRI(int *, int *, void *, int *, void *, int *, int *, int *); +#endif +#ifdef _CRAYPVP +int IBM2CRAY(int *, int *, void *, int *, void *); +int CRAY2IBM(int *, int *, void *, int *, void *); +#endif +#ifdef _CRAYNONIEEE +int CRAY2IEG(int *, int *, void *, int *, void *); +int IEG2CRAY(int *, int *, void *, int *, void *); +#endif + +#endif diff -Naur cdat-4.0b3/libcdms/include/cdunifpp/vardef.h cdat-4.0b3-pp/libcdms/include/cdunifpp/vardef.h --- cdat-4.0b3/libcdms/include/cdunifpp/vardef.h 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/include/cdunifpp/vardef.h 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,67 @@ +#include "util.h" + +#define _IEEE4 0 +#define _IEEE8 1 +#define _CRAY8 2 + +#ifndef _FLT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _FLT_TYPE _CRAY8 +#else +#define _FLT_TYPE _IEEE8 +#endif +#else +#define _FLT_TYPE _IEEE4 +#endif +#endif + +#ifndef _INT_TYPE +#ifdef _CRAY +#ifndef _CRAYIEEE +#define _INT_TYPE _CRAY8 +#else +#define _INT_TYPE _IEEE8 +#endif +#else +#define _INT_TYPE _IEEE4 +#endif +#endif + +#if _FLT_TYPE == _CRAY8 || _FLT_TYPE == _IEEE8 +#define _FLT_SIZE 8 +#else +#define _FLT_SIZE 4 +#endif + +#if _INT_TYPE == _CRAY8 || _INT_TYPE == _IEEE8 +#define _INT_SIZE 8 +#else +#define _INT_SIZE 4 +#endif + +#if _FLT_SIZE == 8 +#define real8 +#ifdef FLOAT32 +#define REAL double +#else +#define REAL float +#endif +#else +#define REAL float +#endif + +#if _INT_SIZE == 8 +#define int8 +#ifdef INT32 +#ifdef LONG64 +#define INTEGER long +#else +#define INTEGER long long +#endif +#else +#define INTEGER int +#endif +#else +#define INTEGER int +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunif.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunif.c --- cdat-4.0b3/libcdms/src/cdunif/cdunif.c 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunif.c 2004-11-04 16:57:55.000000000 +0000 @@ -289,6 +289,38 @@ cuattname_stub, cuseterropts_gen, #endif +}, +{ + CuPP, +#ifdef HAVE_PP + cuopenread_pp, + cuclose_pp, + cuinquire_gen, + cudimid_gen, + cudiminq_gen, + cudimget_pp, + cuvarid_gen, + cuvarinq_gen, + cuvarget_pp, + cuattinq_gen, + cuattget_gen, + cuattname_gen, + cuseterropts_gen, +#else + cuopenread_stub_pp, + cuclose_stub, + cuinquire_stub, + cudimid_stub, + cudiminq_stub, + cudimget_stub, + cuvarid_stub, + cuvarinq_stub, + cuvarget_stub, + cuattinq_stub, + cuattget_stub, + cuattname_stub, + cuseterropts_gen, +#endif } }; diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifint.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifint.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifint.c 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifint.c 2004-11-04 16:57:55.000000000 +0000 @@ -431,7 +431,17 @@ fclose(fd); return CuPop; } - + +#ifdef HAVE_PP + /* Check for a PP file */ + strncpy(pathcopy, controlpath, CU_MAX_PATH); + pathcopy[CU_MAX_PATH-1]='\0'; + custrtrim(pathcopy); + if (pp_is_ppum_file(pathcopy,fd)) { + fclose(fd); + return CuPP; + } +#endif /* No CDMS format found */ error: if(feof(fd)) diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_attribute.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_attribute.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_attribute.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_attribute.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,126 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* + * Attributes: + * + * functions which create attributes during processing; + * these will later be copied to var->atts when the total number is known + * + * the cu_att structure suits our needs just fine, so no need to define + * a "pp_att" structure in the way we've done for vars and dims + */ + +CuAtt *pp_att_new(const char *name, CuType datatype, long len, const void *vals, PPlist *heaplist) +{ + int size; + CuAtt *att; + + if(( att=pp_malloc(sizeof(CuAtt),heaplist) )==NULL) goto err; + + strncpy(att->name, name, CU_MAX_NAME); + att->name[CU_MAX_NAME]='\0'; + + att->datatype = datatype; + att->len = len; + + size = cutypelen(datatype); + + if (len > 0) { + if(( att->val = pp_malloc(len*size,heaplist) )==NULL) goto err; + if (vals==NULL) goto err; + memcpy(att->val, vals, len*size); + + } else { + att->val=NULL; + } + + return att; + + err: + pp_error("pp_att_new"); + return NULL; +} + +int pp_add_att(PPlist *attlist, const char *name, CuType datatype, long len, const void *vals, PPlist *heaplist) +{ + CuAtt *att; + if(( att=pp_att_new(name,datatype,len,vals,heaplist) )==NULL) goto err; + if(( pp_list_add(attlist,att,heaplist) )!=0) goto err; + return 0; + err: + pp_error("pp_add_att"); + return -1; +} + +/*------------------------------------------------- + * utility wrappers in case of strin attributes + */ + +CuAtt *pp_string_att_new(const char *name, const char *val, PPlist *heaplist) +{ + if (val==NULL) goto err; + return pp_att_new(name, CuChar, strlen(val), val, heaplist); + err: + pp_error("pp_string_att_new"); + return NULL; +} + +int pp_add_string_att(PPlist *attlist, const char *name, const char *val, PPlist *heaplist) +{ + if (val==NULL) goto err; + return pp_add_att(attlist, name, CuChar, strlen(val), val, heaplist); + err: + pp_error("pp_add_string_att"); + return -1; +} + +/*-------------------------------------------------*/ + +/* copy atts from temp storage into proper location allocated with CuCreateAtts + * + * + * (NB the heaplist is contained indirectly in CuFile structure, but it's just as easy -- + * and in some ways more transparent -- for the calling routine to supply it) + */ +int pp_copy_and_free_atts(CuFile *file, CuVar *var, PPlist *attlist, PPlist *heaplist) +{ + int natts,i; + CuAtt *atts, *savedatt; + PPlistpos handle; + + natts=pp_list_size(attlist); + + /* set natts - this ought to be done by CuCreateAtts ;-) */ + if (var==NULL) + file->ngatts = natts; + else + var->natts=natts; + + /* copy atts from attlist to standard location + * + * (NB must not call CuCreateAtts with natts=0, else CuDeleteAtts later frees uninitialised pointer ) + */ + if (natts>0) { + if(( atts=CuCreateAtts(file,var,natts) )==NULL) goto err; + + pp_list_startwalk(attlist, &handle); + for (i=0; ivalues=pp_malloc(n*size,heaplist) )==NULL) goto err; + + data->type = type; + data->n = n; + + return data; + + err: + pp_error("pp_data_new"); + return NULL; +} + +PPdata *pp_regaxis_to_values(const PPregaxis *a, PPlist *heaplist) +{ + PPdata *data; + int i; + Freal val; + + if(( data=pp_data_new(realtype,a->n,heaplist) )==NULL) goto err; + + val = a->start; + for (i=0; i < a->n; i++) { + ((Freal*)(data->values))[i]=val; + val += a->interval; + } + return data; + + err: + pp_error("pp_regaxis_to_values"); + return NULL; +} + +/*-----------------------------------------------------------------------------*/ + +PPdata *pp_zaxis_to_values(const PPzaxis *zaxis, PPlevvaltype vtype, PPlist *heaplist) +{ + PPdata *data; + int i; + int n; + Freal val; + PPlevel *lev; + PPlist *list; + PPlistpos handle; + int is_hybrid; + + is_hybrid = pp_is_hybrid_levels(zaxis->type); + + list=zaxis->values; + n=pp_list_size(list); + + if(( data=pp_data_new(realtype,n,heaplist) )==NULL) goto err; + + pp_list_startwalk(list,&handle); + for (i=0; i < n; i++) { + lev=pp_list_walk(list,0,&handle); + + switch (vtype){ + case lev_type: + if (is_hybrid) + val = lev->hybrid_a / reference_pressure + lev->level; + else + val=lev->level; + break; + case hybrid_a_type: + if (is_hybrid) + val=lev->hybrid_a; + else + return NULL; + break; + case hybrid_b_type: + if (is_hybrid) + val=lev->level; + else + return NULL; + break; + + default: val=0.; pp_switch_bug(); + } + + ((Freal*)(data->values))[i]=val; + } + return data; + + err: + pp_error("pp_zaxis_to_values"); + return NULL; +} + + +int pp_is_hybrid_levels(Fint LBVC) { + return (LBVC==9); +} + + +/*-----------------------------------------------------------------------------*/ + +PPdata *pp_taxis_to_values(const PPtaxis *taxis, PPlist *heaplist) +{ + PPdata *data; + PPlist *list; + PPtime *t; + int mean; + int i; + int n; + Freal val,val2; + PPlistpos handle; + + list=taxis->values; + n=pp_list_size(list); + + if(( data=pp_data_new(realtype,n,heaplist) )==NULL) goto err; + + mean = pp_is_time_mean(taxis->type); + + pp_list_startwalk(list,&handle); + for (i=0; i < n; i++) { + t=pp_list_walk(list,0,&handle); + + val=pp_time_diff(t->type, + &t->time1, + &taxis->time_orig); + + if (mean) { + + /* FIXME(?): with difference field (time 2 - time 1), maybe want to do likewise and + * use average time also? + */ + + /* FIXME(?): in the event of a seasonal composite, + * (I think this is LBTIM==3 but doc not to hand at time of writing this), + * time1 is meaning start date and first year, time2 is meaning start date and end year; + * in event of even number of years, the date could end up 6 months out from the time + * of year (e.g. Jan mean over ten years 2000-2009 becomes average of 1 Jan 2000 and + * 1 Feb 2009, which is mid-July 2004 -- maybe more helpful to report e.g. mid-Jan 2004?) + */ + + val2=pp_time_diff(t->type, + &t->time2, + &taxis->time_orig); + + val = (val + val2) / 2; + } + + ((Freal*)(data->values))[i]=val; + } + return data; + + err: + pp_error("pp_taxis_to_values"); + return NULL; +} + +PPdata *pp_taxis_to_boundary_values(const PPtaxis *taxis, PPlist *heaplist) +{ + PPdata *data; + PPlist *list; + PPtime *t; + int i; + int n; + Freal val,val2; + PPlistpos handle; + + /* only valid for time mean */ + if (!pp_is_time_mean(taxis->type)) goto err; + + list=taxis->values; + n=pp_list_size(list); + + if(( data=pp_data_new(realtype,n*2,heaplist) )==NULL) goto err; + + pp_list_startwalk(list,&handle); + for (i=0; i < n; i++) { + t=pp_list_walk(list,0,&handle); + + val=pp_time_diff(t->type, + &t->time1, + &taxis->time_orig); + + val2=pp_time_diff(t->type, + &t->time2, + &taxis->time_orig); + + ((Freal*)(data->values))[ 2*i ]=val; + + ((Freal*)(data->values))[ 2*i+1 ]=val2; + } + return data; + + err: + pp_error("pp_taxis_to_boundary_values"); + return NULL; +} + + +/*-----------------------------------------------------------------------------*/ + +int pp_is_time_mean(Fint LBTIM) { + int ib; + ib = (LBTIM / 10) % 10; + return (ib == 2) || (ib == 3); +} + + +/* float_time returns time in days since origin time */ + +Freal pp_time_diff(Fint LBTIM, const PPdate *date, const PPdate *orig_date) +{ + long long secs; + + const Freal sec_to_day = 1. / 86400.; + + switch(pp_calendar_type(LBTIM)) { + case gregorian: + return (pp_gregorian_to_secs(date) - pp_gregorian_to_secs(orig_date)) * sec_to_day; + break; /* notreached */ + case cal360day: + secs = + date->second - orig_date->second + + 60 * (date->minute - orig_date->minute + + 60 * (date->hour - orig_date->hour + + 24 * (date->day - orig_date->day + + 30 * (date->month - orig_date->month + + 12 * (long long) (date->year - orig_date->year) )))); + + return secs * sec_to_day; + break; /* notreached */ + case model: + secs = + date->second - orig_date->second + + 60 * (date->minute - orig_date->minute + + 60 * (date->hour - orig_date->hour + + 24 * (long long) (date->day - orig_date->day))); + + return secs * sec_to_day; + break; + } +} + +PPcalendartype pp_calendar_type(Fint type){ + + switch(type%10) { + + case 0: + /* fallthrough */ + case 3: + return model; + break; /* notreached */ + case 1: + return gregorian; + break; /* notreached */ + case 2: + return cal360day; + break; /* notreached */ + default: pp_switch_bug(); + + } +} + + +long long pp_gregorian_to_secs(const PPdate *date) +{ + /* FIXME: uses builtin time functions; these have a range 1902 - 2038 (approx). + * Replace with julian day routine (suitably scaled) + * + * Can be with respect to any arbitary origin, because return values from this are + * differenced. + */ + + time_t t; + struct tm tm; + + tm.tm_year = date->year - 1900; + tm.tm_mon = date->month - 1; + tm.tm_mday = date->day ; + tm.tm_hour = date->hour ; + tm.tm_min = date->minute ; + tm.tm_sec = date->second ; + t=mktime(&tm); + + return (long long) t; +} + +char *pp_t_units(const PPtaxis *taxis, PPlist *heaplist) +{ + char *units; + + const int string_length = 30; + const char *fmt = "days since %04d-%02d-%02d %02d:%02d:%02d"; + + const PPdate *orig; + + orig = &taxis->time_orig; + + if(( units=pp_malloc(string_length+1,heaplist) )==NULL) goto err; + + snprintf(units,string_length,fmt, + orig->year, orig->month, orig->day, + orig->hour, orig->minute, orig->second); + + return units; + + + err: + pp_error("pp_t_units"); + return NULL; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,135 @@ +/* -*-Mode: C;-*- + * Module: cdunif PP driver functions + * + * Copyright: 2004, CCLRC + * + * Author: British Atmosphere Data Centre + * badc@badc.rl.ac.uk + * + * Revision History: + */ + +#ifdef HAVE_PP + +#include "cdunifpp.h" + +int cuopenread_pp(const char* controlpath, const char* datapath){ + CuFile *file; + PPfile *ppfile; + + pp_errorhandle_init(); + + if (pp_check_sizes()!=0) goto err_no_close; + + if(( file = pp_create_file(controlpath) )==NULL) goto err_no_close; + ppfile = file->internp; + + /* open file */ + if(( ppfile->fh=fopen(controlpath,"r") )==NULL) goto err_no_close; + + /* get file type */ + if(( pp_determine_file_type(ppfile,controlpath,1) )!=0) goto err; + + /* read all the PP headers */ + if( pp_read_all_headers(file) !=0) goto err; + + /* do the processing to sort out vars and dims */ + if( pp_process(file) !=0) goto err; + + return file->id; + + err: + cuclose_pp(file); + err_no_close: + return -1; +} + +/*---------------------------------------------------------*/ + +int cuclose_pp(CuFile* file){ + PPfile *ppfile; + + pp_errorhandle_init(); + + if (file != NULL){ + ppfile=file->internp; + if (ppfile != NULL && ppfile->fh != NULL) { + fclose(ppfile->fh); + } + pp_delete_file(file); + } + + return CU_SUCCESS; +} + +/*---------------------------------------------------------*/ + +int cuvarget_pp(CuFile* file, int varid, const long start[], const long count[], void* values){ + CuVar *var; + PPvar *ppvar; + + pp_errorhandle_init(); + + if (file == NULL || values == NULL) return CU_EINVAL; + if (file->vars == NULL) return CU_ENOVARS; + if (varid < 0 || varid >= file->nvars) return CU_ENOTVAR; + var=&file->vars[varid]; + ppvar=var->internp; + if (ppvar == NULL) return CU_EINTERN; + + if (ppvar->data != NULL) { + /* coord var */ + return pp_data_copy(file,var,start,count,values); + } + else { + /* field var */ + return pp_data_read(file,var,start,count,values); + } +} + +/*---------------------------------------------------------*/ + +int cudimget_pp(CuFile* file, int dimid, void* values){ + CuDim *dim; + CuVar *var; + int length,i; + long start[1]; + long count[1]; + + pp_errorhandle_init(); + + if (file == NULL || values == NULL) return CU_EINVAL; + if (dimid < 0 || dimid >= file->ndims) return CU_EBADDIM; + if (file->dims == NULL) return CU_SERROR; + + dim=&file->dims[dimid]; + + var=dim->coord; + length=dim->len; + + if (var==NULL) { + + /* copy default dim according to type */ + if (dim->datatype==inttype) + for (i=0; idatatype==realtype) + for (i=0; iid, start, count, values); + } + + return CU_SUCCESS; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_check.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_check.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_check.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_check.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,23 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* check compiled-in type sizes */ + +int pp_check_sizes() +{ + if (sizeof(Freal4) != 4 || + sizeof(Freal8) != 8 || + sizeof(Fint4) != 4 || + sizeof(Fint8) != 8 || + sizeof(Fint) != sizeof (Freal) || + cutypelen(inttype) != sizeof(Fint) || + cutypelen(realtype) != sizeof(Freal)) { + + pp_error("pp_check_sizes"); + return -1; + } + + return 0; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_compare.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_compare.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_compare.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_compare.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,217 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* + * COMPARISON FUNCTIONS. + * + * NOTE: functions which take arguments of type void* are designed to be used with generic routines: + * pp_compare_records is envisaged for use with qsort; + * several other functions are envisaged for use with pp_compare_lists (below). + * + * In these cases if supplying pointers directly to the relevant structures, need to generate + * an extra level of pointer with "&" syntax. + * + * But not all functions below are like that. Don't assume functions can be used analogously + * without first examining the argument lists. + */ + +/* The code profiler suggests that pp_compare_ints and pp_compare_reals are candidates for + * inlining; however, unfortunately this sometimes gets compiled with c89 which doesn't support + * inline functions. Use a #define for pp_compare_ints. pp_compare_reals, which is more + * awkward to #define, is just going to have to stay as it is for now (it's called less often). + */ + +#define pp_compare_ints(a,b) ((a)<(b)?(-1):(a)>(b)?1:0) + +/* + * static int pp_compare_ints(Fint a, Fint b) + * { + * if (ab) return 1; + * return 0; + * } + */ + +static int pp_compare_reals(Freal a, Freal b) +{ + Freal delta; + + /* first test for special case (unnecessary, but code profiler shows + * slightly more efficient) + */ + if (a==b) return 0; + + delta = fabs(b * tolerance); + if (ab+delta) return 1; + + return 0; +} + +/* routine to compare two PP records. + * returns: + * -2 or 2 headers are from different variable + * -1 or 1 headers are from same variable + * 0 difference not found in elements inspected + */ + +int pp_compare_records(const void *p1, const void *p2) +{ + const PPrec *a = *(PPrec **)p1; + const PPrec *b = *(PPrec **)p2; + +#define COMPARE_INTS(tag,ret) {int cmp=pp_compare_ints(a->hdr.tag,b->hdr.tag); if (cmp!=0) return cmp*ret;} +#define COMPARE_REALS(tag,ret) {int cmp=pp_compare_reals(a->hdr.tag,b->hdr.tag); if (cmp!=0) return cmp*ret;} + + /* elements to distinguish variables */ + + COMPARE_INTS(LBUSER4,2); + COMPARE_INTS(LBUSER7,2); + COMPARE_INTS(LBCODE,2); + COMPARE_INTS(LBVC,2); + COMPARE_INTS(LBTIM,2); + COMPARE_INTS(LBPROC,2); + COMPARE_REALS(BPLAT,2); + COMPARE_REALS(BPLON,2); + COMPARE_INTS(LBHEM,2); + COMPARE_INTS(LBROW,2); + COMPARE_INTS(LBNPT,2); + + COMPARE_REALS(BGOR,2); + COMPARE_REALS(BZY,2); + COMPARE_REALS(BDY,2); + COMPARE_REALS(BZX,2); + COMPARE_REALS(BDX,2); + + /* elements to sort records within a variable + * (sort on time, then sort on level) + */ + + COMPARE_INTS(LBFT,1); + + COMPARE_INTS(LBYR,1); + COMPARE_INTS(LBMON,1); + COMPARE_INTS(LBDAT,1); + COMPARE_INTS(LBDAY,1); + COMPARE_INTS(LBHR,1); + COMPARE_INTS(LBMIN,1); + + COMPARE_INTS(LBYRD,1); + COMPARE_INTS(LBMOND,1); + COMPARE_INTS(LBDATD,1); + COMPARE_INTS(LBDAYD,1); + COMPARE_INTS(LBHRD,1); + COMPARE_INTS(LBMIND,1); + + COMPARE_INTS(LBLEV,1); + COMPARE_REALS(BLEV,1); + COMPARE_REALS(BHLEV,1); + + return 0; +} + +int pp_records_from_different_vars(const PPrec *a, const PPrec *b) +{ + int cmp; + cmp = pp_compare_records(&a,&b); + if (cmp == -2) return 1; + if (cmp == 2) return 1; + return 0; +} + +/*---------------------------------------------------------*/ + +int pp_compare_regaxes(const void *p1, const void *p2) { + const PPregaxis *a = *(PPregaxis **)p1; + const PPregaxis *b = *(PPregaxis **)p2; + int cmp; + if ((cmp=pp_compare_ints(a->n,b->n))!=0) return cmp; + if ((cmp=pp_compare_reals(a->start,b->start))!=0) return cmp; + if ((cmp=pp_compare_reals(a->interval,b->interval))!=0) return cmp; + return 0; +} + +int pp_compare_lists(const PPlist *l1, const PPlist *l2, int (*compfunc)(const void*, const void*)) { + int i,n,cmp; + const void *item1, *item2; + PPlistpos handle1, handle2; + + /* differ if number of items differs */ + n=pp_list_size(l1); + if ((cmp=pp_compare_ints(n,pp_list_size(l2)))!=0) return cmp; + + /* differ if any individual item differs */ + pp_list_startwalk(l1,&handle1); + pp_list_startwalk(l2,&handle2); + for (i=0; itype ,b->type ))!=0) return cmp; + if ((cmp=pp_compare_reals(a->level ,b->level ))!=0) return cmp; + if ((cmp=pp_compare_reals(a->ref_level ,b->ref_level ))!=0) return cmp; + if ((cmp=pp_compare_reals(a->hybrid_a ,b->hybrid_a ))!=0) return cmp; + if ((cmp=pp_compare_reals(a->hybrid_ref_a,b->hybrid_ref_a))!=0) return cmp; + return 0; +} + +int pp_compare_zaxes(const void *p1, const void *p2) { + const PPzaxis *a = *(PPzaxis **)p1; + const PPzaxis *b = *(PPzaxis **)p2; + int cmp; + /* differ if level type differs */ + /* if ((cmp=pp_compare_ints(a->type,b->type))!=0) return cmp; */ + /* differ if level lists differ */ + if ((cmp=pp_compare_lists(a->values,b->values,pp_compare_levels))!=0) return cmp; + return 0; +} + +int pp_compare_times(const void *p1, const void *p2) { + const PPtime *a = *(PPtime **)p1; + const PPtime *b = *(PPtime **)p2; + int cmp; + + /* LBTYP: ignore 100s digit = sampling frequency, as we don't use it for anything */ + if ((cmp=pp_compare_ints(a->type%100,b->type%100))!=0) return cmp; + + if ((cmp=pp_compare_dates(&a->time1,&b->time1))!=0) return cmp; + if ((cmp=pp_compare_dates(&a->time2,&b->time2))!=0) return cmp; + return 0; +} + +int pp_compare_dates(const PPdate *a, const PPdate *b) { + int cmp; + if ((cmp=pp_compare_ints(a->year ,b->year ))!=0) return cmp; + if ((cmp=pp_compare_ints(a->month ,b->month ))!=0) return cmp; + if ((cmp=pp_compare_ints(a->day ,b->day ))!=0) return cmp; + if ((cmp=pp_compare_ints(a->hour ,b->hour ))!=0) return cmp; + if ((cmp=pp_compare_ints(a->minute,b->minute))!=0) return cmp; + if ((cmp=pp_compare_ints(a->second,b->second))!=0) return cmp; + return 0; +} + +int pp_compare_taxes(const void *p1, const void *p2) { + const PPtaxis *a = *(PPtaxis **)p1; + const PPtaxis *b = *(PPtaxis **)p2; + int cmp; + /* differ if time type differs */ + /* if ((cmp=pp_compare_ints(a->type%100,b->type%100))!=0) return cmp; */ + + /* differ if time origin differs */ + if ((cmp=pp_compare_dates(&a->time_orig,&b->time_orig))!=0) return cmp; + + /* differ if time lists differ */ + if ((cmp=pp_compare_lists(a->values,b->values,pp_compare_times))!=0) return cmp; + return 0; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_data.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_data.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_data.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_data.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,177 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* pp_data_copy and pp_data_read are the back end to cuvarget + * + * pp_data_copy is for copying data already stored from memory (coordinate vars) + * pp_data_read is for reading data from a file (field vars) + */ + +/* pp_data_copy handles the general n-dimensional case for dealing with hyperslabs (coordinate + * variables are not guaranteed to be 1d, because they may have "nv" dimension from cell_methods -- + * okay, maybe no more than 2d, but n-dimensional problem is not particularly more difficult) + * + * pp_data_read currently handles just the 4d case; if n-dimensional was ever required, then + * still need to treat the fastest varying two dimensions (longitude, latitude) as a + * special case (a pp record), but instead of hard-code looping over height and time could + * treat the higher dimensions using the N-dim code. + */ + + +int pp_data_copy(const CuFile *file, const CuVar *var, const long start[], const long count[], void *values) { + + const PPfile *ppfile; + PPlist *heaplist; + const PPvar *ppvar; + const PPdata *data; + const void *src; + int ndim,idim; + int *indices, *size; + int srcoffset, destoffset; + int carryout; + int is_int, is_real; + + ppfile = file->internp; + ppvar = var->internp; + heaplist = ppfile->heaplist; + data = ppvar->data; + + if(( src=data->values )==NULL) goto err; + + ndim = var->ndims; + + if(( size=pp_malloc(ndim*sizeof(int),heaplist) )==NULL) goto err; + if(( indices=pp_malloc(ndim*sizeof(int),heaplist) )==NULL) goto err; + + for (idim=0; idimdims[var->dims[idim]].len; + indices[idim]=0; + + if (start[idim]<0 || count[idim]<0 || start[idim]+count[idim]>size[idim]) + return CU_EINVALCOORDS; + + } + carryout=0; + + is_int=(data->type != inttype); + is_real=(data->type != realtype); + if (!is_int && !is_real) goto err; + + while (!carryout) { + /* indices loop from 0 to count-1 in each dimension: keep looping until + * carry-out from most slowly varying dimension + */ + + /* locate hyperslab element within source and destination 1d arrays */ + srcoffset=0; + destoffset=0; + for (idim=ndim-1 ; idim>=0; idim--) { + srcoffset *= size[idim]; + destoffset *= count[idim]; + + srcoffset += indices[idim]+start[idim]; + destoffset += indices[idim]; + } + + /* copy data */ + if (is_int) + *((Fint *)values + destoffset) = *((Fint *)src + srcoffset); + else if (is_real) + *((Freal *)values + destoffset) = *((Freal *)src + srcoffset); + + /* increment indices */ + for (idim=0; idim < ndim ; idim++) { + indices[idim]++; + if (indices[idim]==count[idim]) + indices[idim]=0; /* carry, so keep looping */ + else + break; /* no internal carry */ + } + if (idim==ndim) + carryout=1; + } + + pp_free(size,heaplist); + pp_free(indices,heaplist); + return CU_SUCCESS; + + err: + pp_error("pp_data_copy"); + return CU_SERROR; +} + + +int pp_data_read(const CuFile *file, const CuVar *var, const long start[], const long count[], void *values) +{ + const PPfile *ppfile; + PPlist *heaplist; + const PPvar *ppvar; + int startrec, endrec, nrec, recno; + int nx,ny,nz,nt,cx,cy,cz,ct,sx,sy,sz,st,iy,iz,it; + const void *src; + void *data, *ptr, *dest; + + /* shouldn't have got this far unless variable is 4d */ + if (var->ndims != 4) goto err; + + ppfile = file->internp; + ppvar = var->internp; + heaplist = ppfile->heaplist; + + startrec = ppvar->startrec; + endrec = ppvar->endrec; + nrec = endrec - startrec + 1; + + nx = file->dims[var->dims[3]].len; + ny = file->dims[var->dims[2]].len; + nz = file->dims[var->dims[1]].len; + nt = file->dims[var->dims[0]].len; + + cx = count[3]; + cy = count[2]; + cz = count[1]; + ct = count[0]; + + sx = start[3]; + sy = start[2]; + sz = start[1]; + st = start[0]; + + if (sx<0 || sy<0 || sz<0 || st<0 || cx<0 || cy<0 || cz<0 || ct<0 || sx+cx>nx || sy+cy>ny || sz+cz>nz || st+ct>nt) + return CU_EINVALCOORDS; + + if (nrec != nz * nt) { + CuError(CU_EINVALCOORDS,"refusing to read variable which has missing combinations of z,t"); + return CU_EINVALCOORDS; + } + + /* we can now assume that the records loop over correct times and levels + * (loop over time is the more slowly varying dimension because that's + * how we sorted them) + */ + + for (it=0; itrecs[recno],ppfile,heaplist) )==NULL) goto err; + + for (iy=0; iyLBYR); +#endif +#ifdef PP_STORE_LBMON + printf("LBMON=%d\n",hdr->LBMON); +#endif +#ifdef PP_STORE_LBDAT + printf("LBDAT=%d\n",hdr->LBDAT); +#endif +#ifdef PP_STORE_LBHR + printf("LBHR=%d\n",hdr->LBHR); +#endif +#ifdef PP_STORE_LBMIN + printf("LBMIN=%d\n",hdr->LBMIN); +#endif +#ifdef PP_STORE_LBDAY + printf("LBDAY=%d\n",hdr->LBDAY); +#endif +#ifdef PP_STORE_LBYRD + printf("LBYRD=%d\n",hdr->LBYRD); +#endif +#ifdef PP_STORE_LBMOND + printf("LBMOND=%d\n",hdr->LBMOND); +#endif +#ifdef PP_STORE_LBDATD + printf("LBDATD=%d\n",hdr->LBDATD); +#endif +#ifdef PP_STORE_LBHRD + printf("LBHRD=%d\n",hdr->LBHRD); +#endif +#ifdef PP_STORE_LBMIND + printf("LBMIND=%d\n",hdr->LBMIND); +#endif +#ifdef PP_STORE_LBDAYD + printf("LBDAYD=%d\n",hdr->LBDAYD); +#endif +#ifdef PP_STORE_LBTIM + printf("LBTIM=%d\n",hdr->LBTIM); +#endif +#ifdef PP_STORE_LBFT + printf("LBFT=%d\n", hdr->LBFT); +#endif +#ifdef PP_STORE_LBLREC + printf("LBLREC=%d\n", hdr->LBLREC); +#endif +#ifdef PP_STORE_LBCODE + printf("LBCODE=%d\n", hdr->LBCODE); +#endif +#ifdef PP_STORE_LBHEM + printf("LBHEM=%d\n", hdr->LBHEM); +#endif +#ifdef PP_STORE_LBROW + printf("LBROW=%d\n", hdr->LBROW); +#endif +#ifdef PP_STORE_LBNPT + printf("LBNPT=%d\n", hdr->LBNPT); +#endif +#ifdef PP_STORE_LBEXT + printf("LBEXT=%d\n", hdr->LBEXT); +#endif +#ifdef PP_STORE_LBPACK + printf("LBPACK=%d\n", hdr->LBPACK); +#endif +#ifdef PP_STORE_LBREL + printf("LBREL=%d\n", hdr->LBREL); +#endif +#ifdef PP_STORE_LBFC + printf("LBFC=%d\n", hdr->LBFC); +#endif +#ifdef PP_STORE_LBCFC + printf("LBCFC=%d\n", hdr->LBCFC); +#endif +#ifdef PP_STORE_LBPROC + printf("LBPROC=%d\n", hdr->LBPROC); +#endif +#ifdef PP_STORE_LBVC + printf("LBVC=%d\n", hdr->LBVC); +#endif +#ifdef PP_STORE_LBRVC + printf("LBRVC=%d\n", hdr->LBRVC); +#endif +#ifdef PP_STORE_LBEXP + printf("LBEXP=%d\n", hdr->LBEXP); +#endif +#ifdef PP_STORE_LBBEGIN + printf("LBBEGIN=%d\n", hdr->LBBEGIN); +#endif +#ifdef PP_STORE_LBNREC + printf("LBNREC=%d\n", hdr->LBNREC); +#endif +#ifdef PP_STORE_LBPROJ + printf("LBPROJ=%d\n", hdr->LBPROJ); +#endif +#ifdef PP_STORE_LBTYP + printf("LBTYP=%d\n", hdr->LBTYP); +#endif +#ifdef PP_STORE_LBLEV + printf("LBLEV=%d\n", hdr->LBLEV); +#endif +#ifdef PP_STORE_LBRSVD1 + printf("LBRSVD1=%d\n", hdr->LBRSVD1); +#endif +#ifdef PP_STORE_LBRSVD2 + printf("LBRSVD2=%d\n", hdr->LBRSVD2); +#endif +#ifdef PP_STORE_LBRSVD3 + printf("LBRSVD3=%d\n", hdr->LBRSVD3); +#endif +#ifdef PP_STORE_LBRSVD4 + printf("LBRSVD4=%d\n", hdr->LBRSVD4); +#endif +#ifdef PP_STORE_LBSRCE + printf("LBSRCE=%d\n", hdr->LBSRCE); +#endif +#ifdef PP_STORE_LBUSER1 + printf("LBUSER1=%d\n", hdr->LBUSER1); +#endif +#ifdef PP_STORE_LBUSER2 + printf("LBUSER2=%d\n", hdr->LBUSER2); +#endif +#ifdef PP_STORE_LBUSER3 + printf("LBUSER3=%d\n", hdr->LBUSER3); +#endif +#ifdef PP_STORE_LBUSER4 + printf("LBUSER4=%d\n", hdr->LBUSER4); +#endif +#ifdef PP_STORE_LBUSER5 + printf("LBUSER5=%d\n", hdr->LBUSER5); +#endif +#ifdef PP_STORE_LBUSER6 + printf("LBUSER6=%d\n", hdr->LBUSER6); +#endif +#ifdef PP_STORE_LBUSER7 + printf("LBUSER7=%d\n", hdr->LBUSER7); +#endif + +#ifdef PP_STORE_BRSVD1 + printf("BRSVD1=%e\n", hdr->BRSVD1); +#endif +#ifdef PP_STORE_BRSVD2 + printf("BRSVD2=%e\n", hdr->BRSVD2); +#endif +#ifdef PP_STORE_BRSVD3 + printf("BRSVD3=%e\n", hdr->BRSVD3); +#endif +#ifdef PP_STORE_BRSVD4 + printf("BRSVD4=%e\n", hdr->BRSVD4); +#endif +#ifdef PP_STORE_BDATUM + printf("BDATUM=%e\n", hdr->BDATUM); +#endif +#ifdef PP_STORE_BACC + printf("BACC=%e\n", hdr->BACC); +#endif +#ifdef PP_STORE_BLEV + printf("BLEV=%e\n", hdr->BLEV); +#endif +#ifdef PP_STORE_BRLEV + printf("BRLEV=%e\n", hdr->BRLEV); +#endif +#ifdef PP_STORE_BHLEV + printf("BHLEV=%e\n", hdr->BHLEV); +#endif +#ifdef PP_STORE_BHRLEV + printf("BHRLEV=%e\n", hdr->BHRLEV); +#endif +#ifdef PP_STORE_BPLAT + printf("BPLAT=%e\n", hdr->BPLAT); +#endif +#ifdef PP_STORE_BPLON + printf("BPLON=%e\n", hdr->BPLON); +#endif +#ifdef PP_STORE_BGOR + printf("BGOR=%e\n", hdr->BGOR); +#endif +#ifdef PP_STORE_BZY + printf("BZY=%e\n", hdr->BZY); +#endif +#ifdef PP_STORE_BDY + printf("BDY=%e\n", hdr->BDY); +#endif +#ifdef PP_STORE_BZX + printf("BZX=%e\n", hdr->BZX); +#endif +#ifdef PP_STORE_BDX + printf("BDX=%e\n", hdr->BDX); +#endif +#ifdef PP_STORE_BMDI + printf("BMDI=%e\n", hdr->BMDI); +#endif +#ifdef PP_STORE_BMKS + printf("BMKS=%e\n", hdr->BMKS); +#endif +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_error.c 2004-11-04 16:58:30.000000000 +0000 @@ -0,0 +1,36 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* + * for use as default action in switch statements which shouldn't need a default + */ + +static int verbose; + +static const int debug=0; + +int pp_switch_bug() +{ + pp_error("no match in switch statement; may indicate coding bug in CDUNIFPP or unexpected header value"); + return 0; +} + +int pp_error(const char *routine) +{ + if (verbose || debug) + CuError(CU_EINTERN,"CDUNIF_PP: error condition detected in routine %s",routine); + verbose=0; + return 0; +} + +int pp_errorhandle_init() +{ + /* init sets verbose -- called at start of each of the interface routines -- + * then first call to pp_error will cause a diagnostic to be printed, + * but then unsets verbose to avoid series of knock-on messages + */ + verbose=1; + return 0; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_filetype.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_filetype.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_filetype.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_filetype.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,218 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* takes input filename and PPfile structure containing file handle + * + * fills in the "type", "swap" and "wordsize" elements of the structure, + * and then returns 0 on success, or -1 if file doesn't appear to be a + * valid PP or UM ancillary file + */ + +/* tests the contents, but first see if the filename has one of the specified + * extensions, and if so then this forces the file type + */ + +int pp_determine_file_type(PPfile *ppfile, const char *filename, int verbose) +{ + int status; + + status=pp_determine_file_type_by_name(ppfile,filename); + + if (status!=0) + status=pp_determine_file_type_by_contents(ppfile); + + if (verbose && status==0) + printf("%s is a %s%d-bit %s-file\n", + filename, + ppfile->swap ? "byte-swapped ":"", + ppfile->wordsize * 8, + ppfile->type == um_type ? "UM" : "PP"); + + return status; +} + +int pp_determine_file_type_by_contents(PPfile *ppfile) +{ + FILE *fh; + Fint4 data4[4],data4s[4]; + Fint8 data8[2],data8s[2]; + + if( ppfile==NULL || (fh=ppfile->fh)==NULL) return -1; + + /* read and store first two integers according to suppositions + * of 4- or 8- byte, and native or swapped byte ordering + */ + + fseek(fh,0,SEEK_SET); + if(fread(data8,8,2,fh) != 2) return -1; + + memcpy(data4,data8,16); + + memcpy(data4s,data8,16); + pp_swapbytes(data4s,4,4); + + memcpy(data8s,data8,16); + pp_swapbytes(data8s,8,2); + + /* UM ancillary files: test second word (the submodel ID - is this 1, 2 or 4?) + * (this should not give false +ve with PP file -- though takes thinking through + * the various combinations of 32 / 64 bit to convince yourself of this) + * + * If this test fails, test for PP file. Here test first word, which should be + * record length (put there by fortran). Because it's the first word, 64-bit + * little-endian could appear to be 32-bit little-endian, so a file is not 32-bit + * PP if both the second and fourth words are zero. + */ + + if (pp_valid_um_word2(data4[1])) { + ppfile->type = um_type; + ppfile->swap=0; + ppfile->wordsize=4; + } else if (pp_valid_um_word2(data8[1])) { + ppfile->type = um_type; + ppfile->swap=0; + ppfile->wordsize=8; + } else if (pp_valid_um_word2(data4s[1])) { + ppfile->type = um_type; + ppfile->swap=1; + ppfile->wordsize=4; + } else if (pp_valid_um_word2(data8s[1])) { + ppfile->type = um_type; + ppfile->swap=1; + ppfile->wordsize=8; + } else if (pp_valid_pp_word1(data4[0],4) && !(data4[1]==0 && data4[3]==0)) { + ppfile->type = pp_type; + ppfile->swap=0; + ppfile->wordsize=4; + } else if (pp_valid_pp_word1(data8[0],8)) { + ppfile->type = pp_type; + ppfile->swap=0; + ppfile->wordsize=8; + } else if (pp_valid_pp_word1(data4s[0],4) && !(data4s[1]==0 && data4s[3]==0)) { + ppfile->type = pp_type; + ppfile->swap=1; + ppfile->wordsize=4; + } else if (pp_valid_pp_word1(data8s[0],8)) { + ppfile->type = pp_type; + ppfile->swap=1; + ppfile->wordsize=8; + } else { + /* type not identified */ + return -1; + } + return 0; +} + +/* values passed to pp_valid_um_word2 and pp_valid_pp_word1 could be 32 or 64-bit. + * Declare as longer of these two (Fint8), and shorter will be accommodated also. + */ + +int pp_valid_um_word2(Fint8 val) +{ + /* second word should be 1,2 or 4, reflecting model ID in fixed length header */ + return (val==1 || val==2 || val==4); +} + +int pp_valid_pp_word1(Fint8 val, int wsize) +{ + /* first word should be integer from Fortan representing length of header record */ + return (val==64*wsize || val==128*wsize); +} + + +int pp_determine_file_type_by_name(PPfile *ppfile, const char *filename) +{ + int len; + + if (ppfile==NULL) return -1; + + len=strlen(filename); + + if (pp_string_ends_with(filename,".pp32")) { + + ppfile->type = pp_type; + ppfile->swap=0; + ppfile->wordsize=4; + + } else if (pp_string_ends_with(filename,".pp64")) { + + ppfile->type = pp_type; + ppfile->swap=0; + ppfile->wordsize=8; + + } else if (pp_string_ends_with(filename,".pp32s")) { + + ppfile->type = pp_type; + ppfile->swap=1; + ppfile->wordsize=4; + + } else if (pp_string_ends_with(filename,".pp64s")) { + + ppfile->type = pp_type; + ppfile->swap=1; + ppfile->wordsize=8; + + } else if (pp_string_ends_with(filename,".um32")) { + + ppfile->type = um_type; + ppfile->swap=0; + ppfile->wordsize=4; + + } else if (pp_string_ends_with(filename,".um64")) { + + ppfile->type = um_type; + ppfile->swap=0; + ppfile->wordsize=8; + + } else if (pp_string_ends_with(filename,".um32s")) { + + ppfile->type = um_type; + ppfile->swap=1; + ppfile->wordsize=4; + + } else if (pp_string_ends_with(filename,".um64s")) { + + ppfile->type = um_type; + ppfile->swap=1; + ppfile->wordsize=8; + + } else { + /* type not identified */ + return -1; + } + return 0; +} + + +int pp_is_ppum_file(const char *filename, FILE *fd) +{ + PPfile ppfile; + + ppfile.fh = fd; + + return (pp_determine_file_type(&ppfile, filename, 0) == 0); +} + +/* case-insensitive test of ending part of string */ + +int pp_string_ends_with(const char *string, const char *ending) { + + int lstr, lend, i; + const char *end; + + lstr=strlen(string); + lend=strlen(ending); + + if (lend > lstr) return 0; + + end = string + lstr - lend; + + for (i=0 ; ifirst=NULL; + list->last=NULL; + list->n=0; + return list; + err: + pp_error("pp_list_new"); + return NULL; +} + +/* This function frees a list; + * Set free_ptrs if the pointers which have been explicitly stored on the + * list (2nd argument to pp_list_add) are to be freed, not just the pointers + * which are implicit in the linked list structure. NB there is no further + * recursion, in the sense that if the stored pointers are to datatypes which + * contain further pointers then these may have to be freed explicitly. + */ +int pp_list_free(PPlist *list, int free_ptrs, PPlist *heaplist){ + PPlistel *p, *next; + if (list == NULL) goto err; + for (p=list->first ; p != NULL ; p=next) { + next=p->next; + if (free_ptrs) + pp_free(p->ptr,heaplist); + pp_free(p,heaplist); + } + pp_free(list,heaplist); + return 0; + + err: + pp_error("pp_list_free"); + return -1; +} + + +int pp_list_size(const PPlist *list){ + if (list == NULL) goto err; + return list->n; + + err: + pp_error("pp_list_size"); + return -1; +} + + +int pp_list_add(PPlist *list, void *ptr, PPlist *heaplist){ + PPlistel *el; + if (list == NULL) goto err; + if(( el = pp_malloc(sizeof(PPlistel),heaplist) )==NULL) goto err; + list->n++; + el->ptr=ptr; + el->next=NULL; + if (list->first == NULL) { + el->prev=NULL; + list->first=list->last=el; + } + else { + list->last->next=el; + el->prev=list->last; + list->last=el; + } + return 0; + + err: + pp_error("pp_list_add"); + return -1; +} + +/* call pp_list_del to find a pointer ("ptr" element contained within the + * listel structure) on the list, and then delete that element from the list, + * or call pp_list_del_by_listel directly (more efficient) if you already + * have the listel structure pointer for what you want to delete. + */ + +int pp_list_del(PPlist *list, void *ptr, PPlist *heaplist){ + PPlistel *p, *prev, *next; + if (list == NULL) goto err; + for (p=list->first; p != NULL; p=p->next) + if (p->ptr == ptr) + return pp_list_del_by_listel(list,p,heaplist); + + /* if what we're trying to remove is not found, fall through + * to error exit + */ + + err: + pp_error("pp_list_del"); + return -1; +} + + +int pp_list_del_by_listel(PPlist *list,PPlistel *p, PPlist *heaplist){ + PPlistel *prev, *next; + next=p->next; + prev=p->prev; + if (next!=NULL) next->prev=prev; + if (prev!=NULL) prev->next=next; + if (p==list->first) list->first=next; + if (p==list->last) list->last=prev; + pp_free(p,heaplist); + list->n--; + return 0; +} + +/* call pp_list_startwalk before a sequence of calls to pp_list_walk */ +int pp_list_startwalk(const PPlist *list, PPlistpos *handle){ + if (list==NULL || handle==NULL) goto err; + handle->current = list->first; + handle->list = list; + return 0; + + err: + pp_error("pp_list_startwalk"); + return -1; +} + + +/* pp_list_walk: + * designed to be called repeatedly, and returns the next element of the list + * each time (but must not call either add or del between calls) + * + * (Set return_listel to nonzero to return the list element structure rather than + * the pointer it contains. This is just so that if you put null pointers on the + * list you can tell the difference from end of list.) + */ +void *pp_list_walk(const PPlist *list, int return_listel, PPlistpos *handle){ + void *ptr; + if (list==NULL || handle==NULL || handle->list!=list ) goto err; + if (handle->current == NULL) + return NULL; + else { + ptr = (return_listel) ? (void *)handle->current : handle->current->ptr; + handle->current=handle->current->next; + return ptr; + } + + err: + pp_error("pp_list_walk"); + return NULL; +} + +/*------------------------------------------------------------------------------*/ +/* pp_list_find: find first item on the list matching specified item, + * where "compar" is the matching function, and "matchval" is return value from + * compar in the event of a match + */ +void *pp_list_find(PPlist *list, const void *item, + int (*compar)(const void *, const void *), int matchval) { + int found; + PPlistel *listel; + PPlistpos handle; + void *ptr; + + pp_list_startwalk(list,&handle); + found=0; + while ((listel = pp_list_walk(list,1,&handle)) != NULL) { + ptr=listel->ptr; + if (compar(&item, &ptr) == matchval) + return ptr; + } + return NULL; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_malloc.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_malloc.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_malloc.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_malloc.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,106 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* Malloc functions + * + * These routines are closely integrated with the link list functions; they + * are called with a linked list "heaplist"; the malloc function adds the + * newly allocated pointer to this list, and the free function removes it from + * the list. (They can also be called with NULL in which case they reduce to + * simple malloc and free; this is necessary when allocating or freeing memory + * for the heaplist itself.) + * + * The idea is that all the dynamically memory allocation associated with + * a given file should be through these functions. Then whenever the file + * is closed properly or because an error condition gave an abort, the + * memory can be freed without needing complicated tests to work out what + * has been allocated: just go through the linked list freeing pointers. + * + * NOTE: this routine now allocates a little more memory than requested, + * and saves the pointer to the list element on the heaplist at the start, + * before returning to the calling routine the pointer to the actual block + * of memory that the caller is interested in. This ensures that when freeing + * the memory, pp_list_del_by_listel can be used instead of pp_list_del, giving + * efficiency gains. + */ + +static const int extrasize = sizeof(PPlistel*); + +void *pp_malloc(size_t size, PPlist *heaplist){ + + void *ptr; + PPlistel* *elp; + + if (size==0) + return NULL; + + /* The only call to malloc in cdunifpp_* */ + ptr=malloc(size+extrasize); + + if (ptr==NULL) + { + CuError(CU_EINTERN,"WARNING: unable to allocate of %d bytes of memory in cdunifpp",size); + } + else { + + /* copy the pointer so we can use the start of the address to store + * the PPlistel* + */ + elp = (PPlistel**) ptr; + + /* Now increment the pointer (to after our stored PPlistel*) to give + * what the calling routine calling routine sees the start of memory + * (cast to char* for ptr arithmetic. Do this *before* storing it + * on the heaplist, because pointers on will be freed with pp_free + */ + ptr = (void*) ((char*)ptr+extrasize); + + if (heaplist != NULL) { + + if(( pp_list_add(heaplist,ptr,NULL) )!=0) goto err; + + /* we just added to the list, so that heaplist->last will + * contain pointer to the relevant PPlistel* + */ + *elp = heaplist->last; + } + else + *elp = NULL; + } + + return ptr; + + err: + pp_error("pp_malloc"); + return NULL; +} + +int pp_free(void *ptr, PPlist *heaplist){ + + PPlistel *el; + + if (ptr==NULL) + return -1; + + /* first subtract off the extra size we added (see pp_malloc) */ + ptr = (void*) ((char*)ptr-extrasize); + + /* this is our list element */ + el=*(PPlistel**)ptr; + + /* The only call to free in cdunifpp_* */ + free(ptr); + + /* printf ("pp_free: %p\n",ptr); */ + if (heaplist != NULL) + pp_list_del_by_listel(heaplist,el,NULL); + + return 0; +} + + +int pp_free_all(PPlist *heaplist) { + return pp_list_free(heaplist,1,NULL); +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_ppcode.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_ppcode.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_ppcode.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_ppcode.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,1894 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* The data for these functions is taken from xconv v1.90 */ + +/* returns string, or NULL if not matched */ +char *pp_pplongname(int code) +{ + switch (code) { + case 0: return "Unspecified"; + case 1: return "Height"; + case 2: return "Depth"; + case 3: return "Geopotential (= g*height)"; + case 4: return "ICAO height"; + case 5: return "Boundary layer height"; + case 6: return "Non-dimensional soil model level"; + case 7: return "Exner pressure"; + case 8: return "Pressure"; + case 9: return "Hybrid pressure"; + case 10: return "Sigma (= p/surface p)"; + case 11: return "T*u"; + case 12: return "T*v"; + case 13: return "T**2"; + case 14: return "T*omega"; + case 15: return "Height**2"; + case 16: return "Temperature T"; + case 17: return "Dew point temperature"; + case 18: return "Dew point depression"; + case 19: return "Potential temperature"; + case 20: return "Maximum temperature"; + case 21: return "Minimum temperature"; + case 22: return "Wet bulb potential temperature"; + case 23: return "Soil temperature (levels 2,3,4)"; + case 24: return "d theta/dt"; + case 25: return "Visibility"; + case 26: return "Brunt-Vaisala Frequency N"; + case 27: return "(Atmospheric) density"; + case 28: return "d(p*)/dt . p* = surface pressure"; + case 29: return "Cloud fraction below a level in feet"; + case 30: return "Total cloud"; + case 31: return "High cloud"; + case 32: return "Medium cloud"; + case 33: return "Low cloud"; + case 34: return "Convective cloud"; + case 35: return "Contrail"; + case 36: return "Fractional land amount"; + case 37: return "Fractional sea-ice cover"; + case 38: return "Atmospheric model land/sea mask Land=1, Sea=0"; + case 39: return "Coriolis parameter"; + case 40: return "Omega (= dp/dt)"; + case 41: return "Wet bulb temperature"; + case 42: return "Vertical velocity (= dz/dt)"; + case 43: return "Eta dot"; + case 44: return "Time in seconds"; + case 45: return "d(sigma)/dt"; + case 46: return "u*q"; + case 47: return "v*q"; + case 48: return "x wind component (with respect to grid)"; + case 49: return "y wind component (with respect to grid)"; + case 50: return "Wind speed"; + case 51: return "Thermal wind speed"; + case 52: return "Vertical speed shear"; + case 53: return "u*omega"; + case 54: return "v*omega"; + case 55: return "Wind direction"; + case 56: return "Westerly component of wind u"; + case 57: return "Southerly component of wind v"; + case 58: return "u**2"; + case 59: return "v**2"; + case 60: return "Product of wind components u*v"; + case 61: return "x component of wind stress"; + case 62: return "y component of wind stress"; + case 63: return "Kinetic energy"; + case 64: return "Wind in DDDFFF format"; + case 65: return "Hybrid height"; + case 66: return "Reserved for M.Mawson"; + case 67: return "Reserved for M.Mawson"; + case 68: return "u-acceleration from saturated stress"; + case 69: return "v-acceleration from saturated stress"; + case 70: return "u-acceleration from hydraulic jump"; + case 71: return "v-acceleration from hydraulic jump"; + case 72: return "Absolute vorticity"; + case 73: return "Relative vorticity"; + case 74: return "Divergence"; + case 75: return "Height of base of lowest cloud in feet"; + case 76: return "Height of top of lowest cloud in feet"; + case 77: return "Total precipitation accumulation"; + case 78: return "QCF - Frozen cloud water"; + case 79: return "QCL - Liquid cloud water"; + case 80: return "Stream function"; + case 81: return "Velocity potential"; + case 82: return "Ertel potential vorticity (Q)"; + case 83: return "Thermal vorticity"; + case 84: return "Quasi-geostrophic potential vorticity"; + case 85: return "Montgomery stream function"; + case 86: return "Geostrophic absolute vorticity"; + case 87: return "dq/dt"; + case 88: return "Relative humidity"; + case 89: return "Precipitable water"; + case 90: return "Total precipitation rate"; + case 91: return "Equivalent ice depth"; + case 92: return "Actual ice depth"; + case 93: return "Snow depth (water equivalent)"; + case 94: return "Convective rain"; + case 95: return "Specific humidity q"; + case 96: return "Condensed water (per unit area)"; + case 97: return "Total rainfall rate"; + case 98: return "Convective rainfall rate"; + case 99: return "Dynamic rainfall rate"; + case 100: return "Local convective rainfall"; + case 101: return "Mixing ratio"; + case 102: return "Large scale rain"; + case 103: return "Snow"; + case 104: return "Total rain"; + case 105: return "Evaporation"; + case 106: return "Total soil moisture content (levels 1-4)"; + case 107: return "Sublimation"; + case 108: return "Snowfall rate"; + case 109: return "Total runoff"; + case 110: return "Snowmelt"; + case 111: return "Quick runoff"; + case 112: return "Slow runoff"; + case 113: return "(Precipitation minus evaporation) rate"; + case 114: return "Evaporation rate"; + case 115: return "Evaporation from soil surface"; + case 116: return "Large scale snowfall"; + case 117: return "Convective snowfall"; + case 118: return "Large scale snowfall rate mm/s"; + case 119: return "Convective snowfall rate mm/s"; + case 120: return "Total large-scale precipitation"; + case 121: return "Total convective precipitation"; + case 122: return "Soil moisture in each (of 4) levels"; + case 123: return "u-acceleration from trapped lee waves"; + case 124: return "v-acceleration from trapped lee waves"; + case 125: return "Vertical transmission coefficient"; + case 126: return "Max C.A.T. level"; + case 127: return "Sea bed level"; + case 128: return "Mean sea level"; + case 129: return "Surface"; + case 130: return "Tropopause level"; + case 131: return "Maximum wind level"; + case 132: return "Freezing level"; + case 133: return "Top of atmosphere"; + case 134: return "-20 deg.C level"; + case 135: return "Upper level (height)"; + case 136: return "Lower level (height)"; + case 137: return "Upper level (pressure)"; + case 138: return "Lower level (pressure)"; + case 139: return "Wet bulb freezing level height (asl)"; + case 140: return "Salinity"; + case 141: return "Snowmelt heat flux"; + case 142: return "Upper level (hybrid)"; + case 143: return "Lower level (hybrid)"; + case 144: return "Unified model test diagnostic for output no. 1"; + case 145: return "Unified model test diagnostic for output no. 2"; + case 146: return "Unified model test diagnostic for output no. 3"; + case 147: return "Unified model test diagnostic for output no. 4"; + case 148: return "X component of geostrophic wind"; + case 149: return "Y component of geostrophic wind"; + case 150: return "Standard deviation of orography"; + case 151: return "Distance to the centre of the earth"; + case 152: return "Orography XX gradient component"; + case 153: return "Orography XY gradient component"; + case 154: return "Orography YY gradient component"; + case 155: return "Orographic roughness"; + case 156: return "Total ozone climatology"; + case 157: return "Ultra violet index climatology"; + case 158: return "Total ozone field, Dobson units"; + case 159: return "UVB (Ultra violet index - dimensionless)"; + case 160: return "Drag coefficient CD"; + case 161: return "Theta_e"; + case 162: return "Sunshine hours"; + case 163: return "Convective cloud liquid re * convective cloud amount"; + case 164: return "Layer cloud liquid re * layer cloud amount"; + case 165: return "Convective cloud amount in SWRAD (microphysics)"; + case 166: return "Layer cloud amount in SWRAD (microphysics)"; + case 167: return "Layer cloud condensed water path * amount"; + case 168: return "Cloud emissivity * cloud fraction"; + case 169: return "Cloud albedo * cloud fraction"; + case 170: return "Transmissivity"; + case 171: return "RHOKH (RHO* * CH * SURF_LAYER_WIND_SHEAR)"; + case 172: return "RHOKM (RHO* * CD * SURF_LAYER_WIND_SHEAR)"; + case 173: return "Probability of visibility less than 5 km"; + case 174: return "Silhouette area of unresolved orography per unit horizontal area"; + case 175: return "Peak to trough height of unresolved orography divided by 2"; + case 176: return "Latitude (north positive)"; + case 177: return "Longitude (east positive)"; + case 178: return "Sensible heat flux"; + case 179: return "Soil heat flux"; + case 180: return "Latent heat flux"; + case 181: return "Bulk Richardson number"; + case 182: return "Wind mixing energy"; + case 183: return "CH - bulk transfer coefficient of heat"; + case 184: return "Moisture flux"; + case 185: return "Mass flux"; + case 186: return "Net short wave radiation flux"; + case 187: return "Net long wave radiation flux"; + case 188: return "Total surface heat flux (inc. sensible+latent)"; + case 189: return "Thermal advection"; + case 190: return "C.A.T. probability"; + case 191: return "Snow probability"; + case 192: return "Boundary mixing coeffs."; + case 193: return "Convective heating rate"; + case 194: return "Convective moistening rate"; + case 195: return "Vertical momentum flux - U"; + case 196: return "Vertical momentum flux - V"; + case 197: return "Snow melt heating flux"; + case 198: return "Evaporation duct height"; + case 199: return "Evap. duct intensity (max wavelength trapped)"; + case 200: return "Downward solar"; + case 201: return "Upward solar"; + case 202: return "Net surface radiation flux (No sensible or latent)"; + case 203: return "Total downward surface solar flux over sea-ice."; + case 204: return "Reserved for M.Mawson"; + case 205: return "IR down"; + case 206: return "IR up"; + case 207: return "Clear-sky flux (type II) solar up"; + case 208: return "Clear-sky flux (type II) solar down"; + case 209: return "Sea-ice temperature"; + case 210: return "Clear-sky (type II) IR up"; + case 211: return "Clear-sky (type II) IR down"; + case 212: return "Convective cloud base times amount"; + case 213: return "Dilute convectively available potential energy"; + case 214: return "Clear-sky (type II) net shortwave flux"; + case 215: return "Clear-sky (type II) net longwave flux"; + case 216: return "Cloud top height (asl)"; + case 217: return "Convective cloud top times amount"; + case 218: return "Convective cloud water"; + case 219: return "Convective cloud condensed water path"; + case 220: return "Cloud amount in a layer / at a level"; + case 221: return "Total water condensed by convection"; + case 222: return "Convective cloud base level-number"; + case 223: return "Convective cloud top level-number"; + case 224: return "Advecting u * layer thickness (pascals) = zonal mass-flux"; + case 225: return "Advecting v * layer thickness (pascals) = meridional mass-flux"; + case 226: return "Blocking index (Tibaldi & Molteni definition)"; + case 227: return "EMAX from convection scheme"; + case 228: return "Total net radiative heating"; + case 229: return "Zonal mass-flux * temperature"; + case 230: return "Meridional mass-flux * temperature"; + case 231: return "Zonal mass-flux * specific humidity q"; + case 232: return "Meridional mass-flux * specific humidity q"; + case 233: return "Zonal mass-flux * liquid water temperature"; + case 234: return "Meridional mass-flux * liquid water temperature"; + case 235: return "Zonal mass-flux * total water"; + case 236: return "Meridional mass-flux * total water"; + case 237: return "Clear-sky (type I) solar up"; + case 238: return "Clear-sky (type I) solar down"; + case 239: return "Vapour pressure"; + case 240: return "Clear-sky (type I) IR up"; + case 241: return "Clear-sky (type I) IR down"; + case 242: return "Probability of precipitation"; + case 243: return "Clear-sky (type I) net shortwave flux"; + case 244: return "Clear-sky (type I) net longwave flux"; + case 245: return "Clear-sky(type I) radiative heating"; + case 246: return "Clear-sky(type I) short-wave radiative heating"; + case 247: return "Clear-sky(type I) long wave radiative heating"; + case 248: return "X component of ageostrophic wind"; + case 249: return "Y component of ageostrophic wind"; + case 250: return "Clear-sky(type II) radiative heating"; + case 251: return "Short-wave radiative heating"; + case 252: return "Clear-sky(type II) short-wave radiative heating"; + case 253: return "Long-wave radiative heating"; + case 254: return "Clear-sky(type II) long-wave radiative heating"; + case 255: return "Convective cloud liquid re * convective cloud weighting (full levels)"; + case 256: return "Convective cloud weighting for microphysics (full levels)"; + case 257: return "RHO_CD_MODV1 = rhostar*cD*modv1"; + case 258: return "RHO_KM = rho*Km (Km = turbulent mixing coefficient for momentum)"; + case 259: return "Atmospheric energy correction (from UM 3.3)"; + case 260: return "Sea-ice topmelt"; + case 261: return "Sea-ice botmelt"; + case 262: return "Fractional time of change of ice cover."; + case 263: return "Zonal mass-flux * u"; + case 264: return "Meridional mass-flux * u"; + case 265: return "Zonal mass-flux * v"; + case 266: return "Meridional mass-flux * v"; + case 267: return "Zonal mass-flux * geopotential"; + case 268: return "Meridional mass-flux * geopotential"; + case 269: return "Zonal mass-flux * moist static energy"; + case 270: return "Meridional mass-flux * moist static energy"; + case 271: return "Canopy water content"; + case 272: return "Canopy condensation"; + case 273: return "Canopy evaporation"; + case 274: return "Canopy water throughfall"; + case 275: return "Canopy height (all vegetation)"; + case 276: return "Air concentration of radioactivity"; + case 277: return "Dosage of radioactivity"; + case 278: return "Dry deposition of radioactivity"; + case 279: return "Wet deposition of radioactivity"; + case 280: return "Leads;net solar radiation"; + case 281: return "Leads;net infra-red flux"; + case 282: return "Leads;sensible heat flux"; + case 283: return "Leads;latent heat flux"; + case 284: return "Total deposition of radioactivity"; + case 285: return "Evap from sea * leads fraction."; + case 286: return "Total aerosol"; + case 287: return "Total aerosol emissions"; + case 288: return "Visibility assimilation weights"; + case 289: return "Visibility assimilation increment"; + case 290: return "P* (surface pressure) weights"; + case 291: return "Theta weights"; + case 292: return "Wind weights"; + case 293: return "Surface wind weights......."; + case 294: return "RH weights"; + case 295: return "Precipitation rate assimilation weights"; + case 296: return "Spare for A/C"; + case 297: return "Spare for A/C"; + case 298: return "Spare for A/C"; + case 299: return "Specific layer cloud water content"; + case 300: return "Spare for A/C"; + case 301: return "Spare for A/C"; + case 302: return "Spare for A/C"; + case 303: return "P* (surface pressure) assimilation increments"; + case 304: return "Theta assimilation increments"; + case 305: return "u assimilation increments"; + case 306: return "v assimilation increments"; + case 307: return "Hydrostatic increments"; + case 308: return "Probability of ground frost"; + case 309: return "RH assimilation increments"; + case 310: return "Precipitation rate assimilation increments"; + case 311: return "Reserved for M.Mawson"; + case 312: return "Reserved for M.Mawson"; + case 313: return "Reserved for M.Mawson"; + case 314: return "Reserved for M.Mawson"; + case 315: return "Increment in q from a routine"; + case 316: return "Increment in T from a routine"; + case 317: return "Increment in theta from a routine"; + case 318: return "Increment in u from a routine"; + case 319: return "Increment in v from a routine"; + case 320: return "Surface roughness (heat)"; + case 321: return "Root depth"; + case 322: return "Snow free albedo (all types of land)"; + case 323: return "Surface resistance to evaporation"; + case 324: return "Surface roughness (momentum)"; + case 325: return "Surface capacity"; + case 326: return "Vegetation fraction"; + case 327: return "Veg. infilt. enhancement factor"; + case 328: return "Deep snow albedo"; + case 329: return "Wilting point"; + case 330: return "Critical point"; + case 331: return "Field capacity"; + case 332: return "Saturation"; + case 333: return "Saturated conductivity"; + case 334: return "Eagleson's exponent"; + case 335: return "Heat capacity"; + case 336: return "Heat conductivity"; + case 337: return "SOILB (Soil hydrology parameter BS)"; + case 338: return "Field capacity-root depth"; + case 339: return "Surface infilt.-infilt. factor"; + case 340: return "Thermal inertia-(lambda C ** 1/2)"; + case 341: return "Veg. infilt. enhancement factor * Saturated conductivity"; + case 342: return "Saturated soil water suction"; + case 343: return "Lowest convective cloud amount"; + case 344: return "Lowest convective cloud base"; + case 345: return "Lowest convective cloud top"; + case 346: return "Lowest convective cloud base"; + case 347: return "Lowest convective cloud top"; + case 348: return "X component of Q"; + case 349: return "Y component of Q"; + case 350: return "DIV(Q)"; + case 351: return "Wave/ Spectral wave energy component"; + case 366: return "Wave/ Induced stress"; + case 367: return "Wave/ Dependent roughness length"; + case 368: return "Wave/ Total induced current speed"; + case 369: return "Wave/ Total induced current direction"; + case 370: return "Wave/ Surge induced current speed"; + case 371: return "Wave/ Surge induced current direction"; + case 372: return "Wave/ Tide induced water level"; + case 373: return "Wave/ Tide induced current speed"; + case 374: return "Wave/ Tide induced current direction"; + case 375: return "Wave/ Mean wave height error"; + case 376: return "Wave/ Mean wave period error"; + case 377: return "Wave/ Mean wave speed error"; + case 378: return "Wave/ RMS wave height error"; + case 379: return "Wave/ RMS wave period error"; + case 380: return "Wave/ RMS wave speed error"; + case 384: return "Wave/ Water temperature"; + case 385: return "Wave/ Height of wind-driven waves"; + case 386: return "Wave/ Height of sea swells"; + case 387: return "Wave/ Combined wave and swell height"; + case 388: return "Wave/ Period of wind-driven waves"; + case 389: return "Wave/ Direction from which waves come"; + case 390: return "Wave/ Period of sea swells"; + case 391: return "Wave/ Direction from which swells come"; + case 392: return "Wave/ Total depth (wave+surge)"; + case 393: return "Wave/ Period of significant waves"; + case 394: return "Wave/ Dirn. from which sig. waves come"; + case 395: return "Wave/ Grid point type (sea/land/coast)"; + case 396: return "Wave/ Surge induced water level"; + case 397: return "Wave/ Wave model land/sea indicator"; + case 401: return "MA/ d(ln p)/dt"; + case 402: return "MA/ d(theta)/dp"; + case 403: return "MA/ Log(Absolute ertel pot. vorticity)"; + case 404: return "MA/ Sign of dq/dt"; + case 405: return "MA/ d(theta)/dt"; + case 406: return "MA/ Shortwave heating rates"; + case 407: return "MA/ Longwave cooling rates"; + case 408: return "MA/ Total radiative heating"; + case 409: return "MA/ Friction term in circulation budget"; + case 410: return "MA/ dp/d(theta)"; + case 411: return "MA/ Geostrophic Ertel potential vorticity"; + case 412: return "MA/ dq/dt advection term"; + case 413: return "MA/ dq/dt source term"; + case 414: return "MA/ Total dq/dt ie source + advection"; + case 415: return "MA/ d(theta)/dt"; + case 416: return "MA/ Absolute vorticity (interpolated)"; + case 417: return "MA/ Absolute vorticity*total dq/dt"; + case 418: return "MA/ dq/dt from Raleigh friction"; + case 451: return "MAtr/ Passive tracer"; + case 452: return "MAtr/ Nitrous oxide tracer"; + case 453: return "MAtr/ Ozone tracer"; + case 501: return "MAUA/ Atmosphere tracer 1 (conventionally O3)"; + case 502: return "MAUA/ Atmosphere tracer 2 (conventionally H2O)"; + case 503: return "MAUA/ Atmosphere tracer 3 (conventionally CO)"; + case 504: return "MAUA/ Atmosphere tracer 4 (conventionally CH4)"; + case 505: return "MAUA/ Atmosphere tracer 5 (conventionally N2O)"; + case 506: return "MAUA/ Atmosphere tracer 6 (conventionally NO)"; + case 507: return "MAUA/ Atmosphere tracer 7 (conventionally NO2)"; + case 508: return "MAUA/ Atmosphere tracer 8 (conventionally HNO3)"; + case 509: return "MAUA/ Atmosphere tracer 9 (conventionally N2O5)"; + case 510: return "MAUA/ Atmosphere tracer 10 (conventionally ClONO2)"; + case 511: return "MAUA/ Atmosphere tracer 11 (conventionally ClO)"; + case 512: return "MAUA/ Atmosphere tracer 12 (conventionally HCl)"; + case 513: return "MAUA/ Atmosphere tracer 13 (conventionally CF2Cl2)"; + case 514: return "MAUA/ Atmosphere tracer 14 (conventionally CFCl3)"; + case 515: return "MAUA/ Atmosphere tracer 15 (conventionally HF)"; + case 516: return "MAUA/ Atmosphere tracer 16"; + case 517: return "MAUA/ Atmosphere tracer 17"; + case 518: return "MAUA/ Atmosphere tracer 18"; + case 519: return "MAUA/ Atmosphere tracer 19 (conventionally SO2)"; + case 520: return "MAUA/ Atmosphere tracer 20 (conventionally DMS)"; + case 521: return "MAUA/ Atmosphere tracer 21 (conventionally H2S)"; + case 522: return "MAUA/ Atmosphere tracer 22 (conventionally WATER-SOLUBLE)"; + case 523: return "MAUA/ Atmosphere tracer 23 (conventionally DUST-LIKE)"; + case 524: return "MAUA/ Atmosphere tracer 24 (conventionally OCEANIC)"; + case 525: return "MAUA/ Atmosphere tracer 25 (conventionally SOOT)"; + case 526: return "MAUA/ Atmosphere tracer 26 (conventionally VOLCANIC ASH)"; + case 527: return "MAUA/ Atmosphere tracer 27 (conventionally SULPHURIC ACID)"; + case 528: return "MAUA/ Atmosphere tracer 28 (conventionally AMMONIUM SULPHATE)"; + case 529: return "MAUA/ Atmosphere tracer 29 (conventionally MINERAL)"; + case 569: return "MAUA/ Sulphur Dioxide emissions."; + case 570: return "MAUA/ Dimethyl Sulphide emissions."; + case 571: return "MAUA/ Hydrogen Sulphide emissions."; + case 572: return "MAUA/ NH3 gas emissions"; + case 573: return "MAUA/ Soot emissions"; + case 580: return "MAUA/ Hydroxyl radical concentration molecules"; + case 581: return "MAUA/ Hydrogen Peroxide concentration"; + case 600: return "MAUA/ HO2 concentration"; + case 601: return "OCtr/ Temperature."; + case 602: return "OCtr/ Salinity."; + case 603: return "OCtr/ T*"; + case 604: return "OCtr/ Temperature at t-1."; + case 605: return "OCtr/ Salinity at t-1."; + case 606: return "OCtr/ No. deep convection points"; + case 607: return "OCtr/ Fractional expansion of sea water (dimensionless)"; + case 608: return "OCtr/ Sea surface elevation"; + case 609: return "OCtr/ Density of sea water"; + case 610: return "OCtr/ Sea level rise"; + case 611: return "OCtr/ Stream function."; + case 612: return "OCtr/ Stream function at t-1."; + case 613: return "OCtr/ Change of stream function across a time step."; + case 614: return "OCtr/ Change of stream function across previous timestep."; + case 615: return "OCtr/ (Formerly reciprocal of total depth at U/V points, use 715 1/1/92)"; + case 616: return "OCtr/ Number of vertical levels of ocean at T points."; + case 617: return "Octr/ rigid-lid pressure"; + case 618: return "OCtr/ Change of vorticity across one timestep."; + case 619: return "OCtr/ Vertical expansion of sea water."; + case 620: return "OCtr/ Convergence heat"; + case 621: return "OCtr/ Equivalent ice depth."; + case 622: return "OCtr/ Snow depth."; + case 623: return "OCtr/ Snowfall."; + case 624: return "OCtr/ Sublimation."; + case 625: return "OCtr/ Net solar heat flux."; + case 626: return "OCtr/ Net surface heat flux (HTN)."; + case 627: return "OCtr/ Wind mixing energy."; + case 628: return "OCtr/ Diffusive heat flux."; + case 629: return "OCtr/ Precipitation minus evaporation (PLE)"; + case 630: return "OCtr/ Sum of net solar and net surface heating."; + case 631: return "OCtr/ River outflow"; + case 632: return "OCtr/ Surface water flux * salinity / density"; + case 633: return "OCtr/ x component of sea-ice/ocean surface stress (ISX)"; + case 634: return "OCtr/ y component of sea-ice/ocean surface stress (ISY)"; + case 635: return "OCtr/ Buoyancy"; + case 636: return "OCtr/ Buoyancy flux"; + case 637: return "OCtr/ In-situ temperature"; + case 638: return "OCtr/ sigma-T/kg m**-3 ( (rho(insitu_T,S,0)-1000 )"; + case 639: return "OCtr/ sigma-theta/kg m**-3 ( rho(theta,S,0)-1000 )"; + case 640: return "OCtr/ Zonal heat advection."; + case 641: return "OCtr/ Meridional heat advection."; + case 642: return "OCtr/ Heating rate due to advection"; + case 643: return "OCtr/ Heating rate due to diffusion "; + case 644: return "OCtr/ Heating rate due to surface fluxes"; + case 645: return "OCtr/ Heating rate due to mixing"; + case 646: return "OCtr/ Heating rate due to filtering"; + case 647: return "OCtr/ Heating rate"; + case 648: return "OCtr/ Rate of change of salinity (UM cant control LBPROC)"; + case 649: return "OCtr/ Climatological reference surface salinity"; + case 650: return "OCtr/ Climatological reference SST (sea surface temperature)."; + case 651: return "OCtr/ Anomalous heat flux from Haney term."; + case 652: return "OCtr/ Anomalous latent heat flux from Haney term"; + case 653: return "OCtr/ Mixed layer depth,type 1."; + case 654: return "OCtr/ Mixed layer depth,type 2."; + case 655: return "OCtr/ Heat content"; + case 656: return "OCtr/ Latent heat content"; + case 657: return "OCtr/ Turbulent kinetic energy"; + case 658: return "OCtr/ Thickness diff coeff (ocean)"; + case 660: return "OCtr/ Vertical mean vorticity forcing: advection"; + case 661: return "OCtr/ Vertical mean vorticity forcing: hor diffn"; + case 662: return "OCtr/ Vertical mean vorticity forcing: vrt diffn"; + case 663: return "OCtr/ Vertical mean vorticity forcing: coriolis"; + case 664: return "OCtr/ Vertical mean vorticity forcing: pressure"; + case 665: return "OCtr/ Vertical integral vorticity forcing: advection"; + case 666: return "OCtr/ Vertical integral vorticity forcing: hor diffn"; + case 667: return "OCtr/ Vertical integral vorticity forcing: vrt diffn"; + case 668: return "OCtr/ Vertical integral vorticity forcing: coriolis"; + case 669: return "OCtr/ Vertical integral vorticity forcing: bottom p"; + case 670: return "OCtr/ Boundary profiles."; + case 671: return "OCtr/ Anomalous heat flux."; + case 672: return "OCtr/ Anomalous salt flux."; + case 673: return "OCtr/ Virtual air-sea flux of co2"; + case 674: return "OCtr/ Virtual air-sea flux of alkalinity"; + case 675: return "OCtr/ Climatological Ice depth"; + case 676: return "OCtr/ Mass of ocean below rigid lid"; + case 677: return "OCtr/ Ocean bottom pressure"; + case 678: return "OCtr/ Anomolous sea-ice heat flux"; + case 679: return "OCtr/ Anomalous sea-ice P-E flux"; + case 680: return "OCtr/ W (vertical velocity)."; + case 681: return "OCtr/ Topmelt."; + case 682: return "OCtr/ Botmelt."; + case 683: return "OCtr/ Fractional ice cover."; + case 684: return "OCtr/ Ocean-ice heat flux."; + case 685: return "OCtr/ Carry heat."; + case 686: return "OCtr/ Carry salt."; + case 687: return "OCtr/ Actual ice depth."; + case 688: return "OCtr/ Snow depth over ice."; + case 689: return "OCtr/ Sea-ice internal pressure"; + case 690: return "OCtr/ Sea-ice strength"; + case 692: return "OCtr/ Average snow depth."; + case 693: return "OCtr/ Average ice cover."; + case 694: return "OCtr/ Average O/I heat flux."; + case 695: return "OCtr/ KT Vertical tracer diffusion coeff"; + case 696: return "OCtr/ RiT Richardson no tracer"; + case 697: return "OCtr/ HT Max depth Large scheme tracer"; + case 698: return "OCtr/ Downwards solar radiation over ice"; + case 699: return "OCtr/ Depth of ocean at TS points"; + case 700: return "OCuv/ River run-off ocean entry point co-ordinates."; + case 701: return "OCuv/ Baroclinic component of zonal velocity"; + case 702: return "OCuv/ Baroclinic component of meridional velocity"; + case 703: return "OCuv/ Zonal velocity (total)"; + case 704: return "OCuv/ Meridional velocity (total)"; + case 711: return "OCuv/ Barotropic component of zonal velocity"; + case 712: return "OCuv/ Barotropic component of meridional velocity"; + case 713: return "OCuv/ Baroclinic x-acceleration"; + case 714: return "OCuv/ Baroclinic y-acceleration"; + case 715: return "OCuv/ Reciprocal of total depth"; + case 717: return "OCuv/ Number of vertical levels of ocean at U/V points."; + case 718: return "OCuv/ Vertical integral of zonal velocity"; + case 719: return "OCuv/ Vertical integral of meridional velocity"; + case 721: return "OCuv/ Zonal component of windstress (TAUX)"; + case 722: return "OCuv/ Meridional component of windstress (TAUY)"; + case 728: return "OCuv/ x component of sea-ice velocity"; + case 729: return "OCuv/ y component of sea-ice velocity"; + case 730: return "OCuv/ Magnitude of sea-ice velocity"; + case 731: return "OCuv/ Zonal component of sea-ice velocity"; + case 732: return "OCuv/ Meridional component of sea-ice velocity"; + case 733: return "OCuv/ Zonal component of ice-ocean stress"; + case 734: return "OCuv/ Meridional component of ice-ocean stress"; + case 735: return "OCuv/ Zonal component of Coriolis stress"; + case 736: return "OCuv/ Meridional component of Coriolis stress"; + case 737: return "OCuv/ Zonal component of internal ice stress"; + case 738: return "OCuv/ Meridional component of internal ice stress"; + case 740: return "OCuv/ Zonal mean tracer transport diagnostics"; + case 741: return "OCuv/ Baroclinic acceleration diag, meridional: Advection"; + case 742: return "OCuv/ Baroclinic acceleration diag, meridional: Hor Diffusion"; + case 743: return "OCuv/ Baroclinic acceleration diag, meridional: Vert Diffusion"; + case 744: return "OCuv/ Baroclinic acceleration diag, meridional: Coriolis"; + case 745: return "OCuv/ Baroclinic acceleration diag, meridional: Pressure"; + case 746: return "OCuv/ Baroclinic acceleration diag, zonal: Advection"; + case 747: return "OCuv/ Baroclinic acceleration diag, zonal: Hor Diffusion"; + case 748: return "OCuv/ Baroclinic acceleration diag, zonal: Vert Diffusion"; + case 749: return "OCuv/ Baroclinic acceleration diag, zonal: Coriolis"; + case 750: return "OCuv/ Baroclinic acceleration diag, zonal: Pressure"; + case 751: return "OCuv/ Meridional net pressure gradient"; + case 752: return "OCuv/ Zonal net pressure gradient"; + case 753: return "OCuv/ Meridional acceleration"; + case 754: return "OCuv/ Zonal acceleration"; + case 795: return "OCuv/ KM Vertical momentum diffusion coeff"; + case 796: return "OCuv/ RiM Richardson no momentum"; + case 797: return "OCuv/ HM Max depth Large scheme momentum"; + case 801: return "OCE/ ocean extra tracer 1 (conventionally TCO2 )"; + case 802: return "OCE/ ocean extra tracer 2 (conventionally alkalinity)"; + case 803: return "OCE/ ocean extra tracer 3 (conventionally nutrient)"; + case 804: return "OCE/ ocean extra tracer 4 (conventionally phytoplankton conc.)"; + case 805: return "OCE/ ocean extra tracer 5 (conventionally zooplankton)"; + case 806: return "OCE/ ocean extra tracer 6 (conventionally detritus)"; + case 807: return "OCE/ ocean extra tracer 7 (conventionally tritium)"; + case 808: return "OCE/ ocean extra tracer 8 (conventionally 3H+3He total mass)"; + case 809: return "OCE/ ocean extra tracer 9 (conventionally CFC11)"; + case 810: return "OCE/ ocean extra tracer 10 (conventionally CFC12)"; + case 811: return "OCE/ ocean extra tracer 11 (conventionally CFC13)"; + case 812: return "OCE/ ocean extra tracer 12 (conventionally carbon 14)"; + case 813: return "OCE/ ocean extra tracer 13"; + case 814: return "OCE/ ocean extra tracer 14"; + case 815: return "OCE/ ocean extra tracer 15"; + case 816: return "OCE/ ocean extra tracer 16"; + case 817: return "OCE/ ocean extra tracer 17"; + case 818: return "OCE/ ocean extra tracer 18"; + case 820: return "OCE/ Sonic layer depth"; + case 821: return "OCE/ Sonic layer trap at 10Hz (0/1)"; + case 822: return "OCE/ Sonic layer trap at 50Hz (0/1)"; + case 823: return "OCE/ Sonic layer trap at 1kHz (0/1)"; + case 824: return "OCE/ Sonic layer trap at 10kHz (0/1)"; + case 825: return "OCE/ Sound channel strength at 10Hz (1-3)"; + case 826: return "OCE/ Sound channel strength at 50Hz (1-3)"; + case 827: return "OCE/ Sound channel strength at 1kHz (1-3)"; + case 828: return "OCE/ Sound channel strength at 10kHz (1-3)"; + case 829: return "OCE/ Range to the 1st CZ"; + case 830: return "OCE/ Strength of 1st CZ (0-100)"; + case 831: return "OCE/ Gent and McWilliams scheme eddy u velocity (ocean)"; + case 832: return "OCE/ Gent and McWilliams scheme eddy v velocity (N face) (ocean)"; + case 833: return "OCE/ Gent and McWilliams scheme eddy w velocity (top face) (ocean)"; + case 834: return "OCE/ d theta/dt from Gent and McWilliams scheme"; + case 835: return "OCE/ Speed of sound in water"; + case 836: return "OCE/ Depth of sound speed minimum (sound channel)"; + case 837: return "OCE/ Depth of max neg ssp grad"; + case 838: return "OCE/ CO2 atmosphere level 1 conc"; + case 840: return "OCE/ Total temperature advection, zonal."; + case 841: return "OCE/ Total temperature diffusion, zonal."; + case 850: return "OA/ Surface height analysis weights"; + case 851: return "OA/ Mixed layer depth analysis weights"; + case 852: return "OA/ Surface temperature analysis weights"; + case 853: return "OA/ Potential temperature analysis weights"; + case 854: return "OA/ Salinity analysis weights"; + case 855: return "OA/ Velocity components analysis weights"; + case 860: return "OA/ Surface height analysis increments"; + case 861: return "OA/ Mixed layer depth analysis increments"; + case 862: return "OA/ Surface temperature analysis increments"; + case 863: return "OA/ Potential temperature analysis increments"; + case 864: return "OA/ Salinity analysis increments"; + case 865: return "OA/ Zonal velocity analysis increments"; + case 870: return "OA/ Meridional velocity analysis increments"; + case 871: return "OA/ Meridional velocity increments after surface height analysis"; + case 872: return "OA/ Meridional velocity increments after thermal analysis"; + case 873: return "OA/ Meridional velocity increments after saline analysis"; + case 876: return "OA/ Zonal velocity increments after surface height analysis"; + case 877: return "OA/ Zonal velocity increments after thermal analysis"; + case 878: return "OA/ Zonal velocity increments after saline analysis"; + case 880: return "OA/ Pressure increments after surface height analysis"; + case 881: return "OA/ Pressure increments after thermal analysis"; + case 882: return "OA/ Pressure increments after saline analysis"; + case 885: return "OA/ Potential temperature increments after surface height analysis"; + case 888: return "OA/ Saline increments after surface height analysis"; + case 891: return "OCE/ PRIMARY PRODUCTION (GC/M2/DAY)"; + case 892: return "OCE/ ZOOPLTN PRODUCTION (GC/M2/DAY)"; + case 893: return "OCE/ PHYTO SPECIFIC GROWTH RATE (1/DAY)"; + case 894: return "OCE/ PHYTO SPECIFIC GRAZING RATE (1/DAY)"; + case 895: return "OCE/ PHYTO SPECIFIC MORTALITY (1/DAY)"; + case 896: return "OCE/ NITRATE GAIN-EXCRETION (MMOL-N/M2/D)"; + case 897: return "OCE/ NITRATE LOSS - GROWTH (MMOL-N/M2/D)"; + case 898: return "OCE/ NITRATE GAIN-PHY MORT (MMOL-N/M2/D)"; + case 899: return "OCE/ NITRATE GAIN-ZOO MORT (MMOL-N/M2/D)"; + case 900: return "OCE/ NITRATE GAIN-PHY RESP (MMOL-N/M2/D)"; + case 901: return "OCE/ NITRATE GAIN-REMIN (MMOL-N/M2/D)"; + case 902: return "OCE/ NUTRIENT LIMITATION"; + case 903: return "OCE/ LIGHT LIMITATION"; + case 904: return "OCE/ TEMPERATURE LIMITATION"; + case 905: return "OCE/ DETRITUS FLUX (MMOL-N/M2/D)"; + case 906: return "OCE/ VERTICAL NITRATE FLUX (MMOL-N/M2/D)"; + case 907: return "OCE/ HORIZ NITRATE ADVECT RATE(MMOL/M3/D)"; + case 908: return "OCE/ VERT NITRATE ADVECTN RATE(MMOL/M3/D)"; + case 909: return "OCE/ HORIZ NITRATE DIFFUSION (MMOL/M3/D)"; + case 910: return "OCE/ VERT NITRATE DIFFUSION (MMOL/M3/D)"; + case 911: return "OCE/ NITRATE MIXING DUE TO MLM(MMOL/M3/D)"; + case 912: return "OCE/ NITRATE CONVECTION (MMOL/M3/D)"; + case 913: return "OCE/ NITRATE CHANGE - BIOLOGY (MMOL/M3/D)"; + case 914: return "OCE/ NITRATE CHANGE-RESETTING (MMOL/M3/D)"; + case 915: return "OCE/ HORIZ PHYTO ADVECT RATE(MMOL-N/M3/D)"; + case 916: return "OCE/ HORIZ ZOO ADVECT RATE(MMOL-N/M3/D)"; + case 917: return "OCE/ HORIZ DETRI ADVECT RATE(MMOL-N/M3/D)"; + case 918: return "OCE/ Rate of change of sea-ice concentration"; + case 919: return "OCE/ Rate of change of sea-ice depth"; + case 920: return "OCE/ Rate of change of snowdepth on sea-ice"; + case 940: return "OCE/ Total temperature advection, meridional."; + case 941: return "OCE/ Total temperature diffusion, meridional."; + case 942: return "OCE/ Mmeridional overturning streamfunction/Sv"; + case 1301: return "BL flux of atmospheric tracer 1 (conventionally O3)"; + case 1302: return "BL flux of atmospheric tracer 2 (conventionally H2O)"; + case 1303: return "BL flux of atmospheric tracer 3 (conventionally CO)"; + case 1304: return "BL flux of atmospheric tracer 4 (conventionally CH4)"; + case 1305: return "BL flux of atmospheric tracer 5 (conventionally N2O)"; + case 1306: return "BL flux of atmospheric tracer 6 (conventionally NO)"; + case 1307: return "BL flux of atmospheric tracer 7 (conventionally NO2)"; + case 1308: return "BL flux of atmospheric tracer 8 (conventionally HNO3)"; + case 1309: return "BL flux of atmospheric tracer 9 (conventionally N2O5)"; + case 1310: return "BL flux of atmospheric tracer 10 (conventionally ClONO2)"; + case 1311: return "BL flux of atmospheric tracer 11 (conventionally ClO)"; + case 1312: return "BL flux of atmospheric tracer 12 (conventionally HCl)"; + case 1313: return "BL flux of atmospheric tracer 13 (conventionally CF2Cl2)"; + case 1314: return "BL flux of atmospheric tracer 14 (conventionally CFCl3)"; + case 1315: return "BL flux of atmospheric tracer 15 (conventionally HF)"; + case 1316: return "BL flux of atmospheric tracer 16"; + case 1317: return "BL flux of atmospheric tracer 17"; + case 1318: return "BL flux of atmospheric tracer 18"; + case 1319: return "BL flux of atmospheric tracer 19 (conventionally SO2)"; + case 1320: return "BL flux of atmospheric tracer 20 (conventionally DMS)"; + case 1321: return "BL flux of atmospheric tracer 21 (conventionally H2S)"; + case 1322: return "BL flux of atmospheric tracer 22 (conventionally WATER-SOLUBLE)"; + case 1323: return "BL flux of atmospheric tracer 23 (conventionally DUST-LIKE)"; + case 1324: return "BL flux of atmospheric tracer 24 (conventionally OCEANIC)"; + case 1325: return "BL flux of atmospheric tracer 25 (conventionally SOOT)"; + case 1326: return "BL flux of atmospheric tracer 26 (conventionally VOLCANIC ASH)"; + case 1327: return "BL flux of atmospheric tracer 27 (conventionally SULPHURIC ACID)"; + case 1328: return "BL flux of atmospheric tracer 28 (conventionally AMMONIUM SULPHATE)"; + case 1329: return "BL flux of atmospheric tracer 29 (conventionally MINERAL)"; + case 1330: return "BL flux of atmospheric total aerosol"; + case 1332: return "Ice Possible (0- -20 Celcius, RH =>70%) 1.0=possible;0.0 not"; + case 1333: return "Liquid water in any region averaged during all-sky conditions"; + case 1334: return "q*w (specific humidity * vertical velocity)"; + case 1335: return "Fraction of time pressure level is above model surface"; + case 1336: return "U * geopotential height"; + case 1337: return "V * geopotential height"; + case 1338: return "Virtual temperature"; + case 1339: return "Saturation mixing ratio"; + case 1370: return "SO4 aerosol: Aitken mode. Units: mass mixing ratio"; + case 1371: return "SO4 aerosol: accumulation mode. Units: mass mixing ratio"; + case 1372: return "SO4 aerosol: dissolved mode. Units: mass mixing ratio"; + case 1373: return "SO4 aerosol: DMS mass mixing ratio"; + case 1374: return "SO4 aerosol: SO2 mass mixing ratio"; + case 1375: return "SO4 Methyl Sulphonic Acid mass mixing ratio"; + case 1376: return "SO4 aerosol: column mass loading"; + case 1377: return "SO4 aerosol: SW radiative forcing"; + case 1379: return "NH3 gas mass mass mix ratio"; + case 1380: return "Van-Genuchten B parameter"; + case 1381: return "Clapp-Hornberger B exponent"; + case 1382: return "Leaf area index of vegetated fraction"; + case 1383: return "Canopy height of vegetated fraction"; + case 1384: return "Canopy conductance"; + case 1385: return "Unfrozen soil moisture fraction"; + case 1386: return "Frozen soil moisture fraction"; + case 1387: return "Transpiration"; + case 1388: return "Gross Primary Productivity"; + case 1389: return "Net Primary Productivity"; + case 1390: return "Plant Respiration"; + case 1391: return "Fractional covering of functional types"; + case 1392: return "LAI of veg functional types"; + case 1393: return "Canopy height of vegetation functional types"; + case 1394: return "Disturbed fraction of vegetation"; + case 1395: return "Soil albedo"; + case 1396: return "Snow soot"; + case 1397: return "Soil carbon content"; + case 1398: return "Accumulated net primary productivity on tiles"; + case 1399: return "Mountain torque per unit area"; + case 1400: return "Surface dry deposition flux of SO2"; + case 1401: return " Surface dry deposition flux of SO4 Aitken mode"; + case 1402: return "Surface dry deposition flux of SO4 ACCUMULATION mode"; + case 1403: return "Surface dry deposition flux of SO4 DISSOLVED mode"; + case 1404: return "RESIST_B for SO2"; + case 1405: return "RESIST_B for SO2 Aitken mode"; + case 1406: return "RESIST_B for SO2 ACCUMULATION mode"; + case 1407: return "RESIST_B for SO2 DISSOLVED mode"; + case 1408: return "RESIST_S for SO2"; + case 1409: return "RESIST_S for SO2 Aitken mode"; + case 1410: return "RESIST_S for SO2 ACCUMULATION mode"; + case 1411: return "RESIST_S for SO2 DISSOLVED mode"; + case 1412: return "Dry deposition velocity for SO2"; + case 1413: return "Dry deposition velocity for SO4 Aitken mode"; + case 1414: return "Dry deposition velocity for SO4 ACCUMULATION mode"; + case 1415: return "Dry deposition velocity for SO4 DISSOLVED mode"; + case 1416: return "Aerodynamic resistance 1/CDSTD after TSTEP"; + case 1417: return "SO2 scavenged by convective precipitation kg(S)/m2/tstep"; + case 1418: return "SO4 Aitken scavenged by convective precipitation kg(S)/m2/tstep"; + case 1419: return "SO4 accumulation scavenged by convective precipitation kg(S)/m2/tstep"; + case 1420: return "SO4 dissolved scavenged by convective precipitation kg(S)/m2/tstep"; + case 1421: return "SO2 scavenged by large scale precipitation kg(S)/m2/tstep"; + case 1422: return "SO4 Aitken scavenged by large scale precipitation kg(S)/m2/tstep"; + case 1423: return "SO4 accumulation scavenged by large scale precipitation kg(S)/m2/tstep"; + case 1424: return "SO4 dissolved scavenged by large scale precipitation kg(S)/m2/tstep"; + case 1425: return "Layer liquid cloud amount in layers"; + case 1426: return "Layer frozen cloud amount in layers"; + case 1427: return "Layer cloud frequency in each layer"; + case 1428: return "Net energy change this period"; + case 1429: return "Thickness"; + case 1430: return "Thickness tendency"; + case 1431: return "du/dp"; + case 1432: return "dv/dp"; + case 1433: return "dtheta/dp"; + case 1434: return "dtheta_e/dp"; + case 1435: return "Moist PV"; + case 1436: return "Magnitude Geostrophic Deformation"; + case 1437: return "EW cpt, Geostrophic deformation axis"; + case 1438: return "NS cpt, Geostrophic deformation axis"; + case 1439: return "Magnitude Grad(ThetaW)"; + case 1440: return "EW cpt Grad(ThetaW)"; + case 1441: return "NS cpt Grad(ThetaW)"; + case 1442: return "Geostrophic Deformation wrt ThetaW"; + case 1443: return "Geostrophic Relative Vorticity"; + case 1444: return "Magnitude Grad(Theta)"; + case 1445: return "EW cpt Grad(Theta)"; + case 1446: return "NS cpt Grad(Theta)"; + case 1447: return "Omega eqn. inversion with diabatic forcing"; + case 1448: return "Omega eqn. inversion with divQ & diabatic forcing"; + case 1449: return "Omega eqn. inversion with divQ only"; + case 1450: return "Omega eqn. inversion with divQ 800-600mb"; + case 1451: return "Omega eqn. inversion with divQ 600-100mb"; + case 1452: return "Omega eqn. inversion with divQ 1000-800mb"; + case 1453: return "DelSqd(ThetaW)"; + case 1454: return "Local value of magnitude of grad(ThetaW)"; + case 1455: return "Theta Frontal Speed - advection of magnitude (theta_w)"; + case 1456: return "Advection of theta_w"; + case 1457: return "Geostrophic advection of theta_w"; + case 1458: return "DelSqd(Theta)"; + case 1459: return "Local value of magnitude of grad(Theta)"; + case 1460: return "Theta Frontal Speed - advection of magnitude (theta)"; + case 1461: return "Advection of theta"; + case 1462: return "Geostrophic advection of theta"; + case 1463: return "Ambient noise"; + case 1464: return "Droplet number conc * cloud amount"; + case 1465: return "Layer cloud lwc * cloud amount"; + case 1466: return "SO4 ccn mass conc * cond samp weight"; + case 1467: return "Conditional sampling weight"; + case 1468: return "2-D effective radius * 2-D re weight"; + case 1469: return "Weight for 2-D effective radius"; + case 1470: return "Advection of mixing ratio"; + case 1471: return "Advection of dew point temperature"; + case 1472: return "Advection of relative humidity"; + case 1473: return "Advection of relative vorticity"; + case 1474: return "Advection of absolute vorticity"; + case 1475: return "X Component of Isallobaric Wind"; + case 1476: return "Y Component of Isallobaric Wind"; + case 1477: return "Scalar Divergence"; + case 1478: return "Showalter index (an instability index)"; + case 1479: return "Total total index (an instability index)"; + case 1480: return "Sweat index (an instability index)"; + case 1481: return "Lifted index (an instability index)"; + case 1482: return "Cape (convective available potential energy)"; + case 1483: return "k index (an instability index)"; + case 1484: return "Saturation vapour pressure"; + case 1485: return "Modified refractivity index, M (M units)"; + case 1486: return "Vertical gradient of modified refractivity, dM/dz (M/km)"; + case 1487: return "Minimum of dM/dz with height (M/km)"; + case 1488: return "Maximum of dM/dz with height (M/km)"; + case 1489: return "Radar duct intensity (max wavelength trapped)"; + case 1490: return "Refractivity index, N (N units)"; + case 1491: return "Fresh soot mass mix ratio"; + case 1492: return "Aged soot mass mix ratio"; + case 1493: return "Soot in cloud mix ratio"; + case 1494: return "SO4 Aitken surface settlement flux"; + case 1495: return "SO4 Accumulation surface settlement flux"; + case 1496: return "MSA (methyl sulphonic acid) mass mixing ratio after tstep"; + case 1497: return "NH3 (ammonia) depletion after tstep"; + case 1498: return "Ship noise (from passing ships)"; + case 1499: return "Leaf turnover rate of plant functional types"; + case 1500: return "Accumulated leaf turnover rate on PFTs"; + case 1501: return "Accumulated phenological leaf turnover rate on PFTs"; + case 1502: return "Accumulated wood respiration on PFTs"; + case 1503: return "Accumulated soil respiration"; + case 1504: return "Canopy & surface water content on tiles"; + case 1505: return "Canopy & surface capacity on tiles"; + case 1506: return "Infiltration enhancement factor on tiles"; + case 1507: return "Snow grain size (microns)"; + case 1508: return "Snow temperature"; + case 1509: return "Radiative surface temperature"; + case 1510: return "Surface temperature on tiles"; + case 1511: return "Roughness length on tiles"; + case 1512: return "Vegetation carbon on Plant Functional Types (PFTs)"; + case 1513: return "Gridbox mean vegetation carbon"; + case 1514: return "Phenological leaf turnover rate on PFTs"; + case 1515: return "Litter carbon on Plant Functional Types (PFTs)"; + case 1516: return "Gridbox mean litter carbon"; + case 1517: return "Canopy evaporation on tiles"; + case 1518: return "Evapotranspiration from the soil"; + case 1519: return "Gross primary productivity on plant functional types"; + case 1520: return "Sensible heat flux on tiles"; + case 1521: return "Net primary productivity on plant functional types"; + case 1522: return "Plant respiration on plant functional types"; + case 1523: return "Soil respiration"; + case 1524: return "Bulk Richardson number on tiles"; + case 1525: return "Fractional snow cover"; + case 1526: return "Rate of evaporation from soil surface"; + case 1527: return "Rate of evaporation from canopy"; + case 1528: return "Rate of sublimation from surface (gridbox mean)"; + case 1529: return "Rate of transpiration"; + case 1530: return "Rate of snow melt on land"; + case 1531: return "Rate of canopy throughfall"; + case 1532: return "Rate of surface runoff"; + case 1533: return "Rate of sub-surface runoff"; + case 1534: return "Turbulent mixing ht after Boundary Layer"; + case 1535: return "Stable BL indicator"; + case 1536: return "Stratocumulus over stable BL indicator"; + case 1537: return "Well_mixed BL indicator"; + case 1538: return "Decoupled SC not over CU indicator"; + case 1539: return "Decoupled SC over CU indicator"; + case 1540: return "Cumulus-capped BL indicator"; + case 1541: return "NH3 Surface dry deposition flux"; + case 1542: return "Fresh soot surface dry deposition flux"; + case 1543: return "Aged soot surface dry deposition flux"; + case 1544: return "Soot in cloud occult deposition flux"; + case 1545: return "NH3 scavenged by large scale precipitation"; + case 1546: return "Soot scavenged by large scale precipitation"; + case 1547: return "SO2 scavenged by large scale precipitation"; + case 1548: return "SO4 Aitken scavenged by large scale precipitation"; + case 1549: return "SO4 accumulation scavenged by large scale precipitation"; + case 1550: return "SO4 dissolved scavenged by large scale precipitation"; + case 1551: return "NH3 scavenged by convective precipitation"; + case 1552: return "Soot scavenged by convective precipitation"; + case 1553: return "SO2 scavenged by convective precipitation"; + case 1554: return "SO4 Aitken scavenged by convective precipitation"; + case 1555: return "SO4 accumulation scavenged by convective precipitation"; + case 1556: return "SO4 dissolved scavenged by convective precipitation"; + case 1557: return "Potential evaporation amount"; + case 1558: return "Potential evaporation rate"; + case 1559: return "Soil moisture availability factor"; + case 1560: return "CO2 ocean flux"; + case 1561: return "CO2 surface emissions"; + case 1562: return "CO2 land surface flux"; + case 1563: return "CO2 total flux to atmosphere"; + case 1564: return "Precipitation rate codes for symbol plotting"; + case 1565: return "Present Weather codes (ww-code)"; + case 1566: return "T before dynamics"; + case 1567: return "T after dynamics"; + case 1568: return "q before dynamics"; + case 1569: return "q after dynamics"; + case 1570: return "x component of E vector = (v**2 - u**2)"; + case 1571: return "y component of E vector = -uv"; + case 1572: return "z component of E vector - proportional to vT"; + case 1573: return "Supercooled liquid water content"; + case 1574: return "Supercooled rain"; + case 1575: return "Rain fraction"; + case 1577: return "Accumulated precipitation for 6 hours (for fieldsfiles, 1998)"; + case 1578: return "Modified maximum gravity wave stress magnitude"; + case 1579: return "U in the GWD surface layer"; + case 1580: return "V in the GWD surface layer"; + case 1581: return "N in the GWD surface layer"; + case 1582: return "GWD surface Froude number"; + case 1583: return "GWD Blocked Layer Depth"; + case 1584: return "Percent of hydro GWD that is linear"; + case 1585: return "Percent of time with Hydr. Jumps"; + case 1586: return "Percent of time with Lee Waves"; + case 1587: return "Percent of time with blocked flow"; + case 1588: return "x component of GW saturation stress"; + case 1589: return "y component of GW saturation stress"; + case 1590: return "x component of GW jump stress"; + case 1591: return "y component of GW jump stress"; + case 1592: return "x component of GW wake stress"; + case 1593: return "y component of GW wake stress"; + case 1594: return "x component of GW lee stress"; + case 1595: return "y component of GW lee stress"; + case 1596: return "u-accel from GWD blocked flow"; + case 1597: return "v-accel from GWD blocked flow"; + case 1600: return "Net surface water flux"; + case 1601: return "Pressure tendency"; + case 1602: return "X Component of Thermal Wind"; + case 1603: return "Y Component of Thermal Wind"; + case 1604: return "Saturated specific humidity"; + case 1605: return "Isallobaric direction ( true )"; + case 1606: return "Isallobaric wind speed"; + case 1607: return "Geostrophic wind direction ( true )"; + case 1608: return "Geostrophic wind speed"; + case 1609: return "Thermal wind direction ( true )"; + case 1610: return "ISCCP C2 high thin cloud amount"; + case 1611: return "ISCCP C2 high medium cloud amount"; + case 1612: return "ISCCP C2 high thick cloud amount"; + case 1613: return "ISCCP C2 mid-level thin cloud amount"; + case 1614: return "ISCCP C2 mid-level thick cloud amount"; + case 1615: return "ISCCP C2 low thin cloud amount"; + case 1616: return "ISCCP C2 low thick cloud amount"; + case 1617: return "Sea Surface Temperature (SST) minus Dew point (for forecasting sea fog)"; + case 1618: return "500-850 Potential Instability Index (measure of thunder risk)"; + case 1619: return "Boyden Index"; + case 1620: return "Height of 2 deg C isotherm in feet (Navy requirement)"; + case 1621: return "Casswell maximum vertical velocity (for NMC)"; + case 1622: return "Casswell height of maximum vertical velocity (for NMC)"; + case 1623: return "Pseudo WV image from Horace - estimated radiance received"; + case 1624: return "Pseudo IR image from Horace - estimated radiance received"; + case 1625: return "Frequency unit type: 1=Hz (eg for noise fields)"; + case 1626: return "Areal fraction of intensive grassland"; + case 1627: return "Areal fraction of extensive grassland"; + case 1682: return "Cape inhibition"; + case 1690: return "C.A.T. probability derived from fieldsfiles, not model"; + case 1701: return "OD"; + case 1702: return "OP"; + case 1703: return "OH"; + case 1704: return "NO"; + case 1705: return "NO2"; + case 1706: return "NO3"; + case 1707: return "N2O5"; + case 1708: return "CO"; + case 1709: return "CH4"; + case 1710: return "HCHO"; + case 1711: return "O3"; + case 1712: return "H2"; + case 1713: return "HNO3"; + case 1714: return "H2O2"; + case 1715: return "CH3O2"; + case 1716: return "HO2"; + case 1717: return "C2H6"; + case 1718: return "C2H5O2"; + case 1719: return "CH3CHO"; + case 1720: return "CH3COO2"; + case 1721: return "PAN"; + case 1722: return "CH3OOH"; + case 1723: return "NC4H10"; + case 1724: return "SC4H9O2"; + case 1725: return "CH3COE"; + case 1726: return "C2H4"; + case 1727: return "C3H6"; + case 1728: return "C3H8"; + case 1729: return "C3H7O2"; + case 1730: return "C3H7OOH"; + case 1731: return "C2H5OOH"; + case 1732: return "C4H9OOH"; + case 1733: return "CH3OH"; + case 1734: return "ACETONE"; + case 1735: return "ACETO2"; + case 1736: return "CH3COX"; + case 1737: return "CH2O2C"; + case 1738: return "MGLYOX"; + case 1739: return "CH3CHX"; + case 1740: return "C5H8"; + case 1741: return "RO2IP1"; + case 1742: return "MVK"; + case 1743: return "RO2IP2"; + case 1744: return "ISOPOOH"; + case 1745: return "MVKOOH"; + case 1746: return "RNC2H4"; + case 1747: return "RNC3H6"; + case 1748: return "RNC5H8"; + case 1749: return "NAER"; + case 1750: return "HO2NO2"; + case 1751: return "H2O"; + case 1752: return "EXTRA"; + } + return NULL; +} + + +/* returns string, or NULL if not matched */ +char *pp_ppshortname(int code) +{ + switch (code) { + case 0: return "unspecified"; + case 1: return "ht"; + case 2: return "depth"; + case 3: return "zg"; + case 4: return "icaoht"; + case 5: return "blht"; + case 8: return "p"; + case 9: return "hybrid_p"; + case 10: return "sigma"; + case 11: return "Tu"; + case 12: return "Tv"; + case 13: return "TT"; + case 14: return "Tomega"; + case 15: return "htht"; + case 16: return "temp"; + case 19: return "theta"; + case 23: return "soiltemp"; + case 24: return "dtheta_dt"; + case 28: return "dpstar_dt"; + case 34: return "convcld"; + case 37: return "iceconc"; + case 38: return "lsm"; + case 39: return "f"; + case 40: return "omega"; + case 41: return "Tw"; + case 42: return "dz_dt"; + case 43: return "eta_dot"; + case 44: return "time"; + case 45: return "dsigma_dt"; + case 46: return "uq"; + case 47: return "vq"; + case 48: return "x-wind"; + case 49: return "y-wind"; + case 50: return "wind"; + case 53: return "uomega"; + case 54: return "vomega"; + case 56: return "u"; + case 57: return "v"; + case 58: return "uu"; + case 59: return "vv"; + case 60: return "uv"; + case 61: return "taux"; + case 62: return "tauy"; + case 63: return "ke"; + case 65: return "hybrid_ht"; + case 72: return "avor"; + case 73: return "rvor"; + case 74: return "div"; + case 77: return "tot_precip"; + case 78: return "QCF"; + case 79: return "QCL"; + case 80: return "psi"; + case 81: return "chi"; + case 82: return "pv"; + case 84: return "Q"; + case 85: return "M"; + case 87: return "dq_dt"; + case 88: return "rh"; + case 90: return "precip"; + case 93: return "snowdepth"; + case 94: return "cvrain"; + case 95: return "q"; + case 96: return "water"; + case 97: return "rain"; + case 98: return "cvrain"; + case 99: return "lsrain"; + case 100: return "cvrain"; + case 101: return "mix"; + case 102: return "lsrain"; + case 103: return "snow"; + case 104: return "rain"; + case 105: return "evap"; + case 106: return "sm"; + case 107: return "sublim"; + case 108: return "snow"; + case 109: return "runoff"; + case 110: return "snowmelt"; + case 111: return "fastrunoff"; + case 112: return "slowrunoff"; + case 113: return "pme"; + case 114: return "evap"; + case 115: return "evap"; + case 116: return "lssnow"; + case 117: return "cvsnow"; + case 118: return "lssnow"; + case 119: return "cvsnow"; + case 120: return "lsp"; + case 121: return "cvp"; + case 122: return "sm"; + case 123: return "uacc"; + case 124: return "vacc"; + case 127: return "sbl"; + case 128: return "msl"; + case 129: return "surface"; + case 130: return "Trop"; + case 131: return "mwl"; + case 132: return "fl"; + case 133: return "toa"; + case 134: return "-20_deg.C"; + case 135: return "ul_ht"; + case 136: return "ll_ht"; + case 137: return "ul_p"; + case 138: return "ll_p"; + case 139: return "wbfl"; + case 140: return "salinity"; + case 142: return "ul_hy"; + case 143: return "ll_hy"; + case 156: return "03"; + case 158: return "03"; + case 176: return "lat"; + case 177: return "long"; + case 178: return "sh"; + case 180: return "lh"; + case 182: return "wme"; + case 186: return "solar"; + case 187: return "longwave"; + case 205: return "ilr"; + case 206: return "olr"; + case 210: return "csolr"; + case 211: return "csilr"; + case 213: return "CAPE"; + case 218: return "convcldwater"; + case 220: return "cldamount"; + case 222: return "convcldbase"; + case 223: return "convcldtop"; + case 240: return "csolr"; + case 241: return "csilr"; + case 245: return "cshr"; + case 246: return "csswhr"; + case 247: return "cslwhr"; + case 250: return "cshr"; + case 251: return "swhr"; + case 252: return "csswhr"; + case 253: return "lwhr"; + case 254: return "cslwhr"; + case 260: return "topmelt"; + case 261: return "botmelt"; + case 285: return "evap"; + case 395: return "lsm"; + case 452: return "N20"; + case 453: return "O3"; + case 501: return "tracer1"; + case 502: return "tracer2"; + case 503: return "tracer3"; + case 504: return "tracer4"; + case 505: return "tracer5"; + case 506: return "tracer6"; + case 507: return "tracer7"; + case 508: return "tracer8"; + case 509: return "tracer9"; + case 510: return "tracer10"; + case 511: return "tracer11"; + case 512: return "tracer12"; + case 513: return "tracer13"; + case 514: return "tracer14"; + case 515: return "tracer15"; + case 516: return "tracer16"; + case 517: return "tracer17"; + case 518: return "tracer18"; + case 519: return "tracer19"; + case 520: return "tracer20"; + case 521: return "tracer21"; + case 522: return "tracer22"; + case 523: return "tracer23"; + case 524: return "tracer24"; + case 525: return "tracer25"; + case 526: return "tracer26"; + case 527: return "tracer27"; + case 528: return "tracer28"; + case 529: return "tracer29"; + case 601: return "temp"; + case 602: return "salinity"; + case 603: return "temp"; + case 604: return "temp"; + case 605: return "salinity"; + case 623: return "snowfall"; + case 624: return "sublim"; + case 625: return "SOL"; + case 626: return "HTN"; + case 627: return "WME"; + case 629: return "PLE"; + case 631: return "outflow"; + case 633: return "ISX"; + case 634: return "ISY"; + case 637: return "insitu_T"; + case 649: return "salinity"; + case 650: return "SST"; + case 680: return "W"; + case 681: return "topmelt"; + case 682: return "botmelt"; + case 683: return "iceconc"; + case 687: return "icedepth"; + case 688: return "snowdepth"; + case 701: return "ucurr"; + case 702: return "vcurr"; + case 721: return "TAUX"; + case 722: return "TAUY"; + case 801: return "otracer1"; + case 802: return "otracer2"; + case 803: return "otracer3"; + case 804: return "otracer4"; + case 805: return "otracer5"; + case 806: return "otracer6"; + case 807: return "otracer7"; + case 808: return "otracer8"; + case 809: return "otracer9"; + case 810: return "otracer10"; + case 811: return "otracer11"; + case 812: return "otracer12"; + case 813: return "otracer13"; + case 814: return "otracer14"; + case 815: return "otracer15"; + case 816: return "otracer16"; + case 817: return "otracer17"; + case 818: return "otracer18"; + case 1334: return "qomega"; + case 1335: return "psag"; + case 1336: return "uzg"; + case 1337: return "vzg"; + case 1338: return "vtemp"; + case 1508: return "temp"; + case 1509: return "temp"; + case 1510: return "temp"; + case 1566: return "temp"; + case 1567: return "temp"; + case 1568: return "q"; + case 1569: return "q"; + case 1701: return "OD"; + case 1702: return "OP"; + case 1703: return "OH"; + case 1704: return "NO"; + case 1705: return "NO2"; + case 1706: return "NO3"; + case 1707: return "N2O5"; + case 1708: return "CO"; + case 1709: return "CH4"; + case 1710: return "HCHO"; + case 1711: return "O3"; + case 1712: return "H2"; + case 1713: return "HNO3"; + case 1714: return "H2O2"; + case 1715: return "CH3O2"; + case 1716: return "HO2"; + case 1717: return "C2H6"; + case 1718: return "C2H5O2"; + case 1719: return "CH3CHO"; + case 1720: return "CH3COO2"; + case 1721: return "PAN"; + case 1722: return "CH3OOH"; + case 1723: return "NC4H10"; + case 1724: return "SC4H9O2"; + case 1725: return "CH3COE"; + case 1726: return "C2H4"; + case 1727: return "C3H6"; + case 1728: return "C3H8"; + case 1729: return "C3H7O2"; + case 1730: return "C3H7OOH"; + case 1731: return "C2H5OOH"; + case 1732: return "C4H9OOH"; + case 1733: return "CH3OH"; + case 1734: return "ACETONE"; + case 1735: return "ACETO2"; + case 1736: return "CH3COX"; + case 1737: return "CH2O2C"; + case 1738: return "MGLYOX"; + case 1739: return "CH3CHX"; + case 1740: return "C5H8"; + case 1741: return "RO2IP1"; + case 1742: return "MVK"; + case 1743: return "RO2IP2"; + case 1744: return "ISOPOOH"; + case 1745: return "MVKOOH"; + case 1746: return "RNC2H4"; + case 1747: return "RNC3H6"; + case 1748: return "RNC5H8"; + case 1749: return "NAER"; + case 1750: return "HO2NO2"; + case 1751: return "H2O"; + case 1752: return "EXTRA"; + } + return NULL; +} + +/* returns string, or NULL if not matched */ +char *pp_ppunit(int code) +{ + switch (code) { + case 0: return "unspecified"; + case 1: return "m"; + case 2: return "m"; + case 3: return "m2 s-2"; + case 4: return "kft"; + case 5: return "m"; + case 6: return "level"; + case 7: return "Pa"; + case 8: return "Pa"; + case 9: return "level"; + case 10: return "sigma_level"; + case 11: return "K m s-1"; + case 12: return "K m s-1"; + case 13: return "K2"; + case 14: return "K Pa s-1"; + case 15: return "m2"; + case 16: return "K"; + case 17: return "K"; + case 18: return "K"; + case 19: return "K"; + case 20: return "K"; + case 21: return "K"; + case 22: return "K"; + case 23: return "K"; + case 24: return "K s-1"; + case 25: return "m"; + case 26: return "s-1"; + case 27: return "kg m-3"; + case 28: return "Pa s-1"; + case 30: return "0-1"; + case 35: return "kft"; + case 36: return "0-1"; + case 37: return "0-1"; + case 39: return "s-1"; + case 40: return "Pa s-1"; + case 41: return "K"; + case 42: return "m s-1"; + case 43: return "s-1"; + case 44: return "s"; + case 45: return "s-1"; + case 46: return "m kg s-1 kg-1"; + case 47: return "m kg s-1 kg-1"; + case 48: return "m s-1"; + case 49: return "m s-1"; + case 50: return "m s-1"; + case 51: return "m s-1"; + case 53: return "m Pa s-2"; + case 54: return "m Pa s-2"; + case 55: return "degrees"; + case 56: return "m s-1"; + case 57: return "m s-1"; + case 58: return "m2 s-2"; + case 59: return "m2 s-2"; + case 60: return "m2 s-2"; + case 61: return "N m-2"; + case 62: return "N m-2"; + case 63: return "J"; + case 65: return "level"; + case 68: return "m s-2"; + case 69: return "m s-2"; + case 70: return "m s-2"; + case 71: return "m s-2"; + case 72: return "s-1"; + case 73: return "s-1"; + case 74: return "s-1"; + case 75: return "feet"; + case 76: return "feet"; + case 77: return "kg m-2"; + case 78: return "kg kg-1"; + case 79: return "kg kg-1"; + case 80: return "m2 s-1"; + case 81: return "m2 s-1"; + case 82: return "K m2 s-1 kg-1"; + case 84: return "K m2 s-1 kg-1"; + case 85: return "m2 s-2"; + case 86: return "s-1"; + case 87: return "kg kg-1 s-1"; + case 89: return "kg m-2"; + case 90: return "kg m-2"; + case 91: return "m"; + case 92: return "m"; + case 93: return "kg m-2"; + case 94: return "kg m-2"; + case 95: return "kg kg-1"; + case 96: return "kg m-2"; + case 97: return "kg m-2 s-1"; + case 98: return "kg m-2 s-1"; + case 99: return "kg m-2 s-1"; + case 100: return "kg m-2 s-1"; + case 101: return "kg kg-1"; + case 102: return "kg m-2"; + case 103: return "kg m-2"; + case 104: return "kg m-2"; + case 105: return "kg m-2"; + case 106: return "kg m-2"; + case 107: return "kg m-2"; + case 108: return "kg m-2 s-1"; + case 109: return "kg m-2"; + case 110: return "kg m-2"; + case 111: return "kg m-2"; + case 112: return "kg m-2"; + case 113: return "kg m-2 s-1"; + case 114: return "kg m-2 s-1"; + case 115: return "kg m-2"; + case 116: return "kg m-2"; + case 117: return "kg m-2"; + case 118: return "kg m-2 s-1"; + case 119: return "kg m-2 s-1"; + case 120: return "kg m-2"; + case 121: return "kg m-2"; + case 122: return "kg m-2"; + case 123: return "m s-2"; + case 124: return "m s-2"; + case 126: return "level"; + case 127: return "level"; + case 128: return "level"; + case 129: return "level"; + case 130: return "level"; + case 131: return "level"; + case 132: return "level"; + case 133: return "level"; + case 134: return "level"; + case 135: return "kft"; + case 136: return "kft"; + case 137: return "mbar"; + case 138: return "mbar"; + case 139: return "m"; + case 140: return "kg kg-1"; + case 141: return "W m-2"; + case 142: return "level"; + case 143: return "level"; + case 148: return "m s-1"; + case 149: return "m s-1"; + case 150: return "m"; + case 151: return "m"; + case 155: return "m"; + case 156: return "kg m-2"; + case 158: return "Dobson"; + case 159: return "0-12"; + case 161: return "K"; + case 162: return "hr"; + case 173: return "0-1"; + case 175: return "m"; + case 176: return "degrees_north"; + case 177: return "degrees_east"; + case 178: return "W m-2"; + case 179: return "W m-2"; + case 180: return "W m-2"; + case 182: return "W m-2"; + case 184: return "kg m-2 s-1"; + case 185: return "kg m-2 s-1"; + case 186: return "W m-2"; + case 187: return "W m-2"; + case 188: return "W m-2"; + case 189: return "K (6hr)-1"; + case 190: return "0-1"; + case 191: return "0-1"; + case 193: return "K s-1"; + case 195: return "N m-2"; + case 196: return "N m-2"; + case 197: return "W m-2"; + case 198: return "m"; + case 199: return "m"; + case 200: return "W m-2"; + case 201: return "W m-2"; + case 202: return "W m-2"; + case 203: return "W m-2"; + case 205: return "W m-2"; + case 206: return "W m-2"; + case 207: return "W m-2"; + case 208: return "W m-2"; + case 209: return "K"; + case 210: return "W m-2"; + case 211: return "W m-2"; + case 213: return "J kg-1"; + case 214: return "W m-2"; + case 215: return "W m-2"; + case 216: return "kft"; + case 218: return "kg kg-1"; + case 219: return "kg m-2"; + case 220: return "0-1"; + case 228: return "K s-1"; + case 229: return "K kg m-2 s-1"; + case 230: return "K kg m-2 s-1"; + case 231: return "K kg m-2 s-1 kg-1"; + case 232: return "K kg m-2 s-1 kg-1"; + case 233: return "K kg m-2 s-1"; + case 234: return "K kg m-2 s-1"; + case 235: return "K kg m-2 s-1 kg-1"; + case 236: return "K kg m-2 s-1 kg-1"; + case 237: return "W m-2"; + case 238: return "W m-2"; + case 239: return "Pa"; + case 240: return "W m-2"; + case 241: return "W m-2"; + case 242: return "0-1"; + case 243: return "W m-2"; + case 244: return "W m-2"; + case 245: return "W m-2"; + case 246: return "K s-1"; + case 247: return "K s-1"; + case 248: return "m s-1"; + case 249: return "m s-1"; + case 250: return "K s-1"; + case 251: return "K s-1"; + case 252: return "K s-1"; + case 253: return "K s-1"; + case 254: return "K s-1"; + case 259: return "W m-2"; + case 260: return "W m-2"; + case 261: return "W m-2"; + case 262: return "0-1"; + case 263: return "N"; + case 264: return "N"; + case 265: return "N"; + case 266: return "N"; + case 267: return "kg s-3"; + case 268: return "kg s-3"; + case 269: return "kg2 s-3"; + case 270: return "kg2 s-3"; + case 271: return "kg m-2"; + case 272: return "kg m-2"; + case 273: return "kg m-2"; + case 274: return "kg m-2"; + case 275: return "m"; + case 276: return "Bq m-3"; + case 277: return "Bq s m-3"; + case 278: return "Bq m-2"; + case 279: return "Bq m-2"; + case 280: return "W m-2"; + case 281: return "W m-2"; + case 282: return "W m-2"; + case 283: return "W m-2"; + case 284: return "Bq m-2"; + case 285: return "kg m-2 s-1"; + case 286: return "micro g kg-1"; + case 287: return "micro g m-2 s-1"; + case 299: return "kg kg-1"; + case 303: return "Pa"; + case 304: return "K"; + case 305: return "m s-1"; + case 306: return "m s-1"; + case 308: return "0-1"; + case 310: return "kg m-2 s-1"; + case 315: return "kg kg-1"; + case 316: return "K"; + case 317: return "K"; + case 318: return "m s-1"; + case 319: return "m s-1"; + case 320: return "m"; + case 321: return "m"; + case 323: return "s m-1"; + case 324: return "m"; + case 325: return "kg m-2"; + case 326: return "0-1"; + case 333: return "kg m-2 s-1"; + case 335: return "J m-3 K-1"; + case 336: return "J m-1 K-1 s-1"; + case 342: return "m"; + case 343: return "kg m-2"; + case 344: return "Pa"; + case 345: return "Pa"; + case 346: return "kft"; + case 347: return "kft"; + case 348: return "K m2 s-1 kg-1"; + case 349: return "K m2 s-1 kg-1"; + case 350: return "K m s-1 kg-1"; + case 366: return "N m-2"; + case 367: return "m"; + case 370: return "m s-1"; + case 371: return "degrees"; + case 372: return "m"; + case 373: return "m s-1"; + case 374: return "degrees"; + case 375: return "m"; + case 376: return "s"; + case 377: return "m s-1"; + case 378: return "m"; + case 379: return "s"; + case 380: return "m s-1"; + case 384: return "K"; + case 385: return "m"; + case 386: return "m"; + case 387: return "m"; + case 388: return "s"; + case 389: return "radians"; + case 390: return "s"; + case 391: return "radians"; + case 393: return "s"; + case 394: return "radians"; + case 396: return "m"; + case 501: return "kg kg-1"; + case 502: return "kg kg-1"; + case 503: return "kg kg-1"; + case 504: return "kg kg-1"; + case 505: return "kg kg-1"; + case 506: return "kg kg-1"; + case 507: return "kg kg-1"; + case 508: return "kg kg-1"; + case 509: return "kg kg-1"; + case 510: return "kg kg-1"; + case 511: return "kg kg-1"; + case 512: return "kg kg-1"; + case 513: return "kg kg-1"; + case 514: return "kg kg-1"; + case 515: return "kg kg-1"; + case 516: return "kg kg-1"; + case 517: return "kg kg-1"; + case 518: return "kg kg-1"; + case 519: return "kg kg-1"; + case 520: return "kg kg-1"; + case 521: return "kg kg-1"; + case 522: return "kg kg-1"; + case 523: return "kg kg-1"; + case 524: return "kg kg-1"; + case 525: return "kg kg-1"; + case 526: return "kg kg-1"; + case 527: return "kg kg-1"; + case 528: return "kg kg-1"; + case 529: return "kg kg-1"; + case 572: return "kg m-2 s-1"; + case 573: return "kg m-2 s-1"; + case 601: return "degC"; + case 602: return "(psu-35)/1000"; + case 603: return "degC"; + case 604: return "degC"; + case 605: return "(psu-35)/1000"; + case 608: return "cm"; + case 609: return "kg m-3"; + case 610: return "m"; + case 611: return "cm3 s-1"; + case 612: return "cm3 s-1"; + case 613: return "cm3 s-1 ts-1"; + case 614: return "cm3 s-1 ts-1"; + case 617: return "Pa"; + case 618: return "s-2"; + case 619: return "m"; + case 620: return "W m-2"; + case 621: return "m"; + case 622: return "m"; + case 623: return "kg m-2 s-1"; + case 624: return "kg m-2 s-1"; + case 625: return "W m-2"; + case 626: return "W m-2"; + case 627: return "W m-2"; + case 628: return "W m-2"; + case 629: return "kg m-2 s-1"; + case 630: return "W m-2"; + case 631: return "kg m-2 s-1"; + case 632: return "m s-1"; + case 633: return "N m-2"; + case 634: return "N m-2"; + case 635: return "m-2 s-2"; + case 636: return "kg m-1 s-3"; + case 637: return "K"; + case 640: return "K s-1"; + case 641: return "K s-1"; + case 642: return "K s-1"; + case 643: return "K s-1"; + case 644: return "K s-1"; + case 645: return "K s-1"; + case 646: return "K s-1"; + case 647: return "K s-1"; + case 648: return "psu s-1"; + case 649: return "(psu-35)/1000"; + case 650: return "degC"; + case 651: return "W m-2"; + case 652: return "W m-2"; + case 653: return "m"; + case 654: return "m"; + case 655: return "J"; + case 656: return "J"; + case 657: return "m2 s-2"; + case 658: return "cm2 s-1"; + case 660: return "s-2"; + case 661: return "s-2"; + case 662: return "s-2"; + case 663: return "s-2"; + case 664: return "s-2"; + case 665: return "cm s-2"; + case 666: return "cm s-2"; + case 667: return "cm s-2"; + case 668: return "cm s-2"; + case 669: return "cm s-2"; + case 671: return "W m-2"; + case 672: return "kg m-2 s-1"; + case 675: return "m"; + case 676: return "kg m-2"; + case 677: return "Pa"; + case 678: return "W m-2"; + case 679: return "kg m-2 s-1"; + case 680: return "cm s-1"; + case 681: return "W m-2"; + case 682: return "W m-2"; + case 684: return "W m-2"; + case 685: return "W m-2"; + case 686: return "psu s-1"; + case 687: return "m"; + case 688: return "m"; + case 689: return "N m-2"; + case 690: return "N m-2"; + case 692: return "m"; + case 694: return "W m-2"; + case 698: return "W m-2"; + case 699: return "m"; + case 701: return "cm s-1"; + case 702: return "cm s-1"; + case 703: return "cm s-1"; + case 704: return "cm s-1"; + case 711: return "cm s-1"; + case 712: return "cm s-1"; + case 713: return "cm s-2"; + case 714: return "cm s-2"; + case 715: return "cm-1"; + case 718: return "m2 s-1"; + case 719: return "m2 s-1"; + case 721: return "N m-2"; + case 722: return "N m-2"; + case 728: return "m s-1"; + case 729: return "m s-1"; + case 730: return "m s-1"; + case 731: return "m s-1"; + case 732: return "m s-1"; + case 733: return "Pa"; + case 734: return "Pa"; + case 735: return "Pa"; + case 736: return "Pa"; + case 737: return "Pa"; + case 738: return "Pa"; + case 739: return "Pa"; + case 741: return "m s-2"; + case 742: return "m s-2"; + case 743: return "m s-2"; + case 744: return "m s-2"; + case 745: return "m s-2"; + case 746: return "m s-2"; + case 747: return "m s-2"; + case 748: return "m s-2"; + case 749: return "m s-2"; + case 750: return "m s-2"; + case 820: return "m"; + case 829: return "km"; + case 834: return "K s-1"; + case 835: return "m s-1"; + case 836: return "m"; + case 838: return "ppmv"; + case 918: return "s-1"; + case 919: return "m s-1"; + case 920: return "m s-1"; + case 1334: return "kg kg-1 Pa s-1"; + case 1335: return "0-1"; + case 1336: return "m3 s-3"; + case 1337: return "m3 s-3"; + case 1338: return "K"; + case 1370: return "kg kg-1"; + case 1371: return "kg kg-1"; + case 1372: return "kg kg-1"; + case 1373: return "kg kg-1"; + case 1374: return "kg kg-1"; + case 1375: return "kg kg-1"; + case 1376: return "kg m-2"; + case 1377: return "W m-2"; + case 1379: return "kg kg-1"; + case 1383: return "m"; + case 1393: return "m"; + case 1398: return "kg C m-2 s-1"; + case 1399: return "N m-1"; + case 1400: return "kg m-2 s-1"; + case 1401: return "kg m-2 s-1"; + case 1402: return "kg m-2 s-1"; + case 1403: return "kg m-2 s-1"; + case 1407: return "kg m-2 s-1"; + case 1428: return "J m2"; + case 1429: return "m"; + case 1430: return "m s-1"; + case 1431: return "m s-1 Pa-1"; + case 1432: return "m s-1 Pa-1"; + case 1433: return "K Pa-1"; + case 1434: return "K Pa-1"; + case 1435: return "K m2 s-1 kg-1"; + case 1489: return "cm"; + case 1491: return "kg kg-1"; + case 1492: return "kg kg-1"; + case 1493: return "kg kg-1"; + case 1494: return "kg m-2 s-1"; + case 1495: return "kg m-2 s-1"; + case 1496: return "kg kg-1"; + case 1497: return "kg kg-1"; + case 1499: return "360days"; + case 1500: return "s-1"; + case 1501: return "s-1"; + case 1502: return "kg C m-2 s-1"; + case 1503: return "kg C m-2 s-1"; + case 1504: return "kg m-2"; + case 1508: return "K"; + case 1509: return "K"; + case 1510: return "K"; + case 1511: return "m"; + case 1512: return "kg C m-2"; + case 1513: return "kg C m-2"; + case 1514: return "s-1"; + case 1515: return "kg C m-2 year-1"; + case 1516: return "kg C m-2 year-1"; + case 1517: return "kg m-2 s-1"; + case 1518: return "kg m-2 s-1"; + case 1519: return "kg C m-2 s-1"; + case 1520: return "W m-2"; + case 1521: return "kg C m-2 s-1"; + case 1522: return "kg C m-2 s-1"; + case 1523: return "kg C m-2 s-1"; + case 1525: return "0-1"; + case 1526: return "kg m-2 s-1"; + case 1527: return "kg m-2 s-1"; + case 1528: return "kg m-2 s-1"; + case 1529: return "kg m-2 s-1"; + case 1530: return "kg m-2 s-1"; + case 1531: return "kg m-2 s-1"; + case 1532: return "kg m-2 s-1"; + case 1533: return "kg m-2 s-1"; + case 1534: return "m"; + case 1541: return "kg m-2 s-1"; + case 1542: return "kg m-2 s-1"; + case 1543: return "kg m-2 s-1"; + case 1544: return "kg m-2 s-1"; + case 1545: return "kg m-2 s-1"; + case 1546: return "kg m-2 s-1"; + case 1547: return "kg m-2 s-1"; + case 1548: return "kg m-2 s-1"; + case 1549: return "kg m-2 s-1"; + case 1550: return "kg m-2 s-1"; + case 1551: return "kg m-2 s-1"; + case 1552: return "kg m-2 s-1"; + case 1553: return "kg m-2 s-1"; + case 1554: return "kg m-2 s-1"; + case 1555: return "kg m-2 s-1"; + case 1556: return "kg m-2 s-1"; + case 1557: return "kg m-2 tstep-1"; + case 1558: return "kg m-2 s-1"; + case 1560: return "kg m-2 s-1"; + case 1561: return "kg m-2 s-1"; + case 1562: return "kg m-2 s-1"; + case 1563: return "kg m-2 s-1"; + case 1564: return "kg m-2 s-1"; + case 1578: return "N m-2"; + case 1579: return "m s-1"; + case 1580: return "m s-1"; + case 1583: return "m"; + case 1584: return "%"; + case 1585: return "%"; + case 1586: return "%"; + case 1587: return "%"; + case 1588: return "N m-2"; + case 1589: return "N m-2"; + case 1590: return "N m-2"; + case 1591: return "N m-2"; + case 1592: return "N m-2"; + case 1593: return "N m-2"; + case 1594: return "N m-2"; + case 1595: return "N m-2"; + case 1596: return "m s-2"; + case 1597: return "m s-2"; + case 1600: return "kg m-2 s-1"; + } + return NULL; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_process.c 2004-11-05 18:33:18.000000000 +0000 @@ -0,0 +1,924 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* + * pp_process is the routine which does the bulk of the work + * + * It is called from cuopenread_pp after calling pp_read_all_headers, and it + * works out all the variables, dimensions and attributes. + * + */ + +int pp_process(CuFile *file) +{ + int rec, nrec, at_start_rec, at_end_rec; + PPfile *ppfile; + PPfieldvar *fvar; + PPhdr *hdrp; + PPregaxis *xaxis, *yaxis; + PPzaxis *zaxis; + PPtaxis *taxis; + PPlevel *lev; + PPtime *time, *tval; + void *oldptr; + PPlist *heaplist, *xaxes, *yaxes, *zaxes, *taxes; + PPlist *fieldvars; + PPlistpos handle, thandle; + PPlist *gatts,*catts; + + int ndims, dimid; + int idim; /* dim number of given type */ + int have_time_mean, tmdimid; /* dimensions used for meaning (CF cell methods) */ + CuDim *cudims,*dim; + PPdim *ppdim; + + int nvars, varid; + int ncvars; /* coord vars */ + CuVar *cuvars,*var; + PPvar *ppvar; + PPlist *axislist; + void *axis; + char *tunits, *calatt; + int have_hybrid=1; + PPaxistype axistype; + + PPlandmask *landmask; + + char *axisname, *pointspacing, *standardname, *units, *varnamea, *varnameb, *dimnamestem; + char *posdir; + + PPstashmeta stashmeta; + char formulaterms[MAX_ATT_LEN+1],cellmethods[MAX_ATT_LEN+1]; + char input_uri[MAX_ATT_LEN+1],current_directory[MAX_ATT_LEN+1]; + + int skip_this_variable, dont_free_horiz_axes; + char *skip_reason; + + void *fill_ptr; + int stashval; + int ilev; + int ilen1, ilen2; + Freal lon_modulo, plev_scale; + + int has_cellmethod; + char tmpstring[MAX_ATT_LEN+1]; + + /* ------------------------------------------------------ */ + /* initialisation constants which matter */ + ncvars = 0; + have_hybrid = 0; + have_time_mean = 0; + lon_modulo=360.; + plev_scale=100.; + + /* initialisation constants just to avoid compiler warnings + * (rather than get accustomed to ignoring warnings) + * but flow logic should mean that these vars do actually get + * initialised elsewhere before use + */ + at_end_rec=0; + xaxis=yaxis=NULL; + fvar=NULL; + zaxis=NULL; + taxis=NULL; + axislist=NULL; + tmdimid=-1; + skip_this_variable=dont_free_horiz_axes=0; + skip_reason=NULL; + /* ------------------------------------------------------ */ + + ppfile = file->internp; + + heaplist=ppfile->heaplist; + + /* sort the records */ + nrec = ppfile->nrec; + qsort(ppfile->recs, nrec, sizeof(PPrec*), pp_compare_records); + + /* tmp space for global attributes */ + if(( gatts = pp_list_new(heaplist) )==NULL) goto err; + + /* now sort out the list of variables and dimensions */ + + if(( fieldvars=pp_list_new(heaplist) )==NULL) goto err; + if(( xaxes=pp_list_new(heaplist) )==NULL) goto err; + if(( yaxes=pp_list_new(heaplist) )==NULL) goto err; + if(( zaxes=pp_list_new(heaplist) )==NULL) goto err; + if(( taxes=pp_list_new(heaplist) )==NULL) goto err; + + /* before looping over records, look for land mask */ + for (rec=0; recrecs[rec]->hdr; + + if (pp_var_is_land_mask(hdrp)) { + + if (( landmask = pp_malloc(sizeof(PPlandmask),heaplist) )==NULL) goto err; + if (( xaxis = pp_malloc(sizeof(PPregaxis),heaplist) )==NULL) goto err; + if (( yaxis = pp_malloc(sizeof(PPregaxis),heaplist) )==NULL) goto err; + + xaxis->start = hdrp->BZX + hdrp->BDX; + xaxis->interval = hdrp->BDX; + xaxis->n = hdrp->LBNPT; + + yaxis->start = hdrp->BZY + hdrp->BDY; + yaxis->interval = hdrp->BDY; + yaxis->n = hdrp->LBROW; + + if (( landmask->data = pp_data_new(inttype,xaxis->n * yaxis->n,heaplist) )==NULL) goto err; + + /* read in land mask data values */ + + landmask->xaxis = xaxis; + landmask->yaxis = yaxis; + if (( landmask->data->values=pp_read_data_record(ppfile->recs[rec],ppfile,heaplist) )==NULL) goto err; + + ppfile->landmask = landmask; + + } + } + + /* ====== START LOOP OVER RECORDS ====== */ + + for (rec=0; recrecs[rec+1],ppfile->recs[rec])); + + hdrp=&ppfile->recs[rec]->hdr; + + + /*------------------------------*/ + /* allow for variables which are unsupported for some reason */ + + if (at_start_rec) { + skip_this_variable = 0; + + skip_reason=NULL; + + /* Compressed field index */ + if (pp_get_var_compression(hdrp) == 1) + skip_reason="compressed field index not supported"; + + if (pp_get_var_compression(hdrp) == 2 && ppfile->landmask==NULL) + skip_reason="land/sea mask compression used but landmask field absent"; + + /* ADD ANY MORE VARIABLE SKIPPING CASES HERE. */ + + if (pp_get_var_gridcode(hdrp) > 1) + skip_reason="grid code not supported"; + + if (skip_reason!=NULL) { + skip_this_variable = 1; + CuError(CU_EOPEN,"skipping variable stash code=%d,%d,%d because: %s", + pp_get_var_stash_model(hdrp), + pp_get_var_stash_section(hdrp), + pp_get_var_stash_item(hdrp), + skip_reason); + } + }; + + if (skip_this_variable) + continue; + + /*------------------------------*/ + /* printf("processing record %d / %d\n",rec,nrec); */ + /* pp_dump_header(hdrp); */ + + + + if (at_start_rec) { + + /* ====== THINGS DONE ONLY AT START RECORD OF EACH VARIABLE ====== */ + + /* get PPvar structure, and initialise certain structure members for tidiness */ + if(( fvar=pp_malloc(sizeof(PPfieldvar), heaplist) )==NULL) goto err; + fvar->xaxis=NULL; + fvar->yaxis=NULL; + fvar->zaxis=NULL; + fvar->taxis=NULL; + + if( pp_list_add(fieldvars, fvar, heaplist) !=0) goto err; + + fvar->startrec = rec; + + if (pp_get_var_compression(hdrp) == 2) { + /* land/sea mask compression: for horiz axes use those of LSM */ + xaxis = ppfile->landmask->xaxis; + yaxis = ppfile->landmask->yaxis; + dont_free_horiz_axes = 1; + } + else { + + if(( xaxis=pp_malloc(sizeof(PPregaxis),heaplist) )==NULL) goto err; + xaxis->start = hdrp->BZX + hdrp->BDX; + xaxis->interval = hdrp->BDX; + xaxis->n = hdrp->LBNPT; + + if(( yaxis=pp_malloc(sizeof(PPregaxis),heaplist) )==NULL) goto err; + yaxis->start = hdrp->BZY + hdrp->BDY; + yaxis->interval = hdrp->BDY; + yaxis->n = hdrp->LBROW; + + dont_free_horiz_axes = 0; + } + + if(( zaxis=pp_malloc(sizeof(PPzaxis),heaplist) )==NULL) goto err; + zaxis->type = hdrp->LBVC; + if(( zaxis->values = pp_list_new(heaplist) )==NULL) goto err; + + if(( taxis=pp_malloc(sizeof(PPtaxis),heaplist) )==NULL) goto err; + taxis->type = hdrp->LBTIM; + if(( taxis->values = pp_list_new(heaplist) )==NULL) goto err; + + /*=== set reference time -- + * + * FIXME (?) for forecast fields could possibly change this to use + * the initialisation time (though that is not necessarily desirable) + */ + taxis->time_orig.year = default_year_orig; + taxis->time_orig.month = default_month_orig; + taxis->time_orig.day = default_day_orig; + taxis->time_orig.hour = default_hour_orig; + taxis->time_orig.minute= default_minute_orig; + taxis->time_orig.second= default_second_orig; + + /* ===================================================== */ + } + + /* construct pp_lev struct, and add it to the z axis if not already present + * (could already be present if field has multiple times on each level) + */ + + /* ====== THINGS DONE FOR EVERY PP RECORD ====== */ + + /* store level info */ + + if(( lev=pp_malloc(sizeof(PPlevel), heaplist) )==NULL) goto err; + lev->type = hdrp->LBVC; + lev->level = hdrp->BLEV; + lev->ref_level = hdrp->BRLEV; + lev->hybrid_a = hdrp->BHLEV; + lev->hybrid_ref_a = hdrp->BHRLEV; + + if ((oldptr = pp_list_find(zaxis->values, lev, pp_compare_levels, 0)) != NULL) { + pp_free(lev,heaplist); + lev=oldptr; + } else { + if(( pp_list_add(zaxis->values,lev,heaplist) )!=0) goto err; + } + + /* store time info */ + + if(( time=pp_malloc(sizeof(PPtime), heaplist) )==NULL) goto err; + + time->type = hdrp->LBTIM; + + time->time1.year = hdrp->LBYR; + time->time1.month = hdrp->LBMON; + time->time1.day = hdrp->LBDAT; + time->time1.hour = hdrp->LBHR; + time->time1.minute = hdrp->LBMIN; + time->time1.second = 0; + + time->time2.year = hdrp->LBYRD; + time->time2.month = hdrp->LBMOND; + time->time2.day = hdrp->LBDATD; + time->time2.hour = hdrp->LBHRD; + time->time2.minute = hdrp->LBMIND; + time->time2.second = 0; + + if ((oldptr = pp_list_find(taxis->values, time, pp_compare_times, 0)) != NULL) { + pp_free(time,heaplist); + time=oldptr; + } else { + if(( pp_list_add(taxis->values,time,heaplist) )!=0) goto err; + } + /* ===================================================== */ + + if (at_end_rec) { + + /* ====== THINGS DONE ONLY AT END RECORD OF EACH VARIABLE ====== */ + + fvar->endrec=rec; + + /* + * For each axis, see if it matches an axis which already exists from a previous + * variable. + * + * If so, then free the structure and point to the existing occurrence instead. + * + * If not, then add to the list. + */ + + /* x */ + if ((oldptr = pp_list_find(xaxes, xaxis, pp_compare_regaxes, 0)) != NULL) { + if (!dont_free_horiz_axes) + pp_free(xaxis,heaplist); + xaxis=oldptr; + } else { + if(( pp_list_add(xaxes,xaxis,heaplist) )!=0) goto err; + ncvars++; + } + /* y */ + if ((oldptr = pp_list_find(yaxes, yaxis, pp_compare_regaxes, 0)) != NULL) { + if (!dont_free_horiz_axes) + pp_free(yaxis,heaplist); + yaxis=oldptr; + } else { + if(( pp_list_add(yaxes,yaxis,heaplist) )!=0) goto err; + ncvars++; + } + /* z */ + if ((oldptr = pp_list_find(zaxes, zaxis, pp_compare_zaxes, 0)) != NULL) { + pp_list_free(zaxis->values,1,heaplist); + pp_free(zaxis,heaplist); + zaxis=oldptr; + } else { + if(( pp_list_add(zaxes,zaxis,heaplist) )!=0) goto err; + ncvars++; + if (pp_is_hybrid_levels(zaxis->type)) { + /* two more coord vars (a and b coeffs) */ + ncvars+=2; + have_hybrid=1; + } + } + /* t */ + if ((oldptr = pp_list_find(taxes, taxis, pp_compare_taxes, 0)) != NULL) { + pp_list_free(taxis->values,1,heaplist); + pp_free(taxis,heaplist); + taxis=oldptr; + } else { + if(( pp_list_add(taxes,taxis,heaplist) )!=0) goto err; + ncvars++; + if (pp_is_time_mean(taxis->type)) { + /* need to make sure we have the mean dim (size 2), + * also one more coordinate var + */ + have_time_mean=1; + ncvars++; + } + } + + /* associate var with these axes */ + + fvar->xaxis=xaxis; + fvar->yaxis=yaxis; + fvar->zaxis=zaxis; + fvar->taxis=taxis; + + /* ===================================================== */ + } + } + + /* ==================================================================== + * Having completed the loop over records, we now know the number of + * dimensions and variables, so we can finally do the relevant calls + * to allocate these arrays and populate them usefully. + * ==================================================================== + */ + + /* FIRST ALLOCATE THE ARRAYS, and initialise some values */ + + ndims = pp_list_size(xaxes) + pp_list_size(yaxes) + pp_list_size(zaxes) + pp_list_size(taxes); + + if (have_time_mean){ + tmdimid=ndims; + ndims++; + } + + if(( cudims = CuCreateDims(file,ndims) )==NULL) goto err; + + if (have_hybrid) ncvars++; /* will need a scalar variable called p0 */ + + nvars = ncvars + pp_list_size(fieldvars); + + if(( cuvars = CuCreateVars(file,nvars) )==NULL) goto err; + + for (dimid=0; dimidvar = (CuVar*)0; + dim->coord = (CuVar*)0; + dim->datatype = realtype; + dim->dimtype = CuGlobalDim; + + /* uncomment if internal structure is to be used + * if(( dim->internp = pp_malloc(sizeof(PPdim), heaplist) )==NULL) goto err; + * ppdim=(PPdim*)dim->internp; + */ + } + for (varid=0; variddatatype = realtype; + if(( var->internp = pp_malloc(sizeof(PPvar), heaplist) )==NULL) goto err; + ppvar=(PPvar*)var->internp; + ppvar->startrec=-1; + ppvar->endrec=-1; + ppvar->data=NULL; + if(( ppvar->atts = pp_list_new(heaplist) )==NULL) goto err; + } + + + /* + * NOW POPULATE THE STRUCTURES + * + * The procedure will be to loop over all the axes, adding dimensions and + * variables associated with those axes. + * + * Having done that, any dimensions not associated with axes will be added, + * and then the field variables will be added. + */ + + dimid=0; + varid=0; + + for (axistype=0; axistypeinternp; + ppvar=(PPvar*) var->internp; + + dim->coord = var; + + pointspacing=standardname=axisname=posdir=NULL; + + switch(axistype){ + + case xaxistype: + xaxis=(PPregaxis*) axis; + xaxis->dimid = dimid; + sprintf(dim->name,"longitude%d",idim); + dim->len = xaxis->n; + if(( ppvar->data = pp_regaxis_to_values(xaxis,heaplist) )==NULL) goto err; + axisname="X"; + units="degrees_east"; + standardname="longitude"; + pointspacing="even"; + if( pp_add_att(ppvar->atts,"modulo",realtype,1,&lon_modulo,heaplist) !=0) goto err; + break; + + case yaxistype: + yaxis=(PPregaxis*) axis; + yaxis->dimid = dimid; + sprintf(dim->name,"latitude%d",idim); + dim->len = yaxis->n; + if(( ppvar->data = pp_regaxis_to_values(yaxis,heaplist) )==NULL) goto err; + axisname="Y"; + units="degrees_north"; + standardname="latitude"; + pointspacing="even"; + break; + + case zaxistype: + zaxis=(PPzaxis*) axis; + zaxis->dimid = dimid; + dim->len = pp_list_size(zaxis->values); + if(( ppvar->data = pp_zaxis_to_values(zaxis,lev_type,heaplist) )==NULL) goto err; + axisname="Z"; + + switch (zaxis->type) { + + /* + * 1 Height (m) 8 Pressure (mb) + * 9 Hybrid co-ordinates 10 Sigma (=p/p*) + * 128 Mean sea level 129 Surface + * 130 Tropopause level 131 Maximum wind level + * 132 Freezing level 142 Upper hybrid level + * 143 Lower hybrid level 176 Latitude (deg) + * 177 Longitude (deg) + */ + + case 1: + standardname="height"; + units="m"; + dimnamestem="height"; + posdir="up"; + break; + case 2: + dimnamestem="depth"; + standardname="depth"; + units="m"; + posdir="down"; + break; + case 9: + standardname="atmosphere_hybrid_sigma_pressure_coordinate"; + dimnamestem="hybrid"; + posdir="down"; + break; + case 8: + standardname="air_pressure"; + units="Pa"; + dimnamestem="p_level"; + + /* scale the values to Pa */ + for (ilev=0; ilevdata->n; ilev++) + ((Freal *)(ppvar->data->values))[ilev] *= plev_scale; + + posdir="down"; + break; + case 6: + dimnamestem="soil"; + posdir="up"; + break; + case 5: + dimnamestem="bdylyrtop"; + break; + case 133: + dimnamestem="toa"; + break; + case 128: + dimnamestem="msl"; + break; + case 130: + dimnamestem="tropo"; + break; + case 129: + dimnamestem="surface"; + break; + default: + dimnamestem="level"; + break; + } + + sprintf(dim->name,"z%d_%s",idim,dimnamestem); + + break; + + case taxistype: + taxis=(PPtaxis*) axis; + taxis->dimid = dimid; + sprintf(dim->name,"time%d",idim); + + switch(pp_calendar_type(taxis->type)) { + case gregorian: + calatt="gregorian"; + break; + case cal360day: + calatt="360_day"; + break; + case model: + pp_list_startwalk(taxis->values,&thandle); + tval = pp_list_walk(taxis->values,0,&thandle); + + taxis->time_orig.year = tval->time1.year; + taxis->time_orig.month = tval->time1.month; + taxis->time_orig.day = tval->time1.day; + taxis->time_orig.hour = tval->time1.hour; + taxis->time_orig.minute= tval->time1.minute; + taxis->time_orig.second= tval->time1.second; + calatt="none"; + break; + } + + if( pp_add_string_att(ppvar->atts,"calendar", + calatt, + heaplist) !=0) goto err; + + if(( tunits=pp_t_units(taxis,heaplist) )==NULL) goto err; + dim->len = pp_list_size(taxis->values); + if(( ppvar->data = pp_taxis_to_values(taxis,heaplist) )==NULL) goto err; + axisname="T"; + standardname="time"; + units=tunits; + break; + + default: pp_switch_bug(); + } + + strncpy(var->name,dim->name,CU_MAX_NAME); + var->name[CU_MAX_NAME]='\0'; + + var->ndims=1; + var->dims[0] = dimid; + + if (units != NULL) { + if( pp_add_string_att(ppvar->atts,"units",units,heaplist) !=0) goto err; + strncpy(dim->units,units,CU_MAX_NAME); + dim->units[CU_MAX_NAME]='\0'; + } + + if (axisname != NULL) + if( pp_add_string_att(ppvar->atts,"axis",axisname,heaplist) !=0) goto err; + + if (standardname != NULL) + if( pp_add_string_att(ppvar->atts,"standard_name",standardname,heaplist) !=0) goto err; + + if (pointspacing != NULL) + if( pp_add_string_att(ppvar->atts,"point_spacing",pointspacing,heaplist) !=0) goto err; + + if (posdir != NULL) + if( pp_add_string_att(ppvar->atts,"positive",posdir,heaplist) !=0) goto err; + + varid++; + + /* now add certain variables for hybrid z axis */ + if (axistype == zaxistype && pp_is_hybrid_levels(zaxis->type)) { + + catts=ppvar->atts; /* attribute list for the main coord var */ + + /* Hybrid A coefficient */ + var=&cuvars[varid]; + ppvar=(PPvar*) var->internp; + sprintf(var->name,"z%d_acoeff",idim); + varnamea=var->name; + if(( ppvar->data = pp_zaxis_to_values(zaxis,hybrid_a_type,heaplist) )==NULL) goto err; + if( pp_add_string_att(ppvar->atts,"units","Pa",heaplist) !=0) goto err; + var->ndims=1; + var->dims[0] = dimid; + varid++; + + /* Hybrid B coefficient */ + var=&cuvars[varid]; + ppvar=(PPvar*) var->internp; + sprintf(var->name,"z%d_bcoeff",idim); + varnameb=var->name; + if(( ppvar->data = pp_zaxis_to_values(zaxis,hybrid_b_type,heaplist) )==NULL) goto err; + var->ndims=1; + var->dims[0] = dimid; + varid++; + + snprintf(formulaterms,MAX_ATT_LEN,"ap: %s b: %s ps: ps p0: p0",varnamea,varnameb); + + if( pp_add_string_att(catts,"formula_terms",formulaterms,heaplist) !=0) goto err; + if( pp_add_string_att(catts,"standard_name","atmosphere_hybrid_sigma_pressure_coordinate",heaplist) !=0) goto err; + } + + /* add the boundary variable for time mean */ + if (axistype == taxistype && pp_is_time_mean(taxis->type)) { + + catts=ppvar->atts; /* attribute list for the main coord var */ + + var=&cuvars[varid]; + ppvar=(PPvar*) var->internp; + sprintf(var->name,"time_bnd%d",idim); + if(( ppvar->data = pp_taxis_to_boundary_values(taxis,heaplist) )==NULL) goto err; + var->ndims=2; + var->dims[0]=tmdimid; + var->dims[1]=dimid; + + if( pp_add_string_att(catts,"bounds",var->name,heaplist) !=0) goto err; + + varid++; + } + + dimid++; + idim++; + } /* end loop over axes of given */ + } /* end loop over axis types */ + + /* add nv dimension if we had time mean */ + if (have_time_mean) { + + dim=&cudims[dimid]; + + strcpy(dim->name,"nv"); + dim->len=2; + + dimid++; + } + + /* add p0 variable if we had hybrid coords */ + if (have_hybrid) { + var=&cuvars[varid]; + ppvar=(PPvar*) var->internp; + sprintf(var->name,"p0"); + var->ndims=0; + + /* single value consisting of p0 */ + if(( ppvar->data = pp_data_new(realtype,1,heaplist) )==NULL) goto err; + ((Freal*)(ppvar->data->values))[0]=reference_pressure; + + varid++; + } + + /* add all the attributes for coord variables + * (didn't do inside the loop because more complicated + * for hybrid z coords / t mean) + */ + for (varid=0; varidinternp; + if( pp_copy_and_free_atts(file,var,ppvar->atts,heaplist) !=0) goto err; + } + + + /*======================================================== + * Okay we've done all the variables related to dimensions + * Add the field variables. + *======================================================== + */ + + pp_list_startwalk(fieldvars,&handle); + while ((fvar=pp_list_walk(fieldvars,0,&handle))!=NULL) { + var=&cuvars[varid]; + ppvar=(PPvar*) var->internp; + hdrp=&ppfile->recs[fvar->startrec]->hdr; + + if( pp_var_lookup(hdrp,&stashmeta) !=0) goto err; + + if( pp_get_var_name(varid, stashmeta.shortname, cuvars) !=0) goto err; + + var->ndims=4; + + var->dims[3]=fvar->xaxis->dimid; + var->dims[2]=fvar->yaxis->dimid; + var->dims[1]=fvar->zaxis->dimid; + var->dims[0]=fvar->taxis->dimid; + + var->datatype=pp_get_var_type(hdrp); + + ppvar->startrec = fvar->startrec; + ppvar->endrec = fvar->endrec; + + /* long name */ + if(strlen(stashmeta.longname)>0) + if( pp_add_string_att(ppvar->atts,"long_name",stashmeta.longname,heaplist) !=0) goto err; + + if(strlen(stashmeta.stdname)>0) + if( pp_add_string_att(ppvar->atts,"standard_name",stashmeta.longname,heaplist) !=0) goto err; + + if(strlen(stashmeta.units)>0) + if( pp_add_string_att(ppvar->atts,"units",stashmeta.units,heaplist) !=0) goto err; + + if(strlen(stashmeta.source)>0) + if( pp_add_string_att(ppvar->atts,"lookup_source",stashmeta.source,heaplist) !=0) goto err; + + + /* stash code */ + stashval = pp_get_var_stash_model(hdrp); + if( pp_add_att(ppvar->atts,"stash_model",inttype,1,&stashval,heaplist) !=0) goto err; + + stashval = pp_get_var_stash_section(hdrp); + if( pp_add_att(ppvar->atts,"stash_section",inttype,1,&stashval,heaplist) !=0) goto err; + + stashval = pp_get_var_stash_item(hdrp); + if( pp_add_att(ppvar->atts,"stash_item",inttype,1,&stashval,heaplist) !=0) goto err; + + /* fill value attribute */ + fill_ptr=pp_get_var_fill_value(hdrp); + if(fill_ptr) { + if( pp_add_att(ppvar->atts,"_FillValue",var->datatype,1,fill_ptr,heaplist) !=0) goto err; + if( pp_add_att(ppvar->atts,"missing_value",var->datatype,1,fill_ptr,heaplist) !=0) goto err; + } + + /* cell_methods att for time mean */ + /* + *if (pp_is_time_mean(fvar->taxis->type)) { + * snprintf(cellmethods,MAX_ATT_LEN,"%s: mean",cudims[fvar->taxis->dimid].name); + * if( pp_add_string_att(ppvar->atts,"cell_methods",cellmethods,heaplist) !=0) goto err; + *} + */ + + has_cellmethod=0; + strcpy(cellmethods,""); + if (pp_var_is_time_mean(hdrp)) { /* mean, min, max should be mutually exclusive */ + has_cellmethod=1; + if (snprintf(cellmethods,MAX_ATT_LEN,"%s: mean",cudims[fvar->taxis->dimid].name) > MAX_ATT_LEN+1) { + cellmethods[MAX_ATT_LEN]='\0'; + } + } + if (pp_var_is_time_max(hdrp)) { + has_cellmethod=1; + if (snprintf(cellmethods,MAX_ATT_LEN,"%s: maximum",cudims[fvar->taxis->dimid].name) > MAX_ATT_LEN+1) { + cellmethods[MAX_ATT_LEN]='\0'; + } + } + if (pp_var_is_time_min(hdrp)) { + has_cellmethod=1; + if (snprintf(cellmethods,MAX_ATT_LEN,"%s: minimum",cudims[fvar->taxis->dimid].name) >MAX_ATT_LEN+1) { + cellmethods[MAX_ATT_LEN]='\0'; + } + } + if (pp_var_is_zonal_mean(hdrp)) { + has_cellmethod=1; + if (snprintf(tmpstring,MAX_ATT_LEN," %s: mean",cudims[fvar->xaxis->dimid].name) > MAX_ATT_LEN+1) { + tmpstring[MAX_ATT_LEN]='\0'; + } + ilen1=strlen(cellmethods); + ilen2=strlen(tmpstring); + strncat(cellmethods,tmpstring,MAX_ATT_LEN-ilen1); /* correct length? */ + if ((ilen1+ilen2) > MAX_ATT_LEN+1) { + cellmethods[MAX_ATT_LEN]='\0'; + } + } + if (has_cellmethod) { + if( pp_add_string_att(ppvar->atts,"cell_methods",cellmethods,heaplist) !=0) goto err; + } + + /* FIXME(?): maybe do time difference analogously to time mean, but with different + * cell_methods attribute. See also pp_taxis_to_values() in cdunifpp_axisvals.c + */ + + if( pp_copy_and_free_atts(file,var,ppvar->atts,heaplist) !=0) goto err; + + varid++; + } + + + /*======================================================== + * All done and ready for dimget / varget. + * Free up some of the most important temporary + * heap variables. + *======================================================== + */ + + /* free all the field vars */ + pp_list_free(fieldvars,1,heaplist); + + /* free all the axes -- + * but first free axis value lists for y and z + * (and their contents: pp_level, pp_time structs) -- + * not needed for regular axes x and y + */ + pp_list_startwalk(zaxes,&handle); + while ((zaxis=pp_list_walk(zaxes,0,&handle))!=NULL) { + pp_list_free(zaxis->values,1,heaplist); + } + pp_list_startwalk(taxes,&handle); + while ((taxis=pp_list_walk(taxes,0,&handle))!=NULL) { + pp_list_free(taxis->values,1,heaplist); + } + pp_list_free(xaxes,1,heaplist); + pp_list_free(yaxes,1,heaplist); + pp_list_free(zaxes,1,heaplist); + pp_list_free(taxes,1,heaplist); + + /* set numbers in file structure */ + file->ndims=ndims; + file->nvars=nvars; + file->recdim=-1; + + /* global attributes: */ + + if( pp_add_string_att(gatts,"history","PP/UM file read by cdunif",heaplist) !=0) goto err; + + /*-------------------------*/ + /* input_uri */ + if (file->controlpath[0]=='/') { + snprintf(input_uri,MAX_ATT_LEN,"file://%s",file->controlpath); + } + else { + if(getcwd(current_directory,MAX_ATT_LEN)!=NULL) { + snprintf(input_uri,MAX_ATT_LEN,"file://%s/%s",current_directory,file->controlpath); + } else { + /* better than nothing */ + snprintf(input_uri,MAX_ATT_LEN,"%s",file->controlpath); + } + } + input_uri[MAX_ATT_LEN]='\0'; + if( pp_add_string_att(gatts,"input_uri",input_uri,heaplist) !=0) goto err; + /*-------------------------*/ + + if( pp_add_att(gatts,"input_word_length",inttype,1,&ppfile->wordsize,heaplist) !=0) goto err; + if( pp_add_string_att(gatts,"input_byte_ordering", +#ifdef LITTLE_ENDIAN_MACHINE + (ppfile->swap) +#else + (! ppfile->swap) +#endif + ? "big_endian" : "little_endian", heaplist) !=0) goto err; + + if (ppfile->type == um_type) + if( pp_add_string_att(gatts,"input_file_format","UM ancillary",heaplist) !=0) goto err; + + if (ppfile->type == pp_type) + if( pp_add_string_att(gatts,"input_file_format","PP",heaplist) !=0) goto err; + + /* add global attributes */ + if( pp_copy_and_free_atts(file,NULL,gatts,heaplist) !=0) goto err; + + return 0; + + err: + pp_error("cdunifpp_process"); + return -1; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_read.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_read.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_read.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_read.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,904 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + + +/*--------------------------------------------------------- + * reads n words from ppfile, storing them at ptr + * + * Number of bytes read from file is n * (file wordsize). + * + * In the case where (file wordsize) != (compiled-in wordsize), + * conversion may be done if "conv" is set to "convert_int" or + * "convert_real", in which case bytes written at supplied pointer + * will be n * (compiled-in wordsize). If "conv" is set to + * "convert_none" then number of bytes written to pointer will be + * number of bytes read. + * + * (Conversion simply means copying values between variables of different + * word length. convert_none is for use with packed data, to be unpacked + * elsewhere.) + * + * returns number of file words read (i.e. n, unless there's a short read) + */ + +size_t pp_read_words(void *ptr, size_t n, PPconvert conv, const PPfile *ppfile) +{ + size_t i,nread,nread1; + void *tmp; + + Fint8 dummy; /* a variable of longest word length which might be used - we point ptr at it, + * and use it as a place to store a variable of that length or shorter + */ + + if (ppfile==NULL || ptr==NULL) goto err; + + if (ppfile->wordsize == wordsize || conv==convert_none) { + nread = fread(ptr, ppfile->wordsize, n, ppfile->fh); + + /* NOTE: for 64-bit file packed with the CRAY32 method, the following call to swapbytes will + * transpose pairs of 32-bit data values. It is responsibility of calling routine to deal + * with this. + */ + if (ppfile->swap) + pp_swapbytes(ptr,ppfile->wordsize,nread); + } + else { + + tmp = &dummy; + + nread=0; + + /* read and convert a word at a time - save allocating extra memory */ + for (i=0; iwordsize, 1, ppfile->fh); + if (nread1==0) + break; + + nread += nread1; + + if (ppfile->swap) + pp_swapbytes(tmp, ppfile->wordsize, nread1); + + /* gruesome switches on constants in the loop - hoping the optimiser will sort it out - + * I'd rather not explicitly code copies of the loop inside the switch */ + + switch(ppfile->wordsize) { + case 4: + switch(conv) { + case convert_int: ((Fint *)ptr)[i] = *(Fint4 *)tmp; break; + case convert_real: ((Freal *)ptr)[i] = *(Freal4 *)tmp; break; + default: pp_switch_bug(); goto err; + } + break; + case 8: + switch(conv) { + case convert_int: ((Fint *)ptr)[i] = *(Fint8 *)tmp; break; + case convert_real: ((Freal *)ptr)[i] = *(Freal8 *)tmp; break; + default: pp_switch_bug(); goto err; + } + break; + default: pp_switch_bug(); goto err; + } + } + } + return nread; + + err: + pp_error("pp_read_ints"); + return 0; +} + +/*---------------------------------------------------------*/ + +int pp_swapbytes(void *ptr, int bytes, int nchunk) +{ + int i; + char *p; + char t; + p = (char*) ptr; + /* just deal with the 2 realistic cases; faster than + * doing the general case with two sliding pointers + */ + switch(bytes){ + case 4: + for(i=0; ifh; + + fseek(fh, rec->datapos, SEEK_SET); + + hdrp=&rec->hdr; + + pack = pp_get_var_packing(hdrp); + vartype=pp_get_var_type(hdrp); + + if (pack==0) { + /* unpacked data -- read and convert according to type */ + + bytes = rec->datalen * wordsize; + if(( data = pp_malloc(bytes,heaplist) )==NULL) goto err; + + if (vartype==inttype) + conv = convert_int; + else if (vartype==realtype) + conv = convert_real; + else { + conv=convert_none; + pp_switch_bug(); goto err; + } + + if(( nread = pp_read_words(data, rec->datalen, conv, ppfile) )!=rec->datalen) goto err; + } + else { + + /* PACKING IN USE */ + + /* first allocate array and read in packed data */ + + packed_bytes = rec->disklen * ppfile->wordsize; + if(( packed_data = pp_malloc(packed_bytes,heaplist) )==NULL) goto err; + + if(( nread = pp_read_words(packed_data, rec->disklen, convert_none, ppfile) )!=rec->disklen) goto err; + + /* and allocate array for unpacked data*/ + bytes = rec->datalen * wordsize; + if(( data = pp_malloc(bytes,heaplist) )==NULL) goto err; + + /* NOW UNPACK ACCORDING TO PACKING TYPE: */ + + switch(pack) { + + case 1: + + /* WGDOS */ + + /* for this case we will use unwgdos routine */ + + /* unwgdos routine wants to know number of native integers in input. + * input type might not be native int, so calculate: + */ + nint = rec->disklen * ppfile->wordsize / sizeof(int); + mdi = *(Freal*)pp_get_var_fill_value(hdrp); + + if( pp_unwgdos_wrap(packed_data, nint, data, rec->datalen, mdi, heaplist) !=0) goto err; + + break; + + + case 2: + /* CRAY 32-bit method */ + + if (vartype != realtype) { + CuError(CU_EINTERN,"Cray 32-bit unpacking supported only for REAL type data"); + goto err; + } + + /* + * in the event of a 64-bit file (which it probably is, else 32-bit packing is + * redundant), and if we're on a little-endian machine, the file was written on + * a cray, so the 64-bit byte swapping (whether done by cdunifpp or previously) + * will have had the side-effect of swapping pairs of 32-bit words and we need + * to swap them back again. + * + * NB LITTLE_ENDIAN_MACHINE is defined (if at all) in cdunifpp.h + */ + +#ifdef LITTLE_ENDIAN_MACHINE + if (ppfile->wordsize == 8) + pp_swap32couplets(packed_data,packed_bytes); +#endif + + for (ipt=0; ipt < rec->datalen ; ipt++) + *(((Freal*) (data)) + ipt) = *(((Freal4*) (packed_data)) + ipt); + + break; + + case 3: + CuError(CU_EINTERN,"GRIB unpacking not supported"); + goto err; + /* break; */ + + default: + pp_switch_bug(); goto err; + } + + /* Okay - data unpacked - free up packed data */ + pp_free(packed_data,heaplist); + } + + + /* if land or sea mask compression, then allocate another array, and + * copy the relevant data across, filling the gaps with missing data + */ + + if (pp_get_var_compression(hdrp) == 2) { + + npoint = ppfile->landmask->xaxis->n * ppfile->landmask->yaxis->n; + bytes = npoint * wordsize; + if(( data_expanded = pp_malloc(bytes,heaplist) )==NULL) goto err; + + switch ((hdrp->LBPACK/100)%10) { + case 1: + /* land mask compression */ + valid_landmask_value = 1; + break; + case 2: + /* sea mask compression */ + valid_landmask_value = 0; + break; + default: + pp_switch_bug(); goto err; + } + + landmask_vals = ppfile->landmask->data->values; + srcptr = data; + destptr = data_expanded; + + if(( fill_ptr = pp_get_var_fill_value(hdrp) )==NULL) goto err; + + npoint_used = 0; + + for (ipt = 0; ipt < npoint; ipt++) { + if (landmask_vals[ipt] == valid_landmask_value) { + + if (npoint_used >= rec->datalen) { + CuError(CU_EINTERN,"Uncompressing tried to use more compressed data than available"); + goto err; + } + + memcpy(destptr,srcptr,wordsize); + srcptr += wordsize; + npoint_used++; + } + else { + memcpy(destptr,fill_ptr,wordsize); + } + destptr += wordsize; + } + + if (npoint_used != rec->datalen) { + CuError(CU_EINTERN,"Uncompressing did not use all the compressed data"); + goto err; + } + + + pp_free(data,heaplist); + data = data_expanded; + } + + return data; + + err: + pp_error("pp_read_data_record"); + return NULL; + +} + + +#ifdef LITTLE_ENDIAN_MACHINE +int pp_swap32couplets(char *p,int nbytes) +{ + int i; + char a,b,c,d,e,f,g,h; + for (i=0; ifh; + if( pp_read_words(&recsize,1,convert_int,ppfile) !=1) return -1; + if( fseek(f,recsize,SEEK_CUR) !=0) goto err; + if( pp_read_words(&recsize2,1,convert_int,ppfile) !=1) goto err; + if (recsize != recsize2) goto err; + return recsize; + err: + pp_error("pp_skip_fortran_record"); + return -2; +} + + +/* skip a single word */ +int pp_skip_word(const PPfile *ppfile) +{ + if( fseek(ppfile->fh, ppfile->wordsize, SEEK_CUR) !=0) goto err; + return 0; + + err: + pp_error("pp_skip_word"); + return -1; +} + +void *pp_read_header(const PPfile *ppfile, PPlist *heaplist) +{ + void *hdr; + /* reads a PP header -- file must be positioned at start of header, + * (after any fortran record length integer) */ + + if(( hdr=pp_malloc(n_hdr * wordsize,heaplist) )==NULL) goto err; + if( pp_read_words(hdr,n_int_hdr,convert_int,ppfile) !=n_int_hdr) goto err; + + if( pp_read_words(hdr + n_int_hdr * wordsize, + n_real_hdr,convert_real,ppfile) !=n_real_hdr) goto err; + + return hdr; /* success */ + + err: + pp_error("pp_read_header"); + return NULL; +} + +/*---------------------------------------------------------*/ + +/* + * The pp_read_all_headers routine takes a CuFile*, and does the following: + * + * count the records (nrec), and allocate an array of nrec pointers to PPrec structures, + * + * populate: file->internp->nrec (= nrec) + * file->internp->recs (pointer to recs array) + * + * populate the PPrec structures themselves + * + * returns 0 on success, -1 on failure + * + * + * (Incidentally: why are the pointers to records stored in an array, + * when virtually every other list used by cdunifpp is a linked list? + * Answer: so we can use qsort, and also so we can access them directly by index.) + */ + +int pp_read_all_headers(CuFile *file) +{ + FILE *fh; + int rec,nrec,recsize, filerec; + void *hdr; + PPfile *ppfile; + PPrec **recs,*recp; + PPlist *heaplist; + + Fint start_lookup, nlookup1, nlookup2, lbbegin, dataset_type, start_data; + long hdr_start, hdr_size, lbbegin_offset, datapos; + + int *valid; + PPhdr *hdrp; + int fieldsfile; + + + ppfile=file->internp; + fh=ppfile->fh; + heaplist=ppfile->heaplist; + + switch(ppfile->type) { + case pp_type: + + fseek(fh,0,SEEK_SET); + /* count the PP records in the file */ + for (nrec=0; (recsize=pp_skip_fortran_record(ppfile)) != -1; nrec++) { + if (recsize==-2) + goto err; + if (recsize != n_hdr * ppfile->wordsize) { + CuError(CU_EOPEN,"Opening PP file %s: unsupported header length: %d words", + file->controlpath, recsize / ppfile->wordsize); + goto err; + } + if( pp_skip_fortran_record(ppfile) <0) goto err; /* skip the data record */ + } + + /* now rewind, and read in all the PP header data */ + fseek(fh,0,SEEK_SET); + + ppfile->nrec=nrec; + if(( recs=pp_malloc(nrec*sizeof(PPrec*),heaplist) )==NULL) goto err; + ppfile->recs = recs; + + for (rec=0; rechdr; + + pp_store_header(hdrp,hdr); + + recp->recno = rec; + + /* skip data record but store length */ + recp->datapos = ftell(fh) + ppfile->wordsize; + recp->disklen = pp_skip_fortran_record(ppfile) / ppfile->wordsize; + + /* work out datalen */ + pp_evaluate_lengths(hdrp, ppfile, &recp->datalen, NULL); + + pp_free(hdr,heaplist); + } + break; + case um_type: + + /* pick out certain information from the fixed length header */ + + if( fseek(fh,4*ppfile->wordsize,SEEK_SET) !=0) goto err; + if( pp_read_words(&dataset_type, 1, convert_int, ppfile) !=1) goto err; + + if( fseek(fh,149*ppfile->wordsize,SEEK_SET) !=0) goto err; + if( pp_read_words(&start_lookup, 1, convert_int, ppfile) !=1) goto err; + if( pp_read_words(&nlookup1, 1, convert_int, ppfile) !=1) goto err; + if( pp_read_words(&nlookup2, 1, convert_int, ppfile) !=1) goto err; + + if( fseek(fh,159*ppfile->wordsize,SEEK_SET) !=0) goto err; + if( pp_read_words(&start_data, 1, convert_int, ppfile) !=1) goto err; + + fieldsfile = (dataset_type == 3); + + /* (first dim of lookup documented as being 64 or 128, so + * allow header longer than n_hdr (64) -- discarding excess -- but not shorter) + */ + if (nlookup1 < n_hdr) { + CuError(CU_EOPEN,"Opening UM file %s: unsupported header length: %d words", + file->controlpath, nlookup1); + goto err; + } + + /* count the valid records in the file */ + /* loop over all records and pick out the valid ones - test for LBBEGIN != -99 */ + nrec=0; + hdr_start = (start_lookup - 1) * ppfile->wordsize; + hdr_size = nlookup1 * ppfile->wordsize; + lbbegin_offset = 28 * ppfile->wordsize; + + if(( valid = pp_malloc(nlookup2 * sizeof(int),heaplist) )==NULL) goto err; + + for (filerec=0; filerecnrec=nrec; + if(( recs=pp_malloc(nrec*sizeof(PPrec*),heaplist) )==NULL) goto err; + ppfile->recs = recs; + + + rec=0; /* valid record number, as opposed to + * filerec which is total record number */ + + datapos = (start_data-1) * ppfile->wordsize; + + for (filerec=0; filerechdr; + pp_store_header(hdrp,hdr); + pp_free(hdr,heaplist); + + /* work out datalen and disklen */ + pp_evaluate_lengths(hdrp, ppfile, &recp->datalen, &recp->disklen); + + recp->datapos = datapos; + + /* If LBNREC and LBBEGIN are both non-zero and it's not a FIELDSfile, + * the file has well-formed records. In that case, + * LBBEGIN should be correct, so do an assertion + */ + if (!fieldsfile && hdrp->LBNREC != 0 && hdrp->LBBEGIN != 0) { + + if (recp->datapos != hdrp->LBBEGIN * ppfile->wordsize) { + + CuError(CU_EOPEN,"start of data record mismatch: %d %d", + recp->datapos, hdrp->LBBEGIN * ppfile->wordsize); + goto err; + } + } + + datapos += recp->disklen * ppfile->wordsize; + rec++; + } + } + + + pp_free(valid,heaplist); + + break; + default: pp_switch_bug(); + } + + return 0; + + err: + pp_error("pp_read_all_headers"); + return -1; +} + +int pp_store_header(PPhdr *hdrp, const void *hdr){ + const Fint *ihdr; + const Freal *rhdr; + + ihdr = (Fint*) hdr; + rhdr = (Freal*) (ihdr + 45); + +#ifdef PP_STORE_LBYR + hdrp->LBYR =ihdr[ 0]; +#endif +#ifdef PP_STORE_LBMON + hdrp->LBMON =ihdr[ 1]; +#endif +#ifdef PP_STORE_LBDAT + hdrp->LBDAT =ihdr[ 2]; +#endif +#ifdef PP_STORE_LBHR + hdrp->LBHR =ihdr[ 3]; +#endif +#ifdef PP_STORE_LBMIN + hdrp->LBMIN =ihdr[ 4]; +#endif +#ifdef PP_STORE_LBDAY + hdrp->LBDAY =ihdr[ 5]; +#endif +#ifdef PP_STORE_LBYRD + hdrp->LBYRD =ihdr[ 6]; +#endif +#ifdef PP_STORE_LBMOND + hdrp->LBMOND =ihdr[ 7]; +#endif +#ifdef PP_STORE_LBDATD + hdrp->LBDATD =ihdr[ 8]; +#endif +#ifdef PP_STORE_LBHRD + hdrp->LBHRD =ihdr[ 9]; +#endif +#ifdef PP_STORE_LBMIND + hdrp->LBMIND =ihdr[10]; +#endif +#ifdef PP_STORE_LBDAYD + hdrp->LBDAYD =ihdr[11]; +#endif +#ifdef PP_STORE_LBTIM + hdrp->LBTIM =ihdr[12]; +#endif +#ifdef PP_STORE_LBFT + hdrp->LBFT =ihdr[13]; +#endif +#ifdef PP_STORE_LBLREC + hdrp->LBLREC =ihdr[14]; +#endif +#ifdef PP_STORE_LBCODE + hdrp->LBCODE =ihdr[15]; +#endif +#ifdef PP_STORE_LBHEM + hdrp->LBHEM =ihdr[16]; +#endif +#ifdef PP_STORE_LBROW + hdrp->LBROW =ihdr[17]; +#endif +#ifdef PP_STORE_LBNPT + hdrp->LBNPT =ihdr[18]; +#endif +#ifdef PP_STORE_LBEXT + hdrp->LBEXT =ihdr[19]; +#endif +#ifdef PP_STORE_LBPACK + hdrp->LBPACK =ihdr[20]; +#endif +#ifdef PP_STORE_LBREL + hdrp->LBREL =ihdr[21]; +#endif +#ifdef PP_STORE_LBFC + hdrp->LBFC =ihdr[22]; +#endif +#ifdef PP_STORE_LBCFC + hdrp->LBCFC =ihdr[23]; +#endif +#ifdef PP_STORE_LBPROC + hdrp->LBPROC =ihdr[24]; +#endif +#ifdef PP_STORE_LBVC + hdrp->LBVC =ihdr[25]; +#endif +#ifdef PP_STORE_LBRVC + hdrp->LBRVC =ihdr[26]; +#endif +#ifdef PP_STORE_LBEXP + hdrp->LBEXP =ihdr[27]; +#endif +#ifdef PP_STORE_LBBEGIN + hdrp->LBBEGIN =ihdr[28]; +#endif +#ifdef PP_STORE_LBNREC + hdrp->LBNREC =ihdr[29]; +#endif +#ifdef PP_STORE_LBPROJ + hdrp->LBPROJ =ihdr[30]; +#endif +#ifdef PP_STORE_LBTYP + hdrp->LBTYP =ihdr[31]; +#endif +#ifdef PP_STORE_LBLEV + hdrp->LBLEV =ihdr[32]; +#endif +#ifdef PP_STORE_LBRSVD1 + hdrp->LBRSVD1=ihdr[33]; +#endif +#ifdef PP_STORE_LBRSVD2 + hdrp->LBRSVD2=ihdr[34]; +#endif +#ifdef PP_STORE_LBRSVD3 + hdrp->LBRSVD3=ihdr[35]; +#endif +#ifdef PP_STORE_LBRSVD4 + hdrp->LBRSVD4=ihdr[36]; +#endif +#ifdef PP_STORE_LBSRCE + hdrp->LBSRCE =ihdr[37]; +#endif +#ifdef PP_STORE_LBUSER1 + hdrp->LBUSER1=ihdr[38]; +#endif +#ifdef PP_STORE_LBUSER2 + hdrp->LBUSER2=ihdr[39]; +#endif +#ifdef PP_STORE_LBUSER3 + hdrp->LBUSER3=ihdr[40]; +#endif +#ifdef PP_STORE_LBUSER4 + hdrp->LBUSER4=ihdr[41]; +#endif +#ifdef PP_STORE_LBUSER5 + hdrp->LBUSER5=ihdr[42]; +#endif +#ifdef PP_STORE_LBUSER6 + hdrp->LBUSER6=ihdr[43]; +#endif +#ifdef PP_STORE_LBUSER7 + hdrp->LBUSER7=ihdr[44]; +#endif + +#ifdef PP_STORE_BRSVD1 + hdrp->BRSVD1=rhdr[ 0]; +#endif +#ifdef PP_STORE_BRSVD2 + hdrp->BRSVD2=rhdr[ 1]; +#endif +#ifdef PP_STORE_BRSVD3 + hdrp->BRSVD3=rhdr[ 2]; +#endif +#ifdef PP_STORE_BRSVD4 + hdrp->BRSVD4=rhdr[ 3]; +#endif +#ifdef PP_STORE_BDATUM + hdrp->BDATUM=rhdr[ 4]; +#endif +#ifdef PP_STORE_BACC + hdrp->BACC =rhdr[ 5]; +#endif +#ifdef PP_STORE_BLEV + hdrp->BLEV =rhdr[ 6]; +#endif +#ifdef PP_STORE_BRLEV + hdrp->BRLEV =rhdr[ 7]; +#endif +#ifdef PP_STORE_BHLEV + hdrp->BHLEV =rhdr[ 8]; +#endif +#ifdef PP_STORE_BHRLEV + hdrp->BHRLEV=rhdr[ 9]; +#endif +#ifdef PP_STORE_BPLAT + hdrp->BPLAT =rhdr[10]; +#endif +#ifdef PP_STORE_BPLON + hdrp->BPLON =rhdr[11]; +#endif +#ifdef PP_STORE_BGOR + hdrp->BGOR =rhdr[12]; +#endif +#ifdef PP_STORE_BZY + hdrp->BZY =rhdr[13]; +#endif +#ifdef PP_STORE_BDY + hdrp->BDY =rhdr[14]; +#endif +#ifdef PP_STORE_BZX + hdrp->BZX =rhdr[15]; +#endif +#ifdef PP_STORE_BDX + hdrp->BDX =rhdr[16]; +#endif +#ifdef PP_STORE_BMDI + hdrp->BMDI =rhdr[17]; +#endif +#ifdef PP_STORE_BMKS + hdrp->BMKS =rhdr[18]; +#endif + + return 0; +} + +/* + * pp_evaluate_lengths works out the data length and disk length, and outputs them using the supplied + * pointers (unless these are NULL). + * + * NB as currently coded, pp_read_all_headers() does not use the calculated value of disk length in + * the case of raw PP files (using instead the Fortran record length). But to allow for future changes, + * this routine has a stab at calculating it anyway. + */ + +int pp_evaluate_lengths (const PPhdr *hdrp, const PPfile *ppfile, long *datalenp, long *disklenp) { + + long datalen; + long disklen; + + if (hdrp->LBPACK != 0) { + datalen=0; + if (hdrp->LBROW > 0 && hdrp->LBNPT>0) + datalen += hdrp->LBROW * hdrp->LBNPT; + if (hdrp->LBEXT > 0) + datalen += hdrp->LBEXT; + if (datalen==0) + datalen = hdrp->LBLREC; + + /* Input array size (packed field): + * First try LBNREC + * then if Cray 32-bit packing, know ratio of packed to unpacked lengths; + * else use LBLREC + * + * For raw PP files, first try LBLREC if it's non-zero, because values of + * LBNREC written by CONVPP may be wrong (particularly if CONVPP does unpacking) + */ + switch(ppfile->type) { + case um_type: + disklen = + (hdrp->LBNREC != 0) ? hdrp->LBNREC : + (hdrp->LBPACK%10 ==2) ? datalen * 4 / ppfile->wordsize : + hdrp->LBLREC; + break; + case pp_type: + disklen = + (hdrp->LBLREC != 0) ? hdrp->LBLREC : + (hdrp->LBNREC != 0) ? hdrp->LBNREC : + (hdrp->LBPACK%10 ==2) ? datalen * 4 / ppfile->wordsize : + 0; + break; + default: + pp_switch_bug(); + } + } + else { + disklen=0; /* init to avoid compiler warnings */ + + /* unpacked record */ + datalen = hdrp->LBLREC; + + /* UM file: try LBNREC first + * + * PP file: try LBLREC first, because convpp copies LBNREC direct from UM file + * without setting it to value appropriate to PP file + */ + switch(ppfile->type) { + case pp_type: + disklen = (hdrp->LBLREC != 0) ? hdrp->LBLREC : hdrp->LBNREC; + break; + case um_type: + disklen = (hdrp->LBNREC != 0) ? hdrp->LBNREC : hdrp->LBLREC; + break; + default: + pp_switch_bug(); + } + } + + if (datalenp != NULL) + *datalenp = datalen; + + if (disklenp != NULL) + *disklenp = disklen; + + return 0; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_stash2pp.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_stash2pp.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_stash2pp.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_stash2pp.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,1889 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* + * NOTE: It turns out that as currently implemented, pp_stashpp() is NOT USED, + * ==== because PP codes are taken directly from the header rather than + * being lookup up from the stash code. But this routine is potentially + * useful, so it is being left in the source tree for possible later + * use. + */ + + +/* returns PP code corresponding to stash codes, or -1 if not found. */ + +/* NOTE: the code of this function was largely auto-generated from the stashmaster files + * from UM version 4.5. See below for perl script. + */ + +int pp_stashpp(int model, int section, int item) +{ + switch (model) { + case 1: + switch (section) { + case 0: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 5: return 19; + case 9: return 122; + case 10: return 95; + case 11: return 95; + case 12: return 78; + case 13: return 34; + case 14: return 222; + case 15: return 223; + case 16: return 219; + case 17: return 174; + case 18: return 175; + case 20: return 23; + case 21: return 106; + case 22: return 271; + case 23: return 93; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 27: return 0; + case 28: return 701; + case 29: return 702; + case 30: return 395; + case 31: return 37; + case 32: return 687; + case 33: return 1; + case 34: return 150; + case 35: return 152; + case 36: return 153; + case 37: return 154; + case 38: return 0; + case 39: return 0; + case 40: return 329; + case 41: return 330; + case 42: return 331; + case 43: return 332; + case 44: return 333; + case 45: return 334; + case 46: return 335; + case 47: return 336; + case 48: return 342; + case 49: return 209; + case 50: return 326; + case 51: return 321; + case 52: return 322; + case 53: return 328; + case 54: return 323; + case 55: return 325; + case 56: return 327; + case 57: return 287; + case 58: return 569; + case 59: return 570; + case 60: return 453; + case 61: return 501; + case 62: return 502; + case 63: return 503; + case 64: return 504; + case 65: return 505; + case 66: return 506; + case 67: return 507; + case 68: return 508; + case 69: return 509; + case 70: return 510; + case 71: return 511; + case 72: return 512; + case 73: return 513; + case 74: return 514; + case 75: return 515; + case 76: return 516; + case 77: return 517; + case 78: return 518; + case 79: return 519; + case 80: return 520; + case 81: return 521; + case 82: return 522; + case 83: return 523; + case 84: return 524; + case 85: return 525; + case 86: return 526; + case 87: return 527; + case 88: return 528; + case 89: return 529; + case 90: return 286; + case 93: return 0; + case 96: return 0; + case 97: return 0; + case 98: return 0; + case 101: return 1374; + case 102: return 1373; + case 103: return 1370; + case 104: return 1371; + case 105: return 1372; + case 106: return 581; + case 107: return 1379; + case 108: return 1491; + case 109: return 1492; + case 110: return 1493; + case 121: return 569; + case 122: return 580; + case 123: return 600; + case 124: return 581; + case 125: return 60; + case 126: return 569; + case 127: return 572; + case 128: return 573; + case 129: return 573; + case 150: return 42; + case 151: return 8; + case 152: return 999; + case 153: return 56; + case 154: return 57; + case 160: return 1376; + case 201: return 8; + case 202: return 56; + case 203: return 57; + case 204: return 19; + case 205: return 36; + case 207: return 1381; + case 208: return 1382; + case 209: return 1383; + case 211: return 218; + case 213: return 1384; + case 214: return 1385; + case 215: return 1386; + case 216: return 1391; + case 217: return 1392; + case 218: return 1393; + case 219: return 1394; + case 220: return 1395; + case 221: return 1396; + case 222: return 259; + case 223: return 1397; + case 224: return 1398; + case 225: return 1500; + case 226: return 1501; + case 227: return 1502; + case 228: return 1503; + case 229: return 1504; + case 230: return 1505; + case 231: return 1507; + case 232: return 1508; + case 233: return 1510; + case 234: return 1511; + case 250: return 1560; + case 251: return 1561; + case 252: return 1564; + case 401: return 7; + case 402: return 79; + case 403: return 78; + case 404: return 1731; + case 405: return 106; + } + break; + case 1: + switch (item) { + case 4: return 16; + case 201: return 186; + case 202: return 186; + case 203: return 186; + case 204: return 186; + case 205: return 322; + case 206: return 328; + case 207: return 200; + case 208: return 201; + case 209: return 207; + case 210: return 208; + case 211: return 207; + case 212: return 220; + case 213: return 34; + case 214: return 169; + case 215: return 169; + case 216: return 169; + case 217: return 169; + case 218: return 220; + case 219: return 30; + case 220: return 163; + case 221: return 164; + case 222: return 165; + case 223: return 166; + case 224: return 167; + case 225: return 163; + case 226: return 165; + case 232: return 251; + case 233: return 252; + case 234: return 1376; + case 235: return 203; + case 236: return 1377; + case 237: return 186; + case 238: return 201; + case 241: return 1464; + case 242: return 1465; + case 243: return 1466; + case 244: return 1467; + case 245: return 1468; + case 246: return 1469; + } + break; + case 2: + switch (item) { + case 4: return 16; + case 201: return 187; + case 202: return 187; + case 203: return 187; + case 204: return 30; + case 205: return 206; + case 206: return 210; + case 207: return 205; + case 208: return 211; + case 232: return 253; + case 233: return 254; + case 237: return 187; + case 238: return 205; + } + break; + case 3: + switch (item) { + case 2: return 56; + case 3: return 57; + case 4: return 16; + case 10: return 95; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 49: return 209; + case 100: return 1301; + case 101: return 1302; + case 102: return 1303; + case 103: return 1304; + case 104: return 1305; + case 105: return 1306; + case 106: return 1307; + case 107: return 1308; + case 108: return 1309; + case 109: return 1310; + case 110: return 1311; + case 111: return 1312; + case 112: return 1313; + case 113: return 1314; + case 114: return 1315; + case 115: return 1316; + case 116: return 1317; + case 117: return 1318; + case 118: return 1319; + case 119: return 1320; + case 120: return 1321; + case 121: return 1322; + case 122: return 1323; + case 123: return 1324; + case 124: return 1325; + case 125: return 1326; + case 126: return 1327; + case 127: return 1328; + case 128: return 1329; + case 129: return 1330; + case 201: return 261; + case 202: return 179; + case 203: return 160; + case 204: return 183; + case 205: return 52; + case 206: return 172; + case 207: return 171; + case 208: return 181; + case 217: return 178; + case 219: return 61; + case 220: return 62; + case 223: return 184; + case 224: return 182; + case 225: return 56; + case 226: return 57; + case 228: return 178; + case 229: return 115; + case 230: return 273; + case 231: return 107; + case 232: return 285; + case 234: return 180; + case 235: return 260; + case 236: return 16; + case 237: return 95; + case 238: return 23; + case 239: return 79; + case 240: return 78; + case 241: return 184; + case 242: return 220; + case 243: return 79; + case 244: return 78; + case 245: return 88; + case 247: return 25; + case 248: return 220; + case 249: return 50; + case 250: return 17; + case 251: return 174; + case 252: return 175; + case 253: return 173; + case 254: return 19; + case 255: return 95; + case 256: return 257; + case 257: return 258; + case 258: return 141; + case 259: return 1384; + case 260: return 1387; + case 261: return 1388; + case 262: return 1389; + case 263: return 1390; + case 264: return 1382; + case 265: return 1383; + case 270: return 1400; + case 271: return 1401; + case 272: return 1402; + case 273: return 1403; + case 274: return 1404; + case 275: return 1405; + case 276: return 1406; + case 277: return 1407; + case 278: return 1408; + case 279: return 1409; + case 280: return 1410; + case 281: return 1411; + case 282: return 1412; + case 283: return 1413; + case 284: return 1414; + case 285: return 1415; + case 286: return 1416; + case 287: return 1517; + case 288: return 1518; + case 289: return 1519; + case 290: return 1520; + case 291: return 1521; + case 292: return 1522; + case 293: return 1523; + case 294: return 1524; + case 295: return 1525; + case 296: return 1526; + case 297: return 1527; + case 298: return 1528; + case 299: return 1529; + case 300: return 1541; + case 301: return 1542; + case 302: return 1543; + case 303: return 1544; + case 304: return 1534; + case 305: return 1535; + case 306: return 1536; + case 307: return 1537; + case 308: return 1538; + case 309: return 1539; + case 310: return 1540; + case 311: return 1557; + case 312: return 1558; + case 313: return 1559; + case 314: return 202; + case 315: return 1391; + case 316: return 1510; + case 317: return 1391; + case 318: return 1392; + case 319: return 1393; + case 320: return 1397; + case 321: return 1504; + case 322: return 1505; + case 323: return 1508; + case 324: return 1511; + case 325: return 1499; + case 326: return 1562; + case 327: return 1563; + } + break; + case 4: + switch (item) { + case 4: return 16; + case 10: return 95; + case 201: return 102; + case 202: return 116; + case 203: return 99; + case 204: return 118; + case 205: return 79; + case 206: return 78; + case 207: return 88; + case 208: return 25; + case 211: return 1421; + case 212: return 1422; + case 213: return 1423; + case 214: return 1424; + case 215: return 1545; + case 216: return 1547; + case 217: return 1548; + case 218: return 1549; + case 219: return 1550; + case 220: return 1546; + case 221: return 1546; + case 222: return 78; + case 223: return 78; + case 224: return 78; + case 225: return 78; + } + break; + case 5: + switch (item) { + case 4: return 19; + case 10: return 95; + case 13: return 34; + case 201: return 94; + case 202: return 117; + case 203: return 24; + case 204: return 95; + case 205: return 98; + case 206: return 119; + case 207: return 34; + case 208: return 34; + case 209: return 16; + case 210: return 34; + case 211: return 34; + case 212: return 34; + case 213: return 218; + case 214: return 97; + case 215: return 108; + case 216: return 90; + case 217: return 213; + case 218: return 222; + case 219: return 223; + case 220: return 343; + case 221: return 219; + case 222: return 344; + case 223: return 345; + case 224: return 346; + case 225: return 347; + case 226: return 77; + case 227: return 1417; + case 228: return 1418; + case 229: return 1419; + case 230: return 1420; + case 231: return 344; + case 232: return 345; + case 233: return 218; + case 234: return 219; + case 235: return 56; + case 236: return 57; + case 237: return 1551; + case 238: return 1553; + case 239: return 1554; + case 240: return 1555; + case 241: return 1556; + case 242: return 1552; + case 250: return 40; + case 251: return 40; + case 252: return 74; + case 253: return 74; + case 254: return 74; + case 255: return 74; + case 256: return 318; + case 257: return 319; + } + break; + case 6: + switch (item) { + case 2: return 56; + case 3: return 57; + case 201: return 61; + case 202: return 62; + case 203: return 150; + case 204: return 152; + case 205: return 153; + case 206: return 154; + case 207: return 68; + case 208: return 69; + case 209: return 70; + case 210: return 71; + case 211: return 124; + case 212: return 124; + case 213: return 125; + } + break; + case 7: + switch (item) { + case 2: return 56; + case 3: return 57; + case 201: return 195; + case 202: return 196; + } + break; + case 8: + switch (item) { + case 23: return 93; + case 24: return 16; + case 201: return 110; + case 202: return 197; + case 203: return 274; + case 204: return 111; + case 205: return 112; + case 206: return 337; + case 207: return 338; + case 208: return 106; + case 209: return 271; + case 210: return 329; + case 211: return 330; + case 212: return 331; + case 213: return 332; + case 214: return 333; + case 215: return 334; + case 216: return 335; + case 217: return 336; + case 218: return 326; + case 219: return 321; + case 220: return 323; + case 221: return 325; + case 222: return 327; + case 223: return 122; + case 224: return 342; + case 225: return 23; + case 226: return 141; + case 228: return 1381; + case 229: return 1385; + case 230: return 1386; + case 231: return 1530; + case 233: return 1531; + case 234: return 1532; + case 235: return 1533; + } + break; + case 9: + switch (item) { + case 4: return 16; + case 10: return 95; + case 201: return 220; + case 202: return 33; + case 203: return 33; + case 204: return 32; + case 205: return 31; + case 206: return 79; + case 207: return 78; + case 208: return 136; + case 209: return 136; + case 210: return 136; + case 211: return 136; + case 212: return 136; + case 213: return 136; + case 214: return 136; + case 215: return 136; + case 216: return 30; + case 217: return 30; + case 218: return 29; + case 219: return 75; + case 220: return 76; + case 221: return 139; + case 222: return 41; + case 223: return 216; + case 224: return 1425; + case 225: return 1426; + case 226: return 1427; + case 227: return 1729; + case 228: return 1730; + } + break; + case 10: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 201: return 224; + case 202: return 225; + case 203: return 151; + case 204: return 43; + case 205: return 28; + case 206: return 3; + case 207: return 229; + case 208: return 230; + case 209: return 231; + case 210: return 232; + case 211: return 233; + case 212: return 234; + case 213: return 235; + case 214: return 236; + case 215: return 263; + case 216: return 264; + case 217: return 265; + case 218: return 266; + case 219: return 267; + case 220: return 268; + case 221: return 269; + case 222: return 270; + case 223: return 56; + case 224: return 57; + case 225: return 88; + case 226: return 56; + case 227: return 57; + case 228: return 88; + case 229: return 79; + case 230: return 78; + } + break; + case 12: + switch (item) { + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 201: return 40; + case 202: return 40; + } + break; + case 13: + switch (item) { + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 201: return 184; + } + break; + case 14: + switch (item) { + case 201: return 259; + } + break; + case 15: + switch (item) { + case 201: return 56; + case 202: return 57; + case 203: return 190; + case 204: return 8; + case 205: return 190; + case 206: return 1; + case 207: return 4; + case 208: return 8; + case 209: return 56; + case 210: return 57; + case 211: return 190; + case 212: return 56; + case 213: return 57; + case 214: return 82; + case 215: return 60; + case 216: return 16; + case 217: return 11; + case 218: return 12; + case 219: return 13; + case 220: return 58; + case 221: return 59; + case 222: return 40; + case 223: return 14; + case 224: return 53; + case 225: return 54; + case 226: return 95; + case 227: return 46; + case 228: return 47; + case 229: return 82; + case 230: return 19; + case 231: return 144; + case 232: return 145; + case 233: return 146; + case 234: return 147; + case 235: return 1334; + case 236: return 1335; + case 237: return 63; + case 238: return 1; + case 239: return 1334; + case 240: return 1334; + case 241: return 1399; + } + break; + case 16: + switch (item) { + case 201: return 1; + case 202: return 1; + case 203: return 16; + case 204: return 88; + case 205: return 22; + case 206: return 191; + case 207: return 4; + case 208: return 8; + case 209: return 4; + case 210: return 1; + case 211: return 8; + case 212: return 35; + case 213: return 35; + case 214: return 8; + case 215: return 16; + case 216: return 1; + case 217: return 4; + case 218: return 1; + case 219: return 189; + case 220: return 1; + case 221: return 199; + case 222: return 8; + case 223: return 189; + case 224: return 15; + case 225: return 1; + case 226: return 501; + case 227: return 502; + case 228: return 503; + case 229: return 504; + case 230: return 505; + case 231: return 506; + case 232: return 507; + case 233: return 508; + case 234: return 509; + case 235: return 510; + case 236: return 511; + case 237: return 512; + case 238: return 513; + case 239: return 514; + case 240: return 515; + case 241: return 516; + case 242: return 517; + case 243: return 518; + case 244: return 519; + case 245: return 520; + case 246: return 521; + case 247: return 522; + case 248: return 523; + case 249: return 524; + case 250: return 525; + case 251: return 526; + case 252: return 527; + case 253: return 528; + case 254: return 529; + } + break; + case 17: + switch (item) { + case 201: return 1494; + case 202: return 1495; + case 203: return 1496; + case 204: return 1497; + } + break; + case 18: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 201: return 290; + case 202: return 291; + case 203: return 292; + case 204: return 294; + case 205: return 295; + case 209: return 288; + case 211: return 303; + case 212: return 304; + case 213: return 305; + case 214: return 309; + case 215: return 310; + case 219: return 289; + case 223: return 306; + case 231: return 304; + case 241: return 305; + case 242: return 305; + case 251: return 306; + case 252: return 306; + case 261: return 303; + case 262: return 304; + case 271: return 24; + case 272: return 304; + } + break; + case 19: + switch (item) { + case 1: return 1512; + case 2: return 1513; + case 3: return 1514; + case 4: return 1515; + case 5: return 1516; + case 6: return 1500; + case 7: return 1392; + case 8: return 1500; + case 9: return 1398; + case 10: return 1502; + case 11: return 1503; + case 12: return 1394; + case 13: return 1391; + case 14: return 1392; + case 15: return 1393; + case 16: return 1397; + } + break; + case 21: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 13: return 34; + case 14: return 222; + case 15: return 223; + case 16: return 219; + case 23: return 93; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 28: return 701; + case 29: return 702; + case 31: return 37; + case 32: return 687; + case 61: return 501; + case 62: return 502; + case 63: return 503; + case 64: return 504; + case 65: return 505; + case 66: return 506; + case 67: return 507; + case 68: return 508; + case 69: return 509; + case 70: return 510; + case 71: return 511; + case 72: return 512; + case 73: return 513; + case 74: return 514; + case 75: return 515; + case 76: return 516; + case 77: return 517; + case 78: return 518; + case 79: return 519; + case 80: return 520; + case 81: return 521; + case 82: return 522; + case 83: return 523; + case 84: return 524; + case 85: return 525; + case 86: return 526; + case 87: return 527; + case 88: return 528; + case 89: return 529; + case 201: return 56; + case 202: return 57; + case 203: return 40; + case 205: return 190; + case 206: return 1; + case 207: return 8; + case 208: return 56; + case 209: return 57; + case 210: return 1; + case 211: return 1; + case 212: return 16; + case 213: return 88; + case 214: return 22; + case 215: return 191; + case 216: return 1; + case 217: return 8; + case 218: return 8; + case 219: return 16; + case 220: return 1; + case 221: return 31; + case 222: return 32; + case 223: return 33; + case 224: return 8; + } + break; + case 22: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 13: return 34; + case 14: return 222; + case 15: return 223; + case 16: return 219; + case 23: return 93; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 28: return 701; + case 29: return 702; + case 31: return 37; + case 32: return 687; + case 61: return 501; + case 62: return 502; + case 63: return 503; + case 64: return 504; + case 65: return 505; + case 66: return 506; + case 67: return 507; + case 68: return 508; + case 69: return 509; + case 70: return 510; + case 71: return 511; + case 72: return 512; + case 73: return 513; + case 74: return 514; + case 75: return 515; + case 76: return 516; + case 77: return 517; + case 78: return 518; + case 79: return 519; + case 80: return 520; + case 81: return 521; + case 82: return 522; + case 83: return 523; + case 84: return 524; + case 85: return 525; + case 86: return 526; + case 87: return 527; + case 88: return 528; + case 89: return 529; + case 201: return 56; + case 202: return 57; + case 203: return 40; + case 205: return 190; + case 206: return 1; + case 207: return 8; + case 208: return 56; + case 209: return 57; + case 210: return 1; + case 211: return 1; + case 212: return 16; + case 213: return 88; + case 214: return 22; + case 215: return 191; + case 216: return 1; + case 217: return 8; + case 218: return 8; + case 219: return 16; + case 220: return 1; + case 221: return 31; + case 222: return 32; + case 223: return 33; + case 224: return 8; + } + break; + case 23: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 13: return 34; + case 14: return 222; + case 15: return 223; + case 16: return 219; + case 23: return 93; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 28: return 701; + case 29: return 702; + case 31: return 37; + case 32: return 687; + case 61: return 501; + case 62: return 502; + case 63: return 503; + case 64: return 504; + case 65: return 505; + case 66: return 506; + case 67: return 507; + case 68: return 508; + case 69: return 509; + case 70: return 510; + case 71: return 511; + case 72: return 512; + case 73: return 513; + case 74: return 514; + case 75: return 515; + case 76: return 516; + case 77: return 517; + case 78: return 518; + case 79: return 519; + case 80: return 520; + case 81: return 521; + case 82: return 522; + case 83: return 523; + case 84: return 524; + case 85: return 525; + case 86: return 526; + case 87: return 527; + case 88: return 528; + case 89: return 529; + case 201: return 56; + case 202: return 57; + case 203: return 40; + case 205: return 190; + case 206: return 1; + case 207: return 8; + case 208: return 56; + case 209: return 57; + case 210: return 1; + case 211: return 1; + case 212: return 16; + case 213: return 88; + case 214: return 22; + case 215: return 191; + case 216: return 1; + case 217: return 8; + case 218: return 8; + case 219: return 16; + case 220: return 1; + case 221: return 31; + case 222: return 32; + case 223: return 33; + case 224: return 8; + } + break; + case 24: + switch (item) { + case 1: return 8; + case 2: return 56; + case 3: return 57; + case 4: return 19; + case 10: return 95; + case 13: return 34; + case 14: return 222; + case 15: return 223; + case 16: return 219; + case 23: return 93; + case 24: return 16; + case 25: return 5; + case 26: return 324; + case 28: return 701; + case 29: return 702; + case 31: return 37; + case 32: return 687; + case 61: return 501; + case 62: return 502; + case 63: return 503; + case 64: return 504; + case 65: return 505; + case 66: return 506; + case 67: return 507; + case 68: return 508; + case 69: return 509; + case 70: return 510; + case 71: return 511; + case 72: return 512; + case 73: return 513; + case 74: return 514; + case 75: return 515; + case 76: return 516; + case 77: return 517; + case 78: return 518; + case 79: return 519; + case 80: return 520; + case 81: return 521; + case 82: return 522; + case 83: return 523; + case 84: return 524; + case 85: return 525; + case 86: return 526; + case 87: return 527; + case 88: return 528; + case 89: return 529; + case 201: return 56; + case 202: return 57; + case 203: return 40; + case 205: return 190; + case 206: return 1; + case 207: return 8; + case 208: return 56; + case 209: return 57; + case 210: return 1; + case 211: return 1; + case 212: return 16; + case 213: return 88; + case 214: return 22; + case 215: return 191; + case 216: return 1; + case 217: return 8; + case 218: return 8; + case 219: return 16; + case 220: return 1; + case 221: return 31; + case 222: return 32; + case 223: return 33; + case 224: return 8; + } + break; + } + break; + case 2: + switch (section) { + case 0: + switch (item) { + case 101: return 601; + case 102: return 602; + case 103: return 801; + case 104: return 802; + case 105: return 803; + case 106: return 804; + case 107: return 805; + case 108: return 806; + case 109: return 807; + case 110: return 808; + case 111: return 809; + case 112: return 810; + case 113: return 811; + case 114: return 812; + case 115: return 813; + case 116: return 814; + case 117: return 815; + case 118: return 816; + case 119: return 817; + case 120: return 818; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 131: return 612; + case 132: return 613; + case 133: return 614; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 139: return 733; + case 140: return 734; + case 141: return 688; + case 142: return 685; + case 143: return 684; + case 144: return 686; + case 145: return 0; + case 146: return 683; + case 147: return 687; + case 148: return 728; + case 149: return 729; + case 150: return 721; + case 151: return 722; + case 152: return 627; + case 161: return 625; + case 162: return 626; + case 165: return 629; + case 166: return 631; + case 167: return 0; + case 170: return 698; + case 171: return 623; + case 172: return 624; + case 175: return 670; + case 176: return 670; + case 180: return 650; + case 181: return 649; + case 182: return 0; + case 183: return 675; + case 185: return 671; + case 186: return 672; + case 190: return 681; + case 191: return 682; + case 192: return 615; + case 193: return 616; + case 194: return 658; + case 195: return 609; + case 196: return 713; + case 197: return 714; + case 198: return 715; + case 199: return 716; + case 200: return 838; + } + break; + case 30: + switch (item) { + case 201: return 680; + case 202: return 653; + case 203: return 671; + case 204: return 672; + case 205: return 678; + case 206: return 626; + case 207: return 623; + case 208: return 685; + case 210: return 647; + case 211: return 740; + case 212: return 740; + case 213: return 740; + case 214: return 740; + case 215: return 740; + case 216: return 740; + case 217: return 740; + case 218: return 740; + case 219: return 740; + case 220: return 740; + case 221: return 740; + case 222: return 740; + case 223: return 740; + case 224: return 740; + case 225: return 740; + case 226: return 740; + case 227: return 740; + case 228: return 740; + case 229: return 740; + case 230: return 740; + case 231: return 801; + case 232: return 802; + case 233: return 803; + case 234: return 804; + case 235: return 805; + case 236: return 806; + case 237: return 807; + case 238: return 808; + case 239: return 809; + case 240: return 810; + case 241: return 811; + case 242: return 642; + case 243: return 813; + case 244: return 814; + case 245: return 815; + case 246: return 713; + case 247: return 714; + case 248: return 645; + case 249: return 646; + case 250: return 647; + case 251: return 648; + case 252: return 891; + case 253: return 892; + case 254: return 893; + case 255: return 894; + case 256: return 895; + case 257: return 896; + case 258: return 897; + case 259: return 898; + case 260: return 899; + case 261: return 900; + case 262: return 901; + case 263: return 902; + case 264: return 903; + case 265: return 904; + case 266: return 905; + case 267: return 906; + case 268: return 907; + case 269: return 908; + case 270: return 909; + case 271: return 910; + case 272: return 911; + case 273: return 912; + case 274: return 913; + case 275: return 914; + case 276: return 915; + case 277: return 916; + case 278: return 917; + case 279: return 678; + case 280: return 632; + case 281: return 831; + case 282: return 832; + case 283: return 833; + case 284: return 834; + case 285: return 617; + case 286: return 795; + case 287: return 695; + case 288: return 796; + case 289: return 696; + case 290: return 797; + case 291: return 697; + case 292: return 673; + case 293: return 674; + case 294: return 867; + case 296: return 795; + case 297: return 695; + case 298: return 796; + case 299: return 696; + case 301: return 637; + case 302: return 865; + case 303: return 866; + case 306: return 648; + case 307: return 648; + case 308: return 648; + case 309: return 648; + case 310: return 648; + case 311: return 648; + case 312: return 648; + case 313: return 648; + case 314: return 648; + case 315: return 648; + case 316: return 648; + case 317: return 648; + case 318: return 648; + case 319: return 648; + case 320: return 703; + case 321: return 704; + case 322: return 648; + } + break; + case 31: + switch (item) { + case 201: return 715; + case 202: return 618; + case 211: return 660; + case 212: return 661; + case 213: return 662; + case 214: return 663; + case 215: return 664; + case 216: return 665; + case 217: return 666; + case 218: return 667; + case 219: return 668; + case 220: return 669; + } + break; + case 32: + switch (item) { + case 201: return 683; + case 202: return 687; + case 203: return 688; + case 204: return 687; + case 209: return 731; + case 210: return 732; + case 211: return 683; + case 212: return 687; + case 213: return 688; + case 214: return 626; + case 215: return 623; + case 216: return 601; + case 217: return 626; + case 218: return 626; + case 219: return 733; + case 220: return 734; + case 221: return 735; + case 222: return 736; + case 223: return 918; + case 224: return 919; + case 225: return 920; + case 226: return 919; + case 227: return 918; + case 228: return 919; + case 229: return 920; + case 230: return 737; + case 231: return 738; + } + break; + case 35: + switch (item) { + case 101: return 601; + case 102: return 602; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 201: return 850; + case 202: return 851; + case 203: return 852; + case 204: return 853; + case 205: return 854; + case 206: return 855; + case 211: return 860; + case 213: return 862; + case 214: return 863; + case 215: return 864; + case 221: return 871; + case 224: return 872; + case 225: return 873; + case 231: return 876; + case 234: return 877; + case 235: return 878; + case 241: return 880; + case 244: return 881; + case 245: return 882; + case 251: return 885; + case 254: return 888; + case 255: return 884; + } + break; + case 41: + switch (item) { + case 101: return 601; + case 102: return 602; + case 103: return 801; + case 104: return 802; + case 105: return 803; + case 106: return 804; + case 107: return 805; + case 108: return 806; + case 109: return 807; + case 110: return 808; + case 111: return 809; + case 112: return 810; + case 113: return 811; + case 114: return 812; + case 115: return 813; + case 116: return 814; + case 117: return 815; + case 118: return 816; + case 119: return 817; + case 120: return 818; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 131: return 612; + case 132: return 613; + case 133: return 614; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 139: return 633; + case 140: return 634; + case 141: return 688; + case 142: return 685; + case 143: return 684; + case 144: return 686; + case 145: return 0; + case 146: return 683; + case 147: return 687; + case 148: return 728; + case 149: return 729; + case 150: return 721; + case 151: return 722; + case 152: return 627; + case 161: return 625; + case 162: return 626; + case 165: return 629; + case 166: return 631; + case 167: return 0; + case 170: return 698; + case 171: return 623; + case 172: return 624; + case 180: return 650; + case 181: return 649; + case 182: return 0; + case 183: return 675; + case 185: return 671; + case 186: return 672; + case 187: return 678; + case 190: return 681; + case 191: return 682; + } + break; + case 42: + switch (item) { + case 101: return 601; + case 102: return 602; + case 103: return 801; + case 104: return 802; + case 105: return 803; + case 106: return 804; + case 107: return 805; + case 108: return 806; + case 109: return 807; + case 110: return 808; + case 111: return 809; + case 112: return 810; + case 113: return 811; + case 114: return 812; + case 115: return 813; + case 116: return 814; + case 117: return 815; + case 118: return 816; + case 119: return 817; + case 120: return 818; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 131: return 612; + case 132: return 613; + case 133: return 614; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 139: return 633; + case 140: return 634; + case 141: return 688; + case 142: return 685; + case 143: return 684; + case 144: return 686; + case 145: return 0; + case 146: return 683; + case 147: return 687; + case 148: return 728; + case 149: return 729; + case 150: return 721; + case 151: return 722; + case 152: return 627; + case 161: return 625; + case 162: return 626; + case 165: return 629; + case 166: return 631; + case 167: return 0; + case 170: return 698; + case 171: return 623; + case 172: return 624; + case 180: return 650; + case 181: return 649; + case 182: return 0; + case 183: return 675; + case 185: return 671; + case 186: return 672; + case 187: return 678; + case 190: return 681; + case 191: return 682; + } + break; + case 43: + switch (item) { + case 101: return 601; + case 102: return 602; + case 103: return 801; + case 104: return 802; + case 105: return 803; + case 106: return 804; + case 107: return 805; + case 108: return 806; + case 109: return 807; + case 110: return 808; + case 111: return 809; + case 112: return 810; + case 113: return 811; + case 114: return 812; + case 115: return 813; + case 116: return 814; + case 117: return 815; + case 118: return 816; + case 119: return 817; + case 120: return 818; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 131: return 612; + case 132: return 613; + case 133: return 614; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 139: return 633; + case 140: return 634; + case 141: return 688; + case 142: return 685; + case 143: return 684; + case 144: return 686; + case 145: return 0; + case 146: return 683; + case 147: return 687; + case 148: return 728; + case 149: return 729; + case 150: return 721; + case 151: return 722; + case 152: return 627; + case 161: return 625; + case 162: return 626; + case 165: return 629; + case 166: return 631; + case 167: return 0; + case 170: return 698; + case 171: return 623; + case 172: return 624; + case 180: return 650; + case 181: return 649; + case 182: return 0; + case 183: return 675; + case 185: return 671; + case 186: return 672; + case 187: return 678; + case 190: return 681; + case 191: return 682; + } + break; + case 44: + switch (item) { + case 101: return 601; + case 102: return 602; + case 103: return 801; + case 104: return 802; + case 105: return 803; + case 106: return 804; + case 107: return 805; + case 108: return 806; + case 109: return 807; + case 110: return 808; + case 111: return 809; + case 112: return 810; + case 113: return 811; + case 114: return 812; + case 115: return 813; + case 116: return 814; + case 117: return 815; + case 118: return 816; + case 119: return 817; + case 120: return 818; + case 121: return 701; + case 122: return 702; + case 130: return 611; + case 131: return 612; + case 132: return 613; + case 133: return 614; + case 134: return 608; + case 135: return 711; + case 136: return 712; + case 137: return 653; + case 139: return 633; + case 140: return 634; + case 141: return 688; + case 142: return 685; + case 143: return 684; + case 144: return 686; + case 145: return 0; + case 146: return 683; + case 147: return 687; + case 148: return 728; + case 149: return 729; + case 150: return 721; + case 151: return 722; + case 152: return 627; + case 161: return 625; + case 162: return 626; + case 165: return 629; + case 166: return 631; + case 167: return 0; + case 170: return 698; + case 171: return 623; + case 172: return 624; + case 180: return 650; + case 181: return 649; + case 182: return 0; + case 183: return 675; + case 185: return 671; + case 186: return 672; + case 187: return 678; + case 190: return 681; + case 191: return 682; + } + break; + } + break; + case 3: + switch (section) { + case 0: + switch (item) { + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 210: return 16; + case 211: return 728; + case 212: return 729; + } + break; + case 21: + switch (item) { + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 225: return 16; + case 226: return 728; + case 227: return 729; + } + break; + case 22: + switch (item) { + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 225: return 16; + case 226: return 728; + case 227: return 729; + } + break; + case 23: + switch (item) { + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 225: return 16; + case 226: return 728; + case 227: return 729; + } + break; + case 24: + switch (item) { + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 225: return 16; + case 226: return 728; + case 227: return 729; + } + break; + case 40: + switch (item) { + case 23: return 93; + case 24: return 16; + case 31: return 37; + case 32: return 687; + case 177: return 620; + case 178: return 650; + case 179: return 675; + case 201: return 620; + case 202: return 620; + case 203: return 687; + case 204: return 683; + case 205: return 687; + case 206: return 687; + case 207: return 688; + case 208: return 683; + case 209: return 687; + case 210: return 688; + case 211: return 684; + case 212: return 689; + case 213: return 690; + case 214: return 188; + case 215: return 188; + case 216: return 14; + case 217: return 14; + case 218: return 910; + case 219: return 911; + case 220: return 685; + case 221: return 912; + case 222: return 108; + case 223: return 108; + case 224: return 687; + case 225: return 688; + case 226: return 15; + } + break; + } + break; + case 4: + switch (section) { + case 0: + switch (item) { + case 1: return 351; + case 2: return 38; + case 3: return 2; + case 4: return 56; + case 5: return 57; + case 6: return 61; + case 7: return 62; + case 8: return 37; + case 9: return 364; + case 10: return 365; + } + break; + case 1: + switch (item) { + case 1: return 353; + } + break; + case 2: + switch (item) { + case 1: return 367; + case 2: return 61; + case 3: return 62; + case 4: return 364; + case 5: return 365; + case 6: return 366; + case 7: return 354; + } + break; + case 3: + switch (item) { + case 1: return 355; + } + break; + case 4: + switch (item) { + case 1: return 356; + } + break; + case 5: + switch (item) { + case 1: return 357; + } + break; + case 6: + switch (item) { + case 1: return 387; + case 2: return 393; + case 3: return 394; + case 4: return 392; + case 5: return 385; + case 6: return 388; + case 7: return 389; + case 8: return 386; + case 9: return 390; + case 10: return 391; + case 11: return 398; + case 12: return 381; + case 13: return 382; + case 14: return 383; + case 15: return 399; + case 16: return 400; + case 17: return 50; + case 18: return 55; + } + break; + case 7: + switch (item) { + case 1: return 358; + case 2: return 359; + case 3: return 360; + } + } + } + return -1; +} + +/*------------------------------------------------------------------------------- + * PERL CODE USED TO GENERATE THE ABOVE SWITCH STATEMENT FROM STASHMASTER FILE(S) + * ============================================================================== + * + * #!/usr/bin/perl + * + * $Sm=" switch (model) {\n"; + * $Em=" }\n"; + * $sm=" case %d:\n"; + * $em=" break;\n"; + * + * $Ss=" switch (section) {\n"; + * $Es=" }\n"; + * $ss=" case %d:\n"; + * $es=" break;\n"; + * + * $Si=" switch (item) {\n"; + * $Ei=" }\n"; + * $si=" case %d: "; + * #$ei=" break;\n"; + * $ei="\n"; + * + * + * $first=1; + * $lm=$ls=-1; + * $open=0; + * while (<>){ + * if (/^1\|\s*([0-9]+)\s*\|\s*([0-9]+)\s*\|\s*([0-9]+)\s*\|/) { + * ($m,$s,$i)=($1,$2,$3); + * $open=1; + * } + * elsif ($open && /^5\|\s*([0-9]+)\s*\|\s*([0-9]+)\s*\|/) { + * $open=0; + * $ppcode=$2; + * + * if ($first) { + * print $Sm; + * printf $sm,$m; + * print $Ss; + * printf $ss,$s; + * print $Si; + * } else { + * + * if ($s != $ls) { + * print $Ei; + * print $es; + * } + * if ($m != $lm) { + * print $Es; + * print $em; + * printf $sm,$m; + * print $Ss; + * } + * if ($s != $ls) { + * printf $ss,$s; + * print $Si; + * } + * } + * + * $name =~ s/ +/ /g; + * $name =~ s/\s+$//; + * $name =~ s/\"/\\\"/g; + * + * printf $si,$i; + * print "return $ppcode;"; + * print $ei; + * $first=0; + * ($lm,$ls)=($m,$s); + * } + * } + * + * print $Ei; + * print $Es; + * print $Em; + * + */ + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_stashname.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_stashname.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_stashname.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_stashname.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,1877 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* returns name corresponding to stash codes, or NULL if not found. */ + +/* NOTE: the code of this function was largely auto-generated from the stashmaster files + * from UM version 4.5. See below for perl script. + */ + +char *pp_stashname(int model, int section, int item) +{ + switch (model) { + case 1: + switch (section) { + case 0: + switch (item) { + case 1: return "PSTAR AFTER TIMESTEP"; + case 2: return "U COMPNT OF WIND AFTER TIMESTEP"; + case 3: return "V COMPNT OF WIND AFTER TIMESTEP"; + case 4: return "THETA AFTER TIMESTEP"; + case 5: return "THETAL IN THE EXTERNAL DUMP"; + case 9: return "SOIL MOISTURE CONTENT IN A LAYER"; + case 10: return "SPECIFIC HUMIDITY AFTER TIMESTEP"; + case 11: return "QT IN THE EXTERNAL DUMP"; + case 12: return "QCF IN THE EXTERNAL DUMP"; + case 13: return "CONV CLOUD AMOUNT AFTER TIMESTEP"; + case 14: return "CONV CLOUD BASE LEVEL NO. AFTER TS"; + case 15: return "CONV CLOUD TOP LEVEL NO. AFTER TS"; + case 16: return "CONV CLOUD LIQUID WATER PATH"; + case 17: return "SILHOUETTE OROGRAPHIC ROUGHNESS"; + case 18: return "HALF OF (PEAK TO TROUGH HT OF OROG)"; + case 20: return "DEEP SOIL TEMP AFTER TIMESTEP"; + case 21: return "SOIL MOISTURE CONTENT AFTER TS KG/M2"; + case 22: return "CANOPY WATER AFTER TIMESTEP KG/M2"; + case 23: return "SNOW AMOUNT AFTER TIMESTEP KG/M2"; + case 24: return "SURFACE TEMPERATURE AFTER TIMESTEP"; + case 25: return "BOUNDARY LAYER DEPTH AFTER TIMESTEP"; + case 26: return "ROUGHNESS LENGTH AFTER TIMESTEP"; + case 27: return "SNOW EDGE AFTER TIMESTEP **"; + case 28: return "SURFACE ZONAL CURRENT AFTER TIMESTEP"; + case 29: return "SURFACE MERID CURRENT AFTER TIMESTEP"; + case 30: return "LAND MASK (LOGICAL: LAND=TRUE)"; + case 31: return "SEA ICE FRACTION AFTER TIMESTEP"; + case 32: return "SEA ICE DEPTH (MEAN OVER ICE) M"; + case 33: return "OROGRAPHY (/STRAT LOWER BC)"; + case 34: return "STANDARD DEVIATION OF OROGRAPHY"; + case 35: return "OROGRAPHIC GRADIENT XX COMPONENT"; + case 36: return "OROGRAPHIC GRADIENT XY COMPONENT"; + case 37: return "OROGRAPHIC GRADIENT YY COMPONENT"; + case 38: return "ICE EDGE IN THE ANCILLARY FILE ONLY"; + case 39: return "SST ANOMALY"; + case 40: return "VOL SMC AT WILTING AFTER TIMESTEP"; + case 41: return "VOL SMC AT CRIT PT AFTER TIMESTEP"; + case 42: return "VOL SMC AT FIELD CAP AFTER TIMESTEP"; + case 43: return "VOL SMC AT SATURATION AFTER TIMESTEP"; + case 44: return "SAT SOIL CONDUCTIVITY AFTER TIMESTEP"; + case 45: return "EAGLESON'S EXPONENT AFTER TIMESTEP"; + case 46: return "THERMAL CAPACITY AFTER TIMESTEP"; + case 47: return "THERMAL CONDUCTIVITY AFTER TIMESTEP"; + case 48: return "SATURATED SOIL WATER SUCTION **"; + case 49: return "SEA-ICE TEMPERATURE AFTER TIMESTEP"; + case 50: return "VEGETATION FRACTION AFTER TIMESTEP"; + case 51: return "ROOT DEPTH AFTER TIMESTEP"; + case 52: return "SNOW-FREE SURFACE ALBEDO AFTER TS"; + case 53: return "DEEP SNOW SURFACE ALBEDO AFTER TS"; + case 54: return "SURFACE RESISTANCE TO EVAP AFTER TS"; + case 55: return "SURFACE CAPACITY AFTER TIMESTEP"; + case 56: return "INFILTRATION FACTOR AFTER TIMESTEP"; + case 57: return "TOTAL AEROSOL EMISSIONS (FOR VIS)"; + case 58: return "SULPHUR DIOXIDE EMISSIONS"; + case 59: return "DIMETHYL SULPHIDE EMISSIONS"; + case 60: return "OZONE **"; + case 61: return "ATM TRACER 1 (CONVEN O3 )AFTER TS"; + case 62: return "ATM TRACER 2 (CONVEN H2O )AFTER TS"; + case 63: return "ATM TRACER 3 (CONVEN CO )AFTER TS"; + case 64: return "ATM TRACER 4 (CONVEN CH4 )AFTER TS"; + case 65: return "ATM TRACER 5 (CONVEN N2O )AFTER TS"; + case 66: return "ATM TRACER 6 (CONVEN NO )AFTER TS"; + case 67: return "ATM TRACER 7 (CONVEN NO2 )AFTER TS"; + case 68: return "ATM TRACER 8 (CONVEN HNO3 )AFTER TS"; + case 69: return "ATM TRACER 9 (CONVEN N2O5 )AFTER TS"; + case 70: return "ATM TRACER 10 (CONVN CLONO2)AFTER TS"; + case 71: return "ATM TRACER 11 (CONVEN CLO )AFTER TS"; + case 72: return "ATM TRACER 12 (CONVEN HCL )AFTER TS"; + case 73: return "ATM TRACER 13 (CONVN CF2CL2)AFTER TS"; + case 74: return "ATM TRACER 14 (CONVEN CFCL3)AFTER TS"; + case 75: return "ATM TRACER 15 (CONVEN HF )AFTER TS"; + case 76: return "ATM TRACER 16 (CONVEN -----)AFTER TS"; + case 77: return "ATM TRACER 17 (CONVEN -----)AFTER TS"; + case 78: return "ATM TRACER 18 (CONVEN -----)AFTER TS"; + case 79: return "ATM TRACER 19 (CONVEN ---- )AFTER TS"; + case 80: return "ATM TRACER 20 (CONVEN ---- )AFTER TS"; + case 81: return "ATM TRACER 21 (CONVEN H2S )AFTER TS"; + case 82: return "ATM TRACER 22 (CONV WATER-SOL)AFT TS"; + case 83: return "ATM TRACER 23 (CONV \"DUST\" )AFTER TS"; + case 84: return "ATM TRACER 24 (CONV OCEANIC)AFTER TS"; + case 85: return "ATM TRACER 25 (CONVEN SOOT )AFTER TS"; + case 86: return "ATM TRACER 26 (CONV VOLC ASH) AFT TS"; + case 87: return "ATM TRACER 27 (CONVEN H2SO4)AFTER TS"; + case 88: return "ATM TRACER 28 (NH4)2SO4 AFTER TS"; + case 89: return "ATM TRACER 29 (CONV MINERAL)AFTER TS"; + case 90: return "TOTAL AEROSOL (FOR VISIBILITY)"; + case 93: return "RUNOFF COASTAL OUTFLOW POINT"; + case 96: return "HORIZ BOUNDARY TENDS: UNAVAILABLE"; + case 97: return "HORIZ BOUNDARY VALUES: UNAVAILABLE"; + case 98: return "LOWER BOUNDARY TENDENCIES (OROG)"; + case 101: return "SO2 MASS MIXING RATIO AFTER TSTEP"; + case 102: return "DIMETHYL SULPHIDE MIX RAT AFTER TS"; + case 103: return "SO4 AITKEN MODE AEROSOL AFTER TSTEP"; + case 104: return "SO4 ACCUM. MODE AEROSOL AFTER TSTEP"; + case 105: return "SO4 DISSOLVED AEROSOL AFTER TSTEP"; + case 106: return "H2O2 MASS MIXING RATIO AFTER TSTEP"; + case 107: return "NH3 MASS MIXING RATIO AFTER TSTEP"; + case 108: return "FRESH SOOT MASS MIX RAT AFTER TSTEP"; + case 109: return "AGED SOOT MASS MIX RAT AFTER TSTEP"; + case 110: return "CLOUD SOOT MASS MIX RAT AFTER TSTEP"; + case 121: return "3D NATURAL SO2 EMISSIONS KG/M2/S"; + case 122: return "3D OH CONCENTRATIONS IN MCULES/CC"; + case 123: return "3D HO2 CONCENTRATIONS IN MCULES/CC"; + case 124: return "3D H2O2 MIX RATIO LIMIT FIELD"; + case 125: return "3D OZONE MIX RAT FOR SULPHUR CYCLE"; + case 126: return "HIGH LEVEL SO2 EMISSIONS KG/M2/S"; + case 127: return "AMMONIA GAS EMISSIONS KG/M2/S"; + case 128: return "FRESH SOOT SURF EMISS KG/M2/S"; + case 129: return "FRESH SOOT HI LEV EMISS KG/M2/S"; + case 150: return "W COMP OF WIND C-P TH LEVS:VAR DUMMY"; + case 151: return "PRESSURE C-P RHO LEVS:VAR DUMMY"; + case 152: return "DENSITY*R*R C-P RHO LEVS:VAR DUMMY"; + case 153: return "U COMP OF WIND C-P RHO LEVS:VAR DUM"; + case 154: return "V COMP OF WIND C-P RHO LEVS:VAR DUM"; + case 160: return "HADCM2 SULPHATE LOADING PATTERNS"; + case 201: return "PSTAR PERTURBATION- DUMMY"; + case 202: return "U COMPNT PERTURBATION- DUMMY"; + case 203: return "V COMPNT PERTURBATION- DUMMY"; + case 204: return "THETA PERTURBATION- DUMMY"; + case 205: return "FRACTIONAL LAND COVER"; + case 207: return "CLAPP-HORNBERGER \"B\" COEFFICIENT"; + case 208: return "LEAF AREA INDEX OF VEG FRACTION"; + case 209: return "CANOPY HEIGHT OF VEGETATED FRACTION"; + case 211: return "CCA with anvil after timestep"; + case 213: return "CANOPY CONDUCTANCE AFTER TIMESTEP"; + case 214: return "UNFROZEN SOIL MOISTURE FRAC AFTER TS"; + case 215: return "FROZEN SOIL MOISTURE FRAC AFTER TS"; + case 216: return "FRACTIONS OF SURFACE TYPES"; + case 217: return "LEAF AREA INDEX OF PLANT FUNC TYPES"; + case 218: return "CANOPY HEIGHT OF PLANT FUNC TYPES M"; + case 219: return "DISTURBED FRACTION OF VEGETATION"; + case 220: return "SNOW-FREE ALBEDO OF SOIL"; + case 221: return "SNOW SOOT CONTENT"; + case 222: return "NET ENERGY CHANGE THIS PERIOD J/M**2"; + case 223: return "SOIL CARBON CONTENT KG C / M2"; + case 224: return "ACCUMULATED NPP ON PLANT FUNC TYPES"; + case 225: return "ACCUMULATED LEAF TURNOVER RATE PFTS"; + case 226: return "ACCUMULATED PHENOL LEAF TRNVR PFTS"; + case 227: return "ACCUMULATED WOOD RESPIRATION PFTS"; + case 228: return "ACCUMULATED SOIL RESPIRATION"; + case 229: return "CANOPY WATER ON NON-ICE TILES KG/M2"; + case 230: return "CANOPY CAPACITY NON-ICE TILES KG/M2"; + case 231: return "SNOW GRAIN SIZE MICRONS"; + case 232: return "SNOW TEMPERATURE K"; + case 233: return "SURFACE TEMP ON SNOW-ADJSTD TILES K"; + case 234: return "ROUGHNESS LENGTH ON TILES M"; + case 250: return "CO2 OCEAN FLUX KG/M**2/S"; + case 251: return "CO2 SURFACE EMISSIONS KG/M**2/S"; + case 252: return "CO2 3D TRACER MASS MIXING RATIO"; + case 401: return "P_EXNER IN D1 FOR ADDRESSING ONLY"; + case 402: return " QCL IN D1 FOR ADDRESSING ONLY"; + case 403: return " QCF IN D1 FOR ADDRESSING ONLY"; + case 404: return "RHCRIT IN D1 FOR ADDRESSING ONLY"; + case 405: return "SOIL MOISTURE CONTENT IN D1 FOR ADD"; + } + break; + case 1: + switch (item) { + case 4: return "TEMPERATURE AFTER SW RAD INCREMENTS"; + case 201: return "NET DOWN SURFACE SW FLUX: SW TS ONLY"; + case 202: return "NET DOWN SW FLUX: SOLID SURF: ALL TS"; + case 203: return "NET DOWN SW RAD FLUX: OPEN SEA"; + case 204: return "NET DOWN SURFACE SW FLUX BELOW 690NM"; + case 205: return "SNOW-FREE SURFACE ALBEDO (ANCILLARY)"; + case 206: return "DEEP SNOW SURFACE ALBEDO (ANCILLARY)"; + case 207: return "INCOMING SW RAD FLUX (TOA): ALL TSS"; + case 208: return "OUTGOING SW RAD FLUX (TOA)"; + case 209: return "CLEAR-SKY (II) UPWARD SW FLUX (TOA)"; + case 210: return "CLEAR-SKY (II) DOWN SURFACE SW FLUX"; + case 211: return "CLEAR-SKY (II) UP SURFACE SW FLUX"; + case 212: return "LAYER CLOUD WEIGHTS IN SWRAD"; + case 213: return "CONVECTIVE CLOUD WEIGHTS IN SWRAD"; + case 214: return "LAYER CLOUD DIRECT ALBEDO * AMOUNT"; + case 215: return "LAYER CLOUD DIFFUSE ALBEDO * AMOUNT"; + case 216: return "CONV CLOUD DIRECT ALBEDO * AMOUNT"; + case 217: return "CONV CLOUD DIFFUSE ALBEDO * AMOUNT"; + case 218: return "LAYER CLOUD REDUCED TO 3 LAYERS - SW"; + case 219: return "TOTAL CLOUD AMOUNT IN SW RADIATION"; + case 220: return "CONV CLD LIQ RE * CONV CLD AMOUNT"; + case 221: return "LAYER CLD LIQ RE * LAYER CLD AMOUNT"; + case 222: return "CONV CLD AMT IN SWRAD (MICROPHYSICS)"; + case 223: return "LYR CLD AMT IN SWRAD (MICROPHYSICS)"; + case 224: return "LAYER CLD CONDENSED WATER PATH * AMT"; + case 225: return "CONV CLD LIQ RE * CONV CLD WEIGHT"; + case 226: return "CONV CLD WGT IN SWRAD (MPHY ALL LYR)"; + case 232: return "SW HEATING RATES: ALL TIMESTEPS"; + case 233: return "CLEAR-SKY SW HEATING RATES"; + case 234: return "HADCM2 SULPHATE LOADING (KG/M2)"; + case 235: return "TOTAL DOWNWARD SURFACE SW FLUX"; + case 236: return "HADCM2 SULPHATE FORCING (W/M2)"; + case 237: return "NET DOWNWARD SW FLUX AT THE TROP."; + case 238: return "UPWARD SW FLUX AT THE TROP."; + case 241: return "DROPLET NUMBER CONC * CLOUD AMOUNT"; + case 242: return "LAYER CLOUD LWC * CLOUD AMOUNT"; + case 243: return "SO4 CCN MASS CONC * COND SAMP WEIGHT"; + case 244: return "CONDITIONAL SAMPLING WEIGHT"; + case 245: return "2-D EFFECTIVE RADIUS * 2-D RE WEIGHT"; + case 246: return "WEIGHT FOR 2-D EFFECTIVE RADIUS"; + } + break; + case 2: + switch (item) { + case 4: return "TEMPERATURE AFTER LW RAD INCREMENTS"; + case 201: return "NET DOWN SURFACE LW RAD FLUX"; + case 202: return "NET DOWN LW RAD FLUX: SOLID SURFACE"; + case 203: return "NET DOWN LW RAD FLUX: OPEN SEA"; + case 204: return "TOTAL CLOUD AMOUNT IN LW RADIATION"; + case 205: return "OUTGOING LW RAD FLUX (TOA)"; + case 206: return "CLEAR-SKY (II) UPWARD LW FLUX (TOA)"; + case 207: return "DOWNWARD LW RAD FLUX: SURFACE"; + case 208: return "CLEAR-SKY (II) DOWN SURFACE LW FLUX"; + case 232: return "LW HEATING RATES"; + case 233: return "CLEAR-SKY LW HEATING RATES"; + case 237: return "NET DOWNWARD LW FLUX AT THE TROP."; + case 238: return "TOTAL DOWNWARD LW FLUX AT THE TROP."; + } + break; + case 3: + switch (item) { + case 2: return "U COMPNT OF WIND AFTER B.LAYER"; + case 3: return "V COMPNT OF WIND AFTER B.LAYER"; + case 4: return "TEMPERATURE AFTER B.LAYER"; + case 10: return "SPECIFIC HUMIDITY AFTER B.LAYER"; + case 24: return "SURFACE TEMPERATURE AFTER B.LAYER"; + case 25: return "BOUNDARY LAYER DEPTH AFTER B.LAYER"; + case 26: return "ROUGHNESS LEN. AFTER B.L. (SEE DOC)"; + case 49: return "SEA-ICE TEMPERATURE AFTER B. LAYER"; + case 100: return "FLUX OF TRACER 1 IN BL"; + case 101: return "FLUX OF TRACER 2 IN BL"; + case 102: return "FLUX OF TRACER 3 IN BL"; + case 103: return "FLUX OF TRACER 4 IN BL"; + case 104: return "FLUX OF TRACER 5 IN BL"; + case 105: return "FLUX OF TRACER 6 IN BL"; + case 106: return "FLUX OF TRACER 7 IN BL"; + case 107: return "FLUX OF TRACER 8 IN BL"; + case 108: return "FLUX OF TRACER 9 IN BL"; + case 109: return "FLUX OF TRACER 10 IN BL"; + case 110: return "FLUX OF TRACER 11 IN BL"; + case 111: return "FLUX OF TRACER 12 IN BL"; + case 112: return "FLUX OF TRACER 13 IN BL"; + case 113: return "FLUX OF TRACER 14 IN BL"; + case 114: return "FLUX OF TRACER 15 IN BL"; + case 115: return "FLUX OF TRACER 16 IN BL"; + case 116: return "FLUX OF TRACER 17 IN BL"; + case 117: return "FLUX OF TRACER 18 IN BL"; + case 118: return "FLUX OF TRACER 19 IN BL"; + case 119: return "FLUX OF TRACER 20 IN BL"; + case 120: return "FLUX OF TRACER 21 IN BL"; + case 121: return "FLUX OF TRACER 22 IN BL"; + case 122: return "FLUX OF TRACER 23 IN BL"; + case 123: return "FLUX OF TRACER 24 IN BL"; + case 124: return "FLUX OF TRACER 25 IN BL"; + case 125: return "FLUX OF TRACER 26 IN BL"; + case 126: return "FLUX OF TRACER 27 IN BL"; + case 127: return "FLUX OF TRACER 28 IN BL"; + case 128: return "FLUX OF TRACER 29 IN BL"; + case 129: return "FLUX OF TOTAL AEROSOL IN BL"; + case 201: return "HEAT FLUX THROUGH SEA ICE (GBM) W/M2"; + case 202: return "HT FLUX FROM SURF TO DEEP SOIL LEV 1"; + case 203: return "CD"; + case 204: return "CH"; + case 205: return "SURFACE LAYER WIND SHEAR"; + case 206: return "RHOSTAR * CD * SURF_LAYER_WIND_SHEAR"; + case 207: return "RHOSTAR * CH * SURF_LAYER_WIND_SHEAR"; + case 208: return "LOWEST LAYER BULK RICHARDSON NO. RIB"; + case 217: return "SURFACE & B.LAYER HEAT FLUXES W/M2"; + case 219: return "X-COMP OF SURF & BL WIND STRESS N/M2"; + case 220: return "Y-COMP OF SURF & BL WIND STRESS N/M2"; + case 223: return "SURF & BL TOTL MOISTURE FLUX KG/M2/S"; + case 224: return "WIND MIXING EN'GY FLUX INTO SEA W/M2"; + case 225: return "10 METRE WIND U-COMP"; + case 226: return "10 METRE WIND V-COMP"; + case 228: return "SURFACE SH FLUX FROM SEA (GBM) W/M2"; + case 229: return "EVAP FROM SOIL SURF -AMOUNT KG/M2/TS"; + case 230: return "EVAP FROM CANOPY - AMOUNT KG/M2/TS"; + case 231: return "SUBLIM. FROM SURFACE (GBM) KG/M2/TS"; + case 232: return "EVAPORATION FROM SEA (GBM) KG/M2/S"; + case 234: return "SURFACE LATENT HEAT FLUX W/M2"; + case 235: return "SEAICE TOP MELTING LH FLUX(GBM) W/M2"; + case 236: return "TEMPERATURE AT 1.5M"; + case 237: return "SPECIFIC HUMIDITY AT 1.5M"; + case 238: return "DEEP SOIL TEMPERATURE AFTER B.LAYER"; + case 239: return "CLOUD LIQUID WATER AFTER B.LAYER"; + case 240: return "CLOUD ICE CONTENT AFTER B.LAYER"; + case 241: return "TOTAL SURF MOIST FLUX PER TIMESTEP"; + case 242: return "CLOUD FRACTION AT 1.5M"; + case 243: return "CLOUD LIQUID WATER AT 1.5M"; + case 244: return "CLOUD ICE CONTENT AT 1.5M"; + case 245: return "RELATIVE HUMIDITY AT 1.5M"; + case 247: return "VISIBILITY AT 1.5M M"; + case 248: return "FOG FRACTION AT 1.5 M"; + case 249: return "10 METRE WIND SPEED M/S"; + case 250: return "DEWPOINT AT 1.5M (K)"; + case 251: return "SILHOUETTE OROGRAPHIC ROUGHNESS"; + case 252: return "HALF OF (PEAK TO TROUGH HT OF OROG)"; + case 253: return "PROBABILITY OF VIS LESS THAN 5 KM"; + case 254: return "TL AT 1.5M"; + case 255: return "QT AT 1.5M"; + case 256: return "RHO_CD_MODV1"; + case 257: return "RHO_KM"; + case 258: return "SURFACE SNOWMELT HEAT FLUX W/M2"; + case 259: return "CANOPY CONDUCTANCE M/S"; + case 260: return "TRANSPIRATION KG/M2/TS"; + case 261: return "GROSS PRIMARY PRODUCTIVITY KG C/M2/S"; + case 262: return "NET PRIMARY PRODUCTIVITY KG C/M2/S"; + case 263: return "PLANT RESPIRATION KG/M2/S"; + case 264: return "LEAF AREA INDEX OF VEG FRACTION"; + case 265: return "CANOPY HEIGHT OF VEGETATED FRACTION"; + case 270: return "SO2 SURFACE DRY DEP FLUX KG/M2/S"; + case 271: return "SO4 AIT SURF DRY DEP FLUX KG/M2/S"; + case 272: return "SO4 ACC SURF DRY DEP FLUX KG/M2/S"; + case 273: return "SO4 DIS SURF DRY DEP FLUX KG/M2/S"; + case 274: return "RESIST B FOR SO2 AFTER TS S/M"; + case 275: return "RESIST B FOR SO4 AIT AFTER TS S/M"; + case 276: return "RESIST B FOR SO4 ACC AFTER TS S/M"; + case 277: return "RESIST B FOR SO4 DIS AFTER TS S/M"; + case 278: return "RESIST S FOR SO2 AFTER TS S/M"; + case 279: return "RESIST S FOR SO4 AIT AFTER TS S/M"; + case 280: return "RESIST S FOR SO4 ACC AFTER TS S/M"; + case 281: return "RESIST S FOR SO4 DIS AFTER TS S/M"; + case 282: return "DRY DEP VEL FOR SO2 AFTER TS M/S"; + case 283: return "DRY DEP VEL FOR SO4 AIT AFTER TS M/S"; + case 284: return "DRY DEP VEL FOR SO4 ACC AFTER TS M/S"; + case 285: return "DRY DEP VEL FOR SO4 DIS AFTER TS M/S"; + case 286: return "AERODYNAMIC RESISTANCE AFTER TS"; + case 287: return "CANOPY EVAPORATION ON NON-ICE TILES"; + case 288: return "TRANSPIRATION+SOIL EVP NON-ICE TILES"; + case 289: return "GROSS PRIMARY PRODUCTIVITY ON PFTS"; + case 290: return "SURFACE SENSIBLE HEAT FLUX ON TILES"; + case 291: return "NET PRIMARY PRODUCTIVITY ON PFTS"; + case 292: return "PLANT RESPIRATION ON PFTS KG C/M2/S"; + case 293: return "SOIL RESPIRATION KG C/M2/S"; + case 294: return "BULK RICHARDSON NUMBER ON TILES"; + case 295: return "FRACTIONAL SNOW COVER"; + case 296: return "EVAP FROM SOIL SURF : RATE KG/M2/S"; + case 297: return "EVAP FROM CANOPY : RATE KG/M2/S"; + case 298: return "SUBLIM. SURFACE (GBM) : RATE KG/M2/S"; + case 299: return "TRANSPIRATION RATE KG/M2/S"; + case 300: return "NH3 SURFACE DRY DEP FLUX KG/M2/S"; + case 301: return "FRESH SOOT DRY DEPN FLUX KG/M2/S"; + case 302: return "AGED SOOT DRY DEPN FLUX KG/M2/S"; + case 303: return "SOOT IN CLOUD (OCCULT) DEPN KG/M2/S"; + case 304: return "TURBULENT MIXING HT AFTER B.LAYER m"; + case 305: return "STABLE BL INDICATOR"; + case 306: return "STRATOCUM. OVER STABLE BL INDICATOR"; + case 307: return "WELL_MIXED BL INDICATOR"; + case 308: return "DECOUPLED SC. NOT OVER CU. INDICATOR"; + case 309: return "DECOUPLED SC. OVER CU. INDICATOR"; + case 310: return "CUMULUS-CAPPED BL INDICATOR"; + case 311: return "POTENTIAL EVAPORATION AMNT KG/M2/TS"; + case 312: return "POTENTIAL EVAPORATION RATE KG/M2/S"; + case 313: return "SOIL MOISTURE AVAILABILITY FACTOR"; + case 314: return "SURFACE NET RADIATION"; + case 315: return "SNOW-ADJUSTED TILE FRACTIONS"; + case 316: return "SURFACE TEMP ON SNOW-ADJSTD TILES K"; + case 317: return "TILE FRACTIONS (B.LAYER)"; + case 318: return "LEAF AREA INDEX ON PFTS (B.LAYER)"; + case 319: return "CANOPY HEIGHT ON PFTS (B.LAYER) M"; + case 320: return "SOIL CARBON CONTENT (B.LAYER) KGC/M2"; + case 321: return "CANOPY WATER ON NON-ICE TILES KG/M2"; + case 322: return "CANOPY CAPACITY NON-ICE TILES KG/M2"; + case 323: return "SNOW TEMPERATURE K"; + case 324: return "ROUGHNESS LENGTH ON TILES M"; + case 325: return "LEAF TURNOVER RATE ON PFTS"; + case 326: return "CO2 LAND SURFACE FLUX KG/M**2/S"; + case 327: return "CO2 TOTAL FLUX TO ATMOS KG/M**2/S"; + } + break; + case 4: + switch (item) { + case 4: return "TEMPERATURE AFTER LARGE SCALE PRECIP"; + case 10: return "SPECIFIC HUMIDITY AFTER LS PRECIP"; + case 201: return "LARGE SCALE RAIN AMOUNT KG/M2/TS"; + case 202: return "LARGE SCALE SNOW AMOUNT KG/M2/TS"; + case 203: return "LARGE SCALE RAINFALL RATE KG/M2/S"; + case 204: return "LARGE SCALE SNOWFALL RATE KG/M2/S"; + case 205: return "CLOUD LIQUID WATER AFTER LS PRECIP"; + case 206: return "CLOUD ICE CONTENT AFTER LS PRECIP"; + case 207: return "RELATIVE HUMIDITY AFTER LS PRECIP"; + case 208: return "VISIBILITY AFTER LS PREC IN LEVEL M"; + case 211: return "SO2 SCAVENGED BY LS PPN KG/M2/TS"; + case 212: return "SO4 AIT SCAVNGD BY LS PPN KG/M2/TS"; + case 213: return "SO4 ACC SCAVNGD BY LS PPN KG/M2/TS"; + case 214: return "SO4 DIS SCAVNGD BY LS PPN KG/M2/TS"; + case 215: return "NH3 SCAVENGED BY LS PPN KG/M2/S"; + case 216: return "SO2 SCAVENGED BY LS PPN KG/M2/S"; + case 217: return "SO4 AIT SCAVNGD BY LS PPN KG/M2/S"; + case 218: return "SO4 ACC SCAVNGD BY LS PPN KG/M2/S"; + case 219: return "SO4 DIS SCAVNGD BY LS PPN KG/M2/S"; + case 220: return "SOOT LS RAINOUT KG/M2/S"; + case 221: return "SOOT LS WASHOUT KG/M2/S"; + case 222: return "RAINFALL RATE OUT OF MODEL LEVELS"; + case 223: return "SNOWFALL RATE OUT OF MODEL LEVELS"; + case 224: return "SUPERCOOLED LIQUID WATER CONTENT"; + case 225: return "SUPERCOOLED RAIN OUT OF MODEL LEVELS"; + } + break; + case 5: + switch (item) { + case 4: return "THETA AFTER CONVECTION INCREMENT"; + case 10: return "SPECIFIC HUMIDITY AFTER CONVECTION"; + case 13: return "CONV CLOUD AMOUNT AFTER CONVECTION"; + case 201: return "CONVECTIVE RAIN AMOUNT KG/M2/TS"; + case 202: return "CONVECTIVE SNOW AMOUNT KG/M2/TS"; + case 203: return "THETA INCREMENT FROM CONVECTION"; + case 204: return "SPECIFIC HUMID INCRMNT FROM CONVECTN"; + case 205: return "CONVECTIVE RAINFALL RATE KG/M2/S"; + case 206: return "CONVECTIVE SNOWFALL RATE KG/M2/S"; + case 207: return "PRESSURE AT CONVECTIVE CLOUD BASE"; + case 208: return "PRESSURE AT CONVECTIVE CLOUD TOP"; + case 209: return "TEMPERATURE AFTER CONVECTION"; + case 210: return "ICAO HT OF CONVECTIVE CLOUD BASE"; + case 211: return "ICAO HT OF CONVECTIVE CLOUD TOP"; + case 212: return "CONV. CLOUD AMOUNT ON EACH MODEL LEV"; + case 213: return "CONV CLOUD CONDENSED WATER KG/KG"; + case 214: return "TOTAL RAINFALL RATE: LS+CONV KG/M2/S"; + case 215: return "TOTAL SNOWFALL RATE: LS+CONV KG/M2/S"; + case 216: return "TOTAL PRECIPITATION RATE KG/M2/S"; + case 217: return "DILUTE CONVECTIVELY AVAIL POT E J/KG"; + case 218: return "LOWEST CONV CLOUD BASE LEVEL NO."; + case 219: return "LOWEST CONV CLOUD TOP LEVEL NO."; + case 220: return "LOWEST CONV CLOUD AMOUNT AFTER CONV"; + case 221: return "LOWEST CONV CLOUD LIQUID WATER PATH"; + case 222: return "PRESSURE AT LOWEST CONV CLOUD BASE"; + case 223: return "PRESSURE AT LOWEST CONV CLOUD TOP"; + case 224: return "ICAO HT OF LOWEST CONV CLOUD BASE"; + case 225: return "ICAO HT OF LOWEST CONV CLOUD TOP"; + case 226: return "TOTAL PRECIPITATION AMOUNT KG/M2/TS"; + case 227: return "SO2 SCAVENGED BY CONV PPN KG/M2/TS"; + case 228: return "SO4 AIT SCAVNGD BY CONV PPN KG/M2/TS"; + case 229: return "SO4 ACC SCAVNGD BY CONV PPN KG/M2/TS"; + case 230: return "SO4 DIS SCAVNGD BY CONV PPN KG/M2/TS"; + case 231: return "CONV. CLOUD BASE PRESSURE * CCA"; + case 232: return "CONV. CLOUD TOP PRESSURE * CCA"; + case 233: return "GRIDBOX MEAN CONVECTIVE CLOUD WATER"; + case 234: return "GRIDBOX MEAN CONV. CLOUD WATER PATH"; + case 235: return "U compnt of wind after convection"; + case 236: return "V compnt of wind after convection"; + case 237: return "NH3 SCAVENGED BY CONV PPN KG/M2/S"; + case 238: return "SO2 SCAVENGED BY CONV PPN KG/M2/SEC"; + case 239: return "SO4 AIT SCAVNGD BY CONV PPN KG/M2/S"; + case 240: return "SO4 ACC SCAVNGD BY CONV PPN KG/M2/S"; + case 241: return "SO4 DIS SCAVNGD BY CONV PPN KG/M2/S"; + case 242: return "CONVECTIVELY SCAVENGED SOOT KG/M2/S"; + case 250: return "UPDRAUGHT MASS FLUX (PA/S)"; + case 251: return "DOWNDRAUGHT MASS FLUX (PA/S)"; + case 252: return "UPDRAUGHT ENTRAINMENT RATE (S-1)"; + case 253: return "UPDRAUGHT DETRAINMENT RATE (S-1)"; + case 254: return "DOWNDRAUGHT ENTRAINMENT RATE (S-1)"; + case 255: return "DOWNDRAUGHT DETRAINMENT RATE (S-1)"; + case 256: return "U INCREMENT MS-2 ( P GRID)"; + case 257: return "V INCREMENT MS-2 ( P GRID)"; + } + break; + case 6: + switch (item) { + case 2: return "U COMPNT OF WIND AFTER G.WAVE DRAG"; + case 3: return "V COMPNT OF WIND AFTER G.WAVE DRAG"; + case 201: return "U COMPONENT OF GRAVITY WAVE STRESS"; + case 202: return "V COMPONENT OF GRAVITY WAVE STRESS"; + case 203: return "STANDARD DEVIATION OF OROGRAPHY"; + case 204: return "OROGRAPHIC GRADIENT XX COMPONENT"; + case 205: return "OROGRAPHIC GRADIENT XY COMPONENT"; + case 206: return "OROGRAPHIC GRADIENT YY COMPONENT"; + case 207: return "U-ACCEL FROM SATURATED STRESS"; + case 208: return "V-ACCEL FROM SATURATED STRESS"; + case 209: return "U-ACCEL FROM HYDRAULIC JUMP"; + case 210: return "V-ACCEL FROM HYDRAULIC JUMP"; + case 211: return "U-ACCEL FROM TRAPPED LEE WAVES"; + case 212: return "V-ACCEL FROM TRAPPED LEE WAVES"; + case 213: return "VERTICAL TRANSMISSION COEFFICIENT"; + } + break; + case 7: + switch (item) { + case 2: return "U COMPNT OF WIND AFTER VERT DIF'SION"; + case 3: return "V COMPNT OF WIND AFTER VERT DIF'SION"; + case 201: return "VERT FLUX OF U MOMENTUM FROM V.DIFFN"; + case 202: return "VERT FLUX OF V MOMENTUM FROM V.DIFFN"; + } + break; + case 8: + switch (item) { + case 23: return "SNOW MASS AFTER HYDROLOGY KG/M2"; + case 24: return "SURFACE TEMPERATURE,AFTER HYDROLOGY"; + case 201: return "LAND SNOW MELT AMOUNT KG/M2/TS"; + case 202: return "LAND SNOW MELT HEAT FLUX W/M2"; + case 203: return "CANOPY THROUGHFALL AMOUNT KG/M2/TS"; + case 204: return "SURFACE RUNOFF AMOUNT KG/M2/TS"; + case 205: return "SUB-SURFACE RUNOFF AMOUNT KG/M2/TS"; + case 206: return "SOIL HYDROLOGY PARAMETER \"BS\""; + case 207: return "VEG MODIFIED INFILTRATION RATE"; + case 208: return "SOIL MOISTURE CONTENT"; + case 209: return "CANOPY WATER CONTENT"; + case 210: return "VOL SMC AT WILTING"; + case 211: return "VOL SMC AT CRIT PT"; + case 212: return "VOL SMC AT FLD CAP"; + case 213: return "VOL SMC AT SATURATION"; + case 214: return "SATURATED SOIL CONDUCTIVITY"; + case 215: return "EAGLESON'S EXPONENT"; + case 216: return "THERMAL CAPACITY"; + case 217: return "THERMAL CONDUCTIVITY"; + case 218: return "VEGETATION FRACTION"; + case 219: return "ROOT DEPTH"; + case 220: return "SURFACE RESISTANCE TO EVAPORATION"; + case 221: return "SURFACE CAPACITY"; + case 222: return "INFILTRATION FACTOR"; + case 223: return "SOIL MOISTURE CONTENT IN A LAYER"; + case 224: return "SATURATED SOIL WATER SUCTION"; + case 225: return "DEEP SOIL TEMP. AFTER HYDROLOGY DEGK"; + case 226: return "DEEP SNOWMELT HEAT FLUX W/M2"; + case 228: return "CLAPP-HORNBERGER \"B\" COEFFICIENT"; + case 229: return "UNFROZEN SOIL MOISTURE FRACTION"; + case 230: return "FROZEN SOIL MOISTURE FRACTION"; + case 231: return "LAND SNOW MELT RATE KG/M2/S"; + case 233: return "CANOPY THROUGHFALL RATE KG/M2/S"; + case 234: return "SURFACE RUNOFF RATE KG/M2/S"; + case 235: return "SUB-SURFACE RUNOFF RATE KG/M2/S"; + } + break; + case 9: + switch (item) { + case 4: return "TEMPERATURE AFTER DYNAMIC CLOUD"; + case 10: return "SPEC. HUMIDITY AFTER DYNAMIC CLOUD"; + case 201: return "LAYER CLOUD AMOUNT IN EACH LAYER"; + case 202: return "VERY LOW CLOUD AMOUNT"; + case 203: return "LOW CLOUD AMOUNT"; + case 204: return "MEDIUM CLOUD AMOUNT"; + case 205: return "HIGH CLOUD AMOUNT"; + case 206: return "CLOUD LIQUID WATER AFTER DYN CLOUD"; + case 207: return "CLOUD ICE CONTENT AFTER DYNAM CLOUD"; + case 208: return "CLOUD BASE FOR COVER.GT.0.1 OCTA KFT"; + case 209: return "CLOUD BASE FOR COVER.GT.1.5 OCTA KFT"; + case 210: return "CLOUD BASE FOR COVER.GT.2.5 OCTA KFT"; + case 211: return "CLOUD BASE FOR COVER.GT.3.5 OCTA KFT"; + case 212: return "CLOUD BASE FOR COVER.GT.4.5 OCTA KFT"; + case 213: return "CLOUD BASE FOR COVER.GT.5.5 OCTA KFT"; + case 214: return "CLOUD BASE FOR COVER.GT.6.5 OCTA KFT"; + case 215: return "CLOUD BASE FOR COVER.GT.7.9 OCTA KFT"; + case 216: return "TOTAL CLOUD AMOUNT - RANDOM OVERLAP"; + case 217: return "TOTAL CLOUD AMOUNT MAX/RANDOM OVERLP"; + case 218: return "CLOUD FRACTION BELOW 1000 FT ASL"; + case 219: return "LOW CLOUD BASE (FT ASL)"; + case 220: return "LOW CLOUD TOP (FT ASL)"; + case 221: return "WET BULB FREEZING LEV HEIGHT (M)"; + case 222: return "WET BULB TEMPERATURE (K)"; + case 223: return "TOTAL CLOUD TOP HEIGHT (KFT)"; + case 224: return "LAYER LIQUID CLOUD AMOUNT IN LAYERS"; + case 225: return "LAYER FROZEN CLOUD AMOUNT IN LAYERS"; + case 226: return "LAYER CLOUD FREQUENCY IN EACH LAYER"; + case 227: return "LAYER CLOUD AREA IN LAYER"; + case 228: return "CRITICAL RELATIVE HUMIDITY"; + } + break; + case 10: + switch (item) { + case 1: return "PSTAR AFTER ADJUSTMENT"; + case 2: return "U COMPNT OF WIND AFTER ADJUSTMENT"; + case 3: return "V COMPNT OF WIND AFTER ADJUSTMENT"; + case 4: return "THETA AFTER ADJUSTMENT"; + case 10: return "SPEC HUMID TOT WATER CONTENT:ADJUST"; + case 201: return "MEAN U OVER ADJ*LAYER THICK=MASS FLX"; + case 202: return "MEAN V OVER ADJ*LAYER THICK=MASS FLX"; + case 203: return "PSEUDO-RADIUS AT MODEL LEVELS"; + case 204: return "ETADOT FROM THE ADJUSTMENT STEP"; + case 205: return "RATE OF CHANGE OF PSTAR"; + case 206: return "GEOPOTENTIAL"; + case 207: return "MEAN U OVER ADJ * LAYER THICK * TEMP"; + case 208: return "MEAN V OVER ADJ * LAYER THICK * TEMP"; + case 209: return "MEAN U OVER ADJ * LAYER THICK *HUMID"; + case 210: return "MEAN V OVER ADJ * LAYER THICK *HUMID"; + case 211: return "MEAN U ADJ *LAYER THICK* LIQ WATER T"; + case 212: return "MEAN V ADJ *LAYER THICK* LIQ WATER T"; + case 213: return "MEAN U ADJ *LAYER THICK* TOTAL WATER"; + case 214: return "MEAN V ADJ *LAYER THICK* TOTAL WATER"; + case 215: return "MEAN U ADJ * LAYER THICK * U"; + case 216: return "MEAN V ADJ * LAYER THICK * U"; + case 217: return "MEAN U ADJ * LAYER THICK * V"; + case 218: return "MEAN V ADJ * LAYER THICK * V"; + case 219: return "MEAN U * LAYER THICK * GEOPOTENTIAL"; + case 220: return "MEAN V * LAYER THICK * GEOPOTENTIAL"; + case 221: return "MN U *LYR THICK* MOIST STATIC ENERGY"; + case 222: return "MN V *LYR THICK* MOIST STATIC ENERGY"; + case 223: return "ANGULAR MOMENTUM M1 KG M2/S X10-24"; + case 224: return "ANGULAR MOMENTUM M2 KG M2/S X10-24"; + case 225: return "ANGULAR MOMENTUM M3 KG M2/S X10-24"; + case 226: return "ANGULAR MOMENTUM W1 KG M2/S X10-24"; + case 227: return "ANGULAR MOMENTUM W2 KG M2/S X10-24"; + case 228: return "ANGULAR MOMENTUM W3 KG M2/S X10-24"; + case 229: return "CLOUD LIQUID WATER BEFORE DYNAMICS"; + case 230: return "CLOUD ICE CONTENT BEFORE DYNAMICS"; + } + break; + case 12: + switch (item) { + case 2: return "U AFTER PRIMARY FIELD ADVECTION"; + case 3: return "V AFTER PRIMARY FIELD ADVECTION"; + case 4: return "THETAL AFTER PRIMARY FIELD ADVECTION"; + case 10: return "QT AFTER PRIMARY FIELD ADVECTION"; + case 201: return "OMEGA ON MODEL LEVELS"; + case 202: return "OMEGA ON PRESSURE LEVELS"; + } + break; + case 13: + switch (item) { + case 2: return "U AFTER FILTERING AND DIFFUSION"; + case 3: return "V AFTER FILTERING AND DIFFUSION"; + case 4: return "THETAL AFTER FILTERING AND DIFFUSION"; + case 10: return "QT AFTER FILTERING AND DIFFUSION"; + case 201: return "QT SOURCE/SINK IN QT_POS KG/M2/S"; + } + break; + case 14: + switch (item) { + case 201: return "ATMOS ENERGY CORR'N IN COLUMN W/M2"; + } + break; + case 15: + switch (item) { + case 201: return "U COMPNT OF WIND ON PRESSURE LEVELS"; + case 202: return "V COMPNT OF WIND ON PRESSURE LEVELS"; + case 203: return "MAX CAT PROBABILITY. NEED MAX WIND"; + case 204: return "MAX CAT PROB LEVEL. NEED MAX WIND"; + case 205: return "CAT PROB @ P LEVELS. NEED MAX WIND"; + case 206: return "HEIGHT OF MAX WIND LEVEL- NOT AVALBL"; + case 207: return "ICAO HT OF MAX WIND LEV-NEED MAX UV&"; + case 208: return "PRESSURE OF MAX WIND LEV-NEED MAX U,"; + case 209: return "U COMPONENT OF MAX WIND-NEED MAX V&P"; + case 210: return "V COMPONENT OF MAX WIND-NEED MAX U&P"; + case 211: return "CAT PROB AVE 300 250 200MB NEED MAX"; + case 212: return "50 METRE WIND U-COMPONENT"; + case 213: return "50 METRE WIND V-COMPONENT"; + case 214: return "ERTEL POTENTIAL VORTICITY(THETA LEV)"; + case 215: return "UV ON PRESSURE LEVS. USE MACRO"; + case 216: return "T ON PRESSURE LEVS U GRID. USE MACRO"; + case 217: return "UT ON PRESS LEVS U GRID. USE MACRO"; + case 218: return "VT ON PRESS LEVS U GRID. USE MACRO"; + case 219: return "T**2 ON PRESS LEVS U GRID. USE MACRO"; + case 220: return "U**2 ON PRESS LEVS U GRID. USE MACRO"; + case 221: return "V**2 ON PRESS LEVS U GRID. USE MACRO"; + case 222: return "OMEGA ON PRESS LEVS U GRID.USE MACRO"; + case 223: return "OMEGA*T ON P LEVS U GRID. USE MACRO"; + case 224: return "OMEGA*U ON P LEVS U GRID. USE MACRO"; + case 225: return "OMEGA*V ON P LEVS U GRID. USE MACRO"; + case 226: return "SPECIF HUM;P LEVS;U GRID. USE MACRO"; + case 227: return "Q*U ON PRESS LEVS U GRID. USE MACRO"; + case 228: return "Q*V ON PRESS LEVS U GRID. USE MACRO"; + case 229: return "POTENTIAL VORTICITY ON PRESSURE LEVS"; + case 230: return "THETA ON POT VORT LEVS-SEE CON.B.5.F"; + case 231: return "TEST FIELD ON UV GRID-SINGLE LEVEL"; + case 232: return "TEST FIELD ON TH GRID-SINGLE LEVEL"; + case 233: return "TEST FIELD ON TH GRID-PRESS LEVELS"; + case 234: return "TEST FIELD ON TH GRID-MODEL LEVELS"; + case 235: return "q*w on press levs, u grid"; + case 236: return "Fract of time pres lev above surface"; + case 237: return "Total KE per unit area x10e-6 J/m2"; + case 238: return "Geopotential height, u grid"; + case 239: return "U*Geopotential height, u grid x1.e6"; + case 240: return "v*Geopotential height, u grid x1.e6"; + case 241: return " mountain torque per unit area N/m"; + } + break; + case 16: + switch (item) { + case 201: return "GEOPOTENTIAL HEIGHT:LAYER BOUNDARIES"; + case 202: return "GEOPOTENTIAL HEIGHT: PRESSURE LEVELS"; + case 203: return "TEMPERATURE ON PRESSURE LEVELS"; + case 204: return "RELATIVE HUMIDITY ON PRESSURE LEVELS"; + case 205: return "WET BULB POTENTIAL TEMPERATURE"; + case 206: return "SURFACE SNOW PROBABILITY"; + case 207: return "ICAO HT OF -20 DEG ISO- NEED P,HT"; + case 208: return "PRESSURE OF -20 DEG ISO- NEED HT"; + case 209: return "ICAO HT OF FREEZING LEV- NEED P,HT"; + case 210: return "HEIGHT OF FREEZING LEV- NEED PRESS"; + case 211: return "PRESSURE OF FREEZING LEV- NEED HT"; + case 212: return "HT OF CONTRAIL LOWER LIM- NEED UPPER"; + case 213: return "HT OF CONTRAIL UPPER LIM- NEED LOWER"; + case 214: return "PRESSURE AT TROP LEV- NEED HT,TEMP"; + case 215: return "TEMP AT TROP LEVEL- NEED HT,PRESS"; + case 216: return "HEIGHT OF TROP- NEED TEMP, PRESS"; + case 217: return "ICAO HT OF TROP- NEED HT,TEMP,PRESS"; + case 218: return "HEIGHT OF -20 DEG ISO- NEED PRESSURE"; + case 219: return "THERMAL ADVECTION ON PRESSURE LEVELS"; + case 220: return "RADIO DUCT HEIGHT- NEED INTENSITY"; + case 221: return "RADIO DUCT INTENSITY- NEED HEIGHT"; + case 222: return "PRESSURE AT MEAN SEA LEVEL"; + case 223: return "THERMAL ADVECT AVE OVER 850 700 500"; + case 224: return "HEIGHT**2 ON PRESS LEVS. USE MACRO"; + case 225: return "GEOPOTENTIAL HT OF MODEL LEVEL M"; + case 226: return "ATM TRACER 1 (O3 ) ON PRESS LEVS"; + case 227: return "ATM TRACER 2 (H2O ) ON PRESS LEVS"; + case 228: return "ATM TRACER 3 (CO ) ON PRESS LEVS"; + case 229: return "ATM TRACER 4 (CH4 ) ON PRESS LEVS"; + case 230: return "ATM TRACER 5 (N2O ) ON PRESS LEVS"; + case 231: return "ATM TRACER 6 (NO ) ON PRESS LEVS"; + case 232: return "ATM TRACER 7 (NO2 ) ON PRESS LEVS"; + case 233: return "ATM TRACER 8 (HNO3 ) ON PRESS LEVS"; + case 234: return "ATM TRACER 9 (N2O5 ) ON PRESS LEVS"; + case 235: return "ATM TRACER 10 (CLONO2) ON PRESS LEVS"; + case 236: return "ATM TRACER 11 (CLO ) ON PRESS LEVS"; + case 237: return "ATM TRACER 12 (HCL ) ON PRESS LEVS"; + case 238: return "ATM TRACER 13 (CF2CL2) ON PRESS LEVS"; + case 239: return "ATM TRACER 14 (CFCL3 ) ON PRESS LEVS"; + case 240: return "ATM TRACER 15 (HF ) ON PRESS LEVS"; + case 241: return "ATM TRACER 16 (------) ON PRESS LEVS"; + case 242: return "ATM TRACER 17 (------) ON PRESS LEVS"; + case 243: return "ATM TRACER 18 (------) ON PRESS LEVS"; + case 244: return "ATM TRACER 19 (------) ON PRESS LEVS"; + case 245: return "ATM TRACER 20 (------) ON PRESS LEVS"; + case 246: return "ATM TRACER 21 (H2S ) ON PRESS LEVS"; + case 247: return "ATM TRACER 22 (WATER-SOL) PRESS LEVS"; + case 248: return "ATM TRACER 23 (\"DUST\") ON PRESS LEVS"; + case 249: return "ATM TRACER 24 (OCEANIC)ON PRESS LEVS"; + case 250: return "ATM TRACER 25 (SOOT ) ON PRESS LEVS"; + case 251: return "ATM TRACER 26 (VOLC ASH) PRESS LEVS"; + case 252: return "ATM TRACER 27 (H2SO4 ) ON PRESS LEVS"; + case 253: return "ATM TRACER 28 ((NH4)2SO4) PRESS LEVS"; + case 254: return "ATM TRACER 29 (MINERAL)ON PRESS LEVS"; + } + break; + case 17: + switch (item) { + case 201: return "SO4 AIT SURF SETTLEMENT FLUX KG/M2/S"; + case 202: return "SO4 ACC SURF SETTLEMENT FLUX KG/M2/S"; + case 203: return "MSA MASS MIXING RATIO AFTER TSTEP"; + case 204: return "NH3 DEPLETION KG/KG AFTER TSTEP"; + } + break; + case 18: + switch (item) { + case 1: return "P* AFTER ASSIMILATION INCREMENTS"; + case 2: return "U AFTER ASSIMILATION INCREMENTS"; + case 3: return "V AFTER ASSIMILATION INCREMENTS"; + case 4: return "THETA AFTER ASSIMILATION INCREMENTS"; + case 10: return "Q AFTER ASSIMILATION INCREMENTS"; + case 201: return "P* ASSIMILATION WEIGHTS"; + case 202: return "THETA ASSIMILATION WEIGHTS"; + case 203: return "WIND ASSIMILATION WEIGHTS"; + case 204: return "RH ASSIMILATION WEIGHTS"; + case 205: return "PRECIPITATION RATE ASSIM WEIGHTS"; + case 209: return "VISIBILITY ASSIMILATION WEIGHTS"; + case 211: return "P* ASSIMILATION INCREMENT"; + case 212: return "THETA ASSIMILATION INCREMENT"; + case 213: return "U ASSIMILATION INCREMENT"; + case 214: return "RH ASSIMILATION INCREMENT"; + case 215: return "PRECIPITATION RATE ASSIM INCREMENTS"; + case 219: return "VISIBILITY ASSIMILATION INCREMENTS"; + case 223: return "V ASSIMILATION INCREMENT"; + case 231: return "HYDROSTATIC THETA ASSM INCR(FROM P*)"; + case 241: return "GEOSTROPHIC U ASSM INCR (FROM P*)"; + case 242: return "GEOSTROPHIC U ASSM INCR (FROM THETA)"; + case 251: return "GEOSTROPHIC V ASSM INCR (FROM P*)"; + case 252: return "GEOSTROPHIC V ASSM INCR (FROM THETA)"; + case 261: return "P* INCREMENTS FROM WIND BALANCE"; + case 262: return "THETA INCREMENTS FROM WIND BALANCE"; + case 271: return "THETA INCR FROM LS LATENT HEATING"; + case 272: return "THETA INCR FROM PRECIP DATA (LHN)"; + } + break; + case 19: + switch (item) { + case 1: return "VEGETATION CARBON ON PFTS KG C/M2"; + case 2: return "GRIDBOX MEAN VEG CARBON KG C/M2"; + case 3: return "PHENOLOGICAL LEAF TURNOVER RATE PFTS"; + case 4: return "LITTER CARBON ON PFTS KG C/M2/YEAR"; + case 5: return "GRIDBOX MEAN LITTER CARBN KGC/M2/YR"; + case 6: return "MEAN LEAF TRNVR RATE PFTS FOR PHENOL"; + case 7: return "LEAF AREA INDEX PFTS AFTER PHENOLOGY"; + case 8: return "MN LEAF TRNVR RATE PFTS FOR TRIFFID"; + case 9: return "MEAN NPP ON PFTS FOR TRIFFID"; + case 10: return "MEAN WOOD RESP ON PFTS FOR TRIFFID"; + case 11: return "MEAN SOIL RESPIRATION FOR TRIFFID"; + case 12: return "DISTURBED FRACTION OF VEGETATION"; + case 13: return "SURFACE TYPE FRACTIONS AFTER TRIFFID"; + case 14: return "LEAF AREA INDEX PFTS AFTER TRIFFID"; + case 15: return "CANOPY HEIGHT ON PFTS AFTER TRIFFID"; + case 16: return "SOIL CARBON CONTENT AFTER TRIFFID"; + } + break; + case 21: + switch (item) { + case 1: return "CM1: PSTAR AFTER TIMESTEP"; + case 2: return "CM1: U COMPNT OF WIND AFTER TIMESTEP"; + case 3: return "CM1: V COMPNT OF WIND AFTER TIMESTEP"; + case 4: return "CM1: THETA AFTER TIMESTEP"; + case 10: return "CM1: SPECIFIC HUMIDITY AFTER TSTEP"; + case 13: return "CM1: CONV CLOUD AMOUNT AFTER TSTEP"; + case 14: return "CM1: CONV CLOUD BASE LEV NO AFTER TS"; + case 15: return "CM1: CONV CLOUD TOP LEV NO AFTER TS"; + case 16: return "CM1: CONV CLOUD LIQUID WATER PATH"; + case 23: return "CM1: SNOW AMOUNT AFTER TSTEP KG/M2"; + case 24: return "CM1: SURFACE TEMPERATURE AFTER TS"; + case 25: return "CM1: BOUNDARY LAYER DEPTH AFTER TS"; + case 26: return "CM1: ROUGHNESS LENGTH AFTER TIMESTEP"; + case 28: return "CM1: SURFACE ZONAL CURRENT AFTER TS"; + case 29: return "CM1: SURFACE MERID CURRENT AFTER TS"; + case 31: return "CM1: SEA ICE FRACTION AFTER TIMESTEP"; + case 32: return "CM1: SEA ICE DEPTH (MEAN OVER ICE) M"; + case 61: return "CM1: ATM TRACER 1 (CONVEN O3 )"; + case 62: return "CM1: ATM TRACER 2 (CONVEN H2O )"; + case 63: return "CM1: ATM TRACER 3 (CONVEN CO )"; + case 64: return "CM1: ATM TRACER 4 (CONVEN CH4 )"; + case 65: return "CM1: ATM TRACER 5 (CONVEN N2O )"; + case 66: return "CM1: ATM TRACER 6 (CONVEN NO )"; + case 67: return "CM1: ATM TRACER 7 (CONVEN NO2 )"; + case 68: return "CM1: ATM TRACER 8 (CONVEN HNO3 )"; + case 69: return "CM1: ATM TRACER 9 (CONVEN N2O5 )"; + case 70: return "CM1: ATM TRACER 10 (CONVEN CLONO2)"; + case 71: return "CM1: ATM TRACER 11 (CONVEN CLO )"; + case 72: return "CM1: ATM TRACER 12 (CONVEN HCL )"; + case 73: return "CM1: ATM TRACER 13 (CONVEN CF2CL2)"; + case 74: return "CM1: ATM TRACER 14 (CONVEN CFCL3 )"; + case 75: return "CM1: ATM TRACER 15 (CONVEN HF )"; + case 76: return "CM1: ATM TRACER 16 (CONVEN ----- )"; + case 77: return "CM1: ATM TRACER 17 (CONVEN ----- )"; + case 78: return "CM1: ATM TRACER 18 (CONVEN ----- )"; + case 79: return "CM1: ATM TRACER 19 (CONVEN S02 )"; + case 80: return "CM1: ATM TRACER 20 (CONVEN DMS )"; + case 81: return "CM1: ATM TRACER 21 (CONVEN H2S )"; + case 82: return "CM1: ATM TRACER 22 (CONV WATER-SOL )"; + case 83: return "CM1: ATM TRACER 23 (CONV DUST-LIKE )"; + case 84: return "CM1: ATM TRACER 24 (CONV OCEANIC )"; + case 85: return "CM1: ATM TRACER 25 (CONV SOOT )"; + case 86: return "CM1: ATM TRACER 26 (CONV VOLC ASH )"; + case 87: return "CM1: ATM TRACER 27 (CONV H2SO4 - )"; + case 88: return "CM1: ATM TRACER 28 (CONV (NH4)2SO4 )"; + case 89: return "CM1: ATM TRACER 29 (CONV MINERAL )"; + case 201: return "CM1: U COMP OF WIND ON PRESSURE LEV."; + case 202: return "CM1: V COMP OF WIND ON PRESSURE LEV."; + case 203: return "CM1: VERT VEL.(OMEGA): PRESSURE LEV."; + case 205: return "CM1: CAT PROBABILITY"; + case 206: return "CM1: HEIGHT OF THE MAX WIND LEVEL"; + case 207: return "CM1: PRESSURE OF THE MAX WIND LEVEL"; + case 208: return "CM1: U COMPONENT OF THE MAX WIND"; + case 209: return "CM1: V COMPONENT OF THE MAX WIND"; + case 210: return "CM1: GEOPOTENTIAL HT. MODEL HALF LEV"; + case 211: return "CM1: GEOPOTENTIAL HT. PRESSURE LEV."; + case 212: return "CM1: TEMPERATURE ON PRESSURE LEVELS"; + case 213: return "CM1: RELATIVE HUMIDITY ON PRESS LEVS"; + case 214: return "CM1: WET BULB POTENTIAL TEMPERATURE"; + case 215: return "CM1: SURFACE SNOW PROBABILITY"; + case 216: return "CM1: HEIGHT OF THE FREEZING LEVEL"; + case 217: return "CM1: PRESSURE OF THE FREEZING LEVEL"; + case 218: return "CM1: PRESSURE AT THE TROPOPAUSE LEV."; + case 219: return "CM1: TEMPERATURE AT THE TROP. LEVEL"; + case 220: return "CM1: HEIGHT OF THE TROPOPAUSE"; + case 221: return "CM1: HIGH CLOUD AMOUNT"; + case 222: return "CM1: MEDIUM CLOUD AMOUNT"; + case 223: return "CM1: LOW CLOUD AMOUNT"; + case 224: return "CM1: PRESSURE AT MEAN SEA LEVEL"; + } + break; + case 22: + switch (item) { + case 1: return "CM2: PSTAR AFTER TIMESTEP"; + case 2: return "CM2: U COMPNT OF WIND AFTER TIMESTEP"; + case 3: return "CM2: V COMPNT OF WIND AFTER TIMESTEP"; + case 4: return "CM2: THETA AFTER TIMESTEP"; + case 10: return "CM2: SPECIFIC HUMIDITY AFTER TSTEP"; + case 13: return "CM2: CONV CLOUD AMOUNT AFTER TSTEP"; + case 14: return "CM2: CONV CLOUD BASE LEV NO AFTER TS"; + case 15: return "CM2: CONV CLOUD TOP LEV NO AFTER TS"; + case 16: return "CM2: CONV CLOUD LIQUID WATER PATH"; + case 23: return "CM2: SNOW AMOUNT AFTER TSTEP KG/M2"; + case 24: return "CM2: SURFACE TEMPERATURE AFTER TS"; + case 25: return "CM2: BOUNDARY LAYER DEPTH AFTER TS"; + case 26: return "CM2: ROUGHNESS LENGTH AFTER TIMESTEP"; + case 28: return "CM2: SURFACE ZONAL CURRENT AFTER TS"; + case 29: return "CM2: SURFACE MERID CURRENT AFTER TS"; + case 31: return "CM2: SEA ICE FRACTION AFTER TIMESTEP"; + case 32: return "CM2: SEA ICE DEPTH (MEAN OVER ICE) M"; + case 61: return "CM2: ATM TRACER 1 (CONVEN O3 )"; + case 62: return "CM2: ATM TRACER 2 (CONVEN H2O )"; + case 63: return "CM2: ATM TRACER 3 (CONVEN CO )"; + case 64: return "CM2: ATM TRACER 4 (CONVEN CH4 )"; + case 65: return "CM2: ATM TRACER 5 (CONVEN N2O )"; + case 66: return "CM2: ATM TRACER 6 (CONVEN NO )"; + case 67: return "CM2: ATM TRACER 7 (CONVEN NO2 )"; + case 68: return "CM2: ATM TRACER 8 (CONVEN HNO3 )"; + case 69: return "CM2: ATM TRACER 9 (CONVEN N2O5 )"; + case 70: return "CM2: ATM TRACER 10 (CONVEN CLONO2)"; + case 71: return "CM2: ATM TRACER 11 (CONVEN CLO )"; + case 72: return "CM2: ATM TRACER 12 (CONVEN HCL )"; + case 73: return "CM2: ATM TRACER 13 (CONVEN CF2CL2)"; + case 74: return "CM2: ATM TRACER 14 (CONVEN CFCL3 )"; + case 75: return "CM2: ATM TRACER 15 (CONVEN HF )"; + case 76: return "CM2: ATM TRACER 16 (CONVEN ----- )"; + case 77: return "CM2: ATM TRACER 17 (CONVEN ----- )"; + case 78: return "CM2: ATM TRACER 18 (CONVEN ----- )"; + case 79: return "CM2: ATM TRACER 19 (CONVEN ---- )"; + case 80: return "CM2: ATM TRACER 20 (CONVEN ----- )"; + case 81: return "CM2: ATM TRACER 21 (CONVEN H2S )"; + case 82: return "CM2: ATM TRACER 22 (CONV WATER-SOL )"; + case 83: return "CM2: ATM TRACER 23 (CONV DUST-LIKE )"; + case 84: return "CM2: ATM TRACER 24 (CONV OCEANIC )"; + case 85: return "CM2: ATM TRACER 25 (CONV SOOT )"; + case 86: return "CM2: ATM TRACER 26 (CONV VOLC ASH )"; + case 87: return "CM2: ATM TRACER 27 (CONV H2SO4 )"; + case 88: return "CM2: ATM TRACER 28 (CONV (NH4)2SO4 )"; + case 89: return "CM2: ATM TRACER 29 (MINERAL )"; + case 201: return "CM2: U COMP OF WIND ON PRESSURE LEV."; + case 202: return "CM2: V COMP OF WIND ON PRESSURE LEV."; + case 203: return "CM2: VERT VEL.(OMEGA): PRESSURE LEV."; + case 205: return "CM2: CAT PROBABILITY"; + case 206: return "CM2: HEIGHT OF THE MAX WIND LEVEL"; + case 207: return "CM2: PRESSURE OF THE MAX WIND LEVEL"; + case 208: return "CM2: U COMPONENT OF THE MAX WIND"; + case 209: return "CM2: V COMPONENT OF THE MAX WIND"; + case 210: return "CM2: GEOPOTENTIAL HT. MODEL HALF LEV"; + case 211: return "CM2: GEOPOTENTIAL HT. PRESSURE LEV."; + case 212: return "CM2: TEMPERATURE ON PRESSURE LEVELS"; + case 213: return "CM2: RELATIVE HUMIDITY ON PRESS LEVS"; + case 214: return "CM2: WET BULB POTENTIAL TEMPERATURE"; + case 215: return "CM2: SURFACE SNOW PROBABILITY"; + case 216: return "CM2: HEIGHT OF THE FREEZING LEVEL"; + case 217: return "CM2: PRESSURE OF THE FREEZING LEVEL"; + case 218: return "CM2: PRESSURE AT THE TROPOPAUSE LEV."; + case 219: return "CM2: TEMPERATURE AT THE TROP. LEVEL"; + case 220: return "CM2: HEIGHT OF THE TROPOPAUSE"; + case 221: return "CM2: HIGH CLOUD AMOUNT"; + case 222: return "CM2: MEDIUM CLOUD AMOUNT"; + case 223: return "CM2: LOW CLOUD AMOUNT"; + case 224: return "CM2: PRESSURE AT MEAN SEA LEVEL"; + } + break; + case 23: + switch (item) { + case 1: return "CM3: PSTAR AFTER TIMESTEP"; + case 2: return "CM3: U COMPNT OF WIND AFTER TIMESTEP"; + case 3: return "CM3: V COMPNT OF WIND AFTER TIMESTEP"; + case 4: return "CM3: THETA AFTER TIMESTEP"; + case 10: return "CM3: SPECIFIC HUMIDITY AFTER TSTEP"; + case 13: return "CM3: CONV CLOUD AMOUNT AFTER TSTEP"; + case 14: return "CM3: CONV CLOUD BASE LEV NO AFTER TS"; + case 15: return "CM3: CONV CLOUD TOP LEV NO AFTER TS"; + case 16: return "CM3: CONV CLOUD LIQUID WATER PATH"; + case 23: return "CM3: SNOW AMOUNT AFTER TSTEP KG/M2"; + case 24: return "CM3: SURFACE TEMPERATURE AFTER TS"; + case 25: return "CM3: BOUNDARY LAYER DEPTH AFTER TS"; + case 26: return "CM3: ROUGHNESS LENGTH AFTER TIMESTEP"; + case 28: return "CM3: SURFACE ZONAL CURRENT AFTER TS"; + case 29: return "CM3: SURFACE MERID CURRENT AFTER TS"; + case 31: return "CM3: SEA ICE FRACTION AFTER TIMESTEP"; + case 32: return "CM3: SEA ICE DEPTH (MEAN OVER ICE) M"; + case 61: return "CM3: ATM TRACER 1 (CONVEN O3 )"; + case 62: return "CM3: ATM TRACER 2 (CONVEN H2O )"; + case 63: return "CM3: ATM TRACER 3 (CONVEN CO )"; + case 64: return "CM3: ATM TRACER 4 (CONVEN CH4 )"; + case 65: return "CM3: ATM TRACER 5 (CONVEN N2O )"; + case 66: return "CM3: ATM TRACER 6 (CONVEN NO )"; + case 67: return "CM3: ATM TRACER 7 (CONVEN NO2 )"; + case 68: return "CM3: ATM TRACER 8 (CONVEN HNO3 )"; + case 69: return "CM3: ATM TRACER 9 (CONVEN N2O5 )"; + case 70: return "CM3: ATM TRACER 10 (CONVEN CLONO2)"; + case 71: return "CM3: ATM TRACER 11 (CONVEN CLO )"; + case 72: return "CM3: ATM TRACER 12 (CONVEN HCL )"; + case 73: return "CM3: ATM TRACER 13 (CONVEN CF2CL2)"; + case 74: return "CM3: ATM TRACER 14 (CONVEN CFCL3 )"; + case 75: return "CM3: ATM TRACER 15 (CONVEN HF )"; + case 76: return "CM3: ATM TRACER 16 (CONVEN ----- )"; + case 77: return "CM3: ATM TRACER 17 (CONVEN ----- )"; + case 78: return "CM3: ATM TRACER 18 (CONVEN ----- )"; + case 79: return "CM3: ATM TRACER 19 (CONVEN ---- )"; + case 80: return "CM3: ATM TRACER 20 (CONVEN ---- )"; + case 81: return "CM3: ATM TRACER 21 (CONVEN H2S )"; + case 82: return "CM3: ATM TRACER 22 (CONV WATER-SOL )"; + case 83: return "CM3: ATM TRACER 23 (CONV DUST-LIKE )"; + case 84: return "CM3: ATM TRACER 24 (CONV OCEANIC )"; + case 85: return "CM3: ATM TRACER 25 (CONV SOOT )"; + case 86: return "CM3: ATM TRACER 26 (CONV VOLC ASH )"; + case 87: return "CM3: ATM TRACER 27 (CONV H2SO4 )"; + case 88: return "CM3: ATM TRACER 28 (CONV (NH4)2SO4 )"; + case 89: return "CM3: ATM TRACER 29 (CONV MINERAL )"; + case 201: return "CM3: U COMP OF WIND ON PRESSURE LEV."; + case 202: return "CM3: V COMP OF WIND ON PRESSURE LEV."; + case 203: return "CM3: VERT VEL.(OMEGA): PRESSURE LEV."; + case 205: return "CM3: CAT PROBABILITY"; + case 206: return "CM3: HEIGHT OF THE MAX WIND LEVEL"; + case 207: return "CM3: PRESSURE OF THE MAX WIND LEVEL"; + case 208: return "CM3: U COMPONENT OF THE MAX WIND"; + case 209: return "CM3: V COMPONENT OF THE MAX WIND"; + case 210: return "CM3: GEOPOTENTIAL HT. MODEL HALF LEV"; + case 211: return "CM3: GEOPOTENTIAL HT. PRESSURE LEV."; + case 212: return "CM3: TEMPERATURE ON PRESSURE LEVELS"; + case 213: return "CM3: RELATIVE HUMIDITY ON PRESS LEVS"; + case 214: return "CM3: WET BULB POTENTIAL TEMPERATURE"; + case 215: return "CM3: SURFACE SNOW PROBABILITY"; + case 216: return "CM3: HEIGHT OF THE FREEZING LEVEL"; + case 217: return "CM3: PRESSURE OF THE FREEZING LEVEL"; + case 218: return "CM3: PRESSURE AT THE TROPOPAUSE LEV."; + case 219: return "CM3: TEMPERATURE AT THE TROP. LEVEL"; + case 220: return "CM3: HEIGHT OF THE TROPOPAUSE"; + case 221: return "CM3: HIGH CLOUD AMOUNT"; + case 222: return "CM3: MEDIUM CLOUD AMOUNT"; + case 223: return "CM3: LOW CLOUD AMOUNT"; + case 224: return "CM3: PRESSURE AT MEAN SEA LEVEL"; + } + break; + case 24: + switch (item) { + case 1: return "CM4: PSTAR AFTER TIMESTEP"; + case 2: return "CM4: U COMPNT OF WIND AFTER TIMESTEP"; + case 3: return "CM4: V COMPNT OF WIND AFTER TIMESTEP"; + case 4: return "CM4: THETA AFTER TIMESTEP"; + case 10: return "CM4: SPECIFIC HUMIDITY AFTER TSTEP"; + case 13: return "CM4: CONV CLOUD AMOUNT AFTER TSTEP"; + case 14: return "CM4: CONV CLOUD BASE LEV NO AFTER TS"; + case 15: return "CM4: CONV CLOUD TOP LEV NO AFTER TS"; + case 16: return "CM4: CONV CLOUD LIQUID WATER PATH"; + case 23: return "CM4: SNOW AMOUNT AFTER TSTEP KG/M2"; + case 24: return "CM4: SURFACE TEMPERATURE AFTER TS"; + case 25: return "CM4: BOUNDARY LAYER DEPTH AFTER TS"; + case 26: return "CM4: ROUGHNESS LENGTH AFTER TIMESTEP"; + case 28: return "CM4: SURFACE ZONAL CURRENT AFTER TS"; + case 29: return "CM4: SURFACE MERID CURRENT AFTER TS"; + case 31: return "CM4: SEA ICE FRACTION AFTER TIMESTEP"; + case 32: return "CM4: SEA ICE DEPTH (MEAN OVER ICE) M"; + case 61: return "CM4: ATM TRACER 1 (CONVEN O3 )"; + case 62: return "CM4: ATM TRACER 2 (CONVEN H2O )"; + case 63: return "CM4: ATM TRACER 3 (CONVEN CO )"; + case 64: return "CM4: ATM TRACER 4 (CONVEN CH4 )"; + case 65: return "CM4: ATM TRACER 5 (CONVEN N2O )"; + case 66: return "CM4: ATM TRACER 6 (CONVEN NO )"; + case 67: return "CM4: ATM TRACER 7 (CONVEN NO2 )"; + case 68: return "CM4: ATM TRACER 8 (CONVEN HNO3 )"; + case 69: return "CM4: ATM TRACER 9 (CONVEN N2O5 )"; + case 70: return "CM4: ATM TRACER 10 (CONVEN CLONO2)"; + case 71: return "CM4: ATM TRACER 11 (CONVEN CLO )"; + case 72: return "CM4: ATM TRACER 12 (CONVEN HCL )"; + case 73: return "CM4: ATM TRACER 13 (CONVEN CF2CL2)"; + case 74: return "CM4: ATM TRACER 14 (CONVEN CFCL3 )"; + case 75: return "CM4: ATM TRACER 15 (CONVEN HF )"; + case 76: return "CM4: ATM TRACER 16 (CONVEN ----- )"; + case 77: return "CM4: ATM TRACER 17 (CONVEN ----- )"; + case 78: return "CM4: ATM TRACER 18 (CONVEN ----- )"; + case 79: return "CM4: ATM TRACER 19 (CONVEN ---- )"; + case 80: return "CM4: ATM TRACER 20 (CONVEN ---- )"; + case 81: return "CM4: ATM TRACER 21 (CONVEN H2S )"; + case 82: return "CM4: ATM TRACER 22 (CONV WATER-SOL )"; + case 83: return "CM4: ATM TRACER 23 (CONV DUST-LIKE )"; + case 84: return "CM4: ATM TRACER 24 (CONV OCEANIC )"; + case 85: return "CM4: ATM TRACER 25 (CONV SOOT )"; + case 86: return "CM4: ATM TRACER 26 (CONV VOLC ASH )"; + case 87: return "CM4: ATM TRACER 27 (CONV H2SO4 )"; + case 88: return "CM4: ATM TRACER 28 (CONV (NH4)2SO4 )"; + case 89: return "CM4: ATM TRACER 29 (MINERAL )"; + case 201: return "CM4: U COMP OF WIND ON PRESSURE LEV."; + case 202: return "CM4: V COMP OF WIND ON PRESSURE LEV."; + case 203: return "CM4: VERT VEL.(OMEGA): PRESSURE LEV."; + case 205: return "CM4: CAT PROBABILITY"; + case 206: return "CM4: HEIGHT OF THE MAX WIND LEVEL"; + case 207: return "CM4: PRESSURE OF THE MAX WIND LEVEL"; + case 208: return "CM4: U COMPONENT OF THE MAX WIND"; + case 209: return "CM4: V COMPONENT OF THE MAX WIND"; + case 210: return "CM4: GEOPOTENTIAL HT. MODEL HALF LEV"; + case 211: return "CM4: GEOPOTENTIAL HT. PRESSURE LEV."; + case 212: return "CM4: TEMPERATURE ON PRESSURE LEVELS"; + case 213: return "CM4: RELATIVE HUMIDITY ON PRESS LEVS"; + case 214: return "CM4: WET BULB POTENTIAL TEMPERATURE"; + case 215: return "CM4: SURFACE SNOW PROBABILITY"; + case 216: return "CM4: HEIGHT OF THE FREEZING LEVEL"; + case 217: return "CM4: PRESSURE OF THE FREEZING LEVEL"; + case 218: return "CM4: PRESSURE AT THE TROPOPAUSE LEV."; + case 219: return "CM4: TEMPERATURE AT THE TROP. LEVEL"; + case 220: return "CM4: HEIGHT OF THE TROPOPAUSE"; + case 221: return "CM4: HIGH CLOUD AMOUNT"; + case 222: return "CM4: MEDIUM CLOUD AMOUNT"; + case 223: return "CM4: LOW CLOUD AMOUNT"; + case 224: return "CM4: PRESSURE AT MEAN SEA LEVEL"; + } + break; + } + break; + case 2: + switch (section) { + case 0: + switch (item) { + case 101: return "POTENTIAL TEMPERATURE (OCEAN) DEG.C"; + case 102: return "SALINITY (OCEAN) (PSU-35)/1000"; + case 103: return "OCN EXTRACER 1: CONVEN TCO2"; + case 104: return "OCN EXTRACER 2: CONVEN ALAKLINITY"; + case 105: return "OCN EXTRACER 3: CONVEN NUTRIENT"; + case 106: return "OCN EXTRACER 4: CONVEN PHYTOPLNKTN"; + case 107: return "OCN EXTRACER 5: CONVEN ZOOPLNKTN"; + case 108: return "OCN EXTRACER 6: CONVEN DETRITUS"; + case 109: return "OCN EXTRACER 7: CONVEN TRITIUM"; + case 110: return "OCN EXTRACER 8: CONVEN 3H+3HE"; + case 111: return "OCN EXTRACER 9: CONVEN CFC11"; + case 112: return "OCN EXTRACER 10: CONVEN CFC12"; + case 113: return "OCN EXTRACER 11: CONVEN CFC13"; + case 114: return "OCN EXTRACER 12: CONVEN CARBON14"; + case 115: return "OCN EXTRACER 13: CONVEN --------"; + case 116: return "OCN EXTRACER 14: CONVEN --------"; + case 117: return "OCN EXTRACER 15: CONVEN -------"; + case 118: return "OCN EXTRACER 16: CONVEN -------"; + case 119: return "OCN EXTRACER 17: CONVEN -------"; + case 120: return "OCN EXTRACER 18: CONVEN -------"; + case 121: return "BAROCLINIC U_VELOCITY (OCEAN) CM/S"; + case 122: return "BAROCLINIC V_VELOCITY (OCEAN) CM/S"; + case 130: return "STREAMFUNCTION (OCEAN) CM3/S"; + case 131: return "STREAMFUNCTION (T-1) (OCEAN) CM3/S"; + case 132: return "STREAMFN TENDENCY (OCEAN) CM3/S/TS"; + case 133: return "STREAMFN TENDENCY(T-1)(OCN) CM3/S/TS"; + case 134: return "SURFACE ELEVATION (OCEAN) CM"; + case 135: return "BAROTROPIC U_VELOCITY (OCEAN) CM/S"; + case 136: return "BAROTROPIC V_VELOCITY (OCEAN) CM/S"; + case 137: return "MIXED LAYER DEPTH (OCEAN) M"; + case 139: return "ISX X OCEAN/ICE STRESS (ICE) N/M2"; + case 140: return "ISY Y OCEAN/ICE STRESS (ICE) N/M2"; + case 141: return "SNOW DEPTH (OCEAN) M"; + case 142: return "GBM CARYHEAT MISC HEAT FLX(ICE) W/M2"; + case 143: return "GBM HEAT FLUX:OCEAN TO ICE(OCN) W/M2"; + case 144: return "RATE OF SALINITY CHANGE (ICE) PSU/S"; + case 145: return "ICY : TRUE IF BOX CONTAINS ICE"; + case 146: return "AICE : ICE CONCENTRATION"; + case 147: return "HICE: MEAN ICE DEPTH OVER GRIDBOX M"; + case 148: return "ICE U_VELOCITY M/S"; + case 149: return "ICE V_VELOCITY M/S"; + case 150: return "TAUX: X_WINDSTRESS N/M2 A"; + case 151: return "TAUY: Y_WINDSTRESS N/M2 A"; + case 152: return "WME: WIND MIXING ENERGY FLUX W/M2 A"; + case 161: return "SOL: PEN.SOLAR*LF INTO OCEAN W/M2 A"; + case 162: return "HTN:NONPEN.HT.FLX*LF INTO OCN W/M2 A"; + case 165: return "PLE:PRECIP-EVAP INTO OCEAN KG/M2/S A"; + case 166: return "RIVER OUTFLOW INTO OCEAN KG/M2/S A"; + case 167: return "WATER TYPE A"; + case 170: return "SOLAR RADIATION OVER ICE W/M2 A"; + case 171: return "SNOWFALL INTO OCN/ONTO ICE KG/M2/S A"; + case 172: return "SUBLIMATION FROM SEAICE KG/M2/S A"; + case 175: return "LAT B'DARY CONDITIONS (BOUNDARY)"; + case 176: return "LAT B'DARY TENDENCIES (BOUNDARY)"; + case 180: return "REF. SEA SURF. TEMPERATURE DEG.C A"; + case 181: return "REF.SEA SURF.SALINITY(PSU-35)/1000 A"; + case 182: return "CLIM. AIR TEMPERATURE DEG.C A"; + case 183: return "CLIMATOLOGICAL ICE DEPTH M A"; + case 185: return "OCEAN HEAT FLUX CORRECTION W/M2 A"; + case 186: return "P-E FLUX CORRECTION KG/M2/S A"; + case 190: return "GBM SEAICE TOPMELT HEAT FLUX W/M2 A"; + case 191: return "GBM SEAICE BOTMELT HEAT FLUX W/M2 A"; + case 192: return "CONJUGATE GRADIENT RESIDUAL (TS)"; + case 193: return "CONJUGATE GRADIENT RESIDUAL (TS-1)"; + case 194: return "THICKNESS DIFF COEFF (OCEAN) CM2/S"; + case 195: return "SURFACE ELEVATION(DTBT-1)(OCEAN) CM"; + case 196: return "B'TROPIC U_FLUX (DTBT-1)(OCEAN)CM2/S"; + case 197: return "B'TROPIC V_FLUX (DTBT-1)(OCEAN)CM2/S"; + case 198: return "B'TROPIC U_FLUX (DTBC-1)(OCEAN)CM2/S"; + case 199: return "B'TROPIC V_FLUX (DTBC-1)(OCEAN)CM2/S"; + case 200: return "CO2 ATMOS LEVEL 1 CONC ppmv"; + } + break; + case 30: + switch (item) { + case 201: return "VERT.VEL. ON OCEAN HALF LEVELS CM/S"; + case 202: return "MIXED LAYER DEPTH M"; + case 203: return "ANOMALOUS HEAT FLUX W/M2"; + case 204: return "ANOMALOUS SALINITY FLUX KG/M2/S"; + case 205: return "ANOMALOUS SEA ICE HEAT FLUX W/M2"; + case 206: return "GBM HTN INTO OCEAN BUDGET W/M**2"; + case 207: return "SNOWRATE WHERE NO ICE KG M**-2 S**-1"; + case 208: return "CARYHEAT AFTER ROW CALCULATION W/M2"; + case 210: return "DTHETA/DT IN TOTAL K/Gs"; + case 211: return "MEAD DIAGNOSTICS: TEMPERATURE W"; + case 212: return "MEAD DIAGNOSTICS: SALINITY KG/S"; + case 213: return "MEAD DIAGNOSTICS: EXTRA TRACER 1"; + case 214: return "MEAD DIAGNOSTICS: EXTRA TRACER 2"; + case 215: return "MEAD DIAGNOSTICS: EXTRA TRACER 3"; + case 216: return "MEAD DIAGNOSTICS: EXTRA TRACER 4"; + case 217: return "MEAD DIAGNOSTICS: EXTRA TRACER 5"; + case 218: return "MEAD DIAGNOSTICS: EXTRA TRACER 6"; + case 219: return "MEAD DIAGNOSTICS: EXTRA TRACER 7"; + case 220: return "MEAD DIAGNOSTICS: EXTRA TRACER 8"; + case 221: return "MEAD DIAGNOSTICS: EXTRA TRACER 9"; + case 222: return "MEAD DIAGNOSTICS: EXTRA TRACER 10"; + case 223: return "MEAD DIAGNOSTICS: EXTRA TRACER 11"; + case 224: return "MEAD DIAGNOSTICS: EXTRA TRACER 12"; + case 225: return "MEAD DIAGNOSTICS: EXTRA TRACER 13"; + case 226: return "MEAD DIAGNOSTICS: EXTRA TRACER 14"; + case 227: return "MEAD DIAGNOSTICS: EXTRA TRACER 15"; + case 228: return "MEAD DIAGNOSTICS: EXTRA TRACER 16"; + case 229: return "MEAD DIAGNOSTICS: EXTRA TRACER 17"; + case 230: return "MEAD DIAGNOSTICS: EXTRA TRACER 18"; + case 231: return "DTHETA/DT FROM X-ADVECTION K/Gs"; + case 232: return "DTHETA/DT FROM Y-ADVECTION K/Gs"; + case 233: return "DTHETA/DT FROM Z-ADVECTION K/Gs"; + case 234: return "DTHETA/DT FROM X-DIFFUSION K/Gs"; + case 235: return "DTHETA/DT FROM Y-DIFFUSION K/Gs"; + case 236: return "DTHETA/DT FROM Z-DIFFUSION K/Gs"; + case 237: return "DTHETA/DT FROM SFC. FLUXES K/Gs"; + case 238: return "DTHETA/DT FROM PEN. SOLAR K/Gs"; + case 239: return "DTHETA/DT FROM ICE PHYSICS K/Gs"; + case 240: return "DTHETA/DT FROM ML PHYSICS K/Gs"; + case 241: return "DTHETA/DT FROM CONVECTION K/Gs"; + case 242: return "DTHETA/DT FROM ADVECTION K/Gs"; + case 243: return "DTHETA/DT FROM FOURIER FILT K/Gs"; + case 244: return "DTHETA/DT FROM ROBERT FILT K/Gs"; + case 245: return "DTHETA/DT FROM MED. OUTFLOW K/Gs"; + case 246: return "BAROCLINIC X-ACCN (ZUN) CM/S**2"; + case 247: return "BAROCLINIC Y-ACCN (ZVN) CM/S**2"; + case 248: return "PCO2 (OCEAN)"; + case 249: return "CO2 FLUX (AIR-TO-SEA) (MOLE-C/M2/YR)"; + case 250: return "CO2 INVASION RATE (MOLE-C/M2/YR)"; + case 251: return "CO2 EVASION RATE (MOLE-C/M2/YR)"; + case 252: return "PRIMARY PRODUCTION (GC/M2/DAY)"; + case 253: return "ZOOPLTN PRODUCTION (GC/M2/DAY)"; + case 254: return "PHYTO SPECIFIC GROWTH RATE (1/DAY)"; + case 255: return "PHYTO SPECIFIC GRAZING RATE (1/DAY)"; + case 256: return "PHYTO SPECIFIC MORTALITY (1/DAY)"; + case 257: return "NITRATE GAIN-EXCRETION (MMOL-N/M2/D)"; + case 258: return "NITRATE LOSS - GROWTH (MMOL-N/M2/D)"; + case 259: return "NITRATE GAIN-PHY MORT (MMOL-N/M2/D)"; + case 260: return "NITRATE GAIN-ZOO MORT (MMOL-N/M2/D)"; + case 261: return "NITRATE GAIN-PHY RESP (MMOL-N/M2/D)"; + case 262: return "NITRATE GAIN-REMIN (MMOL-N/M2/D)"; + case 263: return "NUTRIENT LIMITATION"; + case 264: return "LIGHT LIMITATION"; + case 265: return "TEMPERATURE LIMITATION"; + case 266: return "DETRITUS FLUX (MMOL-N/M2/D)"; + case 267: return "VERTICAL NITRATE FLUX (MMOL-N/M2/D)"; + case 268: return "HORIZ NITRATE ADVECT RATE(MMOL/M3/D)"; + case 269: return "VERT NITRATE ADVECTN RATE(MMOL/M3/D)"; + case 270: return "HORIZ NITRATE DIFFUSION (MMOL/M3/D)"; + case 271: return "VERT NITRATE DIFFUSION (MMOL/M3/D)"; + case 272: return "NITRATE MIXING DUE TO MLM(MMOL/M3/D)"; + case 273: return "NITRATE CONVECTION (MMOL/M3/D)"; + case 274: return "NITRATE CHANGE - BIOLOGY (MMOL/M3/D)"; + case 275: return "NITRATE CHANGE-RESETTING (MMOL/M3/D)"; + case 276: return "HORIZ PHYTO ADVECT RATE(MMOL-N/M3/D)"; + case 277: return "HORIZ ZOO ADVECT RATE(MMOL-N/M3/D)"; + case 278: return "HORIZ DETRI ADVECT RATE(MMOL-N/M3/D)"; + case 279: return "ANOM. HEAT \"SINK\" AT OCN FLOOR W/M2"; + case 280: return "WATER_FLUX*SALINITY/DENSITY m Gs**-1"; + case 281: return "GM EDDY U VELOCITY (OCEAN)"; + case 282: return "GM EDDY V VELOCITY (N FACE) (OCEAN)"; + case 283: return "GM EDDY W VEL (TOP FACE) (OCEAN)"; + case 284: return "DTHETA/DT FROM G&MCW SCHEME K/Gs"; + case 285: return "RIGID-LID PRESSURE/PA"; + case 286: return "OLD- DO NOT USE: KM"; + case 287: return "OLD- DO NOT USE: KT"; + case 288: return "OLD- DO NOT USE: RIM"; + case 289: return "OLD- DO NOT USE: RIT"; + case 290: return "HM MAX DEPTH LARGE SCHEME MOMENTUM"; + case 291: return "HT MAX DEPTH LARGE SCHEME TRACER"; + case 292: return "OLD- DO NOT USE: VIRT A-S FLUX CO2"; + case 293: return "OLD- DO NOT USE: VIRT A-S FLUX ALK"; + case 294: return "RICHARDSON NO CALC FROM MLD ROUTINE"; + case 296: return "KM VERT MOM DIFF COEFF"; + case 297: return "KT VERT TRACER DIFF COEFF"; + case 298: return "RIM RICHARDSON NUMBER MOMENTUM"; + case 299: return "RIT RICHARDSON NUMBER TRACER"; + case 301: return "TEMPERATURE (OCEAN) DEG.C"; + case 302: return "LM MONIN OBUKHOV LENGTH MOMENTUM"; + case 303: return "LT MONIN OBUKHOV LENGTH TRACER"; + case 306: return "DS/DT FROM X-ADVECTION (OCN) Gs**-1"; + case 307: return "DS/DT FROM Y-ADVECTION (OCN) Gs**-1"; + case 308: return "DS/DT FROM Z-ADVECTION (OCN) Gs**-1"; + case 309: return "DS/DT FROM X-DIFFUSION (OCN) Gs**-1"; + case 310: return "DS/DT FROM Y-DIFFUSION (OCN) Gs**-1"; + case 311: return "DS/DT FROM Z-DIFFUSION (OCN) Gs**-1"; + case 312: return "DS/DT FROM SFC. FLUXES (OCN) Gs**-1"; + case 313: return "DS/DT FROM ICE PHYSICS (OCN) Gs**-1"; + case 314: return "DS/DT FROM ML PHYSICS (OCN) Gs**-1"; + case 315: return "DS/DT FROM CONVECTION (OCN) Gs**-1"; + case 316: return "DS/DT FROM ADVECTION Gs**-1"; + case 317: return "DS/DT FROM FOURIER FILT (OCN) Gs**-1"; + case 318: return "DS/DT FROM ROBERT FILT (OCN) Gs**-1"; + case 319: return "DS/DT FROM MED. OUTFLOW (OCN) Gs**-1"; + case 320: return "TOTAL OCEAN U-VELOCITY CM S**-1"; + case 321: return "TOTAL OCEAN V-VELOCITY CM S**-1"; + case 322: return "DS/DT FROM G&MCW SCHEME Gs**-1"; + } + break; + case 31: + switch (item) { + case 201: return "HR: RECIP.OF DEPTH AT UV POINTS 1/CM"; + case 202: return "CHANGE IN VORTICITY ACROSS TSTEP:ZTD"; + case 211: return "ZMN VORTY FORCING: ADVECTION S*-2"; + case 212: return "ZMN VORTY FORCING: HOR DIFFN S*-2"; + case 213: return "ZMN VORTY FORCING: VRT DIFFN S*-2"; + case 214: return "ZMN VORTY FORCING: CORIOLIS S*-2"; + case 215: return "ZMN VORTY FORCING: PRESSURE S*-2"; + case 216: return "INT VORTY FORCING: ADVECTION CM S*-2"; + case 217: return "INT VORTY FORCING: HOR DIFFN CM S*-2"; + case 218: return "INT VORTY FORCING: VRT DIFFN CM S*-2"; + case 219: return "INT VORTY FORCING: CORIOLIS CM S*-2"; + case 220: return "INT VORTY FORCING: BOTTOM P CM S*-2"; + } + break; + case 32: + switch (item) { + case 201: return "AICE INC. DUE TO DYNAMICS FRACT/TS"; + case 202: return "HICE INC. DUE TO DYNAMICS M/TS"; + case 203: return "GBM SNOWDEPTH DYNAMIC INC M/TS"; + case 204: return "HICE INC. DUE TO DIFFUSION M/TS"; + case 209: return "U COMPONENT OF ICE VELOCITY (M.S-1)"; + case 210: return "V COMPONENT OF ICE VELOCITY (M.S-1)"; + case 211: return "AICE INC. (THERMODYNAMIC) FRACT/TS"; + case 212: return "HICE INC. (THERMODYNAMIC) M/TS"; + case 213: return "GBM SNOWDEPTH THERMODYNAMIC INC M/TS"; + case 214: return "GBM HTN INTO ICE BUDGET W/M**2"; + case 215: return "SNOWRATE WHERE ICY KG M**-2 S**-1"; + case 216: return "OCN TOP-LEVEL TEMPERATURE K"; + case 217: return "GBM HTN INTO OCN WHERE ICY W/M**2"; + case 218: return "GBM SNOWDEPTH ON SEA-ICE M"; + case 219: return "U CPT OF OCEAN STRESS ON ICE Pa"; + case 220: return "V CPT OF OCEAN STRESS ON ICE Pa"; + case 221: return "U CPT OF CORIOLIS STRESS ON ICE Pa"; + case 222: return "V CPT OF CORIOLIS STRESS ON ICE Pa"; + case 223: return "d/dt AICE DYNAMICS s-1"; + case 224: return "d/dt HICE DYNAMICS m s-1"; + case 225: return "d/dt GBM SNOWDEPTH DYNAMICS m s-1"; + case 226: return "d/dt HICE DIFFUSION m s-1"; + case 227: return "d/dt AICE THERMODYN s-1"; + case 228: return "d/dt HICE THERMODYN m s-1"; + case 229: return "d/dt GBM SNOWDEPTH THERMODYN m s-1"; + case 230: return "U CPT OF INTERNAL ICE STRESS Pa"; + case 231: return "V CPT OF INTERNAL ICE STRESS Pa"; + } + break; + case 35: + switch (item) { + case 101: return "POTENTIAL TEMPERATURE (OCEAN) DEG.C"; + case 102: return "SALINITY (OCEAN) (PSU-35)/1000"; + case 121: return "BAROCLINIC U_VELOCITY (OCEAN) CM/S"; + case 122: return "BAROCLINIC V_VELOCITY (OCEAN) CM/S"; + case 130: return "STREAMFUNCTION (OCEAN) CM3/S"; + case 134: return "SURFACE ELEVATION (OCEAN) CM"; + case 135: return "BAROTROPIC U_VELOCITY (OCEAN) CM/S"; + case 136: return "BAROTROPIC V_VELOCITY (OCEAN) CM/S"; + case 137: return "MIXED LAYER DEPTH (OCEAN) M"; + case 201: return "OCEAN ASSIM SRFC. HEIGHT WEIGHTS"; + case 202: return "OCEAN ASSIM MIXED LAYER DEPTH WTS"; + case 203: return "OCEAN ASSIM SRFC. TEMP. WEIGHTS"; + case 204: return "OCEAN ASSIM POT. TEMP. WEIGHTS"; + case 205: return "OCEAN ASSIM SALINE WEIGHTS"; + case 206: return "OCEAN ASSIM VELOCITY WEIGHTS"; + case 211: return "OCEAN ASSIM SRFC. HEIGHT INCREMENTS"; + case 213: return "OCEAN ASSIM SRFC. TEMP. INCREMENTS"; + case 214: return "OCEAN ASSIM POT. TEMP. INCREMENTS"; + case 215: return "OCEAN ASSIM SALINE INCREMENTS"; + case 221: return "OCN ASSM MERID VEL. INCS AFTER SHGHT"; + case 224: return "OCN ASSM MERID VEL. INCS AFTER THRML"; + case 225: return "OCN ASSM MERID VEL. INCS AFTER SALIN"; + case 231: return "OCN ASSM ZONAL VEL. INCS AFTER SHGHT"; + case 234: return "OCN ASSM ZONAL VEL. INCS AFTER THRML"; + case 235: return "OCN ASSM ZONAL VEL. INCS AFTER SALIN"; + case 241: return "OCN ASSM PRESS. INCS AFTER SHGHT ANA"; + case 244: return "OCN ASSM PRESS. INCS AFTER THRML ANA"; + case 245: return "OCN ASSM PRESS. INCS AFTER SALIN ANA"; + case 251: return "OCN ASSM PTM INCR AFTER SRF HGT ANAL"; + case 254: return "OCN ASSM SAL INCR AFTER SRF HGT ANAL"; + case 255: return "OCN ASSM VRT DISP AFTER SRF HGT ANAL"; + } + break; + case 41: + switch (item) { + case 101: return "CM1: POTENTIAL TEMP. (OCEAN) DEG.C"; + case 102: return "CM1: SALINITY (OCEAN) (PSU-35)/1000"; + case 103: return "CM1: OCN EXTRACER 1: CON TCO2"; + case 104: return "CM1: OCN EXTRACER 2: CON ALKALINITY"; + case 105: return "CM1: OCN EXTRACER 3: CON NUTRIENT"; + case 106: return "CM1: OCN EXTRACER 4: CON PHYTOPLNKT"; + case 107: return "CM1: OCN EXTRACER 5: CON ZOOPLNKTN"; + case 108: return "CM1: OCN EXTRACER 6: CON DETRITUS"; + case 109: return "CM1: OCN EXTRACER 7: CON TRITIUM"; + case 110: return "CM1: OCN EXTRACER 8: CON 3H+3HE"; + case 111: return "CM1: OCN EXTRACER 9: CON CFC11"; + case 112: return "CM1: OCN EXTRACER 10: CON CFC12"; + case 113: return "CM1: OCN EXTRACER 11: CON CFC13"; + case 114: return "CM1: OCN EXTRACER 12: CON CARBON14"; + case 115: return "CM1: OCN EXTRACER 13: CON -------"; + case 116: return "CM1: OCN EXTRACER 14: CON -------"; + case 117: return "CM1: OCN EXTRACER 15: CON -------"; + case 118: return "CM1: OCN EXTRACER 16: CON -------"; + case 119: return "CM1: OCN EXTRACER 17: CON -------"; + case 120: return "CM1: OCN EXTRACER 18: CON -------"; + case 121: return "CM1: BAROCLINIC U_VEL (OCEAN) CM/S"; + case 122: return "CM1: BAROCLINIC V_VEL (OCEAN) CM/S"; + case 130: return "CM1: STREAMFUNCTION (OCEAN) CM3/S"; + case 131: return "CM1: STREAMFTN (T-1) (OCEAN) CM3/S"; + case 132: return "CM1: STREAMFTN TENDENCY(OC) CM3/S/TS"; + case 133: return "CM1: STREAMFTN TENDENCY(T-1)(OCEAN)"; + case 134: return "CM1: SURFACE ELEVATION (OCEAN) CM"; + case 135: return "CM1: BAROTROPIC U_VEL (OCEAN) CM/S"; + case 136: return "CM1: BAROTROPIC V_VEL (OCEAN) CM/S"; + case 137: return "CM1: MIXED LAYER DEPTH (OCEAN) M"; + case 139: return "CM1: ISX OCEAN/ICE STRESS(ICE) N/M2"; + case 140: return "CM1: ISY OCEAN/ICE STRESS(ICE) N/M2"; + case 141: return "CM1: SNOW DEPTH (OCEAN) M"; + case 142: return "CM1: GBM CARYHEAT MISC HEAT FLX(ICE)"; + case 143: return "CM1: GBM HEAT FLUX:OCEAN TO ICE(OCN)"; + case 144: return "CM1: RATE OF SAL CHANGE (ICE) PSU/S"; + case 145: return "CM1: ICY : TRUE IF SOME ICE"; + case 146: return "CM1: AICE : ICE CONCENTRATION"; + case 147: return "CM1: HICE : MEAN ICE DEPTH M"; + case 148: return "CM1: ICE U_VELOCITY M/S"; + case 149: return "CM1: ICE V_VELOCITY M/S"; + case 150: return "CM1: TAUX: X_WINDSTRESS N/M2 A"; + case 151: return "CM1: TAUY: Y_WINDSTRESS N/M2 A"; + case 152: return "CM1: WME: WIND MIXING EN FLUX W/M2 A"; + case 161: return "CM1: SOL:PEN.SOLAR*LF INTO OC W/M2 A"; + case 162: return "CM1: HTN:NONPEN.HT.FLX*LF INTO OCN A"; + case 165: return "CM1: PLE:PRECIP-EVAP INTO OCEAN A"; + case 166: return "CM1: RIVER OUTFLOW INTO OCEAN A"; + case 167: return "CM1: WATER TYPE A"; + case 170: return "CM1: SOLAR RADIATION OVER ICE W/M2 A"; + case 171: return "CM1: SNOWFALL INTO OCEAN/ONTO ICE A"; + case 172: return "CM1: SUBLIMATION FROM SEAICE A"; + case 180: return "CM1: REF. SEA SURFACE TEMP. DEG.C A"; + case 181: return "CM1: REF. SEA SURFACE SALINITY A"; + case 182: return "CM1: CLIM. AIR TEMPERATURE DEG.C A"; + case 183: return "CM1: CLIMATOLOGICAL ICE DEPTH M A"; + case 185: return "CM1: OCEAN HEAT FLUX CORRN. W/M2 A"; + case 186: return "CM1: P-E FLUX CORRECTION KG/M2/S A"; + case 187: return "CM1: S-ICE HT FLUX CORRN: DIABLED"; + case 190: return "CM1: GBM SEAICE TOPMELT HEAT FLUX A"; + case 191: return "CM1: GBM SEAICE BOTMELT HEAT FLUX A"; + } + break; + case 42: + switch (item) { + case 101: return "CM2: POTENTIAL TEMP. (OCEAN) DEG.C"; + case 102: return "CM2: SALINITY (OCEAN) (PSU-35)/1000"; + case 103: return "CM2: OCN EXTRACER 1: CON TCO2"; + case 104: return "CM2: OCN EXTRACER 2: CON ALKALINITY"; + case 105: return "CM2: OCN EXTRACER 3: CON NUTRIENT"; + case 106: return "CM2: OCN EXTRACER 4: CON PHYTOPLNKT"; + case 107: return "CM2: OCN EXTRACER 5: CON ZOOPLNKTN"; + case 108: return "CM2: OCN EXTRACER 6: CON DETRIUS"; + case 109: return "CM2: OCN EXTRACER 7: CON TRITIUM"; + case 110: return "CM2: OCN EXTRACER 8: CON 3H+3HE"; + case 111: return "CM2: OCN EXTRACER 9: CON CFC11"; + case 112: return "CM2: OCN EXTRACER 10: CON CFC12"; + case 113: return "CM2: OCN EXTRACER 11: CON CFC13"; + case 114: return "CM2: OCN EXTRACER 12: CON CARBON14"; + case 115: return "CM2: OCN EXTRACER 13: CON -------"; + case 116: return "CM2: OCN EXTRACER 14: CON -------"; + case 117: return "CM2: OCN EXTRACER 15: CON -------"; + case 118: return "CM2: OCN EXTRACER 16: CON -------"; + case 119: return "CM2: OCN EXTRACER 17: CON -------"; + case 120: return "CM2: OCN EXTRACER 18: CON -------"; + case 121: return "CM2: BAROCLINIC U_VEL (OCEAN) CM/S"; + case 122: return "CM2: BAROCLINIC V_VEL (OCEAN) CM/S"; + case 130: return "CM2: STREAMFUNCTION (OCEAN) CM3/S"; + case 131: return "CM2: STREAMFTN (T-1) (OCEAN) CM3/S"; + case 132: return "CM2: STREAMFTN TENDENCY(OC) CM3/S/TS"; + case 133: return "CM2: STREAMFTN TENDENCY(T-1)(OCEAN)"; + case 134: return "CM2: SURFACE ELEVATION (OCEAN) CM"; + case 135: return "CM2: BAROTROPIC U_VEL (OCEAN) CM/S"; + case 136: return "CM2: BAROTROPIC V_VEL (OCEAN) CM/S"; + case 137: return "CM2: MIXED LAYER DEPTH (OCEAN) M"; + case 139: return "CM2: ISX OCEAN/ICE STRESS(ICE) N/M2"; + case 140: return "CM2: ISY OCEAN/ICE STRESS(ICE) N/M2"; + case 141: return "CM2: SNOW DEPTH (OCEAN) M"; + case 142: return "CM2: GBM CARYHEAT MISC HEAT FLX(ICE)"; + case 143: return "CM2: GBM HEAT FLUX:OCEAN TO ICE(OCN)"; + case 144: return "CM2: RATE OF SAL CHANGE (ICE) PSU/S"; + case 145: return "CM2: ICY : TRUE IF SOME ICE"; + case 146: return "CM2: AICE : ICE CONCENTRATION"; + case 147: return "CM2: HICE : MEAN ICE DEPTH M"; + case 148: return "CM2: ICE U_VELOCITY M/S"; + case 149: return "CM2: ICE V_VELOCITY M/S"; + case 150: return "CM2: TAUX: X_WINDSTRESS N/M2 A"; + case 151: return "CM2: TAUY: Y_WINDSTRESS N/M2 A"; + case 152: return "CM2: WME: WIND MIXING EN FLUX W/M2 A"; + case 161: return "CM2: SOL:PEN.SOLAR*LF INTO OC W/M2 A"; + case 162: return "CM2: HTN:NONPEN.HT.FLX*LF INTO OCN A"; + case 165: return "CM2: PLE:PRECIP-EVAP INTO OCEAN A"; + case 166: return "CM2: RIVER OUTFLOW INTO OCEAN A"; + case 167: return "CM2: WATER TYPE A"; + case 170: return "CM2: SOLAR RADIATION OVER ICE W/M2 A"; + case 171: return "CM2: SNOWFALL INTO OCEAN/ONTO ICE A"; + case 172: return "CM2: SUBLIMATION FROM SEAICE A"; + case 180: return "CM2: REF. SEA SURFACE TEMP. DEG.C A"; + case 181: return "CM2: REF. SEA SURFACE SALINITY A"; + case 182: return "CM2: CLIM. AIR TEMPERATURE DEG.C A"; + case 183: return "CM2: CLIMATOLOGICAL ICE DEPTH M A"; + case 185: return "CM2: OCEAN HEAT FLUX CORRN. W/M2 A"; + case 186: return "CM2: P-E FLUX CORRECTION KG/M2/S A"; + case 187: return "CM2: S-ICE HT FLUX CORRN. DIABLED"; + case 190: return "CM2: GBM SEAICE TOPMELT HEAT FLUX A"; + case 191: return "CM2: GBM SEAICE BOTMELT HEAT FLUX A"; + } + break; + case 43: + switch (item) { + case 101: return "CM3: POTENTIAL TEMP. (OCEAN) DEG.C"; + case 102: return "CM3: SALINITY (OCEAN) (PSU-35)/1000"; + case 103: return "CM3: OCN EXTRACER 1: CON TCO2"; + case 104: return "CM3: OCN EXTRACER 2: CON ALKALINITY"; + case 105: return "CM3: OCN EXTRACER 3: CON NUTRIENT"; + case 106: return "CM3: OCN EXTRACER 4: CON PHYTOPLNKT"; + case 107: return "CM3: OCN EXTRACER 5: CON ZOOPLNKTN"; + case 108: return "CM3: OCN EXTRACER 6: CON DETRITUS"; + case 109: return "CM3: OCN EXTRACER 7: CON TRITIUM"; + case 110: return "CM3: OCN EXTRACER 8: CON 3H+3HE"; + case 111: return "CM3: OCN EXTRACER 9: CON CFC11"; + case 112: return "CM3: OCN EXTRACER 10: CON CFC12"; + case 113: return "CM3: OCN EXTRACER 11: CON CFC13"; + case 114: return "CM3: OCN EXTRACER 12: CON CARBON14"; + case 115: return "CM3: OCN EXTRACER 13: CON -------"; + case 116: return "CM3: OCN EXTRACER 14: CON -------"; + case 117: return "CM3: OCN EXTRACER 15: CON -------"; + case 118: return "CM3: OCN EXTRACER 16: CON -------"; + case 119: return "CM3: OCN EXTRACER 17: CON -------"; + case 120: return "CM3: OCN EXTRACER 18: CON -------"; + case 121: return "CM3: BAROCLINIC U_VEL (OCEAN) CM/S"; + case 122: return "CM3: BAROCLINIC V_VEL (OCEAN) CM/S"; + case 130: return "CM3: STREAMFUNCTION (OCEAN) CM3/S"; + case 131: return "CM3: STREAMFTN (T-1) (OCEAN) CM3/S"; + case 132: return "CM3: STREAMFTN TENDENCY(OC) CM3/S/TS"; + case 133: return "CM3: STREAMFTN TENDENCY(T-1)(OCEAN)"; + case 134: return "CM3: SURFACE ELEVATION (OCEAN) CM"; + case 135: return "CM3: BAROTROPIC U_VEL (OCEAN) CM/S"; + case 136: return "CM3: BAROTROPIC V_VEL (OCEAN) CM/S"; + case 137: return "CM3: MIXED LAYER DEPTH (OCEAN) M"; + case 139: return "CM3: ISX OCEAN/ICE STRESS(ICE) N/M2"; + case 140: return "CM3: ISY OCEAN/ICE STRESS(ICE) N/M2"; + case 141: return "CM3: SNOW DEPTH (OCEAN) M"; + case 142: return "CM3: GBM CARYHEAT MISC HEAT FLX(ICE)"; + case 143: return "CM3: GBM HEAT FLUX:OCEAN TO ICE(OCN)"; + case 144: return "CM3: RATE OF SAL CHANGE (ICE) PSU/S"; + case 145: return "CM3: ICY : TRUE IF SOME ICE"; + case 146: return "CM3: AICE : ICE CONCENTRATION"; + case 147: return "CM3: HICE : MEAN ICE DEPTH M"; + case 148: return "CM3: ICE U_VELOCITY M/S"; + case 149: return "CM3: ICE V_VELOCITY M/S"; + case 150: return "CM3: TAUX: X_WINDSTRESS N/M2 A"; + case 151: return "CM3: TAUY: Y_WINDSTRESS N/M2 A"; + case 152: return "CM3: WME: WIND MIXING EN FLUX W/M2 A"; + case 161: return "CM3: SOL:PEN.SOLAR*LF INTO OC W/M2 A"; + case 162: return "CM3: HTN:NONPEN.HT.FLX*LF INTO OCN A"; + case 165: return "CM3: PLE:PRECIP-EVAP INTO OCEAN A"; + case 166: return "CM3: RIVER OUTFLOW INTO OCEAN A"; + case 167: return "CM3: WATER TYPE A"; + case 170: return "CM3: SOLAR RADIATION OVER ICE W/M2 A"; + case 171: return "CM3: SNOWFALL INTO OCEAN/ONTO ICE A"; + case 172: return "CM3: SUBLIMATION FROM SEAICE A"; + case 180: return "CM3: REF. SEA SURFACE TEMP. DEG.C A"; + case 181: return "CM3: REF. SEA SURFACE SALINITY A"; + case 182: return "CM3: CLIM. AIR TEMPERATURE DEG.C A"; + case 183: return "CM3: CLIMATOLOGICAL ICE DEPTH M A"; + case 185: return "CM3: OCEAN HEAT FLUX CORRN. W/M2 A"; + case 186: return "CM3: P-E FLUX CORRECTION KG/M2/S A"; + case 187: return "CM3: S-ICE HT FLUX CORRN. DISABLED"; + case 190: return "CM3: GBM SEAICE TOPMELT HEAT FLUX A"; + case 191: return "CM3: GBM SEAICE BOTMELT HEAT FLUX A"; + } + break; + case 44: + switch (item) { + case 101: return "CM4: POTENTIAL TEMP. (OCEAN) DEG.C"; + case 102: return "CM4: SALINITY (OCEAN) (PSU-35)/1000"; + case 103: return "CM4: OCN EXTRACER 1: CON TCO2"; + case 104: return "CM4: OCN EXTRACER 2: CON ALKALINITY"; + case 105: return "CM4: OCN EXTRACER 3: CON NUTRIENT"; + case 106: return "CM4: OCN EXTRACER 4: CON PHYTOPLNKT"; + case 107: return "CM4: OCN EXTRACER 5: CON ZOOPLNKTN"; + case 108: return "CM4: OCN EXTRACER 6: CON DETRITUS"; + case 109: return "CM4: OCN EXTRACER 7: CON TRITIUM"; + case 110: return "CM4: OCN EXTRACER 8: CON CFC11"; + case 111: return "CM4: OCN EXTRACER 9: CON CFC12"; + case 112: return "CM4: OCN EXTRACER 10: CON CFC13"; + case 113: return "CM4: OCN EXTRACER 11: CON CARBON14"; + case 114: return "CM4: OCN EXTRACER 12: CON -------"; + case 115: return "CM4: OCN EXTRACER 13: CON -------"; + case 116: return "CM4: OCN EXTRACER 14: CON -------"; + case 117: return "CM4: OCN EXTRACER 15: CON -------"; + case 118: return "CM4: OCN EXTRACER 16: CON -------"; + case 119: return "CM4: OCN EXTRACER 17: CON -------"; + case 120: return "CM4: OCN EXTRACER 18: CON -------"; + case 121: return "CM4: BAROCLINIC U_VEL (OCEAN) CM/S"; + case 122: return "CM4: BAROCLINIC V_VEL (OCEAN) CM/S"; + case 130: return "CM4: STREAMFUNCTION (OCEAN) CM3/S"; + case 131: return "CM4: STREAMFTN (T-1) (OCEAN) CM3/S"; + case 132: return "CM4: STREAMFTN TENDENCY(OC) CM3/S/TS"; + case 133: return "CM4: STREAMFTN TENDENCY(T-1)(OCEAN)"; + case 134: return "CM4: SURFACE ELEVATION (OCEAN) CM"; + case 135: return "CM4: BAROTROPIC U_VEL (OCEAN) CM/S"; + case 136: return "CM4: BAROTROPIC V_VEL (OCEAN) CM/S"; + case 137: return "CM4: MIXED LAYER DEPTH (OCEAN) M"; + case 139: return "CM4: ISX OCEAN/ICE STRESS(ICE) N/M2"; + case 140: return "CM4: ISY OCEAN/ICE STRESS(ICE) N/M2"; + case 141: return "CM4: SNOW DEPTH (OCEAN) M"; + case 142: return "CM4: GBM CARYHEAT MISC HEAT FLX(ICE)"; + case 143: return "CM4: GBM HEAT FLUX:OCEAN TO ICE(OCN)"; + case 144: return "CM4: RATE OF SAL CHANGE (ICE) PSU/S"; + case 145: return "CM4: ICY : TRUE IF SOME ICE"; + case 146: return "CM4: AICE : ICE CONCENTRATION"; + case 147: return "CM4: HICE : MEAN ICE DEPTH M"; + case 148: return "CM4: ICE U_VELOCITY M/S"; + case 149: return "CM4: ICE V_VELOCITY M/S"; + case 150: return "CM4: TAUX: X_WINDSTRESS N/M2 A"; + case 151: return "CM4: TAUY: Y_WINDSTRESS N/M2 A"; + case 152: return "CM4: WME: WIND MIXING EN FLUX W/M2 A"; + case 161: return "CM4: SOL:PEN.SOLAR*LF INTO OC W/M2 A"; + case 162: return "CM4: HTN:NONPEN.HT.FLX*LF INTO OCN A"; + case 165: return "CM4: PLE:PRECIP-EVAP INTO OCEAN A"; + case 166: return "CM4: RIVER OUTFLOW INTO OCEAN A"; + case 167: return "CM4: WATER TYPE A"; + case 170: return "CM4: SOLAR RADIATION OVER ICE W/M2 A"; + case 171: return "CM4: SNOWFALL INTO OCEAN/ONTO ICE A"; + case 172: return "CM4: SUBLIMATION FROM SEAICE A"; + case 180: return "CM4: REF. SEA SURFACE TEMP. DEG.C A"; + case 181: return "CM4: REF. SEA SURFACE SALINITY A"; + case 182: return "CM4: CLIM. AIR TEMPERATURE DEG.C A"; + case 183: return "CM4: CLIMATOLOGICAL ICE DEPTH M A"; + case 185: return "CM4: OCEAN HEAT FLUX CORRN. W/M2 A"; + case 186: return "CM4: P-E FLUX CORRECTION KG/M2/S A"; + case 187: return "CM4: S-ICE HT FLUX CORRN. DISABLED"; + case 190: return "CM4: GBM SEAICE TOPMELT HEAT FLUX A"; + case 191: return "CM4: GBM SEAICE BOTMELT HEAT FLUX A"; + } + break; + } + break; + case 3: + switch (section) { + case 0: + switch (item) { + case 177: return "HEAT CONVERGENCE (SLAB MODEL) W/M2 A"; + case 178: return "REF. SEA SURF TEMP (SLAB MODEL) K A"; + case 179: return "CLIM. SEAICE DEPTH (SLAB MODEL) M A"; + case 210: return "SLAB TEMPERATURE AFTER TSTEP SLAB C"; + case 211: return "UICE ICE VELOCITY SLAB M/S"; + case 212: return "VICE ICE VELOCITY SLAB M/S"; + } + break; + case 21: + switch (item) { + case 177: return "CM1: HEAT CONVERGENCE ( SLAB) W/M2 A"; + case 178: return "CM1: REF. SEA SURF TEMP ( SLAB) K A"; + case 179: return "CM1: CLIM. SEAICE DEPTH ( SLAB) M A"; + case 225: return "CM1: SLAB TEMP AFTER TSTEP SLAB C"; + case 226: return "CM1: UICE ICE VELOCITY SLAB M/S"; + case 227: return "CM1: VICE ICE VELOCITY SLAB M/S"; + } + break; + case 22: + switch (item) { + case 177: return "CM2: HEAT CONVERGENCE (SLAB ) W/M2 A"; + case 178: return "CM2: REF. SEA SURF TEMP (SLAB ) K A"; + case 179: return "CM2: CLIM. SEAICE DEPTH (SLAB ) M A"; + case 225: return "CM2: SLAB TEMP AFTER TSTEP SLAB C"; + case 226: return "CM2: UICE ICE VELOCITY SLAB M/S"; + case 227: return "CM2: VICE ICE VELOCITY SLAB M/S"; + } + break; + case 23: + switch (item) { + case 177: return "CM3: HEAT CONVERGENCE (SLAB ) W/M2 A"; + case 178: return "CM3: REF. SEA SURF TEMP (SLAB ) K A"; + case 179: return "CM3: CLIM. SEAICE DEPTH (SLAB ) M A"; + case 225: return "CM3: SLAB TEMP AFTER TSTEP SLAB C"; + case 226: return "CM3: UICE ICE VELOCITY SLAB M/S"; + case 227: return "CM3: VICE ICE VELOCITY SLAB M/S"; + } + break; + case 24: + switch (item) { + case 177: return "CM4: HEAT CONVERGENCE (SLAB ) W/M2 A"; + case 178: return "CM4: REF. SEA SURF TEMP (SLAB ) K A"; + case 179: return "CM4: CLIM. SEAICE DEPTH (SLAB ) M A"; + case 225: return "CM4: SLAB TEMPERATURE SLAB C"; + case 226: return "CM4: UICE ICE VELOCITY SLAB M/S"; + case 227: return "CM4: VICE ICE VELOCITY SLAB M/S"; + } + break; + case 40: + switch (item) { + case 23: return "SNOW AMOUNT AFTER SLAB KG/M2"; + case 24: return "SURFACE TEMPERATURE AFTER SLAB K"; + case 31: return "SEA ICE FRACTION AFTER SLAB"; + case 32: return "SEAICE DEPTH(MN OVR ICE)AFTER SLAB M"; + case 177: return "HEAT CONVERGENCE AFTER SLAB W/M2 A"; + case 178: return "REF. SEA SURF TEMP AFTER SLAB K A"; + case 179: return "CLIM. SEAICE DEPTH AFTER SLAB M A"; + case 201: return "ANOMALOUS HEAT CONVRGENCE(SLAB) W/M2"; + case 202: return "REDISTRIBUTED HEAT CONVERGENCE SLAB"; + case 203: return "SEAICE DEPTH(GRD BOX MN)AFTER SLAB M"; + case 204: return "ICE FRACTION INC. (DYNAMICS) SLAB"; + case 205: return "ICE DEPTH INC. (DYNAMICS) SLAB"; + case 206: return "ICE DEPTH INC. (DIFFUSION) SLAB"; + case 207: return "SNOW DEPTH INC.*AICE (DYNAMICS) SLAB"; + case 208: return "ICE FRACTION INC. (THERMO) SLAB"; + case 209: return "ICE DEPTH INC. (THERMO) SLAB"; + case 210: return "SNOW DEPTH INC.*AICE (THERMO) SLAB"; + case 211: return "OCEAN TO ICE HEAT FLUX (W.M-2) SLAB"; + case 212: return "INTERNAL ICE PRESSURE (N.M-2) SLAB"; + case 213: return "ICE STRENGTH (N.M-2) SLAB"; + case 214: return "NET SLAB FLUX THRO LDS (W.M-2) SLAB"; + case 215: return "NET ICE FLUX THRO LDS (W.M-2) SLAB"; + case 216: return "W X SLABTEMP AT SURFACE AFTER SLAB"; + case 217: return "W X SLABTEMP AT BASE AFTER SLAB"; + case 218: return "SLAB HEATING RATE (ADV) K/S SLAB"; + case 219: return "SLAB HEATING RATE (DIFF) K/S SLAB"; + case 220: return "SLAB CARYHEAT (W M-2) SLAB"; + case 221: return "SLAB HEATING RATE (ICE) K/S SLAB"; + case 222: return "SNOWFALL INTO SLAB (KG/M2/S) SLAB"; + case 223: return "SNOWFALL INTO LEADS (KG/M2/S) SLAB"; + case 224: return "ICE DEPTH INC (ADV) (M/TS) SLAB"; + case 225: return "SNOW DEPTH INC*AICE (ADV M/TS) SLAB"; + case 226: return "GRID BOX AREAS (M2) SLAB"; + } + break; + } + break; + case 4: + switch (section) { + case 0: + switch (item) { + case 1: return "WAVE ENERGY SPECTRUM (FIELDS)"; + case 2: return "LAND/SEA MASK (LOGICAL: LAND=TRUE)"; + case 3: return "WATER DEPTH"; + case 4: return "10 METRE WIND U COMPONENT"; + case 5: return "10 METRE WIND V COMPONENT"; + case 6: return "WAVE DEPENDENT USTAR U COMPONENT"; + case 7: return "WAVE DEPENDENT USTAR V COMPONENT"; + case 8: return "SEA ICE FRACTION AFTER TIMESTEP"; + case 9: return "WAVE INDUCED SURFACE STRESS X COMPT"; + case 10: return "WAVE INDUCED SURFACE STRESS Y COMPT"; + } + break; + case 1: + switch (item) { + case 1: return "ENERGY INCREMENTS AFTER PROPAGATION"; + } + break; + case 2: + switch (item) { + case 1: return "WAVE DEPENDENT ROUGHNESS LENGTH"; + case 2: return "WAVE DEPENDENT USTAR X COMPONENT"; + case 3: return "WAVE DEPENDENT USTAR Y COMPONENT"; + case 4: return "WAVE INDUCED SURFACE STRESS X COMPT"; + case 5: return "WAVE INDUCED SURFACE STRESS Y COMPT"; + case 6: return "WAVE INDUCED SURF STRESS HF CONTRIBN"; + case 7: return "ENERGY INCRTS AFTER INPUT SRCE TERM"; + } + break; + case 3: + switch (item) { + case 1: return "ENERGY INCRTS AFTER NONLIN TRANSFER"; + } + break; + case 4: + switch (item) { + case 1: return "ENERGY INCRTS AFTER DISSIPATION"; + } + break; + case 5: + switch (item) { + case 1: return "ENERGY INCRTS AFTER BOTTOM FRICTION"; + } + break; + case 6: + switch (item) { + case 1: return "TOTAL WAVE HEIGHT"; + case 2: return "TOTAL WAVE UPCROSSING PERIOD"; + case 3: return "TOTAL WAVE PRINCIPAL DIRECTION"; + case 4: return "TOTAL WAVE PEAK PERIOD"; + case 5: return "WINDSEA HEIGHT"; + case 6: return "WINDSEA UPCROSSING PERIOD"; + case 7: return "WINDSEA PRINCIPAL DIRECTION"; + case 8: return "SWELL HEIGHT"; + case 9: return "SWELL UPCROSSING PERIOD"; + case 10: return "SWELL PRINCIPAL DIRECTION"; + case 11: return "SWELL PEAK PERIOD"; + case 12: return "WAVETRAIN WAVE-HEIGHT"; + case 13: return "WAVETRAIN CROSSING PERIOD"; + case 14: return "WAVETRAIN MEAN DIRECTION"; + case 15: return "MEAN ENERGY AT A GIVEN FREQUENCY"; + case 16: return "MEAN DIRECTION AT A GIVEN FREQUENCY"; + case 17: return "10 METRE WIND SPEED"; + case 18: return "10 METRE WIND DIRECTION"; + } + break; + case 7: + switch (item) { + case 1: return "ENERGY INCRTS AFTER ASSIMILATION"; + case 2: return "ASSIMILATION INCRTS FOR WAVE HEIGHT"; + case 3: return "ASSIMILATION INCRTS FOR WINDSPEED"; + } + } + } + + return NULL; +} + + +/*------------------------------------------------------------------------------- + * PERL CODE USED TO GENERATE THE ABOVE SWITCH STATEMENT FROM STASHMASTER FILE(S) + * ============================================================================== + * + * #!/usr/bin/perl + * + * $Sm=" switch (model) {\n"; + * $Em=" }\n"; + * $sm=" case %d:\n"; + * $em=" break;\n"; + * + * $Ss=" switch (section) {\n"; + * $Es=" }\n"; + * $ss=" case %d:\n"; + * $es=" break;\n"; + * + * $Si=" switch (item) {\n"; + * $Ei=" }\n"; + * $si=" case %d: "; + * #$ei=" break;\n"; + * $ei="\n"; + * + * + * $first=1; + * $lm=$ls=-1; + * while (<>){ + * if (/^1\|\s*([0-9]+)\s*\|\s*([0-9]+)\s*\|\s*([0-9]+)\s*\|(.*)\|\s*$/) { + * ($m,$s,$i,$name)=($1,$2,$3,$4); + * + * if ($first) { + * print $Sm; + * printf $sm,$m; + * print $Ss; + * printf $ss,$s; + * print $Si; + * } else { + * + * if ($s != $ls) { + * print $Ei; + * print $es; + * } + * if ($m != $lm) { + * print $Es; + * print $em; + * printf $sm,$m; + * print $Ss; + * } + * if ($s != $ls) { + * printf $ss,$s; + * print $Si; + * } + * } + * + * $name =~ s/ +/ /g; + * $name =~ s/\s+$//; + * $name =~ s/\"/\\\"/g; + * + * printf $si,$i; + * print "return \"$name\";"; + * print $ei; + * + * $first=0; + * ($lm,$ls)=($m,$s); + * } + * } + * + * print $Ei; + * print $Es; + * print $Em; + * + */ + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_struct.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_struct.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_struct.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_struct.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,75 @@ +#ifdef HAVE_PP +#include "cdunifpp.h" + +/* allocating / freeing the file structure, an extension of CuCreateFile / CuDeleteFile */ + +CuFile *pp_create_file(const char *controlpath){ + + CuFile *file; + PPfile *ppfile; + + /* get file structure */ + file = CuCreateFile(CuPP); + if (file == (CuFile*)0) goto err1; + + /* allocate internal structure - hang it off cu_file structure */ + ppfile=pp_malloc(sizeof(PPfile),NULL); + if (ppfile==NULL) goto err2; + + file->internp = ppfile; + ppfile->fh = NULL; + strncpy(file->controlpath,controlpath,CU_MAX_PATH); + ppfile->landmask = NULL; + + /* initialise heap list */ + ppfile->heaplist = pp_list_new(NULL); + if (ppfile->heaplist == NULL) goto err3; + + return file; + + err3: + pp_free(ppfile,NULL); + err2: + CuDeleteFile(file->id); + err1: + pp_error("pp_create_file"); + return NULL; +} + +int pp_delete_file(CuFile *file){ + PPfile *ppfile = file->internp; + int iatt,ivar; + CuVar *var; + + /* Free the extra bits which cdunifpp allocated */ + pp_free_all(ppfile->heaplist); + pp_free(ppfile,NULL); + + /* Now set all the attribute value ptrs to NULL. + * + * Reason: CuDeleteAtt (called by CuDeleteFile) + * will assume that any non-NULL ptrs have to be freed. + * But we already freed them. Hence segfault. :-( + */ + if (file->atts != NULL) + for (iatt=0; iattngatts; iatt++) + file->atts[iatt].val=NULL; + + if (file->vars != NULL) + for (ivar=0; ivarnvars; ivar++) { + var=&file->vars[ivar]; + if (var->atts != NULL) + for (iatt=0; iattnatts; iatt++) + var->atts[iatt].val=NULL; + } + + /* CuDeleteFile commented out - CDMS seems to do that when calling cuclose + * and error if we do it twice. + */ + + /* CuDeleteFile(file->id); */ + + return 0; +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_unwgdoswrap.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_unwgdoswrap.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/cdunifpp_unwgdoswrap.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/cdunifpp_unwgdoswrap.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,50 @@ +/* This is a wrapper function which interfaces between CDUNIFPP and + * UNWGDOS. (It should be the only function which needs both sets + * of header files.) + */ + +#ifdef HAVE_PP +#include "cdunifpp.h" +#include "crayio.h" + +/* prototype unwgdos */ +int unwgdos(int *, int, REAL *, int, REAL); + +int pp_unwgdos_wrap(const void *packed_data, int nint, + void *data, long datalen, + Freal mdi, PPlist *heaplist) +{ + int ipt; + void *tmp; + + /* unwgdos routine as coded writes output which is native size of + * fortran REAL. + * + * Don't want to muck around with unwgdos code, so in the event that + * this cdunifpp has been compiled using Freal which is not the same + * type as REAL, allocate another temporary array and copy across. + */ + + /* NB for output size use datalen, which does not include disk padding. + * It is tested inside unwgdos that (nx * ny = output size), so it is + * important to specify the exactly correct size. + */ + + if (wordsize == sizeof(REAL)) { + if( unwgdos(packed_data, nint, data, datalen, mdi) !=0) goto err; + } else { + if(( tmp=pp_malloc(datalen * sizeof(REAL), heaplist) )==NULL) goto err; + if( unwgdos(packed_data, nint, tmp, datalen, mdi) !=0) goto err; + for (ipt=0; iptshortname[0]='\0'; + sm->longname[0]='\0'; + sm->units[0]='\0'; + sm->stdname[0]='\0'; + sm->source[0]='\0'; + + /* use compiled-in defaults */ + + if (hdr->LBUSER7 == 1 && hdr->LBUSER4 == 1) + /* insist that surface pressure is called "ps", as referred to in + * "formula_terms" attribute for hybrid coordinates + */ + strncpy(sm->shortname,"ps",SM_MAX_LEN); + else + pp_get_var_default_shortname(hdr, sm->shortname, SM_MAX_LEN); + + pp_get_var_default_longname(hdr, sm->longname, SM_MAX_LEN); + pp_get_var_default_units(hdr, sm->units, SM_MAX_LEN); + + strncpy(sm->source,"defaults (cdunifpp V" CDUNIFPP_VERSION ")",SM_MAX_LEN); + sm->source[SM_MAX_LEN] = '\0'; + + return 0; +} + +/*-----------------------------------------------------------------*/ + +/* the functions pp_get_var_default_* are just wrappers to the relevant + * routines which look up the compiled-in defaults; the wrappers copy + * the compiled-in string into the provided storage + */ + +int pp_get_var_default_shortname(const PPhdr *hdr, char *name, int name_max){ + + char *lookupname; + + lookupname = pp_ppshortname(hdr->LBFC); + + if (lookupname != NULL) + snprintf(name,name_max,"%s",lookupname); + else + snprintf(name,name_max,"m%ds%di%d", + pp_get_var_stash_model(hdr), + pp_get_var_stash_section(hdr), + pp_get_var_stash_item(hdr)); + + name[name_max]='\0'; + return 0; +} + +int pp_get_var_default_longname(const PPhdr *hdr, char *name, int name_max) +{ + char *stashname; + stashname = pp_stashname(pp_get_var_stash_model(hdr), + pp_get_var_stash_section(hdr), + pp_get_var_stash_item(hdr)); + + if (stashname==NULL) return -1; + + strncpy(name,stashname,name_max); + name[name_max]='\0'; + + return 0; +} + + +int pp_get_var_default_units(const PPhdr *hdr, char *units, int units_max) +{ + char *ppunit; + + ppunit = pp_ppunit(hdr->LBFC); + if (ppunit==NULL) return -1; + + strncpy(units,ppunit,units_max); + units[units_max]='\0'; + + return 0; +} + +/*-----------------------------------------------------------------*/ + +int pp_get_var_stash_model(const PPhdr *hdr) +{ + return hdr->LBUSER7; +} + +int pp_get_var_stash_section(const PPhdr *hdr) +{ + return hdr->LBUSER4 / 1000; +} + +int pp_get_var_stash_item(const PPhdr *hdr) +{ + return hdr->LBUSER4 % 1000; +} + +int pp_get_var_packing(const PPhdr *hdr) +{ + return hdr->LBPACK % 10; +} + +int pp_get_var_compression(const PPhdr *hdr) +{ + return (hdr->LBPACK / 10) % 10; +} + +int pp_get_var_processing(const PPhdr *hdr) +{ + return hdr->LBPROC; +} + +int pp_get_var_gridcode(const PPhdr *hdr) +{ + return hdr->LBCODE; +} + +/*-----------------------------------------------------------------*/ + +int pp_get_var_name(int varid, const char *prefix, CuVar *cuvars) { + + int okay, var, ext; + + char *name; + + name = cuvars[varid].name; + + okay=0; + + /* keep writing new name based on basename with a possible extension number, + * until condition "okay", which is that name does not already exist + */ + for (ext=0; !okay; ext++) { + + if (ext==0) + strncpy(name,prefix,CU_MAX_NAME); + else + snprintf(name,CU_MAX_NAME,"%s_%d",prefix,ext); + name[CU_MAX_NAME]='\0'; + + okay=1; + for (var=0; varvarid) goto err; + } + return 0; + + err: + pp_error("cdunifpp_varname"); + return -1; +} + + +/* pp_get_fill_value returns fill value + * (as pointer to static memory -- before dereferencing, needs to be cast to + * Fint* or Freal* as appropriate) + */ +void *pp_get_var_fill_value(const PPhdr *hdr) +{ + /* vars used by pp_get_fill_value */ + static Fint intfill; + static Freal realfill; + + CuType vartype; + + vartype=pp_get_var_type(hdr); + + if (vartype==inttype) { + intfill = int_fill_value; + return &intfill; + } + else if (vartype==realtype) { + realfill = hdr->BMDI; + return &realfill; + } + else { + pp_switch_bug(); + return NULL; + } +} + +int pp_var_is_land_mask(const PPhdr *hdr) +{ + int model,section,item; + model=pp_get_var_stash_model(hdr); + section=pp_get_var_stash_section(hdr); + item=pp_get_var_stash_item(hdr); + return ((model==1 && section==0 && item==30) || + (model==4 && section==0 && item==2)); +} + +CuType pp_get_var_type(const PPhdr *hdr){ + + switch (hdr->LBUSER1) { + case(2): + case(-2): + case(3): + case(-3): + return inttype; + /* break; */ + case(1): + case(-1): + return realtype; + /* break; */ + default: + CuError(CU_EINTERN,"Warning: datatype %d not recognised in pp_get_var_type, assuming real", + hdr->LBUSER1); + return realtype; + } + + return 0; +} + +int pp_var_is_time_mean(const PPhdr *hdr) +{ + return (hdr->LBPROC & 128); +} + +int pp_var_is_time_min(const PPhdr *hdr) +{ + return (hdr->LBPROC & 4096); +} + +int pp_var_is_time_max(const PPhdr *hdr) +{ + return (hdr->LBPROC & 8192); +} + +int pp_var_is_zonal_mean(const PPhdr *hdr) +{ + return (hdr->LBPROC & 64); +} + +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/Makefile cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/Makefile --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/Makefile 2004-11-05 18:34:37.000000000 +0000 @@ -0,0 +1,61 @@ +# Generated automatically from Makefile.in by configure. +# makefile for cdunifpp + +OBJS = \ + cdunifpp.o \ + cdunifpp_attribute.o \ + cdunifpp_axisvals.o \ + cdunifpp_check.o \ + cdunifpp_compare.o \ + cdunifpp_data.o \ + cdunifpp_debug.o \ + cdunifpp_error.o \ + cdunifpp_filetype.o \ + cdunifpp_linklist.o \ + cdunifpp_malloc.o \ + cdunifpp_ppcode.o \ + cdunifpp_process.o \ + cdunifpp_read.o \ + cdunifpp_stash2pp.o \ + cdunifpp_stashname.o \ + cdunifpp_struct.o \ + cdunifpp_unwgdoswrap.o \ + cdunifpp_varinfo.o \ + unwgdos.o \ + unwgdos_crayio.o + +HEADERS=../../../include/cdunifint.h ../../../include/cdunifpp/cdunifpp.h + +UNWGDOS_HDRS=../../../include/cdunifpp/crayio.h \ + ../../../include/cdunifpp/util.h \ + ../../../include/cdunifpp/vardef.h \ + ../../../include/cdunifpp/cdunifpp_frename.h + +EXTRAHDR=-include ../../../include/cdunifpp/cdunifpp_frename.h +# set to blank if you don't want to rename symbols in unpacking routines + +CC = cc +CFLAGS = -I../../../include/cdunifpp -I/tmp/cdat/DODS/include -I../../../include $(DEBUG) +CPPFLAGS = -Dnetcdf -DBYTESWAP -DpgiFortran -DHAVE_PP +LIBRARY = ../../../lib/libcdms.a + +all: $(OBJS) + ar rv $(LIBRARY) $(OBJS) +# (ranlib called by higher-level makefile) + +clean: + -rm -f *.o + +distclean: clean + +%.o: %.c $(HEADERS) + +cdunifpp_unwgdoswrap.o: cdunifpp_unwgdoswrap.c $(HEADERS) $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRAHDR) -c $< + +unwgdos.o: unwgdos.c $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(EXTRAHDR) -c $< + +unwgdos_crayio.o: unwgdos_crayio.c $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(EXTRAHDR) -c $< + diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/Makefile.in cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/Makefile.in --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/Makefile.in 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/Makefile.in 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,60 @@ +# makefile for cdunifpp + +OBJS = \ + cdunifpp.o \ + cdunifpp_attribute.o \ + cdunifpp_axisvals.o \ + cdunifpp_check.o \ + cdunifpp_compare.o \ + cdunifpp_data.o \ + cdunifpp_debug.o \ + cdunifpp_error.o \ + cdunifpp_filetype.o \ + cdunifpp_linklist.o \ + cdunifpp_malloc.o \ + cdunifpp_ppcode.o \ + cdunifpp_process.o \ + cdunifpp_read.o \ + cdunifpp_stash2pp.o \ + cdunifpp_stashname.o \ + cdunifpp_struct.o \ + cdunifpp_unwgdoswrap.o \ + cdunifpp_varinfo.o \ + unwgdos.o \ + unwgdos_crayio.o + +HEADERS=../../../include/cdunifint.h ../../../include/cdunifpp/cdunifpp.h + +UNWGDOS_HDRS=../../../include/cdunifpp/crayio.h \ + ../../../include/cdunifpp/util.h \ + ../../../include/cdunifpp/vardef.h \ + ../../../include/cdunifpp/cdunifpp_frename.h + +EXTRAHDR=-include ../../../include/cdunifpp/cdunifpp_frename.h +# set to blank if you don't want to rename symbols in unpacking routines + +CC = @CC@ +CFLAGS = -I../../../include/cdunifpp @CFLAGS@ -I../../../include $(DEBUG) +CPPFLAGS = @CPPFLAGS@ @PPOPTS@ +LIBRARY = ../../../lib/libcdms.a + +all: $(OBJS) + ar rv $(LIBRARY) $(OBJS) +# (ranlib called by higher-level makefile) + +clean: + -rm -f *.o + +distclean: clean + +%.o: %.c $(HEADERS) + +cdunifpp_unwgdoswrap.o: cdunifpp_unwgdoswrap.c $(HEADERS) $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRAHDR) -c $< + +unwgdos.o: unwgdos.c $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(EXTRAHDR) -c $< + +unwgdos_crayio.o: unwgdos_crayio.c $(UNWGDOS_HDRS) + $(CC) $(CFLAGS) $(EXTRAHDR) -c $< + diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/unwgdos.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/unwgdos.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/unwgdos.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/unwgdos.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,570 @@ + +/* unwgdos.c is unpack.c file from xconv but with GRIB stuff stripped out */ + +#include +#include +#include +#include +#include +#include "util.h" +#include "vardef.h" + +#define TRUE 1 +#define FALSE 0 + +int read_wgdos_header(int *, int, int *, int *, int *, int *); +int unwgdos(int *, int, REAL *, int, REAL); +#ifndef _CRAY +int xpnd(int, int32 *, REAL *, REAL, int, REAL, int, REAL); +int extrin(int32 *, int, int, int, int *, int); +#endif +int bit_test(void *, int); +void move_bits(void *, int, int, void *); + +int read_wgdos_header(int *header, int ndata, + int *len, int *isc, int *ix, int *iy) +{ + int nx, ny, n; + int head[2], swap; + + /* Determine if data needs byte swapping */ + + swap = -1; + +#if _INT_SIZE == 8 + n = 2; + head[0] = header[1]; +#else + n = 4; + head[0] = header[2]; +#endif +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &nx, 1, 0); + ibmi2_to_c8(head, &ny, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &nx, 1, 0); + ibmi2_to_i8(head, &ny, 1, 1); +#else + ibmi2_to_i4(head, &nx, 1, 0); + ibmi2_to_i4(head, &ny, 1, 1); +#endif + if (nx*ny == ndata) swap = 0; + + if (swap == -1) + { + /* see if data is byte swapped with 4 byte words */ + +#if _INT_SIZE == 8 + head[0] = header[1]; +#else + head[0] = header[2]; +#endif + swap_bytes(head,4,1); +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &nx, 1, 0); + ibmi2_to_c8(head, &ny, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &nx, 1, 0); + ibmi2_to_i8(head, &ny, 1, 1); +#else + ibmi2_to_i4(head, &nx, 1, 0); + ibmi2_to_i4(head, &ny, 1, 1); +#endif + if (nx*ny == ndata) swap = 4; + } + + if (swap == -1) + { + /* see if data is byte swapped with 8 byte words */ + +#if _INT_SIZE == 8 + head[0] = header[1]; +#else + head[0] = header[2]; + head[1] = header[3]; +#endif + swap_bytes(head,8,1); +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &nx, 1, 0); + ibmi2_to_c8(head, &ny, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &nx, 1, 0); + ibmi2_to_i8(head, &ny, 1, 1); +#else + ibmi2_to_i4(head, &nx, 1, 0); + ibmi2_to_i4(head, &ny, 1, 1); +#endif + if (nx*ny == ndata) swap = 8; + } + + if (swap == -1) + { + printf("WGDOS data header record mismatch \n"); + return 1; + } + else if (swap > 0) + swap_bytes(header,swap,n*sizeof(*header)/swap); + +#if _INT_TYPE == _CRAY8 + ibmi4_to_c8(header, len, 1, 0); + ibmi4_to_c8(header, isc, 1, 1); + ibmi2_to_c8(header+1, ix, 1, 0); + ibmi2_to_c8(header+1, iy, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi4_to_i8(header, len, 1, 0); + ibmi4_to_i8(header, isc, 1, 1); + ibmi2_to_i8(header+1, ix, 1, 0); + ibmi2_to_i8(header+1, iy, 1, 1); +#else + ibmi4_to_i4(header, len, 1); + ibmi4_to_i4(header+1, isc, 1); + ibmi2_to_i4(header+2, ix, 1, 0); + ibmi2_to_i4(header+2, iy, 1, 1); +#endif + + *len = 4*(*len); /* Convert to bytes */ + + return 0; +} + +int unwgdos(int *datain, int nin, REAL *dataout, int nout, REAL mdi) +{ + int len, isc, ix, iy; + REAL prec, base; + int icx, j; + int ibit, nop; + int head[2], swap; +#ifdef _CRAY + int idum1, idum2, idum3, idum4, idum5, false; +#else + int32 *datain32; +#endif + + /* Determine if data needs byte swapping */ + + swap = -1; + +#if _INT_SIZE == 8 + head[0] = datain[1]; +#else + head[0] = datain[2]; +#endif +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &ix, 1, 0); + ibmi2_to_c8(head, &iy, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &ix, 1, 0); + ibmi2_to_i8(head, &iy, 1, 1); +#else + ibmi2_to_i4(head, &ix, 1, 0); + ibmi2_to_i4(head, &iy, 1, 1); +#endif + if (ix*iy == nout) swap = 0; + + if (swap == -1) + { + /* see if data is byte swapped with 4 byte words */ + +#if _INT_SIZE == 8 + head[0] = datain[1]; +#else + head[0] = datain[2]; +#endif + swap_bytes(head,4,1); +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &ix, 1, 0); + ibmi2_to_c8(head, &iy, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &ix, 1, 0); + ibmi2_to_i8(head, &iy, 1, 1); +#else + ibmi2_to_i4(head, &ix, 1, 0); + ibmi2_to_i4(head, &iy, 1, 1); +#endif + if (ix*iy == nout) swap = 4; + } + + if (swap == -1) + { + /* see if data is byte swapped with 8 byte words */ + +#if _INT_SIZE == 8 + head[0] = datain[1]; +#else + head[0] = datain[2]; + head[1] = datain[3]; +#endif + swap_bytes(head,8,1); +#if _INT_TYPE == _CRAY8 + ibmi2_to_c8(head, &ix, 1, 0); + ibmi2_to_c8(head, &iy, 1, 1); +#elif _INT_TYPE == _IEEE8 + ibmi2_to_i8(head, &ix, 1, 0); + ibmi2_to_i8(head, &iy, 1, 1); +#else + ibmi2_to_i4(head, &ix, 1, 0); + ibmi2_to_i4(head, &iy, 1, 1); +#endif + if (ix*iy == nout) swap = 8; + } + + if (swap == -1) + { + printf("WGDOS data header record mismatch \n"); + return 1; + } + else if (swap > 0) + swap_bytes(datain,swap,nin*sizeof(*datain)/swap); + +#ifdef _CRAY + false = _btol(0); + COEX(dataout, &nout, datain, &nin, + &idum1, &idum2, &idum3, &idum4, &false, &mdi, &idum5); +#else + /* Below only works for 32 bit integers, therefore there must be a + 32 bit integer type */ + + datain32 = (int32 *) datain; + + /* Extract scale factor and number of columns and rows from header */ + + ibmi4_to_i4(datain32, &len, 1); + ibmi4_to_i4(datain32+1, &isc, 1); + ibmi2_to_i4(datain32+2, &ix, 1, 0); + ibmi2_to_i4(datain32+2, &iy, 1, 1); + + /* Expand compressed data */ + + prec = pow(2.0, (double) isc); + icx = 3; + + for (j=0; j= 128) + { + btzer = TRUE; + btmap = TRUE; + ibit -= 128; + } + + /* check if bitmap used for minimum values */ + + if (ibit >= 64) + { + btmin = TRUE; + btmap = TRUE; + ibit -= 64; + } + + /* check if bitmap used for missing data values */ + + if (ibit >= 32) + { + btmis = TRUE; + btmap = TRUE; + ibit -= 32; + } + + if (ibit > 32) + { + printf("Number of bits used to pack wgdos data = %d must be <= 32 \n", + ibit); + return 1; + } + + if (btmap) + { + if ( (imap = malloc (ix*sizeof(int))) == NULL ) + { + printf("Error unable to allocate memory for imap in xpnd ix = %d \n", + ix); + return 1; + } + + for (j=0; j 0) + jbit--; + else + { + jbit = 31; + jword++; + } + } + } + + /* Extract minimum value bitmap */ + + if (btmin) + { + if ( (imin = malloc (ix*sizeof(int))) == NULL ) + { + printf("Error unable to allocate memory for imin in xpnd ix = %d \n", + ix); + return 1; + } + + for (j=0; j 0) + jbit--; + else + { + jbit = 31; + jword++; + } + } + } + + /* Extract zero value bitmap */ + + if (btzer) + { + if ( (izer = malloc (ix*sizeof(int))) == NULL ) + { + printf("Error unable to allocate memory for izer in xpnd ix = %d \n", + ix); + return 1; + } + + for (j=0; j 0) + jbit--; + else + { + jbit = 31; + jword++; + } + } + } + + /* If bitmap used reset pointers to beginning of 32 bit boundary */ + + if (btmap && jbit != 31) + { + jbit = 31; + jword++; + } + + if (ibit > 0) + { + /* Unpack scaled values */ + + for (j=0; j> ibit) & ~(~0 << 1); + + if (i == 1) + return TRUE; + else + return FALSE; +} + +/* + * Move nbits from 32 bit word1 starting at start1 into 32 bit word2. + * 0 =< nbits <= 32, bits can cross into word1+1. + */ + +void move_bits(void *word1, int start1, int nbits, void *word2) +{ + uint32 *ui1, *ui2, temp1, temp2; + + ui1 = (uint32 *) word1; + ui2 = (uint32 *) word2; + + if (start1+1-nbits >= 0) + { + /* move bits within one word */ + + ui2[0] = (ui1[0] >> (start1+1-nbits)) & ~(~0 << nbits); + } + else + { + /* move bits within two words */ + + temp1 = (ui1[0] << (nbits-start1-1)) & ~(~0 << nbits); + temp2 = (ui1[1] >> (32+start1+1-nbits)) & ~(~0 << (nbits-start1-1)); + ui2[0] = temp1 | temp2; + } +} +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifpp/unwgdos_crayio.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/unwgdos_crayio.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifpp/unwgdos_crayio.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifpp/unwgdos_crayio.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,2112 @@ +#include +#include +#include +#include +#include +#include +#include "crayio.h" + +/* Routines callable from C */ + +COSFILE *cos_open (char *fname, char *mode) +{ + COSFILE *file; + FILE *fp; + + /* Allocate memory for COSFILE structure */ + + if ((file = (COSFILE *) malloc(sizeof(COSFILE))) == NULL) + { + printf("Error unable to allocate memory in cos_open \n"); + return NULL; + } + + /* Open file */ + + if ((fp = fopen(fname, mode)) == NULL) + { + printf("Error opening file %s in cos_open \n", fname); + return NULL; + } + + /* Initialise COSFILE structure */ + + file->fname = fname; + file->fp = fp; + file->fwi = 0; + file->pri = 0; + + return file; +} + +int cos_close (COSFILE *file) +{ + int iret; + + /* Close file */ + + iret = fclose(file->fp); + + if (iret != 0) + printf("Error closing file %s in cos_close \n", file->fname); + + /* Free memory for COSFILE structure */ + + free(file); + + return iret; +} + +int cos_rewind (COSFILE *file) +{ + int iret; + + /* Rewind file */ + + iret = fseek(file->fp, 0L, SEEK_SET); + + if (iret != 0) + printf("Error rewinding file %s in cos_rewind \n", file->fname); + + /* Reset forward index and previous record index */ + + file->fwi = 0; + file->pri = 0; + + return iret; +} + +int cos_backspace (COSFILE *file) +{ + long inum, blknum; + unsigned long m, pri, fwi, curpos, pos; + unsigned char cw[CRAYWORD]; + + curpos = ftell(file->fp); + blknum = curpos/BLOCKSIZE; + pri = file->pri; + pos = (blknum-pri)*BLOCKSIZE; + + /* Seek to start of block containing start of record */ + + if (fseek(file->fp, pos, SEEK_SET) != 0) + { + printf("Error backspacing file %s in cos_backspace \n", file->fname); + return 1; + } + + inum = fread(cw, 1, CRAYWORD, file->fp); + m = cw[0] >> 4; + if (m != 0) + { + printf("Error backspacing file %s in cos_backspace \n", file->fname); + return 2; + } + fwi = ((unsigned long) (cw[CRAYWORD-2] & 1) << 8) | cw[CRAYWORD-1]; + pos += CRAYWORD*(fwi+1); + m = 1; + if (pri == 0) + { + if (pos+CRAYWORD == curpos) m = 0; + } + else + { + if (pos == (blknum-pri+1)*BLOCKSIZE) m = 0; + } + + while ( m != 0 ) + { + /* Seek to next record until start of current record or start of next + block is found */ + + if (fseek(file->fp, pos, SEEK_SET) != 0) + { + printf("Error backspacing file %s in cos_backspace \n", file->fname); + return 3; + } + + inum = fread(cw, 1, CRAYWORD, file->fp); + m = cw[0] >> 4; + if (m == 0) + { + printf("Error backspacing file %s in cos_backspace \n", file->fname); + return 4; + } + fwi = ((unsigned long) (cw[CRAYWORD-2] & 1) << 8) | cw[CRAYWORD-1]; + pos += CRAYWORD*(fwi+1); + + if (pri == 0) + { + if (pos+CRAYWORD == curpos) break; + } + else + { + if (pos == (blknum-pri+1)*BLOCKSIZE) break; + } + } + + /* Reset forward index and previous record index */ + + file->fwi = fwi; + file->pri = (cw[CRAYWORD-3] << 7) | (cw[CRAYWORD-2] >> 1); + + return 0; +} + +int cos_read (COSFILE *file, void *data, int datasize, int *readsize) +{ + int iret, inum, full; + long datalen, dataoffset, ilen; + unsigned long m, fwi; + unsigned char cw[CRAYWORD]; + char *cdata; + + cdata = (char *) data; + + iret = 0; + fwi = file->fwi; + ilen = 0; + m = 0; + if (datasize == 0) + full = 1; + else + full = 0; + dataoffset = 0; + + while ( m != CEOR && m != CEOF && m != CEOD ) + { + ilen += CRAYWORD*fwi; + + if (ilen > datasize) + { + if (full == 0) + { + datalen=CRAYWORD*fwi - ilen + datasize; + full = 1; + } + else + datalen = 0; + } + else + datalen=CRAYWORD*fwi; + + if (datalen > 0) + { + inum = fread(cdata+dataoffset, 1, datalen, file->fp); + dataoffset += datalen; + if (full == 1) + inum = fseek(file->fp, ilen - datasize, SEEK_CUR); + } + else + inum = fseek(file->fp, CRAYWORD*fwi, SEEK_CUR); + + inum = fread(cw, 1, CRAYWORD, file->fp); + + m = cw[0] >> 4; + fwi = ((unsigned long) (cw[CRAYWORD-2] & 1) << 8) | cw[CRAYWORD-1]; + } + + if ( m == CEOF || m == CEOD ) + iret = -1; + else if ( full == 1 ) + iret = -3; + + file->fwi = fwi; + file->pri = (cw[CRAYWORD-3] << 7) | (cw[CRAYWORD-2] >> 1); + *readsize = dataoffset; + + return iret; +} + +/* + * buf is an array of n objects of size nbytes bytes. + * reverse order of bytes in buf. buf will be changed by function. + */ + +void swap_bytes(void *buf, int nbytes, int n) +{ + int i, j; + unsigned char temp, *cbuf; + + cbuf = (unsigned char *) buf; + + for (i=0; i> j; + if ((*mp & mask) == mask) + break; + shift += 1; + } + + for (j = 0; j < nchar-1; j++) + *(p+j+2) = (mp[j] << shift) | (mp[j+1] >> (8-shift)); + + *(p+nchar+1) = mp[nchar-1] << shift; + + for (j = nchar; j < 6; j++) + *(p+j+2) = '\0'; + + cexp -= (6-nchar)*8 + shift; + } + + if (cexp <= MAXEXP32 && cexp >= MINEXP32) /* Normal numbers */ + { + /* IEEE mantissa */ + iman = ((unsigned long) (*(p+2) & ~CSIGNMASK) << 16) | + ((unsigned long) *(p+3) << 8) | *(p+4); + + if ((*(p+5) & CSIGNMASK) == CSIGNMASK) + { + /* Round up mantissa */ + if (((~iman) & 0x7fffff) == 0) + { + iman = 0; + cexp += 1; + } + else + iman += 1; + } + } + else if (cexp < MINEXP32 && cexp >= MINSEXP32) /* Subnormal numbers */ + { + k = MINEXP32 - cexp - 1; + iman = ((unsigned long) *(p+2) << 16) | + ((unsigned long) *(p+3) << 8) | *(p+4); + mask = (unsigned long) 1 << k; + round = iman & mask; + iman = iman >> (k+1); + if (round == mask) iman += 1; + } + + /* Pack input into 32 bit IEEE float representation */ + + if (cexp <= MAXEXP32 && cexp >= MINSEXP32) + { + if (cexp >= MINEXP32) + iexp = cexp - CBIAS + I32BIAS - 1; /* IEEE unbiased exponent */ + else + iexp = 0; /* IEEE unbiased exponent for subnormal numbers*/ + + uiout[joff] = sign32 | (iexp << 23) | iman; + } + + /* If invalid Cray floats, set to NaN */ + + else if (cexp < MINCEXP || cexp > MAXCEXP) + { + uiout[joff] = I32_NAN; + err=1; + } + + /* Small Cray numbers, set to +/- 0 */ + + else if (cexp < MINSEXP32) + { + uiout[joff] = sign32; + } + + /* Large Cray numbers, set to +/- INF */ + + else if (cexp > MAXEXP32) + { + uiout[joff] = sign32 | I32_INFP; + err=1; + } + } + + return err; +#else + int err, type, bitoff, stride, natlen, forlen; + void *forn, *nat; + +#ifdef _CRAYIEEE + forn = in; + nat = out; + natlen = 32; + forlen = 64; +#else + forn = out; + nat = in; + natlen = 64; + forlen = 32; +#endif + type = 3; + bitoff = 0; + stride = 1; + + err = CRY2CRI(&type, &n, forn, &bitoff, nat, &stride, &natlen, &forlen); + + return err; +#endif +} + +/* + * Translate Cray 64-bit integers to IEEE 32-bit integers + * + * in: array of Cray 64-bit integers + * out: array of result IEEE 32-bit integers + * n: length of in, out + * + * return: 0 if no errors, 1 if an error occurred + * + */ + +int c8_to_i4(void *in, void *out, int n) +{ +#ifndef _CRAY + unsigned char *pin, sign; + int32 *pout; + int err, i; + + pin = (unsigned char *) in; + pout = (int32 *) out; + + err=0; + + for (i=0; i> j; + if ((*mp & mask) == mask) + break; + shift += 1; + } + + for (j = 0; j < nchar-1; j++) + *(p+j+2) = (mp[j] << shift) | (mp[j+1] >> (8-shift)); + + *(p+nchar+1) = mp[nchar-1] << shift; + + for (j = nchar; j < 6; j++) + *(p+j+2) = '\0'; + + cexp -= (6-nchar)*8 + shift; + } + + if (cexp <= MAXEXP64 && cexp >= MINEXP64) /* Normal numbers */ + { + /* IEEE mantissa */ + iman = ((uint64) (*(p+2) & ~CSIGNMASK) << 45) | ((uint64) *(p+3) << 37) | + ((uint64) *(p+4) << 29) | ((uint64) *(p+5) << 21) | + ((uint64) *(p+6) << 13) | ((uint64) *(p+7) << 5); + } + else if (cexp < MINEXP64 && cexp >= MINSEXP64) /* Subnormal numbers */ + { + k = MINEXP64 - cexp - 1; + iman = ((uint64) *(p+2) << 45) | ((uint64) *(p+3) << 37) | + ((uint64) *(p+4) << 29) | ((uint64) *(p+5) << 21) | + ((uint64) *(p+6) << 13) | ((uint64) *(p+7) << 5); + mask64 = (uint64) 1 << k; + round = iman & mask64; + iman = iman >> (k+1); + if (round == mask64) iman += 1; + } + + /* Pack input into 64 bit IEEE float representation */ + + if (cexp <= MAXEXP64 && cexp >= MINSEXP64) + { + if (cexp >= MINEXP64) + iexp = cexp - CBIAS + I64BIAS - 1; /* IEEE unbiased exponent */ + else + iexp = 0; /* IEEE unbiased exponent for subnormal numbers */ + + uiout[joff] = sign64 | ((uint64) iexp << 52) | iman; + } + + /* If invalid Cray floats, set to NaN */ + + else if (cexp < MINCEXP || cexp > MAXCEXP) + { + uiout[joff] = I64_NAN; + err=1; + } + + /* Small Cray numbers, set to +/- 0 */ + + else if (cexp < MINSEXP64) + { + uiout[joff] = sign64; + } + + /* Large Cray numbers, set to +/- INF */ + + else if (cexp > MAXEXP64) + { + uiout[joff] = sign64 | I64_INFP; + err=1; + } + } + + return err; +#else + int err, type, bitoff, stride, natlen, forlen; + void *forn, *nat; + +#ifdef _CRAYIEEE + forn = in; + nat = out; +#else + forn = out; + nat = in; +#endif + type = 3; + bitoff = 0; + stride = 1; + natlen = 64; + forlen = 64; + + err = CRY2CRI(&type, &n, forn, &bitoff, nat, &stride, &natlen, &forlen); + + return err; +#endif +} + +/* + * Translate Cray 64-bit integers to IEEE 64-bit integers + * + * in: array of Cray 64-bit integers + * out: array of result IEEE 64-bit integers + * n: length of in, out + * + * return: 0 if no errors, 1 if an error occurred + * + */ + +int c8_to_i8(void *in, void *out, int n) +{ + int64 *pin, *pout; + int err; + + pin = (int64 *) in; + pout = (int64 *) out; + + err=0; + + memcpy(pout, pin, 8*n); + +#ifdef LITTLE__ENDIAN + swap_bytes(pout, 8, n); +#endif + + return err; +} + +/* + * Translate Cray 64-bit logicals to IEEE 64-bit logicals + * + * in: array of Cray 64-bit logicals + * out: array of result IEEE 64-bit logicals + * n: length of in, out + * + * return: 0 if no errors, 1 if an error occurred + * + */ + +int c8_to_l8(void *in, void *out, int n) +{ + int64 *pin, *pout; + int err, i; + + pin = (int64 *) in; + pout = (int64 *) out; + + err=0; + + for (i=0; i (double) FLT_MAX) + *i32 = (int32) I32_INFP; + else if (*r64 < - (double) FLT_MAX) + *i32 = (int32) I32_INFN; + else + *r32 = (float32) *r64; + + r32++; + i32++; + r64++; + } + + return 0; +#else + int err, type, bitoff, stride, intlen, extlen; + + type = 3; + bitoff = 0; + stride = 1; + intlen = 64; + extlen = 32; + + err = CRI2IEG(&type, &n, out, &bitoff, in, &stride, &intlen, &extlen); + + return err; +#endif +} + +/* + * Translate IEEE 64-bit integers to IEEE 32-bit integers + * + * in: array of IEEE 64-bit integers + * out: array of result IEEE 32-bit integers + * n: length of in, out + * + * return: 0 if no errors, 1 if an error occurred + * + */ + +int i8_to_i4(void *in, void *out, int n) +{ +#ifndef _CRAY + int i; + int32 *i32; + int64 *i64; + + i64 = (int64 *) in; + i32 = (int32 *) out; + + for (i=0; i (double) FLT_MAX || errno == ERANGE) + { + i32 = (sign ? (int32) I32_INFN : (int32) I32_INFP); + *pout = *(float32 *) &i32; + err=1; + } + else if (d < (double) FLT_MIN) + { + i32 = (sign ? (int32) I32_ZERON : (int32) I32_ZEROP); + *pout = *(float32 *) &i32; + } + else + *pout = (sign ? -d : d); + + pout++; + pin += 4; + } + + return err; +#else + int err, type, bitoff, stride, intlen, extlen; + + type = 3; + bitoff = 0; + stride = 1; + intlen = 32; + extlen = 32; + + err = IBM2CRI(&type, &n, in, &bitoff, out, &stride, &intlen, &extlen); + + return err; +#endif +} + +/* + * Translate IBM 32-bit reals to IEEE 64-bit reals + * + */ + +int ibmr4_to_r8(void *in, void *out, int n, int offset) +{ +#ifndef _CRAY + unsigned char *pin; + float64 *pout; + unsigned long man; + int err, i, exp, sign; + double d; + uint64 i64; + + pin = (unsigned char *) in; + pout = (float64 *) out; + + for (i=0; i<4*offset; i++) pin++; + + err=0; + + for (i=0; i (double) DBL_MAX || errno == ERANGE) + { + i64 = (sign ? (int64) I64_INFN : (int64) I64_INFP); + *pout = *(float64 *) &i64; + err=1; + } + else + *pout = (sign ? -d : d); + + pout++; + pin += 4; + } + + return err; +#else + int err, type, bitoff, stride, intlen, extlen; + + type = 3; + bitoff = offset*32; + stride = 1; + intlen = 64; + extlen = 32; + + err = IBM2CRI(&type, &n, in, &bitoff, out, &stride, &intlen, &extlen); + + return err; +#endif +} + +/* + * Translate IBM 64-bit reals to IEEE 64-bit reals + * + */ + +int ibmr8_to_r8(void *in, void *out, int n) +{ +#ifndef _CRAY + unsigned char *pin; + float64 *pout; + unsigned long man; + int err, i, exp, sign; + double d; + uint64 i64; + + pin = (unsigned char *) in; + pout = (float64 *) out; + + err=0; + + for (i=0; i (double) DBL_MAX || errno == ERANGE) + { + i64 = (sign ? (int64) I64_INFN : (int64) I64_INFP); + *pout = *(float *) &i64; + err=1; + } + else + *pout = (sign ? -d : d); + + pout++; + pin += 8; + } + + return err; +#else + int err, type, bitoff, stride, intlen, extlen; + + type = 3; + bitoff = 0; + stride = 1; + intlen = 64; + extlen = 64; + + err = IBM2CRI(&type, &n, in, &bitoff, out, &stride, &intlen, &extlen); + + return err; +#endif +} + +#ifdef _CRAYPVP +/* + * Translate IBM 32-bit integers to CRAY 64-bit integers + * + */ + +int ibmi4_to_c8(void *in, void *out, int n, int offset) +{ + int err, type, bitoff; + + type = 1; + bitoff = offset*32; + + err = IBM2CRAY(&type, &n, in, &bitoff, out); + + return err; +} + +/* + * Translate IBM 16-bit integers to CRAY 64-bit integers + * + */ + +int ibmi2_to_c8(void *in, void *out, int n, int offset) +{ + int err, type, bitoff; + + type = 7; + bitoff = offset*16; + + err = IBM2CRAY(&type, &n, in, &bitoff, out); + + return err; +} + +/* + * Translate IBM 32-bit reals to CRAY 64-bit reals + * + */ + +int ibmr4_to_c8(void *in, void *out, int n, int offset) +{ + int err, type, bitoff; + + type = 2; + bitoff = offset*32; + + err = IBM2CRAY(&type, &n, in, &bitoff, out); + + return err; +} + +/* + * Translate IBM 64-bit reals to CRAY 64-bit reals + * + */ + +int ibmr8_to_c8(void *in, void *out, int n) +{ + int err, type, bitoff; + + type = 3; + bitoff = 0; + + err = IBM2CRAY(&type, &n, in, &bitoff, out); + + return err; +} +#endif + +/* Routines callable from Fortran */ + +void cosopen (COSFILE **file, fpchar fname, fpchar mode, INTEGER *iret, + long flen, long mlen) +{ + char *p, *cfname, *cmode; + +#ifdef _CRAY + flen = _fcdlen(fname); + cfname = (char *) malloc(flen+1); + strncpy(cfname, _fcdtocp(fname), flen); + cfname[flen] = '\0'; + mlen = _fcdlen(mode); + cmode = (char *) malloc(mlen+1); + strncpy(cmode, _fcdtocp(mode), mlen); + cmode[mlen] = '\0'; +#else + cfname = (char *) malloc(flen+1); + strncpy(cfname, fname, flen); + cfname[flen] = '\0'; + cmode = (char *) malloc(mlen+1); + strncpy(cmode, mode, mlen); + cmode[mlen] = '\0'; +#endif + + /* strip blanks */ + + p = cfname; + while(*p) + { + if (*p == ' ') *p = '\0'; + p++; + } + p = cmode; + while(*p) + { + if (*p == ' ') *p = '\0'; + p++; + } + + /* Open file */ + + *file = cos_open(cfname, cmode); + + if (*file == NULL) + *iret = -1; + else + *iret = 0; + + return; +} + +void cosclose (COSFILE **file, INTEGER *iret) +{ + + /* Close file */ + + *iret = cos_close(*file); + + return; +} + +void cosrewind (COSFILE **file, INTEGER *iret) +{ + + /* Rewind file */ + + *iret = cos_rewind(*file); + + return; +} + +void cosbackspace (COSFILE **file, INTEGER *iret) +{ + + /* Backspace file */ + + *iret = cos_backspace(*file); + + return; +} + +void cosread (COSFILE **file, void *data, INTEGER *datasize, INTEGER *readsize, + INTEGER *iret) +{ + + /* Read file */ + + int readsize1; + + *iret = cos_read(*file, data, *datasize, &readsize1); + + *readsize = readsize1; + + return; +} + +void swapbytes(void *buf, INTEGER *nbytes, INTEGER *n) +{ + swap_bytes(buf, *nbytes, *n); + + return; +} + +void c8tor4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit reals to Ieee 32 bit reals */ + + *iret = c8_to_r4(in, out, *n); + + return; +} + +void c8toi4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit integers to Ieee 32 bit integers */ + + *iret = c8_to_i4(in, out, *n); + + return; +} + +void c8tol4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit logicals to Ieee 32 bit logicals */ + + *iret = c8_to_l4(in, out, *n); + + return; +} + +void c8tor8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit reals to Ieee 64 bit reals */ + + *iret = c8_to_r8(in, out, *n); + + return; +} + +void c8toi8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit integers to Ieee 64 bit integers */ + + *iret = c8_to_i8(in, out, *n); + + return; +} + +void c8tol8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Cray 64 bit logicals to Ieee 64 bit logicals */ + + *iret = c8_to_l8(in, out, *n); + + return; +} + +void r8tor4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 64 bit reals to Ieee 32 bit reals */ + + *iret = r8_to_r4(in, out, *n); + + return; +} + +void ii8toi4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 64 bit integers to Ieee 32 bit integers */ + + *iret = i8_to_i4(in, out, *n); + + return; +} + +void r4tor8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 32 bit reals to Ieee 64 bit reals */ + + *iret = r4_to_r8(in, out, *n); + + return; +} + +void ii4toi8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 32 bit integers to Ieee 64 bit integers */ + + *iret = i4_to_i8(in, out, *n); + + return; +} + +#ifdef _CRAY +void r4toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 32 bit reals to Cray 64 bit reals */ + + *iret = r4_to_c8(in, out, *n); + + return; +} + +void i4toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 32 bit integers to Cray 64 bit integers */ + + *iret = i4_to_c8(in, out, *n); + + return; +} + +void l4toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 32 bit logicals to Cray 64 bit logicals */ + + *iret = l4_to_c8(in, out, *n); + + return; +} + +void r8toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 64 bit reals to Cray 64 bit reals */ + + *iret = r8_to_c8(in, out, *n); + + return; +} + +void i8toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 64 bit integers to Cray 64 bit integers */ + + *iret = i8_to_c8(in, out, *n); + + return; +} + +void l8toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert Ieee 64 bit logicals to Cray 64 logicals */ + + *iret = l8_to_c8(in, out, *n); + + return; +} +#endif + +void ibmi4toi4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert IBM 32 bit integers to Ieee 32 bit integers */ + + *iret = ibmi4_to_i4(in, out, *n); + + return; +} + +void ibmi2toi4 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 16 bit integers to Ieee 32 bit integers */ + + *iret = ibmi2_to_i4(in, out, *n, *offset); + + return; +} + +void ibmr4tor4 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert IBM 32 bit floats to Ieee 32 bit floats */ + + *iret = ibmr4_to_r4(in, out, *n); + + return; +} + +void ibmi4toi8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 32 bit integers to Ieee 64 bit integers */ + + *iret = ibmi4_to_i8(in, out, *n, *offset); + + return; +} + +void ibmi2toi8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 16 bit integers to Ieee 64 bit integers */ + + *iret = ibmi2_to_i8(in, out, *n, *offset); + + return; +} + +void ibmr4tor8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 32 bit floats to Ieee 64 bit floats */ + + *iret = ibmr4_to_r8(in, out, *n, *offset); + + return; +} + +void ibmr8tor8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert IBM 64 bit floats to Ieee 64 bit floats */ + + *iret = ibmr8_to_r8(in, out, *n); + + return; +} + +#ifdef _CRAYPVP +void ibmi4toc8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 32 bit integers to CRAY 64 bit integers */ + + *iret = ibmi4_to_c8(in, out, *n, *offset); + + return; +} + +void ibmi2toc8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 16 bit integers to CRAY 64 bit integers */ + + *iret = ibmi2_to_c8(in, out, *n, *offset); + + return; +} + +void ibmr4toc8 (void *in, void *out, INTEGER *n, INTEGER *offset, INTEGER *iret) +{ + + /* Convert IBM 32 bit floats to CRAY 64 bit floats */ + + *iret = ibmr4_to_c8(in, out, *n, *offset); + + return; +} + +void ibmr8toc8 (void *in, void *out, INTEGER *n, INTEGER *iret) +{ + + /* Convert IBM 64 bit floats to CRAY 64 bit floats */ + + *iret = ibmr8_to_c8(in, out, *n); + + return; +} +#endif + +#ifndef _CRAYPVP +/* + * + * Translate 32-bit packed Cray reals to reals + * c version of CRAY routine EXPAND21 written in CAL. + * + * n: length of in, out + * in: array of 32-bit packed Cray reals + * out: array of result reals + * nexp: size of exponent + * + * 32-bit packed Cray representation: + * bits 0-(30-nexp): mantissa + * bits (31-nexp)-30: exponent + * bit 31: sign + */ + +void expand21(INTEGER *n, void *in, void *out, INTEGER *nexp) +{ +#if _FLT_TYPE == _IEEE8 + expand21_r8(n, in, out, nexp); +#else + expand21_r4(n, in, out, nexp); +#endif +} + +void expand21_r4(INTEGER *n, void *in, void *out, INTEGER *nexp) +{ + int i, bias; + uint32 *lin, crayword[2]; + uint32 cexp, pexp, sign, pfrac; + uint32 mask1, mask2, mask3, mask4; + float32 *lout; + +#ifdef LITTLE__ENDIAN + swap_bytes(in, 4, *n); +#endif + + lin = (uint32 *) in; + lout = (float32 *) out; + bias = pow(2.0,(double) *nexp-1); + mask1 = ~(~0 << *nexp); + mask2 = ~(~0 << (31-*nexp)); + mask3 = ~(~0 << 16); + mask4 = ~(~0 << (15-*nexp)); + + for (i = 0; i < *n; i++, lin++, lout++) + { + sign = *lin & CSIGNMASK1; /* sign bit */ + + /* Calculate packed unbiased exponent and Cray unbiased exponent */ + + pexp = (*lin >> (31-*nexp)) & mask1; + cexp = pexp - bias + CBIAS; + + /* Calculate packed fraction */ + + pfrac = *lin & mask2; + + /* Calculate 64 bit cray word stored as 2 32 bit integers */ + + crayword[0] = sign | (cexp << 16) | ((pfrac >> (15-*nexp)) & mask3); + crayword[1] = (pfrac & mask4) << (17+*nexp); + + /* Calculate 32 bit IEEE word */ + +#ifdef LITTLE__ENDIAN + swap_bytes(crayword, 4, 2); +#endif + c8_to_r4(crayword, lout, 1); + } + +#ifdef LITTLE__ENDIAN + swap_bytes(in, 4, *n); +#endif +} + +void expand21_r8(INTEGER *n, void *in, void *out, INTEGER *nexp) +{ + int i, bias; + uint32 *lin, crayword[2]; + uint32 cexp, pexp, sign, pfrac; + uint32 mask1, mask2, mask3, mask4; + float64 *lout; + +#ifdef LITTLE__ENDIAN + swap_bytes(in, 4, *n); +#endif + + lin = (uint32 *) in; + lout = (float64 *) out; + bias = pow(2.0,(double) *nexp-1); + mask1 = ~(~0 << *nexp); + mask2 = ~(~0 << (31-*nexp)); + mask3 = ~(~0 << 16); + mask4 = ~(~0 << (15-*nexp)); + + for (i = 0; i < *n; i++, lin++, lout++) + { + sign = *lin & CSIGNMASK1; /* sign bit */ + + /* Calculate packed unbiased exponent and Cray unbiased exponent */ + + pexp = (*lin >> (31-*nexp)) & mask1; + cexp = pexp - bias + CBIAS; + + /* Calculate packed fraction */ + + pfrac = *lin & mask2; + + /* Calculate 64 bit cray word stored as 2 32 bit integers */ + + crayword[0] = sign | (cexp << 16) | ((pfrac >> (15-*nexp)) & mask3); + crayword[1] = (pfrac & mask4) << (17+*nexp); + + /* Calculate 64 bit IEEE word */ + +#ifdef LITTLE__ENDIAN + swap_bytes(crayword, 4, 2); +#endif + c8_to_r8(crayword, lout, 1); + } + +#ifdef LITTLE__ENDIAN + swap_bytes(in, 4, *n); +#endif +} +#endif diff -Naur cdat-4.0b3/libcdms/src/cdunif/cdunifstub.c cdat-4.0b3-pp/libcdms/src/cdunif/cdunifstub.c --- cdat-4.0b3/libcdms/src/cdunif/cdunifstub.c 2004-06-28 18:07:50.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/cdunifstub.c 2004-11-04 16:57:55.000000000 +0000 @@ -57,6 +57,10 @@ CuError(CU_EBADFORM,"POP I/O routines not available, file %s.",controlpath); return -1; } +int cuopenread_stub_pp(const char* controlpath, const char* datapath){ + CuError(CU_EBADFORM,"PP I/O routines not available, file %s.",controlpath); + return -1; +} int cuclose_stub(CuFile* file){ CuError(CU_EBADFORM,"Stub called, file %s",file->controlpath); return -1; diff -Naur cdat-4.0b3/libcdms/src/cdunif/Makefile.in cdat-4.0b3-pp/libcdms/src/cdunif/Makefile.in --- cdat-4.0b3/libcdms/src/cdunif/Makefile.in 2004-06-28 18:07:49.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/Makefile.in 2004-11-04 16:57:55.000000000 +0000 @@ -48,7 +48,7 @@ CC = @CC@ CFLAGS = -I../../include @CFLAGS@ $(DEBUG) -Dgrads -CPPFLAGS = @CPPFLAGS@ -DSTNDALN=1 -DBYTEORDER=@GRADS_BYTEORDER@ -DGRADS_CRAY=@GRADS_CRAY@ @QLOPTS@ +CPPFLAGS = @CPPFLAGS@ -DSTNDALN=1 -DBYTEORDER=@GRADS_BYTEORDER@ -DGRADS_CRAY=@GRADS_CRAY@ @QLOPTS@ @PPOPTS@ DEBUG = -O DEFS = @DEFS@ FC = @FC@ @@ -69,6 +69,7 @@ all: $(OBJS) FORCE ar rv $(LIBRARY) $(OBJS) + make -C cdunifpp DEBUG=$(DEBUG) $(RANLIB) $(LIBRARY) cdunif.o: cdunif.c ../../include/cdunifint.h ../../include/cdunif.h @@ -115,6 +116,7 @@ clean: -rm -f *.o core *.~*~ + make -C cdunifpp clean distclean: clean diff -Naur cdat-4.0b3/libcdms/src/cdunif/test/Makefile.in cdat-4.0b3-pp/libcdms/src/cdunif/test/Makefile.in --- cdat-4.0b3/libcdms/src/cdunif/test/Makefile.in 2004-06-28 18:07:50.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/test/Makefile.in 2004-11-04 16:57:55.000000000 +0000 @@ -43,7 +43,7 @@ CC = @CC@ CFLAGS = -I../../../include @CFLAGS@ $(DEBUG) -Dgrads -CPPFLAGS = @CPPFLAGS@ +CPPFLAGS = @CPPFLAGS@ @PPOPTS@ DEBUG = -O DEFS = @DEFS@ FC = @FC@ @@ -61,15 +61,17 @@ # LIBRARY = ../../../lib/libcdms.a -all: cdfile cudump cuget testnc testgrib testdrs +all: cdfile cudump cuget testnc testgrib testdrs testpp -test: testnc testgrib testdrs +test: testnc testgrib testdrs testpp @echo "test netCDF" @testnc @echo "test GRIB" @testgrib @echo "test DRS" @testdrs + @echo "test PP" + @testpp .SUFFIXES: .F @@ -104,4 +106,5 @@ -rm -f *.o core *.~*~ distclean: clean - -rm -f cdfile cudump cuget testnc testgrib testdrs testslab + -rm -f cdfile cudump cuget testnc testgrib testdrs testslab testpp + diff -Naur cdat-4.0b3/libcdms/src/cdunif/test/testpp.c cdat-4.0b3-pp/libcdms/src/cdunif/test/testpp.c --- cdat-4.0b3/libcdms/src/cdunif/test/testpp.c 1970-01-01 01:00:00.000000000 +0100 +++ cdat-4.0b3-pp/libcdms/src/cdunif/test/testpp.c 2004-11-04 16:57:55.000000000 +0000 @@ -0,0 +1,113 @@ +/* Test cdunif/PP: + * + * Reads the test PP file, and tests certain data values against known contents + */ + +#include +#include +#include +#include "cdunif.h" +#include + +extern void usage(); + +#define UNAME "u" +#define NULAT 72 + +#define STARTX 10 +#define STARTY 20 +#define STARTZ 5 +#define STARTT 0 + +#define COUNTX 4 +#define COUNTY 5 +#define COUNTZ 3 +#define COUNTT 1 + +#define TESTX 2 +#define TESTY 3 +#define TESTZ 1 +#define TESTT 0 + +#define TESTLAT 10 +#define LATVAL 63.75 +#define UVAL -0.0643737 +#define TOLERANCE 1e-5 + +typedef float Real; + +main(int argc, char *argv[]){ +#ifdef HAVE_PP + int fileid; + char *filename="testpp.pp"; + int varid_u,dimid_lat,status; + + char varname[CU_MAX_NAME+1],dimname[CU_MAX_NAME+1],dimunits[CU_MAX_NAME+1]; + CuType datatype; + CuDimType dimtype; + int varid, ndims, dimids[CU_MAX_VAR_DIMS], natts; + long length; + + Real latitude[NULAT]; + Real u[COUNTT][COUNTZ][COUNTY][COUNTX]; + + long start[4]={STARTT,STARTZ,STARTY,STARTX},count[4]={COUNTT,COUNTZ,COUNTY,COUNTX}; + + if(argc != 1) usage(); + + /* open */ + fileid = cuopenread(filename,0); + if (fileid!=0) goto err; + + /* find the U variable */ + varid_u = cuvarid(fileid,UNAME); + + /* find its corresponding latitude dimension */ + status = cuvarinq(fileid, varid_u, varname, &datatype, &ndims, dimids, &natts); + if (status!=0) goto err; + + dimid_lat = dimids[2]; + + /* get info on the latitude dimension */ + status = cudiminq(fileid, dimid_lat, dimname, dimunits, &datatype, &dimtype, &varid, &length); + if (status!=0) goto err; + + if (length != NULAT) goto err; + + /* get values of latitude */ + status = cudimget(fileid, dimid_lat, latitude); + if (status!=0) goto err; + + /* test a latitude value */ + if (fabs(latitude[TESTLAT] - LATVAL) > TOLERANCE) goto err; + + /* get a hyperslab from U */ + status=cuvarget(fileid, varid_u, start, count, u); + if (status!=0) goto err; + + /* test a U value */ + if (fabs(u[TESTT][TESTZ][TESTY][TESTX] - UVAL) > TOLERANCE) goto err; + + /* close */ + status = cuclose(fileid); + if (status!=0) goto err; + + exit(0); + + err: + fprintf(stderr,"*** Error in TestPP verifying file %s\n",filename); + exit(1); + +#else + fprintf(stderr,"PP library not present\n"); + exit(0); +#endif +} + + +void +usage(){ + fprintf(stderr,"Usage: testpp\n"); + fprintf(stderr," Open the test PP file and check data\n"); + exit(1); +}