Menu

#30 ncap2 on shell gives error

open
nobody
None
3
2024-07-19
2024-07-18
No

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,

Discussion

  • henry Butowsky

    henry Butowsky - 2024-07-18

    I suggest you get the command working in a script first then once its working move it to the command line. eg

    test.nco

    defdim("ens",40 );
    pre[$time,$latitude,$longitude,$ens]=pre;
    

    then run the above script with the command

    ncap2 -S test.nco in.nc out.nc

    ...Henry

     

    Last edit: henry Butowsky 2024-07-18
  • Husain Najafi

    Husain Najafi - 2024-07-19

    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
  • henry Butowsky

    henry Butowsky - 2024-07-19

    its a bit tricky because you are redefining the variable "pre" that is already in input. try something like.

    defdim("ens",40 );
    pre_new[$time,$latitude,$longitude,$ens]=pre;
    

    ...Henry

     
  • Husain Najafi

    Husain Najafi - 2024-07-19

    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
  • henry Butowsky

    henry Butowsky - 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.

     

Log in to post a comment.

MongoDB Logo MongoDB