lanl / LaGriT

Los Alamos Grid Toolbox (LaGriT) is a library of user callable tools that provide mesh generation, mesh optimization and dynamic mesh maintenance in two and three dimensions.
https://lanl.github.io/LaGriT/
Other
116 stars 48 forks source link

cmo_get_info return of REAL looks wrong #241

Open millerta opened 2 years ago

millerta commented 2 years ago

A few strange things.

REAL value is being assigned to returning ipout as integer value. Is this intentional (and will give wrong values) or just never used and never noticed? I removed the nint() for REAL, it might have come from cmo_get_intinfo code copy.

cmo_get_info() returns mesh object values correctly for INT, VINT, and VDOUBLE but fails for REAL values such as epsilonl

Note this should be resolved, but for now is just a user caution. lagrit codes do not use cmo_get_info to get REAL values from mesh object. Instead codes use cmo_get_attinfo()

millerta commented 2 years ago

cmo_get_info is used throughout lagrit codes to get mesh data for both integer and real8 memory arrays including imt1 and xic. It is also used to return integer values such as nnodes and nelements. All through argument declared as: pointer (ipout,out) real8 out(*)

cmo_get_info works for arguments defined as pointer (ipout,out) real8 out() for memory arrays VINT and VDOUBLE for arguments passed as integer and returning INT but gets wrong result passed as real8 or real8 pointer returning REAL

Correct result for INT nnodes where ipout is called with integer iout:

 Size of cmo_get_info parameters.
 cray pointer ipout:        8
 return nnodes:             27
ilen,ityp,ierr:     1    1       0

Wrong result for REAL epsilonl where ipout is called as real8 or pointer (ipout,out) real8 out(*)

cray pointer ipout:        8
value :    1.9229626863835638E-013
ilen,ityp,ierr:    1     2     0
millerta commented 2 years ago

cleaned code and changed to avoid multiple line calculations by using variable iindex. The values within cmo_get_info for REAL look good in print statements, but returned value outside routine is garbage.

cmo_get_info REAL ------------------------------
 REAL cmo_get_info: xmax
 mmfindbk icscode :                     0
 attparam:    1.5000000000000000
 out val :                     1
 lout,itype:                   1                 2

return: xmax: real*8 xreal   4.9406564584124654E-324