#!/usr/bintenv bash
VPATH = @srcdir@

srcdir = @srcdir@
FC=@FC@
CC=@CC@
LDSHARED="@CC@ ${LDSHARED_FLAGS}"
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
CPPFLAGS_USER=""
USERFFLAGS=@USERFFLAGS@
#MODULE_SUFFIX="mod"
PREFIX=@prefix@
PYTHONPATH:=@prefix@/lib/python2.7/site-packages:${PYTHONPATH}
DIR=$(shell echo ${PYTHONPATH} | cut -d: -f1)
FCFLAGS=@FCFLAGS@
PYTHONEXEC=@PYTHONEXEC@
NO_COLOR2=\x1b[0m
OK_COLOR2=\x1b[2;34m
NO_COLOR=${@NO_COLOR@}
OK_COLOR=${@OK_COLOR@}
USERCFLAGS=@USERCFLAGS@
NCCFLAGS=@NCCFLAGS@
ZFLAGS=@ZFLAGS@
UUIDFLAGS=@UUIDFLAGS@
UDUNITS2FLAGS=@UDUNITS2FLAGS@
NCLDFLAGS=@NCLDFLAGS@
ZLDFLAGS=@ZLDFLAGS@
UUIDLDFLAGS=@UUIDLDFLAGS@
UDUNITS2LDFLAGS=@UDUNITS2LDFLAGS@
RTAG=@RTAG@
FTAG=@FTAG@
FNCLDFLAGS=@NCLDFLAGS@
FZLDFLAGS=@ZLDFLAGS@
FUUIDLDFLAGS=@UUIDLDFLAGS@
FUDUNITS2LDFLAGS=@UDUNITS2LDFLAGS@
DEBUG=@DEBUG@
VERB=@VERB@
MACROS=@MACROS@


# Library name
LIBNAME=libcmor.a
SONAME := libcmor.so.2
SHLIBFLAGS:= -Wl,-O1 -Wl,-soname,$(SONAME) -Wl,--version-script,cmor.ver -lgfortran -lm

# Library sources
LIBSOURCES=@LIBSOURCES@
LIBSOURCESCV=@LIBSOURCESCV@
LIBFSOURCES=@LIBFSOURCES@
LIBSOURCESSO=$(patsubst Src/_cmormodule.c,,$(LIBSOURCES))

LIBFILES=@LIBFILES@

#Include Files
INCFILES=@INCFILES@

# Temporary Files
TMPFILES=*~ $(LIBFILES) *.mod a.out *.stb Test/*.nc Test/IPCC_Fourth_Assessment *.LOG* *.dSYM Test/IPCC Test/CMIP5 CMIP5
DISTFILES=libcmor.a
DEPEND= makedepend -c ${DEBUG} ${CFLAGS} ${USERCFLAGS}  ${NCCFLAGS} ${UDUNITS2FLAGS} ${UUIDLDFLAGS} ${ZFLAGS}
UNAME := $(shell uname)

CCOMPILE=${CC} -c ${DEBUG} ${MACROS} ${CPPFLAGS} ${CFLAGS} ${USERCFLAGS} \
		${NCCFLAGS} ${UDUNITS2FLAGS} ${UUIDFLAGS} ${ZFLAGS}

PIC_OBJS = $(patsubst %.c, %.pic_o, $(LIBSOURCESSO)) $(patsubst %.f90,%.pic_o, $(LIBFSOURCES))

%.pic_o: %.c
	@CC@ @CPPFLAGS@  -I/usr/include/ossp -fstack-protector --param=ssp-buffer-size=4 \
		-Wformat -Wformat-security -Werror=format-security  -D_FORTIFY_SOURCE=2 \
		-fPIC -c -o $@  @DEBUG@ @MACROS@ @CFLAGS@  @NCCFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @ZFLAGS@  $<

%.pic_o: %.f90
	@FC@ -c -o $@ -fPIC @FCFLAGS@ @DEBUG@ @MACROS@  $<

shlib $(SONAME):   $(PIC_OBJS)
	$(CC) -shared  -o $(SONAME) $(LDFLAGS) $(SHLIBFLAGS)  $(PIC_OBJS)  @NCCFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @ZFLAGS@ 
install_shlib: $(SONAME)
	mkdir -p $(DESTDIR)@prefix@/lib
	cp -p $(SONAME) $(DESTDIR)@prefix@/lib


all:    cmor
	@echo
depend:  $(LIBSOURCES)
	${DEPEND}  $(LIBSOURCES)
cmor.o: Src/cmor.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_variables.o: Src/cmor_variables.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_axes.o: Src/cmor_axes.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_tables.o: Src/cmor_tables.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_grids.o: Src/cmor_grids.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_CV.o: Src/cmor_CV.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cmor_md5.o: Src/cmor_md5.c include/cmor.h include/cmor_func_def.h \
		include/cmor_md5.h
	${CCOMPILE} $<
cmor_cfortran_interface.o: Src/cmor_cfortran_interface.c include/cmor.h \
		include/cmor_func_def.h
	${CCOMPILE} $<
cdTimeConv.o: Src/cdTime/cdTimeConv.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
cdUtil.o: Src/cdTime/cdUtil.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
timeConv.o: Src/cdTime/timeConv.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
timeArith.o: Src/cdTime/timeArith.c include/cmor.h include/cmor_func_def.h
	${CCOMPILE} $<
arraylist.o: Src/json-c/arraylist.c
	${CCOMPILE} $<
debug.o: Src/json-c/debug.c
	${CCOMPILE} $<
json_c_version.o: Src/json-c/json_c_version.c
	${CCOMPILE} $<
json_object.o: Src/json-c/json_object.c
	${CCOMPILE} $<
json_object_iterator.o: Src/json-c/json_object_iterator.c
	${CCOMPILE} $<
json_tokener.o: Src/json-c/json_tokener.c
	${CCOMPILE} $<
json_util.o: Src/json-c/json_util.c
	${CCOMPILE} $<
libjson.o: Src/json-c/libjson.c
	${CCOMPILE} $<
linkhash.o: Src/json-c/linkhash.c
	${CCOMPILE} $<
printbuf.o: Src/json-c/printbuf.c
	${CCOMPILE} $<
random_seed.o: Src/json-c/random_seed.c
	${CCOMPILE} $<
cmor_fortran_interface.o: Src/cmor_fortran_interface.f90
	${FC} -c ${FCFLAGS} ${USERFFLAGS} ${DEBUG} ${MACROS} $<
cmor:  $(LIBFILES) @MAKEDEPPYTHON@
	@ar crv $(LIBNAME) $(LIBFILES) 
	@ranlib $(LIBNAME)
clean:
	@echo "Cleaning [$(WHEREAMI)] ..."
	@rm -rf $(TMPFILES)
distclean: clean
	@echo "Completely cleaning [$(WHEREAMI)]..."
	@rm -f $(DISTFILES)
install: cmor
	mkdir -p ${DESTDIR}${PREFIX}/lib
	mkdir -p ${DESTDIR}${PREFIX}/include
	mkdir -p ${DESTDIR}${PREFIX}/include/cdTime
	mkdir -p ${DESTDIR}${PREFIX}/include/json-c
	mkdir -p ${DESTDIR}${PREFIX}/include/cdTime/cdunifpp
	cp -p $(LIBNAME) ${DESTDIR}${PREFIX}/lib
	cp -pr $(srcdir)/include/*.h @MODFILES@ ${DESTDIR}${PREFIX}/include
	cp -pr $(srcdir)/include/json-c/*.h ${DESTDIR}${PREFIX}/include/json-c
	cp -pr $(srcdir)/include/cdTime/*.h ${DESTDIR}${PREFIX}/include/cdTime
	cp -pr $(srcdir)/include/cdTime/cdunifpp/*.h ${DESTDIR}${PREFIX}/include/cdTime/cdunifpp
uninstall: distclean 
	rm ${DESTDIR}${PREFIX}/lib/$(LIBNAME)    
	cd ${DESTDIR}${PREFIX} ; rm $(INCFILES)  
backup: clean
	@echo "Creating full backup tar file..."
	@(cd ..; \
	@TGZNAME=$(TGZDIR)/cmor_`$(TIMESTAMP)`_full.tgz; \
	@tar cfz $$TGZNAME Cmor; \
	@touch $(TIMESTAMPDIR)/cmor_`$(TIMESTAMP)`_full.time; \
	@echo "Full backup tar file created : $$TGZNAME")
test:  cmor test_C @TEST_FORTRAN@ @MAKETESTPYTHON@
	@echo "All C and Fortran Test passed successfully"
test_C: cmor 
	rm -f ./ipcc_test_code ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/ipcc_test_code.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ @LDFLAGS@  -o ipcc_test_code  @VERB@; ./ipcc_test_code @VERB@
	rm -f test_grid ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/test_grid.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ -o test_grid @LDFLAGS@ @VERB@; ./test_grid @VERB@;
	rm -f test_grid_unstructured ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/test_cmor_grid_unstructured_fabi.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ -o test_grid_unstructured @LDFLAGS@ @VERB@; ./test_grid_unstructured @VERB@;
	rm -f test_cat_unique ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/test_unit_cat_unique.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ @LDFLAGS@ -o test_unit_cat_unique @VERB@; ./test_unit_cat_unique @VERB@;
	rm -f test_cmor_append_associated ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/test_cmor_append_associated.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ @LDFLAGS@ -o test_cmor_append_associated @VERB@; ./test_cmor_append_associated @VERB@;
ifeq ($(UNAME), Linux)
	rm -f test_lots_of_variables ; @CC@ @CFLAGS@ @USERCFLAGS@ @CPPFLAGS@  Test/test_lots_of_variables.c -L@prefix@/lib -I@prefix@/include  -L. -lcmor @NCCFLAGS@ @NCLDFLAGS@ @UDUNITS2LDFLAGS@ @UDUNITS2FLAGS@ @UUIDLDFLAGS@ @UUIDFLAGS@ @LDFLAGS@ -o test_lots_of_variables @VERB@; ./test_lots_of_variables @VERB@;
# do something Linux-y
endif
python:
	@echo "Building Python interface"
	#if [ ! -d "${DIR}" ]; then mkdir -p ${DIR}; fi
	LDSHARED=${LDSHARED} ${PYTHONEXEC} setup.py install --prefix=${DESTDIR}${PREFIX}
test_a_python:
	@echo "${OK_COLOR}Testing ${TEST_NAME} ${NO_COLOR}"
	${PYTHONEXEC} ${TEST_NAME} ${VERB}
test_python: python
	env TEST_NAME=Test/test_python_climatology.py make test_a_python
	env TEST_NAME=Test/test_python_history.py make test_a_python
	env TEST_NAME=Test/test_python_historydefault.py make test_a_python
	env TEST_NAME=Test/test_python_test_write.py make test_a_python
	env TEST_NAME=Test/test_python_missing_values.py make test_a_python
	env TEST_NAME=Test/test_python_history.py make test_a_python
	env TEST_NAME=Test/test_python_sos_psu_units.py make test_a_python
	env TEST_NAME=Test/test_python_CMIP6_projections.py make test_a_python
	env TEST_NAME=Test/test_python_toomany_tables.py make test_a_python
	env TEST_NAME=Test/test_chunking.py make test_a_python
	env TEST_NAME=Test/test_python_direct_calls.py make test_a_python
	env TEST_NAME=Test/test_python_user_interface_00.py make test_a_python
	env TEST_NAME=Test/test_python_user_interface_01.py make test_a_python
	env TEST_NAME=Test/test_python_user_interface_03.py make test_a_python
	env TEST_NAME=Test/test_python_common.py make test_a_python
	env TEST_NAME=Test/cmor_speed_and_compression.py make test_a_python
	env TEST_NAME=Test/cmor_speed_and_compression_01.py make test_a_python
#	@env TEST_NAME=Test/cmor_speed_and_compression_02.py make test_a_python
	env TEST_NAME=Test/test_compression.py make test_a_python
	env TEST_NAME=Test/test_python_appending.py make test_a_python
	env TEST_NAME=Test/test_python_bounds_request.py make test_a_python
	env TEST_NAME=Test/test_python_new_tables.py make test_a_python
#	@env TEST_NAME=Test/test_python_index_coord.py make test_a_python
	env TEST_NAME=Test/test_python_jamie.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_2.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_3.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_4.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_6.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_7.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_8.py make test_a_python
	env TEST_NAME=Test/test_python_memory_check.py make test_a_python
	env TEST_NAME=Test/test_python_open_close_cmor_multiple.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_7.py make test_a_python
#	env TEST_NAME=Test/test_python_joerg_1.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_2.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_3.py make test_a_python
#	env TEST_NAME=Test/test_python_joerg_4.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_5.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_6.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_7.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_8.py make test_a_python
#	@env TEST_NAME=Test/test_python_joerg_9.py make test_a_python
#	env TEST_NAME=Test/test_python_joerg_10.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_11.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_12.py make test_a_python
	env TEST_NAME=Test/test_python_YYYMMDDHH_exp_fmt.py make test_a_python
	env TEST_NAME=Test/test_python_region.py make test_a_python
	env TEST_NAME=Test/jamie_hybrid_height.py make test_a_python
	env TEST_NAME=Test/jamie_positive.py make test_a_python
	env TEST_NAME=Test/test_python_1D_var.py make test_a_python
	env TEST_NAME=Test/test_python_2Gb_file.py make test_a_python
	env TEST_NAME=Test/test_python_2Gb_slice.py make test_a_python
#	env TEST_NAME=Test/test_python_3hr.py make test_a_python
	env TEST_NAME=Test/test_python_YYYMMDDHH_exp_fmt.py make test_a_python
#	@env TEST_NAME=Test/test_python_alastair_1.py make test_a_python
	env TEST_NAME=Test/test_python_cfmip_site_axis_test.py make test_a_python
#	env TEST_NAME=Test/test_python_fx.py make test_a_python
	env TEST_NAME=Test/test_python_grid_and_ocn_sigma.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_site_surface.py make test_a_python
	env TEST_NAME=Test/test_python_max_variables.py make test_a_python
	env TEST_NAME=Test/test_python_max_variables_2.py make test_a_python
	env TEST_NAME=Test/test_python_reverted_lats.py make test_a_python
	env TEST_NAME=Test/test_lon_gt_360.py make test_a_python
	env TEST_NAME=Test/test_lon_thro_360.py make test_a_python
	env TEST_NAME=Test/test_python_jamie_11.py make test_a_python
	env TEST_NAME=Test/test_python_joerg_tim2_clim_02.py make test_a_python
	env TEST_NAME=Test/test_site_ts.py make test_a_python
	env TEST_NAME=Test/test_python_free_wrapping_issue.py make test_a_python
	env TEST_NAME=Test/test_python_filename_time_range.py make test_a_python
	env TEST_NAME=Test/test_cmor_half_levels.py make test_a_python
	env TEST_NAME=Test/test_cmor_half_levels_with_bounds.py make test_a_python
	env TEST_NAME=Test/test_cmor_half_levels_wrong_generic_level.py make test_a_python
	env TEST_NAME=Test/test_cmor_double_singleton.py make test_a_python

test_case:
	@echo "${OK_COLOR}Testing: "${TEST_NAME}" with input file: ${INPUT_FILE}${NO_COLOR}"
	@rm -f ./${TEST_NAME} 2>/dev/null ; ${FC} ${USERFFLAGS} ${FCFLAGS} ${DEBUG}  Test/${TEST_NAME}.f90 -L${PREFIX}/lib -L. -lcmor ${NCCFLAGS} ${FNCLDFLAGS} ${FUDUNITS2LDFLAGS} ${UDUNITS2FLAGS} ${FUUIDLDFLAGS} ${UUIDLDFLAGS} ${ZFLAGS} ${FZLDFLAGS} -o ${TEST_NAME} ;
	@./${TEST_NAME} ${VERB} < ${INPUT_FILE} ;
	@ rm ./${TEST_NAME}
ifeq (@MAKEDEPPYTHON@,python)
	@env TEST_NAME="Test/check_results.py ${TEST_NAME}" make test_a_python
endif
test_case_old_cmor_tables:
	@echo "Testing: "${TEST_NAME}" with input file: "${INPUT_FILE}
	@rm -f ./${TEST_NAME} 2>/dev/null ; ${FC} ${USERFFLAGS} ${FCFLAGS} ${DEBUG}  Test/old_cmor_tables/${TEST_NAME}.f90 -L${PREFIX}/lib -L. -lcmor ${NCCFLAGS} ${FNCLDFLAGS} ${FUDUNITS2LDFLAGS} ${UDUNITS2FLAGS} ${FUUIDLDFLAGS} ${UUIDLDFLAGS} ${ZFLAGS} ${FZLDFLAGS} -o ${TEST_NAME} ;
	@./${TEST_NAME} ${VERB} < ${INPUT_FILE} ;
	@ rm ./${TEST_NAME}
ifeq (@MAKEDEPPYTHON@,python)
	@env TEST_NAME="Test/check_results.py old_cmor_tables_${TEST_NAME}" make test_a_python
endif
test_fortran_old_cmor_tables: cmor Tables
	@env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/tas_3D_noreorder.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_txy.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_txy_split_lon.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_xty_split_lon.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/tas_3D_noreorder.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_txy.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_txy_split_lon.input" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_xty_split_lon.input" make test_case_old_cmor_tables
	@env TEST_NAME="karls_test" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test1" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test2" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test3" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test4" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="main_prog" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_any_from_asc_i" INPUT_FILE="Test/tas_mytest_3d_i.input" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_r" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	# @env TEST_NAME="rewrite_harvardf_data" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_3h" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_dimensionless" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_fortran_example_00" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_fortran_example_01" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_station_data" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_region" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_sigma" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_singleton" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	# @env TEST_NAME="test_singleton_5D_tas" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_r_big_array" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_d_big_array_2" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_d_big_array_3" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_d_big_array_4" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="mytest_4d_d_big_array_5" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="climatology_test_code" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_lots_of_variables" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_shrt_exp_nm_set_att_initi" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	@env TEST_NAME="test_sophie" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
test_fortran: cmor
	env TEST_NAME="CMIP6_sample_CMOR_driver" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_cmor_fx_basin" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/tas_3D_noreorder.input" make test_case
	env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_txy.input" make test_case
	env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_txy_split_lon.input" make test_case
	env TEST_NAME="test_any_from_asc" INPUT_FILE="Test/3D_xty_split_lon.input" make test_case
	env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/tas_3D_noreorder.input" make test_case
	env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_txy.input" make test_case
	env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_txy_split_lon.input" make test_case
	env TEST_NAME="test_any_from_asc_d" INPUT_FILE="Test/3D_xty_split_lon.input" make test_case
	env TEST_NAME="karls_test" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test1" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test2" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test3" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test4" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="main_prog" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_any_from_asc_i" INPUT_FILE="Test/tas_mytest_3d_i.input" make test_case
	env TEST_NAME="mytest_4d_r" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="rewrite_harvardf_data" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_3h" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_dimensionless" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_fortran_example_00" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_fortran_example_01" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_station_data" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_cmor_grid_alejandro" INPUT_FILE="Test/alejandro.txt" make test_case
	env TEST_NAME="test_cmor_grid_alejandro" INPUT_FILE="Test/alejandro_1.txt" make test_case
	#	env TEST_NAME="test_cmor_grid_alejandro" INPUT_FILE="Test/alejandro_2.txt" make test_case
	env TEST_NAME="test_cmor_grid_time_varying" INPUT_FILE="Test/alejandro.txt" make test_case
	env TEST_NAME="test_cmor_grid_time_varying" INPUT_FILE="Test/alejandro_1.txt" make test_case
	env TEST_NAME="test_region" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_sigma" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_singleton" INPUT_FILE="Test/noinput" make test_case
	#@env TEST_NAME="test_singleton_5D_tas" INPUT_FILE="Test/noinput" make test_case_old_cmor_tables
	env TEST_NAME="mytest_4d_r_big_array" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="mytest_4d_d_big_array_2" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="mytest_4d_d_big_array_3" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="mytest_4d_d_big_array_4" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="mytest_4d_d_big_array_5" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="climatology_test_code" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_shrt_exp_nm_set_att_initi" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="test_sophie" INPUT_FILE="Test/noinput" make test_case
	env TEST_NAME="ipcc_test_code" INPUT_FILE="Test/noinput" make test_case
ifeq ($(UNAME), Linux)
	env TEST_NAME="test_lots_of_variables" INPUT_FILE="Test/noinput" make test_case
endif
atest: cmor
#	@env TEST_NAME="mytest_4d_d_big_array_2" INPUT_FILE="Test/noinput" make test_case
	@env TEST_NAME="test_lots_of_variables" INPUT_FILE="Test/noinput" make test_case
#	@env TEST_NAME="wegner_test" INPUT_FILE="Test/noinput" make test_case



