|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Fri Jan 13, 2017 10:27 am Post subject: Character variable in format specification statement |
|
|
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 |
|
|
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Fri Jan 13, 2017 10:29 am Post subject: |
|
|
The stacse which I intended colouring it didnøt take up the color. I meant this one:
stcase, |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Jan 13, 2017 1:26 pm Post subject: |
|
|
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 |
|
|
ajaytaneja
Joined: 08 Apr 2011 Posts: 17
|
Posted: Fri Jan 13, 2017 2:56 pm Post subject: |
|
|
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 |
|
|
|
|
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
|