Commit a3111eef authored by Pillai, Himanshu's avatar Pillai, Himanshu
Browse files

Make fixes and kern1_multiple works for both Kokkos and Legion

parent 148c48d8
...@@ -5,7 +5,7 @@ OBJECT = . ...@@ -5,7 +5,7 @@ OBJECT = .
default: all default: all
all: cc_fortran_wrappers fortran cc_implementation all: cc_fortran_wrappers fortran cc_serial cc_kokkos
cc_fortran_wrappers: fortran cc_fortran_wrappers: fortran
$(MAKE) -C cc_fortran_wrappers all $(MAKE) -C cc_fortran_wrappers all
......
...@@ -25,7 +25,7 @@ def run_comparison(testname, full_message=False): ...@@ -25,7 +25,7 @@ def run_comparison(testname, full_message=False):
gold = np.loadtxt(fname_gold, skiprows=1) gold = np.loadtxt(fname_gold, skiprows=1)
except IOError: except IOError:
print 'ERROR: cannot find gold file "%s", bad testname?'%fname_gold print 'ERROR: cannot find gold file "%s", bad testname?'%fname_gold
return 'G' return 'G '
# get my file # get my file
fname_mine = '%s.soln'%testname fname_mine = '%s.soln'%testname
...@@ -37,7 +37,7 @@ def run_comparison(testname, full_message=False): ...@@ -37,7 +37,7 @@ def run_comparison(testname, full_message=False):
mine = np.loadtxt(fname_mine, skiprows=1) mine = np.loadtxt(fname_mine, skiprows=1)
except IOError: except IOError:
print 'ERROR: cannot find my file "%s", failed test run?'%fname_mine print 'ERROR: cannot find my file "%s", failed test run?'%fname_mine
return 'D' return 'D '
# compare # compare
try: try:
...@@ -46,12 +46,12 @@ def run_comparison(testname, full_message=False): ...@@ -46,12 +46,12 @@ def run_comparison(testname, full_message=False):
if full_message: if full_message:
print '' print ''
print 'Test: "%s" FAILED with error: "%r"'%(testname, err) print 'Test: "%s" FAILED with error: "%r"'%(testname, err)
return 'E' return 'E '
if close: if close:
return 'PASS' return 'PASS '
else: else:
return 'FAIL' return 'FAIL '
if __name__ == "__main__": if __name__ == "__main__":
...@@ -69,5 +69,5 @@ if __name__ == "__main__": ...@@ -69,5 +69,5 @@ if __name__ == "__main__":
results.append(run_comparison(test, args.verbose)) results.append(run_comparison(test, args.verbose))
except Exception as err: except Exception as err:
print err print err
results.append('N/A') results.append('N/A ')
print ''.join(results) print ''.join(results)
OBJECT = ../../src/ OBJECT = ../../src/
KERNEL_FOLDER = cc_implementation KERNEL_FOLDER = cc_serial
SRCDIR = $(OBJECT)$(KERNEL_FOLDER) SRCDIR = $(OBJECT)$(KERNEL_FOLDER)
include $(OBJECT)config/Makefile.config include $(OBJECT)config/Makefile.config
...@@ -26,13 +26,13 @@ test: $(EXEC_TESTS) ...@@ -26,13 +26,13 @@ test: $(EXEC_TESTS)
CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single
./test_CanopyHydrology_kern1_single &> test_CanopyHydrology_kern1_single.stdout ./test_CanopyHydrology_kern1_single > test_CanopyHydrology_kern1_single.stdout
CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple
./test_CanopyHydrology_kern1_multiple &> test_CanopyHydrology_kern1_multiple.stdout ./test_CanopyHydrology_kern1_multiple > test_CanopyHydrology_kern1_multiple.stdout
CanopyHydrology_module: test_CanopyHydrology_module CanopyHydrology_module: test_CanopyHydrology_module
./test_CanopyHydrology_module &> test_CanopyHydrology_module.stdout ./test_CanopyHydrology_module > test_CanopyHydrology_module.stdout
test_%: %.cpp.o readers.hh utils.hh library test_%: %.cpp.o readers.hh utils.hh library
......
...@@ -28,13 +28,13 @@ test: $(EXEC_TESTS) ...@@ -28,13 +28,13 @@ test: $(EXEC_TESTS)
python ../compare_to_gold.py $(TESTS) python ../compare_to_gold.py $(TESTS)
CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single
./test_CanopyHydrology_kern1_single &> test_CanopyHydrology_kern1_single.stdout ./test_CanopyHydrology_kern1_single > test_CanopyHydrology_kern1_single.stdout
CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple
./test_CanopyHydrology_kern1_multiple &> test_CanopyHydrology_kern1_multiple.stdout ./test_CanopyHydrology_kern1_multiple > test_CanopyHydrology_kern1_multiple.stdout
CanopyHydrology_module: test_CanopyHydrology_module CanopyHydrology_module: test_CanopyHydrology_module
./test_CanopyHydrology_module &> test_CanopyHydrology_module.stdout ./test_CanopyHydrology_module > test_CanopyHydrology_module.stdout
test_%: %.cc.o readers.hh utils.hh library test_%: %.cc.o readers.hh utils.hh library
......
...@@ -29,7 +29,7 @@ program CanopyHydrology_kern1_single ...@@ -29,7 +29,7 @@ program CanopyHydrology_kern1_single
! This will be the netCDF ID for the file and data variable. ! This will be the netCDF ID for the file and data variable.
integer :: ncid, varid, dimid, status integer :: ncid, varid, dimid, status
status = nf90_open(SURFDAT_FILE_NAME, NF90_NOWRITE, ncid) status = nf90_open(SURFDAT_FILE_NAME, NF90_NOwrite, ncid)
if( status .ne. 0) call err_handle( status ) if( status .ne. 0) call err_handle( status )
...@@ -48,7 +48,7 @@ program CanopyHydrology_kern1_single ...@@ -48,7 +48,7 @@ program CanopyHydrology_kern1_single
status = nf90_close(ncid) status = nf90_close(ncid)
status = nf90_open(FORCDAT_FILE_NAME, NF90_NOWRITE, ncid) status = nf90_open(FORCDAT_FILE_NAME, NF90_NOwrite, ncid)
if( status .ne. 0) call err_handle( status ) if( status .ne. 0) call err_handle( status )
status = nf90_inq_dimid(ncid, "time", dimid) status = nf90_inq_dimid(ncid, "time", dimid)
if( status .ne. 0) call err_handle( status ) if( status .ne. 0) call err_handle( status )
...@@ -65,6 +65,8 @@ program CanopyHydrology_kern1_single ...@@ -65,6 +65,8 @@ program CanopyHydrology_kern1_single
h2ocan = 0.0d0 h2ocan = 0.0d0
print *, "Timestep, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr" print *, "Timestep, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr"
!open(1, file = 'test_CanopyHydrology_kern1_single.stdout', status = 'new')
!write(1,*)"Timestep, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr"
do itime=1,ntimes do itime=1,ntimes
...@@ -87,8 +89,11 @@ program CanopyHydrology_kern1_single ...@@ -87,8 +89,11 @@ program CanopyHydrology_kern1_single
qflx_snwcp_liq, qflx_snwcp_ice, qflx_snow_grnd_patch, qflx_rain_grnd) qflx_snwcp_liq, qflx_snwcp_ice, qflx_snow_grnd_patch, qflx_rain_grnd)
print *, itime, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr print *, itime, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr
!open(1,file='test_CanopyHydrology_kern1_single.stdout',action='write',position='append')
!write(1,*) itime, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr
end do end do
!close(1)
stop stop
contains contains
...@@ -97,6 +102,8 @@ program CanopyHydrology_kern1_single ...@@ -97,6 +102,8 @@ program CanopyHydrology_kern1_single
use netcdf use netcdf
integer :: status integer :: status
print *, 'error ', status, nf90_strerror(status) print *, 'error ', status, nf90_strerror(status)
!open(1,file='test_CanopyHydrology_kern1_single.stdout',action='write',position='append')
!write(1,*) 'error ', status, nf90_strerror(status)
stop stop
end subroutine err_handle end subroutine err_handle
......
...@@ -93,7 +93,12 @@ program test_CanopyHydrology_module ...@@ -93,7 +93,12 @@ program test_CanopyHydrology_module
h2ocan_pft = 0.0d0 h2ocan_pft = 0.0d0
frac_h2osfc = 0.0d0 frac_h2osfc = 0.0d0
print*, "Time", "Total Canopy Water", "Min Water", "Max Water", "Total Snow", &
"Min Snow", "Max Snow", "Avg Frac Sfc", "Min Frac Sfc", "Max Frac Sfc"
print*, 0, sum(h2ocan_pft), minval(h2ocan_pft), maxval(h2ocan_pft), sum(h2osno_grc), &
minval(h2osno_grc), maxval(h2osno_grc), sum(h2osoi_liq), minval(h2osoi_liq), maxval(h2osoi_liq)
do itime=1,28*48 ! February is shortest month do itime=1,28*48 ! February is shortest month
do g=1,ngrcs ! grid cell loop do g=1,ngrcs ! grid cell loop
...@@ -159,6 +164,9 @@ program test_CanopyHydrology_module ...@@ -159,6 +164,9 @@ program test_CanopyHydrology_module
dz_grc(g,:) = dz dz_grc(g,:) = dz
end do !mesh loop end do !mesh loop
print*, itime, sum(h2ocan_pft), minval(h2ocan_pft), maxval(h2ocan_pft), &
sum(h2osno_grc), minval(h2osno_grc), maxval(h2osno_grc), &
sum(h2osoi_liq), minval(h2osoi_liq), maxval(h2osoi_liq)
end do ! time loop end do ! time loop
......
...@@ -25,13 +25,13 @@ test: $(EXEC_TESTS) ...@@ -25,13 +25,13 @@ test: $(EXEC_TESTS)
CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single
./test_CanopyHydrology_kern1_single &> test_CanopyHydrology_kern1_single.stdout ./test_CanopyHydrology_kern1_single > test_CanopyHydrology_kern1_single.stdout
CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple CanopyHydrology_kern1_multiple: test_CanopyHydrology_kern1_multiple
./test_CanopyHydrology_kern1_multiple &> test_CanopyHydrology_kern1_multiple.stdout ./test_CanopyHydrology_kern1_multiple > test_CanopyHydrology_kern1_multiple.stdout
CanopyHydrology_module: test_CanopyHydrology_module CanopyHydrology_module: test_CanopyHydrology_module
./test_CanopyHydrology_module &> test_CanopyHydrology_module.stdout ./test_CanopyHydrology_module > test_CanopyHydrology_module.stdout
test_%: %.F90.o library test_%: %.F90.o library
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#include <cstring> #include <cstring>
#include <cmath>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
...@@ -100,7 +101,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_Interception(double dtime, ...@@ -100,7 +101,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_Interception(double dtime,
h2ocan = std::max(0.0, h2ocan + dtime*qflx_prec_intr); h2ocan = max(0.0, h2ocan + dtime*qflx_prec_intr);
qflx_candrip = 0.0; qflx_candrip = 0.0;
...@@ -196,8 +197,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracWet(const int& frac_veg_nosno, ...@@ -196,8 +197,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracWet(const int& frac_veg_nosno,
if (h2ocan > 0.0) { if (h2ocan > 0.0) {
vegt = frac_veg_nosno*(elai + esai); vegt = frac_veg_nosno*(elai + esai);
dewmxi = 1.00/dewmx; dewmxi = 1.00/dewmx;
fwet = std::pow(((dewmxi/vegt)*h2ocan), 2.0/3); fwet = pow(((dewmxi/vegt)*h2ocan), 2.0/3);
fwet = std::min(fwet,1.00); fwet = min(fwet,1.00);
fdry = (1.0-fwet)*elai/(elai+esai); fdry = (1.0-fwet)*elai/(elai+esai);
} }
else{ else{
...@@ -298,9 +299,9 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -298,9 +299,9 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
} else { } else {
if (forc_air_temp > tfrz + 2.) { if (forc_air_temp > tfrz + 2.) {
bifall=50. + 1.7*std::pow((17.0),1.5); bifall=50. + 1.7*pow((17.0),1.5);
} else if (forc_air_temp > tfrz - 15.) { } else if (forc_air_temp > tfrz - 15.) {
bifall=50. + 1.7*std::pow((forc_air_temp - tfrz + 15.),1.5); bifall=50. + 1.7*pow((forc_air_temp - tfrz + 15.),1.5);
} else { } else {
bifall=50.; bifall=50.;
} }
...@@ -309,7 +310,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -309,7 +310,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
newsnow = (1. - frac_h2osfc) * qflx_snow_grnd_col * dtime; newsnow = (1. - frac_h2osfc) * qflx_snow_grnd_col * dtime;
// update integrated_snow // update integrated_snow
integrated_snow = std::max(integrated_snow,h2osno) ; //h2osno could be larger due to frost integrated_snow = max(integrated_snow,h2osno) ; //h2osno could be larger due to frost
// snowmelt from previous time step * dtime // snowmelt from previous time step * dtime
snowmelt = qflx_snow_melt * dtime; snowmelt = qflx_snow_melt * dtime;
...@@ -324,9 +325,9 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -324,9 +325,9 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
// first compute change from melt during previous time step // first compute change from melt during previous time step
if(snowmelt > 0.) { if(snowmelt > 0.) {
smr=std::min(1.,(h2osno)/(integrated_snow)); smr=min(1.,(h2osno)/(integrated_snow));
frac_sno = 1. - std::pow((acos(fmin(1.,(2.*smr - 1.)))/rpi),(n_melt)) ; frac_sno = 1. - pow((acos(fmin(1.,(2.*smr - 1.)))/rpi),(n_melt)) ;
} }
...@@ -336,8 +337,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -336,8 +337,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
frac_sno = fsno_new; frac_sno = fsno_new;
// reset integrated_snow after accumulation events // reset integrated_snow after accumulation events
temp_intsnow= (h2osno + newsnow) / (0.5*(cos(rpi*std::pow((1.0-std::max(frac_sno,1e-6)),(1.0/n_melt))+1.0))) ; temp_intsnow= (h2osno + newsnow) / (0.5*(cos(rpi*pow((1.0-max(frac_sno,1e-6)),(1.0/n_melt))+1.0))) ;
integrated_snow = std::min(1.e8,temp_intsnow) ; integrated_snow = min(1.e8,temp_intsnow) ;
} }
//==================================================================== //====================================================================
...@@ -358,10 +359,10 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -358,10 +359,10 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
if (oldfflag == 1) { if (oldfflag == 1) {
// snow cover fraction in Niu et al. 2007 // snow cover fraction in Niu et al. 2007
if(snow_depth > 0.0) { if(snow_depth > 0.0) {
frac_sno = tanh(snow_depth/(2.5*zlnd*std::pow((std::min(800.0,(h2osno+ newsnow)/snow_depth)/100.0),1.0)) ) ; frac_sno = tanh(snow_depth/(2.5*zlnd*pow((min(800.0,(h2osno+ newsnow)/snow_depth)/100.0),1.0)) ) ;
} }
if(h2osno < 1.0) { if(h2osno < 1.0) {
frac_sno=std::min(frac_sno,h2osno); frac_sno=min(frac_sno,h2osno);
} }
} }
...@@ -374,8 +375,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -374,8 +375,8 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
// make integrated_snow consistent w/ new fsno, h2osno // make integrated_snow consistent w/ new fsno, h2osno
integrated_snow = 0. ;//reset prior to adding newsnow below integrated_snow = 0. ;//reset prior to adding newsnow below
temp_intsnow= (h2osno + newsnow) / (0.5*(cos(rpi*std::pow((1.0-std::max(frac_sno,1e-6)),(1.0/n_melt)))+1.0)); temp_intsnow= (h2osno + newsnow) / (0.5*(cos(rpi*pow((1.0-max(frac_sno,1e-6)),(1.0/n_melt)))+1.0));
integrated_snow = std::min(1.e8,temp_intsnow); integrated_snow = min(1.e8,temp_intsnow);
// update snow_depth and h2osno to be consistent with frac_sno, z_avg // update snow_depth and h2osno to be consistent with frac_sno, z_avg
if (subgridflag ==1 && !urbpoi) { if (subgridflag ==1 && !urbpoi) {
...@@ -387,7 +388,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime, ...@@ -387,7 +388,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_SnowWater(const double& dtime,
if (oldfflag == 1) { if (oldfflag == 1) {
// snow cover fraction in Niu et al. 2007 // snow cover fraction in Niu et al. 2007
if(snow_depth > 0.0) { if(snow_depth > 0.0) {
frac_sno = tanh(snow_depth/(2.5*zlnd*std::pow((std::min(800.0,newsnow/snow_depth)/100.0),1.0)) ); frac_sno = tanh(snow_depth/(2.5*zlnd*pow((min(800.0,newsnow/snow_depth)/100.0),1.0)) );
} }
} }
} else { } else {
...@@ -488,7 +489,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracH2OSfc(const double& dtime, ...@@ -488,7 +489,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracH2OSfc(const double& dtime,
sigma=1.0e3 * micro_sigma ; sigma=1.0e3 * micro_sigma ;
for(int l = 0 ; l < 10; l++) { 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)*std::exp(-std::pow(d,2)/(2.0*std::pow(sigma,2))) -h2osfc; 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)))); dfdd = 0.5*(1.00+erf(d/(sigma*sqrt(2.0))));
d = d - fd/dfdd; d = d - fd/dfdd;
...@@ -509,7 +510,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracH2OSfc(const double& dtime, ...@@ -509,7 +510,7 @@ KOKKOS_INLINE_FUNCTION void CanopyHydrology_FracH2OSfc(const double& dtime,
if (frac_sno > (1.0 - frac_h2osfc) && h2osno > 0) { if (frac_sno > (1.0 - frac_h2osfc) && h2osno > 0) {
if (frac_h2osfc > 0.010) { if (frac_h2osfc > 0.010) {
frac_h2osfc = std::max(1.00 - frac_sno,0.010) ; frac_h2osfc = max(1.00 - frac_sno,0.010) ;
frac_sno = 1.00 - frac_h2osfc; } frac_sno = 1.00 - frac_h2osfc; }
else { else {
frac_sno = 1.00 - frac_h2osfc; frac_sno = 1.00 - frac_h2osfc;
...@@ -701,7 +702,7 @@ int main(int argc, char ** argv) ...@@ -701,7 +702,7 @@ int main(int argc, char ** argv)
// std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl; // std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl;
// auto min_max = std::minmax_element(&h_h2ocan(0,0), end1+1); // auto min_max = std::minmax_element(&h_h2ocan(0,0), end1+1);
// std::cout << std::setprecision(16) // std::cout << std::minmax_element(16)
// << 0 << "\t" << std::accumulate(&h_h2ocan(0,0), end1+1, 0.) // << 0 << "\t" << std::accumulate(&h_h2ocan(0,0), end1+1, 0.)
// << "\t" << *min_max.first // << "\t" << *min_max.first
// << "\t" << *min_max.second << std::endl; // << "\t" << *min_max.second << std::endl;
...@@ -772,13 +773,13 @@ int main(int argc, char ** argv) ...@@ -772,13 +773,13 @@ int main(int argc, char ** argv)
// PFT level operations // PFT level operations
//for (size_t p = 0; p != n_pfts; ++p) { //for (size_t p = 0; p != n_pfts; ++p) {
Kokkos::parallel_for("n_grid_cells", n_grid_cells, KOKKOS_LAMBDA (const size_t& g) { Kokkos::parallel_for("n_grid_cells", n_grid_cells, KOKKOS_LAMBDA (const size_t& g) {
for (size_t p = 0; p != n_pfts; ++p) { for (size_t p = 0; p != n_pfts; ++p) {
// //
// Calculate interception // Calculate interception
// //
// NOTE: this currently punts on what to do with the qflx variables! // NOTE: this currently punts on what to do with the qflx variables!
// Surely they should be either accumulated or stored on PFTs as well. // Surely they should be either std::accumulated or stored on PFTs as well.
// --etc // --etc
ELM::CanopyHydrology_Interception(dtime, ELM::CanopyHydrology_Interception(dtime,
forc_rain(t,g), forc_snow(t,g), forc_irrig(t,g), forc_rain(t,g), forc_snow(t,g), forc_irrig(t,g),
...@@ -835,7 +836,7 @@ int main(int argc, char ** argv) ...@@ -835,7 +836,7 @@ int main(int argc, char ** argv)
// auto min_max = std::minmax_element(&h_h2ocan(0,0), end1+1); // auto min_max = std::minmax_element(&h_h2ocan(0,0), end1+1);
// std::cout << std::setprecision(16) // std::cout << std::minmax_element(16)
// << t+1 << "\t" << std::accumulate(&h_h2ocan(0,0), end1+1, 0.) // << t+1 << "\t" << std::accumulate(&h_h2ocan(0,0), end1+1, 0.)
// << "\t" << *min_max.first // << "\t" << *min_max.first
// << "\t" << *min_max.second << std::endl; // << "\t" << *min_max.second << std::endl;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <numeric> #include <numeric>
#include <fstream>
#include <algorithm> #include <algorithm>
#include <Kokkos_Core.hpp> #include <Kokkos_Core.hpp>
#include "utils.hh" #include "utils.hh"
...@@ -145,12 +146,14 @@ int main(int argc, char ** argv) ...@@ -145,12 +146,14 @@ int main(int argc, char ** argv)
double* end = &h_h2o_can(n_grid_cells-1, n_pfts-1) ; double* end = &h_h2o_can(n_grid_cells-1, n_pfts-1) ;
std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl; std::ofstream soln_file;
soln_file.open("test_CanopyHydrology_kern1_multiple.soln");
soln_file << "Time\t Total Canopy Water\t Min Water\t Max Water" << std::endl;
auto min_max = std::minmax_element(&h_h2o_can(0,0), end+1);//h2o_can1.begin(), h2o_can1.end()); auto min_max = std::minmax_element(&h_h2o_can(0,0), end+1);//h2o_can1.begin(), h2o_can1.end());
std::cout << std::setprecision(16) soln_file << std::setprecision(16)
<< 0 << "\t" << std::accumulate(&h_h2o_can(0,0), end+1, 0.) //h2o_can1.begin(), h2o_can1.end(), 0.) << 0 << "\t" << std::accumulate(&h_h2o_can(0,0), end+1, 0.) //h2o_can1.begin(), h2o_can1.end(), 0.)
<< "\t" << *min_max.first << "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl; << "\t" << *min_max.second << std::endl;
...@@ -192,12 +195,12 @@ int main(int argc, char ** argv) ...@@ -192,12 +195,12 @@ int main(int argc, char ** argv)
}); });
auto min_max = std::minmax_element(&h_h2o_can(0,0), end+1);//h2o_can1.begin(), h2o_can1.end()); auto min_max = std::minmax_element(&h_h2o_can(0,0), end+1);//h2o_can1.begin(), h2o_can1.end());
std::cout << std::setprecision(16) soln_file << std::setprecision(16)
<< t+1 << "\t" << std::accumulate(&h_h2o_can(0,0), end+1, 0.)//h2o_can1.begin(), h2o_can1.end(), 0.) << t+1 << "\t" << std::accumulate(&h_h2o_can(0,0), end+1, 0.)//h2o_can1.begin(), h2o_can1.end(), 0.)
<< "\t" << *min_max.first << "\t" << *min_max.first
<< "\t" << *min_max.second << std::endl; << "\t" << *min_max.second << std::endl;
} } soln_file.close();
} }
Kokkos::finalize(); Kokkos::finalize();
return 0; return 0;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <numeric> #include <numeric>
#include <fstream>
#include <Kokkos_Core.hpp> #include <Kokkos_Core.hpp>
#include "utils.hh" #include "utils.hh"
#include "readers.hh" #include "readers.hh"
...@@ -245,7 +246,9 @@ int main(int argc, char ** argv) ...@@ -245,7 +246,9 @@ int main(int argc, char ** argv)
double* end1 = &h_h2ocan(n_grid_cells-1, n_pfts-1) ; double* end1 = &h_h2ocan(n_grid_cells-1, n_pfts-1) ;
double* end2 = &h_h2osno(n_grid_cells-1) ; double* end2 = &h_h2osno(n_grid_cells-1) ;
double* end3 = &h_frac_h2osfc(n_grid_cells-1) ; double* end3 = &h_frac_h2osfc(n_grid_cells-1) ;
std::cout << "Time\t Total Canopy Water\t Min Water\t Max Water\t Total Snow\t Min Snow\t Max Snow\t Avg Frac Sfc\t Min Frac Sfc\t Max Frac Sfc" << std::endl; std::ofstream soln_file;
soln_file.open("test_CanopyHydrology_module.soln");
soln_file << "Time\t Total Canopy Water\t Min Water\t Max Water\t Total Snow\t Min Snow\t Max Snow\t Avg Frac Sfc\t Min Frac Sfc\t Max Frac Sfc" << std::endl;
auto min_max_water = std::minmax_element(&h_h2ocan(0,0), end1+1); auto min_max_water = std::minmax_element(&h_h2ocan(0,0), end1+1);
auto sum_water = std::accumulate(&h_h2ocan(0,0), end1+1, 0.); auto sum_water = std::accumulate(&h_h2ocan(0,0), end1+1, 0.);
...@@ -255,7 +258,7 @@ int main(int argc, char ** argv) ...@@ -255,7 +258,7 @@ int main(int argc, char ** argv)
auto min_max_frac_sfc = std::minmax_element(&h_frac_h2osfc(0), end3+1); auto min_max_frac_sfc = std::minmax_element(&h_frac_h2osfc(0), end3+1);
auto avg_frac_sfc = std::accumulate(&h_frac_h2osfc(0), end3+1, 0.) / (end3+1 - &h_frac_h2osfc(0)); auto avg_frac_sfc = std::accumulate(&h_frac_h2osfc(0), end3+1, 0.) / (end3+1 - &h_frac_h2osfc(0));