fortran77

Include both .f and .F90 file in Fortran main file header

梦想的初衷 提交于 2019-11-28 09:53:06
问题 I am using some F77 fixed format code with my F90 program. I am trying to include both kinds of code in my main program. Here's how I have arranged my code: Header files: File Name:include.inc include 'module_variables.F90' include 'message.F90' include 'module_common_functions.f90' include 'module_input_gdf.F90' ... Relavant LAPACK files File Name: lapack.inc include 'xerbla.f' include 'strsm.f' include 'slaswp.f' include 'sgetrs.f' include 'sgetrf.f' ... Now my main program looks like:

How to use Fortran 77 subroutines in Fortran 90/95?

99封情书 提交于 2019-11-28 08:56:15
问题 I'm writing a code with Fortran 90 and now I need to use the special functions in the*amos Fotran 77 library(http://www.netlib.org/amos/). Now I found a module interface for those routines(https://github.com/certik/fortran-utils/blob/master/src/amos.f90). My question is: how can I combine them and use them in my Fortran 90 program and how to compile them correctly? I have been struggling for this for one whole day and still could not figure it out. The following is my test code: PROGRAM TEST

How can gfortran tell if I am compiling f90 or f95 code?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 06:35:27
I understand gfortran can compile f90 or f95? How does it know which one it is compiling? Also can it compile f77 code? Does ubuntu already have a fortran compiler or do I need to download gfortran? Jonathan Dursi gfortran can guess certain things from the file extension; if the file has an extension of .f, .f90, f95, .f03, or .f08 it will assume fixed (.f) or free format with the appropriate standards. But you can force it to compile (say) fortran2003 code with the option -std=f2003. Eg, from the documentation , -std=std Specify the standard to which the program is expected to conform, which

Compiling with gfortran: undefined reference to iargc_

て烟熏妆下的殇ゞ 提交于 2019-11-28 00:33:04
I'm using gfortran [GNU Fortran (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)] on a Fedora 20 x86_64 to compile a bunch of Fortran 77 code which refers to 'iargc' function in the following manner: bin2D2nc.f:31: integer iargc,strlen1 bin2D2nc.f:32: external iargc,strlen1 bin2D2nc.f:44: i=iargc() When the make script reaches the compilation comand bellow, gfortran -O3 -ffixed-line-length-132 -fall-intrinsics -I/home/santiago/Install/netcdf_sam/include -o bin2D2nc -I./SRC ./SRC/bin2D2nc.f ./SRC/hbuf_lib.f ./SRC/cape.f ./SRC/cin.f -L/home/santiago/Install/netcdf_sam/lib -lnetcdf -L/usr/lib64 -lpthread I

Why define PI = 4*ATAN(1.d0)

徘徊边缘 提交于 2019-11-27 18:56:25
What is the motivation for defining PI as PI=4.D0*DATAN(1.D0) within Fortran 77 code? I understand how it works, but, what is the reasoning? This style ensures that the maximum precision available on ANY architecture is used when assigning a value to PI. Because Fortran does not have a built-in constant for PI . But rather than typing in the number manually and potentially making a mistake or not getting the maximum possible precision on the given implementation, letting the library calculate the result for you guarantees that neither of those downsides happen. These are equivalent and you'll

What are the ways to pass a set of variable values through the subroutine to a function without common block?

梦想与她 提交于 2019-11-27 16:23:56
I do not want to use common blocks in my program. My main program calls a subroutine which calls a function. The function needs variables from the subroutine. What are the ways to pass the set of information from the subroutine to the function? program ... call CONDAT(i,j) end program SUBROUTINE CONDAT(i,j) common /contact/ iab11,iab22,xx2,yy2,zz2 common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2 call function f(x) RETURN END function f(x) common /contact/ iab11,iab22,xx2,yy2,zz2 common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2 end What you care about here is association :

pass fortran 77 function to C/C++

北城余情 提交于 2019-11-27 07:55:53
问题 Is it possible to pass fortran 77 function as a callback function pointer to C/C++? if so, how? information I found on the web relates to fortran 90 and above, but my legacy code base is in 77. many thanks 回答1: If it can be done in FORTRAN 77, it will be compiler and platform specific. The new ISO C Binding of Fortran 2003 provides a standard way of mixing Fortran and C, and any language that follows or can follow the calling conventions of C, such as C++. While formally a part of Fortran

What are the ways to pass a set of variable values through the subroutine to a function without common block?

不问归期 提交于 2019-11-27 04:07:36
问题 I do not want to use common blocks in my program. My main program calls a subroutine which calls a function. The function needs variables from the subroutine. What are the ways to pass the set of information from the subroutine to the function? program ... call CONDAT(i,j) end program SUBROUTINE CONDAT(i,j) common /contact/ iab11,iab22,xx2,yy2,zz2 common /ellip/ b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2 call function f(x) RETURN END function f(x) common /contact/ iab11,iab22,xx2,yy2,zz2

How can gfortran tell if I am compiling f90 or f95 code?

我与影子孤独终老i 提交于 2019-11-27 01:29:25
问题 I understand gfortran can compile f90 or f95? How does it know which one it is compiling? Also can it compile f77 code? Does ubuntu already have a fortran compiler or do I need to download gfortran? 回答1: gfortran can guess certain things from the file extension; if the file has an extension of .f, .f90, f95, .f03, or .f08 it will assume fixed (.f) or free format with the appropriate standards. But you can force it to compile (say) fortran2003 code with the option -std=f2003. Eg, from the

Compiling with gfortran: undefined reference to iargc_

僤鯓⒐⒋嵵緔 提交于 2019-11-26 21:43:16
问题 I'm using gfortran [GNU Fortran (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)] on a Fedora 20 x86_64 to compile a bunch of Fortran 77 code which refers to 'iargc' function in the following manner: bin2D2nc.f:31: integer iargc,strlen1 bin2D2nc.f:32: external iargc,strlen1 bin2D2nc.f:44: i=iargc() When the make script reaches the compilation comand bellow, gfortran -O3 -ffixed-line-length-132 -fall-intrinsics -I/home/santiago/Install/netcdf_sam/include -o bin2D2nc -I./SRC ./SRC/bin2D2nc.f ./SRC/hbuf