Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
library('RNetCDF')
# set path and filename
ncpath <- "/depot/ssg/geoshare/data/GLASS/INFEWS/DOE_Flood/historical/MPI-ESM-LR.WRF.day.NAM-22i.mbcn-gridMET/daily/daily/"
ncname <- "wbm_1950"
ncfname <- paste(ncpath, ncname, ".nc", sep="")
print(ncfname)
# open a netCDF file
ncin <- open.nc(ncfname, write=FALSE)
print(ncin)
print.nc(ncin)
## Provide the dir name(i.e sub dir) that you want to create under main dir:
main_dir <- "."
sub_dir <- "OUTPUT"
output_dir <- file.path(main_dir, sub_dir)
if (!dir.exists(output_dir)){
dir.create(output_dir)
} else {
print("Dir already exists!")
}
filename <- 'out.r.txt'
output_file <- paste(output_dir, filename, sep='/' )
print(output_file)
# write to a file
# Save the print(nc) dump to a text file
{
sink(output_file)
print.nc(ncin)
sink()
}
close.nc(ncin)