ncap2 on shell gives error
Command-line operators for netCDF and HDF files
Brought to you by:
zender
I want to use ncap 2 on a shell script and followed examples from other tickets. However, I am still getting an error. Could you please correct this script? ncap2 -s "defdim('ens_member',${ensemble});pre[\$time, \$latitude,\$longitude, \$ens_member] = pre;" "$in" "$out" Many thanks,
I suggest you get the command working in a script first then once its working move it to the command line. eg
test.nco
then run the above script with the command
...Henry
Last edit: henry Butowsky 2024-07-18
Dear Henry,
Thanks for the tip. I used the follwoing script
cat << EOF > test.nco
defdim("ens_member", $ens);
pre[\$time, \$latitude, \$longitude, \$ens_member] = pre;
EOF
($ens is expanded from bash as a variable as it changes from 00 to 20) .
With this, ncap2 passed without any error from the bash script. But then when I look into the output file, no displayable variables found. I also tried defdim("ens",40 ), but it also did not work out.
Last edit: Husain Najafi 2024-07-19
its a bit tricky because you are redefining the variable "pre" that is already in input. try something like.
...Henry
Thanks Henry,
Now ens_member = UNLIMITED ; // (0 currently))
is there any way to define this dimension as fixes size?
I am getting ERROR nco_cnk_sz_set_trv() reports variable pre_new has dim_sz == 0L for non-record dimension ens_member. This should not occur and it will cause chunking to fail...
Last edit: Husain Najafi 2024-07-19
Either the dim ens_member is already defined as 0 (UNLIMITED) in the input file or your shell script is setting it to 0.