Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 19th, 2006, 05:04 PM
gaanee gaanee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 153 gaanee User rank is Sergeant (500 - 2000 Reputation Level)gaanee User rank is Sergeant (500 - 2000 Reputation Level)gaanee User rank is Sergeant (500 - 2000 Reputation Level)gaanee User rank is Sergeant (500 - 2000 Reputation Level)gaanee User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 10 h 32 m 44 sec
Reputation Power: 21
Concatenate integer with a character data type

Is there any way in Fortran77 to concatenate an integer with a character data type?
Basically, I'm trying to create filenames in a loop like:
file01.out
file02.out
file03.out
....
.......
for this I need to concatenate 'file' which is a character with 01 which is an integer, and I cannot simply do file//01, since the data types are different.
Is there a way to get around this issue in Fortran77.
is there any function similar to sprintf in F77.

Reply With Quote
  #2  
Old October 20th, 2006, 07:23 AM
mawe mawe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 394 mawe User rank is Sergeant Major (2000 - 5000 Reputation Level)mawe User rank is Sergeant Major (2000 - 5000 Reputation Level)mawe User rank is Sergeant Major (2000 - 5000 Reputation Level)mawe User rank is Sergeant Major (2000 - 5000 Reputation Level)mawe User rank is Sergeant Major (2000 - 5000 Reputation Level)mawe User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 10 h 6 m 47 sec
Reputation Power: 45
Hi!

fortran Code:
Original - fortran Code
    program concat implicit none integer intvar, i character string*2 intvar = 10 do i=1, 10   write(unit=string, fmt='(I2)') intvar   write(*,*) "file" // string // ".out"   intvar = intvar + 1 end do end program concat

I leave the numbers 01 - 09 as an exercise to you (to be honest I have no idea how to do that )

Regards, mawe

Reply With Quote
  #3  
Old January 23rd, 2007, 12:54 PM
rahu rahu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 1 rahu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 37 sec
Reputation Power: 0
Re:Concatenate integer with a character data type

Hi,

I hope it might work.

PROGRAM concatinating_int_char

IMPLICIT NONE
CHARACTER(LEN = 20 ) :: file_name
CHARACTER(LEN = 20 ) :: file_char
INTEGER :: i

file_char = '010203040506070809'
DO i = 1,18,2
file_name = 'output'// file_char(i:i+1)//'.dat'
WRITE(*,*) file_name
END DO

END PROGRAM concatinating_int_char

Enjoy,
Rahu.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Concatenate integer with a character data type


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway