LIB: Difference between revisions

9 bytes removed ,  15 May 2019
→‎Client code example: move cformat assignment into plugin_open, and definition into a module variable
(→‎Client code example: separate assignment of cformat from its definition. Reason: otherwise, a static variable results)
(→‎Client code example: move cformat assignment into plugin_open, and definition into a module variable)
Line 131: Line 131:


MODULE plugin_test_mod
MODULE plugin_test_mod
       CHARACTER :: fn_template*132=''
       CHARACTER :: fn_template*132='',cformat*6='(i4.4)'
       INTEGER  :: lenfn,firstqm,lastqm
       INTEGER  :: lenfn,firstqm,lastqm
END MODULE
END MODULE
Line 154: Line 154:
       firstqm=INDEX(fn_template,'?')
       firstqm=INDEX(fn_template,'?')
       lastqm =INDEX(fn_template,'?',BACK=.TRUE.)
       lastqm =INDEX(fn_template,'?',BACK=.TRUE.)
      WRITE(cformat(3:5),'(i1,a1,i1)')lastqm-firstqm+1,'.',lastqm-firstqm+1
END SUBROUTINE plugin_open
END SUBROUTINE plugin_open
!
!
Line 184: Line 185:
! local variables
! local variables
     INTEGER k,i,dummy
     INTEGER k,i,dummy
     CHARACTER :: fn*132,cformat*6
     CHARACTER :: fn*132
    cformat='(i4.4)'
     fn=fn_template
     fn=fn_template
    WRITE(cformat(3:5),'(i1,a1,i1)')lastqm-firstqm+1,'.',lastqm-firstqm+1
     IF (frame_number>0) WRITE(fn(firstqm:lastqm),cformat) frame_number
     IF (frame_number>0) WRITE(fn(firstqm:lastqm),cformat) frame_number
! -qopenmp compile option needs to be used otherwise race in writing fn
! -qopenmp compile option needs to be used otherwise race in writing fn
2,652

edits