SwiftWork/DiagDevelopment

How to maintain the swift version and the c-shell version?

First note that C-shell and Swift languages look somewhat different.

From the original C-shell script of the AMWG diag package.

# save unweighted variables
if ($weight_months == 0) then 
  if ($test_ANN_climo == 0 || $test_MON_climo == 0 || $test_DJF_climo == 0) then 
    set filename = {$conv_test}`printf "%04d" {$test_begin}`-01.nc
    ncks -C -O -v $non_time_vars {$test_path}{$filename} {$WKDIR}test_unweighted.nc
  else 
    if ($test_JJA_climo == 0) then 
      set filename = {$conv_test}`printf "%04d" {$test_begin}`-06.nc
      ncks -C -O -v $non_time_vars {$test_path}{$filename} {$WKDIR}test_unweighted.nc
    endif
  endif
endif

The swift version of the above is in two pieces. First an "app" is defined.

(file out)Save_Unweighted_Variables(string file_name, string n_t_var, string t_path)
{
        app {ncks "-C" "-O" "-v" n_t_var @strcat(t_path,file_name) @filename(out);}
}

About 100 lines later, this app is used

#====================================================================================
if( weight_months == 0) {
        string yr_prnt=@strcat(conv_test,yearprint(test_begin));


        if(test_ANN_climo == 0 || test_DJF_climo==0) {
                 string filename = @strcat(yr_prnt,"-01.nc");
                 unWgt_file = Save_Unweighted_Variables(filename, non_time_vars, test_path);
        } else {
                if(test_JJA_climo == 0) {
                        string filename = @strcat(yr_prnt,"-06.nc");
                        unWgt_file = Save_Unweighted_Variables(filename, non_time_vars, test_path);
                }
        }
}
#=======