At 14:00 27-10-97 -0400, you wrote:
> I want to print a string of variable length without adding a space in
> the first column. the sample code looks like:
>
> character(len=256) :: line
> .........
> read(10,*) line
> n1=len_trim(line)
> write(12,14) line(1:n1)
> 14 format( ?? ) ! what to put here?
>
You may use
14 format (A)
write (12, 14) trim(line)
! Without using LEN_TRIM
> when I use: write(12,*) line(1:n1) it leaves a space in the first
> column which is not acceptable.
>
> Microsoft has an extension 14 format(a<n1>) which allowed me to check
> my program on PC. Now I want to port it to 4 UNIX platforms as well
> and I cannot find a simple way to do it.
>
> Further, I would like to use the value of an integer variable in a
string
> through concatenation. Is there a simple way to do it?
>
! Is this what you mean ?
character (len=8) :: FileName = "FileName"
character (len=3) :: ext
integer :: number = 1
write (unit = ext, fmt = "(I3.3)") Number
Open (unit=12, file=Filename//"."//Ext)
! JvO
---
Best Greetings,
Jan van Oosterwijk
Computing Centre
Delft University of Technology
P.O. Box 354
2600 AJ Delft
Netherlands
Phone: +31 15 278 50 17
Fax: +31 15 278 37 87
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|