From: Celine La on

Hello, Dear...

I am trying to run *.f with matlab.

I have chosen compaq 6.6 and visual studio 6.0 with mex command.I didn't see any problem with them.I have integrated my fortran into visual studio by manual setting.
I could successfully compile all the c files,(I could see a lot of 'done' results)
but I am having trouble with *.f files.

This showed:-----------------------------------------------------------------------------------------
COMPILING IRI2001 MEX-FUNCTION ...
Error iricira.f: 1 syntax error; found `cira' expecting `;'
Error iricira.f: 1 syntax error; found `.' expecting `;'
Error iricira.f: 1 skipping `.' `for' `,'
Error iricira.f: 1 syntax error; found `number' expecting `;'
Error iricira.f: 1 syntax error; found `can' expecting `;'
Error iricira.f: 1 syntax error; found `be' expecting `;'
Error iricira.f: 1 syntax error; found `found' expecting `;'
Error iricira.f: 1 syntax error; found `at' expecting `;'
Error iricira.f: 1 syntax error; found `the' expecting `;'
Error iricira.f: 1 syntax error; found `end' expecting `;'
Error iricira.f: 1 syntax error; found `of' expecting `;'
Error iricira.f: 1 syntax error; found `this' expecting `;'
Error iricira.f: 1 syntax error; found `comment' expecting `;'
Error iricira.f: 2 syntax error; found `c' expecting `;'
Error iricira.f: 2 syntax error; found `--' expecting `;'
Error iricira.f: 2 unrecognized declaration
Error iricira.f: 2 unrecognized declaration
Error iricira.f: 2 unrecognized declaration
Error iricira.f: 2 unrecognized declaration
Error iricira.f: 2 unrecognized declaration
Error iricira.f: 2 too many errors

C:\MATLAB7\BIN\WIN32\MEX.PL: Error: Compile of 'iricira.f' failed.

??? Error using ==> mex
Unable to complete successfully

Error in ==> compile at 29
eval(['mex -f ' f_compiler ' -output ' mexfile ' ' codefiles ' ' libfiles]);

-------------------------------------------------------------------------------------------------------------------

all other fortran written files have shown the same results, actually.

Thus, I directly went to the directory with *.f files of my interest, in order to debug them. when I have attempted to comand mex -g *.f, this has been shown.

--------------------------------------------------------------------------------------------------------------------
>> mex -g iricira.f
Creating library _lib846.lib and object _lib846.exp
_lib846.exp : error LNK2001: unresolved external symbol _MEXFUNCTION(a)16
iricira.dll : fatal error LNK1120: 1 unresolved externals

C:\MATLAB7\BIN\WIN32\MEX.PL: Error: Link of 'iricira.dll' failed.

??? Error using ==> mex
Unable to complete successfully

---------------------------------------------------------------------------------------------------------------------
From: Rune Allnor on
On 6 Mar, 16:16, "Celine La" <helio...(a)naver.com> wrote:
> Hello, Dear...
>
> I am trying to run *.f with matlab.
>
> I have chosen compaq 6.6 and visual studio 6.0 with mex command.I didn't see any problem with them.I have integrated my fortran into visual studio by manual setting.
> I could successfully compile all the c files,(I could see a  lot of 'done' results)
> but I am having trouble with *.f files.
>
> This showed:

Seems like the tolkens the compiler complains about form
some sort of sentence. The first issue to check is if
the file uses the wrong character to indicate comments.

Rune
From: Celine La on
Dear Rune,

Thank you for your reply,

Actually, my algorithm has several mex-files. Especially for this one, it is written in fortran, while other files associated with this file are written in C. Thus, When I compile each folder at subdirectory seperatedly one by one, it looks fine with no any problem. This iri*.f file (one of the subdirectory)was also successfully compiled. However, every time when I compile all the mex-files together at the higher directory, this error was reported.

I also thought about a possibility of wrong character, but actually it's just a 'C' letter( % as in Matlab) embeded in the fortran. Let me post the problematic part (first five lines) of the source code below.

---------------------------------------------------------------------------------------------------------------------
1c cira.for, version number can be found at the end of this comment
2c-----------------------------------------------------------------------
3C
4C Calculates neutral temperature parameters for IRI using the
5C MSIS-86/CIRA

---------------------------------------------------------------------------------------------------------------

My matlab is v7(R14) such that I really have to use compaq fortran. My compaq is v6.6C, integrated with visual studio 6.0. I think this is interface problem. Anyone shoot this problem?

Thanks,

La.


Rune Allnor <allnor(a)tele.ntnu.no> wrote in message <22e0d276-55f9-45d4-8a9d-2c7e068ce9e1(a)x22g2000yqx.googlegroups.com>...
> On 6 Mar, 16:16, "Celine La" <helio...(a)naver.com> wrote:
> > Hello, Dear...
> >
> > I am trying to run *.f with matlab.
> >
> > I have chosen compaq 6.6 and visual studio 6.0 with mex command.I didn't see any problem with them.I have integrated my fortran into visual studio by manual setting.
> > I could successfully compile all the c files,(I could see a  lot of 'done' results)
> > but I am having trouble with *.f files.
> >
> > This showed:
>
> Seems like the tolkens the compiler complains about form
> some sort of sentence. The first issue to check is if
> the file uses the wrong character to indicate comments.
>
> Rune
From: James Tursa on
"Celine La" <helio_22(a)naver.com> wrote in message <hmv6ca$93s$1(a)fred.mathworks.com>...
> Dear Rune,
>
> Thank you for your reply,
>
> Actually, my algorithm has several mex-files. Especially for this one, it is written in fortran, while other files associated with this file are written in C. Thus, When I compile each folder at subdirectory seperatedly one by one, it looks fine with no any problem. This iri*.f file (one of the subdirectory)was also successfully compiled. However, every time when I compile all the mex-files together at the higher directory, this error was reported.
>
> I also thought about a possibility of wrong character, but actually it's just a 'C' letter( % as in Matlab) embeded in the fortran. Let me post the problematic part (first five lines) of the source code below.
>
> ---------------------------------------------------------------------------------------------------------------------
> 1c cira.for, version number can be found at the end of this comment
> 2c-----------------------------------------------------------------------
> 3C
> 4C Calculates neutral temperature parameters for IRI using the
> 5C MSIS-86/CIRA
>
> ---------------------------------------------------------------------------------------------------------------
>
> My matlab is v7(R14) such that I really have to use compaq fortran. My compaq is v6.6C, integrated with visual studio 6.0. I think this is interface problem. Anyone shoot this problem?

You can't compile Fortran source code and C source code at the same time at the mex level. You must compile one first (e.g., with the -c option) and then compile the other ones. e.g., suppose your mexFunction happens to be in your Fortran file myfortran.f, and a supporting function is in a file called myc.c. Then the sequence of mex commands would be like this:

mex -setup
(then select a C compiler)
mex -c myc.c
mex -setup
(then select a Fortran compiler)
mex myfortran.f myc.obj

Note particularly that the C file has been compiled into an object file, and then that object file is included in the mex command for the Fotran compile.

In order for this to work, however, your Fortran compiler and C compiler have to play nice together. ii.e., any name mangling, such as trailing underscores, etc. need to be the same. Compaq Fortran compilers can be a problem because they name mangle with @bytes placed at the end of all the exported names, with the bytes being the number of total bytes of the arguments. To get C compilers to do the same name mangling you will need to include a __stdcall (if I remember correctly) in the function declaration.

James Tursa