Changes between Initial Version and Version 1 of Documentation/UserGuide/ShellScriptFind


Ignore:
Timestamp:
2015-02-05T11:03:06+01:00 (9 years ago)
Author:
ychen
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/UserGuide/ShellScriptFind

    v1 v1  
     1Sometimes, you may need some works for combining the ORCHIDEE results from the specific output frequency to a single file for the post analysis. 
     2Here, I made a simple bash script for your reference and you can combine the several files to a single file by running the following bash script. 
     3The commands, ncract, find, sort and export, will be used. See the following script for the detail.       
     4{{{ 
     5#!/bin/bash 
     6 
     7# search file names and rebuild 
     8# set up working years 
     9year=(1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000) 
     10 
     11# set the experiment name 
     12exp="BCLb" 
     13 
     14# set the file path for searching files  
     15in_dir_path="/ccc/store/cont003/dsm/p529luy/IGCM_OUT/LMDZOR/PROD/amip/"$exp"/ATM/Output/DA" 
     16 
     17#echo $in_dir_path 
     18# move the path to search the files 
     19cd $in_dir_path 
     20 
     21# start the loop for searching the files... 
     22for index in {0..19} 
     23do 
     24    echo "Search files on year: ${year[$index]}" 
     25    # use the "find" and "sort" command to find the files  
     26    # and sort by the numeric number appears in the filenames  
     27    inputfilename=( $(find -name "${exp}_${year[$index]}*" | sort -n) ) 
     28    echo "PROCESSING input files: "${inputfilename[@]} 
     29 
     30    # make a outout file name based on the working "exp" and "year"  
     31    export outputfilename="${exp}_${year[$index]}.nc" 
     32 
     33    # use "ncrcat" command to re-create(combine) the nc file based on the searched inputfilename     
     34    ncrcat ${inputfilename[@]} /ccc/store/cont003/dsm/cheny/Daily/${exp}/$outputfilename 
     35 
     36    echo "PLEASE CHECK output file: "$outputfilename 
     37done  
     38 
     39echo "FINISHED THE COMBINE files job.. (AH-JA...)"$outputfilename 
     40}}} 
     41 
     42The above script combines output files (daily temp step monthly output) from 1981-2000. 
     43 
     44You can change the path or year for your necessary.