Saturday, March 12, 2022

[SOLVED] error compressing netcdf files using nccopy through a loop

Issue

I am trying to compress multiple netcdf files in different folders through a loop.

for i in `find . -iname 'wrfout*'`;
do
echo $i
time nccopy -d5 -s $i d_${i} 

When I run this code, I get an error message "./wrfout_d04_2011-08-13_00:00:00 Permission denied Location: file ../../ncdump/nccopy.c; line 1429". However, when I run the last line in the loop for individual files, it runs without any error messages. I have checked the permission mode for the execution file to "777" just to be sure, but still the error persists. Any help with this is approciated.


Solution

Your bash syntax suggests your output filenames are going to look like 'd_./wrfout_d04_2011-08-13_00:00:00'

Suggestion:

nccopy -d5 -s $i $(dirname $i)/d_$(basename $i) 


Answered By - Robert Davy
Answer Checked By - Robin (WPSolving Admin)