I have finish the QUAD algorithm for outliers detection, but I don't know how to add it to GPSTk, and if you don't mind I can send the codes to you. I've got in trouble with 'segmentation fault' , please give me a hand.

I develop with fortran77 and c/c++ under linux(Redhat 4.2), and my compiler is gcc 3.4.6 and g77 3.4.6. My codes work well in windows, it can be build and link successfully in linux, but a 'segmentation fault' error is returned when I try to run it. Wish you or some one can help me.

Here is my problem in detail:

The subroutine call fortran codes to caculate TEC with IGGSH ionosphere model, it work well run stand alone. When I declare some big structs, the codes totally crashed, and the error is 'segmentation fault'. The error seem to be relate to the big structs, so I wonder how to resize the stack size and heap size of gcc compiler?

void test_iggsh()
   int year=2002;
   int month=6;
   int day=14;
   int hour=0;
   int minute=0;
   double second=30;

   double sta_pos[3]={-2267749.0,5009154.0,3221290.0};
   double sat_pos[3]={2609148,23200370,12464136};
   printf("********** in main()\n");
   printf("%4d %2d %2d %2d %2d %12.5lf\n",year,month,day,hour,minute,second);
   printf("%12.5lf %12.5lf %12.5lf\n",sta_pos[0],sta_pos[1],sta_pos[2]);
   printf("%12.5lf %12.5lf %12.5lf\n\n",sat_pos[0],sat_pos[1],sat_pos[2]);
            // call fortran codes to caculate TEC
   double tec=0.0;
   double delay=atm_ion_iggsh(year,month,day,hour,minute,second,sta_pos,sat_pos,&tec);

            // the following code cause   'segmentation fault' error,they  are big structs
   //YSIMPARAMBUF      sysPara;
   //IGG_KJHJ_BASPARAM   basPara;
   //IGG_KJHJ_INPUT      inputPara;
   //IGG_KJHJ_OUTPUT      outputPara;
   //IGG_KJHJ_USER      userPara;

I know it not about GPSTk, but help please!

-- YanWei - 15 Apr 2009


ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

Hi Yan!

I've never combined Fortran and C++ before, so I don't know much about this issue.

However, what I DO know is that it must be done very carefully. I guess that your problem is not related with your big structs, but with the Fortran subroutine call.

The following link will provide you a detailed tutorial about using C/C++ and Fortran together:

Check it out, follow its guidelines, and tell me what happened.

Regarding your QUAD algorithm, you can send it to me and I'll check it, frame it within GPSTk coding standards (if possible), and upload it with proper attributions.

Please take into account that it must be an original contribution, i.e.: it must be your implementation and not a minor rewrite from some other code, and it must be suitable to be released under a LGPL license.

Also, please send a couple references explaining the algorithm.

You can send them at dagoberto DOT jose DOT salazar AT upc DOT edu . I must warn you that I'll take some time to process and upload it.



-- DagobertoSalazar - 15 Apr 2009


First,thanks for your help! Your guess is right, there is problem in my Fortran subroutine. I tried to debug with GDB, and found that this line cause the problem.


After I comment this line, everything goes well. I've never use gdb before, it's really powerful.

Program received signal SIGSEGV, Segmentation fault.
0x005bab25 in _dl_runtime_resolve () from /lib/
(gdb) where
#0  0x005bab25 in _dl_runtime_resolve () from /lib/
#1  0x00735672 in G77_date_and_time_0 () from /usr/lib/
#2  0x009faffa in igggimp_ (fperd=0xbff9d6d0, fcoef=0xbff9d680, nyear=0xbff9d790, nmonth=0xbff9d794,
    nday=0xbff9d798, ngweek=0xbff9c50c, __g77_length_fperd=80, __g77_length_fcoef=80)
    at f_atm_ion_iggsh.for:1099
#3  0x009f884c in caltecgim_ (fperd=0xbff9d6d0, fcoef=0xbff9d680, x_stat__=0xbff9d7f0,
    y_stat__=0xbff9d7f8, z_stat__=0xbff9d800, x_sat__=0xbff9d7d0, y_sat__=0xbff9d7d8,
    z_sat__=0xbff9d7e0, nyear=0xbff9d790, nmonth=0xbff9d794, nday=0xbff9d798, nhour=0xbff9d79c,
    nminute=0xbff9d7a0, second=0xbff9d7a4, multi=0xbff9d738, add=0xbff9d730, icarry=0xbff9d72c,
    dion1=0xbff9d778, tec_out__=0xbff9d7c8, __g77_length_fperd=80, __g77_length_fcoef=80)
    at f_atm_ion_iggsh.for:109
#4  0x009f87ed in f_atm_ion_iggsh__ (year=0xbff9d790, month=0xbff9d794, day=0xbff9d798,
    hour=0xbff9d79c, minute=0xbff9d7a0, second=0xbff9d7a4, sta_pos__=0xbff9d7f0, sat_pos__=0xbff9d7d0,
    dion=0xbff9d778, tec=0xbff9d7c8) at f_atm_ion_iggsh.for:42
#5  0x0804a841 in atm_ion_iggsh (year=2002, month=6, day=14, hour=0, minute=0, second=30,
    sta_pos=0xbff9d7f0, sat_pos=0xbff9d7d0, tec=0xbff9d7c8) at c_atm_ion_iggsh.c:43
#6  0x08097ceb in test_iggsh () at test_gnss_main.cpp:115
#7  0x08097bad in main () at test_gnss_main.cpp:54

To be honest, I have to tell you that the QUAD algorithm was reported by Ji-Kun Ou originally, and have been studied by several PHD, Yan-Ju Chai,Jian-Feng Guo,Ai-Sheng Wang etc. The algorithm I impliment was present by Jian-Feng Guo in his doctal thesics:Theory of Model Errors and Its Applications in GPS Data Processing. And after I impliment the code, I check it with Guo's matlab code.

I don't know whether the algorithm implimentation be suitable to be released under a LGPL license. Anyway, I'll contact with the author Jian-Feng Guo and ask his opinion. If he aggree, I'll send your the code and papers.

By the way, QUAD is really a powerful algorithm that can detect multi-gross errors an the same time, I wish more people can know it and use it.

Thanks again, Cheers!

Best Regards,


-- YanWei - 15 Apr 2009

Hi Dago!

On Apr,25th 2009,I sent you a email with the QUAD codes and references in the attachment, please check your email box,' dagoberto DOT jose DOT salazar AT upc DOT edu '. If you receive the email, please let me know, else I'll resend it. Thank you.



-- YanWei - 27 Apr 2009



-- DagobertoSalazar - 28 Apr 2009 No such template def TMPL:DEF{PROMPT:supportquery}

Topic revision: r7 - 28 Apr 2009, DagobertoSalazar

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback