From cf4fded6995f1f0100b09827e537f777859107ce Mon Sep 17 00:00:00 2001 From: "Benjamin T. Johnson" Date: Mon, 12 Aug 2024 03:16:52 +0000 Subject: [PATCH] added capability to compile both shared object (libcrtm.so) and static object (libcrtm_static.a) files. If you're suddenly having linking problems or segmentation faults in your ctests, this is the cause. First use ldd to check that your compiled ctests (located in build/test) are compiling against the correct shared object -- it will try to pick up things from your LD_LIBRARY_PATH. If you're getting endian errors: export F_UFMTENDIAN=little or export F_UFMTENDIAN=big will swap endianness for you without the need to recompile. Just be sure to update the test/CMakeLists.txt file to point to either Big_Endian or Little_Endian directories. --- CMakeLists.txt | 2 +- TEST_CRTM_Liu/README_testData | 12 - cmake/compiler_flags_Intel_Fortran.cmake | 19 +- configuration/ftn.setup | 18 -- configuration/ftn.setup.csh | 9 - configuration/g95-debug.setup.csh | 10 - configuration/g95.setup.csh | 9 - configuration/gfortran-debug.setup | 48 ---- configuration/gfortran-debug.setup.csh | 9 - configuration/gfortran.setup | 47 ---- configuration/gfortran.setup.csh | 9 - configuration/ifort-debug.setup | 37 --- configuration/ifort-debug.setup.csh | 9 - configuration/ifort.setup | 39 --- configuration/ifort.setup.csh | 9 - configuration/pgf95-debug.setup | 21 -- configuration/pgf95-debug.setup.csh | 9 - configuration/pgf95.setup | 14 - configuration/pgf95.setup.csh | 9 - configuration/xlf2003-debug.setup | 22 -- configuration/xlf2003-debug.setup.csh | 9 - configuration/xlf2003.setup | 20 -- configuration/xlf2003.setup.csh | 9 - .../shell/TauProd/tauprod_create_spccoeff.sh | 53 ---- scripts/shell/Utility/README.link_coeffs | 208 -------------- scripts/shell/Utility/crtm_cleanup.sh | 171 ------------ scripts/shell/Utility/crtm_env.sh | 148 ---------- scripts/shell/Utility/crtm_rebuild.sh | 176 ------------ scripts/shell/Utility/endian_wrapper.sh | 130 --------- scripts/shell/Utility/link_atmprofile.sh | 153 ---------- scripts/shell/Utility/link_coeffs.sh | 262 ------------------ scripts/shell/Utility/link_sensorinfo.sh | 131 --------- scripts/shell/Utility/link_solar.sh | 145 ---------- scripts/shell/Utility/link_srf.sh | 127 --------- scripts/shell/Utility/linkfiles.sh | 212 -------------- scripts/shell/Utility/unlinkfiles.sh | 13 - scripts/shell/crtm_install_scripts.sh | 201 -------------- src/CMakeLists.txt | 13 +- util/checkendian/Makefile | 11 - util/checkendian/main.c | 247 ----------------- 40 files changed, 20 insertions(+), 2780 deletions(-) delete mode 100644 TEST_CRTM_Liu/README_testData delete mode 100644 configuration/ftn.setup delete mode 100644 configuration/ftn.setup.csh delete mode 100644 configuration/g95-debug.setup.csh delete mode 100644 configuration/g95.setup.csh delete mode 100644 configuration/gfortran-debug.setup delete mode 100644 configuration/gfortran-debug.setup.csh delete mode 100644 configuration/gfortran.setup delete mode 100644 configuration/gfortran.setup.csh delete mode 100644 configuration/ifort-debug.setup delete mode 100644 configuration/ifort-debug.setup.csh delete mode 100644 configuration/ifort.setup delete mode 100644 configuration/ifort.setup.csh delete mode 100644 configuration/pgf95-debug.setup delete mode 100644 configuration/pgf95-debug.setup.csh delete mode 100644 configuration/pgf95.setup delete mode 100644 configuration/pgf95.setup.csh delete mode 100644 configuration/xlf2003-debug.setup delete mode 100644 configuration/xlf2003-debug.setup.csh delete mode 100644 configuration/xlf2003.setup delete mode 100644 configuration/xlf2003.setup.csh delete mode 100755 scripts/shell/TauProd/tauprod_create_spccoeff.sh delete mode 100644 scripts/shell/Utility/README.link_coeffs delete mode 100755 scripts/shell/Utility/crtm_cleanup.sh delete mode 100755 scripts/shell/Utility/crtm_env.sh delete mode 100755 scripts/shell/Utility/crtm_rebuild.sh delete mode 100755 scripts/shell/Utility/endian_wrapper.sh delete mode 100755 scripts/shell/Utility/link_atmprofile.sh delete mode 100755 scripts/shell/Utility/link_coeffs.sh delete mode 100755 scripts/shell/Utility/link_sensorinfo.sh delete mode 100755 scripts/shell/Utility/link_solar.sh delete mode 100755 scripts/shell/Utility/link_srf.sh delete mode 100755 scripts/shell/Utility/linkfiles.sh delete mode 100755 scripts/shell/Utility/unlinkfiles.sh delete mode 100755 scripts/shell/crtm_install_scripts.sh delete mode 100644 util/checkendian/Makefile delete mode 100644 util/checkendian/main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c7ccd01..fe85b66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,4 +127,4 @@ else() message(STATUS "No build type specified, defaulting to Release.") endif() -set(crtm_LIBRARIES crtm) +#set(crtm_LIBRARIES crtm) diff --git a/TEST_CRTM_Liu/README_testData b/TEST_CRTM_Liu/README_testData deleted file mode 100644 index 38a64d0..0000000 --- a/TEST_CRTM_Liu/README_testData +++ /dev/null @@ -1,12 +0,0 @@ - -The three data files CRTM_atm100.bin, CRTM_geo100.bin, CRTM_sfc100.bin in big endian - contain 100 profiles, which are constructed from 5000 ECMWF profiles. - 67 tmospheric profiles over water, - 23 profiles over land, - 6 profile over snow and - 5 profiles over ice - - The profile even number (2,4,...,100) are clear sky cases. The profile odd number is for - one type cloud. All profiles include one aerosol profile. - - Quanhua Liu diff --git a/cmake/compiler_flags_Intel_Fortran.cmake b/cmake/compiler_flags_Intel_Fortran.cmake index 134a0c5..f864319 100644 --- a/cmake/compiler_flags_Intel_Fortran.cmake +++ b/cmake/compiler_flags_Intel_Fortran.cmake @@ -1,16 +1,8 @@ -# (C) Copyright 2009-2016 ECMWF. -# -# This software is licensed under the terms of the Apache Licence Version 2.0 -# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. -# In applying this licence, ECMWF does not waive the privileges and immunities -# granted to it by virtue of its status as an intergovernmental organisation nor -# does it submit to any jurisdiction. - #################################################################### # FLAGS COMMON TO ALL BUILD TYPES #################################################################### -set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl -fPIC") +set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -assume byterecl") if( HAVE_AUTOPROFILE ) set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions") @@ -28,6 +20,12 @@ set( CMAKE_Fortran_FLAGS_RELEASE "-O3 -ip -unroll -inline -no-heap-arrays" ) set( CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -check bounds -traceback -warn -heap-arrays -fpe-all=0 -fpe:0 -ftz -check all" ) +#################################################################### +# RELEASE WITH DEBUG INFO FLAGS +#################################################################### + +set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O3 -ip -unroll -inline -g -DNDEBUG -check bounds -traceback -no-heap-arrays -assume byterecl" ) + #################################################################### # BIT REPRODUCIBLE FLAGS #################################################################### @@ -42,7 +40,4 @@ set( CMAKE_Fortran_LINK_FLAGS "" ) #################################################################### -# Meaning of flags -# ---------------- -# todo diff --git a/configuration/ftn.setup b/configuration/ftn.setup deleted file mode 100644 index fe5f3aa..0000000 --- a/configuration/ftn.setup +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for ftn compiler on EMC Linux Cray machine -#-------------------------------------------------------------------------------# - -export FC="ftn" - -export FCFLAGS="\ --O3 \ --axCore-AVX2 \ --fp-model source \ --convert big_endian \ --free \ --assume byterecl" - -export LDFLAGS="" - -export LIBS="" diff --git a/configuration/ftn.setup.csh b/configuration/ftn.setup.csh deleted file mode 100644 index b516544..0000000 --- a/configuration/ftn.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for ftn compiler on EMC Linux Cray machine -#-------------------------------------------------------------------------------# - -setenv FC "ftn" -setenv FCFLAGS "-O3 -axCore-AVX2 -fp-model source -convert big_endian -free -assume byterecl" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/g95-debug.setup.csh b/configuration/g95-debug.setup.csh deleted file mode 100644 index a6ce1eb..0000000 --- a/configuration/g95-debug.setup.csh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux g95 compiler -#-------------------------------------------------------------------------------# - -setenv FC "g95" -setenv FCFLAGS "-fbounds-check -ffree-form -fno-second-underscore -ftrace=frame -malign-double -Wall" -setenv LDFLAGS "" -setenv LIBS "" - diff --git a/configuration/g95.setup.csh b/configuration/g95.setup.csh deleted file mode 100644 index f7ce791..0000000 --- a/configuration/g95.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux g95 compiler -#-------------------------------------------------------------------------------# - -setenv FC "g95" -setenv FCFLAGS "-O2 -ffast-math -ffree-form -fno-second-underscore -funroll-loops -malign-double" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/gfortran-debug.setup b/configuration/gfortran-debug.setup deleted file mode 100644 index 822897d..0000000 --- a/configuration/gfortran-debug.setup +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux gfortran compiler -#-------------------------------------------------------------------------------# - -uname=$(uname -s) - -export FC="gfortran" - -if [[ "$uname" == "Linux" ]] ; then - export NC4_DIR=/usr/local/ #singularity container only - export HDF_DIR=/usr/local/ #singularity container only -elif [[ "$uname" == "Darwin" ]] ; then - export NC4_DIR="/usr/local/Cellar/netcdf/4.8.0_2" #mac OS, brew install - export HDF_DIR="/usr/local/Cellar/hdf5/1.12.1" #mac OS, brew install -fi - -#set the number of openmp threads -export OMP_NUM_THREADS=4 #set here for testing purposes, probably want to override this - -export FCFLAGS="\ --fbounds-check \ --mieee-fp \ --fimplicit-none \ --ffpe-trap=overflow,zero,invalid \ --ffree-form \ --fno-second-underscore \ --frecord-marker=4 \ --ggdb \ --fopenmp \ --Wall \ --Wconversion \ --std=f2008" - -export LDFLAGS="-fopenmp" - -export LIBS="" - -if [[ "$uname" == "Darwin" ]] || [[ "$uname" == "Linux" ]] ; then #mac OS, brew install or Linux (singularity) - export LIBS="\ - -L $NC4_DIR/lib -lnetcdf -lnetcdff \ - -L $HDF_DIR/lib -lhdf5 \ - -I $NC4_DIR/include \ - -I $HDF_DIR/include " -else - export LIBS="" -fi - diff --git a/configuration/gfortran-debug.setup.csh b/configuration/gfortran-debug.setup.csh deleted file mode 100644 index b34c005..0000000 --- a/configuration/gfortran-debug.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux gfortran compiler -#-------------------------------------------------------------------------------# - -setenv FC "gfortran" -setenv FCFLAGS "-fbounds-check -fimplicit-none -ffpe-trap=overflow,zero,invalid -ffree-form -fno-second-underscore -frecord-marker=4 -ggdb -Wall -Wconversion -std=f2008" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/gfortran.setup b/configuration/gfortran.setup deleted file mode 100644 index 293ff4a..0000000 --- a/configuration/gfortran.setup +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux gfortran compiler -#-------------------------------------------------------------------------------# - -uname=$(uname -s) - -export FC="gfortran" - -if [[ "$uname" == "Linux" ]] ; then - export NC4_DIR=/usr/local #singularity container only - export HDF_DIR=/usr/local #singularity container only -elif [[ "$uname" == "Darwin" ]] ; then - export NC4_DIR="/usr/local/Cellar/netcdf/4.8.0_2" #mac OS (brew install) - export HDF_DIR="/usr/local/Cellar/hdf5/1.12.1" #mac OS (brew install) -fi - -#set the number of openmp threads -export OMP_NUM_THREADS=4 #set here for testing purposes, probably want to override this - -export FCFLAGS="\ --O3 \ --fimplicit-none \ --ffree-form \ --fno-second-underscore \ --frecord-marker=4 \ --funroll-loops \ --fopenmp \ --Wall \ --Wconversion \ --mieee-fp \ --fbounds-check \ --std=f2008" - -export LDFLAGS="-fopenmp" - -export LIBS="" - -if [[ "$uname" == "Darwin" ]] || [[ "$uname" == "Linux" ]] ; then #mac OS, brew install or linux (singularity) - export LIBS="\ - -L $NC4_DIR/lib -lnetcdf -lnetcdff \ - -L $HDF_DIR/lib -lhdf5 \ - -I $NC4_DIR/include \ - -I $HDF_DIR/include " -else - export LIBS="" -fi diff --git a/configuration/gfortran.setup.csh b/configuration/gfortran.setup.csh deleted file mode 100644 index 0aa6314..0000000 --- a/configuration/gfortran.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux gfortran compiler -#-------------------------------------------------------------------------------# - -setenv FC "gfortran" -setenv FCFLAGS "-O3 -fimplicit-none -ffree-form -fno-second-underscore -frecord-marker=4 -funroll-loops -ggdb -Wall -Wconversion -std=f2008" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/ifort-debug.setup b/configuration/ifort-debug.setup deleted file mode 100644 index d4866d3..0000000 --- a/configuration/ifort-debug.setup +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux ifort compiler -#-------------------------------------------------------------------------------# - -hostname=$(hostname) -export FC="ifort" -export NC4_DIR="/opt/netcdf4/4.6.2-intel-18.0.3" -export HDF_DIR="/opt/hdf5/1.8.21-intel-18.0.3" -#export HDF4_DIR="/opt/hdf4/4.2.14-intel-18.0.3" - -export OMP_NUM_THREADS=4 #set here for testing purposes, probably want to override this - -export FCFLAGS="\ --g \ --check bounds \ --e08 \ --traceback \ --free \ --assume byterecl,realloc_lhs \ --qopenmp \ --fp-stack-check \ --mieee-fp" - -export LDFLAGS="-qopenmp" - -if [[ "$hostname" == "s4-submit.ssec.wisc.edu" ]] ; then #S4 - export LIBS="\ - -L $NC4_DIR/lib -lnetcdf -lnetcdff \ - -L $HDF_DIR/lib -lhdf5 \ - -g -fpp -traceback -check bounds \ - -I $NC4_DIR/include \ - -I $HDF_DIR/include " -else - export LIBS="" -fi - diff --git a/configuration/ifort-debug.setup.csh b/configuration/ifort-debug.setup.csh deleted file mode 100644 index 82c5fb8..0000000 --- a/configuration/ifort-debug.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux ifort compiler -#-------------------------------------------------------------------------------# - -setenv FC "ifort" -setenv FCFLAGS "-g -check bounds -e08 -traceback -free -assume byterecl,realloc_lhs -fp-stack-check -mieee-fp" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/ifort.setup b/configuration/ifort.setup deleted file mode 100644 index fc241c8..0000000 --- a/configuration/ifort.setup +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux ifort compiler -#-------------------------------------------------------------------------------# - -hostname=$(hostname) -export FC="ifort" - -export OMP_NUM_THREADS=4 #set here for testing purposes, probably want to override this - -export FCFLAGS="\ --O3 \ --fp-model source \ --e08 \ --free \ --qopenmp \ --assume byterecl,realloc_lhs" - -export LDFLAGS="-qopenmp" - -HDF5DISC="/usr/local/other/hdf5/1.13.0/intel-19.1.0.16_impi-20.0.0.166/" - -if [[ "$hostname" == "s4-submit.ssec.wisc.edu" ]] ; then #S4 - export LIBS="\ - -L ${NC4_LIB} -lnetcdf -lnetcdff \ - -L ${HDF5_LIB} -lhdf5 \ - -g -fpp -traceback -check bounds \ - -I ${NC4_INC} \ - -I ${HDF5_INC} " -elif [[ "$hostname" == "discover"* ]] ; then # NCCS Discover - export LIBS="\ - -L $NETCDF/lib -lnetcdf -lnetcdff \ - -L $HDF5DISC/lib -lhdf5 \ - -g -fpp -traceback -check bounds \ - -I $NETCDF/include \ - -I $HDF5DISC/include " -else - export LIBS="" -fi diff --git a/configuration/ifort.setup.csh b/configuration/ifort.setup.csh deleted file mode 100644 index 18ec964..0000000 --- a/configuration/ifort.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux ifort compiler -#-------------------------------------------------------------------------------# - -setenv FC "ifort" -setenv FCFLAGS "-O2 -fp-model source -free -e08 -assume byterecl,realloc_lhs" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/pgf95-debug.setup b/configuration/pgf95-debug.setup deleted file mode 100644 index e5e956b..0000000 --- a/configuration/pgf95-debug.setup +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux pgf95 compiler -#-------------------------------------------------------------------------------# - -export FC="pgf95" - -export FCFLAGS="\ --g \ --Ktrap=ovf,divz -Mdaz \ --Mbounds \ --Mchkstk \ --Mdclchk \ --Minform,inform \ --Mnosave \ --Mref_externals \ --Kieee" - -export LDFLAGS="-Kieee" - -export LIBS="" diff --git a/configuration/pgf95-debug.setup.csh b/configuration/pgf95-debug.setup.csh deleted file mode 100644 index 8401d37..0000000 --- a/configuration/pgf95-debug.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# DEBUG build settings for Linux pgf95 compiler -#-------------------------------------------------------------------------------# - -setenv FC "pgf95" -setenv FCFLAGS "-g -Ktrap=ovf,divz -Mdaz -Mbounds -Mchkstk -Mdclchk -Minform,inform -Mnosave -Mref_externals -Kieee" -setenv LDFLAGS "-Kieee" -setenv LIBS "" diff --git a/configuration/pgf95.setup b/configuration/pgf95.setup deleted file mode 100644 index 3231a9e..0000000 --- a/configuration/pgf95.setup +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux pgf95 compiler -#-------------------------------------------------------------------------------# - -export FC="pgf95" - -export FCFLAGS="\ --g \ --fast" - -export LDFLAGS="" - -export LIBS="" diff --git a/configuration/pgf95.setup.csh b/configuration/pgf95.setup.csh deleted file mode 100644 index ead785e..0000000 --- a/configuration/pgf95.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for Linux pgf95 compiler -#-------------------------------------------------------------------------------# - -setenv FC "pgf95" -setenv FCFLAGS "-g -fast" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/xlf2003-debug.setup b/configuration/xlf2003-debug.setup deleted file mode 100644 index 3fef057..0000000 --- a/configuration/xlf2003-debug.setup +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# DEBUG build settings for IBM AIX xlf2003 compiler -#-------------------------------------------------------------------------------# - -export FC="xlf2003" - -export FCFLAGS="\ --qcheck \ --qdbg \ --qextchk \ --qfloat=nomaf:rndsngl \ --qflttrap=ov:zero:en \ --qinitauto \ --qhalt=W \ --qlanglvl=2008pure \ --qmaxmem=-1 \ --qsuffix=f=f90:cpp=fpp:cpp=F90" - -export LDFLAGS="" - -export LIBS="" diff --git a/configuration/xlf2003-debug.setup.csh b/configuration/xlf2003-debug.setup.csh deleted file mode 100644 index 9cac6cb..0000000 --- a/configuration/xlf2003-debug.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# DEBUG build settings for IBM AIX xlf2003 compiler -#-------------------------------------------------------------------------------# - -setenv FC "xlf2003" -setenv FCFLAGS "-qcheck -qdbg -qextchk -qfloat=nomaf:rndsngl -qflttrap=ov:zero:en -qinitauto -qhalt=W -qlanglvl=2008pure -qmaxmem=-1 -qsuffix=f=f90:cpp=fpp:cpp=F90" -setenv LDFLAGS "" -setenv LIBS "" diff --git a/configuration/xlf2003.setup b/configuration/xlf2003.setup deleted file mode 100644 index d3e91c3..0000000 --- a/configuration/xlf2003.setup +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for IBM AIX xlf2003 compiler -#-------------------------------------------------------------------------------# - -export FC="xlf2003" - -export FCFLAGS="\ --qdbg \ --qarch=auto \ --qhalt=W \ --qlanglvl=2008pure \ --qsuffix=f=f90:cpp=F90 \ --qstrict \ --NS32768 \ --O3" - -export LDFLAGS="-O3" - -export LIBS="-lmass -lm" diff --git a/configuration/xlf2003.setup.csh b/configuration/xlf2003.setup.csh deleted file mode 100644 index 9c0f255..0000000 --- a/configuration/xlf2003.setup.csh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/csh -#-------------------------------------------------------------------------------# -# PRODUCTION build settings for IBM AIX xlf2003 compiler -#-------------------------------------------------------------------------------# - -setenv FC "xlf2003" -setenv FCFLAGS "-qdbg -qarch=auto -qhalt=W -qlanglvl=2008pure -qsuffix=f=f90:cpp=fpp:cpp=F90 -qstrict -NS32768 -O3" -setenv LDFLAGS "-O3" -setenv LIBS "-lmass -lm" diff --git a/scripts/shell/TauProd/tauprod_create_spccoeff.sh b/scripts/shell/TauProd/tauprod_create_spccoeff.sh deleted file mode 100755 index 9668cbd..0000000 --- a/scripts/shell/TauProd/tauprod_create_spccoeff.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -# -# Bash script to run the Create_SpcCoeff application for all the required -# sensors for which there are oSRF datafiles in this directory hierarchy. -# -# Format of the "create_spccoeff.config" include file is an array of descriptors -# including the sensor id and the final SpcCoeff data version number using ":" as -# the delimiter, e.g.: -# -# CONFIG=( [1]=sensor1_platform1:1 -# [2]=sensor1_platform2:4 -# ... -# [I]=sensorN_platformK:2 ) -# - -# Check for existence of SensorInfo -if [ ! -f SensorInfo ]; then - echo "SensorInfo file not found" - exit 1 -fi - - -# Link in the solar files -link_solar.sh -link_solar.sh dF_0.0025.Solar.nc - - -# Define the sensors to be processed and their **NEW** data version number -source ./tauprod_create_spccoeff.config - - -# Loop over the sensors to convert -for (( element = 1 ; element <= ${#CONFIG[@]} ; element++ )) do - - # Extract out sensor id and data version - sensor_id=`echo ${CONFIG[$element]} | cut -d: -f1` - version=`echo ${CONFIG[$element]} | cut -d: -f2` - - # Create data filename - osrf_filename="${sensor_id}.osrf.nc" - - # Run the conversion program - Create_SpcCoeff <<-EOF - ${sensor_id}/${osrf_filename} - ${version} - EOF - -done - - -# Clean up -rm -f *.Solar.nc *.signal diff --git a/scripts/shell/Utility/README.link_coeffs b/scripts/shell/Utility/README.link_coeffs deleted file mode 100644 index 06fff71..0000000 --- a/scripts/shell/Utility/README.link_coeffs +++ /dev/null @@ -1,208 +0,0 @@ -CRTM v2.1 link_coeff.sh Instructions -==================================== - -$Revision$ - - - CRTM SUPPORT EMAIL: ncep.list.emc.jcsda_crtm.support@noaa.gov - - -0) PREAMBLE ------------ - The coefficient files required to use the CRTM are distributed throughout subdirectories - that reflect their logical grouping (well, logical to me). - - However, the CRTM initialisation function, CRTM_Init(), only has a single argument to - specify the coefficient file path. What this means is that all of the coefficients have - to reside in a single directory. As some user's who are reading this will attest, moving, - copying, or linking all those files is not a simple task. - - Currently it's not possible to release the CRTM coefficient files in a single directory - (the best solution, and we're working on it). As a stop gap measure, we've put together - a little bash shell script to do the linking, "link_coeffs.sh". - - -1) ENVIRONMENT SETUP --------------------- - The main script, link_coeffs.sh, uses a bash shell helper script called "linkfiles.sh" - to search directory trees for requested files and then link them in. For the link_coeffs.sh - script to work this helper script linkfiles.sh *must* be executable AND in a directory - specified in your $PATH environment variable. - - Ideally (I hope obviously) both scripts should be in that $PATH location. - - -2) link_coeffs.sh HELP OUTPUT ------------------------------ - The script usage can be displayed via the -h command line argument, - - $ link_coeffs.sh -h - - $Revision$ $LastChangedDate: 2012-09-24 13:50:50 -0400 (Mon, 24 Sep 2012) $ - Mon Sep 24 14:04:18 EDT 2012 - Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov - - Usage: link_coeffs.sh [-xhla] source-dir dest-dir - - Link in CRTM release fixfiles into a single directory. - - Options: - -l - Link in little-endian files. BIG-ENDIAN is the default. - - -a - Link in ODAS TauCoeff files. ODPS is the default. - - Note: Currently there are no ODPS TauCoeff files - for visible sensors (we're working on it). - - -x - Turn on execution tracing - - -h - Print this message - - Arguments: - source-dir - The /fix directory location of the CRTM release. - This directory must already exist. - - dest-dir - The directory into which the coefficients will be linked. - If this directory does not exist, it is created. - - - I will reiterate some of the things mentioned in the above help output: - 1) BIG_ENDIAN files are linked by default. - 2) ODPS transmittance algorithm files are linked by default. - 3) There are no ODPS files for visible sensors. - - A consequence of #3 above means that the script has top be run twice if you want - to use visible sensors, but ODPS files for other (IR and MW) sensors. - - -3) link_coeffs.sh USAGE ------------------------ - Let's say you've built and installed the CRTM library in - - $HOME/local/REL-2.1 - - where $HOME is your user root directory. The release would contain - - local/REL-2.1 : ls -lhF - total 100K - -rw-r--r-- 1 user grp 9.7K Sep 20 14:38 README - drwxr-xr-x 2 user grp 4.0K Sep 20 14:17 configure/ - drwxr-xr-x 7 user grp 4.0K Sep 20 14:09 fix/ - drwxr-xr-x 2 user grp 12K Sep 20 14:45 libsrc/ - -rw-r--r-- 1 user grp 21K Sep 20 14:38 make.macros - -rw-r--r-- 1 user grp 1002 Sep 20 14:38 make.rules - -rw-r--r-- 1 user grp 1.8K Sep 20 14:38 makefile - drwxr-xr-x 4 user grp 4.0K Sep 20 14:13 test/ - - - And let's further say that you want to link all of the files into the main /fix - subdirectory that contains all the subdirectories that in turn contain all the - coefficient files. - - Currently, the /fix directory contains, - - local/REL-2.1 : ls -lhF fix - total 40K - drwxr-xr-x 4 user grp 4.0K Sep 20 14:30 AerosolCoeff/ - drwxr-xr-x 4 user grp 4.0K Sep 20 14:30 CloudCoeff/ - drwxr-xr-x 12 user grp 4.0K Sep 20 14:09 EmisCoeff/ - drwxr-xr-x 4 user grp 4.0K Sep 20 14:30 SpcCoeff/ - drwxr-xr-x 4 user grp 4.0K Sep 20 14:09 TauCoeff/ - - If you invoke the script like so - - local/REL-2.1 : link_coeffs.sh fix fix - - the output will look like - - $Revision$ $LastChangedDate: 2012-09-24 13:50:50 -0400 (Mon, 24 Sep 2012) $ - Mon Sep 24 16:47:40 EDT 2012 - Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov - - Linking coefficient files from root source directory, - /usr1/user/local/REL-2.1/fix - to destination directory, - fix - - ...linking sensor-independent coefficient files... - linkfiles.sh: Searching for files to link... - - ...linking SpcCoeff coefficient files... - linkfiles.sh: Searching for files to link... - - ...linking TauCoeff coefficient files... - linkfiles.sh: Searching for files to link... - - If you now inspect the /fix subdirectory you should see something like: - - local/REL-2.1 : ls -lhF fix | more - total 8.3M - drwxr-xr-x 4 user grp 4.0K Sep 20 14:30 AerosolCoeff/ - lrwxrwxrwx 1 user grp 71 Sep 24 16:47 AerosolCoeff.bin -> .../local/REL-2.1/fix/AerosolCoeff/Big_Endian/AerosolCoeff.bin - drwxr-xr-x 4 user grp 4.0K Sep 20 14:30 CloudCoeff/ - lrwxrwxrwx 1 user grp 67 Sep 24 16:47 CloudCoeff.bin -> .../local/REL-2.1/fix/CloudCoeff/Big_Endian/CloudCoeff.bin - drwxr-xr-x 12 user grp 4.0K Sep 20 14:09 EmisCoeff/ - lrwxrwxrwx 1 user grp 90 Sep 24 16:47 FASTEM4.MWwater.EmisCoeff.bin -> .../local/REL-2.1/fix/EmisCoeff/MW_Water/Big_Endian/FASTEM4.MWwater.EmisCoeff.bin - lrwxrwxrwx 1 user grp 90 Sep 24 16:47 FASTEM5.MWwater.EmisCoeff.bin -> .../local/REL-2.1/fix/EmisCoeff/MW_Water/Big_Endian/FASTEM5.MWwater.EmisCoeff.bin - lrwxrwxrwx 1 user grp 96 Sep 24 16:47 IGBP.IRland.EmisCoeff.bin -> .../local/REL-2.1/fix/EmisCoeff/IR_Land/SEcategory/Big_Endian/IGBP.IRland.EmisCoeff.bin - ...etc... - lrwxrwxrwx 1 user grp 79 Sep 24 16:47 iasi616_metop-b.SpcCoeff.bin -> .../local/REL-2.1/fix/SpcCoeff/Big_Endian/iasi616_metop-b.SpcCoeff.bin - lrwxrwxrwx 1 user grp 84 Sep 24 16:47 iasi616_metop-b.TauCoeff.bin -> .../local/REL-2.1/fix/TauCoeff/ODPS/Big_Endian/iasi616_metop-b.TauCoeff.bin - ...etc... - - where all of the files are linked in. - - If you also wanted to be able to use the visible sensor coefficients, you will need to run - the script a second time specifying the "-a" command line option to select the ODAS files - for those instruments, e.g. - - local/REL-2.1 : link_coeffs.sh -a fix fix - - $Revision$ $LastChangedDate: 2012-09-24 13:50:50 -0400 (Mon, 24 Sep 2012) $ - Mon Sep 24 16:55:53 EDT 2012 - Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov - - Linking coefficient files from root source directory, - /usr1/user/local/REL-2.1/fix - to destination directory, - fix - - ...linking sensor-independent coefficient files... - linkfiles.sh: Searching for files to link... - linkfiles.sh: All required files are present so nothing to do. Exiting. - - ...linking SpcCoeff coefficient files... - linkfiles.sh: Searching for files to link... - linkfiles.sh: All required files are present so nothing to do. Exiting. - - ...linking TauCoeff coefficient files... - linkfiles.sh: Searching for files to link... - - where you will see the visible sensor files: - - local/REL-2.1 : ls -lhF fix | grep "ODAS" - lrwxrwxrwx 1 user grp 77 Sep 24 16:55 v.abi_gr.TauCoeff.bin -> .../local/REL-2.1/fix/TauCoeff/ODAS/Big_Endian/v.abi_gr.TauCoeff.bin - lrwxrwxrwx 1 user grp 85 Sep 24 16:55 v.avhrr3_metop-a.TauCoeff.bin -> .../local/REL-2.1/fix/TauCoeff/ODAS/Big_Endian/v.avhrr3_metop-a.TauCoeff.bin - ...etc... - - - Note that the script will not link "over" already existing links in the directory. that's - what the - - linkfiles.sh: All required files are present so nothing to do. Exiting. - - output means. - - -4) FEEDBACK AND CONTACT INFO ----------------------------- - That's it. Any questions or bug reports or suggestions for improvement/features - can be sent to CRTM Support at - - ncep.list.emc.jcsda_crtm.support@noaa.gov diff --git a/scripts/shell/Utility/crtm_cleanup.sh b/scripts/shell/Utility/crtm_cleanup.sh deleted file mode 100755 index 5ec94ed..0000000 --- a/scripts/shell/Utility/crtm_cleanup.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash - -# Script to clean up a CRTM working copy, removing the library build products -# as well as the regression builds and results. -# -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" -} - -usage() -{ - echo - echo " Usage: crtm_cleanup.sh [-hx]" - echo - echo " Script to clean up a CRTM working copy, removing the library build" - echo " products as well as the regression builds and results." - echo - echo " Options:" - echo " -h" - echo " Print this message and exit" - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - -info_message() -{ - MESSAGE=$1 - echo " ${SCRIPT_NAME}(INFORMATION): ${MESSAGE}" -} - - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Setup -SCRIPT_NAME=`basename $0` -# ...Definitions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -REMOVE="rm -fr" - - -# Parse the command line options -while getopts :hx OPTVAL; do - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break ;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS} ;; - x) script_id; set -x ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# ...Remove the options processed -shift $((OPTIND - 1)) -# ...Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) : ;; - # Invalid option - ?) usage - error_message "Invalid option '-${OPTARG}'" - exit ${FAILURE} ;; -esac - - -# ================= -# Start the cleanup -# ================= - -CURRENT_DIR=${PWD} - -# Determine the CRTM version -CRTM_VERSION=`tr -d "'" < ${CRTM_SOURCE_ROOT}/CRTM_Version.inc` -CRTM_LIB_DIR="crtm_${CRTM_VERSION}" - - -# Clean up the library -cd ${CRTM_SOURCE_ROOT}/Build -if [ $? -ne 0 ]; then - error_message "Error changing to CRTM build directory, ${CRTM_SOURCE_ROOT}/Build" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi -# ...Use makefile if it exists -if [ -f Makefile ]; then - # Uninstall library - make uninstall - if [ $? -ne 0 ]; then - error_message "Error uninstalling CRTM library" - cd ${CURRENT_DIR}; exit ${FAILURE} - fi - # Clean up build products - make distclean - if [ $? -ne 0 ]; then - error_message "Error cleaning up CRTM library build products" - cd ${CURRENT_DIR}; exit ${FAILURE} - fi -# ...Otherwise just delete the directory -elif [ -d ${CRTM_LIB_DIR} ]; then - # Explicitly delete the library directory - ${REMOVE} ${CRTM_LIB_DIR} - if [ $? -ne 0 ]; then - error_message "Error deleting the CRTM library directory, ${CRTM_LIB_DIR}" - cd ${CURRENT_DIR}; exit ${FAILURE} - fi -else - info_message "No library build makefile or ${CRTM_LIB_DIR} directory. Nothing to cleanup!" -fi - - -# Clean up the source links -cd ${CRTM_SOURCE_ROOT} -if [ $? -ne 0 ]; then - error_message "Error changing to CRTM source directory, ${CRTM_SOURCE_ROOT}" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi -make realclean -if [ $? -ne 0 ]; then - error_message "Error cleaning up CRTM library source links" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - - -# Clean up the regression build -CRTM_REGTEST_DIR="${CRTM_TEST_ROOT}/Main/regression_tests" -cd ${CRTM_REGTEST_DIR} -if [ $? -ne 0 ]; then - error_message "Error changing to CRTM regression test directory, ${CRTM_REGTEST_DIR}" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -# ...Use makefile if it exists -if [ -f Makefile ]; then - make realclean - if [ $? -ne 0 ]; then - error_message "Error cleaning up CRTM regression test build products" - cd ${CURRENT_DIR}; exit ${FAILURE} - fi -else - info_message "No regression test makefile. Nothing to cleanup!" -fi - - -# Return to original directory -cd ${CURRENT_DIR} diff --git a/scripts/shell/Utility/crtm_env.sh b/scripts/shell/Utility/crtm_env.sh deleted file mode 100755 index 814fc92..0000000 --- a/scripts/shell/Utility/crtm_env.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/bash - -# Script to display the values of the CRTM environment variables -# in the current session. -# -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate: $' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" -} - -usage() -{ - echo - echo " Usage: crtm_env.sh [-hx] [-o [file]]" - echo - echo " Script to display the values of the CRTM environment variables" - echo " in the current session." - echo - echo " The CRTM envars displayed are:" - echo " CRTM_ROOT : The CRTM working copy root directory" - echo " CRTM_SOURCE_ROOT : The CRTM source code subdirectory" - echo " CRTM_FIXFILE_ROOT : The CRTM fixed file subdirectory" - echo " CRTM_TEST_ROOT : The CRTM test code subdirectory" - echo " CRTM_EXTERNALS_ROOT : The CRTM externals subdirectory" - echo " CRTM_SCRIPTS_ROOT : The CRTM scripts subdirectory" - echo " CRTM_VALIDATION_ROOT: The CRTM validation subdirectory" - echo " CRTM_CONFIG_ROOT : The CRTM configuration subdirectory" - echo - echo " NOTE: These envars are used in various scripts and makefiles within" - echo " the CRTM repository heirarchy so if you are going to change" - echo " them, make sure you know what you are doing!" - echo - echo - echo " Options:" - echo " -h" - echo " Print this message and exit" - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " -o [file]" - echo " Output envar settings to file for export. If no file is" - echo ' specified, the default is $HOME/.crtm_env' - echo -} - - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - -info_message() -{ - MESSAGE=$1 - echo " ${SCRIPT_NAME}(INFORMATION): ${MESSAGE}" -} - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $BASH_SOURCE) -# ...Version number for output file -VERSION_ID='$Revision$' -# ...Definitions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -# ...Defaults -OUTPUT=${FALSE} -OUTPUT_FILE_DEFAULT="${HOME}/.crtm_env" - - -# Parse the command line options -while getopts :hxo: OPTVAL; do - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break ;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS} ;; - x) script_id; set -x ;; - o) OUTPUT=${TRUE}; OUTPUT_FILE=${OPTARG} ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# ...Remove the options processed -shift $((OPTIND - 1)) -# ...Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) : ;; - # Valid option, but missing argument - o) OUTPUT=${TRUE} - OUTPUT_FILE=${OUTPUT_FILE_DEFAULT} ;; - # Invalid option - ?) usage - error_message "Invalid option '-${OPTARG}'" - exit ${FAILURE} ;; -esac - - -# Create the output file -if [ ${OUTPUT} -eq ${TRUE} ]; then - echo "Creating output file ${OUTPUT_FILE}..."; echo - echo "#" > ${OUTPUT_FILE} - echo "# This file created by ${SCRIPT_NAME} ${VERSION_ID}" >> ${OUTPUT_FILE} - echo "#" >> ${OUTPUT_FILE} - echo "# CRTM environment variables" >> ${OUTPUT_FILE} - echo "#" >> ${OUTPUT_FILE} -fi - - -# Display the envars -ENVAR_LIST="CRTM_ROOT \ - CRTM_SOURCE_ROOT \ - CRTM_FIXFILE_ROOT \ - CRTM_TEST_ROOT \ - CRTM_EXTERNALS_ROOT \ - CRTM_SCRIPTS_ROOT \ - CRTM_VALIDATION_ROOT \ - CRTM_CONFIG_ROOT" -for ENVAR in ${ENVAR_LIST}; do - SETTING=`env | grep $ENVAR=` - if [ -n "${SETTING}" ]; then - echo ${SETTING} - if [ ${OUTPUT} -eq ${TRUE} ]; then - echo "export ${SETTING}" >> ${OUTPUT_FILE} - fi - fi -done diff --git a/scripts/shell/Utility/crtm_rebuild.sh b/scripts/shell/Utility/crtm_rebuild.sh deleted file mode 100755 index 560c158..0000000 --- a/scripts/shell/Utility/crtm_rebuild.sh +++ /dev/null @@ -1,176 +0,0 @@ -#!/bin/bash - -# Script to perform a clean rebuild of the CRTM library -# -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" -} - -usage() -{ - echo - echo " Usage: crtm_rerebuild.sh [-dhx] [-c compiler]" - echo - echo " Script to perform a clean rebuild of the CRTM library." - echo - echo " Options:" - echo " -d" - echo " Use DEBUG compilation switches. Default is PRODUCTION." - echo - echo " -h" - echo " Print this message" - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " -c compiler" - echo " Use this option to specify the compiler. Valid compilers are:" - echo " * gfortran [DEFAULT]" - echo " * ifort" - echo " * pgf95" - echo " * g95" - echo " * xlf2003" - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - -compiler_exists () { - command -v $1 >/dev/null 2>&1 -} - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Setup -SCRIPT_NAME=`basename $0` -# ...Defintiions -SUCCESS=0 -FAILURE=1 -# ..Define defaults -DEBUG="" -COMPILER=${FC} -echo "Compiler:" $COMPILER - - -# Parse command line options -while getopts :dhxc: OPTVAL; do - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - d) DEBUG="-debug" ;; - h) usage | more; exit ${SUCCESS} ;; - x) script_id; set -x ;; - c) COMPILER="${OPTARG}" ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# ...Remove the options processed -shift $((OPTIND - 1)) -# ...Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed. - \?) : ;; - # Valid options, but missing arguments - c) usage - error_message "'-${OPTVAL}' option requires an argument" - exit ${FAILURE} ;; - # Invalid option - ?) usage - error_message "Invalid option '-${OPTARG}'" - exit ${FAILURE} ;; -esac - - -# Check the compiler option -compiler_exists ${COMPILER} -if [ $? -ne 0 ]; then - error_message "Cannot find ${COMPILER} compiler" - exit ${FAILURE} -fi - - -# ================= -# Start the process -# ================= - -CURRENT_DIR=${PWD} - -cd ${CRTM_SOURCE_ROOT} -if [ $? -ne 0 ]; then - error_message "Error changing to CRTM source directory, ${CRTM_SOURCE_ROOT}" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make create_links -if [ $? -ne 0 ]; then - error_message "Error linking in source code and data" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -cd Build -if [ $? -ne 0 ]; then - error_message "Error changing to CRTM build directory" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -. config-setup/${COMPILER}${DEBUG}.setup - -NETCDF_DIR=${NETCDF} ./configure --prefix=${PWD} -if [ $? -ne 0 ]; then - error_message "Error configuring the CRTM library build" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make uninstall -if [ $? -ne 0 ]; then - error_message "Error uninstalling prior to CRTM library build" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make clean -if [ $? -ne 0 ]; then - error_message "Error cleaning prior to CRTM library build" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make -if [ $? -ne 0 ]; then - error_message "Error building the CRTM library" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make check -if [ $? -ne 0 ]; then - error_message "Error checking the CRTM library build" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -make install -if [ $? -ne 0 ]; then - error_message "Error installing the CRTM library" - cd ${CURRENT_DIR}; exit ${FAILURE} -fi - -# Return to original directory -cd ${CURRENT_DIR} diff --git a/scripts/shell/Utility/endian_wrapper.sh b/scripts/shell/Utility/endian_wrapper.sh deleted file mode 100755 index fd4921f..0000000 --- a/scripts/shell/Utility/endian_wrapper.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh - -# $Id$ - -usage() -{ - echo " Usage: endian_wrapper -l|-b [-h] exe_file" - echo - echo " Run any Fortran executable for either little- or big-endian" - echo " unformatted file access regardless of how the executable was" - echo " originally built." - echo - echo " l Read and/or write little-endian binary output files" - echo - echo " b Read and/or write big-endian binary output files" - echo - echo " h Print this message and exit" - echo - echo " Note the endian-ness option is only setup for the following" - echo " compilers that allow for run-time conversion via environment" - echo " variables:" - echo " - AIX xlf" - echo " - Linux gfortran" - echo " - Linux ifort (Intel)" - echo " - Linux g95" - echo -} - -error_message() -{ - MESSAGE=$1 - echo; echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" -} - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Define defaults -SCRIPT_NAME="`basename $0`" -ENDIAN_TYPE="NONE" -OVERWRITE="NO" -REMOVE="rm -f" - - -# Parse command line options -while getopts :hlb OPTVAL; do - - # If option argument looks like another option exit the loop - case ${OPTARG} in - -*) break;; - esac - - # Parse the valid options here - case ${OPTVAL} in - l) ENDIAN_TYPE="little";; - b) ENDIAN_TYPE="big";; - h) usage; exit 0;; - \?) OPTVAL=${OPTARG}; break;; - esac -done - -# Remove the options processed -shift $((OPTIND - 1)) - -# Now output invalidities based on OPTVAL -# Need to do this as getopts does not handle -# the situations where an option is passed -# as an argument to another option. -case ${OPTVAL} in - - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) if [ $# -lt 1 ]; then - usage - error_message "Missing 'exe_file' argument" - exit 1 - fi;; - - # Invalid option - ?) usage - error_message " Invalid option '-${OPTARG}'" - exit 1;; -esac - -# Assign, and check, executable argument -INPUT_FILE=$1 -EXE_FILE="`which ${INPUT_FILE}`" -if [ ! -f "${EXE_FILE}" ]; then - error_message "${INPUT_FILE} is not a regular file" - exit 2 -fi -if [ ! -x "${EXE_FILE}" ]; then - error_message "${INPUT_FILE} is not executable" - exit 2 -fi - -# Check endian type for run time options -# ...Save the current envar options -XLFRTEOPTS_SAVE=${XLFRTEOPTS} -GFORTRAN_CONVERT_UNIT_SAVE=${GFORTRAN_CONVERT_UNIT} -F_UFMTENDIAN_SAVE=${F_UFMTENDIAN} -G95_ENDIAN_SAVE=${G95_ENDIAN} -# ...Set the non-switchable envars -case ${ENDIAN_TYPE} in - "little") export XLFRTEOPTS="ufmt_littleendian=-100";; - "big") export XLFRTEOPTS="";; - *) usage; error_message "Must specify an endian type, -l or -b" - exit 3;; -esac -# ...Switchable envars -export GFORTRAN_CONVERT_UNIT="${ENDIAN_TYPE}_endian" -export F_UFMTENDIAN="${ENDIAN_TYPE}" -export G95_ENDIAN="${ENDIAN_TYPE}" - - -# Assign processing parameters -LOG_FILE="${EXE_FILE}.${ENDIAN_TYPE}_endian.log" - - -# Run the executable -${EXE_FILE} - - -# Restore the run-time option environment variables -export XLFRTEOPTS="${XLFRTEOPTS_SAVE}" -export GFORTRAN_CONVERT_UNIT="${GFORTRAN_CONVERT_UNIT_SAVE}" -export F_UFMTENDIAN="${F_UFMTENDIAN_SAVE}" -export G95_ENDIAN="${G95_ENDIAN_SAVE}" diff --git a/scripts/shell/Utility/link_atmprofile.sh b/scripts/shell/Utility/link_atmprofile.sh deleted file mode 100755 index 41c88bd..0000000 --- a/scripts/shell/Utility/link_atmprofile.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/sh - -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" - echo -} - -usage() -{ - echo - echo "Usage: link_atmprofile.sh [-hx] [atm_id]" - echo - echo " Script to link in the netCDF atmospheric profile datafile from the" - echo " CRTM fixfile repository." - echo - echo " The valid atmospheric profile set identifiers are:" - echo " * UMBC48 : The UMBC 48-profile data set." - echo " * ECMWF52: The ECMWF 52-profile data set." - echo " * ECMWF83: The ECMWF 83-profile data set. [DEFAULT]" - echo " * ECMWF5K: The ECMWF 5000-profile data set." - echo " * CIMSS32: The CIMSS 32-profile data set." - echo " * Model6 : The Model climatology 6-profile data set." - echo ' If the optional [atm_id] argument is not specified, the "ECMWF83" profile' - echo " set datafile is linked in by default." - echo - echo - echo " Options:" - echo " -h" - echo " Print this message." - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " Optional arguments:" - echo " atm_id" - echo " The atmospheric profile ids identifying the profile data set to link in." - echo ' If not specified, the "ECMWF83" data set is linked by default.' - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $0) -# ...Defintiions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -DEFAULT_ID="ECMWF83" -VALID_IDS="${DEFAULT_ID} UMBC48 ECMWF52 ECMWF5K CIMSS32 Model6" -# ...Define helper script, and make sure it can be found -LINK_SCRIPT="linkfiles.sh" -type ${LINK_SCRIPT} >/dev/null 2>&1 || { - error_message "Cannot find ${LINK_SCRIPT} helper script. Exiting..." - exit ${FAILURE} -} - - -# Parse the command line options -while getopts :hx OPTVAL; do - # If option argument looks like another option exit the loop - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS};; - x) script_id; set -x;; - \?) OPTVAL=${OPTARG}; break;; - esac -done -# Remove the options processed -shift $(expr ${OPTIND} - 1) -# Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) break;; - # Invalid option - ?) usage; error_message " Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Check that the mandatory envar is defined -if [ -z "${CRTM_FIXFILE_ROOT}" ]; then - error_message "CRTM_FIXFILE_ROOT envar is not defined." - exit ${FAILURE} -fi - - -# Determine the file to link -# ...Set the default id -ATMPROFILE_ID=${DEFAULT_ID} -# ...Was one specified? -if [ $# -ne 0 ]; then - ATMPROFILE_ID=$1 -fi -# ...Is the id valid? -NO_MATCH=${TRUE} -for ID in ${VALID_IDS}; do - if [ "${ID}" = "${ATMPROFILE_ID}" ]; then - NO_MATCH=${FALSE} - break - fi -done -if [ ${NO_MATCH} -eq ${TRUE} ]; then - error_message "AtmProfile id, ${ATMPROFILE_ID}, is not recognised." - exit ${FAILURE} -fi -# ...Construct the filename -ATMPROFILE_FILE="${ATMPROFILE_ID}.AtmProfile.nc" - - -# Output some user info -echo; echo "${SCRIPT_NAME}: Linking in the file ${ATMPROFILE_FILE}"; echo - - -# Link in the file -if [ ! -f ${ATMPROFILE_FILE} ]; then - ${LINK_SCRIPT} -q ${CRTM_FIXFILE_ROOT} ${ATMPROFILE_FILE} - if [ $? -ne 0 ]; then - error_message "Error occuring linking ${ATMPROFILE_FILE} to ${PWD}/${ATMPROFILE_FILE}" - exit ${FAILURE} - fi -else - error_message "${ATMPROFILE_FILE} file already exists in this directory!" - exit ${FAILURE} -fi - - -# Done -exit ${SUCCESS} - diff --git a/scripts/shell/Utility/link_coeffs.sh b/scripts/shell/Utility/link_coeffs.sh deleted file mode 100755 index 783f290..0000000 --- a/scripts/shell/Utility/link_coeffs.sh +++ /dev/null @@ -1,262 +0,0 @@ -#!/bin/sh - -# Link script to link in CRTM release fixfiles into a single directory. -# -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" -} - -usage() -{ - echo - echo " Usage: link_coeffs.sh [-achx] [-t file-type] source-dir dest-dir [sensor_id1 sensor id2 ... sensor_idN]" - echo - echo " Link in CRTM release fixfiles into a single directory." - echo - echo " Options:" - echo " -a" - echo " Link in ODAS TauCoeff files. ODPS is the default." - echo - echo " Note: Currently there are no ODPS TauCoeff files" - echo " for visible sensors (we're working on it)." - echo - echo " -c" - echo " Perform additional special case linking for the AIRS 281 and" - echo " CrIS 399 channel subset datafiles for use with the GSI satinfo" - echo " file. The naming convention is:" - echo " airs281SUBSET_aqua.[Spc|Tau]Coeff.* -> airs281_aqua.[Spc|Tau]Coeff.*" - echo " cris_npp.[Spc|Tau]Coeff.* -> cris399_aqua.[Spc|Tau]Coeff.*" - echo - echo " -h" - echo " Print this message" - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " -t file-type" - echo " Use this option to specify the type of coefficient files to link." - echo " Valid targets are:" - echo " * big-endian [DEFAULT]" - echo " * little-endian" - echo " * netcdf" - echo - echo " Arguments:" - echo " source-dir" - echo " The /fix directory location of the CRTM release." - echo " This directory must already exist." - echo - echo " dest-dir" - echo " The directory into which the coefficients will be linked." - echo " If this directory does not exist, it is created." - echo - echo " Optional arguments:" - echo " sensor_id1 sensor id2 ... sensor_idN" - echo " A list of sensor ids identifying the particular sensors for which" - echo " the SpcCoeff and TauCoeff files are required. If not specified, all" - echo " available sensor files are linked." - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Setup -SCRIPT_NAME=`basename $0` -# ...Defintiions -SUCCESS=0 -FAILURE=1 -# ..Define defaults -FILE_TYPE="big-endian" -TAUCOEFF_TYPE="ODPS" -ALL_SENSORS="yes" -SPECIAL_CASE="no" -# ...Define commands -LINK="ln -sf" -# ...Define helper script, and make sure it can be found -LINK_SCRIPT="linkfiles.sh" -type ${LINK_SCRIPT} >/dev/null 2>&1 || { - error_message "Cannot find ${LINK_SCRIPT} helper script. Exiting..." - exit ${FAILURE} -} - - - -# Parse command line options -while getopts :achxt: OPTVAL; do - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - a) TAUCOEFF_TYPE="ODAS" ;; - c) SPECIAL_CASE="yes";; - h) usage | more; exit ${SUCCESS} ;; - x) script_id; set -x ;; - t) FILE_TYPE="${OPTARG}" ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# ...Remove the options processed -shift $((OPTIND - 1)) -# ...Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed. - # So, check for presence of mandatory arguments. - \?) if [ $# -lt 2 ]; then - usage - error_message "Missing source-dir and/or dest-dir arguments" - exit ${FAILURE} - fi;; - # Valid options, but missing arguments - t) usage; error_message "'-${OPTVAL}' option requires an argument"; exit ${FAILURE} ;; - # Invalid option - ?) usage; error_message "Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Check the file type option -case ${FILE_TYPE} in - "big-endian") FILE_DIR="Big_Endian" ; FILE_EXT="bin" ;; - "little-endian") FILE_DIR="Little_Endian"; FILE_EXT="bin" ;; - "netcdf") FILE_DIR="netCDF" ; FILE_EXT="nc" ;; - "netcdf4") FILE_DIR="netCDF" ; FILE_EXT="nc4" ;; - *) usage; error_message "Invalid file type option argument"; exit ${FAILURE} ;; -esac -# ...Define the sensor independent coefficient files. -COMMON_COEFF_FILES="AerosolCoeff.${FILE_EXT} \ -AerosolCoeff.CMAQ.${FILE_EXT} \ -AerosolCoeff.GOCART-GEOS5.${FILE_EXT} \ -AerosolCoeff.NAAPS.${FILE_EXT} \ -IR.CloudCoeff.${FILE_EXT} \ -MW.CloudCoeff.${FILE_EXT} \ -CloudCoeff.${FILE_EXT} \ -FASTEM4.MWwater.EmisCoeff.${FILE_EXT} \ -FASTEM5.MWwater.EmisCoeff.${FILE_EXT} \ -FASTEM6.MWwater.EmisCoeff.${FILE_EXT} \ -Nalli.IRwater.EmisCoeff.${FILE_EXT} \ -WuSmith.IRwater.EmisCoeff.${FILE_EXT} \ -NPOESS.IRice.EmisCoeff.${FILE_EXT} \ -NPOESS.IRland.EmisCoeff.${FILE_EXT} \ -NPOESS.IRsnow.EmisCoeff.${FILE_EXT} \ -NPOESS.VISice.EmisCoeff.${FILE_EXT} \ -NPOESS.VISland.EmisCoeff.${FILE_EXT} \ -NPOESS.VISsnow.EmisCoeff.${FILE_EXT} \ -NPOESS.VISwater.EmisCoeff.${FILE_EXT} \ -IGBP.IRland.EmisCoeff.${FILE_EXT} \ -IGBP.VISland.EmisCoeff.${FILE_EXT} \ -USGS.IRland.EmisCoeff.${FILE_EXT} \ -USGS.VISland.EmisCoeff.${FILE_EXT}" - - -# Transfer, and remove, the arguments -SOURCE_DIR=$1 -DEST_DIR=$2 -shift 2 - - -# Check if sensor ids have been specified -if [ $# -ne 0 ]; then - SENSOR_ID_LIST="$*" - ALL_SENSORS="no" -fi - - -# Check the directory arguments - -# ...Ensure the source directory exists -if [ ! -d ${SOURCE_DIR} ]; then - usage - error_message "Source directory '${SOURCE_DIR}' does not exist. Exiting." - exit ${FAILURE} -fi - -# ...Get the absolute path to the source directory -CURRENT_DIR=${PWD} -cd ${SOURCE_DIR}; SOURCE_DIR=`pwd -L`; cd ${CURRENT_DIR} - -# ...Create the destination directory if necessary -if [ ! -d ${DEST_DIR} ]; then - mkdir ${DEST_DIR} - if [ $? -ne ${SUCCESS} ]; then - error_message "Error creating destination directory '${DEST_DIR}'. Exiting." - exit ${FAILURE} - fi -fi - - - -# Begin the linking process -echo -echo "Linking coefficient files from root source directory," -echo " ${SOURCE_DIR}" -echo "to destination directory," -echo " ${DEST_DIR}" - -# Go to destination -cd ${DEST_DIR} -if [ $? -ne ${SUCCESS} ]; then - error_message "Error cd'ing to destination directory '${DEST_DIR}'. Exiting." - exit ${FAILURE} -fi - - -# Link common files -echo; echo "...linking ${FILE_TYPE} sensor-independent coefficient files..." -${LINK_SCRIPT} -s -d ${FILE_DIR} ${SOURCE_DIR} ${COMMON_COEFF_FILES} - - -# Link the SpcCoeff files -echo; echo "...linking ${FILE_TYPE} SpcCoeff coefficient files..." -if [ "${ALL_SENSORS}" = "yes" ]; then - SPCCOEFF_FILES=`ls ${SOURCE_DIR}/SpcCoeff/${FILE_DIR}` -else - for SENSOR_ID in ${SENSOR_ID_LIST}; do - SPCCOEFF_FILES="${SPCCOEFF_FILES} ${SENSOR_ID}.SpcCoeff.${FILE_EXT}" - done -fi -${LINK_SCRIPT} -s -d ${FILE_DIR} ${SOURCE_DIR} ${SPCCOEFF_FILES} -# ...Perform special case linking if required -if [ "${SPECIAL_CASE}" = "yes" ]; then - ${LINK} airs281_aqua.SpcCoeff.${FILE_EXT} airs281SUBSET_aqua.SpcCoeff.${FILE_EXT} - ${LINK} cris399_npp.SpcCoeff.${FILE_EXT} cris_npp.SpcCoeff.${FILE_EXT} -fi - -# Link the TauCoeff files -echo; echo "...linking ${FILE_TYPE} TauCoeff coefficient files..." -if [ "${ALL_SENSORS}" = "yes" ]; then - TAUCOEFF_FILES=`ls ${SOURCE_DIR}/TauCoeff/${TAUCOEFF_TYPE}/${FILE_DIR}` -else - for SENSOR_ID in ${SENSOR_ID_LIST}; do - TAUCOEFF_FILES="${TAUCOEFF_FILES} ${SENSOR_ID}.TauCoeff.${FILE_EXT}" - done -fi -${LINK_SCRIPT} -s -d ${FILE_DIR} ${SOURCE_DIR}/TauCoeff/${TAUCOEFF_TYPE} ${TAUCOEFF_FILES} -# ...Perform special case linking if required -if [ "${SPECIAL_CASE}" = "yes" ]; then - ${LINK} airs281_aqua.TauCoeff.${FILE_EXT} airs281SUBSET_aqua.TauCoeff.${FILE_EXT} - ${LINK} cris399_npp.TauCoeff.${FILE_EXT} cris_npp.TauCoeff.${FILE_EXT} -fi - -# Return to original directory -cd ${CURRENT_DIR} diff --git a/scripts/shell/Utility/link_sensorinfo.sh b/scripts/shell/Utility/link_sensorinfo.sh deleted file mode 100755 index 956dd0b..0000000 --- a/scripts/shell/Utility/link_sensorinfo.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/sh - -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" - echo -} - - -usage() -{ - echo - echo "Usage: link_sensorinfo.sh [-hx] [file]" - echo - echo " Script to link in the master sensor information file, SensorInfo, from" - echo " the CRTM fixfile repository." - echo - echo ' If the optional [file] argument is not specified, the "SensorInfo" datafile' - echo " is linked in by default." - echo - echo - echo " Options:" - echo " -h" - echo " Print this message." - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " Optional arguments:" - echo " file" - echo " The particular sensor information to be linked. If not specified," - echo ' the "SensorInfo" file is linked by default.' - echo echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $0) -# ...Defintiions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -DEFAULT_FILE="SensorInfo" -# ...Define helper script, and make sure it can be found -LINK_SCRIPT="linkfiles.sh" -type ${LINK_SCRIPT} >/dev/null 2>&1 || { - error_message "Cannot find ${LINK_SCRIPT} helper script. Exiting..." - exit ${FAILURE} -} - - -# Parse the command line options -while getopts :hx OPTVAL; do - # If option argument looks like another option exit the loop - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS};; - x) script_id; set -x;; - \?) OPTVAL=${OPTARG}; break;; - esac -done -# Remove the options processed -shift $(expr ${OPTIND} - 1) -# Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) break;; - # Invalid option - ?) usage; error_message " Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Check that the mandatory envar is defined -if [ -z "${CRTM_FIXFILE_ROOT}" ]; then - error_message "CRTM_FIXFILE_ROOT envar is not defined." - exit ${FAILURE} -fi - - -# Determine the file to link -# ...Set the default -SENSORINFO_FILE=${DEFAULT_FILE} -# ...Was one specified? -if [ $# -ne 0 ]; then - SENSORINFO_FILE=$1 -fi - - -# Output some user info -echo; echo "${SCRIPT_NAME}: Linking in the file ${SENSORINFO_FILE}"; echo - - -# Link in the file -if [ ! -f ${SENSORINFO_FILE} ]; then - ${LINK_SCRIPT} -q ${CRTM_FIXFILE_ROOT} ${SENSORINFO_FILE} - if [ $? -ne 0 ]; then - error_message "Error occuring linking ${SENSORINFO_FILE} to ${PWD}/${SENSORINFO_FILE}" - exit ${FAILURE} - fi -else - error_message "${SENSORINFO_FILE} file already exists in this directory!" - exit ${FAILURE} -fi - - -# Done -exit ${SUCCESS} - diff --git a/scripts/shell/Utility/link_solar.sh b/scripts/shell/Utility/link_solar.sh deleted file mode 100755 index 93765b5..0000000 --- a/scripts/shell/Utility/link_solar.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh - -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" - echo -} - -usage() -{ - echo - echo "Usage: link_solar.sh [-hx] [file]" - echo - echo " Script to link in the netCDF solar irradiance datafile from the" - echo " CRTM fixfile repository for creation of the instrument SpcCoeff" - echo " datafiles." - echo - echo " The available datafiles for linking are:" - echo " * dF_0.1000.Solar.nc [DEFAULT]" - echo " * dF_0.0025.Solar.nc" - echo " * dF_0.0010.Solar.nc" - echo ' If the optional [file] argument is not specified, the "dF_0.1000.Solar.nc"' - echo " datafile is linked in by default." - echo - echo - echo " Options:" - echo " -h" - echo " Print this message." - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " Optional arguments:" - echo " file" - echo " The particular solar datafile, from the list above, to be linked." - echo ' If not specified, the "dF_0.1000.Solar.nc" file is linked by default.' - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $0) -# ...Defintiions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -DEFAULT_FILE="dF_0.1000.Solar.nc" -VALID_FILES="${DEFAULT_FILE} dF_0.0025.Solar.nc dF_0.0010.Solar.nc" -# ...Define helper script, and make sure it can be found -LINK_SCRIPT="linkfiles.sh" -type ${LINK_SCRIPT} >/dev/null 2>&1 || { - error_message "Cannot find ${LINK_SCRIPT} helper script. Exiting..." - exit ${FAILURE} -} - - -# Parse the command line options -while getopts :hx OPTVAL; do - # If option argument looks like another option exit the loop - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS} ;; - x) script_id; set -x ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# Remove the options processed -shift $(expr ${OPTIND} - 1) -# Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) : ;; - # Invalid option - ?) usage; error_message " Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Check that the mandatory envar is defined -if [ -z "${CRTM_FIXFILE_ROOT}" ]; then - error_message "CRTM_FIXFILE_ROOT envar is not defined." - exit ${FAILURE} -fi - - -# Determine the file to link -# ...Set the default -SOLAR_FILE=${DEFAULT_FILE} -# ...Was one specified? -if [ $# -ne 0 ]; then - SOLAR_FILE=$1 -fi -# ...Is the filename valid? -NO_MATCH=${TRUE} -for FILE in ${VALID_FILES}; do - if [ "${FILE}" = "${SOLAR_FILE}" ]; then - NO_MATCH=${FALSE} - break - fi -done -if [ ${NO_MATCH} -eq ${TRUE} ]; then - error_message "Solar irradiance datafile, ${SOLAR_FILE}, is not recognised." - exit ${FAILURE} -fi - - -# Output some user info -echo; echo "${SCRIPT_NAME}: Linking in the file ${SOLAR_FILE}"; echo - - -# Link in the file -if [ ! -f ${SOLAR_FILE} ]; then - ${LINK_SCRIPT} -q ${CRTM_FIXFILE_ROOT} ${SOLAR_FILE} - if [ $? -ne 0 ]; then - error_message "Error occuring linking ${SOLAR_FILE} to ${PWD}/${SOLAR_FILE}" - exit ${FAILURE} - fi -fi - - -# Done -exit ${SUCCESS} - diff --git a/scripts/shell/Utility/link_srf.sh b/scripts/shell/Utility/link_srf.sh deleted file mode 100755 index 88a3499..0000000 --- a/scripts/shell/Utility/link_srf.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh - -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" - echo -} - -usage() -{ - echo - echo "Usage: link_srf.sh [-hx] sensor_id [sensor_id2 sensor_id3 ... sensor_idN]" - echo - echo " Script to link in the spectral response function (SRF) for the requested" - echo " sensor from the CRTM SRF repository." - echo - echo - echo " Options:" - echo " -h" - echo " Print this message." - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo " Arguments:" - echo " sensor_id [sensor_id2 sensor_id3 ... sensor_idN]" - echo " A list of sensor ids identifying the particular sensors for which" - echo " the SRF files are required." - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $0) -# ...Defintiions -SUCCESS=0 -FAILURE=1 -# ...Define helper script, and make sure it can be found -LINK_SCRIPT="linkfiles.sh" -type ${LINK_SCRIPT} >/dev/null 2>&1 || { - error_message "Cannot find ${LINK_SCRIPT} helper script. Exiting..." - exit ${FAILURE} -} - - -# Parse the command line options -while getopts :hx OPTVAL; do - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS};; - x) script_id; set -x;; - \?) OPTVAL=${OPTARG}; break;; - esac -done -# Remove the options processed -shift $(expr ${OPTIND} - 1) -# Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed and all that - # remains are the arguments - \?) if [ $# -lt 1 ]; then - usage; error_message " Missing 'sensor_id' argument(s)" - exit ${FAILURE} - fi;; - # Invalid option - ?) usage; error_message " Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Assign command line arguments -SENSOR_ID_LIST=$* - - -# Check that the mandatory envar is defined -if [ -z "${CRTM_SRF_ROOT}" ]; then - error_message "CRTM_SRF_ROOT envar is not defined." - exit ${FAILURE} -fi - - -# Construct the list of files to link -SRF_FILE_LIST="" -for SENSOR_ID in ${SENSOR_ID_LIST}; do - SRF_FILE_LIST="${SRF_FILE_LIST} ${SENSOR_ID}.osrf.nc" -done -SRF_FILE_LIST=${SRF_FILE_LIST/[[:space:]]/} - - -# Output some user info -echo; echo "${SCRIPT_NAME}: Linking in the SRF files: ${SRF_FILE_LIST//[[:space:]]/, }"; echo - -# And now link them in -${LINK_SCRIPT} -q ${CRTM_SRF_ROOT} ${SRF_FILE_LIST} -if [ $? -ne 0 ]; then - error_message "Error occuring linking SRF datafiles}" - exit ${FAILURE} -fi - - -# Done. Turn off execution tracing -exit ${SUCCESS} - diff --git a/scripts/shell/Utility/linkfiles.sh b/scripts/shell/Utility/linkfiles.sh deleted file mode 100755 index 8a38b68..0000000 --- a/scripts/shell/Utility/linkfiles.sh +++ /dev/null @@ -1,212 +0,0 @@ -#!/bin/sh - -# $Id$ - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" -} - -usage() -{ - echo - echo " Usage: linkfiles.sh [-hqsx] [-d filter-dir] dir file [file2 | file3 | ... | fileN]" - echo - echo " Script to search a directory tree and symlink in the requested" - echo " file(s) to the current directory." - echo - echo " * If multiple files of the same name exist in the directory tree," - echo " the first one found is linked in." - echo - echo - echo " Options:" - echo " -d filter-dir" - echo " Use this option to filter the directory location" - echo " of the requested file(s) to symlink." - echo - echo " -h" - echo " Print this message and exit." - echo - echo " -q" - echo " Suppress informational output." - echo - echo " -s" - echo ' Allow symbolic links to themselves be linked, i.e. "chain-linking"' - echo " the files. Default action is to *NOT* link in symlinks." - echo - echo " -x" - echo " Turn on execution tracing. This also causes extra script" - echo " information to be printed out." - echo - echo " Arguments:" - echo " dir" - echo " Directory at which to begin the search for the" - echo " requested file(s) to symlink." - echo - echo " file" - echo " File for which a symlink is required." - echo - echo " Optional arguments:" - echo " file2 | file3 | ... | fileN" - echo " Additional list of files for which symlinks are required." - echo -} - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Setup -# ...Script name for error messages -SCRIPT_NAME=$(basename $0) -# ...Defintiions -SUCCESS=0 -FAILURE=1 -LINK="ln -sf" -EXCLUDE_SYMLINK="YES" -NOISY="YES" - - -# Parse the command line options -while getopts :hqsxd: OPTVAL; do - - # Exit if option argument looks like another option - case ${OPTARG} in - -*) break;; - esac - - # Parse the valid options - case ${OPTVAL} in - d) FILTER_DIR=${OPTARG} ;; - h) usage | more; exit ${SUCCESS} ;; - q) NOISY= ;; - s) EXCLUDE_SYMLINK= ;; - x) script_id; set -x ;; - :|\?) OPTVAL=${OPTARG}; break ;; - esac -done - -# ...Remove the options processed -shift $(expr ${OPTIND} - 1) - -# ...Output invalidities based on OPTVAL -case ${OPTVAL} in - - # If OPTVAL contains nothing, then all options - # have been successfully parsed and all that - # remains are the arguments - \?) if [ $# -lt 2 ]; then - usage - error_message "Missing 'dir' and 'file' arguments" - exit ${FAILURE} - fi;; - - # Valid options, but missing arguments - d) usage - error_message "'-${OPTVAL}' option requires an argument" - exit ${FAILURE} ;; - - # Invalid option - ?) usage - error_message "Invalid option '-${OPTARG}'" - exit ${FAILURE} ;; -esac - - -# Assign command line arguments -LINKFILE_ROOT=$1 -shift 1 -LINKFILE_LIST=$* - - -# Output some user info -if [ ${NOISY} ]; then - echo "${SCRIPT_NAME}: Searching for file(s) to link..." -fi - -# Build argument list for find -OR="-o" -FINDFILE_LIST="" -for FILE in ${LINKFILE_LIST}; do - # Skip if file already exists - if [ -f ${FILE} ]; then - continue - fi - FINDFILE_LIST="${FINDFILE_LIST} -name ${FILE} ${OR}" -done -FINDFILE_LIST=${FINDFILE_LIST%$OR} - - -# Exit if FINDFILE_LIST is empty -if [ -z "${FINDFILE_LIST}" ]; then - echo "${SCRIPT_NAME}: All required files are present so nothing to do. Exiting." - exit ${SUCCESS} -fi - - -# Find the required files -# ...Specify expressions for find -IGNORE_SVN='-type d -name ".svn" -prune' # Do not search the .svn directories -FILES_TO_FIND="-type f ${FINDFILE_LIST}" # The list of files to actually find -# ...Construct the expression for the find command -EXPRESSION="${IGNORE_SVN} -o ${FILES_TO_FIND}" -# ...Run the command -if [ -z "${FILTER_DIR}" ]; then - LINKFILES=$(find -L ${LINKFILE_ROOT}/ \( ${EXPRESSION} \) | sort -r) -else - LINKFILES=$(find -L ${LINKFILE_ROOT}/ \( ${EXPRESSION} \) | grep ${FILTER_DIR} | sort -r) -fi -if [ $? -ne 0 ]; then - error_message "Find command failed for: ${FINDFILE_LIST}" - exit ${FAILURE} -fi - - -# Set the condition for skipping existing files or symlinks -if [ ${EXCLUDE_SYMLINK} ]; then - SKIP_CONDITION='[ -f $(basename ${FILE}) ] || [ -h ${FILE} ]' - if [ ${NOISY} ]; then - echo "${SCRIPT_NAME}: Skipping symbolic links..." - fi -else - SKIP_CONDITION='[ -f $(basename ${FILE}) ]' -fi - - -# Link in the files found -for FILE in ${LINKFILES}; do - # Skip file if necessary - if eval "${SKIP_CONDITION}"; then - continue - fi - # Link in the file - ${LINK} ${FILE} . - if [ $? -ne 0 ]; then - error_message "Link command failed for ${FILE}" - exit ${FAILURE} - fi -done - - -# Check that all the required files were found -for FILE in ${LINKFILE_LIST}; do - if [ ! -f ${FILE} ]; then - echo "File ${FILE} not found in ${LINKFILE_ROOT} hierarchy." - fi -done diff --git a/scripts/shell/Utility/unlinkfiles.sh b/scripts/shell/Utility/unlinkfiles.sh deleted file mode 100755 index 646b59e..0000000 --- a/scripts/shell/Utility/unlinkfiles.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -LINKFILE_LIST=$* -if [ -z "${LINKFILE_LIST}" ]; then - exit 0 -fi - -for FILE in ${LINKFILE_LIST}; do - if [ -h ${FILE} ]; then - rm -f ${FILE} - fi -done - diff --git a/scripts/shell/crtm_install_scripts.sh b/scripts/shell/crtm_install_scripts.sh deleted file mode 100755 index 4569b06..0000000 --- a/scripts/shell/crtm_install_scripts.sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/bash - -script_id() -{ - REVISION='$Revision$' - LAST_CHANGED_DATE='$LastChangedDate$' - echo - echo "${SCRIPT_NAME} ${REVISION} ${LAST_CHANGED_DATE}" - echo " "`date` - echo " Support email: NCEP.List.EMC.JCSDA_CRTM.Support@noaa.gov" - echo -} - - -usage() -{ - echo - echo "Usage: crtm_install_scripts.sh [-hux] [bindir]" - echo - echo " Utility script to link in the various CRTM shell scripts in a user directory" - echo " to contain executable commands, bindir." - echo - echo " * If the optional bindir argument is not specified, the default is ~/bin." - echo - echo " * If bindir does not exist it is created." - echo - echo ' * If bindir is not in $PATH a "crtmrc" file is created that can be sourced to' - echo ' add bindir to the $PATH in the current shell:' - echo " $ . crtmrc" - echo - echo - echo " Options:" - echo - echo " -h" - echo " Print this message." - echo - echo " -u" - echo " Use this option to UNINSTALL (i.e. remove) the CRTM scripts in bindir." - echo - echo " -x" - echo " Turn on execution tracing" - echo - echo - echo " Optional arguments:" - echo - echo " bindir" - echo " A specified directory in which to (un)install the scripts. If it is" - echo " specified and does not exist it is created for installation." - echo; echo -} - - -error_message() -{ - MESSAGE=$1 - echo >&2 - echo " *********************" >&2 - echo " ${SCRIPT_NAME}(ERROR): ${MESSAGE}" >&2 - echo " *********************" >&2 -} - - -info_message() -{ - MESSAGE=$1 - echo " ${SCRIPT_NAME}(INFORMATION): ${MESSAGE}" -} - - -######################################################################## -# MAIN SCRIPT BEGINS # -######################################################################## - -# Set up -# ...Script name for error messages -SCRIPT_NAME=$(basename $BASH_SOURCE) -# ...Commands -LINK="ln -sf" -REMOVE="rm -f" -# ...Definitions -SUCCESS=0; TRUE=0 -FAILURE=1; FALSE=1 -BINDIR_DEFAULT="${HOME}/bin" -INSTALL=${TRUE} -SOURCEFILE="crtmrc" -SCRIPTFILE_GLOB="*.sh" # Only files matching this glob are installed - - -# Parse the command line options -while getopts :hux OPTVAL; do - # If option argument looks like another option exit the loop - case ${OPTARG} in - -*) break;; - esac - # Parse the valid options - case ${OPTVAL} in - h) usage | more; exit ${SUCCESS} ;; - u) INSTALL=${FALSE} ;; - x) script_id; set -x ;; - \?) OPTVAL=${OPTARG}; break ;; - esac -done -# Remove the options processed -shift $(expr ${OPTIND} - 1) -# Output invalidities based on OPTVAL -case ${OPTVAL} in - # If OPTVAL contains nothing, then all options - # have been successfully parsed - \?) : ;; - # Invalid option - *) usage; error_message " Invalid option '-${OPTARG}'"; exit ${FAILURE};; -esac - - -# Check if bindir has been specified -BINDIR=${BINDIR_DEFAULT} -if [ $# -ne 0 ]; then - BINDIR=$1 -fi - - -# Check that the mandatory envars are defined -if [ -z "${CRTM_ROOT}" -o -z "${CRTM_SCRIPTS_ROOT}" ]; then - error_message "CRTM_ROOT and CRTM_SCRIPTS_ROOT envars are not defined." - exit ${FAILURE} -fi -info_message "CRTM root directory is `basename ${CRTM_ROOT}`" - - -# If no BINDIR for uninstallation, do nothing... -if [ ! -d ${BINDIR} -a ${INSTALL} -eq ${FALSE} ]; then - info_message "${BINDIR} does not exist. Cannot uninstall from a non-existant directory" - exit ${SUCCESS} -fi - - -# Does BINDIR exist for installation? -if [ ! -d ${BINDIR} -a ${INSTALL} -eq ${TRUE} ]; then - # Create it - info_message "Creating ${BINDIR} for script installation..." - mkdir ${BINDIR} - if [ $? -ne 0 ]; then - error_message "Error creating ${BINDIR} directory for script installation" - exit ${FAILURE} - fi -else - # Just output info message - info_message "${BINDIR} exists..." -fi - - -# Is BINDIR in PATH? -if [[ ":$PATH:" != *":$BINDIR:"* ]]; then - info_message 'Your $PATH does NOT contain '"$BINDIR..." - if [ ${INSTALL} -eq ${TRUE} ]; then - info_message 'Creating a crtmrc file with $PATH modification. For a permanent change modify your .bash_profile (or similar) file.' - echo "export PATH="'${PATH}'":${BINDIR}" > ${SOURCEFILE} - cat ${SOURCEFILE} - fi -fi - - -# (Un)install all the scripts in BINDIR -( - cd ${CRTM_SCRIPTS_ROOT}/shell - # ...Get the script directory list - SCRIPTDIR_LIST=`ls -d` # current directory - SCRIPTDIR_LIST="${SCRIPTDIR_LIST} `ls -d */`" # subdirectories - # ...Install from each directory. - for SCRIPTDIR in ${SCRIPTDIR_LIST}; do - ( - # Enter directory, but skip if no scripts - cd $SCRIPTDIR - if [ -z "$(find . -maxdepth 1 -name "${SCRIPTFILE_GLOB}" -print -quit)" ]; then - continue - fi - - # Define the info message root to output - MSG_ROOT="`basename ${PWD}` scripts in ${BINDIR}" - - # Define the install type specifics - if [ ${INSTALL} -eq ${TRUE} ]; then - MSG_TYPE="Installing" - COMMAND='${LINK} ${PWD}/${SCRIPT} ${BINDIR}' - else - MSG_TYPE="Uninstalling" - COMMAND='${REMOVE} ${BINDIR}/${SCRIPT}' - fi - - # Perform the (un)installation - info_message "${MSG_TYPE} ${MSG_ROOT}..." - for SCRIPT in `ls ${SCRIPTFILE_GLOB}`; do - eval "${COMMAND}" - if [ $? -ne 0 ]; then - error_message "${MSG_TYPE} ${MSG_ROOT} failed" - exit ${FAILURE} - fi - done - ) - done -) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b887c36..d3d36f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -211,12 +211,22 @@ list( APPEND crtm_src_files Zeeman/Zeeman_Utility.f90 ) -add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_src_files}) +if(((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) AND CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + SET_SOURCE_FILES_PROPERTIES(RTSolution/ADA/ADA_Module.f90 APPEND_STRING PROPERTY COMPILE_FLAGS " -check none -check bounds,pointers,uninit") +endif() + + +add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_src_files}) +add_library(${PROJECT_NAME}_static STATIC ${${PROJECT_NAME}_src_files}) # Dependencies target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_Fortran) target_link_libraries(${PROJECT_NAME} PUBLIC NetCDF::NetCDF_Fortran) +# Dependencies +target_link_libraries(${PROJECT_NAME}_static PUBLIC OpenMP::OpenMP_Fortran) +target_link_libraries(${PROJECT_NAME}_static PUBLIC NetCDF::NetCDF_Fortran) + # Fortran module output directory for build and install interfaces set(MODULE_DIR module/${PROJECT_NAME}/${CMAKE_Fortran_COMPILER_ID}/${CMAKE_Fortran_COMPILER_VERSION}) set_target_properties(${PROJECT_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR}) @@ -224,3 +234,4 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/${MODULE_DIR}/ DESTINATION ${MODULE_DIR}) target_include_directories(${PROJECT_NAME} INTERFACE $ $) + diff --git a/util/checkendian/Makefile b/util/checkendian/Makefile deleted file mode 100644 index 3652135..0000000 --- a/util/checkendian/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -CC = gcc -CFLAGS = -g -O1 -COBJS = main.o - -all: endian - -endian: $(COBJS) - $(CC) -o $@ $^ $(LDFLAGS) - -clean: - $(RM) $(COBJS) endian diff --git a/util/checkendian/main.c b/util/checkendian/main.c deleted file mode 100644 index e04cfd3..0000000 --- a/util/checkendian/main.c +++ /dev/null @@ -1,247 +0,0 @@ -/* -** Purpose: Determine 1) Is this a Fortran sequential binary file? -** 2) What is the endianness and RCW size? -** Usage: $0 input_file -*/ - -#include /* lseek */ -#include /* open */ -#include /* open */ -#include /* lseek, read */ -#include -#include /* uint32_t, uint64_t */ - -extern int IsLittleEndian (void); -extern void printresults (int); - -int main (int argc, char **argv) -{ - char *fn; // input file name - int fd; // file descriptor - extern int check32 (int, char *, int); - extern int check64 (int, char *, int); - - if (argc != 2) { - printf ("Usage: %s input_file\n", argv[0]); - return -1; - } - - fn = argv[1]; - if ((fd = open (fn, O_RDONLY)) == -1) { - printf ("Failed to open %s for reading\n", fn); - return -1; - } - - /* - ** Check combinations of 32- and 64-bit RCW, native endian and byte-swapped - */ - if (check32 (fd, fn, 0) < 0) { - if (check32 (fd, fn, 1) < 0) { - if (check64 (fd, fn, 0) < 0) { - if (check64 (fd, fn, 1) < 0) { - printf ("All tests failed: %s is probably not a Fortran sequential binary file\n", fn); - return -1; - } - } - } - } - return 0; -} - -/* -** check32: See if the 1st record of fn is Fortran sequential binary with 4-byte RCW -** -** Input args -** fd: file descriptor -** swap_bytes: whether to swap bytes or not -** -** Return value: 0 on success (4-byte RCW found at start and end of record) -** -1 on failure -*/ -int check32 (int fd, char *fn, int swap_bytes) -{ - uint32_t rcw[2]; // beginning and ending 4-byte RCW - extern void bswap4 (uint32_t *); - - /* Should always be able to seek to beginning of file */ - if (lseek (fd, (off_t) 0, SEEK_SET) < 0) - return -1; - - if (read (fd, &rcw[0], 4) != 4) { - return -1; - } - - if (swap_bytes) - bswap4 (&rcw[0]); - - if (lseek (fd, (off_t) (rcw[0]+4), SEEK_SET) < 0) { - /* Reposition failed: either swapping is wrong or rcw size is wrong */ - return -1; - } - - /* Now check that a ending rcw matching beginning rcw is found */ - if (read (fd, &rcw[1], 4) != 4) { - return -1; - } - - if (swap_bytes) - bswap4 (&rcw[1]); - - if (rcw[0] == rcw[1]) { - printf ("%s is likely a Fortran sequential binary file.\n", fn); - printf ("It has 4-byte record-control words. The first record is %d bytes long\n", rcw[0]); - printresults (swap_bytes); - return 0; - } else { - /* Ending rcw to match starting rcw not found */ - return -1; - } -} - -/* -** check64: See if the 1st record of fn is Fortran sequential binary with 8-byte RCW -** -** Input args -** fd: file descriptor -** swap_bytes: whether to swap bytes or not -** -** Return value: 0 on success (8-byte RCW found at start and end of record) -** -1 on failure -*/ -int check64 (int fd, char *fn, int swap_bytes) -{ - uint64_t rcw[2]; // beginning and ending 8-byte RCW - extern void bswap8 (uint64_t *); - - /* Should always be able to seek to beginning of file */ - if (lseek (fd, (off_t) 0, SEEK_SET) < 0) - return -1; - - if (read (fd, &rcw[0], 8) != 8) { - return -1; - } - - if (swap_bytes) - bswap8 (&rcw[0]); - - if (lseek (fd, (off_t) (rcw[0]+8), SEEK_SET) < 0) { - /* Reposition failed: either swapping is wrong or rcw size is wrong */ - return -1; - } - - /* Now check that a ending rcw matching beginning rcw is found */ - if (read (fd, &rcw[1], 8) != 8) { - return -1; - } - - if (swap_bytes) - bswap8 (&rcw[1]); - - if (rcw[0] == rcw[1]) { - printf ("%s is likely a Fortran sequential binary file.\n", fn); - printf ("It has 8-byte record-control words. The first record is %d bytes long\n", rcw[0]); - printresults (swap_bytes); - return 0; - } else { - /* Ending rcw to match starting rcw not found */ - return -1; - } -} - -/* -** bswap4: swap the bytes of a 4-byte RCW -*/ -void bswap4 (uint32_t *rcw) -{ - typedef union { - uint32_t intvar; - struct bytes { - unsigned char c1; - unsigned char c2; - unsigned char c3; - unsigned char c4; - } both; - } intbytes; - - intbytes v1, v2; - - /* copy the input */ - v1.intvar = *rcw; - - /* swap the bytes */ - v2.both.c1 = v1.both.c4; - v2.both.c2 = v1.both.c3; - v2.both.c3 = v1.both.c2; - v2.both.c4 = v1.both.c1; - - /* copy the output */ - *rcw = v2.intvar; -} - -/* -** bswap8: swap the bytes of an 8-byte RCW -*/ -void bswap8 (uint64_t *rcw) -{ - typedef union { - uint64_t intvar; - struct bytes { - unsigned char c1; - unsigned char c2; - unsigned char c3; - unsigned char c4; - unsigned char c5; - unsigned char c6; - unsigned char c7; - unsigned char c8; - } both; - } intbytes; - - intbytes v1, v2; - - /* copy the input */ - v1.intvar = *rcw; - - /* swap the bytes */ - v2.both.c1 = v1.both.c8; - v2.both.c2 = v1.both.c7; - v2.both.c3 = v1.both.c6; - v2.both.c4 = v1.both.c5; - v2.both.c5 = v1.both.c4; - v2.both.c6 = v1.both.c3; - v2.both.c7 = v1.both.c2; - v2.both.c8 = v1.both.c1; - - /* copy the output */ - *rcw = v2.intvar; -} - -/* -** IsLittleEndian: Determine if this is a little endian machine or not -*/ -int IsLittleEndian () -{ - int i = 1; - - return (int)*((unsigned char *)&i) == 1; -} - -/* -** printresults: print results of testing input file. -*/ -void printresults (int swap_bytes) -{ - if (swap_bytes) { - if (IsLittleEndian ()) { - printf ("Endianness is BIG: Differs from native so special compiler flags ARE required\n"); - } else { - printf ("Endianness is LITTLE: Differs from native so special compiler flags ARE required\n"); - } - } else { - if (IsLittleEndian ()) { - printf ("Endianness is LITTLE: Matches native so no special compiler flags required.\n"); - } else { - printf ("Endianness is BIG: Matches native so no special compiler flags required.\n"); - } - } -}