Skip to content

Commit

Permalink
update to NCAR(upstream) master. README.md conflict resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
nmizukami committed May 3, 2019
2 parents 8c8902f + cb96586 commit 7c07058
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
*.exe
*.out
*.app

# other files
*.local
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.56043.svg)](http://dx.doi.org/10.5281/zenodo.56043)
# mizuRoute
mizuRoute is a stand-alone, post-processor of runoff output from a hydrologic model to produce streamflow estimates in the river network. The tool was developed for the large scale river routing (e.g., river network over contiguous United States), but works for small-size headwater basin as well.

Expand Down
12 changes: 7 additions & 5 deletions netcdf_test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
CC=pgf90

ifeq "$(CC)" "gfortran"
NCDF_PATH=/opt/netcdf-4.3.0+gcc-4.7.2
NCDF_PATH=/opt/netcdf4-gcc
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif

ifeq "$(CC)" "ifort"
NCDF_PATH = /usr/local/netcdf-4.3.0+ifort-12.1
NCDF_PATH = /opt/netcdf4-intel
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif

ifeq "$(CC)" "pgf90"
LIBNETCDF = -L/usr/local/netcdf-4.3.0+pgi-13.4/lib -lnetcdff -lnetcdf
INCNETCDF = -I/usr/local/netcdf-4.3.0+pgi-13.4/include
NCDF_PATH = /opt/netcdf4-pgi
LIBNETCDF = -L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif

# define flags
Expand All @@ -39,7 +40,8 @@ endif

ifeq "$(CC)" "pgf90"
FLAGS1 = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time
FLAGS = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
#FLAGS = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
FLAGS = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
endif

# define program
Expand Down
103 changes: 46 additions & 57 deletions ntopo/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,65 @@
#
#
#========================================================================
# PART 0: Define directory paths
# PART 0: User configure part
#========================================================================
# Define fortran compiler - gfortran, ifort or pgf90
FC = COMPILERNAME

# Define core directory below which everything resides
F_MASTER = /home/mizukami/hydro_nm/nHRU_routing/ntopo.v1/
# parent directory of the 'build' directory
# do not put space at the end of path
F_MASTER = PARENTDIRECTORY

# Define the NetCDF libraries and path to include files
ifeq "$(FC)" "gfortran"
NCDF_PATH=/opt/netcdf4-gcc
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "ifort"
NCDF_PATH = /opt/netcdf4-intel
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "pgf90"
NCDF_PATH = /opt/netcdf4-pgf90
LIBNETCDF = -L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif

# Define flags
ifeq "$(FC)" "gfortran"
FLAGS = -Wall -g -ffree-line-length-none
endif
ifeq "$(FC)" "ifort"
FLAGS1 = -warn all -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency
# FLAGS = -static -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
FLAGS = -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
endif
ifeq "$(FC)" "pgf90"
FLAGS1 = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time
FLAGS = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
endif

#========================================================================
# PART 1: Define directory paths
#========================================================================
# Core directory that contains source code
F_KORE_DIR = $(F_MASTER)build/
F_KORE_DIR = $(F_MASTER)build/src/

# Location of the compiled modules
MOD_PATH = $(F_MASTER)build/

# Define the directory for the executables
EXE_PATH = $(F_MASTER)bin
#

#========================================================================
# PART 1: Assemble all of the FUSE sub-routines
# PART 1: Assemble all of the sub-routines
#========================================================================
# Define subroutines
#
# data types
DATATYPES = \
nrtype.f90 \
Expand All @@ -50,47 +89,14 @@ QROUTE = \
network_topo.f90 \

# concatanate model subroutines
#TEMP_MODSUB = $(DATATYPES) $(UTILS) $(NUMREC) $(IO) $(QROUTE)
TEMP_MODSUB = $(DATATYPES) $(UTILS) $(IO) $(QROUTE)

# insert appropriate directory name
MODSUB = $(patsubst %, $(F_KORE_DIR)%, $(TEMP_MODSUB))

#========================================================================
# PART 2: Define the libraries, driver programs, and executables
# PART 2: Define driver programs, and executables
#========================================================================

# Define the Fortran Compiler
FC = ifort

# Define the NetCDF libraries and path to include files
ifeq "$(FC)" "gfortran"
HDF_PATH=/opt/hdf5
ZLIB=/opt/zlib
NCDF_PATH=/opt/netcdf-4.3.0+gcc-4.7.2
SZIP=/opt/szip
LIBNETCDF = -Wl,-rpath,$(HDF_PATH)/lib:$(ZLIB)/lib:$(NCDF_PATH)/lib:$(SZIP)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf \
-L$(HDF_PATH)/lib -lhdf5_hl -lhdf5 \
-L$(ZLIB) -L$(SZIP)-lsz -lz -lcurl
INCNETCDF = -I$(NCDF_PATH)/include -I/$(HDF_PATH)/include -I$(SZIP)/include -I$(ZLIB)/include
endif
ifeq "$(FC)" "ifort"
HDF_PATH = /usr/local/hdf5
NCDF_PATH = /usr/local/netcdf-4.3.0+ifort-12.1
LOCL_PATH = /usr/local
SZIP = /opt/szip
ZLIB = /opt/zlib
XTRA_LIBS = -L$(LOCL_PATH) -L$(SZIP)/lib -L$(ZLIB)/lib -lsz -lz -lcurl
LIBNETCDF = -Wl,-rpath,$(HDF_PATH)/lib:$(ZLIB)/lib:$(NCDF_PATH)/lib:$(SZIP)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf -L$(HDF_PATH)/lib -lhdf5_hl -lhdf5 $(XTRA_LIBS)
INCNETCDF = -I$(NCDF_PATH)/include -I/$(HDF_PATH)/include -I$(SZIP)/include -I$(ZLIB)/include
endif
ifeq "$(FC)" "pgf90"
LIBNETCDF = -L/usr/local/netcdf4-pgi/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lsz -lz
INCNETCDF = -I/usr/local/netcdf4-pgi/include
endif

# Define the driver routine
DRIVER = $(F_KORE_DIR)process_river_topology.f90

Expand All @@ -100,23 +106,6 @@ EXE = process_river_topology.exe
#========================================================================
# PART 3: Compile the puppy
#========================================================================

# Define flags
ifeq "$(FC)" "gfortran"
FLAGS = -Wall -g -ffree-line-length-none
endif
ifeq "$(FC)" "ifort"
FLAGS1 = -warn all -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency
# FLAGS = -static -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
FLAGS = -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
endif
ifeq "$(FC)" "pgf90"
FLAGS1 = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time
FLAGS = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
endif

#FLAGS = -O3 -W -v

#.SUFFIXES: .f .o .f90

# tasks
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
90 changes: 45 additions & 45 deletions route/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,55 @@
#========================================================================
#
#
# Define compiler
FC = ifort
#
#========================================================================
# PART 1: Define directory paths and compiler
# PART 0: User configure part
#========================================================================
# Define fortran compiler - gfortran, ifort or pgf90
FC = COMPILERNAME

# Define core directory below which everything resides
F_MASTER = /home/mizukami/mizuRoute/route.v1/
# parent directory of the 'build' directory
# do not put space at the end of path
F_MASTER = PARENTDIRECTORY

# Define the NetCDF libraries and path to include files
ifeq "$(FC)" "gfortran"
NCDF_PATH=/opt/netcdf4-gcc
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "ifort"
NCDF_PATH = /opt/netcdf4-intel
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "pgf90"
NCDF_PATH = /opt/netcdf4-pgf90
LIBNETCDF = -L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif

# Define flags
ifeq "$(FC)" "gfortran"
FLAGS = -Wall -g -ffree-line-length-none
endif
ifeq "$(FC)" "ifort"
FLAGS1 = -warn all -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency
# FLAGS = -static -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
FLAGS = -warn all -check all,noarg_temp_created -FR -O2 -auto -WB -traceback -g -fltconsistency -fpe0
# FLAGS = -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
endif
ifeq "$(FC)" "pgf90"
FLAGS1 = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time
FLAGS = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
endif

#========================================================================
# PART 1: Define directory paths
#========================================================================
# Core directory that contains source code
F_KORE_DIR = $(F_MASTER)build/src/

Expand All @@ -21,7 +60,7 @@ MOD_PATH = $(F_MASTER)build/

# Define the directory for the executables
EXE_PATH = $(F_MASTER)bin
#

#========================================================================
# PART 2: Assemble all of the sub-routines
#========================================================================
Expand Down Expand Up @@ -70,27 +109,8 @@ TEMP_MODSUB = $(DATATYPES) $(UTILS) $(NUMREC) $(IO) $(QROUTE)
MODSUB = $(patsubst %, $(F_KORE_DIR)%, $(TEMP_MODSUB))

#========================================================================
# PART 3: Define the libraries, driver programs, and executables
# PART 2: Define driver programs, and executables
#========================================================================

# Define the NetCDF libraries and path to include files
ifeq "$(FC)" "gfortran"
NCDF_PATH=/opt/netcdf-4.3.0+gcc-4.7.2
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "ifort"
NCDF_PATH = /usr/local/netcdf-4.3.0+ifort-12.1
LIBNETCDF = -Wl,-rpath,$(NCDF_PATH)/lib \
-L$(NCDF_PATH)/lib -lnetcdff -lnetcdf
INCNETCDF = -I$(NCDF_PATH)/include
endif
ifeq "$(FC)" "pgf90"
LIBNETCDF = -L/usr/local/netcdf-4.3.0+pgi-13.4/lib -lnetcdff -lnetcdf
INCNETCDF = -I/usr/local/netcdf-4.3.0+pgi-13.4/include
endif

# Define the driver routine
DRIVER = $(F_KORE_DIR)route_runoff.f90

Expand All @@ -100,26 +120,6 @@ EXE = route_runoff.exe
#========================================================================
# PART 4: Compile the puppy
#========================================================================

# Define flags
ifeq "$(FC)" "gfortran"
FLAGS = -Wall -g -ffree-line-length-none
endif
ifeq "$(FC)" "ifort"
FLAGS1 = -warn all -noerror_limit -FR -O0 -auto -WB -traceback -g -fltconsistency
# FLAGS = -static -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
FLAGS = -warn all -check all,noarg_temp_created -FR -O2 -auto -WB -traceback -g -fltconsistency -fpe0
# FLAGS = -debug -warn all -check all,noarg_temp_created -FR -O0 -auto -WB -traceback -g -fltconsistency -fpe0
endif
ifeq "$(FC)" "pgf90"
FLAGS1 = -Bstatic -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv -Mprof=lines,time
FLAGS = -Mbackslash -g -Mchkptr -Mchkstk -Mpgicoff -Minform=inform -Ktrap=divz,inv
endif

#FLAGS = -O3 -W -v

#.SUFFIXES: .f .o .f90

# tasks
all: compile install clean

Expand Down
27 changes: 19 additions & 8 deletions scripts/Calc_hru_wgtavg_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
import math
import netCDF4 as nc4

############################################
# hardcoded variables #
############################################
# Name of netCDF variable for polygon ID in input data
IDNM='hru_id'
# Name of netCDF variable for weight in weight data
WGTNM='weight'
OVRPLYNM='overlapPolyId'
LATNM='latitude'
LONNM='longitude'
OVRNM='overlaps'
############################################
# Class #
############################################
Expand All @@ -29,11 +40,11 @@ def __init__(self,ncName):

def getWgtHru(self,hru):
"""For given hru id, get weight of the intersected polygons and associated ID and lat/lon"""
wgtAll = getNetCDFData(self.ncName, 'weight')
overlapsIdAll = getNetCDFData(self.ncName, 'overlapPolyId')
latAll = getNetCDFData(self.ncName, 'latitude')
lonAll = getNetCDFData(self.ncName, 'longitude')
overlapsAll = getNetCDFData(self.ncName, 'overlaps')
wgtAll = getNetCDFData(self.ncName, WGTNM)
overlapsIdAll = getNetCDFData(self.ncName, OVRPLYNM)
latAll = getNetCDFData(self.ncName, LATNM)
lonAll = getNetCDFData(self.ncName, LONNM)
overlapsAll = getNetCDFData(self.ncName, OVRNM)

self.hruList = self.getHruID() # get hru id list
idx=self.hruList.index(hru) # get indix in array corresponding hru
Expand All @@ -46,7 +57,8 @@ def getWgtHru(self,hru):
return (self.wgt, self.overlapsId, self.lat, self.lon, self.overlaps)

def getHruIdName(self):
""" get Name of hru ID """
""" get Name of hru ID
it must be the 1st dimension """
f = nc4.Dataset(self.ncName,'r')
self.dim = f.dimensions
self.dimName = self.dim.keys()
Expand Down Expand Up @@ -109,7 +121,7 @@ def compAvgVal(nc_wgt,nc_in,varname):

dataVal = getNetCDFData(nc_in,varname) # Get data value
FillVal = getNetCDFAtt(nc_in,varname,'_FillValue') # Get data value
IdVal = getNetCDFData(nc_in,'hru_id')
IdVal = getNetCDFData(nc_in,IDNM)
dim1size = dataVal.shape[0]

#Initialize wgtVal[ntime,nhru]
Expand Down Expand Up @@ -146,7 +158,6 @@ def compAvgVal(nc_wgt,nc_in,varname):
Val2 = np.zeros((dim1size))
if np.nansum(wgtArray) > 0.0:
# print (np.nansum(wgtArray) > 0.0)
# print (overlaps != 0.0)
# Adjust weight value if valid weight value (> 0) exist in list
newWgtArray = [x/np.nansum(wgtArray) for x in wgtArray]
# print "%d invalid polygons out of %d polygons" %(numvoid,overlaps)
Expand Down

0 comments on commit 7c07058

Please sign in to comment.