LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2014, 07:58 PM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Rep: Reputation: Disabled
Command line argument in GFortran


Hi there. I have a problem. Trying to run a Fortran program which compiles I get an early exit and I don't know how to correct it. The program is posted here. You can see from the code (first few lines, actually) that it wants to read a command line and find out the name of the file where the input array for Fast Fourier Transform is. I found such an array on the web and placed it in a file named: array.dat. Then I tried to run the program (after compilation) as:

Code:
./a.out -o array.dat
It gave me the same response: Wrong number of arguments.

How shall I arrange it? Thanks, - A.
 
Old 12-12-2014, 01:21 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,877

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
I haven't done anything with Fortran in more than 20 years, so please excuse me if I am missing something obvious, but ....

I see the test for COMMAND_ARGUMENT_COUNT(), and I see the call to COMMAND_ARGUMENT_COUNT(), but nowhere do I see the function defined. So, It should generate the error because the test will fail every time.

Is the function COMMAND_ARGUMENT_COUNT() a Fortran builtin, or is it something you overlooked adding to the program?
 
Old 12-12-2014, 07:26 PM   #3
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
COMMAND_ARGUMENT_COUNT is an intrinsic procedure for GFortran. The problem I have is that I don't know how to put arguments on the command line. After searching for quite a while I found that this subject is poorly referenced. There are a few examples to follow and I will try to do this tonight or tomorrow.
 
Old 12-12-2014, 07:28 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,980

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
that FFT program will requite that the image used is a SQUARE image that is of a "power of 2 "
256x256, 1024 x 1024 , 2048 x 2048

if not then it will resize it

but saved as the " array.dat " i would say as a ASCII CSV format "dat" ( ascii raw)
the same as you would fro Matlab or Octave or mathmatica

Last edited by John VV; 12-12-2014 at 07:29 PM.
 
1 members found this post helpful.
Old 12-12-2014, 07:34 PM   #5
turtleli
Member
 
Registered: Aug 2012
Location: UK
Posts: 206

Rep: Reputation: Disabled
I believe it should be

Code:
./a.out array.dat
I don't understand why you have used a "-o".
 
1 members found this post helpful.
Old 12-13-2014, 11:53 AM   #6
AlexBB
Member
 
Registered: Mar 2014
Posts: 437

Original Poster
Rep: Reputation: Disabled
Turtleli is correct. I found it out by trial and error. I first used -o because I found a similar script somewhere and it thought it was essential, then I dropped it. So, John W. says that I have to provide such huge input arrays. Well, It can be done with some analytical functions. I will look into it. Thanks.
 
Old 12-13-2014, 08:56 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,980

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
a image that is 256x256 is tiny

i normally run images with 4096x4096 though a FFT based program


i have seen a lot of old FORTRAN and matlab .m files that used 128^2 or 256^2
at least it is not asking for the image to be in the .UCF format

i take it you already have the input dat file

there should be a image folder with test data
some of the std ones are

Mozart001_256.ucf( or bin , raw or pgm )
vase001_128.ucf( or bin,raw or pgm )
lena256.ucf( or bin,raw or pgm )

Last edited by John VV; 12-14-2014 at 04:16 AM.
 
Old 12-13-2014, 09:29 PM   #8
flshope
Member
 
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.1, 14.04.4, Debian 8.6
Posts: 128
Blog Entries: 34

Rep: Reputation: 26
Quote:
Originally Posted by turtleli View Post
I believe it should be

Code:
./a.out array.dat
I don't understand why you have used a "-o".
I had to use

Code:
./a.out < array.dat
to get a test code to read array.dat from the console (e.g., READ(*,*)).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command line argument in c vipin_jss Linux - Newbie 6 05-11-2009 07:47 PM
[SOLVED] pass file-name as command line argument vikas027 Programming 2 10-15-2008 12:52 AM
Perl command line argument noir911 Programming 8 01-15-2008 05:59 AM
Finding the last command line argument (bash) pete1234 Programming 20 10-30-2006 11:20 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 05:35 PM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration