21 integer frame_get_master
23 rprm_pid0 = frame_get_master()
30 do il = 1, rprm_sec_id_max
32 rprm_sec_act(il) = .false.
33 rprm_sec_name(il) = rprm_blname
37 do il = 1, rprm_par_id_size
38 rprm_par_id(il,1) = -1
40 do il = 1, rprm_par_id_max
41 rprm_par_name(il) = rprm_blname
43 rprm_parv_real(il) = 0.0
44 rprm_parv_log(il) = .false.
45 rprm_parv_str(il) = rprm_blname
52 $
'module ['//trim(rprm_name)//
'] already registered')
61 $
'parent module ['//
'FRAME'//
'] not registered')
65 call mntr_mod_reg(rprm_id,itmp,rprm_name,
'Runtime parameters')
68 call rprm_sec_reg(rprm_lsec_id,rprm_id,
'_'//adjustl(rprm_name),
69 $
'Runtime parameter section for rprm module')
73 call rprm_rp_reg(rprm_ifparf_id,rprm_lsec_id,
'PARFWRITE',
74 $
'Do we write runtime parameter file',rpar_log,0,
77 call rprm_rp_reg(rprm_parfnm_id,rprm_lsec_id,
'PARFNAME',
78 $
'Runtime parameter file name for output (without .par)',
79 $ rpar_str,0,0.0,.false.,
'outparfile')
102 if (rprm_ifinit)
then
104 $
'module ['//trim(rprm_name)//
'] already initiaised.')
109 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,rprm_ifparf_id,rpar_log)
111 call rprm_rp_get(itmp,rtmp,ltmp,ctmp,rprm_parfnm_id,rpar_str)
119 if (rprm_ifparf)
then
122 fname=trim(adjustl(rprm_parfnm))//
'.par'
123 open(unit=iunit,
file=fname,status=
'new',iostat=ierr)
129 $
'ERROR: cannot open output .par file')
133 $
'ERROR: cannot allocate iunit for output .par file')
174 character*(*) pname, pdscr
187 logical mntr_mod_is_id_reg
190 slena = len_trim(adjustl(pname))
192 slen = len_trim(pname) - slena + 1
193 if (slena.gt.rprm_lstl_mnm)
then
195 $
'too long section name; shortenning')
196 slena = min(slena,rprm_lstl_mnm)
198 call blank(lname,rprm_lstl_mnm)
199 lname= pname(slen:slen+slena- 1)
200 call capit(lname,slena)
203 slena = len_trim(adjustl(pdscr))
205 slen = len_trim(pdscr) - slena + 1
206 if (slena.ge.rprm_lstl_mds)
then
208 $
'too long section description; shortenning')
209 slena = min(slena,rprm_lstl_mnm)
211 call blank(ldscr,rprm_lstl_mds)
212 ldscr= pdscr(slen:slen + slena - 1)
218 if (nid.eq.rprm_pid0)
then
221 do il=1,rprm_sec_mpos
222 if (rprm_sec_id(il).gt.0.and.
223 $ rprm_sec_name(il).eq.lname)
then
231 do il=1,rprm_sec_id_max
232 if (rprm_sec_id(il).eq.-1)
then
241 call bcast(ipos,isize)
247 $
'Section '//trim(lname)//
' cannot be registered')
249 elseif (ipos.lt.0)
then
252 $
'Section '//trim(lname)//
' is already registered')
257 if (mntr_mod_is_id_reg(mid))
then
258 rprm_sec_id(ipos) = mid
261 $
"Sections's "//trim(lname)//
" module not registered")
263 rprm_sec_name(ipos)=lname
264 rprm_sec_dscr(ipos)=ldscr
265 rprm_sec_num = rprm_sec_num + 1
266 if (rprm_sec_mpos.lt.ipos) rprm_sec_mpos = ipos
270 llog=
'Module ['//trim(mname)//
'] registered section '
271 llog=trim(llog)//
' '//trim(lname)//
': '//trim(ldscr)
272 call mntr_log(rprm_id,lp_inf,trim(llog))
305 slena = len_trim(adjustl(pname))
307 slen = len_trim(pname) - slena + 1
308 if (slena.gt.rprm_lstl_mnm)
then
310 $
'too long section name; shortenning')
311 slena = min(slena,rprm_lstl_mnm)
313 call blank(lname,rprm_lstl_mnm)
314 lname= pname(slen:slen+slena- 1)
315 call capit(lname,slena)
321 if (nid.eq.rprm_pid0)
then
324 do il=1,rprm_sec_mpos
325 if (rprm_sec_id(il).gt.0.and.
326 $ rprm_sec_name(il).eq.lname)
then
335 call bcast(ipos,isize)
340 $
'Section '//trim(lname)//
' not registered')
343 write(str,
'(I3)') ipos
345 $
'Section '//trim(lname)//
' registered with id = '//trim(str))
347 if (mid.ne.rprm_sec_id(ipos))
then
349 $
"Section's "//trim(lname)//
" module inconsistent")
397 if (rprm_sec_id(rpid).gt.0)
then
398 pname = rprm_sec_name(rpid)
399 mid = rprm_sec_id(rpid)
400 ifact = rprm_sec_act(rpid)
402 write(str,
'(I3)') rpid
404 $
'Section id'//trim(str)//
' not registered')
437 if (rprm_sec_id(rpid).gt.0)
then
440 call bcast(lval,lsize)
441 rprm_sec_act(rpid) = lval
443 write(str,
'(I3)') rpid
445 $
"Section "//trim(str)//
" activation error")
483 $ ipval, rpval, lpval, cpval)
493 integer rpid, mid, ptype, ipval
496 character*(*) pname, pdscr, cpval
512 logical rprm_sec_is_id_reg
515 slena = len_trim(adjustl(pname))
517 slen = len_trim(pname) - slena + 1
518 if (slena.gt.rprm_lstl_mnm)
then
520 $
'too long parameter name; shortenning')
521 slena = min(slena,rprm_lstl_mnm)
523 call blank(lname,rprm_lstl_mnm)
524 lname= pname(slen:slen+slena- 1)
525 call capit(lname,slena)
528 slena = len_trim(adjustl(pdscr))
530 slen = len_trim(pdscr) - slena + 1
531 if (slena.ge.rprm_lstl_mds)
then
533 $
'too long parameter description; shortenning')
534 slena = min(slena,rprm_lstl_mnm)
536 call blank(ldscr,rprm_lstl_mds)
537 ldscr= pdscr(slen:slen + slena - 1)
543 if (nid.eq.rprm_pid0)
then
546 do il=1,rprm_par_mpos
547 if (rprm_par_id(rprm_par_mark,il).gt.0.and.
548 $ rprm_par_id(rprm_par_mark,il).eq.mid.and.
549 $ rprm_par_name(il).eq.lname)
then
557 do il=1,rprm_par_id_max
558 if (rprm_par_id(rprm_par_mark,il).eq.-1)
then
567 call bcast(ipos,isize)
573 $
'Parameter '//trim(lname)//
' cannot be registered')
575 elseif (ipos.lt.0)
then
578 $
'Parameter '//trim(lname)//
' is already registered')
583 if (rprm_sec_is_id_reg(mid))
then
584 rprm_par_id(rprm_par_mark,ipos) = mid
587 $
"Parameter's "//trim(lname)//
" section not registered")
589 rprm_par_id(rprm_par_type,ipos) = ptype
590 rprm_par_name(ipos)=lname
591 rprm_par_dscr(ipos)=ldscr
592 rprm_par_num = rprm_par_num + 1
593 if (rprm_par_mpos.lt.ipos) rprm_par_mpos = ipos
596 if (ptype.eq.rpar_int)
then
598 call bcast(ivall,isize)
599 rprm_parv_int(ipos) = ivall
600 elseif (ptype.eq.rpar_real)
then
602 call bcast(rvall,wdsize)
603 rprm_parv_real(ipos) = rvall
604 elseif (ptype.eq.rpar_log)
then
606 call bcast(lvall,lsize)
607 rprm_parv_log(ipos) = lvall
608 elseif (ptype.eq.rpar_str)
then
610 slena = len_trim(adjustl(cpval))
612 slen = len_trim(cpval) - slena + 1
613 if (slena.gt.rprm_lstl_mnm)
then
615 $
'too long parameter default value; shortenning')
616 slena = min(slena,rprm_lstl_mnm)
618 call blank(cvall,rprm_lstl_mnm)
619 cvall= cpval(slen:slen+slena- 1)
621 call bcast(cvall,rprm_lstl_mnm*csize)
622 rprm_parv_str(ipos) = cvall
625 $
"Parameter's "//trim(lname)//
" wrong type")
629 mname = trim(rprm_sec_name(mid))
630 llog=
'Section '//trim(mname)//
' registered parameter '
631 llog=trim(llog)//
' '//trim(lname)//
': '//trim(ldscr)
632 call mntr_log(rprm_id,lp_inf,trim(llog))
633 if (ptype.eq.rpar_int)
then
635 $
'Default value '//trim(lname)//
' = ',ivall)
636 elseif (ptype.eq.rpar_real)
then
638 $
'Default value '//trim(lname)//
' = ',rvall)
639 elseif (ptype.eq.rpar_log)
then
641 $
'Default value '//trim(lname)//
' = ',lvall)
642 elseif (ptype.eq.rpar_str)
then
644 $
'Default value '//trim(lname)//
' = '//trim(cvall))
666 integer rpid, mid, ptype
679 slena = len_trim(adjustl(pname))
681 slen = len_trim(pname) - slena + 1
682 if (slena.gt.rprm_lstl_mnm)
then
684 $
'too long parameter name; shortenning')
685 slena = min(slena,rprm_lstl_mnm)
687 call blank(lname,rprm_lstl_mnm)
688 lname= pname(slen:slen+slena- 1)
689 call capit(lname,slena)
695 if (nid.eq.rprm_pid0)
then
698 do il=1,rprm_par_mpos
699 if (rprm_par_id(rprm_par_mark,il).gt.0.and.
700 $ rprm_par_name(il).eq.lname)
then
709 call bcast(ipos,isize)
714 $
'Parameter '//trim(lname)//
' not registered')
717 write(str,
'(I3)') ipos
719 $
'Parameter '//trim(lname)//
' registered with id = '//trim(str))
721 if (mid.ne.rprm_par_id(rprm_par_mark,ipos))
then
723 $
"Parameter's "//trim(lname)//
" section inconsistent")
727 if (ptype.ne.rprm_par_id(rprm_par_type,ipos))
then
729 $
"Parameter's "//trim(lname)//
" type inconsistent")
753 $ rprm_par_id(rprm_par_type,rpid).eq.ptype
772 integer rpid, mid, ptype
778 if (rprm_par_id(rprm_par_mark,rpid).gt.0)
then
779 pname = rprm_par_name(rpid)
780 mid = rprm_par_id(rprm_par_mark,rpid)
781 ptype = rprm_par_id(rprm_par_type,rpid)
783 write(str,
'(I3)') rpid
785 $
'Parameter id'//trim(str)//
' not registered')
824 if (rprm_par_id(rprm_par_mark,rpid).gt.0.and.
825 $ rprm_par_id(rprm_par_type,rpid).eq.ptype)
then
826 if(rprm_sec_act(rprm_par_id(rprm_par_mark,rpid)))
then
828 if (ptype.eq.rpar_int)
then
830 call bcast(ivall,isize)
831 rprm_parv_int(rpid) = ivall
832 elseif (ptype.eq.rpar_real)
then
834 call bcast(rvall,wdsize)
835 rprm_parv_real(rpid) = rvall
836 elseif (ptype.eq.rpar_log)
then
838 call bcast(lvall,lsize)
839 rprm_parv_log(rpid) = lvall
840 elseif (ptype.eq.rpar_str)
then
842 slena = len_trim(adjustl(cpval))
844 slen = len_trim(cpval) - slena + 1
845 if (slena.gt.rprm_lstl_mnm)
then
847 $
'too long parameter value; shortenning')
848 slena = min(slena,rprm_lstl_mnm)
850 call blank(cvall,rprm_lstl_mnm)
851 cvall= cpval(slen:slen+slena- 1)
853 call bcast(cvall,rprm_lstl_mnm*csize)
854 rprm_parv_str(rpid) = cvall
856 write(str,
'(I3)') rpid
858 $
"Parameter set "//trim(str)//
" wrong type")
861 write(str,
'(I3)') rpid
863 $
"Parameter set "//trim(str)//
" section not active")
866 write(str,
'(I3)') rpid
868 $
"Parameter "//trim(str)//
" setting error")
899 if (rprm_par_id(rprm_par_mark,rpid).gt.0.and.
900 $ rprm_par_id(rprm_par_type,rpid).eq.ptype)
then
901 if(rprm_sec_act(rprm_par_id(rprm_par_mark,rpid)))
then
903 if (ptype.eq.rpar_int)
then
904 ipval = rprm_parv_int(rpid)
905 elseif (ptype.eq.rpar_real)
then
906 rpval = rprm_parv_real(rpid)
907 elseif (ptype.eq.rpar_log)
then
908 lpval = rprm_parv_log(rpid)
909 elseif (ptype.eq.rpar_str)
then
910 cpval = rprm_parv_str(rpid)
912 write(str,
'(I3)') rpid
914 $
"Parameter get "//trim(str)//
" wrong type")
917 write(str,
'(I3)') rpid
919 $
"Parameter get "//trim(str)//
" section not active")
922 write(str,
'(I3)') rpid
924 $
"Parameter "//trim(str)//
" getting error")
942 integer nkey, ifnd, i_out
944 character*132 key, lkey
946 logical ifoundm, ifoundp, ifact
957 if (nid.eq.rprm_pid0)
then
959 call finiparser_getdictentries(nkey)
964 call finiparser_getpair(key,val,il,ifnd)
970 do jl=1,rprm_sec_mpos
971 if (rprm_sec_id(jl).gt.0)
then
972 lname=trim(adjustl(rprm_sec_name(jl)))
973 ifnd = index(key,trim(lname))
976 rprm_sec_act(jl) = .true.
979 if (trim(key).ne.trim(lname))
then
982 do kl=1,rprm_par_mpos
983 if (rprm_par_id(rprm_par_mark,kl).eq.jl)
then
984 lkey = trim(lname)//
':'//trim(rprm_par_name(kl))
985 if (trim(key).eq.trim(lkey))
then
988 if (rprm_par_id(rprm_par_type,kl).eq.
991 rprm_parv_int(kl) = itmp
992 elseif (rprm_par_id(rprm_par_type,kl).eq.
995 rprm_parv_real(kl) = rtmp
996 elseif (rprm_par_id(rprm_par_type,kl).eq.
998 call finiparser_getbool(i_out,trim(lkey),ifnd)
1000 if (i_out.eq.1)
then
1001 rprm_parv_log(kl) = .true.
1003 rprm_parv_log(kl) = .false.
1007 $
'Boolean parameter reading error '//trim(key))
1009 elseif (rprm_par_id(rprm_par_type,kl).eq.
1011 rprm_parv_str(kl) = trim(adjustl(val))
1014 $
'Runtime parameter type missmatch '//trim(key))
1021 if (.not.ifoundp)
then
1023 $
'Unknown runtime parameter '//trim(key))
1030 if (.not.ifoundm)
then
1037 call bcast(rprm_parv_int,rprm_par_id_max*isize)
1038 call bcast(rprm_parv_real,rprm_par_id_max*wdsize)
1039 call bcast(rprm_parv_log,rprm_par_id_max*lsize)
1040 call bcast(rprm_parv_str,rprm_par_id_max*rprm_lstl_mnm*csize)
1043 call bcast(rprm_sec_act,rprm_sec_id_max*lsize)
1062 integer ind(rprm_par_id_max)
1063 integer offset(2,rprm_par_id_max)
1064 integer slist(2,rprm_par_id_max), itmp1(2)
1065 integer npos, nset, key
1067 integer istart, in, itest
1074 integer mntr_lp_def_get
1078 $
'Summary of registered runtime parameters for active sections')
1081 $
'Generated .par file for active sections')
1084 if (nid.eq.rprm_pid0)
then
1089 do il=1,rprm_par_mpos
1090 in = rprm_par_id(rprm_par_mark,il)
1091 if (in.ge.0.and.rprm_sec_act(in))
then
1105 itest = slist(1,istart)
1107 if(itest.ne.slist(1,il).or.il.eq.npos)
then
1108 if (il.eq.npos.and.itest.eq.slist(1,il))
then
1116 call ituple_sort(slist(1,istart),2,in,key,1,ind,itmp1)
1119 offset(1,nset) = istart
1121 if (il.ne.npos)
then
1124 elseif(itest.ne.slist(1,il))
then
1132 if (mntr_lp_def_get().le.lp_prd.or.unit.ne.6)
then
1134 write(unit,
'(A)') cmnt
1135 write(unit,
'(A,A)') cmnt,
1136 $
' runtime parameter file generated by'
1137 write(unit,
'(A,A)') cmnt,
' rprm_rp_summary_print'
1138 write(unit,
'(A)') cmnt
1141 istart = offset(1,il)
1143 key = rprm_sec_id(slist(1,istart))
1144 sname =
'['//trim(rprm_sec_name(slist(1,istart)))//
']'
1145 write(unit,
'(A)') cmnt
1146 write(unit,
'(A,A)') sname,
1147 $
' '//cmnt//
' '//trim(adjustl(rprm_sec_dscr(slist(1,istart))))
1149 key = slist(2,istart+jl)
1150 if (rprm_par_id(rprm_par_type,key).eq.
1152 write(str,
'(I8)') rprm_parv_int(key)
1153 elseif (rprm_par_id(rprm_par_type,key).eq.
1155 write(str,
'(E15.8)') rprm_parv_real(key)
1156 elseif (rprm_par_id(rprm_par_type,key).eq.
1158 if (rprm_parv_log(key))
then
1163 elseif (rprm_par_id(rprm_par_type,key).eq.
1165 str = rprm_parv_str(key)
1167 write(unit,
'(A," = ",A,A)')
1168 $ rprm_par_name(key), adjustl(str),
1169 $
' '//cmnt//
' '//trim(adjustl(rprm_par_dscr(key)))
1173 write(unit,
'(A)') cmnt
1174 write(unit,
'(A,A)') cmnt,
' end of runtime parameter file'
1175 write(unit,
'(A)') cmnt
1177 write(unit,
'(A1)')
' '
1198 $ mod_l3dkey, ifsec)
1207 integer mod_nkeys, mod_n3dkeys, mod_l3dkey(mod_n3dkeys)
1208 character*132 mod_dictkey(mod_nkeys)
1214 integer nkey, ifnd, i_out
1216 character*132 key, lkey
1218 logical ifvar, if3dkey
1222 call finiparser_getdictentries(nkey)
1228 call finiparser_getpair(key,val,il,ifnd)
1232 ifnd = index(key,trim(mod_dictkey(1)))
1237 do ip = mod_nkeys,1,-1
1238 lkey = trim(adjustl(mod_dictkey(1)))
1239 if (ip.gt.1) lkey =trim(adjustl(lkey))//
1240 $
':'//trim(adjustl(mod_dictkey(ip)))
1241 if(index(key,trim(lkey)).eq.1)
then
1252 if (ip.eq.mod_l3dkey(jl))
then
1260 $
'Module '//trim(mod_dictkey(1)))
1262 $
'3D parameter '//trim(key)//
' specified for 2D run')
1268 $
'Module '//trim(mod_dictkey(1)))
1270 $
'Unknown runtime parameter: '//trim(key))
1276 if (.not.ifsec)
then
1277 call mntr_log(rprm_id,lp_inf,
'Module '//trim(mod_dictkey(1)))
1279 $
'runtime parameter section not found.')
subroutine bcast(buf, len)
subroutine mntr_logi(mid, priority, logs, ivar)
Write log message adding single integer.
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_abort(mid, logs)
Abort simulation.
subroutine mntr_log(mid, priority, logs)
Write log message.
subroutine mntr_mod_reg(mid, pmid, mname, mdscr)
Register new module.
subroutine mntr_logl(mid, priority, logs, lvar)
Write log message adding single logical.
subroutine rprm_register
Register runtime parameters database.
subroutine rprm_sec_get_info(pname, mid, ifact, rpid)
Get section info based on its id. This operation is performed locally.
subroutine rprm_rp_is_name_reg(rpid, mid, pname, ptype)
Check if parameter name is registered and return its id. Check flags as well.
subroutine rprm_rp_set(rpid, ptype, ipval, rpval, lpval, cpval)
Set runtime parameter of active section. Master value is broadcasted.
subroutine rprm_rp_summary_print(unit)
Print out summary of registered runtime parameters (active sections only)
logical function rprm_rp_is_id_reg(rpid, ptype)
Check if parameter id is registered and check type consistency. This operation is performed locally.
subroutine rprm_init
Initialise modules runtime parameters and write summary.
subroutine rprm_dict_get()
Get runtime parameter from nek parser dictionary.
subroutine rprm_rp_get(ipval, rpval, lpval, cpval, rpid, ptype)
Get runtime parameter form active section. This operation is performed locally.
logical function rprm_sec_is_id_act(rpid)
Check if section id is registered and activated. This operation is performed locally.
subroutine rprm_check(mod_nkeys, mod_dictkey, mod_n3dkeys, mod_l3dkey, ifsec)
Check consistency of module's runtime parameters.
subroutine rprm_sec_is_name_reg(rpid, mid, pname)
Check if section name is registered and return its id. Check mid as well.
subroutine rprm_rp_get_info(pname, mid, ptype, rpid)
Get parameter info based on its id. This operation is performed locally.
logical function rprm_sec_is_id_reg(rpid)
Check if section id is registered. 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.
logical function rprm_is_initialised()
Check if module was initialised.
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)