<p><b>duda</b> 2012-02-23 14:51:49 -0700 (Thu, 23 Feb 2012)</p><p>BRANCH COMMIT<br>
<br>
Add error checking code for reading namelists:<br>
<br>
- if a namelist record is not found in namelist.input, just print a warning message like<br>
"Namelist record &restart not found; using default values for this namelist's variables"<br>
and continue<br>
<br>
- if there is an error in a namelist record, print an error message like<br>
"Error while reading namelist record &restart"<br>
and stop the executable<br>
<br>
<br>
M src/registry/gen_inc.c<br>
M src/framework/mpas_configure.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_physics/src/framework/mpas_configure.F
===================================================================
--- branches/atmos_physics/src/framework/mpas_configure.F        2012-02-23 20:03:05 UTC (rev 1531)
+++ branches/atmos_physics/src/framework/mpas_configure.F        2012-02-23 21:51:49 UTC (rev 1532)
@@ -13,7 +13,7 @@
type (dm_info), intent(in) :: dminfo
- integer :: funit
+ integer :: funit, ierr
#include "config_namelist_defs.inc"
@@ -23,10 +23,12 @@
#include "config_set_defaults.inc"
if (dminfo % my_proc_id == IO_NODE) then
+ write(0,*) 'Reading namelist.input'
open(funit,file='namelist.input',status='old',form='formatted')
#include "config_namelist_reads.inc"
close(funit)
+ write(0,*) ' '
end if
#include "config_bcast_namelist.inc"
Modified: branches/atmos_physics/src/registry/gen_inc.c
===================================================================
--- branches/atmos_physics/src/registry/gen_inc.c        2012-02-23 20:03:05 UTC (rev 1531)
+++ branches/atmos_physics/src/registry/gen_inc.c        2012-02-23 21:51:49 UTC (rev 1532)
@@ -125,7 +125,15 @@
nls_ptr = nls;
while (nls_ptr) {
if (!dict_search(dictionary, nls_ptr->record)) {
- fortprintf(fd, " read(funit,%s)</font>
<font color="blue">", nls_ptr->record);
+ fortprintf(fd, " read(funit,%s,iostat=ierr)</font>
<font color="blue">", nls_ptr->record);
+ fortprintf(fd, " if (ierr > 0) then</font>
<font color="blue">");
+ fortprintf(fd, " write(0,*) \'Error while reading namelist record &%s\'</font>
<font color="blue">",nls_ptr->record);
+ fortprintf(fd, " call mpas_dmpar_abort(dminfo)</font>
<font color="blue">");
+ fortprintf(fd, " else if (ierr < 0) then</font>
<font color="blue">");
+ fortprintf(fd, " write(0,*) \'Namelist record &%s not found; using default values for this namelist\'\'s variables\'</font>
<font color="blue">",nls_ptr->record);
+ fortprintf(fd, " rewind(funit)</font>
<font color="blue">");
+ fortprintf(fd, " end if</font>
<font color="blue">");
+
dict_insert(dictionary, nls_ptr->record);
}
nls_ptr = nls_ptr->next;
</font>
</pre>