gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1519 Posts in 504 Topics by 735 Members - Latest Member: Rosy December 02, 2020, 07:24:32 AM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  General  |  <> in formats
gfx
gfxgfx
 

Author Topic: <> in formats  (Read 7853 times)

afilhol

  • Guest
<> in formats
« on: July 08, 2007, 10:26:42 AM »
Hi,

I am a beginner in Fortran 90/95 and I do not find an equivalent to an old 77 code.

   10 format(A<LEN(myString)>)
   20 Format(A10, <LEN(myString)>('#'), F10.5)

In other words, the quantity <xxx> is evaluated at run time thus making the format self-adjusting.

With Absoft Fortran 10 on a Mac, <LEN(myString)> is not rejected by the compiler but the result is always 1.
I found no mention of <> in formats in recent Fortran manuals.

Alain

Mike Linacre

  • Full Member
  • ***
  • Posts: 236
Re: <> in formats
« Reply #1 on: July 15, 2007, 07:51:04 PM »
Alain, this <> extension to FORTRAN is new to me ... despite programming for 40+ years! I do this in two steps:
1. Internal write a dynamic FORMAT statement from a static  FORMAT statement. The big challenge is getting the apostrophes correct.
2. Use the dynamic FORMAT statement for the I/O.

susie

  • Newbie
  • *
  • Posts: 2
Re: <> in formats
« Reply #2 on: April 25, 2008, 04:17:06 PM »
Well, I have used it plenty, and want to make it work in Absoft too.  Did you ever find out how to make it work?

mecej4

  • Jr. Member
  • **
  • Posts: 66
Re: <> in formats
« Reply #3 on: May 02, 2008, 05:54:01 PM »
Here is a toy program that may illustrate how to do this. It uses the non-standard function "len_trim", which is provided by many compilers.

Code: [Select]
       program varfmt
       character myFmt*10,myStr*20
       myStr='This is my string'
       write(myFmt,10)len_Trim(myStr)
   10 format('(1x,A',I2,')')
       write(*,myFmt)myStr
       stop
       end

Absoft User Forum  |  Support  |  General  |  <> in formats
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!