hexagon logo

PCL; is there a string formatting which can produce 8 digits Nastran exponentials?

PCL; is there a string formatting which can produce 8 digits Nastran exponentials?
Parents
  • Here is my second thoughts on doing this - just posting so that both ideas are in the same discussion.
    FUNCTION r2nas8(invalue)
      REAL value(1)
      REAL invalue
      REAL logval
      REAL absval
      STRING sval[18]
      STRING retstring[8]
      INTEGER sdig
      INTEGER ints(1)
      INTEGER i10
      INTEGER status
      STRING fmtstr[50]
       
      value(1) = invalue
      absval = abs(value(1))
      IF ( absval == 0.0) THEN return "  0.0 "
      logval = log(abs(value(1)))
      i10 = logval
        
      sdig = 0
      IF (value(1) < 0.) then
        sdig =-1
      END IF
       
      IF ( i10 <= -9 ) then
        sdig += 3
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 <= -1) then
        sdig += 4
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 < 6) then
        sdig += 6 - i10
        fmtstr="%F8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 < 10) then
        sdig += 4
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE
         sdig += 3
        fmtstr="%E8."//str_from_integer(sdig)//"C%"  
      ENDIF
       
      status = string_write(fmtstr, ints, value, "", sval) 
     
      IF ( status > 0 ) THEN RETURN "CnvERROR"
       
      retstring=sval
      RETURN retstring
    END FUNCTION
Reply
  • Here is my second thoughts on doing this - just posting so that both ideas are in the same discussion.
    FUNCTION r2nas8(invalue)
      REAL value(1)
      REAL invalue
      REAL logval
      REAL absval
      STRING sval[18]
      STRING retstring[8]
      INTEGER sdig
      INTEGER ints(1)
      INTEGER i10
      INTEGER status
      STRING fmtstr[50]
       
      value(1) = invalue
      absval = abs(value(1))
      IF ( absval == 0.0) THEN return "  0.0 "
      logval = log(abs(value(1)))
      i10 = logval
        
      sdig = 0
      IF (value(1) < 0.) then
        sdig =-1
      END IF
       
      IF ( i10 <= -9 ) then
        sdig += 3
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 <= -1) then
        sdig += 4
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 < 6) then
        sdig += 6 - i10
        fmtstr="%F8."//str_from_integer(sdig)//"C%"
      ELSE IF ( i10 < 10) then
        sdig += 4
        fmtstr="%E8."//str_from_integer(sdig)//"C%"
      ELSE
         sdig += 3
        fmtstr="%E8."//str_from_integer(sdig)//"C%"  
      ENDIF
       
      status = string_write(fmtstr, ints, value, "", sval) 
     
      IF ( status > 0 ) THEN RETURN "CnvERROR"
       
      retstring=sval
      RETURN retstring
    END FUNCTION
Children
No Data