s.db.rim memory problems fortran/c routines
Vannessa Chewings
Vannessa.Chewings at its.csiro.au
Tue Sep 15 01:56:58 EDT 1992
Subject: s.db.rim fortran/c problems
Can anyone help with s.db.rim problems?
We are using Interactive Unix on a 486 and Salford Fortran v1.19
I managed to get RIM going and only needed to change upcase and
the inquire statement but s.db.rim has beaten me!
Any suggestions will be VERY gratefully received!
Vanessa Chewings
CSIRO Division of Wildlife and Ecology
Alice Springs, NT 0871 Australia
ph 61 89 524255 fax 61 89 529587
che076 at its.csiro.au
The problems occur when calling Fortran subroutines from C namely,
asctxt.f and strasc.f. Although I can get parameters passed quite happily
with small test programs pointers seem to get lost here.
Specifically there are 2 problems:
1. in fill_buf_t there is a core dump on G_malloc unless free is
commented out. At one stage it seemed to work without the last text_length
parameter on asctxt but I took some trace statements out and it bombed again!
2. If we get passed this, column.type does not return correctly from strasc.
strasc called from retr_buf_t from ret_f_table from get_field_info
from make_done.
For s.db.rim I have made the following changes:
C can call Salford Fortran routines if a call to ftn77init() is made first.
However to access the Fortran /tupler/ and rimcom.d common blocks
from C (the extern int statements gave an undefined symbol) I added
a couple of fortran subroutines to pass the location of the common blocks.
(1)In rim.h:
extern long int rimcom changed to long int *rimcom
extern long int tupler changed to long int *tupler
(2)In toplevel.c :
ftn77init_();
tupler=tuple1(&nump);
rimcom=rimcof(&nump);
(3) SUBROUTINE RIMCOF(RMST)
IMPLICIT INTEGER (A-Z)
COMMON /RIMCOM/RMSTAT
RIMCOF=LOC(RMSTAT)
RETURN
(4) subroutine TUPLE1(numb)
implicit integer (A-Z) PARAMETER (Z=4)
COMMON /TUPLER/ NAME(Z),RDATE,RPW(Z),MPW(Z),NCOL,NATT,
1 NTUPLE,RSTART,REND
integer*4 numb in db_size.c
PARAMETER (ZTUPAR=3*Z+6) changed number=
tuple1=LOC(NAME) *(&tupler + ((3*4)+4-1)); to
return
end
(5)in crim.c int rmstat
rmstat=((long *)rimcom)[0];
return(rmstat);
used to be return(rimcom_)
(6)in db_size.c
changed number=*(&tupler + ((3*4)+4-1)); to
number=((long *)tupler)[15];
(7)in backup.c getwd changed to getcwd(pathname,64)etc
(8)In fill_buf_t the pointer to text_buf was changed after asctxt (Fortran)
reulting in a core dump at free.
Changed asctxt(buffer_loc,&text_length,text_buf,text_length)
to asctxt(buffer_loc,&text_length,text_buf)
(this only worked for a while - not any more!)
I have an input file very similar to the Archaelogical Database in
the s.db.rim entry in the GRASS Reference Manual and can supply details
of output if anyone is interested???
I have not been able to use the Salford fortran debugger with s.db.rim
(although it works fine with RIM) so this is taking longer than expected.
Any advice would be appreciated.
Vanessa Chewings
cat mess
.end
More information about the grass-dev
mailing list