27 integer frame_get_master
31 mntr_frame_tmini = dnekclock()
40 do il = 1, mntr_id_max
42 mntr_mod_name(il) = mntr_blname
46 do il = 1, mntr_tmr_id_size
47 mntr_tmr_id(il,1) = -1
48 mntr_tmrv_timer(il,1) = 0.0
50 do il = 1, mntr_tmr_id_max
51 mntr_tmr_sum(il) = .false.
52 mntr_tmr_name(il) = mntr_blname
56 mntr_pid0 = frame_get_master()
60 mntr_mod_id(mntr_frame_id) = 0
61 mntr_mod_name(mntr_frame_id) = mntr_frame_name
62 mntr_mod_dscr(mntr_frame_id) =
'Framework backbone'
63 mntr_mod_num = mntr_mod_num + 1
64 mntr_mod_mpos = mntr_mod_mpos + 1
68 mntr_mod_id(mntr_id) = mntr_frame_id
69 mntr_mod_name(mntr_id) = mntr_name
70 mntr_mod_dscr(mntr_id) =
'Monitoring module'
71 mntr_mod_num = mntr_mod_num + 1
72 mntr_mod_mpos = mntr_mod_mpos + 1
78 lstring =
'Registered module ['//trim(mntr_mod_name(mntr_frame_id))
79 lstring= trim(lstring)//
']: '//trim(mntr_mod_dscr(mntr_frame_id))
80 call mntr_log(mntr_id,lp_inf,trim(lstring))
82 lstring =
'Registered module ['//trim(mntr_mod_name(mntr_id))
83 lstring= trim(lstring)//
']: '//trim(mntr_mod_dscr(mntr_id))
84 call mntr_log(mntr_id,lp_inf,trim(lstring))
88 $
'FRM_TOT',
'Total elapsed framework time',.false.)
90 write(str,
'(I2)') mntr_lp_def
92 $
'Initial log threshold set to: '//trim(str))
113 call rprm_sec_reg(mntr_sec_id,mntr_id,
'_'//adjustl(mntr_name),
114 $
'Runtime parameter section for monitor module')
118 call rprm_rp_reg(mntr_lp_def_id,mntr_sec_id,
'LOGLEVEL',
119 $
'Logging threshold for toolboxes',rpar_int,mntr_lp_def,
122 call rprm_rp_reg(mntr_iftdsc_id,mntr_sec_id,
'IFTIMDSCR',
123 $
'Write timer description in the summary',rpar_log,0,
126 call rprm_rp_reg(mntr_wtime_id,mntr_sec_id,
'WALLTIME',
127 $
'Simulation wall time',rpar_str,0,0.0,.false.,
'00:00')
142 integer ierr, nhour, nmin
149 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,mntr_lp_def_id,rpar_int)
152 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,mntr_iftdsc_id,rpar_log)
155 write(str,
'(I2)') mntr_lp_def
157 $
'Reseting log threshold to: '//trim(str))
159 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,mntr_wtime_id,rpar_str)
163 ctmp = trim(adjustl(mntr_wtimes))
166 if (ctmp(3:3).ne.
':') ierr = 1
167 if (.not.(lge(ctmp(1:1),
'0').and.lle(ctmp(1:1),
'9'))) ierr = 1
168 if (.not.(lge(ctmp(2:2),
'0').and.lle(ctmp(2:2),
'9'))) ierr = 1
169 if (.not.(lge(ctmp(4:4),
'0').and.lle(ctmp(4:4),
'9'))) ierr = 1
170 if (.not.(lge(ctmp(5:5),
'0').and.lle(ctmp(5:5),
'9'))) ierr = 1
173 read(ctmp(1:2),
'(I2)') nhour
174 read(ctmp(4:5),
'(I2)') nmin
175 mntr_wtime = 60.0*(nmin +60*nhour)
177 call mntr_log(mntr_id,lp_inf,
'Wrong wall time format')
207 lstdl = 2*mntr_stdl+1
210 if (mntr_wtime.gt.0.0)
then
214 mntr_wtstep(il) = mntr_wtstep(il-1)
220 if (istep.gt.lstdl)
then
222 if (nid.eq.mntr_pid0) rtmp = 2.0*mntr_wtstep(1) -
228 if (rtmp.gt.mntr_wtime.and.(nsteps-istep).gt.lstdl)
then
230 $
'Wall clock reached; adjust NSTEPS')
237 if (mntr_ifconv.and.(nsteps-istep).gt.lstdl)
then
239 $
'Simulation converged; adjust NSTEPS')
245 if (istep.ge.nsteps) lastep=1
264 if (dstep.gt.mntr_stdl_max)
then
265 call mntr_abort(mntr_id,
"Step delay exceeds mntr_stdl_max")
267 mntr_stdl = max(mntr_stdl,dstep)
355 character*(*) mname, mdscr
365 slena = len_trim(adjustl(mname))
367 slen = len_trim(mname) - slena + 1
368 if (slena.gt.mntr_lstl_mnm)
then
370 $
'too long module name; shortenning')
371 slena = min(slena,mntr_lstl_mnm)
373 call blank(lname,mntr_lstl_mnm)
374 lname= mname(slen:slen+slena- 1)
375 call capit(lname,slena)
378 slena = len_trim(adjustl(mdscr))
380 slen = len_trim(mdscr) - slena + 1
381 if (slena.ge.mntr_lstl_mds)
then
383 $
'too long module description; shortenning')
384 slena = min(slena,mntr_lstl_mnm)
386 call blank(ldscr,mntr_lstl_mds)
387 ldscr= mdscr(slen:slen + slena - 1)
393 if (nid.eq.mntr_pid0)
then
396 do il=1,mntr_mod_mpos
397 if (mntr_mod_id(il).ge.0.and.
398 $ mntr_mod_name(il).eq.lname)
then
407 if (mntr_mod_id(il).eq.-1)
then
416 call bcast(ipos,isize)
422 $
'module ['//trim(lname)//
'] cannot be registered')
424 elseif (ipos.lt.0)
then
427 $
'Module ['//trim(lname)//
'] is already registered')
433 if (mntr_mod_id(pmid).ge.0)
then
434 mntr_mod_id(ipos) = pmid
436 mntr_mod_id(ipos) = 0
438 $
"Module's ["//trim(lname)//
"] parent not registered.")
441 mntr_mod_id(ipos) = 0
443 mntr_mod_name(ipos)=lname
444 mntr_mod_dscr(ipos)=ldscr
445 mntr_mod_num = mntr_mod_num + 1
446 if (mntr_mod_mpos.lt.ipos) mntr_mod_mpos = ipos
448 $
'Registered module ['//trim(lname)//
']: '//trim(ldscr))
478 slena = len_trim(adjustl(mname))
480 slen = len_trim(mname) - slena + 1
481 if (slena.gt.mntr_lstl_mnm)
then
483 $
'too long module name; shortenning')
484 slena = min(slena,mntr_lstl_mnm)
486 call blank(lname,mntr_lstl_mnm)
487 lname= mname(slen:slen+slena- 1)
488 call capit(lname,slena)
494 if (nid.eq.mntr_pid0)
then
496 do il=1,mntr_mod_mpos
497 if (mntr_mod_id(il).ge.0.and.
498 $ mntr_mod_name(il).eq.lname)
then
506 call bcast(ipos,isize)
511 $
'Module ['//trim(lname)//
'] not registered')
514 write(str,
'(I3)') ipos
516 $
'Module ['//trim(lname)//
'] registered with mid='//str)
581 if (mntr_mod_id(mid).ge.0)
then
582 pmid = mntr_mod_id(mid)
583 mname = mntr_mod_name(mid)
586 write(str,
'(I3)') mid
588 $
'Module id'//trim(str)//
' not registered')
616 if (priority.lt.mntr_lp_def)
return
619 if (nid.eq.mntr_pid0)
then
622 slena = len_trim(adjustl(logs))
624 slen = len_trim(logs) - slena + 1
625 if (slena.ge.mntr_lstl_log)
then
626 if (mntr_lp_def.le.lp_deb)
write(*,*)
' ['//mntr_name//
'] ',
627 $
'too long log string; shortenning'
628 slena = min(slena,mntr_lstl_log)
630 call blank(llogs,mntr_lstl_mds)
631 llogs= logs(slen:slen + slena - 1)
634 if (mntr_mod_id(mid).ge.0)
then
636 write(*,*)
' ['//trim(mntr_mod_name(mid))//
'] '//trim(llogs)
638 write(str,
'(I3)') mid
639 write(*,*)
' ['//trim(mntr_name)//
'] ',
640 $
' WARNING: module'//trim(str)//
' not registered;'
641 write(*,*)
'Log body: '//trim(llogs)
662 integer mid,priority, prid
671 if (priority.lt.mntr_lp_def)
return
676 slena = len_trim(adjustl(logs))
678 slen = len_trim(logs) - slena + 1
679 if (slena.ge.mntr_lstl_log)
then
680 if (mntr_lp_def.le.lp_deb)
write(*,*)
' ['//mntr_name//
'] ',
681 $
'too long log string; shortenning'
682 slena = min(slena,mntr_lstl_log)
684 call blank(llogs,mntr_lstl_mds)
685 llogs= logs(slen:slen + slena - 1)
688 if (mntr_mod_id(mid).ge.0)
then
690 write(*,*)
' ['//trim(mntr_mod_name(mid))//
'] nid= ',prid,
693 write(str,
'(I3)') mid
694 write(*,*)
' ['//trim(mntr_name)//
'] ',
695 $
' WARNING: module'//trim(str)//
' not registered;'
696 write(*,*)
'Log body: nid= ',prid,
' '//trim(llogs)
712 integer mid,priority,ivar
718 write(str,
'(I8)') ivar
719 call mntr_log(mid,priority,trim(logs)//
' '//trim(str))
741 write(str,
'(E15.8)') rvar
742 call mntr_log(mid,priority,trim(logs)//
' '//trim(str))
758 integer mid,priority,rvarn
766 call mntr_log(mid,priority,trim(logs))
768 write(str,
'(E15.8)') rvarv(il)
769 call mntr_log(mid,priority,
' '//trim(str))
792 write(str,
'(L2)') lvar
793 call mntr_log(mid,priority,trim(logs)//
' '//trim(str))
811 call mntr_log(mid,lp_inf,
'WARNING: '//logs)
828 call mntr_log(mid,lp_err,
'ERROR: '//logs)
845 call mntr_log(mid,lp_err,
'ABORT: '//logs)
865 integer imax, imin, itest
868 integer iglmax, iglmin
870 imax = iglmax(ierr,1)
871 imin = iglmin(ierr,1)
879 write(str,
'(I3)') itest
881 $
'ABORT: '//trim(logs)//
' ierr='//trim(str))
899 integer olist(2,mntr_id_max), ierr
904 $
'Summary of registered modules')
906 if (nid.eq.mntr_pid0)
then
911 if(ierr.eq.0.and.mntr_lp_def.le.lp_prd)
then
913 write(str,
'(I3)') stride*(olist(2,il))
914 ftm =
'('//trim(str)//
'X,"[",A,"] : ",A)'
915 write(*,ftm) mntr_mod_name(olist(1,il)),
916 $ mntr_mod_dscr(olist(1,il))
936 integer olist(2,mntr_id_max), ierr
939 integer ind(mntr_id_max), level, parent, ipos
940 integer slist(2,mntr_id_max), itmp1(2)
943 integer istart, in, itest
950 do il=1,mntr_mod_mpos
951 if (mntr_mod_id(il).ge.0)
then
953 slist(1,npos) = mntr_mod_id(il)
957 if(npos.ne.mntr_mod_num)
then
960 $
'Inconsistent module number; return',mntr_pid0)
970 itest = slist(1,istart)
972 if(itest.ne.slist(1,il).or.il.eq.npos)
then
973 if (il.eq.npos.and.itest.eq.slist(1,il))
then
979 if (itest.eq.0.and.in.ne.1)
then
981 $
'Must be single root of the graph; return',mntr_pid0)
987 call ituple_sort(slist(1,istart),2,in,key,1,ind,itmp1)
1017 integer nlist, npos, parent, level
1018 integer olist(2,nlist),slist(2,nlist)
1022 integer lparent, llevel
1026 if (slist(1,il).eq.parent)
then
1027 slist(1,il) = - parent
1028 lparent = slist(2,il)
1029 olist(1,npos) = lparent
1030 olist(2,npos) = llevel
subroutine bcast(buf, len)
real *8 function dnekclock()
subroutine mntr_logi(mid, priority, logs, ivar)
Write log message adding single integer.
subroutine mntr_mod_summary_print()
Print registered modules showing tree structure.
recursive subroutine mntr_build_ord_list(olist, slist, nlist, npos, parent, level)
Build ordered list reflecting graph structure.
subroutine mntr_logr(mid, priority, logs, rvar)
Write log message adding single real.
subroutine mntr_warn(mid, logs)
Write warning message.
subroutine mntr_mod_is_name_reg(mid, mname)
Check if module name is registered and return its id.
subroutine mntr_mod_get_info(mname, pmid, mid)
Get module name an parent id for given module id. This operation is performed locally.
subroutine mntr_logrv(mid, priority, logs, rvarv, rvarn)
Write log message adding real vector of length n.
subroutine mntr_mod_get_olist(olist, ierr)
Provide ordered list of registered modules for printing.
integer function mntr_lp_def_get()
Get logging threashold.
subroutine mntr_abort(mid, logs)
Abort simulation.
subroutine mntr_set_conv(ifconv)
Set convergence flag to shorten simulation.
subroutine mntr_log(mid, priority, logs)
Write log message.
subroutine mntr_wclock
Monitor simulation wall clock.
subroutine mntr_error(mid, logs)
Write error message.
subroutine mntr_mod_get_number(nmod, mmod)
Get number of registered modules. This operation is performed locally.
subroutine mntr_register_mod(log_thr)
Initialise monitor by registering framework and monitor.
subroutine mntr_mod_reg(mid, pmid, mname, mdscr)
Register new module.
subroutine mntr_init
Initialise monitor module.
subroutine mntr_logl(mid, priority, logs, lvar)
Write log message adding single logical.
subroutine mntr_get_step_delay(dstep)
Get step delay.
logical function mntr_is_initialised()
Check if module was initialised.
subroutine mntr_log_local(mid, priority, logs, prid)
Write log message from given process.
subroutine mntr_tmr_reg(mid, pmid, modid, mname, mdscr, ifsum)
Register new timer.
subroutine mntr_check_abort(mid, ierr, logs)
Abort simulation.
subroutine mntr_register_par
Register monitor runtime parameters.
subroutine mntr_set_step_delay(dstep)
Set number of steps necessary to write proper checkpointing.
logical function mntr_mod_is_id_reg(mid)
Check if module id is registered. This operation is performed locally.
subroutine rprm_rp_get(ipval, rpval, lpval, cpval, rpid, ptype)
Get runtime parameter form active section. This operation is performed locally.
subroutine rprm_rp_reg(rpid, mid, pname, pdscr, ptype, ipval, rpval, lpval, cpval)
Register new runtime parameter.
subroutine rprm_sec_set_act(ifact, rpid)
Set section's activation flag. Master value is broadcasted.
subroutine rprm_sec_reg(rpid, mid, pname, pdscr)
Register new parameter section.
subroutine capit(lettrs, n)
subroutine ituple_sort(a, lda, n, key, nkey, ind, aa)