固定格式代码中可以包含自由格式代码吗? [英] Can free-format code be included in fixed-format code?

查看:92
本文介绍了固定格式代码中可以包含自由格式代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了固定格式的文件FFTRUN.f 该文件的开头看起来像这样:

I inherited a fixed-format file FFTRUN.f The beginning of that files looks like this:

  SUBROUTINE FFTRUN_2e 
  USE, intrinsic :: ISO_C_BINDING
  USE FFTWmod, ONLY : FFTWplan_fwd, FFTWplan_inv, FFTWplanReady
  INCLUDE 'INCL_PARAM.FOR'
  INCLUDE 'INCL_PRATT.FOR'
  INCLUDE 'INCL_XYZ.FOR'
  INCLUDE 'FFTW3.f03'

  PARAMETER (NDIM=2, NDAT=IMAX*JMAX)
  DIMENSION NN(NDIM),DATA(NDAT)
  COMPLEX*16 FACTR,SCATT(IMAX,JMAX),WAVINC,DATA

  IF (.not.FFTWplanReady) THEN
      FFTWplan_fwd = fftw_plan_dft_2d(nn2,nn1,data,data,
 &                FFTW_FORWARD,FFTW_MEASURE)
      FFTWplan_inv = fftw_plan_dft_2d(nn2,nn1,data,data,
 &                FFTW_BACKWARD,FFTW_MEASURE)
  ENDIF

我将使用

    gfortran -c FFTRUN.f

但是,它失败,因为fftw3.f03是自由格式.有没有一种方法可以实现我的目标,而不必将fftw3.f03重新格式化为固定格式?

however, it fails because fftw3.f03 is free form. Is there a way I can accomplish this include without having to reformat the fftw3.f03 to fixed-format?

这是一个庞大的软件,因此我无法重新格式化整个项目的固定格式.

This is a massive piece of software, so it's not possible for me to reformat the entire rest of the project which is fixed format.

推荐答案

否.通过分别编译两个源并将它们链接在一起,您可能会更快地取得进展.由于您已经在使用诸如use之类的Fortran 90功能,这不会给您带来太多痛苦.

No. You'll probably make quicker progress by compiling the two sources separately and linking them together. Since you're already using Fortran 90 features such as use this shouldn't cause you too much pain.

首先,确保fftw3.f03包含一个模块,该模块本身包含您要使用的功能.删除include fftw3.f03行,并与其他use语句一起插入语句use fftw3_mod(或任何被调用的模块).然后修改makefile以编译fftw3.f03,然后再编译fftrun.f.就是这样

First, make sure that fftw3.f03 contains a module which itself contains the function(s) you want to use. Delete the include fftw3.f03 line and insert, with the other use statements, the statement use fftw3_mod (or whatever the module is called). Then modify your makefile to compile fftw3.f03 before it compiles fftrun.f. That's about it.

这篇关于固定格式代码中可以包含自由格式代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆