We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I met foreach: Too many arguments. while trying to link a whole year of fnl data using link_grib.csh. It seems that there are too many files (according to https://www.experts-exchange.com/questions/10210401/foreach-limit.html).
foreach: Too many arguments.
link_grib.csh
I simply rewrite the link_grib.csh with python, which has exactly the same usage as link_grib.csh.
#! /usr/bin/python import sys,glob,os def link_grib_file(filelist): n = 0 for ifile in filelist: if ( ifile != "."): file_suffix = file_alphabet(n) os.symlink(ifile, "GRIBFILE."+file_suffix) n+=1 def file_alphabet(number): alpha=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] if number >= 26*26*26: print("RAN OUT OF GRIB FILE SUFFIXES!") exit() else: i1=number%26 i2=(number-i1)//26%26 i3=(number-i2*26-i1)//26//26%26 return alpha[i3]+alpha[i2]+alpha[i1] if __name__ == "__main__": varlist = sys.argv[1:] if (len(varlist)==1) or (len(varlist)==2 and varlist[1]=='.'): os.system("rm -f GRIBFILE.???") filelist=glob.glob(varlist[0]) link_grib_file(filelist) elif (len(varlist)>1): os.system("rm -f GRIBFILE.???") filelist=varlist link_grib_file(filelist) elif (len(varlist)==0): print(" " ) print(" " ) print(" Please provide some GRIB data to link") print(" usage: ./link_grib.py path_to_grib_data/grib_data_root") print(" " ) print(" " )
I'm wondering if it is helpful. PS. It seems that the python code is about ten times faster than csh (maybe due to using os.symlink instead of ln -sf)
os.symlink
ln -sf
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I met
foreach: Too many arguments.
while trying to link a whole year of fnl data usinglink_grib.csh
. It seems that there are too many files (according to https://www.experts-exchange.com/questions/10210401/foreach-limit.html).I simply rewrite the
link_grib.csh
with python, which has exactly the same usage aslink_grib.csh
.I'm wondering if it is helpful.
PS. It seems that the python code is about ten times faster than csh (maybe due to using
os.symlink
instead ofln -sf
)The text was updated successfully, but these errors were encountered: