70 CHARACTER(LEN=MAX_STRING_LEN) :: coordtransform
139 parallelenv => parallelinit()
140 outputpe = parenv % MyPE
143 IF ( firsttime )
THEN
146 #include "../config.h"
153 IF( noargs > 0 )
THEN
155 CALL getarg( i,optionstring )
156 silent = silent .OR. &
157 ( optionstring==
'-s' .OR. optionstring==
'--silent' )
158 version = version .OR. &
159 ( optionstring==
'-v' .OR. optionstring ==
'--version' )
166 IF (nthreads > 1)
THEN
168 CALL envir(
'OMP_NUM_THREADS'//char(0), threads, tlen )
170 CALL warn(
'MAIN',
'OMP_NUM_THREADS not set. Using only 1 thread.')
175 CALL mkl_set_num_threads(nthreads)
181 IF( .NOT. silent )
THEN
182 CALL info(
'MAIN',
' ')
183 CALL info(
'MAIN',
'=============================================================')
184 CALL info(
'MAIN',
'MyElmerSolver finite element software, Welcome! ')
185 CALL info(
'MAIN',
'This program is free software licensed under (L)GPL ')
186 CALL info(
'MAIN',
'Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.')
187 CALL info(
'MAIN',
'Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi ')
188 CALL info(
'MAIN',
'Library version: ' // version &
190 //
' (Rev: ' // revision //
')' )
194 IF ( parenv % PEs > 1 ) &
195 CALL info(
'MAIN',
' Running in parallel using ' // &
196 trim(i2s(parenv % PEs)) //
' tasks.')
199 IF ( nthreads > 1 ) &
200 CALL info(
'MAIN',
' Running in parallel with ' // &
201 trim(i2s(nthreads)) //
' threads per task.')
204 CALL info(
'MAIN',
' HYPRE library linked in.')
207 CALL info(
'MAIN',
' Trilinos library linked in.')
210 CALL info(
'MAIN',
' MUMPS library linked in.')
213 CALL info(
'MAIN',
' CHOLMOD library linked in.')
216 CALL info(
'MAIN',
' SUPERLU library linked in.')
219 CALL info(
'MAIN',
' PARDISO library linked in.')
222 CALL info(
'MAIN',
' Intel MKL linked in.' )
224 CALL info(
'MAIN',
'=============================================================')
229 CALL initializeelementdescriptions
231 WRITE(*,*)
"Initialize: Setting FirstTime to FALSE"
237 gotmodelname = .false.
238 IF ( parenv % PEs <= 1 .AND. noargs > 0 )
THEN
239 CALL getarg( 1,modelname )
240 IF( modelname(1:1) /=
'-')
THEN
241 gotmodelname = .true.
242 IF ( noargs > 1 ) CALL getarg( 2,eq )
246 IF( .NOT. gotmodelname )
THEN
247 OPEN( 1, file=
'ELMERSOLVER_STARTINFO', status=
'OLD', err=10 )
248 READ(1,
'(a)') modelname
255 IF ( initialize==1 )
THEN
256 CALL freemodel(currentmodel)
266 IF ( initialize==2 ) goto 1
268 IF( myverbosity > 3)
WRITE(*,*)
'FirstLoad = ', firstload
270 IF ( firstload )
THEN
271 IF( .NOT. silent )
THEN
272 CALL info(
'MAIN',
' ')
273 CALL info(
'MAIN',
' ')
274 CALL info(
'MAIN',
'-------------------------------------')
275 CALL info(
'MAIN',
'Reading Model: '//trim( modelname) )
278 INQUIRE(unit=infileunit, opened=gotit)
279 IF ( gotit )
CLOSE(infileunit)
281 IF( myverbosity > 3)
WRITE(*,*)
'ModelName = ', modelname
283 OPEN( unit=infileunit, action=
'Read',file=modelname,status=
'OLD',err=20 )
284 IF( myverbosity > 3)
WRITE(*,*)
'Before LoadModel call'
285 currentmodel => loadmodel(modelname,.false.,parenv % PEs,parenv % MyPE )
286 IF( myverbosity > 3)
WRITE(*,*)
'After LoadModel call'
290 extrudelevels=getinteger(currentmodel % Simulation,
'Extruded Mesh Levels',found)
291 IF(extrudelevels>1)
THEN
292 extrudedmesh => meshextrude(currentmodel % Meshes, extrudelevels-2)
293 DO i=1,currentmodel % NumberOfSolvers
294 IF(
ASSOCIATED(currentmodel % Solvers(i) % Mesh,currentmodel % Meshes)) &
295 currentmodel % Solvers(i) % Mesh => extrudedmesh
297 extrudedmesh % Next => currentmodel % Meshes % Next
298 currentmodel % Meshes => extrudedmesh
302 DO i = 1,currentmodel % NumberOfBCs
303 IF(
ASSOCIATED(currentmodel % Bcs(i) % PMatrix)) &
304 CALL freematrix( currentmodel % BCs(i) % PMatrix )
305 currentmodel % BCs(i) % PMatrix => null()
306 k = listgetinteger( currentmodel % BCs(i) % Values,
'Periodic BC', gotit )
308 currentmodel % BCs(i) % PMatrix => periodicprojector( currentmodel, extrudedmesh, i, k )
316 coordtransform = listgetstring(currentmodel % Simulation,
'Coordinate Transformation',gotit)
319 WRITE(*,*)
'Initialize: Coordinate Transformation is activated for Elmer.\n'
321 CALL coordinatetransformation( currentmodel % Meshes, coordtransform, &
322 currentmodel % Simulation, .true. )
328 IF(.NOT. silent )
THEN
329 CALL info(
'MAIN',
'-------------------------------------')
332 IF ( initialize==3 )
THEN
333 INQUIRE(unit=infileunit, opened=gotit)
334 IF ( gotit )
CLOSE(infileunit)
335 OPEN( unit=infileunit, action=
'Read', &
336 file=modelname,status=
'OLD',err=20 )
339 IF (myverbosity > 3)
THEN
340 WRITE(6,*)
'Initialize: CurrentModel % NumberOfNodes&
341 = ', currentmodel % NumberOfNodes
346 mesh => currentmodel % Meshes
347 DO WHILE(
ASSOCIATED(mesh) )
355 CALL listaddlogical( currentmodel % Simulation, &
356 'Initialization Phase', .true. )
361 IF( listgetlogical( currentmodel % Simulation,
'Simulation Timing',gotit) )
THEN
362 CALL listaddconstreal( currentmodel % Simulation,
'cputime0',ct0 )
363 CALL listaddconstreal( currentmodel % Simulation,
'realtime0',rt0 )
369 eq = listgetstring( currentmodel % Simulation,
'Simulation Type', gotit )
370 scanning = eq ==
'scanning'
371 transient = eq ==
'transient'
390 IF ( transient .OR. scanning )
THEN
391 timesteps => listgetintegerarray( currentmodel % Simulation, &
392 'Timestep Intervals', gotit )
394 IF ( .NOT.gotit )
THEN
395 CALL fatal(
' ',
'Keyword > Timestep Intervals < MUST be ' // &
396 'defined for transient and scanning simulations' )
398 timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
399 'Timestep Sizes', gotit )
401 IF ( .NOT.gotit )
THEN
402 IF( scanning .OR. listcheckpresent( currentmodel % Simulation,
'Timestep Size') )
THEN
403 ALLOCATE(timestepsizes(
SIZE(timesteps),1))
404 timestepsizes = 1.0_dp
406 CALL fatal(
' ',
'Keyword [Timestep Sizes] MUST be ' // &
407 'defined for time dependent simulations' )
412 timeintervals =
SIZE(timesteps)
414 coupledmaxiter = listgetinteger( currentmodel % Simulation, &
415 'Steady State Max Iterations', gotit, minv=1 )
416 IF ( .NOT. gotit ) coupledmaxiter = 1
422 ALLOCATE(timesteps(1))
424 timesteps(1) = listgetinteger( currentmodel % Simulation, &
425 'Steady State Max Iterations', gotit,minv=1 )
426 IF ( .NOT. gotit ) timesteps(1)=1
428 ALLOCATE(timestepsizes(1,1))
429 timestepsizes(1,1) = 1.0d0
436 ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
437 steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
453 coupledminiter = listgetinteger( currentmodel % Simulation, &
454 'Steady State Min Iterations', gotit )
467 outputintervals => listgetintegerarray( currentmodel % Simulation, &
468 'Output Intervals', gotit )
469 IF ( .NOT. gotit )
THEN
470 ALLOCATE( outputintervals(
SIZE(timesteps)) )
486 DO interval=1,timeintervals
487 DO timestep = 1,timesteps(interval)
488 IF( outputintervals(interval) == 0 ) cycle
490 IF ( mod(timestep-1, outputintervals(interval))==0 )
THEN
492 totaltimesteps = totaltimesteps + 1
497 DO i=1,currentmodel % NumberOfSolvers
498 solver => currentmodel % Solvers(i)
499 IF(.NOT.
ASSOCIATED(solver % Variable)) cycle
500 IF(.NOT.
ASSOCIATED(solver % Variable % Values)) cycle
501 when = listgetstring( solver % Values,
'Exec Solver', gotit )
503 IF ( when ==
'after simulation' .OR. when ==
'after all' )
THEN
507 IF ( solver % SolverExecWhen == solver_exec_after_all )
THEN
513 IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
514 IF( totaltimesteps == 0 ) totaltimesteps = 1
516 CALL listaddlogical( currentmodel % Simulation, &
517 'Initialization Phase', .false. )
520 IF (myverbosity > 3)
THEN
521 WRITE(6,*)
'MyElmerSolver 493 Initialize = ', initialize
528 IF (myverbosity > 3)
THEN
529 WRITE(6,*)
'MyRun: CurrentModel % NumberOfNodes = ', &
530 currentmodel % NumberOfNodes
536 eq = listgetstring( currentmodel % Simulation,
'Simulation Type', gotit )
537 scanning = eq ==
'scanning'
538 transient = eq ==
'transient'
546 IF (myverbosity > 3)
THEN
547 write(6,*)
'calling AddVtuOutputSolverHack'
550 IF (myverbosity > 3)
THEN
551 write(6,*)
'leaving AddVtuOutputSolverHack'
558 IF (myverbosity > 3)
THEN
559 write(6,*)
'calling AddSolvers'
562 IF (myverbosity > 3)
THEN
563 write(6,*)
'leaving AddSolvers'
569 IF ( transient .OR. scanning )
THEN
570 timesteps => listgetintegerarray( currentmodel % Simulation, &
571 'Timestep Intervals', gotit )
573 IF ( .NOT.gotit )
THEN
574 CALL fatal(
' ',
'Keyword > Timestep Intervals < MUST be ' // &
575 'defined for transient and scanning simulations' )
577 timestepsizes => listgetconstrealarray( currentmodel % Simulation, &
578 'Timestep Sizes', gotit )
580 IF ( .NOT.gotit )
THEN
581 IF( scanning .OR. listcheckpresent( currentmodel % Simulation,
'Timestep Size') )
THEN
582 ALLOCATE(timestepsizes(
SIZE(timesteps),1))
583 timestepsizes = 1.0_dp
585 CALL fatal(
' ',
'Keyword [Timestep Sizes] MUST be ' // &
586 'defined for time dependent simulations' )
591 timeintervals =
SIZE(timesteps)
593 coupledmaxiter = listgetinteger( currentmodel % Simulation, &
594 'Steady State Max Iterations', gotit, minv=1 )
595 IF ( .NOT. gotit ) coupledmaxiter = 1
601 ALLOCATE(timesteps(1))
603 timesteps(1) = listgetinteger( currentmodel % Simulation, &
604 'Steady State Max Iterations', gotit,minv=1 )
605 IF ( .NOT. gotit ) timesteps(1)=1
607 ALLOCATE(timestepsizes(1,1))
608 timestepsizes(1,1) = 1.0d0
615 ALLOCATE( stime(1), sstep(1), sinterval(1), ssize(1), &
616 steadyit(1), nonlinit(1), sprevsizes(1,5), speriodic(1) )
632 coupledminiter = listgetinteger( currentmodel % Simulation, &
633 'Steady State Min Iterations', gotit )
646 outputintervals => listgetintegerarray( currentmodel % Simulation, &
647 'Output Intervals', gotit )
649 IF ( .NOT. gotit )
THEN
650 ALLOCATE( outputintervals(
SIZE(timesteps)) )
654 IF (myverbosity > 3)
THEN
655 write(6,*)
'MyRunI SIZE(OutputIntervals) =',
SIZE(outputintervals)
656 write(6,*)
'MyRunI OutputIntervals(1) = ',outputintervals(1)
670 DO interval=1,timeintervals
671 DO timestep = 1,timesteps(interval)
672 IF( outputintervals(interval) == 0 ) cycle
674 IF ( mod(timestep-1, outputintervals(interval))==0 )
THEN
676 totaltimesteps = totaltimesteps + 1
681 DO i=1,currentmodel % NumberOfSolvers
682 solver => currentmodel % Solvers(i)
683 IF(.NOT.
ASSOCIATED(solver % Variable)) cycle
684 IF(.NOT.
ASSOCIATED(solver % Variable % Values)) cycle
685 when = listgetstring( solver % Values,
'Exec Solver', gotit )
687 IF ( when ==
'after simulation' .OR. when ==
'after all' )
THEN
691 IF ( solver % SolverExecWhen == solver_exec_after_all )
THEN
697 IF ( .NOT.lastsaved ) totaltimesteps = totaltimesteps + 1
698 IF( totaltimesteps == 0 ) totaltimesteps = 1
700 CALL listaddlogical( currentmodel % Simulation, &
701 'Initialization Phase', .false. )
704 IF (myverbosity > 3)
THEN
705 WRITE(6,*)
'MyElmerSolver 493 Initialize = ', initialize
706 write(6,*)
'TimeIntervals from inside RunI = ', timeintervals
707 WRITE(*,*)
'NumberOfSolvers = ', currentmodel % NumberOfSolvers
712 DO i=1,currentmodel % NumberOfSolvers
713 solver => currentmodel % Solvers(i)
714 IF (myverbosity > 3)
THEN
715 WRITE(*,*)
'Solver % PROCEDURE = ', solver % PROCEDURE
717 IF ( solver % PROCEDURE==0 ) cycle
718 IF ( solver % SolverExecWhen == solver_exec_ahead_all )
THEN
719 IF (myverbosity > 3)
THEN
720 WRITE(*,*)
'Calling SolverActivate for Solver', i
722 CALL solveractivate( currentmodel,solver,dt,transient )
731 CALL fatal(
'MyElmerSolver',
'Unable to find ELMERSOLVER_STARTINFO, can not execute.' )
734 CALL fatal(
'MyElmerSolver',
'Unable to find input file [' // &
735 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