<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Assumed-length character functions in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972853#M24382</link>
    <description>The 'i0' edit descriptor isn't standard, is it?</description>
    <pubDate>Tue, 06 Nov 2001 07:09:16 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2001-11-06T07:09:16Z</dc:date>
    <item>
      <title>Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972851#M24380</link>
      <description>I was searching the forum for threads on assumed-length CHARACTER functions and found a link to an e-newsletter with the following: &lt;BR /&gt; &lt;BR /&gt;"Assumed-length CHARACTER functions (and the CHARACTER* form of declaration) are deemed to be an "irregularity" in the language, which they are, and there are alternatives available, but Dr. Fortran doesn't see these disappearing from users' code anytime soon." &lt;BR /&gt; &lt;BR /&gt;Can anyone enlighten me on the proper Fortran 95 alternatives?  I want a function that returns an integer as a character string with no leading or trailing blanks.   &lt;BR /&gt; &lt;BR /&gt;Thanks, &lt;BR /&gt; &lt;BR /&gt;Andy</description>
      <pubDate>Tue, 06 Nov 2001 03:39:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972851#M24380</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-06T03:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972852#M24381</link>
      <description>The character(*) result form will not do what you want.  Here is some code that will work for and KIND of integer, although unfortunately it doesn't work in the current version of CVF.  Hopefully it will work in the next release.  BTW Steve, there were a couple of bugs encountered in some previous threads that weren't explicitly acknowledged as such in this forum (renaming MATMUL and improper arguments to the ASSOCIATED intrinsic.)  Have these been fixed in the next version of CVF or should I send bug reports? &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt;&lt;FONT size="+0"&gt; 
! File: int2string.fi 
pure function int2string_len(i) 
   integer int2string_len 
   integer(template_kind), intent(in) :: i 
   character(20) string 
 
   write(string,'(i0)') i 
   int2string_len = len_trim(adjustl(string)) 
end function int2string_len 
 
function int2string(i) 
   integer(template_kind), intent(in) :: i 
   character(int2string_len(i)) int2string 
 
   write(int2string,'(i0)') i 
end function int2string 
! End of file: int2string.fi 
 
! File: int2string.f90 
module mykinds 
   implicit none 
   integer, parameter :: ik1 = selected_int_kind(2) 
   integer, parameter :: ik2 = selected_int_kind(4) 
   integer, parameter :: ik4 = selected_int_kind(9) 
   integer, parameter :: ik8 = selected_int_kind(18) 
end module mykinds 
 
module ik1_mod 
   use mykinds, only: template_kind =&amp;gt; ik1 
   implicit none 
   private 
   public int2string 
   contains 
      include 'int2string.fi' 
end module ik1_mod 
 
module ik2_mod 
   use mykinds, only: template_kind =&amp;gt; ik2 
   implicit none 
   private 
   public int2string 
   contains 
      include 'int2string.fi' 
end module ik2_mod 
 
module ik4_mod 
   use mykinds, only: template_kind =&amp;gt; ik4 
   implicit none 
   private 
   public int2string 
   contains 
      include 'int2string.fi' 
end module ik4_mod 
 
module ik8_mod 
   use mykinds, only: template_kind =&amp;gt; ik8 
   implicit none 
   private 
   public int2string 
   contains 
      include 'int2string.fi' 
end module ik8_mod 
 
module generic_recombination 
   use ik1_mod, only: int2string_ik1 =&amp;gt; int2string 
   use ik2_mod, only: int2string_ik2 =&amp;gt; int2string 
   use ik4_mod, only: int2string_ik4 =&amp;gt; int2string 
   use ik8_mod, only: int2string_ik8 =&amp;gt; int2string 
   implicit none 
   interface int2string 
      module procedure int2string_ik1, int2string_ik2, &amp;amp; 
                       int2string_ik4, int2string_ik8 
   end interface int2string 
end module generic_recombination 
 
program int2string_prog 
   use generic_recombination 
   use mykinds 
   implicit none 
 
   write(*,'(a)') ' #'//int2string(-1_ik1)//'#' 
   write(*,'(a)') ' #'//int2string(-1_ik2)//'#' 
   write(*,'(a)') ' #'//int2string(-1_ik4)//'#' 
   write(*,'(a)') ' #'//int2string(-1_ik8)//'#' 
   write(*,'(a)') ' #'//int2string(huge(1_ik1))//'#' 
   write(*,'(a)') ' #'//int2string(huge(1_ik2))//'#' 
   write(*,'(a)') ' #'//int2string(huge(1_ik4))//'#' 
   write(*,'(a)') ' #'//int2string(huge(1_ik8))//'#' 
end program int2string_prog 
! End of file: int2string.f90 
 
Output (on a compiler where this works) 
 
#-1# 
#-1# 
#-1# 
#-1# 
#127# 
#32767# 
#2147483647# 
#9223372036854775807# 
&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Nov 2001 06:31:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972852#M24381</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-06T06:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972853#M24382</link>
      <description>The 'i0' edit descriptor isn't standard, is it?</description>
      <pubDate>Tue, 06 Nov 2001 07:09:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972853#M24382</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-06T07:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972854#M24383</link>
      <description>The 'i0' edit descriptor is standard f95.  CVF supports it since v. 6.0.  It's kind of difficult to find this in Compaq's documentation, though.  I can see it under Index | Edit descriptors | I and then selecting 'General rules for numeric editing' at the bottom of the page, and then the behavior is in &lt;FONT color="#00FF00"&gt;green&lt;/FONT&gt; near the bottom... probably this feature could have been more prominently documented, since I use 'i0' more than any other form of integer edit descriptor.</description>
      <pubDate>Tue, 06 Nov 2001 07:48:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972854#M24383</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-06T07:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972855#M24384</link>
      <description>&lt;B&gt;BTW Steve, there were a couple of bugs encountered in some previous threads that weren't explicitly acknowledged as such in this forum (renaming MATMUL and improper arguments to the ASSOCIATED intrinsic.) Have these been fixed in the next version of CVF or should I send bug reports? &lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;You should always send bug reports.  I don't recall the specific issues you're referring to from discussions in the forum, so it's best to send specific examples to vf-support@compaq.com.  I may not catch everything written in the forum.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 06 Nov 2001 08:03:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972855#M24384</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-11-06T08:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972856#M24385</link>
      <description>Andy,  &lt;BR /&gt;  &lt;BR /&gt;Here is a somewhat simpler solution depending upon your needs:  &lt;BR /&gt;  &lt;BR /&gt;&lt;P&gt;&lt;PRE&gt;&lt;FONT size="+0"&gt;  
CHARACTER(20) :: STRING  
WRITE (STRING,'(A)') '    123456789     '  
STRING = ADJUSTL(STRING)  
L           = LEN_TRIM(STRING)  
WRITE (*,'(A)') '#'//STRING(1:L)//'#'  
&lt;/FONT&gt;&lt;/PRE&gt;  &lt;BR /&gt;  &lt;BR /&gt;The downside is that you have to access STRING with array subscripts from 1 to L everywhere you want to use this in the code.  &lt;BR /&gt;  &lt;BR /&gt;Tom  &lt;BR /&gt;  &lt;BR /&gt;You should easily be able to turn this into a function or a subroutine.  The only downside is that you have to reference each string with (1:L)&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2001 23:53:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972856#M24385</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-06T23:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972857#M24386</link>
      <description>Andy,  &lt;BR /&gt;  &lt;BR /&gt;Here is a somewhat simpler solution depending upon your needs:  &lt;BR /&gt;&lt;P&gt;&lt;PRE&gt;&lt;FONT size="+0"&gt;  
CHARACTER(30) :: STRING  
WRITE (STRING,'(A)') '    123456789    '  
STRING = ADJUSTL(STRING)  
L      = LEN_TRIM(STRING)  
WRITE (*,'(A)') '#'//STRING(1:L)//'#'  
  
OUTPUT:  
#123456789#  
&lt;/FONT&gt;&lt;/PRE&gt;  &lt;BR /&gt;  &lt;BR /&gt;The downside is that you have to reference STRING throughout the rest of the code using the (1:L) substring in order to eliminate the trailing blanks.  &lt;BR /&gt;  &lt;BR /&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2001 00:01:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972857#M24386</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-07T00:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972858#M24387</link>
      <description>Sorry about the double message - sometimes this forum leaves a lot to be desired, but it is great to have anything that can be used as an additional resource. &lt;BR /&gt; &lt;BR /&gt;Tom</description>
      <pubDate>Wed, 07 Nov 2001 00:04:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972858#M24387</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-07T00:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972859#M24388</link>
      <description>Sigh...why is it so difficult to get 5 lines of code correct?  Here is what I should have posted &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
CHARACTER(30) :: STRING 
I = 123456789 
WRITE (STRING,'(I0)') I 
L = LEN_TRIM(STRING) 
WRITE (*,'(A)') STRING(1:L) 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;Tom</description>
      <pubDate>Wed, 07 Nov 2001 00:29:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972859#M24388</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-07T00:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972860#M24389</link>
      <description>Thanks to James Van Buskirk for the program - it does work OK in CVF6.6 except that CVFseems to have a problem in generating HUGE for Integer*8 in some, but not all places.  If one repllaces "huge(1_ik8)" in the last print line with "n" (without the inverted commas) where n is Integer*8 and is set to 2**63-1, you will get JVB's complete output. &lt;BR /&gt; &lt;BR /&gt;Bear of little brain</description>
      <pubDate>Sat, 10 Nov 2001 05:45:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972860#M24389</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-10T05:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assumed-length character functions</title>
      <link>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972861#M24390</link>
      <description>Whoops.  I assumed that this wouldn't compile due to other bugs (15493 and 15596) so I didn't actually try compiling it with CVF.  Neither of them have any effect here.  The bug that affects this code is new to me (16161.)</description>
      <pubDate>Sat, 10 Nov 2001 11:12:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Assumed-length-character-functions/m-p/972861#M24390</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-11-10T11:12:54Z</dc:date>
    </item>
  </channel>
</rss>

