<p><b>duda</b> 2011-11-14 15:10:12 -0700 (Mon, 14 Nov 2011)</p><p>BRANCH COMMIT<br>
<br>
Adding code to write theta and rho fields from non-hydrostatic atmosphere core to a separate file using PIO.<br>
<br>
<br>
M Makefile<br>
M src/framework/Makefile<br>
M src/framework/mpas_io_output.F<br>
M src/core_nhyd_atmos/mpas_atm_mpas_core.F<br>
M src/driver/mpas_subdriver.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/pio/Makefile
===================================================================
--- branches/pio/Makefile        2011-11-14 18:15:49 UTC (rev 1193)
+++ branches/pio/Makefile        2011-11-14 22:10:12 UTC (rev 1194)
@@ -239,9 +239,9 @@
        "CORE = $(CORE)" \
        "CPPFLAGS = -DRKIND=8 $(MODEL_FORMULATION) -D_MPI -DUNDERSCORE $(FILE_OFFSET) $(ZOLTAN_DEFINE)" )
-CPPINCLUDES = -I../inc -I$(NETCDF)/include -I$(PAPI)/include
-FCINCLUDES = -I../inc -I$(NETCDF)/include -I$(PAPI)/include
-LIBS = -L$(NETCDF)/lib -lnetcdf $(PAPILIBS)
+CPPINCLUDES = -I../inc -I$(NETCDF)/include -I$(PAPI)/include -I$(PIO) -I$(PNETCDF)/include
+FCINCLUDES = -I../inc -I$(NETCDF)/include -I$(PAPI)/include -I$(PIO) -I$(PNETCDF)/include
+LIBS = -L$(PIO) -L$(PNETCDF)/lib -L$(NETCDF)/lib -lpio -lpnetcdf -lnetcdf $(PAPILIBS)
RM = rm -f
CPP = cpp -C -P -traditional
Modified: branches/pio/src/core_nhyd_atmos/mpas_atm_mpas_core.F
===================================================================
--- branches/pio/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2011-11-14 18:15:49 UTC (rev 1193)
+++ branches/pio/src/core_nhyd_atmos/mpas_atm_mpas_core.F        2011-11-14 22:10:12 UTC (rev 1194)
@@ -2,7 +2,7 @@
use mpas_framework
- type (io_output_object) :: restart_obj
+ type (io_output_object), save :: restart_obj
type (io_input_object) :: sfc_update_obj
integer :: current_outfile_frames
Modified: branches/pio/src/driver/mpas_subdriver.F
===================================================================
--- branches/pio/src/driver/mpas_subdriver.F        2011-11-14 18:15:49 UTC (rev 1193)
+++ branches/pio/src/driver/mpas_subdriver.F        2011-11-14 22:10:12 UTC (rev 1194)
@@ -5,7 +5,7 @@
type (dm_info), pointer :: dminfo
type (domain_type), pointer :: domain
- type (io_output_object) :: output_obj
+ type (io_output_object), save :: output_obj
integer :: output_frame
@@ -19,16 +19,16 @@
real (kind=RKIND) :: dt
character(len=32) :: timeStamp
- call mpas_timer_start("total time")
- call mpas_timer_start("initialize")
-
!
! Initialize infrastructure
!
call mpas_framework_init(dminfo, domain)
+ call mpas_timer_start("total time")
+ call mpas_timer_start("initialize")
+
call mpas_input_state_for_domain(domain)
Modified: branches/pio/src/framework/Makefile
===================================================================
--- branches/pio/src/framework/Makefile        2011-11-14 18:15:49 UTC (rev 1193)
+++ branches/pio/src/framework/Makefile        2011-11-14 22:10:12 UTC (rev 1194)
@@ -36,7 +36,7 @@
mpas_io_input.o: mpas_grid_types.o mpas_dmpar.o mpas_block_decomp.o mpas_sort.o mpas_configure.o mpas_timekeeping.o $(ZOLTANOBJ)
-mpas_io_output.o: mpas_grid_types.o mpas_dmpar.o mpas_sort.o mpas_configure.o
+mpas_io_output.o: mpas_timer.o mpas_grid_types.o mpas_dmpar.o mpas_sort.o mpas_configure.o
clean:
        $(RM) *.o *.mod *.f90 libframework.a
Modified: branches/pio/src/framework/mpas_io_output.F
===================================================================
--- branches/pio/src/framework/mpas_io_output.F        2011-11-14 18:15:49 UTC (rev 1193)
+++ branches/pio/src/framework/mpas_io_output.F        2011-11-14 22:10:12 UTC (rev 1194)
@@ -4,12 +4,21 @@
use mpas_dmpar
use mpas_sort
use mpas_configure
+ use mpas_timer
+ use pio
+ use pio_types
integer, parameter :: OUTPUT = 1
integer, parameter :: RESTART = 2
integer, parameter :: SFC = 3
type io_output_object
+ ! For PIO
+ type (iosystem_desc_t) :: pio_iosystem
+ type (file_desc_t) :: pio_file
+!MGD-REGISTRY will need to generate an io_desc_t for each combination of dimensions
+ type (io_desc_t) :: iodesc_nVertLevels_nCells
+
integer :: wr_ncid
character (len=1024) :: filename
@@ -20,6 +29,17 @@
integer :: wrDimIDStrLen
#include "io_output_obj_decls.inc"
+!MGD-REGISTRY will need to generate dimensions
+ ! MGD currently hard-wired for testing
+ integer :: pioDimIDTime
+ integer :: pioDimIDnCells
+ integer :: pioDimIDnVertLevels
+
+!MGD-REGISTRY will need to generate variables
+ ! MGD currently hard-wired for testing
+ type (var_desc_t) :: pioVarIDtheta
+ type (var_desc_t) :: pioVarIDrho
+
logical :: validExchangeLists
type (exchange_list), pointer :: sendCellsList, recvCellsList
type (exchange_list), pointer :: sendEdgesList, recvEdgesList
@@ -67,6 +87,18 @@
type (block_type), pointer :: block_ptr
#include "output_dim_actual_decls.inc"
+write(0,*) 'MGD *** calling mpas_output_state_init ***'
+
+write(0,*) 'MGD PIO_init'
+ call PIO_init(domain % dminfo % my_proc_id, & ! comp_rank
+ domain % dminfo % comm, & ! comp_comm
+ 4, & ! num_iotasks
+ 0, & ! num_aggregator
+ 32, & ! stride
+ PIO_rearr_box, & ! rearr
+ output_obj % pio_iosystem) ! iosystem
+! domain % dminfo % nprocs, & ! num_iotasks
+
block_ptr => domain % blocklist
nullify(output_obj % sendCellsList)
nullify(output_obj % recvCellsList)
@@ -152,6 +184,13 @@
integer :: nEdgesGlobal
integer :: nVerticesGlobal
integer :: nVertLevelsGlobal
+
+!MGD-REGISTRY will need to generate compdof info for each combination of dimensions
+!MGD hard-wired for initial PIO testing
+ integer, dimension(:), pointer :: compdof
+ integer, dimension(2) :: dimids2
+ integer, dimension(3) :: dimids3
+
integer, dimension(:), pointer :: neededCellList
integer, dimension(:), pointer :: neededEdgeList
integer, dimension(:), pointer :: neededVertexList
@@ -183,6 +222,8 @@
#include "nondecomp_outputs.inc"
+write(0,*) 'MGD *** calling mpas_output_state_for_domain ***'
+
output_obj % time = itime
allocate(int1d % ioinfo)
@@ -284,6 +325,31 @@
end if
if (.not. output_obj % validExchangeLists) then
+
+!MGD-REGISTRY will need to generate compdof info for each combination of dimensions
+write(0,*) 'MGD PIO_initdecomp'
+
+ allocate(compdof(domain % blocklist % mesh % nVertLevelsSolve * domain % blocklist % mesh % nCellsSolve))
+ do i=1,domain % blocklist % mesh % nCellsSolve
+ do j=1,domain % blocklist % mesh % nVertLevelsSolve
+ compdof((i-1)*domain % blocklist % mesh % nVertLevels + j) = &
+ (domain % blocklist % mesh % indexToCellID % array(i)-1) * &
+ domain % blocklist % mesh % nVertLevels + j
+ end do
+ end do
+
+ dimids2(1) = nVertLevelsGlobal
+ dimids2(2) = nCellsGlobal
+
+ dimids3(1) = nVertLevelsGlobal
+ dimids3(2) = nCellsGlobal
+ dimids3(3) = 1 ! Time dimension
+
+ call PIO_initdecomp(output_obj % pio_iosystem, PIO_DOUBLE, &
+ dimids3, compdof, output_obj % iodesc_nVertLevels_nCells)
+ deallocate(compdof)
+!MGD end PIO_initdecomp call
+
call mpas_dmpar_get_owner_list(domain % dminfo, &
domain % blocklist % mesh % nCellsSolve, size(neededCellList), &
domain % blocklist % mesh % indexToCellID % array, neededCellList, &
@@ -329,8 +395,19 @@
domain % blocklist % mesh % cellsOnVertex % array => cellsOnVertex
domain % blocklist % mesh % edgesOnVertex % array => edgesOnVertex
-#include "io_output_fields.inc"
+!include "io_output_fields.inc"
+!MGD-REGISTRY will need to generate write calls for each field
+write(0,*) 'MGD PIO_write_darray'
+call mpas_timer_start("pio theta")
+ call PIO_write_darray(output_obj % pio_file, output_obj % pioVarIDtheta, output_obj % iodesc_nVertLevels_nCells, &
+ domain % blocklist % diag % theta % array(:,1:domain%blocklist%mesh%nCellsSolve), i1)
+call mpas_timer_stop("pio theta")
+call mpas_timer_start("pio rho")
+ call PIO_write_darray(output_obj % pio_file, output_obj % pioVarIDrho, output_obj % iodesc_nVertLevels_nCells, &
+ domain % blocklist % diag % rho % array(:,1:domain%blocklist%mesh%nCellsSolve), i1)
+call mpas_timer_stop("pio rho")
+
domain % blocklist % mesh % cellsOnCell % array => cellsOnCell_save
domain % blocklist % mesh % edgesOnCell % array => edgesOnCell_save
domain % blocklist % mesh % verticesOnCell % array => verticesOnCell_save
@@ -361,6 +438,8 @@
type (io_output_object), intent(inout) :: output_obj
type (dm_info), intent(in) :: dminfo
+write(0,*) 'MGD *** calling mpas_output_state_finalize ***'
+
call mpas_io_output_finalize(output_obj, dminfo)
end subroutine mpas_output_state_finalize
@@ -383,6 +462,11 @@
integer :: nferr
integer, dimension(10) :: dimlist
+
+write(0,*) 'MGD *** calling mpas_io_output_init ***'
+
+write(0,*) 'MGD PIO_createfile'
+ nferr = PIO_createfile(output_obj % pio_iosystem, output_obj % pio_file, PIO_iotype_netcdf, 'pio_output.nc')
if (dminfo % my_proc_id == 0) then
#ifdef OFFSET64BIT
@@ -407,6 +491,24 @@
nferr = nf_enddef(output_obj % wr_ncid)
end if
+
+!MGD-REGISTRY will need to generate definitions for each dimension
+write(0,*) 'MGD PIO_def_dim'
+ nferr = PIO_def_dim(output_obj % pio_file, 'Time', PIO_UNLIMITED, output_obj % pioDimIDTime)
+ nferr = PIO_def_dim(output_obj % pio_file, 'nCells', nCells, output_obj % pioDimIDnCells)
+ nferr = PIO_def_dim(output_obj % pio_file, 'nVertLevels', nVertLevels, output_obj % pioDimIDnVertLevels)
+
+!MGD-REGISTRY will need to generate definitions for each field
+write(0,*) 'MGD PIO_def_var'
+ dimlist(1) = output_obj % pioDimIDnVertLevels
+ dimlist(2) = output_obj % pioDimIDnCells
+ dimlist(3) = output_obj % pioDimIDTime
+ nferr = PIO_def_var(output_obj % pio_file, 'theta', PIO_DOUBLE, dimlist(1:3), output_obj % pioVarIDtheta)
+ nferr = PIO_def_var(output_obj % pio_file, 'rho', PIO_DOUBLE, dimlist(1:3), output_obj % pioVarIDrho)
+
+
+write(0,*) 'MGD PIO_enddef'
+ nferr = PIO_enddef(output_obj % pio_file)
end subroutine mpas_io_output_init
@@ -860,6 +962,18 @@
type (dm_info), intent(in) :: dminfo
integer :: nferr
+
+write(0,*) 'MGD *** calling mpas_io_output_finalize ***'
+
+write(0,*) 'MGD PIO_closefile'
+ call PIO_closefile(output_obj % pio_file)
+
+!MGD-REGISTRY will need to generate calls to free up each io_desc_t
+write(0,*) 'MGD PIO_freedecomp'
+ call PIO_freedecomp(output_obj % pio_iosystem, output_obj % iodesc_nVertLevels_nCells)
+
+write(0,*) 'MGD PIO_finalize'
+ call PIO_finalize(output_obj % pio_iosystem, nferr)
if (dminfo % my_proc_id == 0) then
nferr = nf_close(output_obj % wr_ncid)
</font>
</pre>