fortran

Fortran 90 - Attempt to read past end of file

此生再无相见时 提交于 2021-02-20 16:56:07
问题 I am having a read issue in Fortran 90. I am attempting to read 31488 rows of data. I am using the Portland Group Fortran 90 compiler. My error message is this: PGFIO-F-217/list-directed read/unit=14/attempt to read past end of file. File name = /import/c/w/username/WRFV3/SKILLSETS/Overestimations.txt formatted, sequential access record = 31489 The Fortran program thinks that I have an extra row. I do not know where that is indicated in the code. I have attached the relevant part of the code.

Memory leak when assigning allocatable polymorphic variable with return value

若如初见. 提交于 2021-02-20 00:48:58
问题 I'm struggling with memory management or correct usage of object oriented Fortran 2008. My code has multiple derived types with the same parent (here Example01 and Example02 ) stored in a Example_Class module. I want to load one example in a subroutine workenv depending on some variable (here idx_example ). Whichever one is chosen should be accessed by procedures defined in the base class, so I can do call active_Example%Info() regardless of what active_Example is. The following code compiled

Memory leak when assigning allocatable polymorphic variable with return value

人走茶凉 提交于 2021-02-20 00:46:35
问题 I'm struggling with memory management or correct usage of object oriented Fortran 2008. My code has multiple derived types with the same parent (here Example01 and Example02 ) stored in a Example_Class module. I want to load one example in a subroutine workenv depending on some variable (here idx_example ). Whichever one is chosen should be accessed by procedures defined in the base class, so I can do call active_Example%Info() regardless of what active_Example is. The following code compiled

Libtorch works with g++, but fails with Intel compiler

霸气de小男生 提交于 2021-02-19 09:31:23
问题 I want to use a neural network developed in Python (PyTorch) in a Fortran program. My OS is Ubuntu 18.04. What I am doing: save it as torchscript: TurbNN.pt call it from c++ program: call_ts.cpp, call_ts.h call c++ program from Fortran program (using bind©): main.f90 I successfully compiled the codes using CMake (3.19.4) and g++ (7.5.0). However, I cannot compile them using Intel compilers (HPCKit 2021.1.0.2684): # downloaded torchlib export Torch_DIR=/home/aiskhak/nn/fortran_calls

f951 error: unrecognized command line option

Deadly 提交于 2021-02-19 07:10:47
问题 I am on linux and I am compiling the following: mpif90 -shared source.F90 object1.o object2.o -L/some/path -Qoption,link,-rpath=/some/path -I/some/path -lhdf5 -lhdf5_fortran -fPIC -fpp -DDECDEC_ -DMSMS_ -cxxlib-gcc -o libhdfwrapper.so and I get f95: unrecognized option '-Qoption,link,-rpath=/some/path' f95: unrecognized option '-cxxlib-gcc' f951: error: unrecognized command line option "-fpp" can anybody tell me why fpp is not recognized? 回答1: -fpp is a flag used by some compilers, notably

Combining FORTRAN and C++, linking error

為{幸葍}努か 提交于 2021-02-19 05:44:05
问题 I should couple in linux one c++ code with old fortran code, where fortan is the main code. Im not expert in this area and I try to start with simple test, but still I cannot compile it. Maybe I'm stupid, but I cannot find a working example anywhere. I managed to compile fortran and c, when the linking can be done by ifort (need to use intel compiler later with the actual fortran code). But If I've understood right, with c++ , the linking must be done by c++ compiler ( g++ ). So what do I do

Fortran read mixed text and numbers

不打扰是莪最后的温柔 提交于 2021-02-19 03:44:04
问题 I am using Fortran 90 to read a file that contains data in the following format number# 125 var1= 2 var2= 1 var3: 4 . . . . number# 234 var1= 3 var2= 5 var3: 1 I tried the following command and works fine read (2,*) tempstr , my_param(1), tempstr , my_param(2), tempstr , my_param(3) Problem is when the numbers become larger and there is no space between string and number, i.e. the data looks as following: number# 125 var1= 2 var2=124 var3: 4 I tried read (2,512) my_param(1), my_param(2), my

Why we need 1,2,4,8 bytes to store logical variable in fortran?

∥☆過路亽.° 提交于 2021-02-18 20:50:35
问题 I don't understand that since logical type only has two cases: true and false , then why we need logical(1) , logical(2) , logical(4) , logical(8) in Fortran? We just need 1 bit . Can somebody give an explanation? 回答1: First, Fortran doesn't say that we have logical types taking up 1, 2, 4 and 8 bytes each, and they certainly aren't logical(1) , logical(2) , logical(4) , and logical(8) . An implementation may choose to offer those, calling them those names. A logical variable can indeed be of

Why we need 1,2,4,8 bytes to store logical variable in fortran?

北城以北 提交于 2021-02-18 20:50:26
问题 I don't understand that since logical type only has two cases: true and false , then why we need logical(1) , logical(2) , logical(4) , logical(8) in Fortran? We just need 1 bit . Can somebody give an explanation? 回答1: First, Fortran doesn't say that we have logical types taking up 1, 2, 4 and 8 bytes each, and they certainly aren't logical(1) , logical(2) , logical(4) , and logical(8) . An implementation may choose to offer those, calling them those names. A logical variable can indeed be of

Fortran “Error: The shapes of the array expressions do not conform.”

試著忘記壹切 提交于 2021-02-17 06:35:11
问题 I know someone has asked a similar question. It said that the error maybe come from trying to assign an array to a scalar. I checked my program again and again as it said but I really don't find any wrong with my program. The specific error message is: D:\src\fortran\Kramers\kramers.f90(54) : Error: The shapes of the array expressions do not conform. [Y2] y2(1)=sqrt(2.0d0*T)*[h*omega(2)-h1*omega(3)+h1*h*omega(4)-h1*h1*omega(6)+& ----------------^ D:\src\fortran\Kramers\kramers.f90(65) : Error