Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PEUL_WriteSolution.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: write smoke solution to file
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary.
30 !
31 ! Input: regions = dimensions and cons. variables of all regions
32 ! global%currentTime = physical time
33 ! global%peulResInit = initial residual.
34 !
35 ! Output: to file.
36 !
37 ! Notes: solution is stored only for the current grid level; it is also
38 ! stored for all dummy cells. All regions are written into one file.
39 !
40 !******************************************************************************
41 !
42 ! $Id: PEUL_WriteSolution.F90,v 1.3 2008/12/06 08:44:39 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2002 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE peul_writesolution( regions ) ! PUBLIC
49 
50  USE moddatatypes
51  USE moddatastruct, ONLY : t_region
52  USE modglobal, ONLY : t_global
53  USE moderror
54  USE modmpi
55  USE modparameters
56 
60  IMPLICIT NONE
61 
62 #include "Indexing.h"
63 
64 ! ... parameters
65  TYPE(t_region), POINTER :: regions(:)
66 
67 ! ... loop variables
68  INTEGER :: ireg, i, j, k, n
69 
70 ! ... local variables
71  CHARACTER(2*CHRLEN+22) :: fname,fhead
72  CHARACTER(CHRLEN) :: rcsidentstring, msg
73 
74 #ifdef MPI
75  INTEGER :: status(mpi_status_size)
76 #endif
77  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, ioff, ijoff, ijk
78  INTEGER :: idcbeg, jdcbeg, kdcbeg, idcend, jdcend, kdcend, ijkbeg, ijkend
79  INTEGER :: ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend, inoff, ijnoff
80  INTEGER :: ndimc, ndimn, ncv, errorflag
81  INTEGER, POINTER :: ivar(:,:)
82 
83  REAL(RFREAL), POINTER :: rvar(:,:), cv(:,:), cvfile(:,:)
84 
85  TYPE(t_global), POINTER :: global
86 
87 !******************************************************************************
88 
89  rcsidentstring = '$RCSfile: PEUL_WriteSolution.F90,v $ $Revision: 1.3 $'
90 
91  global => regions(1)%global
92 
93  CALL registerfunction( global,'PEUL_WriteSolution',&
94  'PEUL_WriteSolution.F90' )
95 
96 ! begin -----------------------------------------------------------------------
97 
98  IF (.NOT. global%peulUsed) goto 9
99 
100 ! allocate fixed-size temporary data arrays -----------------------------------
101 
102  ALLOCATE( ivar(5,1),stat=errorflag )
103  ALLOCATE( rvar(2,1),stat=errorflag )
104  global%error = errorflag
105  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
106 
107 ! open solution file (only master proc.) --------------------------------------
108 
109  IF (global%myProcid == masterproc) THEN
110 
111  fhead = trim(global%inDir)//trim(global%casename)
112 
113  SELECT CASE(global%solutFormat)
114  CASE (format_ascii)
115  fhead = trim(fhead)//'.peul_sola_'
116  CASE (format_binary)
117  fhead = trim(fhead)//'.peul_solb_'
118  CASE default
119  CALL errorstop( global,err_unknown_format,__line__ )
120  END SELECT
121 
122  IF (global%flowType == flow_unsteady) THEN
123  WRITE(fname,'(A,ES11.5)') trim(fhead), global%currentTime
124  rvar(1,1) = global%currentTime
125  rvar(2,1) = 1._rfreal
126  ELSE
127  WRITE(fname,'(A,I6.6)') trim(fhead), global%currentIter
128  rvar(1,1) = 0._rfreal
129  rvar(2,1) = global%peulResInit
130  ENDIF
131 
132  SELECT CASE(global%solutFormat)
133  CASE (format_ascii)
134  OPEN(if_peul_solut,file=fname,form= 'formatted',status='unknown', &
135  iostat=errorflag)
136  CASE (format_binary)
137  OPEN(if_peul_solut,file=fname,form='unformatted',status='unknown', &
138  iostat=errorflag)
139  END SELECT
140  global%error = errorflag
141 
142  IF (global%error /= 0) &
143  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
144 
145  ENDIF ! MASTERPROC
146 
147 ! write time and initial residual to file -------------------------------------
148 
149  IF (global%myProcid == masterproc) THEN
150  CALL rflo_writedatafilereal( global,if_peul_solut,global%solutFormat, &
151  2,1,rvar )
152  ENDIF
153 
154 ! write solution data ---------------------------------------------------------
155 
156  DO ireg=1,global%nRegions
157 
158 ! - get dimensions and pointers
159 
160  ilev = regions(ireg)%currLevel
161  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
162  jdcbeg,jdcend,kdcbeg,kdcend )
163  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
164  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
165  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
166  ndimc = ijkend - ijkbeg + 1
167 
168  CALL rflo_getdimensphysnodes( regions(ireg),ilev,ipnbeg,ipnend, &
169  jpnbeg,jpnend,kpnbeg,kpnend )
170  CALL rflo_getnodeoffset( regions(ireg),ilev,inoff,ijnoff )
171  ndimn = (regions(ireg)%levels(ilev)%grid%ipc+1)* &
172  (regions(ireg)%levels(ilev)%grid%jpc+1)* &
173  (regions(ireg)%levels(ilev)%grid%kpc+1)
174 
175  ncv = regions(ireg)%levels(ilev)%peul%nCv
176 
177 ! - allocate memory for data field
178 
179  IF (regions(ireg)%procid==global%myProcid .OR. &
180  global%myProcid==masterproc) THEN
181  ALLOCATE( cvfile(ncv,ndimc),stat=errorflag )
182  global%error = errorflag
183  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
184 
185  ENDIF
186 
187 ! - copy solution into data structure
188 
189  IF (regions(ireg)%procid == global%myProcid) THEN
190  cv => regions(ireg)%levels(ilev)%peul%cv
191  n = 0
192  DO k=kdcbeg,kdcend
193  DO j=jdcbeg,jdcend
194  DO i=idcbeg,idcend
195  n = n + 1
196  ijk = indijk(i,j,k,ioff,ijoff)
197  cvfile(:,n) = cv(:,ijk)
198  ENDDO
199  ENDDO
200  ENDDO
201  ENDIF ! global%myProcid
202 
203 ! - write region number and dimensions (only master)
204 
205  IF (global%myProcid == masterproc) THEN
206  ivar(1,1) = ireg
207  ivar(2,1) = regions(ireg)%levels(ilev)%grid%ipc
208  ivar(3,1) = regions(ireg)%levels(ilev)%grid%jpc
209  ivar(4,1) = regions(ireg)%levels(ilev)%grid%kpc
210  ivar(5,1) = regions(ireg)%nDumCells
211  CALL rflo_writedatafileint( global,if_peul_solut,global%solutFormat, &
212  5,1,ivar )
213  ENDIF
214 
215 ! - master receives and writes data, others send them
216 
217  IF (global%myProcid == masterproc) THEN
218 #ifdef MPI
219  IF (regions(ireg)%procid /= masterproc) THEN
220  CALL mpi_recv( cvfile,ncv*ndimc,mpi_rfreal, &
221  regions(ireg)%procid,ireg, &
222  global%mpiComm,status,global%mpierr )
223  IF (global%mpierr /=0) CALL errorstop(global,err_mpi_trouble,__line__)
224  ENDIF
225 #endif
226  CALL rflo_writedatafilereal( global,if_peul_solut,global%solutFormat, &
227  ncv,ndimc,cvfile )
228 
229  ELSE ! not the master
230 #ifdef MPI
231  IF (regions(ireg)%procid == global%myProcid) THEN
232  CALL mpi_send( cvfile,ncv*ndimc,mpi_rfreal,masterproc,ireg, &
233  global%mpiComm,global%mpierr )
234  IF (global%mpierr /=0) CALL errorstop(global,err_mpi_trouble,__line__)
235  ENDIF
236 #endif
237  ENDIF
238 
239  IF (ASSOCIATED(cvfile)) THEN
240  DEALLOCATE( cvfile,stat=errorflag )
241  global%error = errorflag
242  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
243  nullify( cvfile )
244  ENDIF
245 
246  ENDDO ! iReg
247 
248 ! finalize --------------------------------------------------------------------
249 
250  IF (global%myProcid == masterproc) THEN
251  CLOSE(if_peul_solut,iostat=errorflag)
252  global%error = errorflag
253  IF (global%error /= 0) &
254  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
255  ENDIF
256 
257 9 CONTINUE
258  CALL deregisterfunction( global )
259 
260 END SUBROUTINE peul_writesolution
261 
262 !******************************************************************************
263 !
264 ! RCS Revision history:
265 !
266 ! $Log: PEUL_WriteSolution.F90,v $
267 ! Revision 1.3 2008/12/06 08:44:39 mtcampbe
268 ! Updated license.
269 !
270 ! Revision 1.2 2008/11/19 22:17:52 mtcampbe
271 ! Added Illinois Open Source License/Copyright
272 !
273 ! Revision 1.1 2004/12/01 21:10:04 haselbac
274 ! Initial revision after changing case
275 !
276 ! Revision 1.7 2004/03/05 22:09:04 jferry
277 ! created global variables for peul, plag, and inrt use
278 !
279 ! Revision 1.6 2003/09/26 22:52:12 jferry
280 ! changed file number for read/write of rocsmoke solutions
281 !
282 ! Revision 1.5 2003/05/15 02:57:05 jblazek
283 ! Inlined index function.
284 !
285 ! Revision 1.4 2003/04/14 16:32:24 jferry
286 ! minor edits
287 !
288 ! Revision 1.3 2003/04/09 16:05:19 jferry
289 ! changed naming convention for solution file
290 !
291 ! Revision 1.2 2003/02/12 23:34:48 jferry
292 ! Replaced [io]stat=global%error with local errorFlag
293 !
294 ! Revision 1.1 2003/02/11 22:52:51 jferry
295 ! Initial import of Rocsmoke
296 !
297 !******************************************************************************
298 
299 
300 
301 
302 
303 
304 
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE idcend
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jpnbeg
subroutine rflo_writedatafileint(global, fileId, form, nDim1, nDim2, ivar)
j indices k indices k
Definition: Indexing.h:6
subroutine peul_writesolution(regions)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE kpnbeg
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jpnend
subroutine rflo_getnodeoffset(region, iLev, iNodeOffset, ijNodeOffset)
subroutine rflo_getdimensdummy(region, iLev, idcbeg, idcend, jdcbeg, jdcend, kdcbeg, kdcend)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE kdcbeg
blockLoc i
Definition: read.cpp:79
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE ipnbeg
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE idcbeg
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE form
const NT & n
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jdcend
subroutine rflo_getdimensphysnodes(region, iLev, ipnbeg, ipnend, jpnbeg, jpnend, kpnbeg, kpnend)
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jdcbeg
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine rflo_writedatafilereal(global, fileId, form, nDim1, nDim2, var)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE ipnend