/* cookfile commandline examples: cook [BIN=path_to_tsterode_program] cook [BIN=path_to_tsterode_program] all cook [BIN=path_to_tsterode_program] ero_summary */ UNIX_SYS = [shell uname -s]; setenv UNIX_SYS = [UNIX_SYS]; #if [in [UNIX_SYS] Linux] EXE =; /* executable filename extension */ #elif [in [UNIX_SYS] SunOS] EXE =; /* executable filename extension */ #else /* assume CYGWIN_NT-x.x */ EXE =.exe; /* executable filename extension */ #endif #ifndef BIN BIN = ../../../weps.src; #endif IN = .in; /* input filename extension */ EROD = .erod; /* erosion output summary filename extension */ EGRD = .egrd; /* erosion output grid cell summary filename extension */ SGRD = .sgrd; /* erosion output grid cell summary filename extension */ EMIT = .emit; /* erosion output subdaily summary filename extension */ EXECUTE = [BIN]/tsterode[EXE]; /* executable program */ /* determine all files (*.in, *.out, etc.) */ manifest = [fromto ./%0% %0% [collect find . ! -type d -print] ]; /* find names of all the "input" files from the manifest */ in_files = [match_mask %0%[IN] [manifest] ]; /* find all "erosion summary output" filenames from "input" files in manifest */ erod_files = [fromto %0%[IN] %0%[EROD] [in_files] ]; /* find all "erosion grid cell summary output" filenames from "input" files in manifest */ egrd_files = [fromto %0%[IN] %0%[EGRD] [in_files] ]; /* find all "erosion grid cell subdaily output" filenames from "input" files in manifest */ sgrd_files = [fromto %0%[IN] %0%[SGRD] [in_files] ]; /* find all "erosion subdaily summary output" filenames from "input" files in manifest */ emit_files = [fromto %0%[IN] %0%[EMIT] [in_files] ]; /************** RECIPE section *********************/ /* recipe to build "egrd" files */ %0%[EGRD]: %0%[IN] { [EXECUTE] -i%0%[IN] -Egrd; } /* recipe to build "erod" files */ %0%[EROD]: %0%[IN] { [EXECUTE] -i%0%[IN] -Erod; } /* recipe to build "emit" files */ %0%[EMIT]: %0%[IN] { [EXECUTE] -i%0%[IN] -Emit; } /* recipe to build "egrd" files */ %0%[EGRD]: %0%[IN] { [EXECUTE] -i%0%[IN] -Egrd; } /* recipe to build "sgrd" files */ %0%[SGRD]: %0%[IN] { [EXECUTE] -i%0%[IN] -Esgrd; } /************** TARGET section *********************/ all: [egrd_files] [erod_files] [emit_files]; ero_summary: [erod_files]; clean: /* get all intermediate and binary files */ { rm -f [out_files] set clearstat; } clobber: clean /* get those dependency files as well */ { rm -f [egrd_files] [erod_files] set clearstat; } file_lists: { echo "manifest list is: " [manifest]; echo "all input files are: " [in_files]; /* echo "all output files are: " [out_files]; */ } ToUnix: /* remove CR's from all input files */ { tmp_files = [in_files]; loop { t_file = [firstword [tmp_files]]; if [not [t_file]] then loopstop; tmp_files = [tail [tmp_files]]; tr -d "\r" < [t_file] >! xx.tmp; /* cmp -s returns a non-zero vlaue if files are different */ if [not [execute cmp -s [t_file] xx.tmp ]] then mv xx.tmp [t_file]; } unlink xx.tmp; } /* NOTE: This recipe is currently specific to the set of input files already checked into CVS by Simon Van Donk. Wed Oct 16 17:10:05 CDT 2002 - LEW */ anem_flag_off: /* turn anemometer flag off in all input files */ { tmp_files = [in_files]; loop { t_file = [firstword [tmp_files]]; if [not [t_file]] then loopstop; tmp_files = [tail [tmp_files]]; sed -e "\"s/3.36 1/3.36 0/\"" < [t_file] > xx.tmp; /* cmp -s returns a non-zero vlaue if files are different */ if [not [execute cmp -s [t_file] xx.tmp ]] then mv xx.tmp [t_file]; } unlink xx.tmp; }