72 CHARACTER(LEN=MAX_STRING_LEN) :: coordtransform
143 elmermodulecomm = comm
144 parallelenv => parallelinit()
145 outputpe = parenv % MyPE
148 IF ( firsttime )
THEN
151 #include "../config.h"
158 IF( noargs > 0 )
THEN
160 CALL getarg( i,optionstring )
161 silent = silent .OR. &
162 ( optionstring==
'-s' .OR. optionstring==
'--silent' )
163 version = version .OR. &
164 ( optionstring==
'-v' .OR. optionstring ==
'--version' )
171 IF (nthreads > 1)
THEN
173 CALL envir(
'OMP_NUM_THREADS'//char(0), threads, tlen )
175 CALL warn(
'MAIN',
'OMP_NUM_THREADS not set. Using only 1 thread.')
180 CALL mkl_set_num_threads(nthreads)
186 IF( .NOT. silent )
THEN
187 CALL info(
'MAIN',
' ')
188 CALL info(
'MAIN',
'=============================================================')
189 CALL info(
'MAIN',
'MyElmerSolver finite element software, Welcome! ')
190 CALL info(
'MAIN',
'This program is free software licensed under (L)GPL ')
191 CALL info(
'MAIN',
'Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.')
192 CALL info(
'MAIN',
'Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi ')
193 CALL info(
'MAIN',
'Library version: ' // version &
195 //
' (Rev: ' // revision //
')' )
199 IF ( parenv % PEs > 1 ) &
200 CALL info(
'MAIN',
' Running in parallel using ' // &
201 trim(i2s(parenv % PEs)) //
' tasks.')
204 IF ( nthreads > 1 ) &
205 CALL info(
'MAIN',
' Running in parallel with ' // &
206 trim(i2s(nthreads)) //
' threads per task.')
209 CALL info(
'MAIN',
' HYPRE library linked in.')
212 CALL info(
'MAIN',
' Trilinos library linked in.')
215 CALL info(
'MAIN',
' MUMPS library linked in.')
218 CALL info(
'MAIN',
' CHOLMOD library linked in.')
221 CALL info(
'MAIN',
' SUPERLU library linked in.')
224 CALL info(
'MAIN',
' PARDISO library linked in.')
227 CALL info(
'MAIN',
' Intel MKL linked in.' )
229 CALL info(
'MAIN',
'=============================================================')
234 CALL initializeelementdescriptions
236 WRITE(*,*)
"Initialize: Setting FirstTime to FALSE"
242 gotmodelname = .false.
243 IF ( parenv % PEs <= 1 .AND. noargs > 0 )
THEN
244 CALL getarg( 1,modelname )
245 IF( modelname(1:1) /=
'-')
THEN
246 gotmodelname = .true.
247 IF ( noargs > 1 ) CALL getarg( 2,eq )
251 IF( .NOT. gotmodelname )
THEN
252 OPEN( 1, file=
'ELMERSOLVER_STARTINFO', status=
'OLD', err=10 )
253 READ(1,
'(a)') modelname
260 IF ( initialize==1 )
THEN
261 CALL freemodel(currentmodel)
271 IF ( initialize==2 ) goto 1
273 IF( myverbosity > 3)
WRITE(*,*)
'FirstLoad = ', firstload
275 IF ( firstload )
THEN
276 IF( .NOT. silent )
THEN
277 CALL info(
'MAIN',
' ')
278 CALL info(
'MAIN',
' ')
279 CALL info(
'MAIN',
'-------------------------------------')
280 CALL info(
'MAIN',
'Reading Model: '//trim( modelname) )
283 INQUIRE(unit=infileunit, opened=gotit)
284 IF ( gotit )
CLOSE(infileunit)
286 IF( myverbosity > 3)
WRITE(*,*)
'ModelName = ', modelname
288 OPEN( unit=infileunit, action=
'Read',file=modelname,status=
'OLD',err=20 )
289 IF( myverbosity > 3)
WRITE(*,*)
'Before LoadModel call'
290 currentmodel => loadmodel(modelname,.false.,parenv % PEs,parenv % MyPE )
291 IF( myverbosity > 3)
WRITE(*,*)
'After LoadModel call'
295 extrudelevels=getinteger(currentmodel % Simulation,
'Extruded Mesh Levels',found)
296 IF(extrudelevels>1)
THEN
297 extrudedmesh => meshextrude(currentmodel % Meshes, extrudelevels-2)
298 DO i=1,currentmodel % NumberOfSolvers
299 IF(
ASSOCIATED(currentmodel % Solvers(i) % Mesh,currentmodel % Meshes)) &
300 currentmodel % Solvers(i) % Mesh => extrudedmesh
302 extrudedmesh % Next => currentmodel % Meshes % Next
303 currentmodel % Meshes => extrudedmesh
307 DO i = 1,currentmodel % NumberOfBCs
308 IF(
ASSOCIATED(currentmodel % Bcs(i) % PMatrix)) &
309 CALL freematrix( currentmodel % BCs(i) % PMatrix )
310 currentmodel % BCs(i) % PMatrix => null()
311 k = listgetinteger( currentmodel % BCs(i) % Values,
'Periodic BC', gotit )
313 currentmodel % BCs(i) % PMatrix => periodicprojector( currentmodel, extrudedmesh, i, k )
321 coordtransform = listgetstring(currentmodel % Simulation,
'Coordinate Transformation',gotit)
324 WRITE(*,*)
'Initialize: Coordinate Transformation is activated for Elmer.\n'
326 CALL coordinatetransformation( currentmodel % Meshes, coordtransform, &
327 currentmodel % Simulation, .true. )
333 IF(.NOT. silent )
THEN
334 CALL info(
'MAIN',
'-------------------------------------')
337 IF ( initialize==3 )
THEN
338 INQUIRE(unit=infileunit, opened=gotit)
339 IF ( gotit )
CLOSE(infileunit)
340 OPEN( unit=infileunit, action=
'Read', &
341 file=modelname,status=
'OLD',err=20 )
344 IF (myverbosity > 3)
THEN
345 WRITE(6,*)
'Initialize: CurrentModel % NumberOfNodes&
346 = ', currentmodel % NumberOfNodes
351 mesh => currentmodel % Meshes
352 DO WHILE(
ASSOCIATED(mesh) )
360 CALL listaddlogical( currentmodel % Simulation, &
361 'Initialization Phase', .true. )
366 IF( listgetlogical( currentmodel % Simulation,
'Simulation Timing',gotit) )
THEN
367 CALL listaddconstreal( currentmodel % Simulation,
'cputime0',ct0 )
368 CALL listaddconstreal( currentmodel % Simulation,
'realtime0',rt0 )
374 eq = listgetstring( currentmodel % Simulation,
'Simulation Type', gotit )
375 scanning = eq ==
'scanning'
376 transient = eq ==
'transient'
395 IF ( transient .OR. scanning )
THEN
396 timesteps => listgetintegerarray( currentmodel % Simulation, &
397 'Timestep Intervals', gotit )
399 IF ( .NOT.gotit )
THEN
400 CALL fatal(
' ',
'Keyword > Timestep Intervals < MUST be ' // &
401 'defined for transient and scanning simulations' )
403 timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
404 'Timestep Sizes', gotit )
406 IF ( .NOT.gotit )
THEN
407 IF( scanning .OR. listcheckpresent( currentmodel % Simulation,
'Timestep Size') )
THEN
408 ALLOCATE(timestepsizes(
SIZE(timesteps),1))
409 timestepsizes = 1.0_dp
411 CALL fatal(
' ',
'Keyword [Timestep Sizes] MUST be ' // &
412 'defined for time dependent simulations' )
417 timeintervals =
SIZE(timesteps)
419 coupledmaxiter = listgetinteger( currentmodel % Simulation, &
420 'Steady State Max Iterations', gotit, minv=1 )
421 IF ( .NOT. gotit ) coupledmaxiter = 1
427 ALLOCATE(timesteps(1))
429 timesteps(1) = listgetinteger( currentmodel % Simulation, &
430 'Steady State Max Iterations', gotit,minv=1 )
431 IF ( .NOT. gotit ) timesteps(1)=1
433 ALLOCATE(timestepsizes(1,1))
434 timestepsizes(1,1) = 1.0d0
441 ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
442 steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
458 coupledminiter = listgetinteger( currentmodel % Simulation, &
459 'Steady State Min Iterations', gotit )
472 outputintervals => listgetintegerarray( currentmodel % Simulation, &
473 'Output Intervals', gotit )
474 IF ( .NOT. gotit )
THEN
475 ALLOCATE( outputintervals(
SIZE(timesteps)) )
491 DO interval=1,timeintervals
492 DO timestep = 1,timesteps(interval)
493 IF( outputintervals(interval) == 0 ) cycle
495 IF ( mod(timestep-1, outputintervals(interval))==0 )
THEN
497 totaltimesteps = totaltimesteps + 1
502 DO i=1,currentmodel % NumberOfSolvers
503 solver => currentmodel % Solvers(i)
504 IF(.NOT.
ASSOCIATED(solver % Variable)) cycle
505 IF(.NOT.
ASSOCIATED(solver % Variable % Values)) cycle
506 when = listgetstring( solver % Values,
'Exec Solver', gotit )
508 IF ( when ==
'after simulation' .OR. when ==
'after all' )
THEN
512 IF ( solver % SolverExecWhen == solver_exec_after_all )
THEN
518 IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
519 IF( totaltimesteps == 0 ) totaltimesteps = 1
521 CALL listaddlogical( currentmodel % Simulation, &
522 'Initialization Phase', .false. )
525 IF (myverbosity > 3)
THEN
526 WRITE(6,*)
'MyElmerSolver 493 Initialize = ', initialize
533 IF (myverbosity > 3)
THEN
534 WRITE(6,*)
'MyRun: CurrentModel % NumberOfNodes = ', &
535 currentmodel % NumberOfNodes
541 eq = listgetstring( currentmodel % Simulation,
'Simulation Type', gotit )
542 scanning = eq ==
'scanning'
543 transient = eq ==
'transient'
551 IF (myverbosity > 3)
THEN
552 write(6,*)
'calling AddVtuOutputSolverHack'
555 IF (myverbosity > 3)
THEN
556 write(6,*)
'leaving AddVtuOutputSolverHack'
563 IF (myverbosity > 3)
THEN
564 write(6,*)
'calling AddSolvers'
567 IF (myverbosity > 3)
THEN
568 write(6,*)
'leaving AddSolvers'
574 IF ( transient .OR. scanning )
THEN
575 timesteps => listgetintegerarray( currentmodel % Simulation, &
576 'Timestep Intervals', gotit )
578 IF ( .NOT.gotit )
THEN
579 CALL fatal(
' ',
'Keyword > Timestep Intervals < MUST be ' // &
580 'defined for transient and scanning simulations' )
582 timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
583 'Timestep Sizes', gotit )
585 IF ( .NOT.gotit )
THEN
586 IF( scanning .OR. listcheckpresent( currentmodel % Simulation,
'Timestep Size') )
THEN
587 ALLOCATE(timestepsizes(
SIZE(timesteps),1))
588 timestepsizes = 1.0_dp
590 CALL fatal(
' ',
'Keyword [Timestep Sizes] MUST be ' // &
591 'defined for time dependent simulations' )
596 timeintervals =
SIZE(timesteps)
598 coupledmaxiter = listgetinteger( currentmodel % Simulation, &
599 'Steady State Max Iterations', gotit, minv=1 )
600 IF ( .NOT. gotit ) coupledmaxiter = 1
606 ALLOCATE(timesteps(1))
608 timesteps(1) = listgetinteger( currentmodel % Simulation, &
609 'Steady State Max Iterations', gotit,minv=1 )
610 IF ( .NOT. gotit ) timesteps(1)=1
612 ALLOCATE(timestepsizes(1,1))
613 timestepsizes(1,1) = 1.0d0
620 ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
621 steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
637 coupledminiter = listgetinteger( currentmodel % Simulation, &
638 'Steady State Min Iterations', gotit )
651 outputintervals => listgetintegerarray( currentmodel % Simulation, &
652 'Output Intervals', gotit )
654 IF ( .NOT. gotit )
THEN
655 ALLOCATE( outputintervals(
SIZE(timesteps)) )
659 IF (myverbosity > 3)
THEN
660 write(6,*)
'MyRunI SIZE(OutputIntervals) =',
SIZE(outputintervals)
661 write(6,*)
'MyRunI OutputIntervals(1) = ',outputintervals(1)
675 DO interval=1,timeintervals
676 DO timestep = 1,timesteps(interval)
677 IF( outputintervals(interval) == 0 ) cycle
679 IF ( mod(timestep-1, outputintervals(interval))==0 )
THEN
681 totaltimesteps = totaltimesteps + 1
686 DO i=1,currentmodel % NumberOfSolvers
687 solver => currentmodel % Solvers(i)
688 IF(.NOT.
ASSOCIATED(solver % Variable)) cycle
689 IF(.NOT.
ASSOCIATED(solver % Variable % Values)) cycle
690 when = listgetstring( solver % Values,
'Exec Solver', gotit )
692 IF ( when ==
'after simulation' .OR. when ==
'after all' )
THEN
696 IF ( solver % SolverExecWhen == solver_exec_after_all )
THEN
702 IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
703 IF( totaltimesteps == 0 ) totaltimesteps = 1
705 CALL listaddlogical( currentmodel % Simulation, &
706 'Initialization Phase', .false. )
709 IF (myverbosity > 3)
THEN
710 WRITE(6,*)
'MyElmerSolver 493 Initialize = ', initialize
711 write(6,*)
'TimeIntervals from inside RunI = ', timeintervals
712 WRITE(*,*)
'NumberOfSolvers = ', currentmodel % NumberOfSolvers
717 DO i=1,currentmodel % NumberOfSolvers
718 solver => currentmodel % Solvers(i)
719 IF (myverbosity > 3)
THEN
720 WRITE(*,*)
'Solver % PROCEDURE = ', solver % PROCEDURE
722 IF ( solver % PROCEDURE==0 ) cycle
723 IF ( solver % SolverExecWhen == solver_exec_ahead_all )
THEN
724 IF (myverbosity > 3)
THEN
725 WRITE(*,*)
'Calling SolverActivate for Solver', i
727 CALL solveractivate( currentmodel,solver,dt,transient )
736 CALL fatal(
'MyElmerSolver',
'Unable to find ELMERSOLVER_STARTINFO, can not execute.' )
739 CALL fatal(
'MyElmerSolver',
'Unable to find input file [' // &
740 trim(modelname) //
'], can not execute.' )
subroutine setinitialconditions()
Sets initial conditions for the fields.
subroutine addvtuoutputsolverhack()
subroutine addsolvers()
Adds flags for active solvers.
subroutine addmeshcoordinatesandtime()
Adds coordinate and time variables to the current mesh structure.
subroutine elmerinitialize(runs)
ElmerLib Elmer library routines
ElmerLib Elmer library routines