Copy-in , copy-out (nl2sol)

Copy-in , copy-out (nl2sol)

Nl2sol is a popular routine for unconstrained non-linear least-squares. This routine was ported from A. Miller to Fortran 90 with the following warning:


Use this code with care.

Some compilers use `copy in, copy out' where the INTENT of an array
is IN OUT. A call such as:

CALL l7vml(p, v(g1:), v(rmat1:), v(qtr1:))

which occurs in routine RN2G, can result in routine l7vml copying the
whole of the array v from location g1 to one place, the whole of the
same array from location rmat1 to another place, and the whole of the
array from location qtr1 to another place. On exit from l7vml, the
contents of these temporary workplaces are then written back to array
v with partial overwriting.

This can be overcome either by replacing the call with something like:

CALL l7vml(p, v(g1:g2), v(rmat1:rmat2), v(qtr1:qtr2))
Try the test programs T_SHORT and T_LONG with your compiler.
If it crashes, then you cannot use this code. Most compilers do not
use `copy in, copy out', so this code works. At least one major compiler
does give trouble. The problem is not with the compiler but with this
I tried the test program t_long with Visual Fortran (default options). It crashed when calculating one of the last examples.

Finally my question:
Does Visual Fortran use copy in/copy out or does anyone uses nl2sol?
Can I use certain compiler options to avoid copy in/copy out?`


Ralf Fritschen

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

CVF will use copy-in/copy-out if, 1) It does not know that the array section being passed is contiguous, 2) there is no interface for the called routine or the interface does not specify a deferred-shape array for the argument

In 6.6, an optional run-time informational can be generated when the compiler chooses to make a copy.


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today