#PBS -S /bin/tcsh
#PBS -W group_list=g26113
#PBS -l select=20:ncpus=8:model=bro
#PBS -q long 
#PBS -l walltime=24:00:00

##PBS -l walltime=00:10:00
##PBS -q devel

##PBS -j oe

echo "cd into workdir"
cd $PBS_O_WORKDIR

#https://www.nas.nasa.gov/hecc/resources/pleiades.html

# NATIVE GRID groupings
# ---- 2D
# 0 dynamic sea surface height and model sea level anomaly
# 1 ocean bottom pressure and model ocean bottom pressure anomaly
# 2 ocean and sea-ice surface freshwater fluxes
# 3 ocean and sea-ice surface heat fluxes
# 4 atmosphere surface temperature, humidity, wind, and pressure
# 5 ocean mixed layer depth
# 6 ocean and sea-ice surface stress
# 7 sea-ice and snow concentration and thickness
# 8 sea-ice velocity
# 9 sea-ice and snow horizontal volume fluxes

# ---- 3D
# 10 Gent-McWilliams ocean bolus transport streamfunction
# 11 ocean three-dimensional volume fluxes
# 12 ocean three-dimensional potential temperature fluxes
# 13 ocean three-dimensional salinity fluxes
# 14 sea-ice salt plume fluxes
# 15 ocean potential temperature and salinity
# 16 ocean density, stratification, and hydrostatic pressure
# 17 ocean velocity
# 18 Gent-McWilliams ocean bolus velocity
# 19 ocean three-dimensional momentum tendency

rm pbs_nodefile
cat "$PBS_NODEFILE" > pbs_nodefile

set g_start = 0
set g_end = 20 

set ecco_access_dir = '/home5/ifenty/git_repos_others/ECCO-GROUP/ECCO-ACCESS/generating_netcdf'
set output_dir = '/nobackupp2/ifenty/podaac/podaac_20201216/valid_minmax_20210312/native/day_mean'
set base_dir = '/nobackupp2/ifenty/podaac/podaac_20201216/final_delivered/'
set time_type = "day_mean"
set grid_type = "native"
set n_workers = 1 
set threads_per_worker = 8
set run_description = 'calc_minmax_native_day_mean'

#>python ./valid_minmax_v4.py --dataset_base_dir=/nobackupp2/ifenty/podaac/podaac_20201216/final_delivered --grid_type=native --time_type=mon_mean --grouping_id=1 --output_dir=/nobackupp2/ifenty/podaac/podaac_20201216/valid_minmax_20210311b --n_workers=7 --threads_per_worker=2

#seq ${cpu_start} ${cpu_end} | parallel -j ${cpuspernode} -u --sshloginfile "$PBS_NODEFILE" \
#    "cd $PWD; /bin/tcsh ${ecco_access_dir}/invoke_python_valid_minmax_v4.csh ${run_description} ${ecco_access_dir} ${base_dir} ${output_dir} ${time_type} ${grid_type} ${n_workers} ${threads_per_worker} {}"
seq ${g_start} ${g_end} | parallel -j 1 -u --sshloginfile "$PBS_NODEFILE" \
    "cd $PWD; /bin/tcsh ${ecco_access_dir}/invoke_python_valid_minmax_v4.csh ${run_description} ${ecco_access_dir} ${base_dir} ${output_dir} ${time_type} ${grid_type} ${n_workers} ${threads_per_worker} {}"
