Hi all,
I'm new here, first post. Was hoping someone here with some fortran knowledge could help me out with a little problem, and perhaps give me some general advice. This is DAY ONE of me using fortran, so please be patient. I am running gfortran on osx mavericks.
As an introductory project, I've been trying to use fortran to write a configuration script for gnuplot. My hope is to be able to loop over this code to make different versions of the configuration script. My efforts consist of two f03 files (raw code is below), one contains the program which calls a number of subroutines in order, and the other is a module with subroutines in it. First I compiled the "gnu_style" module, then I compiled the "test" program, then I tried to link them into an executable. The command line arguments I used are below:
$ gfortran -c gnu_style.f03
$ gfortran -c test.f03
$ gfortran gnu_style.o test.o -o testy
Unfortunately, the following error is returned:
Undefined symbols for architecture x86_64:
"_keyoff_", referenced from:
_MAIN__ in test.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I've tried running the code with the -m32 and -m64 flags, and the error is the same. I also tried running them on another mac with gfortran, same error. I then ssh'd into a linux machine and ran the codes there, and it still doesn't like the _keyoff_ symbol. So I am guessing what I have is a programming issue. And if someone could help me with that by looking at the horrible, ignorant code below (I'll say it again, this is DAY 1 fortran), then I would be extremely grateful.
Thanks for your time,
==========================================
program test
use gnu_style
implicit none
real, parameter :: pi = 4*atan(1.0)
call style_new()
call pngcairo()
call output('frames/test')
call grid()
call keyoff()
call xrange(0.0,2.0*pi)
call yrange(-1.0,1.0)
call title('Animation')
call datafile('data/test')
call style_close()
end program test
======================
module gnu_style
implicit none
contains
subroutine style_new
open(unit=1, file='style.gnu')
end subroutine style_new
subroutine pngcairo
write (1,*) "set terminal pngcairo transparent enhanced font 'arial,10' fontscale 1.0 size 500, 300"
end subroutine pngcairo
subroutine output(filename)
character(12) :: filename
write (1,*) "set output'"//trim(filename)//"'"
end subroutine output
subroutine grid
write(1,*) "set grid"
end subroutine grid
subroutine xrange(xmin,xmax)
real :: xmin, xmax
character(8) :: strminx, strmaxx
write(strminx,'(f8.4)') xmin
write(strmaxx,'(f8.4)') xmax
write (1,*) "set xrange ["//trim(strminx)//":"//trim(strmaxx)//"]"
end subroutine xrange
subroutine yrange(ymin,ymax)
real :: ymin, ymax
character(8) :: strminy, strmaxy
write(strminy,'(f8.4)') ymin
write(strmaxy,'(f8.4)') ymax
write (1,*) "set yrange ["//trim(strminy)//":"//trim(strmaxy)//"]"
end subroutine yrange
subroutine title(titletext)
character(50) :: titletext
write (1,*) "set title '"//trim(titletext)//"'"
end subroutine title
subroutine datafile(datafilename)
character(50) :: datafilename
write (1,*) "plot 'data.dat' with linespoints ls6 lc7"
end subroutine datafile
subroutine style_close
close(unit=1)
end subroutine style_close
end module gnu_style
I'm new here, first post. Was hoping someone here with some fortran knowledge could help me out with a little problem, and perhaps give me some general advice. This is DAY ONE of me using fortran, so please be patient. I am running gfortran on osx mavericks.
As an introductory project, I've been trying to use fortran to write a configuration script for gnuplot. My hope is to be able to loop over this code to make different versions of the configuration script. My efforts consist of two f03 files (raw code is below), one contains the program which calls a number of subroutines in order, and the other is a module with subroutines in it. First I compiled the "gnu_style" module, then I compiled the "test" program, then I tried to link them into an executable. The command line arguments I used are below:
$ gfortran -c gnu_style.f03
$ gfortran -c test.f03
$ gfortran gnu_style.o test.o -o testy
Unfortunately, the following error is returned:
Undefined symbols for architecture x86_64:
"_keyoff_", referenced from:
_MAIN__ in test.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I've tried running the code with the -m32 and -m64 flags, and the error is the same. I also tried running them on another mac with gfortran, same error. I then ssh'd into a linux machine and ran the codes there, and it still doesn't like the _keyoff_ symbol. So I am guessing what I have is a programming issue. And if someone could help me with that by looking at the horrible, ignorant code below (I'll say it again, this is DAY 1 fortran), then I would be extremely grateful.
Thanks for your time,
==========================================
program test
use gnu_style
implicit none
real, parameter :: pi = 4*atan(1.0)
call style_new()
call pngcairo()
call output('frames/test')
call grid()
call keyoff()
call xrange(0.0,2.0*pi)
call yrange(-1.0,1.0)
call title('Animation')
call datafile('data/test')
call style_close()
end program test
======================
module gnu_style
implicit none
contains
subroutine style_new
open(unit=1, file='style.gnu')
end subroutine style_new
subroutine pngcairo
write (1,*) "set terminal pngcairo transparent enhanced font 'arial,10' fontscale 1.0 size 500, 300"
end subroutine pngcairo
subroutine output(filename)
character(12) :: filename
write (1,*) "set output'"//trim(filename)//"'"
end subroutine output
subroutine grid
write(1,*) "set grid"
end subroutine grid
subroutine xrange(xmin,xmax)
real :: xmin, xmax
character(8) :: strminx, strmaxx
write(strminx,'(f8.4)') xmin
write(strmaxx,'(f8.4)') xmax
write (1,*) "set xrange ["//trim(strminx)//":"//trim(strmaxx)//"]"
end subroutine xrange
subroutine yrange(ymin,ymax)
real :: ymin, ymax
character(8) :: strminy, strmaxy
write(strminy,'(f8.4)') ymin
write(strmaxy,'(f8.4)') ymax
write (1,*) "set yrange ["//trim(strminy)//":"//trim(strmaxy)//"]"
end subroutine yrange
subroutine title(titletext)
character(50) :: titletext
write (1,*) "set title '"//trim(titletext)//"'"
end subroutine title
subroutine datafile(datafilename)
character(50) :: datafilename
write (1,*) "plot 'data.dat' with linespoints ls6 lc7"
end subroutine datafile
subroutine style_close
close(unit=1)
end subroutine style_close
end module gnu_style