Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

getarg blank filled

jf
Beginner
1,873 Views
hi,
i did what is written in the manual:
character::arg
integer::input,status
input=1
so,
call getarg(input,arg) // arg is blank filled
call getarg(input,arg,status) // compile but crash
with input=0 getarg(input,arg), arg is still blank filled
if i overload getarg or even define wrong types it still compile
i'm using the trial version with xp

thank
0 Kudos
16 Replies
Steven_L_Intel1
Employee
1,873 Views
Welcome to the forum!

Your declaration of arg is for only one character. Let me suggest you use:

character(80) :: arg

instead.

I also suggest that you add:

USE DFPORT

just after the PROGRAM, SUBROUTINE or FUNCTION statement. This will allow you to use the two and three argument versions of GETARG together.

Steve
0 Kudos
emc-nyc
Beginner
1,873 Views
A couple of issues:

Since you don't specify which version of Fortran you're using, I think what is happening is that you cannot mix the 2 and 3 argument forms of getarg. This is likely to be one problem.

The second problem may be that getarg's two integer arguments, input and status, are 2-byte integers. I believe CVF, by default, uses 4-byte integers, so there may be an alignment problem.

The routine should compile if it's syntactically correct; unless the compiler has access to interface information, it cannot determine if the argument list in you code is the same as the argument list that getarg is expecting; call getarg(), call getarg(input, arg), and call getarg(arg, input) are all syntactically correct, so the compiler will be happy. After all, you may have written a routine named 'getarg' or be using one named 'getarg' from a 3d party library.

So my suggestions are:

Add the appropriate "USE" statement (USE DFLIB for CVF 6.6)

Explicity declare input and status to be integer(2).

Unless you've got one-byte command line arguments, declare arg to something generous, like character*256. Do not declare it as character arg(256). These are not equivalent!

Hand check your code to make sure the interfaces are right.
0 Kudos
jf
Beginner
1,873 Views
well, first, i know fortran for about few days.
i don't use cvf i use visual c++, so i don't have this dflib.
my application that work without the getarg, read a matrix from a file do some stuff on it(?syevd) and write eigenvalues.
i compile it with ... /link compiler_lib_path*.lib mkl_path*.lib
and yet to use ?syevd i don't need any USE statement and getarg is supposed to be an intrinstic function of fortran so, be properly compiled only with the lib path of the compiler.
??
thanks
0 Kudos
jf
Beginner
1,873 Views
i mean, it doesn't work with use dflib
0 Kudos
Steven_L_Intel1
Employee
1,873 Views
Are you using Intel Fortran? Visual C++ doesn't compile Fortran programs. What version of Intel Fortran are you using? The current version 7.1 does have USE DFPORT.

Steve
0 Kudos
jf
Beginner
1,873 Views
i use version 7.0.
if i compile it with : ifl test.f90 /link...
i have: module dfport not found
if i compile : ifl test.95 /link...
it says: error lnk1136 invalid or corrupted file
0 Kudos
jf
Beginner
1,873 Views
version 7.1
0 Kudos
Steven_L_Intel1
Employee
1,873 Views
Change to USE IFLPORT

test.95 is not recognized as a Fortran source file type. Make sure the file name is test.f90.

Steve
0 Kudos
jf
Beginner
1,873 Views
buffer is still blank.
this is the code:

program test
use iflport
integer*2 :: in,status
character*16 :: buffer
in=1
call getarg(in,buffer)
print *, in,buffer
end

compiled with:
ifl test.f90 /link C:IntelCompiler70IA32Lib*.lib
0 Kudos
Steven_L_Intel1
Employee
1,873 Views
How are you running the program? You would have to run it from the command line with an argument to see anything.

Steve
0 Kudos
jf
Beginner
1,873 Views
i do run it from the command line!
C:...>test blabla
and i get:
1

C:...>

i really don't know
0 Kudos
Steven_L_Intel1
Employee
1,873 Views
Your compile command is a bit strange. Try it this way:

ifl /4Yportlib test.f90

It works for me.

Steve
0 Kudos
jf
Beginner
1,873 Views
thanks it does work now, but what does /4Yportlib means?
or where can i get some information please.
0 Kudos
jf
Beginner
1,873 Views
why it can be compiled properly with an access to all lib?
i'd like to know
0 Kudos
jf
Beginner
1,873 Views
got it.

thanks a lot
0 Kudos
Steven_L_Intel1
Employee
1,873 Views
To be honest, I don't know what the linker does with the *.lib specification you gave. But I think what happened was that you got a C version of getarg that didn't know how to deal with Fortran character strings.

/4Yportlib means to link against the Fortran Portability library - a collection of UNIX-compatibility routines.

Steve
0 Kudos
Reply