Author Topic: reset tinput  (Read 3218 times)

schmidt

  • New Member
  • *
  • Posts: 2
reset tinput
« on: September 07, 2018, 12:25:31 AM »
Hey all,

tldr; looking for a way to reset the reading with 'tinput' to an earlier line of the input record to re-read the parameters.

I'm writing a wrapper to test some of my user elements. The wrapper itself is another element subroutine (let's say user/elmt01.f). I basically want to read the last parameters in the input file material record, e.g when testing user/elmt33.f the input record reads:

Code: [Select]
MATErial,1
USER,33
  3e+6   1e+6   00
  1e+6   3e+6   00
  00     00   1e+6
end

then when using the wrapper element instead, there are additional parameters indicating the element to be wrapped (in this case 33) and some further parameters for the wrapper itself (0.1, 21). Putting the parameters of the wrapper last has the advantage that the same input file can be used for the elmt33 itself, as only changing USER,1 to USER,33 is necessary.

Code: [Select]
MATErial,1
USER,1
  3e+6   1e+6   00
  1e+6   3e+6   00
  00     00   1e+6
  WRAP   33     0.1    21
end

the idea was to read the input using 'tinput' until finding the keyword 'WRAP' in the end, then resetting the lines read and calling the elmt33( ... ) subroutine from within the wrapper. However when calling 'pinput' reading input parameters starts at the 5th line and so on. How can I reset the reading with tinput to line 1 of the material input record?
I noticed that the variable irecrd(isf) in the common block '/ioincl/' contains the current line, however resetting it doesn't help.

Best,
Simon
« Last Edit: September 07, 2018, 12:34:44 AM by schmidt »

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: reset tinput
« Reply #1 on: September 07, 2018, 06:44:06 AM »
I can't think of an easy way to do this using tinput, however, feap saves material data in a file with name M + input file name with first character stripped.  If you make the value a parameter maybe you can set the parameter and read the Mfile?


Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: reset tinput
« Reply #2 on: September 07, 2018, 12:22:11 PM »
I seems that it makes more sense to put WRAP first and using polling input in element 33.
If element 33 sees WRAP it just ignores it. So no problem.  So something like this

In the input file

Code: [Select]
mate 1
user,33 ! or 1
  wrap 33 0.1 21
  data1 3e6 1e6 00
  data2 1e6 3e6 00
  data3 00 00 1e6
end

Element 01

 
Code: [Select]
if (isw.eq.1)
   call tinput(text(1),1,td,3) to get the wrap stuff
   call element 33 with isw.eq.1 to read the remaining lines (you will of course have to manage the storage for the parameters, but I assume your wrapper does that already)

The in Element 33

Code: [Select]
if(isw.eq.1)
      text(1) = 'xxxxx'
      do while (.not.pcomp(text(1),'end',3))
        errck  = tinput(text,1,td,3)

        if (pcomp(text(1),'data1',5)) then
            d(1) = td(1)
            d(2) = td(2)
            d(3) = td(3)
        elseif (pcomp(text(1),'data2',4)) then
            d(4) = td(1)
            d(5) = td(2)
            d(6) = td(3)
        elseif (pcomp(text(1),'data3',5)) then
            d(7) = td(1)
            d(8) = td(2)
            d(8) = td(3)
        end if

      end do
 

I would name data1 etc. something more meaningful.

schmidt

  • New Member
  • *
  • Posts: 2
Re: reset tinput
« Reply #3 on: September 10, 2018, 01:56:11 AM »
Thanks for the quick answers!

@Prof. S. Govindjee: The reason I wanted to put the keywords for the wrapper last. In that way I can easily add more parameters for the wrapper without changing code in other user elements. Additional lines in the material record are ignored by default. I think this solution is better, though I'm not happy reopening the inputfile twice for isw 1. Here is an excerpt from the elmt01.f I attached:
@Prof. R.L. Taylor: I basically used your solution but re-reading the input file instead of the M* file

Code: [Select]
    case(1)
            write(*,*) 'WRAPPER called, reading input parameters'
            inquire(ior, opened=isopen, named=hasname, name=FN)
            if (.not. (isopen .and. hasname)) then
               ! ERROR
            else
               line = irecrd(isf) ! 1st line of material record

               ! read wrapper parameters after keyword
               do while ( .not. pcomp(ca, kw, 4) )
                  call tinput(ca, 1, param, size(param))
               end do

               ! set parameters
               call input_param_check(param)
               write(*,*) param
               jel =  param(1)
               a = param(2)
               b = param(3)
               c = param(4)

               ! re-open file and advance to 1st line of material record
               close(ior)
               open(unit=ior,file=FN)
               irecrd(isf) = 0
               do while (line .gt. 0 )
                  call tinput(ca,1,param,0)
                  line = line - 1
               end do
            end if
« Last Edit: September 10, 2018, 01:58:39 AM by schmidt »