forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Character variable in format specification statement

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Fri Jan 13, 2017 10:27 am    Post subject: Character variable in format specification statement Reply with quote

I have a format specification statement as below:

Code:
2400  format(/' Pipe  Load  Dist.   -- Axial force --     Bending mome',
     &       'nt   Stress  ------------ Pressure -----------  System  ',
     &       ' Local'/
     &' name  ',[color=orange]stcase[/color],'   node    design     resi-    design     res',
     &       'i-  param.   ext.  local  coll.  burst conta-   col-  bu',
     &       'ckling'/
     &       '              name              stance              stan',
     &       'ce alpha c    pe    pld     pc     pb  inment   lapse eq',
     &       'ua ratio'/
     &       '               (m)      (kN)      (kN)     (kNm)     (kN',
     &       'm)          (MPa)  (MPa)  (MPa)  (MPa)  ratio   ratio ti',
     &       'on'/)


My stcase is a character variable which can take several values. IS it possible to somehow include that variable in the format 2400?
Back to top
View user's profile Send private message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Fri Jan 13, 2017 10:29 am    Post subject: Reply with quote

The stacse which I intended colouring it didnÝt take up the color. I meant this one:

stcase,
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 739

PostPosted: Fri Jan 13, 2017 1:26 pm    Post subject: Reply with quote

You can build up a format string at run time as follows. I am sure that you will need to edit the strings to get the spacings and labels correct, but the main idea is that you can use a character variable as a format string, just as you can use a character constant as a format string.
Code:
program TEST
implicit none
character(len=200) :: fmt1
character(len=10) :: stcase
character(len=400) :: fmt2
character(len=600) :: fmt2400
fmt1="(/' Pipe  Load  Dist.   -- Axial force --     Bending mome" // &
     "nt   Stress  ------------ Pressure -----------  System  " // &
     " Local  name  ,"
stcase='Severe'
fmt2="   node    design     resi-    design     res" // &
     "i-  param.   ext.  local  coll.  burst conta-   col-  bu" // &
     "ckling'/, " // &
     "'              name              stance              stan" // &
     "ce alpha c    pe    pld     pc     pb  inment   lapse eq" // &
     "ua ratio',/ " // &
     "'               (m)      (kN)      (kN)     (kNm)     (kN" // &
     "m)          (MPa)  (MPa)  (MPa)  (MPa)  ratio   ratio ti" // &
     "on'/)"
fmt2400=trim(fmt1) // stcase // trim(fmt2)
write(*,fmt2400)
end program
Back to top
View user's profile Send private message
ajaytaneja



Joined: 08 Apr 2011
Posts: 17

PostPosted: Fri Jan 13, 2017 2:56 pm    Post subject: Reply with quote

Thanks, I did as follows.

Code:
character stcase*4

stcase = 'blah'

write(6,2400) stcase

2400 format(/,' S T R E S S   A N A L Y S I S   A C C O R D I N G',
     &       '   T O   ',A4, 'whatever')
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group