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

running first fortran test

parent b82343f7
......@@ -7,7 +7,7 @@ subroutine CanopyHydrologyKern1( dtime, &
use shr_kind_mod, only : &
r8 => shr_kind_r8, &
i4 => shr_kind_i8, &
i4 => shr_kind_i4, &
bool => shr_kind_bool
use column_varcon , only : icol_sunwall, icol_shadewall
......@@ -55,9 +55,7 @@ subroutine CanopyHydrologyKern1( dtime, &
if (ctype /= icol_sunwall .and. ctype /= icol_shadewall) then
if (frac_veg_nosno == 1 .and. (forc_rain + forc_snow) > 0._r8) then
! determine fraction of input precipitation that is snow and rain
fracsnow = forc_snow/(forc_snow + forc_rain)
fracrain = forc_rain/(forc_snow + forc_rain)
......@@ -100,7 +98,7 @@ subroutine CanopyHydrologyKern1( dtime, &
end if
else if (ltype==istice .or. ltype==istice_mec) then
h2ocan = 0._r8
qflx_candrip = 0._r8
qflx_through_snow = 0._r8
......@@ -109,6 +107,7 @@ subroutine CanopyHydrologyKern1( dtime, &
fracsnow = 0._r8
fracrain = 0._r8
end if
! Precipitation onto ground (kg/(m2 s))
......@@ -150,6 +149,7 @@ subroutine CanopyHydrologyKern1( dtime, &
qflx_snow_grnd_patch = 0._r8
qflx_rain_grnd = 0._r8
else
qflx_snwcp_liq = 0._r8
qflx_snwcp_ice = 0._r8
qflx_snow_grnd_patch = qflx_prec_grnd_snow ! ice onto ground (mm/s)
......
......@@ -5,7 +5,7 @@ OBJECT = .
default: all
include $(OBJECT)/config/Makefile.config
FCFLAGS += -I $(ELM_UTILS_DIR) -fbounds-check -g3
FCFLAGS += -I$(ELM_UTILS_DIR)
# Order is important due to .mod file creation
OBJS = \
......@@ -22,9 +22,8 @@ all: $(OBJS)
$(AR) cr libelm.a $(OBJS)
clean:
@$(ELM_CLEAN)
allclean: clean
@$(ELM_CLEAN);
@cd $(ELM_UTILS_DIR); $(ELM_CLEAN)
.PRECIOUS: %.o
.SUFFIXES:
.PHONY: all
.SUFFIXES: .o .F .f .c .C .cc .cxx .F90
.F90.o:
......@@ -16,11 +18,16 @@
SHELL = /bin/sh
ELM_DATA_LOCATION = /Users/uec/codes/elm/kernels/repos/ELM_Kernels/repos/acme_inputdata
ELM_LIB = libelm.a
ELM_LIBS = -lelm
ELM_DIR = elm
ELM_LIB_DEPEND = $(PARFLOW_LIB_DIR)/libelm.a
NETCDF_ROOT = /Users/uec/codes/ats/amanzi-tpls/install-0.88
ELM_UTILS_DIR = cime_utils
LIB_SUFFIX=.a
......@@ -31,7 +38,10 @@ CP = cp
XARGS =
FC = gfortran
FCFLAGS = -Wall -Wunused -fimplicit-none -free -O2
FCFLAGS = -Wall -Wunused -fimplicit-none -free -g3 -fbounds-check
#FCFLAGS = -Wall -Wunused -fimplicit-none -free -O3
LINKER = gfortran
AR = ar
......@@ -41,4 +51,8 @@ AR = ar
ELM_CLEAN=$(RM) *.o *.ii *.int.c *.log *.log.* stamp-* core core.* stats -r ti_files ii_files *.mod *.a
%.o : %.F90
@echo "found the right .o rule"
$(FC) -c $(FCFLAGS) $< -o $@
program testcanopyhydrologykern1
use netcdf
use shr_kind_mod, only : &
r8 => shr_kind_r8, &
i4 => shr_kind_i4, &
bool => shr_kind_bool
implicit none
character (len = *), parameter :: SURFDAT_FILE_NAME = "links/surfacedataWBW.nc"
character (len = *), parameter :: FORCDAT_FILE_NAME = "links/forcing8.nc"
integer(i4), parameter :: npfts=17, nmonths=12
integer(i4) :: ltype=1, ctype=1
logical(bool) :: urbpoi, do_capsnow
integer(i4) :: n_irrig_steps_left = 0
integer(i4) :: frac_veg_nosno = 1
real(r8) :: elai, esai, dewmx, forc_snow, forc_rain, qflx_prec_intr
real(r8) :: qflx_irrig, qflx_prec_grnd, qflx_snwcp_liq, qflx_snwcp_ice
real(r8) :: qflx_snow_grnd_patch, qflx_rain_grnd,irrig_rate, h2ocan
integer(i4), dimension(4) :: start, count
integer(i4), dimension(3) :: start3, count3
integer(i4) :: ipft,itime,ntimes
real(r8), dimension(npfts,nmonths) :: monthly_lai
real(r8), dimension(npfts,nmonths) :: monthly_sai
real(r8), dimension(:,:,:), allocatable :: total_precip
real(r8) :: dtime = 1800.
! This will be the netCDF ID for the file and data variable.
integer :: ncid, varid, dimid, status
status = nf90_open(SURFDAT_FILE_NAME, NF90_NOWRITE, ncid)
if( status .ne. 0) call err_handle( status )
status = nf90_inq_varid(ncid, "MONTHLY_LAI", varid)
count=(/1,1,npfts,nmonths/) ! netcdf files are row major damn it
start=(/1,1,1,1/) !
status = nf90_get_var(ncid, varid, monthly_lai,start=start,count=count)
if( status .ne. 0) call err_handle( status )
!do ipft=1,npfts
! print *, monthly_lai(ipft,12), monthly_lai(ipft,3), monthly_lai(ipft,6)
!end do
status = nf90_inq_varid(ncid, "MONTHLY_SAI", varid)
status = nf90_get_var(ncid, varid, monthly_sai,start=start,count=count)
if( status .ne. 0) call err_handle( status )
status = nf90_close(ncid)
status = nf90_open(FORCDAT_FILE_NAME, NF90_NOWRITE, ncid)
if( status .ne. 0) call err_handle( status )
status = nf90_inq_dimid(ncid, "time", dimid)
if( status .ne. 0) call err_handle( status )
status = nf90_inquire_dimension(ncid, dimid, len=ntimes)
if( status .ne. 0) call err_handle( status )
status = nf90_inq_varid(ncid, "PRECTmms", varid)
if( status .ne. 0) call err_handle( status )
start3=(/1,1,1/)
count3=(/1,1,ntimes/)
allocate( total_precip(1,1,ntimes) )
status = nf90_get_var(ncid, varid, total_precip, start=start3, count=count3)
if( status .ne. 0) call err_handle( status )
status = nf90_close(ncid)
h2ocan = 0.0d0
print *, "Timestep, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr"
do itime=1,ntimes
forc_rain = total_precip(1,1,itime)
forc_snow = 0.d0
dewmx = 0.1
elai = monthly_lai(8,6)
esai = monthly_sai(8,6)
frac_veg_nosno = 1
irrig_rate = 0.0d0
n_irrig_steps_left = 0
urbpoi=.false.
do_capsnow = .false.
call CanopyHydrologyKern1( dtime, &
qflx_prec_intr, frac_veg_nosno, dewmx, elai, esai, h2ocan, &
n_irrig_steps_left, qflx_irrig, qflx_prec_grnd, &
qflx_snwcp_liq, qflx_snwcp_ice, qflx_snow_grnd_patch, qflx_rain_grnd,irrig_rate, &
ltype, urbpoi, &
ctype, do_capsnow, forc_rain, forc_snow )
print *, itime, forc_rain, h2ocan, qflx_prec_grnd, qflx_prec_intr
end do
stop
contains
subroutine err_handle( status )
integer :: status
print *, 'error ', status
stop
end subroutine err_handle
end program
.PHONY: links library
SRCDIR = ../src/
OBJECT = ../src/
default: all
include $(OBJECT)config/Makefile.config
FCFLAGS += -I$(SRCDIR) -I$(SRCDIR)$(ELM_UTILS_DIR) -I$(NETCDF_ROOT)/include
all: links library CanopyHydrology_kern1_single
CanopyHydrology_kern1_single: test_CanopyHydrology_kern1_single
# ./test_$@
echo 'fail'
test_%: %.o
$(LINKER) $(FCFLAGS) -L$(OBJECT) -lelm -L$(NETCDF_ROOT)/lib -lnetcdff $< -o $@
clean:
@$(ELM_CLEAN)
$(RM) test_*
links:
@echo "making in links"
$(MAKE) -C links links
library:
$(MAKE) -C ../src all
SRCDIR = ../../src/
OBJECT = ../../src/
default: links
include $(OBJECT)config/Makefile.config
OBJS= forcing1.nc forcing2.nc forcing3.nc forcing4.nc forcing5.nc \
forcing6.nc forcing7.nc forcing8.nc forcing9.nc forcing10.nc \
forcing11.nc forcing12.nc forcing13.nc forcing14.nc forcing15.nc \
forcing16.nc forcing17.nc forcing18.nc forcing19.nc forcing20.nc \
forcing21.nc forcing22.nc forcing23.nc forcing24.nc \
surfacedataBRW.nc surfacedataWBW.nc
links: $(OBJS)
forcing1.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-01.nc forcing1.nc
forcing10.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-10.nc forcing10.nc
forcing11.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-11.nc forcing11.nc
forcing12.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-12.nc forcing12.nc
forcing13.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-01.nc forcing13.nc
forcing14.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-02.nc forcing14.nc
forcing15.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-03.nc forcing15.nc
forcing16.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-04.nc forcing16.nc
forcing17.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-05.nc forcing17.nc
forcing18.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-06.nc forcing18.nc
forcing19.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-07.nc forcing19.nc
forcing2.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-02.nc forcing2.nc
forcing20.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-08.nc forcing20.nc
forcing21.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-09.nc forcing21.nc
forcing22.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-10.nc forcing22.nc
forcing23.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-11.nc forcing23.nc
forcing24.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_US-Brw/CLM1PT_data/2003-12.nc forcing24.nc
forcing3.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-03.nc forcing3.nc
forcing4.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-04.nc forcing4.nc
forcing5.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-05.nc forcing5.nc
forcing6.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-06.nc forcing6.nc
forcing7.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-07.nc forcing7.nc
forcing8.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-08.nc forcing8.nc
forcing9.nc:
ln -s $(ELM_DATA_LOCATION)/atm/datm7/1x1pt_wbw/CLM1PT_data/2003-09.nc forcing9.nc
surfacedataBRW.nc:
ln -s $(ELM_DATA_LOCATION)/lnd/clm2/surfdata_map/surfdata_1x1pt_US-Brw_simyr1850.nc surfacedataBRW.nc
surfacedataWBW.nc:
ln -s $(ELM_DATA_LOCATION)/lnd/clm2/surfdata_map/surfdata_1x1pt_wbw_simyr1850.nc surfacedataWBW.nc
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