fortran90

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

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

Evaluating a specific letter of a string defined in a derived type in Fortran90 [duplicate]

走远了吗. 提交于 2021-02-17 06:27:25
问题 This question already has answers here : Extract substring of Fortran string array (3 answers) Extract a single character from a Fortran string (1 answer) Access character at specific index in a string in Fortran (1 answer) Closed 1 year ago . I would like to evaluate if the 3rd letter of variable myline is 'C' or not. I try this: program main implicit none type line integer :: count = 5 character(len=48) :: list = 'ABCDE' end type type(line) :: myline character(len=1) :: letter = 'C' write(*

How to iterate over character strings with numbers, words and blancks in Fortran90?

随声附和 提交于 2021-02-17 06:00:07
问题 Description of the file: The STL file consists of solid <solid_name> facet normal n1 n2 n3 (the triangles normal vector) outerloop (one of the markers I want to read) v1 x1 y1 z1 v2 x2 y2 z2 (three vertex of the triangle/facet) v3 x3 y3 z3 endloop end facet endsolid The idea is to read the information in each line. First, I'm trying !to read the first line:solid program Leitura !use, intrinsic :: trim implicit none integer ilo, ierror, ihi, ios, iunit, num_text, len_blanck, len_word, len_text

Compilation error: Invalid character in name at (1)

吃可爱长大的小学妹 提交于 2021-02-17 03:54:07
问题 I wrote program test implicit none integer, parameter :: N = 3 real(8), parameter :: & A(N,N) = reshape( (/1.5d0,1d0,1d0,1d0,1.5d0,2d0,1d0,1d0,3d0/), shape(A) ) & b(N) = (/ 5d0,-3d0,8d0 /) print *, A end program saved as test.f, and got compilation error with gfortran -ffree-form -Wall -Werror -ffree-line-length-none test.f . test.f:6:24: A(N,N) = reshape( (/1.5d0,1d0,1d0,1d0,1.5d0,2d0,1d0,1d0,3d0/), shape(A) ) & 1 Error: Invalid character in name at (1) test.f:9:12: print *, A 1 Error:

Passing Variables from a Shell-Script to a Fortran 90 Program

大兔子大兔子 提交于 2021-02-17 02:56:11
问题 I'm stuck on this little problem. I was wondering if it is possible to pass a variable of a bash-shell script to a f90 code? 回答1: I am pretty sure it was discussed here before, but I cannot find an exact duplicate. You can pass arguments directly as arguments to the program ./program arg1 arg2 you can retrieve the values in the program as character strings in Fortran 2003 using subroutines GET_COMMAND ARGUMENT and COMMAND_ARGUMENT_COUNT. Click on the links to get useful examples. In older

Fortran DO loop, warning to use integer only

删除回忆录丶 提交于 2021-02-15 11:08:55
问题 I installed gfortran on my Ubuntu 15.04 system. While compiling Fortran code, the DO loop asks to take integer parameters only and not real values or variables. That includes the loop variable and the step expression. Why can't it take real values too? The following is a program taken from here, exercise 3.5 of the section nested do loops . program xytab implicit none !constructs a table of z=x/y for values of x from 1 to 2 and !y from 1 to 4 in steps of .5 real :: x, y, z print *, ' x y z'

Array allocation in Fortran subroutine

情到浓时终转凉″ 提交于 2021-02-08 10:13:59
问题 My question is about array allocation in Fortran. I have a subroutine, say readParams , where I want to read some dynamically sized arrays from files. These are also used outside the subroutine. What is the best way to handle this? In F95 it seems to be impossible to allocate within the subroutine and pass the arrays, filled with values, back to the main program. But if I allocate it in the main program and use "intent(inout)" in the subroutine it also gets deallocated there. (I'm using F90