drive1.f 9.41 KB
Newer Older
1
c-----------------------------------------------------------------------
2
      subroutine nek_init(comm)
ggiannako's avatar
dummy    
ggiannako committed
3
c
4
5
6
7
8
9
10
      include 'SIZE'
      include 'TOTAL'
      include 'DOMAIN'
c
      include 'OPCTR'
      include 'CTIMER'

11
C     used scratch arrays
12
C     NOTE: no initial declaration needed. Linker will take 
stefanke's avatar
stefanke committed
13
c           care about the size of the CBs automatically
14
15
16
17
18
19
20
21
22
23
24
25
c
c      COMMON /CTMP1/ DUMMY1(LCTMP1)
c      COMMON /CTMP0/ DUMMY0(LCTMP0)
c
c      COMMON /SCRNS/ DUMMY2(LX1,LY1,LZ1,LELT,7)
c      COMMON /SCRUZ/ DUMMY3(LX1,LY1,LZ1,LELT,4)
c      COMMON /SCREV/ DUMMY4(LX1,LY1,LZ1,LELT,2)
c      COMMON /SCRVH/ DUMMY5(LX1,LY1,LZ1,LELT,2)
c      COMMON /SCRMG/ DUMMY6(LX1,LY1,LZ1,LELT,4)
c      COMMON /SCRCH/ DUMMY7(LX1,LY1,LZ1,LELT,2)
c      COMMON /SCRSF/ DUMMY8(LX1,LY1,LZ1,LELT,3)
c      COMMON /SCRCG/ DUMM10(LX1,LY1,LZ1,LELT,1)
26

27
      integer comm
28
      common /nekmpi/ mid,mp,nekcomm,nekgroup,nekreal
29
  
ggiannako's avatar
ggiannako committed
30
31
      common /rdump/ ntdump

32
      real kwave2
33
      logical ifemati
peet's avatar
peet committed
34

Stefan's avatar
Stefan committed
35
36
37
38
39
40
      real rtest
      integer itest
      integer*8 itest8
      character ctest
      logical ltest 

41
42
43
44
45
      common /c_is1/ glo_num(lx1 * ly1 * lz1, lelt)
      common /ivrtx/ vertex((2 ** ldim) * lelt)
      integer*8 glo_num, ngv
      integer vertex

46
      ! set word size for REAL
Stefan's avatar
Stefan committed
47
      wdsize = sizeof(rtest)
48
      ! set word size for INTEGER
Stefan's avatar
Stefan committed
49
50
51
      isize = sizeof(itest)
      ! set word size for INTEGER*8
      isize8 = sizeof(itest8) 
52
      ! set word size for LOGICAL
Stefan's avatar
Stefan committed
53
      lsize = sizeof(ltest) 
54
      ! set word size for CHARACTER
Stefan's avatar
Stefan committed
55
      csize = sizeof(ctest)
56

57
58
59
60
      call setupcomm(comm,newcomm,newcommg,'','')
      intracomm   = newcomm   ! within a session
      nekcomm     = newcomm
      iglobalcomm = newcommg  ! across all sessions
61
      call iniproc()
62

Stefan's avatar
Stefan committed
63
64
      if (nid.eq.nio) call printHeader

65
      etimes = dnekclock()
stefanke's avatar
stefanke committed
66
      istep  = 0
67
68
69

      call opcount(1)

70
      call initdim         ! Initialize / set default values.
71
72
73
      call initdat
      call files

74
      call readat          ! Read .rea +map file
75

76
      call setvar          ! Initialize most variables
77

78
      instep=1             ! Check for zero steps
79
80
81
      if (nsteps.eq.0 .and. fintim.eq.0.) instep=0

      igeom = 2
82
      call setup_topo      ! Setup domain topology  
83

84
      call genwz           ! Compute GLL points, weights, etc.
85

heisey's avatar
heisey committed
86
      if(nio.eq.0) write(6,*) 'call usrdat'
87
      call usrdat
heisey's avatar
heisey committed
88
      if(nio.eq.0) write(6,'(A,/)') ' done :: usrdat' 
89

90
      call gengeom(igeom)  ! Generate geometry, after usrdat 
91

92
      if (ifmvbd) call setup_mesh_dssum ! Set mesh dssum (needs geom)
93

heisey's avatar
heisey committed
94
      if(nio.eq.0) write(6,*) 'call usrdat2'
95
      call usrdat2
heisey's avatar
heisey committed
96
      if(nio.eq.0) write(6,'(A,/)') ' done :: usrdat2' 
97

Stefan K's avatar
Stefan K committed
98
      call fix_geom
99
      call geom_reset(1)    ! recompute Jacobians, etc.
Stefan K's avatar
Stefan K committed
100

stefanke's avatar
stefanke committed
101
      call vrdsmsh          ! verify mesh topology
Stefan's avatar
Stefan committed
102
      call mesh_metrics     ! print some metrics
103

104
      call setlog  ! Initalize logical flags
105

Stefan K's avatar
Stefan K committed
106
107
      if (ifneknekc) call neknek_setup

108
      call bcmask  ! Set BC masks for Dirichlet boundaries.
109

Stefan K's avatar
Stefan K committed
110
      if (fintim.ne.0.0 .or. nsteps.ne.0) 
111
     $   call geneig(igeom) ! eigvals for tolerances
112

Stefan's avatar
Stefan committed
113
      call dg_setup ! Setup DG, if dg flag is set.
114

Stefan's avatar
Stefan committed
115
      if (ifflow.and.iftran) then ! Init pressure solver 
Stefan K's avatar
Stefan K committed
116
         if (fintim.ne.0 .or. nsteps.ne.0) call prinit
117
118
      endif

Stefan's avatar
Stefan committed
119
      if(ifcvode) call cv_setsize
stefanke's avatar
   
stefanke committed
120

heisey's avatar
heisey committed
121
      if(nio.eq.0) write(6,*) 'call usrdat3'
122
      call usrdat3
heisey's avatar
heisey committed
123
      if(nio.eq.0) write(6,'(A,/)') ' done :: usrdat3'
124

125
#ifdef CMTNEK
126
        call nek_cmt_init
127
#endif
128

129
130
      call setics
      call setprop
131

132
      if (instep.ne.0) then
Stefan K's avatar
Stefan K committed
133
134
         if (ifneknekc) call neknek_exchange
         if (ifneknekc) call chk_outflow
135
136

         if (nio.eq.0) write(6,*) 'call userchk'
137
         call userchk
138
         if(nio.eq.0) write(6,'(A,/)') ' done :: userchk' 
139
      endif
140

Stefan K's avatar
Stefan K committed
141
      call setprop      ! call again because input has changed in userchk
142

Stefan's avatar
Stefan committed
143
      if (ifcvode .and. nsteps.gt.0) call cv_init
stefanke's avatar
   
stefanke committed
144

fischer's avatar
fischer committed
145
146
      call comment
      call sstest (isss) 
147

fischer's avatar
fischer committed
148
      call dofcnt
149

Stefan K's avatar
Stefan K committed
150
151
      jp = 0  ! Set perturbation field count to 0 for baseline flow
      p0thn = p0th
152

153
154
      call in_situ_init()

155
      call time00       !     Initalize timers to ZERO
stefanke's avatar
   
stefanke committed
156
      call opcount(2)
stefanke's avatar
stefanke committed
157

ggiannako's avatar
ggiannako committed
158
159
160
      ntdump=0
      if (timeio.ne.0.0) ntdump = int( time/timeio )

161
      tinit = dnekclock_sync() - etimes
162
163
164
165
      if (nio.eq.0) then
        write (6,*) ' '
        if (time.ne.0.0) write (6,'(a,e14.7)') ' Initial time:',time
        write (6,'(a,g13.5,a)') 
Stefan's avatar
Stefan committed
166
     &     ' Initialization successfully completed ', tinit, ' sec'
167
      endif
168

169
170
      return
      end
171
c-----------------------------------------------------------------------
stefanke's avatar
stefanke committed
172
      subroutine nek_solve
173

174
175
      include 'SIZE'
      include 'TSTEP'
176
      include 'INPUT'
stefanke's avatar
stefanke committed
177
      include 'CTIMER'
178

179
      call nekgsync()
stefanke's avatar
stefanke committed
180

stefanke's avatar
   
stefanke committed
181
182
183
184
185
      if (instep.eq.0) then
        if(nid.eq.0) write(6,'(/,A,/,A,/)') 
     &     ' nsteps=0 -> skip time loop',
     &     ' running solver in post processing mode'
      else
heisey's avatar
heisey committed
186
        if(nio.eq.0) write(6,'(/,A,/)') 'Starting time loop ...'
stefanke's avatar
   
stefanke committed
187
188
      endif

stefanke's avatar
stefanke committed
189
190
      isyc  = 0
      if(ifsync) isyc=1
Stefan's avatar
Stefan committed
191
192
      itime = 0
#ifdef TIMER
stefanke's avatar
stefanke committed
193
      itime = 1
Stefan's avatar
Stefan committed
194
#endif
195
196
197

      ! start measurements
      dtmp = dnekgflops()
stefanke's avatar
stefanke committed
198

199
      istep  = 0
200
      msteps = 1
201

202
203
      do kstep=1,nsteps,msteps
         call nek__multi_advance(kstep,msteps)
Stefan K's avatar
Stefan K committed
204
         if(kstep.ge.nsteps) lastep = 1
ggiannako's avatar
ggiannako committed
205
206
         call check_ioinfo  
         call set_outfld
207
         etime1 = dnekclock()
208
         call userchk
209
         tuchk = tuchk + dnekclock()-etime1
ggiannako's avatar
ggiannako committed
210
         call prepost (ifoutfld,'his')
211
         call in_situ_check()
Stefan's avatar
Stefan committed
212
         if (mod(kstep,100).eq.0 ..and. lastep.eq.0) call runstat
213
         if (lastep .eq. 1) goto 1001
214
      enddo
stefanke's avatar
   
stefanke committed
215
216
217
218
219
220
221
 1001 lastep=1

      call comment

c     check for post-processing mode
      if (instep.eq.0) then
         nsteps=0
stefanke's avatar
stefanke committed
222
         istep=0
heisey's avatar
heisey committed
223
         if(nio.eq.0) write(6,*) 'call userchk'
stefanke's avatar
   
stefanke committed
224
         call userchk
heisey's avatar
heisey committed
225
         if(nio.eq.0) write(6,*) 'done :: userchk'
stefanke's avatar
   
stefanke committed
226
227
         call prepost (.true.,'his')
      else
heisey's avatar
heisey committed
228
         if (nio.eq.0) write(6,'(/,A,/)') 
stefanke's avatar
   
stefanke committed
229
230
     $      'end of time-step loop' 
      endif
231

232

233
234
      RETURN
      END
Stefan's avatar
Stefan committed
235

236
c-----------------------------------------------------------------------
stefanke's avatar
stefanke committed
237
      subroutine nek_advance
238

239
240
241
      include 'SIZE'
      include 'TOTAL'
      include 'CTIMER'
242

fischer's avatar
fischer committed
243
244
      common /cgeom/ igeom

Stefan K's avatar
Stefan K committed
245
      ntot = lx1*ly1*lz1*nelv
246

247
      call nekgsync
248
249
250

      call setup_convect(2) ! Save conv vel

251
      if (iftran) call settime
252
      if (ifmhd ) call cfl_check
253
254
255
      call setsolv
      call comment

256
257
258
259
#ifdef CMTNEK
      if (nio.eq.0.and.istep.le.1) write(6,*) 'CMT branch active'
      call cmt_nek_advance
      return
260
#endif
stefanke's avatar
   
stefanke committed
261

262
      if (ifsplit) then   ! PN/PN formulation
263

oanam's avatar
oanam committed
264
265
         do igeom=1,ngeom

k10's avatar
k10 committed
266
         if (ifneknekc .and. igeom.gt.2) then
Stefan K's avatar
Stefan K committed
267
            if (ifneknekm.and.igeom.eq.3) call neknek_setup
k10's avatar
k10 committed
268
269
            call neknek_exchange
         endif
k10's avatar
k10 committed
270

Stefan's avatar
Stefan committed
271
         ! call here before we overwrite wx 
Stefan's avatar
Stefan committed
272
         if (ifheat .and. ifcvode) call heat_cvode (igeom)   
273

oanam's avatar
oanam committed
274
         if (ifgeom) then
Stefan K's avatar
Stefan K committed
275
276
            call gengeom (igeom)
            call geneig  (igeom)
oanam's avatar
oanam committed
277
278
         endif

Stefan K's avatar
Stefan K committed
279
         if (ifheat) call heat (igeom)
280
281

         if (igeom.eq.2) then  
Stefan K's avatar
Stefan K committed
282
283
284
            call setprop
            call rzero(qtl,ntot)
            if (iflomach) call qthermal
285
286
         endif

Stefan K's avatar
Stefan K committed
287
288
         if (ifflow)          call fluid    (igeom)
         if (ifmvbd)          call meshv    (igeom)
Stefan K's avatar
Stefan K committed
289
         if (igeom.eq.ngeom.and.filterType.eq.1)
290
291
     $                        call q_filter(param(103))

oanam's avatar
oanam committed
292
         enddo
fischer's avatar
fischer committed
293

294
295
      else                ! PN-2/PN-2 formulation
         call setprop
peet's avatar
peet committed
296
297
         do igeom=1,ngeom

k10's avatar
k10 committed
298
            if (ifneknekc .and. igeom.gt.2) then
Stefan K's avatar
Stefan K committed
299
              if (ifneknekm.and.igeom.eq.3) call neknek_setup
k10's avatar
k10 committed
300
301
              call neknek_exchange
            endif
fischer's avatar
fischer committed
302

Stefan's avatar
Stefan committed
303
304
305
            ! call here before we overwrite wx 
            if (ifheat .and. ifcvode) call heat_cvode (igeom)   

306
            if (ifgeom) then
Kento Kaneko's avatar
Kento Kaneko committed
307
               if (.not.ifrich) call gengeom (igeom)
308
309
               call geneig  (igeom)
            endif
fischer's avatar
fischer committed
310

311
            if (ifmhd) then
obabko's avatar
obabko committed
312
               if (ifheat)      call heat     (igeom)
obabko's avatar
obabko committed
313
                                call induct   (igeom)
314
            elseif (ifpert) then
fischer's avatar
fischer committed
315
316
317
318
               if (ifbase.and.ifheat)  call heat          (igeom)
               if (ifbase.and.ifflow)  call fluid         (igeom)
               if (ifflow)             call fluidp        (igeom)
               if (ifheat)             call heatp         (igeom)
319
            else  ! std. nek case
fischer's avatar
fischer committed
320
321
322
               if (ifheat)             call heat          (igeom)
               if (ifflow)             call fluid         (igeom)
               if (ifmvbd)             call meshv         (igeom)
323
            endif
Stefan K's avatar
Stefan K committed
324
            if (igeom.eq.ngeom.and.filterType.eq.1)
Kento Kaneko's avatar
Kento Kaneko committed
325
     $         call q_filter(param(103))
326
327
         enddo
      endif
fischer's avatar
fischer committed
328

329
330
      return
      end
Stefan's avatar
Stefan committed
331

332
c-----------------------------------------------------------------------
stefanke's avatar
stefanke committed
333
      subroutine nek_end
334
335

      include 'SIZE'
Stefan's avatar
Stefan committed
336
      include 'TOTAL'
337

Stefan's avatar
Stefan committed
338
339
      if(instep.ne.0) call runstat

Stefan's avatar
Stefan committed
340
341
342
343
344
c      if (ifstrs) then
c         call fgslib_crs_free(xxth_strs) 
c      else
c         call fgslib_crs_free(xxth(1))
c      endif
obabko's avatar
obabko committed
345

346
      call in_situ_end()
stgeke's avatar
stgeke committed
347
348
      call exitt0()

349
350
      return
      end
351
c-----------------------------------------------------------------------
352
353
354
355
356
357
358
359
      subroutine nek__multi_advance(kstep,msteps)

      include 'SIZE'
      include 'TOTAL'

      do i=1,msteps
         istep = istep+i
         call nek_advance
fischer's avatar
fischer committed
360

k10's avatar
k10 committed
361
362
363
364
365
         if (ifneknekc) then 
            call neknek_exchange
            call bcopy
            call chk_outflow
         endif
366
367
368
369
370
      enddo

      return
      end
c-----------------------------------------------------------------------