<p><b>duda</b> 2010-10-01 17:48:22 -0600 (Fri, 01 Oct 2010)</p><p>BRANCH COMMIT<br>
<br>
Updates from repository trunk:<br>
<br>
- Add changes to permit specification of non-decomposed dimensions<br>
(nCells, nEdges, nVertices, nVertLevels) at runtime in the namelist.<br>
<br>
- Remove EXPAND_LEVELS code, since the functionality it provided can<br>
now be duplicated at runtime.<br>
<br>
- Fix logic bug in code to generate super-array indices (e.g., index_qv)<br>
in gen_inc.c around line 372 and with the addition of sort_group_vars<br>
subroutine in parse.c).<br>
<br>
- Convert hydrostatic model to use runtime specification of nVertLevels<br>
in new &dimensions namelist.<br>
<br>
Plus:<br>
<br>
- Convert nonhydrostatic model to use runtime specification of nVertLevels<br>
in new &dimensions namelist<br>
<br>
<br>
M namelist.input.nhyd_atmos_squall<br>
M namelist.input.hyd_atmos<br>
M src/core_hyd_atmos/Registry<br>
M src/core_sw/module_test_cases.F<br>
M src/registry/gen_inc.c<br>
M src/registry/parse.c<br>
M src/core_nhyd_atmos/Registry<br>
M src/framework/module_io_input.F<br>
M Makefile<br>
M namelist.input.nhyd_atmos<br>
M namelist.input.nhyd_atmos_jw<br>
M namelist.input.nhyd_atmos_mtn_wave<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_nonhydrostatic/Makefile
===================================================================
--- branches/atmos_nonhydrostatic/Makefile        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/Makefile        2010-10-01 23:48:22 UTC (rev 518)
@@ -1,14 +1,6 @@
#MODEL_FORMULATION = -DNCAR_FORMULATION
MODEL_FORMULATION = -DLANL_FORMULATION
-ifeq ($(CORE),hyd_atmos)
-EXPAND_LEVELS = -DEXPAND_LEVELS=26
-endif
-
-ifeq ($(CORE),nhyd_atmos)
-EXPAND_LEVELS = -DEXPAND_LEVELS=26
-endif
-
FILE_OFFSET = -DOFFSET64BIT
#########################
@@ -38,7 +30,7 @@
        "CFLAGS = -g" \
        "LDFLAGS = -g -C" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
ftn:
        ( make all \
@@ -50,7 +42,7 @@
        "CFLAGS = -fast" \
        "LDFLAGS = " \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi:
        ( make all \
@@ -62,7 +54,7 @@
        "CFLAGS = -O3" \
        "LDFLAGS = -O3" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi-llnl:
        ( make all \
@@ -74,7 +66,7 @@
        "CFLAGS = -fast" \
        "LDFLAGS = " \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
pgi-serial:
        ( make all \
@@ -86,7 +78,7 @@
        "CFLAGS = -O0 -g" \
        "LDFLAGS = -O0 -g -Mbounds -Mchkptr" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
ifort:
        ( make all \
@@ -98,7 +90,7 @@
        "CFLAGS = -O3 -m64" \
        "LDFLAGS = -O3" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
gfortran:
        ( make all \
@@ -110,7 +102,7 @@
        "CFLAGS = -O3 -m64" \
        "LDFLAGS = -O3 -m64" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE -m64 $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
g95:
        ( make all \
@@ -122,7 +114,7 @@
        "CFLAGS = -O3" \
        "LDFLAGS = -O3" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
g95-serial:
        ( make all \
@@ -134,7 +126,7 @@
        "CFLAGS = -O3" \
        "LDFLAGS = -O3" \
        "CORE = $(CORE)" \
-        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) $(EXPAND_LEVELS) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
+        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
CPPINCLUDES = -I../inc -I$(NETCDF)/include
Modified: branches/atmos_nonhydrostatic/namelist.input.hyd_atmos
===================================================================
--- branches/atmos_nonhydrostatic/namelist.input.hyd_atmos        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/namelist.input.hyd_atmos        2010-10-01 23:48:22 UTC (rev 518)
@@ -16,6 +16,10 @@
config_mp_physics = 0
/
+&dimensions
+ config_nvertlevels = 26
+/
+
&io
config_input_name = 'grid.nc'
config_output_name = 'output.nc'
Modified: branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos
===================================================================
--- branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos        2010-10-01 23:48:22 UTC (rev 518)
@@ -19,6 +19,10 @@
config_smdiv = 0.1
/
+&dimensions
+ config_nvertlevels = 26
+/
+
&io
config_input_name = 'grid.nc'
config_output_name = 'output.nc'
Modified: branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_jw
===================================================================
--- branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_jw        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_jw        2010-10-01 23:48:22 UTC (rev 518)
@@ -27,6 +27,10 @@
config_smdiv = 0.1
/
+&dimensions
+ config_nvertlevels = 26
+/
+
&io
config_input_name = 'grid.nc'
config_output_name = 'output.nc'
Modified: branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_mtn_wave
===================================================================
--- branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_mtn_wave        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_mtn_wave        2010-10-01 23:48:22 UTC (rev 518)
@@ -22,6 +22,10 @@
config_epssm = 0.2
/
+&dimensions
+ config_nvertlevels = 26
+/
+
&io
config_input_name = 'grid.nc'
config_output_name = 'output.nc'
Modified: branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_squall
===================================================================
--- branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_squall        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/namelist.input.nhyd_atmos_squall        2010-10-01 23:48:22 UTC (rev 518)
@@ -17,6 +17,10 @@
config_monotonic = .false.
/
+&dimensions
+ config_nvertlevels = 26
+/
+
&io
config_input_name = 'grid.nc'
config_output_name = 'output.nc'
Modified: branches/atmos_nonhydrostatic/src/core_hyd_atmos/Registry
===================================================================
--- branches/atmos_nonhydrostatic/src/core_hyd_atmos/Registry        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/core_hyd_atmos/Registry        2010-10-01 23:48:22 UTC (rev 518)
@@ -18,6 +18,7 @@
namelist logical sw_model config_positive_definite false
namelist logical sw_model config_monotonic true
namelist integer sw_model config_mp_physics 0
+namelist integer dimensions config_nvertlevels 26
namelist character io config_input_name grid.nc
namelist character io config_output_name output.nc
namelist character io config_restart_name restart.nc
@@ -38,7 +39,8 @@
dim FIFTEEN 15
dim TWENTYONE 21
dim R3 3
-dim nVertLevels nVertLevels
+#dim nVertLevels nVertLevels
+dim nVertLevels namelist:config_nvertlevels
#dim nTracers nTracers
dim nVertLevelsP1 nVertLevels+1
Modified: branches/atmos_nonhydrostatic/src/core_nhyd_atmos/Registry
===================================================================
--- branches/atmos_nonhydrostatic/src/core_nhyd_atmos/Registry        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/core_nhyd_atmos/Registry        2010-10-01 23:48:22 UTC (rev 518)
@@ -30,7 +30,7 @@
namelist integer nhyd_model config_mp_physics 0.
namelist real nhyd_model config_epssm 0.1
namelist real nhyd_model config_smdiv 0.1
-
+namelist integer dimensions config_nvertlevels 26
namelist character io config_input_name grid.nc
namelist character io config_output_name output.nc
namelist character io config_restart_name restart.nc
@@ -52,7 +52,8 @@
dim FIFTEEN 15
dim TWENTYONE 21
dim R3 3
-dim nVertLevels nVertLevels
+#dim nVertLevels nVertLevels
+dim nVertLevels namelist:config_nvertlevels
dim nVertLevelsP1 nVertLevels+1
#
Modified: branches/atmos_nonhydrostatic/src/core_sw/module_test_cases.F
===================================================================
--- branches/atmos_nonhydrostatic/src/core_sw/module_test_cases.F        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/core_sw/module_test_cases.F        2010-10-01 23:48:22 UTC (rev 518)
@@ -148,9 +148,6 @@
psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &
psiVertex(grid%verticesOnEdge%array(1,iEdge)) &
) / grid%dvEdge%array(iEdge)
-#ifdef EXPAND_LEVELS
- state % u % array(2:EXPAND_LEVELS, iEdge) = state % u % array(1,iEdge)
-#endif
end do
deallocate(psiVertex)
@@ -164,9 +161,6 @@
else
state % h % array(1,iCell) = 0.0
end if
-#ifdef EXPAND_LEVELS
- state % h % array(2:EXPAND_LEVELS, iCell) = state % h % array(1,iCell)
-#endif
end do
end subroutine sw_test_case_1
@@ -230,9 +224,6 @@
psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &
psiVertex(grid%verticesOnEdge%array(1,iEdge)) &
) / grid%dvEdge%array(iEdge)
-#ifdef EXPAND_LEVELS
- state % u % array(2:EXPAND_LEVELS, iEdge) = state % u % array(1,iEdge)
-#endif
end do
deallocate(psiVertex)
@@ -262,9 +253,6 @@
)**2.0 &
) / &
gravity
-#ifdef EXPAND_LEVELS
- state % h % array(2:EXPAND_LEVELS, iCell) = state % h % array(1,iCell)
-#endif
end do
end subroutine sw_test_case_2
@@ -330,9 +318,6 @@
psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &
psiVertex(grid%verticesOnEdge%array(1,iEdge)) &
) / grid%dvEdge%array(iEdge)
-#ifdef EXPAND_LEVELS
- state % u % array(2:EXPAND_LEVELS, iEdge) = state % u % array(1,iEdge)
-#endif
end do
deallocate(psiVertex)
@@ -389,9 +374,6 @@
) / &
gravity
state % h % array(1,iCell) = state % h % array(1,iCell) - grid % h_s % array(iCell)
-#ifdef EXPAND_LEVELS
- state % h % array(2:EXPAND_LEVELS, iCell) = state % h % array(1,iCell)
-#endif
end do
end subroutine sw_test_case_5
@@ -453,9 +435,6 @@
psiVertex(grid%verticesOnEdge%array(2,iEdge)) - &
psiVertex(grid%verticesOnEdge%array(1,iEdge)) &
) / grid%dvEdge%array(iEdge)
-#ifdef EXPAND_LEVELS
- state % u % array(2:EXPAND_LEVELS, iEdge) = state % u % array(1,iEdge)
-#endif
end do
deallocate(psiVertex)
@@ -467,9 +446,6 @@
a*a*BB(grid%latCell%array(iCell)) * cos(R*grid%lonCell%array(iCell)) + &
a*a*CC(grid%latCell%array(iCell)) * cos(2.0*R*grid%lonCell%array(iCell)) &
) / gravity
-#ifdef EXPAND_LEVELS
- state % h % array(2:EXPAND_LEVELS, iCell) = state % h % array(1,iCell)
-#endif
end do
end subroutine sw_test_case_6
Modified: branches/atmos_nonhydrostatic/src/framework/module_io_input.F
===================================================================
--- branches/atmos_nonhydrostatic/src/framework/module_io_input.F        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/framework/module_io_input.F        2010-10-01 23:48:22 UTC (rev 518)
@@ -1093,13 +1093,6 @@
#include "netcdf_read_ids.inc"
-#ifdef EXPAND_LEVELS
- if (.not. config_do_restart) then
- input_obj % rdLocalnVertLevels = EXPAND_LEVELS
- write(0,*) 'Expanding nVertLevels to ',input_obj % rdLocalnVertLevels,' by duplicating the first level.'
- end if
-#endif
-
end subroutine io_input_init
Modified: branches/atmos_nonhydrostatic/src/registry/gen_inc.c
===================================================================
--- branches/atmos_nonhydrostatic/src/registry/gen_inc.c        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/registry/gen_inc.c        2010-10-01 23:48:22 UTC (rev 518)
@@ -363,16 +363,24 @@
}
var_list_ptr = group_ptr->vlist;
- memcpy(super_array, var_list_ptr->var->super_array, 1024);
- memcpy(array_class, var_list_ptr->var->array_class, 1024);
+ sprintf(super_array, "-");
+ sprintf(array_class, "-");
class_start = 1;
class_end = 1;
i = 1;
+
while (var_list_ptr) {
+
+ /* Is the current variable in a super array? */
if (strncmp(var_list_ptr->var->super_array, "-", 1024) != 0) {
+
+ /* Have we hit the beginning of a new super array? */
if (strncmp(super_array, var_list_ptr->var->super_array, 1024) != 0) {
- if (strncmp(super_array, "-", 1024) != 0) fortprintf(fd, " integer :: %s_end = %i</font>
<font color="red">", array_class, class_end);
- if (strncmp(super_array, "-", 1024) != 0) fortprintf(fd, " integer :: num_%s = %i</font>
<font color="blue">", super_array, i);
+ /* Finish off the previous super array? */
+ if (strncmp(super_array, "-", 1024) != 0) {
+ fortprintf(fd, " integer :: %s_end = %i</font>
<font color="blue">", array_class, class_end);
+ fortprintf(fd, " integer :: num_%s = %i</font>
<font color="gray">", super_array, i);
+ }
class_start = 1;
class_end = 1;
i = 1;
@@ -380,6 +388,7 @@
memcpy(array_class, var_list_ptr->var->array_class, 1024);
fortprintf(fd, " integer :: %s_start = %i</font>
<font color="blue">", array_class, class_start);
}
+ /* Or have we hit the beginning of a new array class? */
else if (strncmp(array_class, var_list_ptr->var->array_class, 1024) != 0) {
fortprintf(fd, " integer :: %s_end = %i</font>
<font color="gray">", array_class, class_end);
class_start = class_end+1;
@@ -392,8 +401,10 @@
class_end++;
i++;
}
+
}
var_list_ptr = var_list_ptr->next;
+
}
if (strncmp(super_array, "-", 1024) != 0) fortprintf(fd, " integer :: %s_end = %i</font>
<font color="black">", array_class, class_end);
if (strncmp(super_array, "-", 1024) != 0) fortprintf(fd, " integer :: num_%s = %i</font>
<font color="gray">", super_array, i);
@@ -538,7 +549,8 @@
if (!strncmp(dimlist_ptr->dim->name_in_file, "nCells", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nEdges", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nVertices", 1024))
- fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_file);
else
if (dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%s", dimlist_ptr->dim->name_in_file);
else fortprintf(fd, "%s", dimlist_ptr->dim->name_in_code);
@@ -547,7 +559,8 @@
if (!strncmp(dimlist_ptr->dim->name_in_file, "nCells", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nEdges", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nVertices", 1024))
- fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_file);
else
if (dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_file);
else fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_code);
@@ -581,7 +594,8 @@
if (!strncmp(dimlist_ptr->dim->name_in_file, "nCells", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nEdges", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nVertices", 1024))
- fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, "%s + 1", dimlist_ptr->dim->name_in_file);
else
if (dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%s", dimlist_ptr->dim->name_in_file);
else fortprintf(fd, "%s", dimlist_ptr->dim->name_in_code);
@@ -590,7 +604,8 @@
if (!strncmp(dimlist_ptr->dim->name_in_file, "nCells", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nEdges", 1024) ||
!strncmp(dimlist_ptr->dim->name_in_file, "nVertices", 1024))
- fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, ", %s + 1", dimlist_ptr->dim->name_in_file);
else
if (dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_file);
else fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_code);
@@ -758,7 +773,6 @@
char * cp1, * cp2;
int i, j;
int ivtype;
- int has_vert_dim, vert_dim;
/*
@@ -820,29 +834,14 @@
fortprintf(fd, " if ((%s %% %s %% ioinfo %% input .and. .not. config_do_restart) .or. &</font>
<font color="black">", struct_deref, var_ptr->name_in_code);
fortprintf(fd, " (%s %% %s %% ioinfo %% restart .and. config_do_restart)) then</font>
<font color="red">", struct_deref, var_ptr->name_in_code);
}
- vert_dim = 0;
while (dimlist_ptr) {
if (i < var_ptr->ndims) {
- has_vert_dim = !strcmp( "nVertLevels", dimlist_ptr->dim->name_in_code);
fortprintf(fd, " %s%id %% ioinfo %% start(%i) = 1</font>
<font color="red">", vtype, var_ptr->ndims, i);
- if (has_vert_dim) {
- vert_dim = i;
- fortprintf(fd, "#ifdef EXPAND_LEVELS</font>
<font color="red">");
- fortprintf(fd, " if (.not. config_do_restart) then</font>
<font color="red">");
- fortprintf(fd, " %s%id %% ioinfo %% count(%i) = 1</font>
<font color="red">", vtype, var_ptr->ndims, i);
- fortprintf(fd, " else</font>
<font color="red">");
- fortprintf(fd, "#endif</font>
<font color="red">");
- }
if (dimlist_ptr->dim->constant_value < 0)
if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, " %s%id %% ioinfo %% count(%i) = block %% mesh %% %s</font>
<font color="black">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code);
else fortprintf(fd, " %s%id %% ioinfo %% count(%i) = block %% mesh %% %s</font>
<font color="black">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_file);
else
fortprintf(fd, " %s%id %% ioinfo %% count(%i) = %s</font>
<font color="red">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code);
- if (has_vert_dim) {
- fortprintf(fd, "#ifdef EXPAND_LEVELS</font>
<font color="red">");
- fortprintf(fd, " end if</font>
<font color="red">");
- fortprintf(fd, "#endif</font>
<font color="gray">");
- }
}
else {
if (is_derived_dim(dimlist_ptr->dim->name_in_code)) {
@@ -853,8 +852,14 @@
free(cp2);
}
else {
- fortprintf(fd, " %s%id %% ioinfo %% start(%i) = read%sStart</font>
<font color="red">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code+1);
- fortprintf(fd, " %s%id %% ioinfo %% count(%i) = read%sCount</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code+1);
+ if (dimlist_ptr->dim->namelist_defined) {
+ fortprintf(fd, " %s%id %% ioinfo %% start(%i) = read%sStart</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_file+1);
+ fortprintf(fd, " %s%id %% ioinfo %% count(%i) = read%sCount</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_file+1);
+ }
+ else {
+ fortprintf(fd, " %s%id %% ioinfo %% start(%i) = read%sStart</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code+1);
+ fortprintf(fd, " %s%id %% ioinfo %% count(%i) = read%sCount</font>
<font color="gray">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code+1);
+ }
}
}
dimlist_ptr = dimlist_ptr->next;
@@ -881,7 +886,8 @@
free(cp2);
}
else
- fortprintf(fd, "read%sCount", dimlist_ptr->dim->name_in_code+1);
+ if (dimlist_ptr->dim->namelist_defined) fortprintf(fd, "read%sCount", dimlist_ptr->dim->name_in_file+1);
+ else fortprintf(fd, "read%sCount", dimlist_ptr->dim->name_in_code+1);
}
dimlist_ptr = dimlist_ptr->next;
@@ -902,7 +908,8 @@
free(cp2);
}
else
- fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_code+1);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_code+1);
+ else fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_file+1);
}
dimlist_ptr = dimlist_ptr->next;
i++;
@@ -919,7 +926,8 @@
if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, "block %% mesh %% %s", dimlist_ptr->dim->name_in_code);
else fortprintf(fd, "block %% mesh %% %s", dimlist_ptr->dim->name_in_file);
else
- fortprintf(fd, "%s", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%s", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, "%s", dimlist_ptr->dim->name_in_file);
}
dimlist_ptr = dimlist_ptr->next;
i++;
@@ -928,7 +936,9 @@
if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", block %% mesh %% %s", dimlist_ptr->dim->name_in_code);
else fortprintf(fd, ", block %% mesh %% %s", dimlist_ptr->dim->name_in_file);
else
- fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, ", %s", dimlist_ptr->dim->name_in_file);
+
dimlist_ptr = dimlist_ptr->next;
i++;
}
@@ -942,26 +952,6 @@
else
fortprintf(fd, " call io_input_field(input_obj, %s%id)</font>
<font color="red">", vtype, var_ptr->ndims);
- if (vert_dim > 0) {
- fortprintf(fd, "#ifdef EXPAND_LEVELS</font>
<font color="red">");
- fortprintf(fd, " if (.not. config_do_restart) then</font>
<font color="red">");
- fortprintf(fd, " do k=2,EXPAND_LEVELS</font>
<font color="red">");
- fortprintf(fd, " %s%id %% array(", vtype, var_ptr->ndims);
- for (i=1; i<=var_ptr->ndims; i++) {
- if (i > 1) fortprintf(fd, ",");
- fortprintf(fd, "%s", i == vert_dim ? "k" : ":");
- }
- fortprintf(fd, ") = %s%id %% array(", vtype, var_ptr->ndims);
- for (i=1; i<=var_ptr->ndims; i++) {
- if (i > 1) fortprintf(fd, ",");
- fortprintf(fd, "%s", i == vert_dim ? "1" : ":");
- }
- fortprintf(fd, ")</font>
<font color="red">");
- fortprintf(fd, " end do</font>
<font color="red">");
- fortprintf(fd, " end if</font>
<font color="red">");
- fortprintf(fd, "#endif</font>
<font color="red">");
- }
-
if (var_ptr->ndims > 0) {
fortprintf(fd, " call dmpar_alltoall_field(dminfo, &</font>
<font color="gray">");
if (strncmp(var_ptr->super_array, "-", 1024) != 0)
@@ -987,7 +977,8 @@
free(cp2);
}
else
- fortprintf(fd, " read%sCount", dimlist_ptr->dim->name_in_code+1);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, " read%sCount", dimlist_ptr->dim->name_in_code+1);
+ else fortprintf(fd, " read%sCount", dimlist_ptr->dim->name_in_file+1);
}
dimlist_ptr = dimlist_ptr->next;
@@ -1008,18 +999,22 @@
free(cp2);
}
else
- fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_code+1);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_code+1);
+ else fortprintf(fd, ", read%sCount", dimlist_ptr->dim->name_in_file+1);
}
dimlist_ptr = dimlist_ptr->next;
i++;
}
- fortprintf(fd, ", block %% mesh %% %s, &</font>
<font color="blue">", lastdim->dim->name_in_code);
+ if (!lastdim->dim->namelist_defined) fortprintf(fd, ", block %% mesh %% %s, &</font>
<font color="blue">", lastdim->dim->name_in_code);
+ else fortprintf(fd, ", block %% mesh %% %s, &</font>
<font color="red">", lastdim->dim->name_in_file);
- if (is_derived_dim(lastdim->dim->name_in_code)) {
+ if (is_derived_dim(lastdim->dim->name_in_code))
fortprintf(fd, " send%sList, recv%sList)</font>
<font color="red">", lastdim->dim->name_in_file+1, lastdim->dim->name_in_file+1);
- }
else
- fortprintf(fd, " send%sList, recv%sList)</font>
<font color="blue">", lastdim->dim->name_in_code+1, lastdim->dim->name_in_code+1);
+ if (lastdim->dim->namelist_defined)
+ fortprintf(fd, " send%sList, recv%sList)</font>
<font color="blue">", lastdim->dim->name_in_file+1, lastdim->dim->name_in_file+1);
+ else
+ fortprintf(fd, " send%sList, recv%sList)</font>
<font color="gray">", lastdim->dim->name_in_code+1, lastdim->dim->name_in_code+1);
/* Copy from super_ array to field */
@@ -1403,7 +1398,8 @@
free(cp2);
}
else
- fortprintf(fd, " %s%id %% ioinfo %% count(%i) = %sGlobal</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, " %s%id %% ioinfo %% count(%i) = %sGlobal</font>
<font color="blue">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, " %s%id %% ioinfo %% count(%i) = %sGlobal</font>
<font color="gray">", vtype, var_ptr->ndims, i, dimlist_ptr->dim->name_in_file);
}
dimlist_ptr = dimlist_ptr->next;
i++;
@@ -1427,7 +1423,8 @@
free(cp2);
}
else
- fortprintf(fd, "%sGlobal", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, "%sGlobal", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, "%sGlobal", dimlist_ptr->dim->name_in_file);
lastdim = dimlist_ptr;
}
dimlist_ptr = dimlist_ptr->next;
@@ -1447,7 +1444,8 @@
free(cp2);
}
else
- fortprintf(fd, ", %sGlobal", dimlist_ptr->dim->name_in_code);
+ if (!dimlist_ptr->dim->namelist_defined) fortprintf(fd, ", %sGlobal", dimlist_ptr->dim->name_in_code);
+ else fortprintf(fd, ", %sGlobal", dimlist_ptr->dim->name_in_file);
lastdim = dimlist_ptr;
}
dimlist_ptr = dimlist_ptr->next;
@@ -1545,8 +1543,14 @@
free(cp2);
}
else {
- fortprintf(fd, ", %sGlobal, &</font>
<font color="red">", lastdim->dim->name_in_code);
- fortprintf(fd, " output_obj %% send%sList, output_obj %% recv%sList)</font>
<font color="blue">", lastdim->dim->name_in_code+1, lastdim->dim->name_in_code+1);
+ if (!lastdim->dim->namelist_defined) {
+ fortprintf(fd, ", %sGlobal, &</font>
<font color="blue">", lastdim->dim->name_in_code);
+ fortprintf(fd, " output_obj %% send%sList, output_obj %% recv%sList)</font>
<font color="blue">", lastdim->dim->name_in_code+1, lastdim->dim->name_in_code+1);
+ }
+ else {
+ fortprintf(fd, ", %sGlobal, &</font>
<font color="blue">", lastdim->dim->name_in_file);
+ fortprintf(fd, " output_obj %% send%sList, output_obj %% recv%sList)</font>
<font color="gray">", lastdim->dim->name_in_file+1, lastdim->dim->name_in_file+1);
+ }
}
}
else {
Modified: branches/atmos_nonhydrostatic/src/registry/parse.c
===================================================================
--- branches/atmos_nonhydrostatic/src/registry/parse.c        2010-10-01 22:55:04 UTC (rev 517)
+++ branches/atmos_nonhydrostatic/src/registry/parse.c        2010-10-01 23:48:22 UTC (rev 518)
@@ -8,6 +8,7 @@
int getword(FILE *, char *);
int is_integer_constant(char *);
void sort_vars(struct variable *);
+void sort_group_vars(struct group_list *);
int main(int argc, char ** argv)
{
@@ -36,6 +37,7 @@
}
sort_vars(vars);
+ sort_group_vars(groups);
gen_namelists(nls);
gen_field_defs(groups, vars, dims);
@@ -306,7 +308,7 @@
var_ptr = vars;
-/*
+/* Attempt at sorting first on super-array, then on class in the same loop
while (var_ptr) {
memcpy(super_array, var_ptr->super_array, 1024);
memcpy(array_class, var_ptr->array_class, 1024);
@@ -375,3 +377,68 @@
var_ptr = var_ptr->next;
}
}
+
+
+void sort_group_vars(struct group_list * groups)
+{
+ struct variable_list * var_list;
+ struct variable_list * var_ptr;
+ struct variable_list * var_ptr2;
+ struct variable_list * var_ptr2_prev;
+ struct group_list * group_ptr;
+ char super_array[1024];
+ char array_class[1024];
+
+ group_ptr = groups;
+
+ while (group_ptr) {
+
+ var_ptr = group_ptr->vlist;
+
+ while (var_ptr) {
+ memcpy(super_array, var_ptr->var->super_array, 1024);
+ var_ptr2_prev = var_ptr;
+ var_ptr2 = var_ptr->next;
+ if (var_ptr2 && strncmp(super_array, var_ptr2->var->super_array, 1024) != 0) {
+ while (var_ptr2) {
+ if (strncmp(super_array, var_ptr2->var->super_array, 1024) == 0) {
+ var_ptr2_prev->next = var_ptr2->next;
+ var_ptr2->next = var_ptr->next;
+ var_ptr->next = var_ptr2;
+ var_ptr2 = var_ptr2_prev->next;
+ }
+ else {
+ var_ptr2_prev = var_ptr2_prev->next;
+ var_ptr2 = var_ptr2->next;
+ }
+ }
+ }
+ var_ptr = var_ptr->next;
+ }
+
+ var_ptr = group_ptr->vlist;
+
+ while (var_ptr) {
+ memcpy(array_class, var_ptr->var->array_class, 1024);
+ var_ptr2_prev = var_ptr;
+ var_ptr2 = var_ptr->next;
+ if (var_ptr2 && strncmp(array_class, var_ptr2->var->array_class, 1024) != 0) {
+ while (var_ptr2) {
+ if (strncmp(array_class, var_ptr2->var->array_class, 1024) == 0) {
+ var_ptr2_prev->next = var_ptr2->next;
+ var_ptr2->next = var_ptr->next;
+ var_ptr->next = var_ptr2;
+ var_ptr2 = var_ptr2_prev->next;
+ }
+ else {
+ var_ptr2_prev = var_ptr2_prev->next;
+ var_ptr2 = var_ptr2->next;
+ }
+ }
+ }
+ var_ptr = var_ptr->next;
+ }
+
+ group_ptr = group_ptr->next;
+ }
+}
</font>
</pre>