5 # This script needs know where the Registry directory is
6 # located and also namelist.input file to review.
8 # No arguments, maybe this is a simple default location.
9 # Make a few educated guesses
12 if (${#argv} == 0 ) then
14 # Is this the WRFV3/run directory
16 if ( ( -d ..
/Registry
) && ( -f namelist.input
) ) then
17 set Reg_Dir
= ..
/Registry
18 set NML_File
= namelist.input
21 # Is this the WRFV3/test/em_* directory
23 else if ( ( -d ..
/..
/Registry
) && ( -f namelist.input
) ) then
24 set Reg_Dir
= ..
/..
/Registry
25 set NML_File
= namelist.input
32 if (${#argv} != 2) then
33 echo "usage: $0 Full_path/Registry Full_path/namelist.input"
36 set Reg_Dir
= $argv[1]
37 set NML_File
= $argv[2]
41 # Check that the input arguments are OK: Registry
43 if ( -d $Reg_Dir ) then
44 if ( -e ${Reg_Dir}/Registry.EM_COMMON
) then
47 echo Cannot
find the expected Registry files
in the
$Reg_Dir directory
51 echo $Reg_Dir is not a valid directory
55 # Check that the input arguments are OK: namelist.input
57 if ( -e $NML_File ) then
58 grep -iq time_control
$NML_File
59 set OK_time_control
= $status
60 grep -iq domains
$NML_File
61 set OK_domains
= $status
62 grep -iq physics
$NML_File
63 set OK_physics
= $status
64 grep -iq dynamics
$NML_File
65 set OK_dynamics
= $status
66 if ( ( $OK_time_control == 0 ) && \
67 ( $OK_domains == 0 ) && \
68 ( $OK_physics == 0 ) && \
69 ( $OK_dynamics == 0 ) )then
71 echo "The supplied namelist.input file does not seem to have the necessary NML records"
75 echo "Cannot find the namelist.input file specified: $NML_File"
79 # Get a list of all possible variables in the Registry directory
80 # that have max_domains, and all variables that have only a single
83 if ( -e list_of_all_max_dom_vars
) then
84 rm -rf list_of_all_max_dom_vars
86 touch list_of_all_max_dom_vars
88 if ( -e list_of_all_one_dom_vars
) then
89 rm -rf list_of_all_one_dom_vars
91 touch list_of_all_one_dom_vars
93 foreach f
( $Reg_Dir/Registry.
* $Reg_Dir/registry.
* )
94 grep -i ^rconfig
$f |
grep -i max_domains |
awk '{print $3}' >> list_of_all_max_dom_vars
95 grep -i ^rconfig
$f |
grep -vi max_ |
awk '{print $3}' >> list_of_all_one_dom_vars
98 # Pick up the KNOWN namelist variable max_dom
100 foreach f
( $Reg_Dir/Registry.
* $Reg_Dir/registry.
* )
101 grep -i ^rconfig
$f |
grep -iw max_dom |
awk '{print $3}' >> list_of_all_one_dom_vars
104 sort -u list_of_all_max_dom_vars
> list_of_all_max_dom_vars_sorted
105 sort -u list_of_all_one_dom_vars
> list_of_all_one_dom_vars_sorted
107 # Check the namelist, record by record. Ignore commented out portions,
108 # and ignore parts outside of the first "/" namelist record closing character.
110 sed -e 's/\!.*//' $NML_File > .nml_no_comments
111 awk '/&/,/\//' .nml_no_comments
> .nml_no_comments-within_record_marks
112 grep "=" .nml_no_comments-within_record_marks
> .nml_no_comments-within_record_marks-has_equals
113 sed -e 's/=/ /' .nml_no_comments-within_record_marks-has_equals
> .nml_no_comments-within_record_marks-has_equals-no_equals
114 sed -e 's/,/ /g' .nml_no_comments-within_record_marks-has_equals-no_equals
> .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas
115 grep -v '\&' .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas |
grep -v '\/' > .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks
116 awk '{print $1 }' .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks
> .var_list_only
117 awk '{print $1 , NF}' .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks
> .var_list_num_fields
119 # How many domains are we trying to use
121 grep -iwq max_dom .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks
124 echo "The number of domains needs to be specified in the namelist.input file: max_dom"
127 set max_dom
= `grep -iw max_dom .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks | awk '{print $2}'`
130 foreach v
( `cat .var_list_only` )
131 set num_fields
= `grep -iw $v .var_list_num_fields | awk '{print $2}'`
133 # Is this a single variable, or does the var have an entry for each domain
135 grep -iwq $v list_of_all_one_dom_vars_sorted
137 grep -iwq $v list_of_all_max_dom_vars_sorted
140 if ( $OK1 == 0 ) then
141 if ( $num_fields > 2 ) then
142 echo "The $v variable should have only one entry: FATAL"
144 else if ( $OK2 == 0 ) then
145 if ( `expr $num_fields - 1` < $max_dom ) then
146 echo "The $v variable should have entries for each domain: BE CAREFUL"
148 else if ( ( $OK1 != 0 ) && ( $OK2 != 0 ) ) then
149 echo "The $v variable is not in any Registry: Problem if you just modified $v in the namelist.input file"
153 # Whack the temporary files.
155 set dummy_files
= ( .nml_no_comments .nml_no_comments-within_record_marks .nml_no_comments-within_record_marks-has_equals .nml_no_comments-within_record_marks-has_equals-no_equals .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas .nml_no_comments-within_record_marks-has_equals-no_equals-no_commas-no_record_marks .var_list_num_fields .var_list_only .var_list list_of_all_max_dom_vars list_of_all_max_dom_vars_sorted list_of_all_one_dom_vars list_of_all_one_dom_vars_sorted
)
157 foreach f
( $dummy_files )