I have tried to download a climate model output from esgf website (https://esgf-node.llnl.gov/search/cmip6/ using the following R code.
###########################################################################
rm(list=ls())
library("epwshiftr")
#this indexes all the information about the models
test = init_cmip6_index(
activity = "ScenarioMIP",
variable = c("pr"),
frequency = "day",
experiment = c("ssp245"),
source = c("GFDL-ESM4"),
variant = "r1i1p1f1",
replica = FALSE,
latest = TRUE,
resolution = c("100 km"),
limit = 10000L,
data_node = NULL,
years = NULL,
save = FALSE
)
#to print the unique model
unique(test$source_id)
test$file_url
fileurl <- test$file_url
directory <- file.path(setwd("E:/New_Future/GFDL-ESM4/SSP245/"),fsep = .Platform$file.sep)
lapply(fileurl, function(url) download.file(url, file.path(directory, basename(url))))
###########################################################################
All the required files are downloaded using the Code. But, the problem is I couldn't access the downloaded nc files in CDO (it says open failed and no such file or directory) or in r (Error in ncatt_get(ncfile):Error, first passed argument must be an object of class ncdf4
). Is there a problem with the code or am I missing something? Here is simple code for downloading one file:
directory <- file.path(setwd("E:/New_Future/GFDL-ESM4/SSP245/"),fsep = .Platform$file.sep)
download.file("http://esgdata.gfdl.noaa.gov/thredds/fileServer/gfdl_dataroot4/ScenarioMIP/NOAA-GFDL/GFDL-ESM4/ssp245/r1i1p1f1/
day/pr/gr1/v20180701/pr_day_GFDL-ESM4_ssp245_r1i1p1f1_gr1_20150101-20341231.nc",
file.path(directory, basename("pr_day_GFDL-ESM4_ssp245_r1i1p1f1_gr1_20150101-20341231.nc")))