LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how to Reading And Writing SAC (Seismic Analysis Code) Data Files in Fortran codes (https://www.linuxquestions.org/questions/linux-software-2/how-to-reading-and-writing-sac-seismic-analysis-code-data-files-in-fortran-codes-687860/)

lengyue 12-02-2008 06:46 PM

how to Reading And Writing SAC (Seismic Analysis Code) Data Files in Fortran codes
 
Dear,all
Recently, I synthesized a seismogram by using Fortran codes, I need plot the synthesized seismogram and the data together, so I can verify the accuracy of code. Now I encounter a question: how to read the SAC data by Fortran code, I have searched some codes on Internet, the details as follow:the velr12a.sac is my data file.
Code:

c    read sac file
      PROGRAM RSAC
      PARAMETER (MAX=1000)
      DIMENSION YARRAY(MAX)
      CHARACTER*10 KNAME
      KNAME='velr12a.sac'
      CALL RSAC1(KNAME,YARRAY,NLEN,BEG,DEL,MAX,NERR)
      IF(NERR.GT.0)GO TO 8888
      CALL DOIT(YARRAY,NLEN)
8888  CONTINUE
      END
c----------------------------------------------------
      subroutine doit(yarray,nlen)
      dimension yarray(nlen)
      do i=1,nlen
        print *,yarray(i)
      enddo
      return
      end

I see the notes on Internet :"when compiling/linking your code, it may be necessary to include '-lX11 -lm' on the compile/link line in order to access the X windows and math libraries respectively. "
So I run my code like this:
Code:

[jing@localhost 3dzeng]$ g77 rsac1.f /usr/local/sac/lib/sac.a -o rsac1 -L/usr/X11R6/lib -lX11 -L/usr/lib/ -lm
/usr/local/sac/lib/sac.a(inissi.o)(.text+0x1b): In function `inissi':
: undefined reference to `dblClearErrorList'
/usr/local/sac/lib/sac.a(inissi.o)(.text+0x20): In function `inissi':
: undefined reference to `dbSetQueryDefaults'
/usr/local/sac/lib/sac.a(inissi.o)(.text+0x25): In function `inissi':
: undefined reference to `smGetDefaultWorksetName'
/usr/local/sac/lib/sac.a(inissi.o)(.text+0x39): In function `inissi':
: undefined reference to `smDeleteWorksetByName'
/usr/local/sac/lib/sac.a(inidfm.o)(.text+0x1039): In function `inidfm':
: undefined reference to `SetIndianSize'
collect2: ld returned 1 exit status

I can not understand what's meaning of the errors, can you give me some suggestions on how to read SAC data file in Fortran code? Thank a lot.

Yueling

telemeister 12-02-2008 10:06 PM

Hello again Yueling -

Well googling those undefined references seems to only produce SAC related hits, so I guess that suggests maybe something wrong with your SAC library?

In case you missed it, there is another thread on the IRIS site about this problem.

http://www.iris.washington.edu/piper...ry/000049.html

Although not sure if it was resolved.

It could be worth an email to the original poster on that site to see if he resolved the library issue.

Ekrem.Zor at mam.gov.tr

Let us know how you go.

Steve

lengyue 12-03-2008 12:39 PM

Hi,telemeister,

Thank you and Ekrem's reply.

When I compiled the Fortran code on 64 bit or 32 bit machine, I
should add -m32 to my command as in the following line;
Code:

g77 rsac1.f -o rsac1 /usr/local/sac/lib/sacio.a -m32
this will create a rsac1 as a 32 bit executable file linked to 32 bit
sac.a library. This may also run on 64 bit machine.

Cheers!

Yueling


All times are GMT -5. The time now is 07:42 PM.