Compiling and Linking to used modules in external

2019-09-16 19:42发布

I've already asked a similar question, here:

Linking to modules in external directory Compaq Visual Fortran command prompt

And I thought that the first answer was correct (that is, in the manual they say you can simply specify the path name before the module), but after deleting the temporary files in my library folder, this approach seemed to stop working. Trying with the /include[:path] approach, here is my .bat file:

 df /include:..\FORTRAN_LIB\ __constants 
 myIO griddata_mod myfdgen myDiff magneticField /exe:magneticField

And an error is returned saying:

 __constants
 myIO
 griddata_mod
 myfdgen
 myDiff
 magneticField
 f90: Severe: No such file or directory
 ... file is '__constants'

Again, I apologize that this question is VERY specific, but it seems like it should be simple and does not work at all.

p.s. Originally, I was using:

 df ..\FORTRAN_LIB\__constants ..\FORTRAN_LIB\myIO 
 ..\FORTRAN_LIB\griddata_mod ..\FORTRAN_LIB\myfdgen 
 ..\FORTRAN_LIB\myDiff magneticField /exe:magneticField

But, as I've said, it stopped working after I deleted the temporary files in my FORTRAN_LIB folder. Also note, these .bat files used only one line, I've broken them into several lines just for readability. I would prefer using the /include[:path] option since that seems like a better solution.

1条回答
淡お忘
2楼-- · 2019-09-16 20:29

Okay, so I think I figured out a workaround at the very least. I understood that the /include[:dir] specifies to search in "dir" for included files. But it seemed from documentation, that this also specifies to search for USEd modules but that doesn't seem to be the case.

My program now looks like this:

   include '..\FORTRAN_LIB\__constants.f90'
   include '..\FORTRAN_LIB\computeError.f90'
   include '..\FORTRAN_LIB\griddata_mod.f90'
   include '..\FORTRAN_LIB\myfdgen.f90'
   include '..\FORTRAN_LIB\myDiff.f90'
   include '..\FORTRAN_LIB\myIO.f90'

   program magneticField
   use constants
   use computeError_mod
   use griddata_mod
   use myfdgen_mod
   use myDiff_mod
   use myIO_mod
   implicit none
   ...

And my DF command like this:

   df magneticField /exe:magneticField

And everything seems to work fine. It would be nicer to have the /include[:dir] option, but so long I'm able to reach in a separate directory, I'm satisfied. If anyone can find a better solution I'll switch the checkmark. I hope this helps with anyone else who was confused like me.

查看更多
登录 后发表回答