Commit e868f05f authored by Ethan Coon's avatar Ethan Coon
Browse files

rework of makefiles

parent 9ca2fc3f
......@@ -11,17 +11,15 @@ cc_fortran_wrappers: fortran
$(MAKE) -C cc_fortran_wrappers all
cc:
$(MAKE) -C cc all
echo "header only"
fortran:
$(MAKE) -C fortran all
clean:
$(MAKE) -C cc clean
$(MAKE) -C fortran clean
allclean:
$(MAKE) -C cc clean
$(MAKE) -C fortran clean
......
#ifndef ELM_CANOPY_HYDROLOGY_HH_
#define ELM_CANOPY_HYDROLOGY_HH_
#include "CanopyHydrology_decl.hh"
#include "CanopyHydrology_Interception_impl.hh"
#include "CanopyHydrology_FracWet_impl.hh"
#include "CanopyHydrology_FracH2OSfc_impl.hh"
#include "CanopyHydrology_SnowWater_impl.hh"
#endif
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <string>
#include "landunit_varcon.h"
#include "CanopyHydrology_cpp.hh"
using namespace std;
using std::min ;
using std::max ;
namespace ELM {
NATURE void CanopyHydrology_FracH2OSfc(const double& dtime,
const double& min_h2osfc,
const int& ltype,
const double& micro_sigma,
const double& h2osno,
double& h2osfc,
double& h2osoi_liq,
double& frac_sno,
double& frac_sno_eff,
double& qflx_h2osfc2topsoi,
double& frac_h2osfc)
{
bool no_update = false;
double shr_const_pi=4.0e0*atan(1.0e0) ;
bool no_update_l ;
double d,fd,dfdd,sigma ;
if (!no_update) {
no_update_l = false; }
else { no_update_l = no_update; }
qflx_h2osfc2topsoi = 0.0 ;
if ( ltype == istsoil || ltype == istcrop) {
if (h2osfc > min_h2osfc) {
d=0.0 ;
sigma=1.0e3 * micro_sigma ;
for(int l = 0 ; l < 10; l++) {
fd = 0.5*d*(1.00+erf(d/(sigma*sqrt(2.0)))) + sigma/sqrt(2.0*shr_const_pi)*exp(-pow(d,2)/(2.0*pow(sigma,2))) -h2osfc;
dfdd = 0.5*(1.00+erf(d/(sigma*sqrt(2.0))));
d = d - fd/dfdd;
}
frac_h2osfc = 0.5*(1.00+erf(d/(sigma*sqrt(2.0)))) ; }
else {
frac_h2osfc = 0.0 ;
h2osoi_liq = h2osoi_liq + h2osfc ;
qflx_h2osfc2topsoi = h2osfc/dtime ;
h2osfc=0.0 ;
}
if (!no_update_l) {
if (frac_sno > (1.0 - frac_h2osfc) && h2osno > 0) {
if (frac_h2osfc > 0.010) {
frac_h2osfc = max(1.00 - frac_sno,0.010) ;
frac_sno = 1.00 - frac_h2osfc; }
else {
frac_sno = 1.00 - frac_h2osfc;
}
frac_sno_eff=frac_sno;
}
}
}
else {
frac_h2osfc = 0.0;
}
}
}
\ No newline at end of file
#ifndef CANOPY_HYDROLOGY_FRACWET_IMPL_HH_
#define CANOPY_HYDROLOGY_FRACWET_IMPL_HH_
#include <algorithm>
#include <iostream>
#include <cmath>
#include <string>
#include "CanopyHydrology_cpp.hh"
using namespace std;
using std::min ;
......@@ -40,4 +43,6 @@ NATURE void CanopyHydrology_FracWet(const int& frac_veg_nosno,
}
}
\ No newline at end of file
}
#endif
#ifndef CANOPYHYDROLOGY_INTERCEPTION_IMPL_HH_
#define CANOPYHYDROLOGY_INTERCEPTION_IMPL_HH_
#include <algorithm>
#include <stdio.h>
#include <cmath>
......@@ -5,7 +9,6 @@
#include <string>
#include "landunit_varcon.h"
#include "column_varcon.h"
#include "CanopyHydrology_cpp.hh"
using namespace std;
using std::min ;
......@@ -152,4 +155,7 @@ namespace ELM {
}
}
}
\ No newline at end of file
}
#endif
#ifndef CANOPY_HYDROLOGY_SNOWWATER_IMPL_HH_
#define CANOPY_HYDROLOGY_SNOWWATER_IMPL_HH_
#include <stdio.h>
#include <cmath>
#include "landunit_varcon.h"
#include "column_varcon.h"
#include "clm_varpar.h"
#include "clm_varctl.h"
#include "CanopyHydrology_cpp.hh"
using namespace std;
using std::min ;
......@@ -252,3 +254,5 @@ if (ltype==istwet && t_grnd>tfrz) {
}
}
#endif
#ifndef ELM_CANOPY_HYDROLOGY_CPP_HH_
#define ELM_CANOPY_HYDROLOGY_CPP_HH_
#ifndef NATURE
#define NATURE
#endif
namespace ELM {
NATURE void CanopyHydrology_Interception(double dtime,
const double& forc_rain,
const double& forc_snow,
const double& irrig_rate,
const int& ltype, const int& ctype,
const bool& urbpoi, const bool& do_capsnow,
const double& elai, const double& esai,
const double& dewmx, const int& frac_veg_nosno,
double& h2ocan,
int n_irrig_steps_left, // need to be fixed
double& qflx_prec_intr,
double& qflx_irrig,
double& qflx_prec_grnd,
double& qflx_snwcp_liq,
double& qflx_snwcp_ice,
double& qflx_snow_grnd_patch,
double& qflx_rain_grnd) ;
NATURE void CanopyHydrology_FracWet(const int& frac_veg_nosno,
const double& h2ocan,
const double& elai,
const double& esai,
const double& dewmx,
double& fwet,
double& fdry) ;
template<typename Array_d>
NATURE void CanopyHydrology_SnowWater(const double& dtime,
const double& qflx_floodg,
const int& ltype,
const int& ctype,
const bool& urbpoi,
const bool& do_capsnow,
const int& oldfflag,
const double& forc_air_temp,
const double& t_grnd,
const double& qflx_snow_grnd_col,
const double& qflx_snow_melt,
const double& n_melt,
const double& frac_h2osfc,
double& snow_depth,
double& h2osno,
double& integrated_snow,
Array_d swe_old,
Array_d h2osoi_liq,
Array_d h2osoi_ice,
Array_d t_soisno,
Array_d frac_iceold,
int& snow_level,
Array_d dz,
Array_d z,
Array_d zi,
int& newnode,
double& qflx_floodc,
double& qflx_snow_h2osfc,
double& frac_sno_eff,
double& frac_sno) ;
NATURE void CanopyHydrology_FracH2OSfc(const double& dtime,
const double& min_h2osfc,
const int& ltype,
const double& micro_sigma,
const double& h2osno,
double& h2osfc,
double& h2osoi_liq,
double& frac_sno,
double& frac_sno_eff,
double& qflx_h2osfc2topsoi,
double& frac_h2osfc) ;
} // namespace
#endif
OBJECT = ../
default: all
include $(OBJECT)config/Makefile.config
# Order is important due to .mod file creation
OBJS =CanopyHydrology_Interception.cpp.o \
CanopyHydrology_FracWet.cpp.o \
CanopyHydrology_FracH2OSfc.cpp.o
all: $(OBJS)
$(AR) cr libelm.a $(OBJS)
clean:
@$(ELM_CLEAN);
@cd $(ELM_UTILS_DIR); $(ELM_CLEAN)
#ifndef COLUMN_VARPAR_H_
#define COLUMN_VARPAR_H_
static const int nlevsno = 5 ;
#endif
#ifndef COLUMN_VARCON_HH_
#define COLUMN_VARCON_HH_
static const int icol_roof = isturb_MIN*10 + 1;
static const int icol_sunwall = isturb_MIN*10 + 2;
static const int icol_shadewall = isturb_MIN*10 + 3;
static const int icol_road_imperv = isturb_MIN*10 + 4;
static const int icol_road_perv = isturb_MIN*10 + 5;
#endif
#ifndef LANDUNIT_VARCON_HH_
#define LANDUNIT_VARCON_HH_
static const int istsoil = 1 ;
static const int istcrop = 2 ;
......@@ -19,3 +20,5 @@
// character(len=landunit_name_length), public :: landunit_names(max_lunit) ;
static const int numurbl = isturb_MAX - isturb_MIN + 1 ;
#endif
......@@ -2,6 +2,10 @@
# Users should change these
# ------------------------------------------------------------------
#ifndef CONFIG_DONE
#define CONFIG_DONE
# Available from: git clone https://code.ornl.gov/isp/acme_inputdata
ELM_DATA_LOCATION ?= /home/7hp/Downloads/acme_inputdata
#ELM_DATA_LOCATION ?= /Users/uec/codes/elm/kernels/repos/acme_inputdata
......@@ -9,19 +13,26 @@ ELM_DATA_LOCATION ?= /home/7hp/Downloads/acme_inputdata
# assumes you have a working NETCDF. This can easily be the version built by
# ATS as a part of an ATS installation.
NETCDF_ROOT ?= /usr/local
MPI_LIB_ROOT ?= /usr/lib/x86_64-linux-gnu/openmpi
#NETCDF_ROOT ?= $(AMANZI_TPLS_DIR)
# assumes you have a working gfortran
FC = gfortran
FC_FLAGS += -fimplicit-none -free -g3 -fbounds-check -fbacktrace
FC_LIB_ROOT = /usr/lib/gcc/x86_64-linux-gnu/8 #/usr/local/Cellar/gcc/8.2.0/lib/gcc/8
FC ?= gfortran
FC_FLAGS ?= -fimplicit-none -free -g3 -fbounds-check -fbacktrace
FC_LIB_ROOT ?= /usr/lib/gcc/x86_64-linux-gnu/8
#FC_LIB_ROOT ?= /usr/local/Cellar/gcc/8.2.0/lib/gcc/8
# assumes you have a working c++ compiler
CC ?= gcc
#CC ?= clang
CXX ?= g++
MPICC ?= mpicc
MPICXX ?= mpic++
CPP_FLAGS += -g -Wall -Wshadow -std=c++11
CXXFLAGS += -g -Wall -Wshadow -std=c++11
#CXX ?= clang++
MPICC ?= mpicc
MPICXX ?= mpic++
CXXFLAGS += -g -Wall -Wshadow -std=c++11
STD_LIB_ROOT = /usr
# assumes you have a working CUDA
......@@ -31,17 +42,19 @@ CUDA_LIBS= -lopenblas -lpthread -lcudart -lcublas
CUDA_LIBDIRS=/usr/local/cuda-10.0/lib64
CUDA_INCDIRS=-I/usr/local/cuda-10.0/include
# END of User specified things
#----------------------------------------
NETCDF_FLAGS = -L$(NETCDF_ROOT)/lib -lnetcdf
NETCDFF_FLAGS = -L$(NETCDF_ROOT)/lib -lnetcdff
NETCDF_INC_FLAGS = -I$(NETCDF_ROOT)/include
ELM_FLAGS = -L$(ELM_ROOT) -lelm
ELM_INC_FLAGS = -I$(ELM_ROOT)
GFORTRAN_FLAGS = -L$(FC_LIB_ROOT) -lgfortran
# linking flags
CC_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(STD_LIB_ROOT)/lib -lstdc++ -L$(MPI_LIB_ROOT)/lib -L$(FC_LIB_ROOT) -lgfortran
FC_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdff
CXX_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf
CUDA_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(CUDA_LIBDIRS) -lstdc++ -lpthread -lcudart -lcublas
CUDA_LD_FLAGS = -L$(CUDA_LIBDIRS) -lpthread -lcudart -lcublas
#
# rules
......@@ -51,21 +64,14 @@ CUDA_LD_FLAGS += -L$(SRCDIR) -lelm -L$(NETCDF_ROOT) -lnetcdf -L$(CUDA_LIBDIRS) -
.SUFFIXES: .cc.o .F90.o .cpp.o .cu.o .cc .F90 .cpp .cu
%.F90.o: %.F90
$(FC) $(FC_FLAGS) -c $< -o $@
%.cc.o: %.cc
$(CC) $(CC_FLAGS) $(CPP_FLAGS) $(INC_FLAGS) -c $< -o $@
$(FC) $(FC_FLAGS) $(NETCDF_INC_FLAGS) $(ELM_INC_FLAGS) -c $< -o $@
%.cpp.o: %.cpp
$(CXX) $(CC_FLAGS) $(CXXFLAGS) $(INC_FLAGS) -c $< -o $@
$(CXX) $(CXXFLAGS) $(NETCDF_INC_FLAGS) $(ELM_INC_FLAGS) -c $< -o $@
%.cu.o: %.cu
$(NVCC) $(CUDA_FLAGS) $(INC_FLAGS) -c $< -o $@
$(NVCC) $(CUDA_FLAGS) -c $< -o $@
SHELL = /bin/sh
ELM_LIB = libelm.a
ELM_LIBS = -lelm
ELM_DIR = elm
ELM_UTILS_DIR = cime_utils
LIB_SUFFIX=.a
M4 =
......@@ -82,3 +88,4 @@ ELM_CLEAN=$(RM) -f *.o *.ii *.int.c *.log *.log.* stamp-* core core.* stats -r t
#endif
......@@ -15,7 +15,7 @@
#include "utils.hh"
#include "readers.hh"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
namespace ELM {
......@@ -24,7 +24,7 @@ namespace Utils {
static const int n_months = 12;
static const int n_pfts = 17;
static const int n_max_times = 31 * 24 * 2; // max days per month times hours per
// day * half hour timestep
// day * half hour timestep
static const int n_grid_cells = 24;
using MatrixState = MatrixStatic<n_grid_cells, n_pfts>;
......@@ -88,12 +88,14 @@ int main(int argc, char ** argv)
// output state by the pft
auto h2o_can = ELM::Utils::MatrixState(); h2o_can = 0.;
std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl;
auto min_max = std::minmax_element(h2o_can.begin(), h2o_can.end());
std::cout << std::setprecision(16)
<< 0 << "\t" << std::accumulate(h2o_can.begin(), h2o_can.end(), 0.)
<< "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl;
{
std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl;
auto min_max = std::minmax_element(h2o_can.begin(), h2o_can.end());
std::cout << std::setprecision(16)
<< 0 << "\t" << std::accumulate(h2o_can.begin(), h2o_can.end(), 0.)
<< "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl;
}
// main loop
// -- the timestep loop cannot/should not be parallelized
......@@ -114,19 +116,20 @@ int main(int argc, char ** argv)
qflx_snwcp_liq(g,p), qflx_snwcp_ice(g,p),
qflx_snow_grnd_patch(g,p), qflx_rain_grnd(g,p));
// qflx_prec_intr[g], qflx_irrig[g], qflx_prec_grnd[g],
// qflx_snwcp_liq[g], qflx_snwcp_ice[g],
// qflx_snow_grnd_patch[g], qflx_rain_grnd[g]);
// qflx_prec_intr[g], qflx_irrig[g], qflx_prec_grnd[g],
// qflx_snwcp_liq[g], qflx_snwcp_ice[g],
// qflx_snow_grnd_patch[g], qflx_rain_grnd[g]);
//printf("%i %i %16.8g %16.8g %16.8g %16.8g %16.8g %16.8g\n", g, p, forc_rain(t,g), forc_snow(t,g), elai(g,p), esai(g,p), h2o_can(g,p), qflx_prec_intr[g]);
}
}
auto min_max = std::minmax_element(h2o_can.begin(), h2o_can.end());
std::cout << std::setprecision(16)
<< t+1 << "\t" << std::accumulate(h2o_can.begin(), h2o_can.end(), 0.)
<< "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl;
{
auto min_max = std::minmax_element(h2o_can.begin(), h2o_can.end());
std::cout << std::setprecision(16)
<< t+1 << "\t" << std::accumulate(h2o_can.begin(), h2o_can.end(), 0.)
<< "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl;
}
}
return 0;
MPI_Finalize();
......
......@@ -14,7 +14,7 @@
#include "utils.hh"
#include "readers.hh"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
namespace ELM {
......
......@@ -16,7 +16,7 @@
#include "readers.hh"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
#include "CanopyHydrology_SnowWater_impl.hh"
......
OBJECT = ../../src/
ELM_BASE = ../../src
KERNEL_FOLDER = cc
SRCDIR = $(OBJECT)$(KERNEL_FOLDER)
MPI = /usr/lib/x86_64-linux-gnu/openmpi/include
NATURE =
include $(OBJECT)config/Makefile.config
ELM_ROOT = $(ELM_BASE)/$(KERNEL_FOLDER)
INC_FLAGS = -I$(NETCDF_ROOT)/include -I$(MPI) -I$(SRCDIR)
FC = mpifort
CXX = mpicxx
CC = mpicc
include $(ELM_BASE)/config/Makefile.config
TESTS = test_CanopyHydrology_kern1_single \
test_CanopyHydrology_kern1_multiple \
......@@ -36,22 +37,16 @@ CanopyHydrology_module: test_CanopyHydrology_module
./test_CanopyHydrology_module > test_CanopyHydrology_module.stdout
test_%: %.cpp.o readers.hh utils.hh library
$(MPICXX) -o $@ $< $(CC_LD_FLAGS)
test_%: %.cpp.o readers.hh utils.hh
$(CXX) -o $@ $< $(NETCDF_FLAGS)
clean:
@$(ELM_CLEAN)
$(RM) test_*
$(RM) test_* *.o
allclean:
@$(ELM_CLEAN)
$(RM) test_*
$(MAKE) -C $(OBJECT) allclean
allclean: clean
links:
@echo "making in links"
$(MAKE) -C ../links links
library:
$(MAKE) -C $(OBJECT)cc
......@@ -16,7 +16,7 @@
#include "readers.hh"
#include "landunit_varcon.h"
#include "column_varcon.h"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
namespace ELM {
namespace Utils {
......
......@@ -16,7 +16,7 @@
#include "utils.hh"
#include "readers.hh"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
namespace ELM {
namespace Utils {
......
......@@ -13,7 +13,7 @@
#include <Kokkos_Core.hpp>
#include "utils.hh"
#include "readers.hh"
#include "CanopyHydrology_cpp.hh"
#include "CanopyHydrology.hh"
#include "CanopyHydrology_SnowWater_impl.hh"
namespace ELM {
......
/* ---------------------------------------------
Makefile constructed configuration:
Tue Jun 18 14:57:16 EDT 2019
Tue Jun 18 16:08:50 EDT 2019
----------------------------------------------*/
#if !defined(KOKKOS_MACROS_HPP) || defined(KOKKOS_CORE_CONFIG_H)
#error "Do not include KokkosCore_config.h directly; include Kokkos_Macros.hpp instead."
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment