小编ver*_*rie的帖子

74029 是什么日期?

我有一份旧的 Fortran 代码打印输出。

标题是:

FORTRAN IV G LEVEL 21, MAIN, DATE=74029, 15/28/03, PAGE 001
Run Code Online (Sandbox Code Playgroud)

我认为它来自 IBM 大型机,如果有帮助的话。

有谁知道什么时候印的吗?

fortran mainframe

2
推荐指数
1
解决办法
143
查看次数

如何避免在每个子程序中声明和设置变量的值?

如何避免在子程序中重复声明具有常量值的变量?

例如:

program test
  implicit none

  integer :: n
  integer :: time

  print*, "enter n" ! this will be a constant value for the whole program
  call Calcul(time)
  print*, time  
end program

subroutine Calcul(Time)
  implicit none

  integer :: time 

  ! i don't want to declare the constant n again and again because some times the subroutines have a lot of variables.  
  time = n*2 
end subroutine
Run Code Online (Sandbox Code Playgroud)

有时,有很多由用户定义的常量,我会制作很多使用这些常量的子例程,所以我想存储它们并使用它们,而不是一次又一次地重新定义它们。

fortran fortran90

1
推荐指数
1
解决办法
766
查看次数

gfortran编译器调用递归log_gamma函数时出错

我上传了一个 2F1 超几何函数,但结果发现它无法在我的计算机上编译。是出自这篇文章。我用

GNU Fortran (Built by Jeroen for the R-project) 8.3.0
Run Code Online (Sandbox Code Playgroud)

随 RTools 4.0 一起提供。你能找出为什么它不能编译以及如何解决这个问题吗?在下面的代码中,我只保留了生成错误的一行。接下来给出错误。

MODULE HYP_2F1_MODULE
  !--------------------------------------------------------------------
  IMPLICIT NONE
  INTEGER, PARAMETER :: PR=KIND(1.0D0)
  REAL(PR)     ::  ONE=1.0D0
CONTAINS
  !
END MODULE HYP_2F1_MODULE
!
!----------------------------------------------------------------------
RECURSIVE FUNCTION LOG_GAMMA(Z) RESULT(RES)

  USE HYP_2F1_MODULE
  IMPLICIT NONE
  COMPLEX(PR),INTENT(IN) :: Z
  COMPLEX(PR)  :: RES
  !
     RES = LOG_GAMMA( ONE -z);
  !
END FUNCTION LOG_GAMMA
Run Code Online (Sandbox Code Playgroud)

这是错误消息

 testZ.f90:18:22:

      RES = LOG_GAMMA( ONE - Z);
                 1
Error: 'x' argument of 'log_gamma' intrinsic at (1) must be …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran

1
推荐指数
1
解决办法
128
查看次数

当map.erase(it)来自模板中的map.find时,map.erase(it)会导致双重释放

我正在尝试运行以下命令:

#include <algorithm>
#include <iostream>
#include <map>

template <class T>
auto first(T t){
  return t.find(0);
}

void f(bool b){
  std::map<int, int> map;
  map.insert({0, 0});
  auto it = b ? first(map) : map.find(0);
  std::cout << "About to erase" << std::endl;
  map.erase(it); // Line 15
}

int main(void){
  f(false);
  std::cout << "Exited g(false) sucessfully" << std::endl;
  f(true); // Line 21
  std::cout << "Exited g(true) sucessfully" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

该函数f应该:

  • 初始化地图
  • 向该地图添加一个元素
  • 获取该元素的迭代器
  • 删除该元素

但是,使用g++ -g(g++版本9.3.0)编译会打印:

About to erase …
Run Code Online (Sandbox Code Playgroud)

c++ templates

0
推荐指数
1
解决办法
540
查看次数

标签 统计

fortran ×3

c++ ×1

fortran90 ×1

gfortran ×1

mainframe ×1

templates ×1