LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command line argument in GFortran (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-argument-in-gfortran-4175528018/)

AlexBB 12-11-2014 06:58 PM

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.

bigrigdriver 12-12-2014 12:21 PM

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?

AlexBB 12-12-2014 06:26 PM

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.

John VV 12-12-2014 06:28 PM

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

turtleli 12-12-2014 06:34 PM

I believe it should be

Code:

./a.out array.dat
I don't understand why you have used a "-o".

AlexBB 12-13-2014 10:53 AM

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.

John VV 12-13-2014 07:56 PM

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 )

flshope 12-13-2014 08:29 PM

Quote:

Originally Posted by turtleli (Post 5283856)
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(*,*)).


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