How To Turn On Word Wrap Dev C++

@mstuff63 As to your program to do word wrap - it would be easier if you just broke up the line you read in into individual words (tokenize the line, maybe placing each word in an entry in a vector). Then starting with an empty line, place each word on the line until you get an overflow on the line. Then you wrap to the next line and continue. Apr 06, 2009  Word wrap in Dev C Forum: Bloodshed Software Forum. Creator: Holly Benton. I no longer use Dev-C or have it installed) has an option to enable/disable line wrapping. It is not on by default, so you must presumably have set it. Line wrapping is a really bad idea in a code editor IMO, I cannot think of a good reason to have it, but most. How can i make the ide word wrap when i am writing lines of code, the code goes so far in width that I have to use the arrow button on my keyboard to see the end of line dev c 4.9.9.2 windows xp. May 22, 2014  /. This function takes a string and an output buffer and a desired width. It then copies the string to the buffer, inserting a new line character when a certain line length is reached. If the end of the line is in the middle of a word, it will backtrack along the string until white space is found. Changing word wrap mode. // To turn word wrap on - based on target device (e.g. Virus ti vst mac download. Printer) // mdcTarget is the device context, mlineWidth is the line width SetTargetDevice(mdcTarget. 3 Understanding the Intricacies of Multiple Inheritance in C; 4 MessageQueue in.NET, Part 2: The Code.

FORTRANC/C++
byteunsigned char
integer*2short int
integerlong int or int
integer iabc(2,3)int iabc[3][2];
logicallong int or int
logical*1bool
(C++, One byte)
realfloat
real*8double
real*16long double
complexstruct{float realnum; float imagnum;}
double complexstruct{double dr; double di;}
character*6 abcchar abc[6];
character*6 abc(4)char abc[4][6];
parameter#define PARAMETERvalue

This table shows the appropriate types to use for FORTRAN and C/C++ interoperability.

Order of multi dimensional arrays in C/C++ is the opposite of FORTRAN.

Native FORTRAN layout (collumn-major order): INTEGER A(2,3)
a(1,1)a(2,1)a(1,2)a(2,2)a(1,3)a(2,3)
Or INTEGER A(2,2,2)
a(1,1,1)a(2,1,1)a(1,2,1)a(2,2,1)a(2,2,1)a(1,1,2)a(2,1,2a(1,2,2)a(2,2,2)
Native C layout (row-major order) is NOT equivalent to the FORTRAN layout: int a[2][3];
a[0][0]a[0][1]a[0][2]a[1][0]a[1][1]a[1][2]
Thus:
  • Equivalent multidimension arrays:
    • FORTRAN 77: INTEGER I(2,3,4)
    • FORTRAN 90: INTEGER, DIMENSION(2,3,4) :: I
    • C: int i[4][3][2];
  • Accessing a FORTRAN array in C:
    Native FORTRAN:
    Native C: C array a[3][2] memory layout:
    a[0][0]a[0][1]a[1][0]a[1][1]a[2][0]a[2][1]
  • In FORTRAN 90, also check out the 'RESHAPE' directive.
  • It is best not to re-dimension multi dimensional arrays within a function. Pass array size 'n' and declare array as x[n][];
Linking FORTRAN And C Subroutines:

Fortran subroutines are the equivalent of 'C' functions returning '(void)'.

Note: The entry point names for some FORTRAN compilers have an underscore appended to the name.This is also true for common block/structure names as shown above.

FORTRANC
CALL SUBRA( .. )subra_( .. )

The GNU gfortran comiler flags '-fno-underscoring' (older f77: '-fno-underscore') and '-fno-second-underscore'will alter the default naming in the object code and thus affect linking.One may view the object file with the command nm (i.e.: nm file.o).

Note: The case in FORTRAN is NOT preserved and is represented in lower case in the object file. The gfortran compiler option '-fcase-lower is default.The older g77 compiler option '-fsource-case-lower' is also default.GNU g77 FORTRAN can be case sensitive with the compile option '-fsource-case-preserve'.

NOTE: When debugging with GDB, the Fortran subroutines must be referencedwith names as they appear in the symbol table. This is the same as the 'C'representation. Thus when setting a break point at the Fortran subroutine subra(), issue the comand 'break subra_'.

Man pages:

  • nm - list symbols from object files
  • gfortran - GNU FORTRAN compiler man page

All arguments in FORTRAN are passed by reference and not by value. Thus C must pass FORTRAN arguments as a pointer.

FORTRANC
call subra( i, x)subra_( int *i, float *x)

Character variables:

  • Linux and GNU compilers:When passing character strings, the length must follow as separate arguments which are passed by value.
    FORTRANC
    call subra( string_a, string_b)len_a = strlen(string_a);
    len_b = strlen(string_a);
    subra_( char *string_a, len_a, char *string_b, len_b)

    I have also seen the passing of a data structure containing two elements, the character string and an integer storing the length. This is common with databases such as Oracle.

  • Classic AT&T UNIX:
    When passing character strings, the length must be appended as separate arguments which are passed by value.
    FORTRANC
    call subra( string_a, string_b)subra_( char *string_a, char *string_b, len_a, len_b)

C expects strings to be null-terminated. Thus character strings from FORTRAN which are passed back to 'C' should be null terminated with CHAR(0)

Alternate Returns:
FORTRANC

Note:When using alternate returns to turn on/off an intlevel by returninga 1/0 you must use a FORTRAN wrapper to perform this function on theCSC Norwich mainframe. This is because the C compiler is old.

Buffering output: Your machine may be configured where the output buffering defaults for FORTRAN and C may be configured the same or differently. C output may be buffered buffered while FORTRAN may not. If so, execute a function initialization task to unbuffer C otherwise print statements for Cwill be output out of order and at the end.

Fortran common block and global C/C++ extern structs of same name are equivalent.Never use un-named common blocks! Reference variables in same order, same typeand with the same name for both C and FORTRAN.Character data is aligned on word boundaries.

Note: use of extern requires that the common block be referenced firstby FORTRAN. If referenced first by C then drop the extern. The externstatement states that it is trying to reference memory which has alreadybeen set aside elsewhere.

[Potential Pitfall]: Bytealignment canbe a source of data corruption if memory boundaries between FORTRAN andC/C++are different. Each language may also align structure data differently.One must preserver the alignment of memory between the C/C++ 'struct'and FORTRAN 'common block' by ordering the variables in the exact sameorder and exactly matching the size of each variable.It is best to order the variables from the largest word size down tothe smallest. Start with 'double' followed by 'float' and 'int'. Booland byte aligned data should be listed last.

Using GDB to examine alignment:

  • Set a breakpoint in the C/C++ section of code which has visibility to the struct.
  • While in a C/C++ section of code: (gdb) print &abc_.b
    $3 = (int *) 0x5013e8
  • Set a breakpoint in the FORTRAN section of code which has visibility to the common block.
  • While in a FORTRAN section of code: (gdb) print &b
    $2 = (PTR TO -> ( integer )) 0x5013e8
This will print the hex memory address of the variable as C/C++ andFORTRAN view the variable. The hex address should be the same for both.If not, the data will be passed improperly.

Forcing alignment with compiler arguments: Mixing IntelFORTRAN compiler and GNU g++: use the following compiler flags to forcea common memory alignment and padding to achieve a common double wordalignment of variables:

  • Intel FORTRAN: -warn alignments -align all -align rec8byte
  • Intel C/C++: -Zp8
  • GNU g++: -Wpadded -Wpacked -malign-double -mpreferred-stack-boundary=8
    Example warning: warning: padding struct size to alignment boundary
  • GNU g77: -malign-double
Example:

FORTRAN program calling a C function:

testF.ftestC.c

Compile:

  • gfortran -c testF.f
  • gcc -c testC.c
  • gfortran -o test testF.o testC.o

How To Turn On Word Wrap Dev C File

Note: If there is use of C/C++ standard libraries you may have to include the following linking arguments: -lc or -lstdc++

Run: ./test

[Potential Pitfall]: If one does not terminate the string with NULL, the default with the new compilers (fort77 1.15 and gcc 4.5.2) and linker is to terminate the string with '004' which is EOT (end of transmission). Previously this was not required but it is now. This code (cc[ll--] = '0';) replaces the string terminating EOT character with a NULL.

C++ calling a FORTRAN function:

testC.cpptestF.f

Compile:

  • gfortran -c testF.f
  • g++ -c testC.cpp
  • g++ -o test testF.o testC.o -lg2c

Run: ./test

FORTRAN unit numbers can not be shared with 'C' and 'C' file pointers can not be used by FORTRAN. Pass data to a function (pick one language) which does the I/O for you. Use this function by both languages.

Word Wrap Html

VAX Extensions:

The GNU FORTRAN compilers have only ported a small subset of VAX extensions.The vast majority will require a clever re-write.

VAX Variable Format Expressions:

VAX expressionPorted to GNU FORTRAN

VAX intrinsic functions:

Many are not supported in GNU FORTRAN and require the creation of an equivalent library written in 'C'.
Return typeVAX FORTRAN intrinsic functionArgument type
Integer*4NINT(arg)
JNINT(arg)
Real*4
Integer*4IDNINT(arg)
JIDNINT(arg)
Real*8
Integer*2ININT(arg)Real*4
Integer*8KNINT(arg)Real*4
Integer*2IIDNNT(arg)Real*8
Integer*8KIDNNT(arg)Real*8
Integer*2IIQNNT(arg)Real*16
Integer*4IQNINT(arg)
JIQNNT(arg)
Real*16
Integer*8KIQNNT(arg)Real*16

Example: inint.c

  • gcc -c inint.c
  • gcc -c idnint.c
  • ..
  • Create library: ar -cvq libvax.a inint.o idnint.o ..

When mixing Fortran with C++, name mangling must be prevented.

For more on C++ name mangling, see the YoLinux.com C++ name mangling discussion.
The GNU FORTRAN compiler:

The GNU FORTRAN compilers have supported the various standards over the years. The current (RHEL6 and Ubuntu 14.04) GNU gfortran compiler supports f95, f2003 and f2008 standards.By default, gfortran supports a superset of f95. Use the '-std=' flag to specify other levels of support.The older (RHEL4) GNU FORTRAN compiler supported the f77 standard.

Installation:

  • Red Hat/CentOS: yum install gcc-gfortran
  • Ubuntu/Debian: apt-get install gfortran

The Intel FORTRAN compilerhas become a popular FORTRAN compiler for Linux as it supports many ofthe FORTRAN extensions supported by the Compaq (old DEC vax) and SGIFORTRAN compilers. (i.e. 'structure', 'record', 'external', 'encode','decode', 'find', 'virtual', 'pointer', 'union', various intr8insicfunctions, I/O directives, ..)It links with object code generated by GNU gcc/g++ compilers as well astheir own Intel C/C++ compilers.

Word Art

Installation:

(as root)
  • mkdir /opt/intel
  • cd /opt/intel
  • move Intel Fortram compiler tar ball to this directory.
  • tar xzf 1_fc_c_9.0.033_ia32.tar.gz
  • cd 1_fc_c_9.0.033/
  • ./install.sh
    1 : Install
    2 : provide name of an existing license file.
    License file path :
    /path-to-license-file/commercial_for_1_F2WC-5FDZV87R.lic
    (file copied to /opt/intel/licenses)
    1 (typical installation)
    Type 'accept' to agree to license terms.
    Accept default location: /opt/intel/fc/9.0
    Accept default location: /opt/intel/idb/9.0
    x : Installation done

Compiler use and user configurations:

File: $HOME/.bashrc

File: MakefileWord (snipet) Intel compiler directives:
DirectiveDescription
-extend_sourceLength of line in source file allows for greater than 72 characters.
-vaxVAX FORTRAN runtime behavior. Changes read behavior. I never use this.
-f77rtlFORTRAN 77 runtime behavior.
-fppRun preprocessor. i.e. handles #define and #ifdef macros.
-intconstantUse FORTRAN 77 semantics to determine the kind of parameter for integer constants.
-ftzFlushes denormal results to zero.
-pad-sourceSpecifies that fixed-form sourcerecords shorter than the statement field width should be padded withspacs (on the right) to the end of the field.
-lowercaseAll function names are represented as lower case symbols.
-soxStore compiler options and version in the executable.
-warn alignmentsWarning if COMMON block records require padding for alignment.
-align allWill get rid of warning: 'Because of COMMON, the alignment of object is inconsistent with its type [variable-name]
This requires a matching alignment for all code which links with this, C, C++ or FORTAN.

Use GNU g++ or Intel C++ compiler to compile and link with main():
g++ -o name-of-exe main_prog.cpp file1.o file2.o -L/opt/intel/fc/9.0/lib -lifport -lifcore -limf -Wabi -Wcast-align

Using ddd as a front-end for the Intel debugger:

ddd --debugger '/opt/intel/idb/9.0/bin/idb -gdb' exe-file

[Potential Pitfall]: I found thatI could not install the Intel FORTRAN compiler from an NFS mounteddrive. I had to copy the Intel installation files to a local drive andinstall from there.

Is there a program like little snitch on windows 10. Documentation: /opt/intel/cc/9.0/doc/main_for/mergedProjects/bldaps_for/

  • FORTRAN GL API: (SGI GL library emulation for Linux)
    • YGL: Written in X11 (2D) and OpenGL (3D) for C and FORTRAN
Books:
'Introduction to Programming with Fortran'
with coverage of Fortran 90, 95, 2003 and 77
by Ian Chivers, Jane Sleightholme
Springer; 1st edition, ISBN# 1846280532

'FORTRAN 90 for Scientists and Engineers'
by Brian Hahn
Butterworth-Heinemann, ISBN# 0340600349

'Introduction to FORTRAN 90 for Engineers and Scientists'
by Larry R. Nyhoff, Sanford Leestma
Prentice Hall; 1st edition, ISBN# 0135052157

Please enable JavaScript to view the comments powered by Disqus.