Skip to content

Commit

Permalink
added some useful checks and warnings in sl.grid.readFESOM
Browse files Browse the repository at this point in the history
  • Loading branch information
helgegoessling committed Mar 8, 2018
1 parent 7d023b7 commit 861366c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions R/sl.grid.readFESOM.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
sl.grid.readFESOM <-
function (griddir,rot=FALSE,rot.invert=FALSE,rot.abg,threeD=TRUE,remove.emptylev=TRUE,read.boundary=TRUE,reorder.ccw=TRUE,maxmaxneigh=12,findneighbours.maxiter=10,repeatlastpoint=TRUE,onlybaryc=FALSE,omitcoastnds=FALSE,calcpolyareas=TRUE,Rearth=6371000,basicreadonly=FALSE,verbose=TRUE) {

if (basicreadonly) {
print("Reading only basic grid data without further computation of neighbourhood etc.")
if (rot || threeD || reorder.ccw) {
print("Reading would be even faster with rot, reorder.ccw, and threeD all set to FALSE")
}
}

if (!file.exists(paste(griddir,"/nod2d.out",sep="")) || !file.exists(paste(griddir,"/elem2d.out",sep=""))) {
stop(paste0("Files nod2d.out and/or elem2d.out not found in ",griddir,"."))
}

if (threeD) {
if (!file.exists(paste(griddir,"/aux3d.out",sep="")) || !file.exists(paste(griddir,"/nod3d.out",sep=""))) {
stop("3D information (files aux3d.out and nod3d.out) seems to be missing or incomplete. To read 2D only, rerun with threeD=FALSE")
}
}

if (verbose) {print("reading node (grid point) coordinates and coast information ...")}
nod.scan = scan(paste0(griddir,"/nod2d.out"))
N = as.integer(nod.scan[1])
Expand Down
2 changes: 1 addition & 1 deletion man/sl.grid.readFESOM.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ a logical value indicating whether or not to compute the areas of the triangular
a scalar specifying the radius of the sphere - in case of FESOM the Earth. Used only if \code{calcpolyareas=TRUE}.
}
\item{basicreadonly}{
a logical value indicating whether or not only to read grid data without analysing neighborhood information etc.
a logical value indicating whether or not only to read grid data without analysing neighborhood information etc. Reading is even faster with rot, reorder.ccw, and threeD all set to FALSE.
}
\item{verbose}{
a logical value indicating whether or not print statements shall report on the function progess.
Expand Down

0 comments on commit 861366c

Please sign in to comment.