Open urbanjost opened 2 years ago
No prob. Maybe someone would like how you can simply NAMELIST group input so you can just use NAME=value with the same special syntax working, with the / not needed so you could run this and simply enter things like
scale=10,2
or "move=,,100" or "scale=3*2"
and you can add your own commands like "stop". I usually add "help", "stop", and "reset" commands. It is a lot nicer to use when you do not have to type "&value" and "/".
program testit
implicit none
real :: move(3)=[0.0,0.0,0.0], scale(3)=[1.0,1.0,1.0], rotate(3)=[0.0,0.0,0.0]
integer :: ios
namelist /values/ move,scale,rotate
character(len=256) :: input(3)=[character(len=256) :: '&values','','/'], msg
do
print , 'Enter transformation value(s) or "stop"'
print , 'move ..............',move
print , 'scale .............',scale
print , 'rotate (degrees)...',rotate
read(,'(a)',iostat=ios,iomsg=msg) input(2)
if(input(2).eq.'stop')exit
read(input,iostat=ios,iomsg=msg,nml=values)
if(ios.ne.0)then
print ,"
On 05/26/2022 10:38 AM Beliavsky ***@***.***> wrote: Thanks -- tweeted https://twitter.com/fortrantip/status/1529807207080009729 . — Reply to this email directly, view it on GitHub https://github.com/Beliavsky/FortranTip/issues/46#issuecomment-1138649126 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHDWN3P5IESHVVYXT5HKMTDVL6EF7ANCNFSM5VI3XB4Q . You are receiving this because you authored the thread.Message ID: ***@***.***>
List-directed input (using an asterisk("*") as a format) is often described simply as free-format input but it is more. It allows for null values and reading a partial list , and the form" r*c" where “r” is a repeater.
Suppose you have a program that prompts you for nine values to translate, scale, and/or rotate an object.
You do
not
have to enter all nine values. To just change all the scaling values to "2.0", you can enter:Where the null values mean to skip changing that value, and the slash means the end of values, or equivalently
Where "3" skips three values, 32.0" sets the next three values to two, and the "/" means you are done supplying values.