test_write_conf.R 2.93 KB
Newer Older
aho's avatar
aho committed
   chunks <- list(lat = 2, lon = 3)
   
aho's avatar
aho committed
   cluster <- list(queue_host = "local", #"nord3", #'local', #Q: What is the name? The ones recognized by autosubmit?
                  #temp_dir = '/esarchive/autosubmit/',  #Q: Do we need a dir for autosubmit? NO.
aho's avatar
aho committed
                  r_module = 'R/4.1.2-foss-2019b',
                  cores_per_job = 4,
                  job_wallclock = '01:00:00',
                  max_jobs = 4,
                  expid = "a659",  # different from now
                  user_id = "bsc32734")  # different from now

  autosubmit_suite_dir <- "/home/Earth/aho/startR_local_autosubmit/"

aho's avatar
aho committed
# These two functions should be called by ByChunks
aho's avatar
aho committed
source("/esarchive/scratch/aho/git/aho-testtest/startR/autosubmit/write_autosubmit_conf.R")
aho's avatar
aho committed
source("/esarchive/scratch/aho/git/aho-testtest/startR/autosubmit/write_bash.R")
aho's avatar
aho committed

write_autosubmit_conf(chunks, cluster, autosubmit_suite_dir)
aho's avatar
aho committed

write_bash(chunks, cluster, autosubmit_suite_dir)

#========================================================

  library(startR)

  data <- Start(dat = "/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_f6h/$var$_$sdate$.nc",
                var = c('tas'),
                sdate = paste0(2017:2018, '0501'),
                ensemble = 'all',
aho's avatar
aho committed
                ftime = indices(1:3),
aho's avatar
aho committed
                lat = values(list(20, 80)), lat_reorder = Sort(),
                lon = values(list(-80, 40)), lon_reorder = CircularSort(-180, 180),
aho's avatar
aho committed
                synonims = list(ftime = c('ftime', 'time'), lat = c('lat', 'latitude'), lon = c('lon', 'longitude')),
                return_vars = list(ftime = 'sdate', lon = NULL, lat = NULL),
aho's avatar
aho committed
                retrieve = FALSE)

 func <- function(x) {
   return(x)
 }

  step <- Step(func, target_dims = c('lat', 'lon'), output_dims = c('lat', 'lon'),
               use_attributes = list("Variables"))
  wf <- AddStep(data, step)

  autosubmit_suite_dir <- "/home/Earth/aho/startR_local_autosubmit/"

#--------- Source stuff for testing -------------
  setwd('/esarchive/scratch/aho/git/aho-testtest/startR/autosubmit')
  source('Compute.R')
  source('ByChunks_AS.R')
  .message <- startR:::.message
  .warning <- startR:::.warning
#-----------------------------------------------

  res <- Compute(wf, chunks = list(sdate = 2),
                 threads_compute = 4,
                 cluster = list(
                   queue_host = 'nord3', #Q:What should the name be?
#                   queue_type = 'slurm',
#                   temp_dir = temp_dir,
                   r_module = 'R/4.1.2-foss-2019b',
                   cores_per_job = 4,
                   job_wallclock = '01:00:00',
                   max_jobs = 4,
#                   bidirectional = FALSE,
                   polling_period = 10,
aho's avatar
aho committed
                  expid = "a68h", #"a659",
aho's avatar
aho committed
                  user_id = "bsc32734"
                 ),
                 ecflow_suite_dir = autosubmit_suite_dir,
                 ecflow_server = 'autosubmit',
                 wait = FALSE #TRUE
                 )