MFIX  2016-1
write_spx1.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Module name: WRITE_SPX1 C
4 ! Purpose: write out the time-dependent restart records (REAL) C
5 ! C
6 ! Author: P. Nicoletti Date: 13-DEC-91 C
7 ! Reviewer: P. Nicoletti, W. Rogers, M. Syamlal Date: 24-JAN-92 C
8 ! C
9 ! Revision Number: C
10 ! Purpose: C
11 ! Author: Date: dd-mmm-yy C
12 ! Reviewer: Date: dd-mmm-yy C
13 ! C
14 ! Literature/Document References: C
15 ! C
16 ! Variables referenced: TIME, NSTEP, EP_g, P_g, P_star, U_g C
17 ! V_g, W_g, U_s, V_s, W_s, ROP_s, T_g, T_s C
18 ! IJKMAX2, MMAX C
19 ! Variables modified: None C
20 ! C
21 ! Local variables: LC, N, NEXT_REC, NUM_REC C
22 ! C
23 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
24 !
25  SUBROUTINE write_spx1(L, unit_add)
26 !...Translated by Pacific-Sierra Research VAST-90 2.06G5 12:17:31 12/09/98
27 !...Switches: -xf
28 !
29 !-----------------------------------------------
30 ! M o d u l e s
31 !-----------------------------------------------
32  USE cdist
33  USE compar
34  USE cutcell
35  USE exit, only: mfix_exit
36  USE fldvar
37  USE funits
38  USE geometry
39  USE machine
40  USE mpi_utility
41  USE output
42  USE param
43  USE param1
44  USE physprop
45  USE run
46  USE rxns
47  USE scalars
48  use discretelement, only: des_continuum_coupled
49  use discretelement, only: discrete_element
50  use discretelement, only: print_des_data
51 
52 !// USE tmp_array
53  IMPLICIT NONE
54 !-----------------------------------------------
55 ! G l o b a l P a r a m e t e r s
56 !-----------------------------------------------
57 !-----------------------------------------------
58 ! D u m m y A r g u m e n t s
59 !-----------------------------------------------
60 !
61 ! flag whether to write a particular SPx file
62  INTEGER L
63 
64 ! offset for use in post_mfix
65  INTEGER unit_add
66 !-----------------------------------------------
67 ! L o c a l P a r a m e t e r s
68 !-----------------------------------------------
69 !-----------------------------------------------
70 ! L o c a l V a r i a b l e s
71 !-----------------------------------------------
72 !
73 ! local variables
74 !
75 !//
76  double precision, allocatable :: array1(:) !//
77  double precision, allocatable :: array2(:) !//
78 
79 ! loop counters
80  INTEGER LC, NN
81 !
82 ! Pointer to the next record
83  INTEGER NEXT_REC
84 !
85 ! Number of records written each time step
86  INTEGER NUM_REC
87 
88  INTEGER uspx ! UNIT_SPX + offset from post_mfix
89  CHARACTER(LEN=50), DIMENSION(1) :: LINE !error message
90  double precision, dimension(:), allocatable :: TMP_VAR
91 
92  allocate(tmp_var(dimension_3))
93 
94 !-----------------------------------------------
95  uspx = unit_spx + unit_add
96 
97 !
98  if (mype .eq.pe_io) then
99  allocate (array1(ijkmax2)) !//
100  allocate (array2(ijkmax3)) !//
101  else
102  allocate (array1(1)) !//
103  allocate (array2(1)) !//
104  end if
105 !
106 ! ".SP1" FILE EP_g [ ROP_g, RO_g must be calculated ...
107 ! not written out ]
108 !
109  SELECT CASE (l)
110  CASE (1)
111  if (mype.eq.pe_io.or.bdist_io) then
112  READ (uspx + l, rec=3) next_rec, num_rec
113  num_rec = next_rec
114  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
115  next_rec = next_rec + 1
116  end if
117 
118 ! Explicitly coupled simulations do not need to rebin particles to
119 ! the fluid grid every time step. However, this implies that the
120 ! fluid cell information and interpolation weights become stale.
121  IF(discrete_element .AND. .NOT.des_continuum_coupled) THEN
122 ! Bin particles to fluid grid.
123  CALL particles_in_cell
124 ! Calculate interpolation weights
126 ! Calculate mean fields (EPg).
127  CALL comp_mean_fields
128  ENDIF
129 
130  if (bdist_io) then
131  IF(re_indexing) THEN
132  CALL unshift_dp_array(ep_g,tmp_var)
133  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
134  ELSE
135  call out_bin_r(uspx+l,ep_g,size(ep_g),next_rec)
136  ENDIF
137 ! call OUT_BIN_R(uspx+L,EP_g,size(EP_g),NEXT_REC)
138  else
139  call gatherwritespx (ep_g,array2, array1, uspx+l, next_rec) !//
140  end if
141  if (mype .eq. pe_io.or.bdist_io) then
142  num_rec = next_rec - num_rec
143  WRITE (uspx + l, rec=3) next_rec, num_rec
144  if(unit_add == 0) CALL flush_bin (uspx + l)
145  end if
146 
147 ! The call made in make_arrays captures the initial state of the system
148 ! as the input and RES files for DES runs are read afte the the first
149 ! call to this routine.
150  IF(discrete_element.AND.print_des_data) THEN
151  IF(time /= zero .OR. trim(run_type)=='RESTART_1') &
152  CALL write_des_data
153  ENDIF
154 
155 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
156 !
157 ! ".SP2" FILE P_g , P_star
158 !
159  CASE (2)
160  if (mype.eq.pe_io.or.bdist_io) then
161  READ (uspx + l, rec=3) next_rec, num_rec
162  num_rec = next_rec
163  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
164  next_rec = next_rec + 1
165  end if
166  if (bdist_io) then
167  IF(re_indexing) THEN
168  CALL unshift_dp_array(p_g,tmp_var)
169  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
170  CALL unshift_dp_array(p_star,tmp_var)
171  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
172  ELSE
173  call out_bin_r(uspx+l,p_g,size(p_g),next_rec)
174  call out_bin_r(uspx+l,p_star,size(p_star),next_rec)
175  ENDIF
176 ! call OUT_BIN_R(uspx+L,P_g,size(P_g),NEXT_REC)
177 ! call OUT_BIN_R(uspx+L,P_star,size(P_star),NEXT_REC)
178  else
179  call gatherwritespx (p_g,array2, array1, uspx+l, next_rec) !//
180  call gatherwritespx (p_star,array2, array1, uspx+l, next_rec) !//
181  end if
182  if (mype.eq.pe_io.or.bdist_io) then
183  num_rec = next_rec - num_rec
184  WRITE (uspx + l, rec=3) next_rec, num_rec
185  if(unit_add == 0) CALL flush_bin (uspx + l)
186  end if
187 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
188 !
189 ! ".SP3" FILE U_g , V_g , W_g
190 !
191  CASE (3)
192  if (mype.eq.pe_io.or.bdist_io) then
193  READ (uspx + l, rec=3) next_rec, num_rec
194  num_rec = next_rec
195  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
196  next_rec = next_rec + 1
197  end if
198  if (bdist_io) then
199  IF(re_indexing) THEN
200  CALL unshift_dp_array(u_g,tmp_var)
201  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
202  CALL unshift_dp_array(v_g,tmp_var)
203  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
204  CALL unshift_dp_array(w_g,tmp_var)
205  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
206  ELSE
207  call out_bin_r(uspx+l,u_g,size(u_g),next_rec)
208  call out_bin_r(uspx+l,v_g,size(v_g),next_rec)
209  call out_bin_r(uspx+l,w_g,size(w_g),next_rec)
210  ENDIF
211 ! call OUT_BIN_R(uspx+L,U_g,size(U_g),NEXT_REC)
212 ! call OUT_BIN_R(uspx+L,V_g,size(V_g),NEXT_REC)
213 ! call OUT_BIN_R(uspx+L,W_g,size(W_g),NEXT_REC)
214  else
215  call gatherwritespx (u_g,array2, array1, uspx+l, next_rec) !//
216  call gatherwritespx (v_g,array2, array1, uspx+l, next_rec) !//
217  call gatherwritespx (w_g,array2, array1, uspx+l, next_rec) !//
218  end if
219  if (mype.eq.pe_io.or.bdist_io) then
220  num_rec = next_rec - num_rec
221  WRITE (uspx + l, rec=3) next_rec, num_rec
222  if(unit_add == 0) CALL flush_bin (uspx + l)
223  end if
224 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
225 !
226 ! ".SP4" FILE U_s , V_s , W_s
227 !
228  CASE (4)
229  if (mype.eq.pe_io.or.bdist_io) then
230  READ (uspx + l, rec=3) next_rec, num_rec
231  num_rec = next_rec
232  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
233  next_rec = next_rec + 1
234  end if
235  if (bdist_io) then
236  DO lc = 1, mmax
237  IF(re_indexing) THEN
238  CALL unshift_dp_array(u_s(:,lc),tmp_var)
239  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
240  CALL unshift_dp_array(v_s(:,lc),tmp_var)
241  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
242  CALL unshift_dp_array(w_s(:,lc),tmp_var)
243  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
244  ELSE
245  call out_bin_r(uspx+l,u_s(:,lc),Size(u_s(:,lc)),next_rec)
246  call out_bin_r(uspx+l,v_s(:,lc),Size(v_s(:,lc)),next_rec)
247  call out_bin_r(uspx+l,w_s(:,lc),Size(w_s(:,lc)),next_rec)
248  ENDIF
249  ENDDO
250 ! DO LC = 1, MMAX
251 ! call OUT_BIN_R(uspx+L,U_s(:,LC),Size(U_s(:,LC)),NEXT_REC)
252 ! call OUT_BIN_R(uspx+L,V_s(:,LC),Size(V_s(:,LC)),NEXT_REC)
253 ! call OUT_BIN_R(uspx+L,W_s(:,LC),Size(W_s(:,LC)),NEXT_REC)
254 ! END DO
255  else
256  DO lc = 1, mmax
257  call gatherwritespx (u_s(:,lc),array2, array1, uspx+l, next_rec)
258  call gatherwritespx (v_s(:,lc),array2, array1, uspx+l, next_rec)
259  call gatherwritespx (w_s(:,lc),array2, array1, uspx+l, next_rec)
260  END DO
261  end if
262  if (mype.eq.pe_io.or.bdist_io) then
263  num_rec = next_rec - num_rec
264  WRITE (uspx + l, rec=3) next_rec, num_rec
265  if(unit_add == 0) CALL flush_bin (uspx + l)
266  end if
267 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
268 !
269 ! ".SP5" FILE ROP_s
270 !
271  CASE (5)
272  if (mype.eq.pe_io.or.bdist_io) then
273  READ (uspx + l, rec=3) next_rec, num_rec
274  num_rec = next_rec
275  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
276  next_rec = next_rec + 1
277  end if
278  if (bdist_io) then
279  DO lc = 1, mmax
280  IF(re_indexing) THEN
281  CALL unshift_dp_array(rop_s(:,lc),tmp_var)
282  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
283  ELSE
284  call out_bin_r(uspx+l,rop_s(:,lc),size(rop_s(:,lc)), next_rec)
285  ENDIF
286  ENDDO
287 ! DO LC = 1, MMAX
288 ! call OUT_BIN_R(uspx+L,ROP_s(:,LC),size(ROP_s(:,LC)), NEXT_REC)
289 ! END DO
290  else
291  DO lc = 1, mmax
292  call gatherwritespx (rop_s(:,lc),array2, array1, uspx+l, next_rec)
293  END DO
294  end if
295  if (mype.eq.pe_io.or.bdist_io) then
296  num_rec = next_rec - num_rec
297  WRITE (uspx + l, rec=3) next_rec, num_rec
298  if(unit_add == 0) CALL flush_bin (uspx + l)
299  end if
300 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
301 !
302 ! ".SP6" FILE T_g , T_s
303 !
304  CASE (6)
305  if (mype.eq.pe_io.or.bdist_io) then
306  READ (uspx + l, rec=3) next_rec, num_rec
307  num_rec = next_rec
308  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
309  next_rec = next_rec + 1
310  end if
311  if (bdist_io) then
312  IF(re_indexing) THEN
313  CALL unshift_dp_array(t_g,tmp_var)
314  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
315  DO lc = 1, mmax
316  CALL unshift_dp_array(t_s(:,lc),tmp_var)
317  call out_bin_r(uspx+l,tmp_var,size(tmp_var), next_rec)
318  END DO
319  ELSE
320  call out_bin_r(uspx+l,t_g,size(t_g), next_rec)
321  DO lc = 1, mmax
322  call out_bin_r(uspx+l,t_s(:,lc),size(t_s(:,lc)), next_rec)
323  END DO
324  ENDIF
325 ! call OUT_BIN_R(uspx+L,T_g,size(T_g), NEXT_REC)
326 ! DO LC = 1, MMAX
327 ! call OUT_BIN_R(uspx+L,T_s(:,LC),size(T_s(:,LC)), NEXT_REC)
328 ! END DO
329  else
330  call gatherwritespx (t_g,array2, array1, uspx+l, next_rec) !//
331  DO lc = 1, mmax
332  call gatherwritespx (t_s(:,lc),array2, array1, uspx+l, next_rec)
333  END DO
334  end if
335  if (mype.eq.pe_io.or.bdist_io) then
336  num_rec = next_rec - num_rec
337  WRITE (uspx + l, rec=3) next_rec, num_rec
338  if(unit_add == 0) CALL flush_bin (uspx + l)
339  end if
340 !
341 ! ".SP7" FILE X_g, X_s
342 !
343  CASE (7)
344  if (mype.eq.pe_io.or.bdist_io) then
345  READ (uspx + l, rec=3) next_rec, num_rec
346  num_rec = next_rec
347  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
348  next_rec = next_rec + 1
349  end if
350  if (bdist_io) then
351  IF(re_indexing) THEN
352  DO nn = 1, nmax(0)
353  CALL unshift_dp_array(x_g(:,nn),tmp_var)
354  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
355  END DO
356  DO lc = 1, mmax
357  DO nn = 1, nmax(lc)
358  CALL unshift_dp_array(x_s(:,lc,nn),tmp_var)
359  call out_bin_r(uspx+l,tmp_var,size(tmp_var), next_rec)
360  ENDDO
361  END DO
362  ELSE
363  DO nn = 1, nmax(0)
364  call out_bin_r(uspx+l,x_g(:,nn),size(x_g(:,nn)), next_rec)
365  END DO
366  DO lc = 1, mmax
367  DO nn = 1, nmax(lc)
368  call out_bin_r(uspx+l,x_s(:,lc,nn),size(x_s(:,lc,nn)), next_rec)
369  END DO
370  END DO
371  ENDIF
372 
373 ! DO NN = 1, NMAX(0)
374 ! call OUT_BIN_R(uspx+L,X_G(:,nn),size(X_G(:,nn)), NEXT_REC)
375 ! END DO
376 ! DO LC = 1, MMAX
377 ! DO NN = 1, NMAX(LC)
378 ! call OUT_BIN_R(uspx+L,X_s(:,LC,nn),size(X_s(:,LC,nn)), NEXT_REC)
379 ! END DO
380 ! END DO
381 
382  else
383  DO nn = 1, nmax(0)
384  call gatherwritespx (x_g(:,nn),array2, array1, uspx+l, next_rec)
385  END DO
386  DO lc = 1, mmax
387  DO nn = 1, nmax(lc)
388  call gatherwritespx (x_s(:,lc,nn),array2, array1, uspx+l, next_rec)
389  END DO
390  END DO
391  end if
392  if (mype.eq.pe_io.or.bdist_io) then
393  num_rec = next_rec - num_rec
394  WRITE (uspx + l, rec=3) next_rec, num_rec
395  if(unit_add == 0) CALL flush_bin (uspx + l)
396  end if
397 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
398 !
399 ! ".SP8" FILE THETA_m
400 !
401  CASE (8)
402  if (mype.eq.pe_io.or.bdist_io) then
403  READ (uspx + l, rec=3) next_rec, num_rec
404  num_rec = next_rec
405  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
406  next_rec = next_rec + 1
407  end if
408  if (bdist_io) then
409  IF(re_indexing) THEN
410  DO lc = 1, mmax
411  CALL unshift_dp_array(theta_m(:,lc),tmp_var)
412  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
413  ENDDO
414  ELSE
415  DO lc = 1, mmax
416  call out_bin_r(uspx+l,theta_m(:,lc),size(theta_m(:,lc)), next_rec)
417  END DO
418  ENDIF
419 ! DO LC = 1, MMAX
420 ! call OUT_BIN_R(uspx+L,THETA_m(:,LC),size(THETA_m(:,LC)), NEXT_REC)
421 ! END DO
422  else
423  DO lc = 1, mmax
424  call gatherwritespx (theta_m(:,lc),array2, array1, uspx+l, next_rec)
425  END DO
426  end if
427  if (mype.eq.pe_io .or. bdist_io) then
428  num_rec = next_rec - num_rec
429  WRITE (uspx + l, rec=3) next_rec, num_rec
430  if(unit_add == 0) CALL flush_bin (uspx + l)
431  end if
432 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
433 !
434 ! ".SP9" FILE Scalar
435 !
436  CASE (9)
437  if (mype.eq.pe_io.or.bdist_io) then
438  READ (uspx + l, rec=3) next_rec, num_rec
439  num_rec = next_rec
440  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
441  next_rec = next_rec + 1
442  end if
443  if (bdist_io) then
444  IF(re_indexing) THEN
445  DO lc = 1, nscalar
446  CALL unshift_dp_array(scalar(:,lc),tmp_var)
447  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
448  ENDDO
449  ELSE
450  DO lc = 1, nscalar
451  call out_bin_r(uspx+l,scalar(:,lc),size(scalar(:,lc)), next_rec)
452  END DO
453  ENDIF
454 ! DO LC = 1, Nscalar
455 ! call OUT_BIN_R(uspx+L,Scalar(:,LC),size(Scalar(:,LC)), NEXT_REC)
456 ! END DO
457  else
458  DO lc = 1, nscalar
459  call gatherwritespx (scalar(:,lc),array2, array1, uspx+l, next_rec)
460  END DO
461  end if
462  if (mype.eq.pe_io.or.bdist_io) then
463  num_rec = next_rec - num_rec
464  WRITE (uspx + l, rec=3) next_rec, num_rec
465  if(unit_add == 0) CALL flush_bin (uspx + l)
466  end if
467 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
468 !
469  CASE (10) ! Reaction rates
470 
471  if (mype.eq.pe_io.or.bdist_io) then
472  READ (uspx + l, rec=3) next_rec, num_rec
473  num_rec = next_rec
474  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
475  next_rec = next_rec + 1
476  end if
477  if (bdist_io) then
478  IF(re_indexing) THEN
479  DO lc = 1, nrr
480  CALL unshift_dp_array(reactionrates(:,lc),tmp_var)
481  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
482  ENDDO
483  ELSE
484  DO lc = 1, nrr
485  call out_bin_r(uspx+l,reactionrates(:,lc),size(reactionrates(:,lc)), next_rec)
486  END DO
487  ENDIF
488 ! DO LC = 1, nRR
489 ! call OUT_BIN_R(uspx+L,ReactionRates(:,LC),size(ReactionRates(:,LC)), NEXT_REC)
490 ! END DO
491  else
492  DO lc = 1, nrr
493  call gatherwritespx (reactionrates(:,lc),array2, array1, uspx+l, next_rec)
494  END DO
495  end if
496  if (mype.eq.pe_io.or.bdist_io) then
497  num_rec = next_rec - num_rec
498  WRITE (uspx + l, rec=3) next_rec, num_rec
499  if(unit_add == 0) CALL flush_bin (uspx + l)
500  end if
501 !
502 ! ".SP11" FILE turbulence
503 !
504  CASE (11)
505  if (mype.eq.pe_io.or.bdist_io) then
506  READ (uspx + l, rec=3) next_rec, num_rec
507  num_rec = next_rec
508  WRITE (uspx + l, rec=next_rec) REAL(TIME), NSTEP
509  next_rec = next_rec + 1
510  end if
511  if (k_epsilon) then
512  if (bdist_io) then
513  IF(re_indexing) THEN
514  CALL unshift_dp_array(k_turb_g,tmp_var)
515  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
516  CALL unshift_dp_array(e_turb_g,tmp_var)
517  call out_bin_r(uspx+l,tmp_var,size(tmp_var),next_rec)
518  ELSE
519  call out_bin_r(uspx+l,k_turb_g,size(k_turb_g), next_rec)
520  call out_bin_r(uspx+l,e_turb_g,size(e_turb_g), next_rec)
521  ENDIF
522 ! call OUT_BIN_R(uspx+L,K_Turb_G,size(K_Turb_G), NEXT_REC)
523 ! call OUT_BIN_R(uspx+L,E_Turb_G,size(E_Turb_G), NEXT_REC)
524 
525  else
526  call gatherwritespx (k_turb_g,array2, array1, uspx+l, next_rec)
527  call gatherwritespx (e_turb_g,array2, array1, uspx+l, next_rec)
528  end if
529  end if
530 
531  if (mype.eq.pe_io.or.bdist_io) then
532  num_rec = next_rec - num_rec
533  WRITE (uspx + l, rec=3) next_rec, num_rec
534  if(unit_add == 0) CALL flush_bin (uspx + l)
535  end if
536 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
537 !
538 !
539  CASE DEFAULT
540  line(1) = 'Unknown SPx file index'
541  CALL write_error ('WRITE_SPX1', line, 1)
542  CALL mfix_exit(mype)
543  END SELECT
544 
545 !// call unlock_tmp_array
546 !
547  deallocate (array1)
548  deallocate (array2)
549  deallocate (tmp_var)
550 !
551  RETURN
552  END SUBROUTINE write_spx1
553 
554  subroutine gatherwritespx(VAR, array2, array1, uspxL, NEXT_REC)
556  USE compar !//
557  USE mpi_utility !//d pnicol : for gatherWriteSpx
558  USE sendrecv !//d pnicol : for gatherWriteSpx
559  USE cutcell
560  USE in_binary_512
561  USE param, only: dimension_3
562  USE param1, only: undefined
563  IMPLICIT NONE
564  integer uspxL, NEXT_REC
565  double precision, dimension(ijkmax2) :: array1
566  double precision, dimension(ijkmax3) :: array2
567  double precision, dimension(DIMENSION_3) :: VAR
568  double precision, dimension(:), allocatable :: TMP_VAR
569 
570  allocate(tmp_var(dimension_3))
571 
572 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
573  IF(re_indexing) THEN
574  tmp_var = undefined
575  CALL unshift_dp_array(var,tmp_var)
576  CALL gather (tmp_var,array2,root)
577  ELSE
578  CALL gather (var,array2,root)
579  ENDIF
580 ! call gather (VAR,array2,root) !//d pnicol
581 
582 ! call MPI_Barrier(MPI_COMM_WORLD,mpierr) !//PAR_I/O enforce barrier here
583  if (mype.eq.pe_io) then
584  call convert_to_io_dp(array2,array1,ijkmax2)
585  CALL out_bin_r (uspxl, array1, ijkmax2, next_rec)
586  end if
587 
588  deallocate(tmp_var)
589 
590  End subroutine gatherwritespx
591 
592 
593 
594  subroutine gatherwritespx_netcdf(VAR, arr1, arr2 , arr4d, ncid, varid , &
595  nx,ny,nz,ijkmax2_use , ijkmax3_use)
596 
597 
598  USE geometry
599  use param, only: dimension_3
600  USE compar !//
601  USE mpi_utility !//d pnicol : for gatherWriteSpx
602  USE sendrecv !//d pnicol : for gatherWriteSpx
603  USE mfix_netcdf
604  USE in_binary_512
605 
606  IMPLICIT NONE
607 
608  integer :: ncid , varid , nx,ny,nz , ijkmax2_use , ijkmax3_use
609  integer :: ii , jj , kk , ijk
610 
611  double precision :: arr1(ijkmax2_use)
612  double precision :: arr2(ijkmax3_use)
613  double precision :: arr4d(nx,ny,nz,1)
614  double precision :: var(dimension_3)
615 
616  call gather(var,arr2,root)
617  if (mype .eq. pe_io) then
618  call convert_to_io_dp(arr2,arr1,ijkmax2_use)
619 
620  ijk = 0
621  do kk = 1,nz
622  do jj = 1,ny
623  do ii = 1,nx
624  ijk = ijk + 1
625  arr4d(ii,jj,kk,1) = arr1(ijk)
626  end do
627  end do
628  end do
629 
630  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid,arr4d) )
631 
632  end if
633 
634 
635  End subroutine gatherwritespx_netcdf
636 
637 
638 
639  subroutine gatherwritespx_netcdf_int(VAR, arr1, arr2 , arr4d, ncid, &
640  varid , nx,ny,nz,ijkmax2_use , ijkmax3_use)
641 
642 
643  USE geometry
644  use param, only: dimension_3
645  USE compar !//
646  USE mpi_utility !//d pnicol : for gatherWriteSpx
647  USE sendrecv !//d pnicol : for gatherWriteSpx
648  USE mfix_netcdf
649  USE in_binary_512i
650 
651  IMPLICIT NONE
652 
653  integer :: ncid , varid , nx,ny,nz , ijkmax2_use , ijkmax3_use
654  integer :: ii , jj , kk , ijk
655 
656  integer :: arr1(ijkmax2_use)
657  integer :: arr2(ijkmax3_use)
658  integer :: arr4d(nx,ny,nz,1)
659  integer :: var(dimension_3)
660 
661  call gather(var,arr2,root)
662  if (mype .eq. pe_io) then
663  call convert_to_io_i(arr2,arr1,ijkmax2_use)
664 
665  ijk = 0
666  do kk = 1,nz
667  do jj = 1,ny
668  do ii = 1,nx
669  ijk = ijk + 1
670  arr4d(ii,jj,kk,1) = arr1(ijk)
671  end do
672  end do
673  end do
674 
675  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid,arr4d) )
676 
677  end if
678 
679 
680  End subroutine gatherwritespx_netcdf_int
681 
682  subroutine copy_d_to_r(darr,rarr,nx,ny,nz)
683  implicit none
684 
685  integer :: nx , ny , nz
686  double precision :: darr(*)
687  real :: rarr(nx,ny,*)
688  integer :: i , j , k , ijk
689 
690 
691  ijk = 0
692 
693  do i = 1,nx
694  do j = 1,ny
695  do k = 1,nz
696  ijk = ijk + 1
697  rarr(i,j,k) = real(darr(ijk))
698  end do
699  end do
700  end do
701 
702  return
703  end subroutine copy_d_to_r
704 
705 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
706 !
707 ! write_mesh_netcdf
708 !
709 !
710  SUBROUTINE write_mesh_netcdf
712  USE param
713  USE param1
714  USE fldvar
715  USE geometry
716  USE physprop
717  USE run
718 ! USE funits
719  USE scalars
720 ! USE output
721  USE rxns
722  USE cdist
723  USE compar
724  USE mpi_utility
725  USE mfix_netcdf
726 ! USE tmp_array
727 
728  implicit none
729 
730  integer :: ncid , x_dimid , y_dimid , z_dimid , t_dimid
731  integer :: varid_x , varid_y , varid_z , L , dimids(4)
732  integer :: varid_flag , coords_dimid , varid_coords , coords
733 
734  character(LEN=80) :: fname
735 
736  double precision, dimension(:) , allocatable :: xloc
737  double precision, dimension(:) , allocatable :: yloc
738  double precision, dimension(:) , allocatable :: zloc
739 
740  integer, dimension(:) , allocatable :: arr1
741  integer, dimension(:) , allocatable :: arr2
742  integer, dimension(:,:,:,:) , allocatable :: arr4d
743 
744 
745  if (.not. mfix_usingnetcdf()) return
746 
747  if (.not. bglobalnetcdf) return ! no netCDF writes asked for
748 
749  if (.not. bfirst_netcdf_write) return
750 
751  if (mype.eq.pe_io) then
752  allocate ( arr1(ijkmax2))
753  allocate ( arr2(ijkmax3))
754  allocate ( arr4d(imax2,jmax2,kmax2,1))
755  allocate ( xloc(imax2) )
756  allocate ( yloc(jmax2) )
757  allocate ( zloc(kmax2) )
758  else
759  allocate ( arr1(1))
760  allocate ( arr2(1))
761  allocate ( arr4d(1,1,1,1))
762  allocate ( xloc(1) )
763  allocate ( yloc(1) )
764  allocate ( zloc(1) )
765  end if
766 
767  if (mype.eq.pe_io) then
768  xloc(1) = -dx(1)
769  do l = 2,imax2
770  xloc(l) = xloc(l-1) + dx(l)
771  end do
772 
773  yloc(1) = -dy(1)
774  do l = 2,jmax2
775  yloc(l) = yloc(l-1) + dy(l)
776  end do
777 
778  zloc(1) = -dz(1)
779  do l = 2,kmax2
780  zloc(l) = zloc(l-1) + dz(l)
781  end do
782 
783  fname = trim(run_name) // "_MESH.nc"
785 
786  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "x" , imax2 , x_dimid ) )
787  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "y" , jmax2 , y_dimid ) )
788  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "z" , kmax2 , z_dimid ) )
789  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "coordinates" , 1 , coords_dimid ) )
790  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "t" , 1 , t_dimid ) ) ! 4
791 
792  dimids = (/ x_dimid , y_dimid, z_dimid , t_dimid/)
793 
794 
795  ! The dimids array is used to pass the IDs of the dimensions of
796  ! the variables. Note that in fortran arrays are stored in
797  ! column-major format.
798  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "x" , nf90_double, x_dimid, varid_x ) )
799  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "y" , nf90_double, y_dimid, varid_y ) )
800  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "z" , nf90_double, z_dimid, varid_z ) )
801  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "coordinates" , nf90_int, coords_dimid, varid_coords ) )
802  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "flag" , nf90_int, dimids, varid_flag ) ) ! 9
803 
804 
805  call mfix_check_netcdf( mfix_nf90_enddef(ncid) )
806 
807  coords = 0
808  if (coordinates .eq. 'CYLINDRICAL') coords = 1
809 
810  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_coords,coords) )
811  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_x,xloc) )
812  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_y,yloc) )
813  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_z,zloc) )
814  end if
815 
816 
817  ! needs to be called by all processes
818 
819  call gatherwritespx_netcdf_int(flag, arr1, arr2 , arr4d, ncid, &
820  varid_flag , imax2,jmax2,kmax2,ijkmax2 , ijkmax3)
821 
822 
823 
824  if (mype.eq.pe_io) then
825  call mfix_check_netcdf( mfix_nf90_close(ncid) )
826  end if
827 
828  deallocate ( arr1 )
829  deallocate ( arr2 )
830  deallocate ( arr4d )
831  deallocate ( xloc )
832  deallocate ( yloc )
833  deallocate ( zloc )
834 
835  return
836  end subroutine write_mesh_netcdf
837 
838  SUBROUTINE write_netcdf(L, unit_add, the_time)
840  USE param
841  USE param1
842  USE fldvar
843  USE geometry
844  USE physprop
845  USE run
846 ! USE funits
847  USE scalars
848 ! USE output
849  USE rxns
850  USE cdist
851  USE compar
852  USE mpi_utility
853  USE mfix_netcdf
854 ! USE tmp_array
855 
856 
857  implicit none
858 
859  integer :: L , unit_add , I , nn , ii
860 
861  integer :: ncid , x_dimid , y_dimid , z_dimid
862  integer :: t_dimid
863  integer :: dimids(4) , varid_epg , varid_pg
864 
865  integer :: varid_pstar , varid_ug , varid_vg , varid_wg
866  integer :: varid_tg , varid_x , varid_y , varid_z , varid_t
867  integer :: varid_coords , coords_dimid , coords
868 
869  integer :: varid_us(20) , varid_vs(20) , varid_ws(20) !! MMAX
870  integer :: varid_rops(20) , varid_ts(20) !! mmax
871  integer :: varid_thetam(20) !! mmax
872 
873  integer :: varid_xg(20) ! nmax(0)
874  integer :: varid_xs(20,20) ! mmax , MAX(nmax(1:mmax))
875 
876  integer :: varid_scalar(20) ! nscalar
877  integer :: varid_rr(20) ! nRR
878 
879  integer :: varid_kturbg , varid_eturbg
880 
881 
882  character(LEN=80) :: fname, var_name
883  character(LEN=9) :: fname_index
884 
885  double precision, dimension(:) , allocatable :: arr1
886  double precision, dimension(:) , allocatable :: arr2
887 
888  double precision, dimension(:,:,:,:) , allocatable :: arr4d
889 
890 
891  double precision, dimension(:) , allocatable :: xloc
892  double precision, dimension(:) , allocatable :: yloc
893  double precision, dimension(:) , allocatable :: zloc
894 
895  double precision :: the_time
896  logical :: file_exists
897 
898 
899 ! bWrite_netcdf(1) : EP_g
900 ! bWrite_netcdf(2) : P_g
901 ! bWrite_netcdf(3) : P_star
902 ! bWrite_netcdf(4) : U_g / V_g / W_g
903 ! bWrite_netcdf(5) : U_s / V_s / W_s
904 ! bWrite_netcdf(6) : ROP_s
905 ! bWrite_netcdf(7) : T_g
906 ! bWrite_netcdf(8) : T_s
907 ! bWrite_netcdf(9) : X_g
908 ! bWrite_netcdf(10) : X_s
909 ! bWrite_netcdf(11) : Theta_m
910 ! bWrite_netCDF(12) : Scalar
911 ! bWrite_netCDF(13) : ReactionRates
912 ! bWrite_netCDF(14) : k_turb_g , e_turb_g
913 
914  if (.not. mfix_usingnetcdf()) return
915  if (.not. bglobalnetcdf) return
916 
917  call write_mesh_netcdf
918 
919  if (mype.eq.pe_io .and. .not.bdist_io) then
920  allocate (arr1(ijkmax2))
921  allocate (arr2(ijkmax3))
922  allocate (arr4d(imax2,jmax2,kmax2,1))
923  allocate ( xloc(imax2) )
924  allocate ( yloc(jmax2) )
925  allocate ( zloc(kmax2) )
926 
927 
928 
929 
930  else
931  allocate (arr1(1))
932  allocate (arr2(1))
933  allocate (arr4d(1,1,1,1))
934  allocate ( xloc(1) )
935  allocate ( yloc(1) )
936  allocate ( zloc(1) )
937  end if
938 
939 ! CALL MPI_BARRIER(MPI_COMM_WORLD,mpierr)
940  if (mype .ne. pe_io) goto 1234
941 
942 
943  xloc(1) = -dx(1)
944  do ii = 2,imax2
945  xloc(ii) = xloc(ii-1) + dx(ii)
946  end do
947 
948 
949  yloc(1) = -dy(1)
950  do ii = 2,jmax2
951  yloc(ii) = yloc(ii-1) + dy(ii)
952  end do
953 
954  zloc(1) = -dz(1)
955  do ii = 2,kmax2
956  zloc(ii) = zloc(ii-1) + dz(ii)
957  end do
958 
959 
960 
961 
962  if (bfirst_netcdf_write .and. mfix_usingnetcdf()) then
963  bfirst_netcdf_write = .false.
964  fname = trim(run_name) // '_netcdf_index.txt'
965  inquire (file=fname,exist=file_exists)
966 
967  if (file_exists) then
968  open (unit=11,file=fname,status='old')
969  read (11,*) netcdf_file_index
970  close (unit=11)
971  else
973  end if
974  end if
975 
976  fname_index = '_xxxxx.nc'
977  write (fname_index(2:6),'(i5.5)') netcdf_file_index
978  fname = trim(run_name)// fname_index
981 
982  if (mfix_usingnetcdf()) then
983  fname = trim(run_name) // '_netcdf_index.txt'
984  open (unit=11,file=fname,status='unknown')
985  write (11,*) netcdf_file_index
986  close (unit=11)
987  end if
988 
989 
990  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "x" , imax2 , x_dimid ) ) ! 1
991  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "y" , jmax2 , y_dimid ) ) ! 2
992  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "z" , kmax2 , z_dimid ) ) ! 3
993  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "coordinates" , 1 , coords_dimid ) ) ! 3
994  call mfix_check_netcdf( mfix_nf90_def_dim(ncid, "t" , 1 , t_dimid ) ) ! 4
995 
996 
997  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "x" , nf90_double, x_dimid, varid_x ) ) ! 5
998  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "y" , nf90_double, y_dimid, varid_y ) ) ! 6
999  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "z" , nf90_double, z_dimid, varid_z ) ) ! 7
1000  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "coordinates" , nf90_int, coords_dimid, varid_coords ) ) ! 7
1001  call mfix_check_netcdf( mfix_nf90_def_var(ncid, "t" , nf90_double, t_dimid, varid_t ) ) ! 8
1002 
1003  dimids = (/ x_dimid , y_dimid, z_dimid , t_dimid/)
1004 
1005  if (bwrite_netcdf(1)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "EP_g" , nf90_double, dimids, varid_epg ) ) ! 9
1006  if (bwrite_netcdf(2)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "P_g" , nf90_double, dimids, varid_pg ) ) ! 10
1007 
1008  if (bwrite_netcdf(3)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "P_star", nf90_double, dimids, varid_pstar) )
1009  if (bwrite_netcdf(4)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "U_g" , nf90_double, dimids, varid_ug ) )
1010  if (bwrite_netcdf(4)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "V_g" , nf90_double, dimids, varid_vg ) )
1011  if (bwrite_netcdf(4)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "W_g" , nf90_double, dimids, varid_wg ) )
1012  if (bwrite_netcdf(7)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, "T_g" , nf90_double, dimids, varid_tg ) )
1013  do i = 1,1 ! mmax
1014  var_name = 'U_s_xxx'
1015  write (var_name(5:7),'(i3.3)') i
1016  if (bwrite_netcdf(5)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_us(i)) )
1017 
1018  var_name = 'V_s_xxx'
1019  write (var_name(5:7),'(i3.3)') i
1020  if (bwrite_netcdf(5)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_vs(i)) )
1021 
1022  var_name = 'W_s_xxx'
1023  write (var_name(5:7),'(i3.3)') i
1024  if (bwrite_netcdf(5)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_ws(i)) )
1025 
1026  var_name = 'ROP_s_xxx'
1027  write (var_name(7:10),'(i3.3)') i
1028  if (bwrite_netcdf(6)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_rops(i)) )
1029 
1030  var_name = 'T_s_xxx'
1031  write (var_name(5:7),'(i3.3)') i
1032  if (bwrite_netcdf(8)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_ts(i)) )
1033 
1034  var_name = 'Theta_m_xxx'
1035  write (var_name(9:11),'(i3.3)') i
1036  if (bwrite_netcdf(11)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_thetam(i)) )
1037 
1038  DO nn = 1, nmax(i)
1039  var_name = 'X_s_xxx_xxx'
1040  write (var_name(5:7) ,'(i3.3)') i
1041  write (var_name(9:11),'(i3.3)') nn
1042  if (bwrite_netcdf(10)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_xs(i,nn)) )
1043  END DO
1044 
1045 
1046  end do
1047 
1048  do i = 1,nmax(0)
1049  var_name = 'X_g_xxx'
1050  write (var_name(5:7),'(i3.3)') i
1051  if (bwrite_netcdf(9)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_xg(i)) )
1052  end do
1053 
1054  do i = 1,nscalar
1055  var_name = 'Scalar_xxx'
1056  write (var_name(8:10),'(i3.3)') i
1057  if (bwrite_netcdf(12)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_scalar(i)) )
1058  end do
1059 
1060  do i = 1,nrr
1061  var_name = 'RRates_xxx'
1062  write (var_name(8:10),'(i3.3)') i
1063  if (bwrite_netcdf(13)) call mfix_check_netcdf( mfix_nf90_def_var(ncid, var_name, nf90_double, dimids, varid_rr(i)) )
1064  end do
1065 
1066 
1067  if (bwrite_netcdf(14) .and. k_epsilon) then
1068  call mfix_check_netcdf( mfix_nf90_def_var(ncid, 'k_turb_g', nf90_double, dimids, varid_kturbg) )
1069  call mfix_check_netcdf( mfix_nf90_def_var(ncid, 'e_turb_g', nf90_double, dimids, varid_eturbg) )
1070  end if
1071 
1072 
1073 
1074  call mfix_check_netcdf( mfix_nf90_enddef(ncid) ) ! 11
1075 
1076  1234 continue
1077  bfirst_netcdf_write = .false.
1078 
1079 ! CALL MPI_BARRIER(MPI_COMM_WORLD,mpierr)
1080 
1081 
1082  if (mype .eq. pe_io) then
1083  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_t,the_time) ) ! 12
1084  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_x,xloc) )
1085  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_y,yloc) )
1086  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_z,zloc) )
1087  coords = 0
1088  if (coordinates .eq. 'CYLINDRICAL') coords = 1
1089  call mfix_check_netcdf( mfix_nf90_put_var(ncid,varid_coords,coords) )
1090  end if
1091 
1092  if (bwrite_netcdf(1)) then
1093 
1094  call gatherwritespx_netcdf(ep_g, arr1, arr2 , arr4d, ncid, varid_epg , &
1096 
1097  end if
1098 
1099  if (bwrite_netcdf(2)) then
1100 
1101  call gatherwritespx_netcdf(p_g, arr1, arr2 , arr4d, ncid, varid_pg , &
1103 
1104  end if
1105 
1106 
1107 
1108 
1109  if (bwrite_netcdf(3)) then
1110 
1111  call gatherwritespx_netcdf(p_star, arr1, arr2 , arr4d, ncid, varid_pstar , &
1113 
1114  end if
1115 
1116  if (bwrite_netcdf(4)) then
1117 
1118  call gatherwritespx_netcdf(u_g, arr1, arr2 , arr4d, ncid, varid_ug , &
1120 
1121  call gatherwritespx_netcdf(v_g, arr1, arr2 , arr4d, ncid, varid_vg , &
1123 
1124  call gatherwritespx_netcdf(w_g, arr1, arr2 , arr4d, ncid, varid_wg , &
1126 
1127  end if
1128 
1129  if (bwrite_netcdf(7)) then
1130 
1131  call gatherwritespx_netcdf(t_g, arr1, arr2 , arr4d, ncid, varid_tg , &
1133 
1134  end if
1135 
1136 
1137  do i = 1,1 ! mmax
1138 
1139  if (bwrite_netcdf(5)) then
1140 
1141  call gatherwritespx_netcdf(u_s(:,i) , arr1, arr2 , arr4d, ncid, varid_us(i) , &
1143 
1144  call gatherwritespx_netcdf(v_s(:,i) , arr1, arr2 , arr4d, ncid, varid_vs(i) , &
1146 
1147  call gatherwritespx_netcdf(w_s(:,i) , arr1, arr2 , arr4d, ncid, varid_ws(i) , &
1149 
1150  end if
1151 
1152  if (bwrite_netcdf(6)) then
1153 
1154  call gatherwritespx_netcdf(rop_s(:,i) , arr1, arr2 , arr4d, ncid, varid_rops(i) , &
1156 
1157  end if
1158 
1159  if (bwrite_netcdf(8)) then
1160 
1161  call gatherwritespx_netcdf(t_s(:,i) , arr1, arr2 , arr4d, ncid, varid_ts(i) , &
1163 
1164  end if
1165 
1166  if (bwrite_netcdf(11)) then
1167 
1168  call gatherwritespx_netcdf(theta_m(:,i) , arr1, arr2 , arr4d, ncid, varid_thetam(i) , &
1170 
1171  end if
1172 
1173  if (bwrite_netcdf(10)) then
1174  do nn = 1,nmax(i)
1175 
1176  call gatherwritespx_netcdf(x_s(:,i,nn) , arr1, arr2 , arr4d, ncid, varid_xs(i,nn) , &
1178 
1179  end do
1180  end if
1181 
1182 
1183  end do
1184 
1185  if (bwrite_netcdf(9)) then
1186  do i = 1,nmax(0)
1187 
1188  call gatherwritespx_netcdf(x_g(:,i) , arr1, arr2 , arr4d, ncid, varid_xg(i) , &
1190 
1191  end do
1192  end if
1193 
1194  if (bwrite_netcdf(12)) then
1195  do i = 1,nscalar
1196 
1197  call gatherwritespx_netcdf(scalar(:,i) , arr1, arr2 , arr4d, ncid, varid_scalar(i) , &
1199 
1200  end do
1201  end if
1202 
1203 
1204  if (bwrite_netcdf(13)) then
1205  do i = 1,nrr
1206 
1207  call gatherwritespx_netcdf(reactionrates(:,i) , arr1, arr2 , arr4d, ncid, varid_rr(i) , &
1209 
1210  end do
1211  end if
1212 
1213  if (bwrite_netcdf(14) .and. k_epsilon) then
1214 
1215  call gatherwritespx_netcdf(k_turb_g , arr1, arr2 , arr4d, ncid, varid_kturbg , &
1217 
1218  call gatherwritespx_netcdf(e_turb_g , arr1, arr2 , arr4d, ncid, varid_eturbg , &
1220 
1221  end if
1222 
1223  ! Close the file. This frees up any internal netCDF resources
1224  ! associated with the file, and flushes any buffers.
1225 ! CALL MPI_BARRIER(MPI_COMM_WORLD,mpierr)
1226  if (mype .eq. pe_io) then
1227  call mfix_check_netcdf( mfix_nf90_close(ncid) )
1228  end if
1229 
1230  deallocate (arr1)
1231  deallocate (arr2)
1232  deallocate (arr4d)
1233  deallocate (xloc)
1234  deallocate (yloc)
1235  deallocate (zloc)
1236 
1237  return
1238  end subroutine write_netcdf
subroutine comp_mean_fields
subroutine gatherwritespx_netcdf_int(VAR, arr1, arr2, arr4d, ncid
Definition: write_spx1.f:640
character(len=16) coordinates
Definition: geometry_mod.f:17
double precision, dimension(:,:), allocatable v_s
Definition: fldvar_mod.f:105
logical re_indexing
Definition: cutcell_mod.f:16
integer function mfix_nf90_def_dim(ncid, name, len, dimid)
subroutine write_mesh_netcdf
Definition: write_spx1.f:711
integer imax2
Definition: geometry_mod.f:61
subroutine write_des_data
double precision, dimension(:), allocatable ep_g
Definition: fldvar_mod.f:15
integer function mfix_nf90_create(path, cmode, ncid, initialsize, chunksize)
logical bdist_io
Definition: cdist_mod.f:4
subroutine mfix_check_netcdf(status)
double precision, dimension(:), allocatable k_turb_g
Definition: fldvar_mod.f:161
integer dimension_3
Definition: param_mod.f:11
subroutine write_error(NAME, LINE, LMAX)
Definition: write_error.f:21
subroutine flush_bin(iunit)
Definition: machine_mod.f:227
subroutine write_spx1(L, unit_add)
Definition: write_spx1.f:26
integer ijkmax2
Definition: geometry_mod.f:80
subroutine gatherwritespx_netcdf(VAR, arr1, arr2, arr4d, ncid, va
Definition: write_spx1.f:595
double precision, dimension(:,:), allocatable w_s
Definition: fldvar_mod.f:117
Definition: rxns_mod.f:1
character(len=60) run_name
Definition: run_mod.f:24
double precision, dimension(:), allocatable t_g
Definition: fldvar_mod.f:63
integer function mfix_nf90_close(ncid)
subroutine write_netcdf(L, unit_add, the_time)
Definition: write_spx1.f:839
double precision, dimension(:,:), allocatable scalar
Definition: fldvar_mod.f:155
double precision, dimension(0:dim_j) dy
Definition: geometry_mod.f:70
double precision, dimension(:), allocatable p_g
Definition: fldvar_mod.f:26
integer nf90_64bit_offset
subroutine convert_to_io_i(arr_internal, arr_io, nn)
double precision, parameter undefined
Definition: param1_mod.f:18
double precision, dimension(0:dim_k) dz
Definition: geometry_mod.f:72
double precision, dimension(:,:), allocatable u_s
Definition: fldvar_mod.f:93
subroutine calc_interp_weights
integer ijkmax3
Definition: geometry_mod.f:82
integer netcdf_file_index
Definition: cdist_mod.f:8
integer pe_io
Definition: compar_mod.f:30
subroutine mfix_exit(myID, normal_termination)
Definition: exit.f:5
integer mmax
Definition: physprop_mod.f:19
subroutine copy_d_to_r(darr, rarr, nx, ny, nz)
Definition: write_spx1.f:683
double precision, dimension(:,:,:), allocatable x_s
Definition: fldvar_mod.f:78
integer jmax2
Definition: geometry_mod.f:63
double precision, dimension(:,:), allocatable t_s
Definition: fldvar_mod.f:66
double precision, dimension(:,:), allocatable x_g
Definition: fldvar_mod.f:75
logical, dimension(20) bwrite_netcdf
Definition: cdist_mod.f:10
integer root
Definition: compar_mod.f:41
Definition: exit.f:2
Definition: cdist_mod.f:2
character(len=16) run_type
Definition: run_mod.f:33
double precision, dimension(:,:), allocatable theta_m
Definition: fldvar_mod.f:149
double precision, dimension(:), allocatable v_g
Definition: fldvar_mod.f:99
subroutine gatherwritespx(VAR, array2, array1, uspxL, NEXT_REC)
Definition: write_spx1.f:555
double precision, dimension(0:dim_i) dx
Definition: geometry_mod.f:68
integer kmax2
Definition: geometry_mod.f:65
double precision, dimension(:), allocatable w_g
Definition: fldvar_mod.f:111
integer, parameter unit_spx
Definition: funits_mod.f:30
Definition: run_mod.f:13
integer nrr
Definition: rxns_mod.f:10
subroutine particles_in_cell
Definition: param_mod.f:2
integer, dimension(0:dim_m) nmax
Definition: physprop_mod.f:119
subroutine out_bin_r(IUNIT, ARRAY, IJKMAX2, NEXT_REC)
Definition: out_bin_r.f:24
logical k_epsilon
Definition: run_mod.f:97
integer mype
Definition: compar_mod.f:24
double precision, dimension(:,:), allocatable reactionrates
Definition: rxns_mod.f:7
double precision, dimension(:), allocatable p_star
Definition: fldvar_mod.f:142
logical function mfix_usingnetcdf()
double precision, dimension(:), allocatable u_g
Definition: fldvar_mod.f:87
integer nscalar
Definition: scalars_mod.f:7
integer function mfix_nf90_enddef(ncid, h_minfree, v_align, v_minfree, r_align)
double precision, dimension(:,:), allocatable rop_s
Definition: fldvar_mod.f:51
integer, dimension(:), allocatable flag
Definition: geometry_mod.f:99
logical bglobalnetcdf
Definition: cdist_mod.f:14
double precision time
Definition: run_mod.f:45
subroutine unshift_dp_array(ARRAY_1, ARRAY_2)
integer nf90_int
double precision, dimension(:), allocatable e_turb_g
Definition: fldvar_mod.f:162
subroutine convert_to_io_dp(arr_internal, arr_io, nn)
integer nf90_double
double precision, parameter zero
Definition: param1_mod.f:27
logical bfirst_netcdf_write
Definition: cdist_mod.f:12