| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| in my code , i need to read few files named POT_A,POT_B and so on. i was thinking about change the variable part as fi=ACHAR(i+16+48) to get the variable A,B etc. but how can i have the name POT_A etc? can any1 help me on that? |
|
#2
| |||
| |||
| On 20 aug, 13:31, rudra <bnrj.ru...@gmail.com> wrote: > in my code , i need to read few files named POT_A,POT_B and so on. > i was thinking about change the variable part as > > fi=ACHAR(i+16+48) > > to get the variable A,B etc. but how can i have the name POT_A etc? > can any1 help me on that? IACHAR('A') gives you the integer value for 'A'. So: do i = 1,26 chr = achar(iachar('A')+i-1) ! Successive letters filename = 'pot_' // chr enddo would loop through the alphabet. Or, perhaps easier: character(len=26) :: alphabet = 'ABC...' do i = 1,26 filename = 'pot_' // alphabet(i:i) enddo Regards, Arjen |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.