I expanded the code trials a bit more, putting in a few variations, explicit use of the non-blank length (len_trim), etc.
The results, while clear, are not consistent. Using len_trim() to set the character count is no better than using trim(), but using trim() then concatenating those results appears to work just fine.
Code:
!FTN95 application...
PROGRAM main
external my_routine
integer*4 my_routine
character*256 raw_data
character*12 quad
character*4 state
integer i,j
logid=1
quad='hndsh'
state='ky'
raw_data = ' xyz'
99000 format(z16)
write(*,99000)my_routine()
print *,'Use 2 trim() calls'
WRITE(*,55055)trim(quad),trim(state),'0'
55055 format(a,a,a)
write(*,99000)my_routine()
print *,'Trim and len_trim',trim(quad),logid,state(1:len_trim(state))
write(*,99000)my_routine()
print *,'Use len_trim',quad(1:len_trim(quad)),logid,state(1:len_trim(state))
write(*,99000)my_routine()
i=len_trim(quad)
j=len_trim(state)
print *,'Used len_trim to get lexplicit engths'
write(*,99000)my_routine()
print *,'Use explicit lengths',quad(1:i),logid,state(1:j)
write(*,99000)my_routine()
raw_data = quad//state//trim(raw_data)
print *,'Concatenation only as assignment'
write(*,99000)my_routine()
print *,'concat trims and print',trim(quad)//trim(state)!//trim(raw_data)
write(*,99000)my_routine()
print *,'Just plain print',quad,state
write(*,99000)my_routine()
print *,'trim only quad',trim(quad),state
write(*,99000)my_routine()
print *,'trim only quad, output state twice',trim(quad),state,state
write(*,99000)my_routine()
print *,'len_trim only quad',quad(1:i),state
write(*,99000)my_routine()
END PROGRAM main
integer function my_routine()
integer i
code
mov eax%,esp%
mov i,eax%
edoc
my_routine = i
return
end
Results:
360F578
Use 2 trim() calls
hndshky0
360F568
Trim and len_trimhndsh 1ky
360F558
Use len_trimhndsh 1ky
360F548
Used len_trim to get lexplicit engths
360F548
Use explicit lengthshndsh 1ky
360F538
Concatenation only as assignment
360F538
concat trims and printhndshky
360F538
Just plain printhndsh ky
360F538
trim only quadhndshky
360F538
trim only quad, output state twicehndshky ky
360F538
len_trim only quadhndshky
360F538
By trying different numbers of trim() strings and other variables, the number of variables that affect the stack (i.e. the trim() or len_trim() ones) are affected by the number of successfully output data of other types, including character data. Given the right number of each, the stack is unaffected.
So, for me, at least at this time, there is no good fix for the code, other than using the /RELEASE version.