Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
0 answers
56 views
Process is not running in real-time priority
I have a Fortran based application that is running fine and it provides the correct results when I run it normally (i.e ./myapp); however, when I tried to run it with real-time priority it gives the following error: > linux@AnasPC:~/myapp/build$ sudo chrt -r 99 ./myapp > [sudo] password for emtplinu...
I have a Fortran based application that is running fine and it provides the correct results when I run it normally (i.e ./myapp); however, when I tried to run it with real-time priority it gives the following error: > linux@AnasPC:~/myapp/build$ sudo chrt -r 99 ./myapp
> [sudo] password for emtplinux:
./myapp: error while loading shared libraries: libmkl_intel_lp64.so.2: cannot open shared object file: No such file or directory I can see that this library is installed as part of Intel OneApi, this is confirmed when I run: >sudo find / -name libmkl_intel_lp64.so.2 I tried adding the path to the library in the running cmd using the following but that didn't solve the issue: > sudo LD_LIBRARY_PATH=/opt/intel/oneapi/mkl/2024.0/lib/libmkl_intel_lp64.so.2 chrt -r 99 ./myapp Please note that I already run the ../../opt/intel/oneapi/setvars.sh to set the env variables. Anyone has any idea what is wrong?
Anas (111 rep)
Sep 5, 2024, 04:57 PM
1 votes
1 answers
175 views
ADCIRC - Cannot find -lhdf5_fortran: No such file or directory
Trying to compile ADCIRC, a Fortran program with NetCDF support, and I hit the following error. ```/usr/bin/ld: cannot find -lhdf5_fortran: No such file or directory``` ```collect2: error: ld returned 1 exit status``` I am a little confused as to which file it is looking for as it cannot find any fi...
Trying to compile ADCIRC, a Fortran program with NetCDF support, and I hit the following error.
/usr/bin/ld: cannot find -lhdf5_fortran: No such file or directory
: error: ld returned 1 exit status
I am a little confused as to which file it is looking for as it cannot find any file named lhdf5_fortran. I have the libhdf5-dev and libhdf5-fortran-102 libraries installed. I am using Ubuntu.
Alexandre Georges (31 rep)
Jan 23, 2024, 10:11 PM • Last activity: Jan 24, 2024, 02:20 AM
1 votes
0 answers
98 views
Fortran program running on Ubuntu 22.04.1 but not on Debian 11
I am trying to run a Fortran program distributed as an executable for Linux (HOM4PS2_64-bit.tar.gz on [HOM4PS][1]). The program works fine on a machine running Ubuntu 22.04.1 (kernel: 5.19.0-42-generic). However, when trying the program (using test files shipped with the code, such as barry.sym) on...
I am trying to run a Fortran program distributed as an executable for Linux (HOM4PS2_64-bit.tar.gz on HOM4PS ). The program works fine on a machine running Ubuntu 22.04.1 (kernel: 5.19.0-42-generic). However, when trying the program (using test files shipped with the code, such as barry.sym) on a machine running Debian 11 (kernel: 5.10.0-23-amd64) the program fails with the following error: forrtl: severe (174): SIGSEGV, segmentation fault occurred Image PC Routine Line Source flwcrv 0000000000473523 Unknown Unknown Unknown flwcrv 00000000004FC730 Unknown Unknown Unknown flwcrv 00000000004734FF Unknown Unknown Unknown flwcrv 00000000004FC730 Unknown Unknown Unknown Stack trace terminated abnormally. I am aware that stack overflow could be one reason for the above error message. However, it should not really be a problem in this case, but I have also tried running the program after setting ulimit -s unlimited with the same result as above. What could be the reason(s) the program works on the Ubuntu machine but not the Debian machine? Is there anything I could do to address the issue? Note that I do not have access to the source code. I also considered posting the question on Stack Overflow instead. Please let me know if you think that would be more appropriate.
Baryogenesis (11 rep)
Jun 28, 2023, 03:06 PM
2 votes
2 answers
270 views
How to remove lines with nonsense format numbers?
I have the following data that I am processing to get the 1st and 5th column, convert the `D` format to `E` format and delete rows that have gibberish numbers such as `9.410-316`. ```text DEG = 1.500 2.600D+01 0.000D+00 0.000D+00 0.000D+00 0.000D+00 2.700D+01 8.720-304 2.369-316 7.556-316 9.410-316...
I have the following data that I am processing to get the 1st and 5th column, convert the D format to E format and delete rows that have gibberish numbers such as 9.410-316.
DEG =      1.500
	 2.600D+01     0.000D+00     0.000D+00     0.000D+00     0.000D+00
     2.700D+01     8.720-304     2.369-316     7.556-316     9.410-316
     4.300D+01     1.208D-83     4.156D-96     7.360D-96     6.984D-96
     1.590D+02     8.002D-07     6.555D-19     7.748D-19     7.376D-19
     1.600D+02     1.173D-06     9.669D-19     1.143D-18     1.089D-18
     1.610D+02     1.709D-06     1.417D-18     1.676D-18     1.596D+01
     1.620D+02     2.468D-06     2.058D-18     2.436D-18     2.320D-10
DEG =     18.500 
     2.700D+01     2.794-314     0.000D+00     0.000D+00     0.000D+00
     2.800D+01     4.352-285     1.224-297     3.685-297     4.412-297
     8.800D+01     1.371D-02     6.564D-15     7.852D-15     7.275D-15
My problem is in identifying the number formats that I want to delete. So far, I have tried
-bash
maxa=18.5
maxangle=$(printf "%.3f" $maxa)
if (( $(echo "$maxa 10, else only 5)
else
  txt2search="DEG =     $maxangle"
fi

line=$(grep -n "$txt2search" file  | cut -d : -f 1)

# Once the line number is read for the string, skip a few lines (4) and read next several lines(1000)
beginline=$((line + 4))
endline=$((line + 1002))
awk -v a="$beginline" -v b="$endline" 'NR==a, NR==b {print $1, $5}' fileinput > fileoutput
sed -i 's/D/E/g' fileoutput
Then, to discard the rows with the nonsense numbers, I tried (one at a time) and failed with the following commands.
-bash
sed -ni '/E/p' fileoutput
sed -E '/(E)/!d' fileoutput > spec2.tempdata
sed '/E/!d' fileoutput > spec2.tempdata
awk '!/E/' fileoutput > spec2.tempdata
How can I identify and remove lines with such nonsense numbers? The versions are * sed (GNU sed) 4.7 * grep (GNU grep) 3.4 * GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.2.0) The output would be
2.600D+01     0.000D+00     0.000D+00     0.000D+00     0.000D+00
4.300D+01     1.208D-83     4.156D-96     7.360D-96     6.984D-96
1.590D+02     8.002D-07     6.555D-19     7.748D-19     7.376D-19
1.600D+02     1.173D-06     9.669D-19     1.143D-18     1.089D-18
1.610D+02     1.709D-06     1.417D-18     1.676D-18     1.596D+01
1.620D+02     2.468D-06     2.058D-18     2.436D-18     2.320D-10
**EDIT:** The solution that I was looking for is (see first comment)
-bash
grep -v '[0-9]-'
csnl (35 rep)
Apr 11, 2023, 04:57 PM • Last activity: Apr 16, 2023, 10:16 PM
3 votes
2 answers
212 views
Indent Fortran source code, propagate indentation down to unindented special lines
I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) do not support indenting empty lines. I essentially want to use `sed` to run through the lines of a f...
I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) do not support indenting empty lines. I essentially want to use sed to run through the lines of a file and if the line is empty, then add spaces to the line until it has the same number of spaces as the line **above it** (therefore ignoring the first line). Because I want to use this as part of a pre-commit hook, it would be fantastic if the file was not modified if it passes the requirements. Example of unformatted file, where > corresponds to a space:
Start of document - First line is ignored
Second line has text and is therefore ignored
>>>>Third line has four spaces so below (empty line) should have 4 spaces added.

>>>>>>>>Third line has 8 spaces so below (empty line) should have 8 spaces added.

End of document
Desired output:
Start of document - First line is ignored
Second line has text and is therefore ignored
>>>>Third line has four spaces so below (empty line) should have 4 spaces added.
>>>>
>>>>>>>>Third line has 8 spaces so below (empty line) should have 8 spaces added.
>>>>>>>>
End of document
Also, related to this is I would like to indent a line that starts with an exclamation mark **in column 1** (without any spaces before it) to level of the line above (as this is not supported by the autoformatter that I use). Example of unformatted file, where > corresponds to a space:
Start of document - First line is ignored
! Second line starts with exclamation mark in column 1 so it is indented to level of above line
>>>>Third line has 4 spaces to start
!This should have 4 spaces added to it because the first character is ‘!’ and above line has 4
>>>>>>>>This line has 8 spaces
>>>>>>>>!This line shouldn’t be changed as it begins with a space, not an exclamation mark.
End of document
Desired output:
Start of document - First line is ignored
! Second line starts with exclamation mark in column 1 so it is indented to level of above line
>>>>Third line has 4 spaces to start
>>>>!This should have 4 spaces added to it because the first character is ‘!’ and above line has 4
>>>>>>>>This line has 8 spaces
>>>>>>>>!This line shouldn’t be changed as it begins with a space, not an exclamation mark.
End of document
I am very new to bash scripting so explanations of how any solutions work would be great and thanks in advance for any help! Edit: replaced images with text as requested by comment!
Philip Moloney (31 rep)
Feb 11, 2023, 03:28 PM • Last activity: Mar 9, 2023, 11:57 AM
0 votes
1 answers
63 views
BlockSolve.o Error in Makefile
I am trying to run Enzo Project simulation and have followed the steps listed on the website here: https://enzo.readthedocs.io/en/latest/user_guide/bootcamp.html . I have been getting an error and google searches are not shedding light on what is going wrong on my end. Here is the error I am getting...
I am trying to run Enzo Project simulation and have followed the steps listed on the website here: https://enzo.readthedocs.io/en/latest/user_guide/bootcamp.html . I have been getting an error and google searches are not shedding light on what is going wrong on my end. Here is the error I am getting:
Compiling BlockSolve.F
gfortran  -c -o BlockSolve.o -fno-second-

underscore -m64 -g -DLINUX -DH5_USE_16_API   -D__max_subgrids=100000 -D__max_baryons=30 -D__max_cpu_per_node=8 -D__memory_pool_size=100000 -DINITS64 -DLARGE_INTS -DCONFIG_PINT_8 -DIO_32    -DUSE_MPI   -DCONFIG_PFLOAT_8 -DCONFIG_BFLOAT_8  -DUSE_HDF5_GROUPS   -DTRANSFER   -DNEW_GRID_IO -DFAST_SIB      -DENZO_PERFORMANCE    -DUSE_UUID -DSAB BlockSolve.F
    
BlockSolve.F:1070:11:

 1070 |       NB = ILAENV( 1, 'UGETRF', ' ', M, N, -1, -1 )
      |           1
Error: Type mismatch in argument 'ispec' at (1); passed INTEGER(4) to INTEGER(8)
BlockSolve.F:1070:11:

 1070 |       NB = ILAENV( 1, 'UGETRF', ' ', M, N, -1, -1 )
      |           1
Error: Type mismatch in argument 'n3' at (1); passed INTEGER(4) to INTEGER(8)
BlockSolve.F:1070:11:

 1070 |       NB = ILAENV( 1, 'UGETRF', ' ', M, N, -1, -1 )
      |           1
Error: Type mismatch in argument 'n4' at (1); passed INTEGER(4) to INTEGER(8)
BlockSolve.F:932:30:

  932 |          JP = J - 1 + e_idamax( M-J+1, A( J, J ), 1 )
      |                              1
Error: Type mismatch in argument 'incx' at (1); passed INTEGER(4) to INTEGER(8)
BlockSolve.F:2628:18:

 2628 |          ILAENV = IEEECK( 0, 0._RKIND, 1._RKIND )
      |                  1
Error: Type mismatch in argument 'ispec' at (1); passed INTEGER(4) to INTEGER(8)
BlockSolve.F:2639:18:

 2639 |          ILAENV = IEEECK( 1, 0._RKIND, 1._RKIND )
      |                  1
Error: Type mismatch in argument 'ispec' at (1); passed INTEGER(4) to INTEGER(8)

make: *** [BlockSolve.o] Error 1
Jacob Krebs (1 rep)
Feb 27, 2023, 10:10 PM • Last activity: Feb 28, 2023, 09:00 AM
0 votes
1 answers
590 views
Why compiling Fortran code with include is different from #include?
I can't understand why including a text file that contains some C lines in a fortran77 code gives me a warning if I do not use `#include`. I wrote an example of a code that is supposed to read some text to be added to the main file, `test.F`: ``` program testInclude include 'includetest.txt' end pro...
I can't understand why including a text file that contains some C lines in a fortran77 code gives me a warning if I do not use #include. I wrote an example of a code that is supposed to read some text to be added to the main file, test.F:
program testInclude
       include 'includetest.txt'
       end program
and the includetest.txt file to be included contains the following
#define _TEST_
#ifdef _TEST_
       write(*,*) 'check'
#endif
If I compile it with gfortran test.F I get the following warning:
includetest.txt:2:2:

    2 | #define _TEST_
      |  1
Warning: Illegal preprocessor directive
includetest.txt:3:2:

    3 | #ifdef _TEST_
      |  1
Warning: Illegal preprocessor directive
includetest.txt:5:2:

    5 | #endif
      |  1
Warning: Illegal preprocessor directive
while no warnings are given if I use #include instead of include in the 2nd line of test.F. Aren't the fortran include statement and the C #include one supposed to do the same exact thing and add some lines of text to another file? What does the warning mean? This happens with gcc 12.2.0 on Arch and Mac OS X, and with gcc 4.8.5 on CentOS.
Giorgio Maria Cavallazzi (3 rep)
Nov 21, 2022, 09:50 PM • Last activity: Nov 21, 2022, 11:18 PM
0 votes
1 answers
130 views
Installing UrQMD in Linux Mint gives error after make command
I am using Linux Mint 21 Cinammon to install the UrQMD simulation package. I have ROOT installed as well as all the required dependencies as specified by the [webpage][1]. The instructions say: $ tar -xvf urqmd-3.4.tar $ make After the make command, I get if [ -e lhc ]; then patch -R -p0 < lhc.patch...
I am using Linux Mint 21 Cinammon to install the UrQMD simulation package. I have ROOT installed as well as all the required dependencies as specified by the webpage . The instructions say: $ tar -xvf urqmd-3.4.tar $ make After the make command, I get if [ -e lhc ]; then patch -R -p0 < lhc.patch || true; fi rm -f lhc gfortran -O3 -mcmodel=medium -c make22.f -o obj_x86_64/make22.o make22.f:548:72: 548 | 151 ba2(j)=0d0 | 1 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 151 at (1) make22.f:3593:72: 3593 | 152 ba2(j)=p(2,j)/p(2,4) | 1 Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 152 at (1) make22.f:1644:45: 1644 | call getbran((/sig1,sig2,sig3/),1,3,dummy,1,3,channel) | 1 ...... 3739 | call getbran(x,minnuc,maxmes,xmax,im,ip,ir) | 2 Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(4)/REAL(8)). make22.f:1670:39: I suspect it has to do with the version of gfortran since it's recommended to use 6 or below as the software hasn't been updated in some time. I also tried to install an older version of gfortran and gcc but it didn't work either.
voidonaut (1 rep)
Aug 16, 2022, 05:19 AM • Last activity: Aug 16, 2022, 05:25 AM
0 votes
1 answers
179 views
How to debug binary file from legacy FORTRAN? Help
I'm working with an older proprietary FORTRAN legacy code from specific corporation (so can't post much source code), I'm having an issue with the file interactions. My compiler bash shell `Install` is calling `make newspaper` which calls a series of other functions via the `makefile` bash shell to...
I'm working with an older proprietary FORTRAN legacy code from specific corporation (so can't post much source code), I'm having an issue with the file interactions. My compiler bash shell Install is calling make newspaper which calls a series of other functions via the makefile bash shell to create newspaper. However, when newspaper is then called within Install with an input file to compare to an output file newspaper then returns not found. I've tried opening the file newspaper to look at it for the error. I've tried converting newspaper into text, simply yielding a text file filled with numbers. I need to read the file as "code" to figure out whats going wrong and causing not found to crop up. For Clarification: - newspaper is a binary file as when doing less newspaper in the terminal my Linux operator said its a binary file - the calling of newspaper inside Install has the following format newspaper f1.test this is followed by diff xfile1R.out f1.test > f1.dif - gfortran is the compiler being used in Ubuntu, the c drive is a mounted drive - little endian should be the binary format used according to this site I'm a noob when it comes to Linux and FORTRAN, I may just be making a rookie mistake, would really appreciate any advice, im not sure if this is a Linux or FORTRAN issue.
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ sh ./Install.sh
cat makefile.sh >makefile
chmod a+x makefile
make: 'newspaper' is up to date.
./Install.sh: 10: newspaper: not found
./Install.sh: 12: newspaper: not found
./Install.sh: 14: newspaper: not found
./Install.sh: 16: newspaper: not found
./Install.sh: 18: newspaper: not found
./Install.sh: 20: newspaper: not found
 84 -rwxrwxrwx 1 roman roman  83071 Feb 17 16:08 f1.dif
152 -rwxrwxrwx 1 roman roman 153543 Feb 17 16:08 f2.dif
108 -rwxrwxrwx 1 roman roman 109718 Feb 17 16:08 f3.dif
232 -rwxrwxrwx 1 roman roman 236209 Feb 17 16:08 f4.dif
164 -rwxrwxrwx 1 roman roman 166612 Feb 17 16:08 f5.dif
 48 -rwxrwxrwx 1 roman roman  48898 Feb 17 16:08 f6.dif
./Install.sh: 31: Syntax error: newline unexpected
Edit 1: tried file newspaper to check PATH
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ file newspaper
newspaper: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=8ac6de30da50639d7e3ea55a09416b049a5291c0, for GNU/Linux 3.2.0, not stripped
Edit 2: Make file fix?
#
# Makefile for newspaper
#

OBJF = \
	sfun1.o \
	sfun2.o \
	sfun3.o \
	sfun4.o \
	sfun5.o \
	sfun6.o \
	sfun7.o 


FLAGS = -O2 -static -std=legacy
COMP  = gfortran

newspaper: $(OBJF)
	$(COMP) $(FLAGS) -o newspaper $(OBJF)

.f.o:
	$(COMP) $(FLAGS) -c $ f1.test
diff xfile1R.out f1.test > f1.dif
./newspaper  f2.test
diff xfile2R.out f2.test > f2.dif
./newspaper  f3.test
diff xfile3R.out f3.test > f3.dif
./newspaper  f4.test
diff xfile4R.out f4.test > f4.dif
./newspaper  f5.test
diff xfile5R.out f5.test > f5.dif
./newspaper  f6.test
diff xfile6.out f6.test > f6.dif

ls -als *.dif

# User input for directory to put executable
if ( $1 == '' ) then
   echo " "
   echo -n "Enter directory for executable file: "
   set Edir = $<
else
   set Edir = $1
endif

if ( $Edir != '' ) then
   mv newspaper $Edir
endif
Edit 4: More Syntax error, same error
./Install.sh: 30: Syntax error: newline unexpected
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ ./
-bash: ./: Is a directory
roman@DESKTOP-QKJTF3S:
Edit 5: csh check
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/Documents/NEWSPAPER/Newspaper/Newspaper$ sudo apt-get install csh
Reading package lists... Done
Building dependency tree
Reading state information... Done
csh is already the newest version (20110502-5).
0 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
Edit 6: It worked!! Courtesy to @steeldriver for guiding myself the noob
164 -rwxrwxrwx 1 roman roman 164829 Feb 17 21:36 f1.dif
304 -rwxrwxrwx 1 roman roman 307257 Feb 17 21:36 f2.dif
216 -rwxrwxrwx 1 roman roman 217791 Feb 17 21:36 f3.dif
460 -rwxrwxrwx 1 roman roman 468651 Feb 17 21:36 f4.dif
324 -rwxrwxrwx 1 roman roman 331213 Feb 17 21:36 f5.dif
 96 -rwxrwxrwx 1 roman roman  96955 Feb 17 21:36 f6.dif

Enter directory for executable file: ./Outputs
roman@DESKTOP-QKJTF3S:/mnt/c/Users/roman/
The Immortal (31 rep)
Feb 17, 2022, 11:24 PM • Last activity: Feb 18, 2022, 05:12 AM
0 votes
2 answers
299 views
Complete file line by line reading dates
I have a text file containing 2 columns. The first one has DATES (DD/MM/YYYY) and the second one, numbers. It looks like this: ``` 15/01/1945 105.0 16/01/1945 4.2 17/01/1945 3.0 31/01/1945 12.0 01/02/1945 3.0 02/02/1945 125.0 05/02/1945 0.3 ``` And I need to fill the file with this conditions: 1. Fi...
I have a text file containing 2 columns. The first one has DATES (DD/MM/YYYY) and the second one, numbers. It looks like this:
15/01/1945 105.0
16/01/1945   4.2
17/01/1945   3.0
31/01/1945  12.0
01/02/1945   3.0
02/02/1945 125.0
05/02/1945   0.3
And I need to fill the file with this conditions: 1. First date 01/01/1945 2. Last date 31/12/2021 3. Dates must be consecutive, with a difference of one day between lines 4. If there is a missing date, we have to complete the line with the correct date and the number -99.0 So, the final file should look like this:
01/01/1945 -99.0
02/01/1945 -99.0
03/01/1945 -99.0
04/01/1945 -99.0
05/01/1945 -99.0
06/01/1945 -99.0
07/01/1945 -99.0
08/01/1945 -99.0
09/01/1945 -99.0
10/01/1945 -99.0
11/01/1945 -99.0
12/01/1945 -99.0
13/01/1945 -99.0
14/01/1945 -99.0
15/01/1945 105.0
16/01/1945   4.2
17/01/1945   3.0
18/01/1945 -99.0
19/01/1945 -99.0
20/01/1945 -99.0
21/01/1945 -99.0
22/01/1945 -99.0
23/01/1945 -99.0
24/01/1945 -99.0
25/01/1945 -99.0
26/01/1945 -99.0
27/01/1945 -99.0
28/01/1945 -99.0
29/01/1945 -99.0
30/01/1945 -99.0
31/01/1945  12.0
01/02/1945   3.0
02/02/1945 125.0
03/02/1945 -99.0
04/02/1945 -99.0
05/02/1945   0.3
06/02/1945 -99.0
07/02/1945 -99.0
...
30/12/2021 -99.0
31/12/2021 -99.0
I have tried by using a fortran program but it doesn't work. I think that maybe using awk or sed or both. This is what I get when I read Ed's script:
`        
meteo@poniente:/datos$ cat awk.script
#!/bin/bash
cat tst.awk
awk { dates2vals[$1] = $2 }
END {
    begDate = "01/01/1945"
    endDate = "31/12/2000"
    begSecs = mktime(gensub("(.*)/(.*)/(.*)","\\3 \\2 \\1 12 00 00",1,begDate))
    daySecs = 24 * 60 * 60
    for (curSecs=begSecs; curDate!=endDate; curSecs+=daySecs) {
        curDate = strftime("%d/%m/%Y",curSecs)
        print curDate, (curDate in dates2vals ? dates2vals[curDate] : "-99.0")
    }
}
` And this is what I get when I run Ed's script:
`
meteo@poniente:/datos$ ./tst.awk
01/01/1946   3.0
02/01/1946  14.2
...
14/11/2021   0.0
15/11/2021   0.0
16/11/2021   0.0
17/11/2021   0.0
18/11/2021   0.0
19/11/2021   0.0
20/11/2021   0.0
21/11/2021   0.0
22/11/2021  54.1
23/11/2021 -99.0
24/11/2021  27.4
25/11/2021   0.0
29/11/2021   0.0
30/11/2021   0.0
awk: li­ne ord.:1: {
awk: line ord.:1:  ^ unexpected newline or end of string
./awk.script: li­ne 4: END: command not found
./awk.script: li­ne 5: begDate: command not found
./awk.script: li­ne 6: endDate: command not found
./awk.script: li­ne 7: syntax error near unexpected element `('
./awk.script: li­ne 7: `    begSecs = mktime(gensub("(.*)/(.*)/(.*)","\\3 \\2 \\1 12 00 00",1,begDate))'
meteo@poniente:/datos$
`
David (1 rep)
Feb 11, 2022, 11:52 AM • Last activity: Feb 17, 2022, 02:37 PM
0 votes
0 answers
156 views
gfortran: command not found even after sudo apt-get install
system says the latest version of `gfortran` has been installed when I retry the `sudo` command, but then i still get the command not found error for `gfortran`. I'm guessing it's something to do with the directory? I'm using a virtual machine to emulate 29~20.04.1-Ubuntu. The command: ```sh gfortra...
system says the latest version of gfortran has been installed when I retry the sudo command, but then i still get the command not found error for gfortran. I'm guessing it's something to do with the directory? I'm using a virtual machine to emulate 29~20.04.1-Ubuntu. The command:
gfortran hello.f90 -o hello
and the error:
gfortran: Command not found.
When I use sudo apt-get install gfortran, i get: gfortran is already the newest version (4:9.3.0-1ubuntu2).
antonia (1 rep)
Aug 22, 2021, 11:00 AM • Last activity: Aug 22, 2021, 11:15 AM
0 votes
1 answers
572 views
How to catch and break on a Fortran 90 runtime error in GDB?
Is it possible to have Fortran 90 break at a runtime error in GDB? I show here a MWE for a simple routine *test.f90* which throws an out of bounds error: ``` program main implicit none integer :: i integer, parameter :: npt = 10 real, dimension(npt) :: A real :: B ! do i = 1,npt A(i) = i enddo B = A...
Is it possible to have Fortran 90 break at a runtime error in GDB? I show here a MWE for a simple routine *test.f90* which throws an out of bounds error:
program main
  implicit none
  integer              :: i
  integer, parameter   :: npt = 10
  real, dimension(npt) :: A
  real                 :: B
  !
  do i = 1,npt
     A(i) = i
  enddo
  B = A(npt+1)
  !
end program main
I compile as follows:
gfortran test.f90 -O0  -fbacktrace  -fbounds-check -g -Wall -w -o test.x
Which, mostly as expected, gives the backtrace here:
Error termination. Backtrace:
#0  0x7ffff7a0f2ed in ???
#1  0x7ffff7a0fed5 in ???
#2  0x7ffff7a102a7 in ???
#3  0x55555555480e in MAIN__
	at ~/test.f90:11
#4  0x555555554844 in main
	at ~/test.f90:13
When I run in GDB I set
catch
and
throw
catchpoints, but upon running GDB still lets the program terminate and I don't have frames to look at.
(gdb) catch catch
Catchpoint 1 (catch)
(gdb) catch throw
Catchpoint 2 (throw)
(gdb) r test.x
`~/test.x' has changed; re-reading symbols.
Starting program: ~/test.x test.x
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
[Inferior 1 (process 3769) exited normally]
(gdb) where
No stack.
(gdb) bt
No stack.
(gdb)
How can I get GDB to catch errors like this and start debugging from the culprit line? Obviously it's easy to identify useful break points in smaller scripts but in a larger legacy Fortran code it can save a ton of time and effort.
tdstoff (3 rep)
Aug 18, 2021, 12:50 PM • Last activity: Aug 19, 2021, 03:47 PM
3 votes
1 answers
3724 views
Why do I have to set LD_LIBRARY_PATH before running a program, even though I already linked the library locations in the compile stage?
I am compiling a model using `make`. The model has a `Makefile` that connects the source code with dependent libraries via flags that look like `-L/lib1 -L/lib2`. But when I try to run that model, it fails unless I also ensure the environmental variable ```bash export LD_LIBRARY_PATH=/lib1:/lib2 ```...
I am compiling a model using make. The model has a Makefile that connects the source code with dependent libraries via flags that look like -L/lib1 -L/lib2. But when I try to run that model, it fails unless I also ensure the environmental variable
export LD_LIBRARY_PATH=/lib1:/lib2
and points to the exact same libraries. This seems redundant to me. What could be going on under the hood here? Why do I effectively have to specify the location of the libraries before compilation and before execution? This might be a silly question; I'm not very experienced compiling to machine code, usually just use scripting languages.
Luke Davis (344 rep)
Feb 18, 2018, 07:40 PM • Last activity: Jun 10, 2021, 06:14 PM
1 votes
1 answers
307 views
Interactive Fortran Program
I have an old fortran executable `foo.exe` that requires interactive input. If I call `foo.exe` from Cywin I am prompted for the interactive input and the program works fine. If I call `foo.exe` from WSL I am prompted for interactive input and the program works fine. I would like to run a script or...
I have an old fortran executable foo.exe that requires interactive input. If I call foo.exe from Cywin I am prompted for the interactive input and the program works fine. If I call foo.exe from WSL I am prompted for interactive input and the program works fine.


I would like to run a script or send input to foo.exe such that I don't need to go through the process of entering everything interactively. In Cygwin I do the following:
foo.exe 

I attempt to do the same thing in WSL and I get the following error message:
forrtl: An attempt was made to move the file pointer before the beginning of the file. forrtl: severe (39): error during read, unit -4, file CONIN$ Image PC Routine Line Source libifcorert.dll 1003A159 Unknown Unknown Unknown

----------------- So I grabbed the original file foo.f and I attempted to recompile it using gfortran
gfortran foo.f -o new_foo.exe
I then attempt to interactively call new_foo.exe from Cygwin and I get the following:
bash: ./newfoo.exe: cannot execute binary file: Exec format error
So what used to work in Cygwin no longer does.  

I then attempt to interactively call new_foo.exe from WSL and it works fine.

I can now run a script or send input to new_foo.exe using WSL and it works fine (couldn't do that before) but I have lost the ability to do it on Cygwin. One step forward, two steps back??

-----------------



I then thought maybe I should recompiling it using 32-bit:
gfortran -m32 foo.f -o new_foo_32.exe
This 32-bit compiled program doesn't work with Cygwin or WSL giving the following error on both:
bash: ./newfoo.exe: cannot execute binary file: Exec format error
The ultimate goal is to have a single foo.exe program that runs interactively on both Cygwin & WSL (my original code does this) **AND** allows me to pipe/send input on both Cygwin & WSL (my original code only allows me to do this in Cygwin).    

Any suggestions?



==============
Cygwin Version ==============
CYGWIN_NT-10.0-WOW 2.4.1(0.293/5/3) 2016-01-24 11:24 i686 Cygwin
==============
WSL version ==============
Linux 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal ```
Matt (83 rep)
Mar 22, 2021, 04:12 PM • Last activity: Mar 22, 2021, 09:36 PM
3 votes
1 answers
13842 views
How to install a FORTRAN compiler on macOS?
I am trying to install a Fortran compiler on my Mac Pro 2019 (running macOS). First step is: sudo apt-get install gfortran but I get error: `command not found` I also tried brew install gfortran also port install gfortran but again, the same error.
I am trying to install a Fortran compiler on my Mac Pro 2019 (running macOS). First step is: sudo apt-get install gfortran but I get error: command not found I also tried brew install gfortran also port install gfortran but again, the same error.
shere (149 rep)
Aug 18, 2019, 10:47 PM • Last activity: Sep 26, 2020, 11:07 AM
2 votes
2 answers
402 views
Feeding a command using file redirection or pipe doesn't always work
I've downloaded this program [construct2d](https://sourceforge.net/projects/construct2d/) and compiled it using GNU Fortran `gfortran 9.3.0`. You can compile the program using gnu make: ``` make ``` (compilation time: 10 seconds on my PC running Ubuntu 20.04 with GNU bash, version 5.0.17(1)-release...
I've downloaded this program [construct2d](https://sourceforge.net/projects/construct2d/) and compiled it using GNU Fortran gfortran 9.3.0. You can compile the program using gnu make:
make
(compilation time: 10 seconds on my PC running Ubuntu 20.04 with GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu) ). This program doesn't work with arguments, instead I have to enter manually the options. In order to avoid that tedious workflow I wrote the options in a file instructions.txt to feed it.
construct2d < instructions.txt
The content of instructions.txt is:
naca0012.dat
SOPT
NSRF
80
RADI
5
NWKE
5
QUIT
VOPT
JMAX
5
YPLS
5
RECD
1E5
QUIT
GRID
SMTH
QUIT
The file naca0012.dat can be found under sample_airfoils directory from uncompressed construct2D archive or can be downloaded from this [link](https://gist.github.com/SignificantCell2/fd75765b9ffd45e880901564e990e2c3) . The problem is that the command:
construct2d < instructions.txt
doesn't give the expected result when I run it only once, I have to run the command above several times (4 times maybe) to get the expected results: (the expected output is: naca0012.p3d and naca0012.nmf). When I run construct2d manually and type the options in instructions.txt one by one, it works as expected. I've tried to use gdb to debug that but unfrotunately it doesn't show anything special. So it appears that the program is ignoring some instructions when feeded from a file. Why does this happen? * The stdout output when the program runs as expected (in addition, the program will generate the output files: naca0012.p3d and naca0012.nmf): [working.log](https://gist.github.com/SignificantCell2/08103ec60378b0946a85b7db6811df16) * The stdout output when the program doesn't run as exepcted (without output files): [not_working.log](https://gist.github.com/SignificantCell2/b375858378df10ebc078e396c311f1f5) I greatly appreciate your help. **EDIT 1**: On Windows 10, with gfortran 8.1.0, file redirection works just fine, it doesn't fail. This happens only on Linux as I described above. **EDIT2**: I confirm this has nothing to do with line endings. Because I've created the file instructions.txt itself on Linux. And used dos2unix tool to check the file. **EDIT3** I have tried compiling the program with older versions of gfortran (gfortran 7.5.0 on Ubuntu server 18.04) and everything works correctly. This might be a bug in newer versions of GNU Fortran. **EDIT 4**: I've solved that weird behaviour in gfortran 9.x and 10.x by adding the flag -Og or -O0 when compiling the program.
adhrar_nmatrous (85 rep)
Sep 16, 2020, 04:35 PM • Last activity: Sep 19, 2020, 04:31 AM
0 votes
0 answers
501 views
Using "expect" command to run an interactive program fails
I am trying to solve my question that I've asked [here](https://unix.stackexchange.com/q/609693/429557) using `expect` script instead of file redirection. Unfortunately, this solution doesn't work as well (the same behaviour as described in the question above: I have to run the script below `./drive...
I am trying to solve my question that I've asked [here](https://unix.stackexchange.com/q/609693/429557) using expect script instead of file redirection. Unfortunately, this solution doesn't work as well (the same behaviour as described in the question above: I have to run the script below ./driver.exp multiple times to get the expected result. Here is the error message:
...

 Input > QUIT
send: spawn id exp4 not open
    while executing
"send "VOPT\n""
    (file "./driver.exp" line 33)
(The full stdout output can be found [here](https://gist.github.com/SignificantCell2/505fb7bd5fd2085895f3472585c5c470)) Here is my driver.exp file:
#!/usr/bin/expect

spawn construct2d

expect "Input"
send "naca0012.dat\n"

expect "Command"
send "SOPT\n"

expect "Input"
send "NSRF\n"

expect "New value"
send "80\n"

expect "Input"
send "RADI\n"

expect "New value"
send "1\n"

expect "Input"
send "NWKE\n"

expect "New value"
send "1\n"

expect "Input"
send "QUIT\n"

expect "Command"
send "VOPT\n"

expect "Input"
send "JMAX\n"

expect "New value"
send "1\n"

expect "Input"
send "YPLS\n"

expect "New value"
send "5\n"

expect "Input"
send "RECD\n"

expect "New value"
send "1E5\n"

expect "Input"
send "QUIT\n"

expect "Command"
send "GRID\n"

expect "Input"
send "SMTH\n"

expect "Command"
send "QUIT\n"

interact
Could you please, help me understand why is this happening? I appreciate your help
adhrar_nmatrous (85 rep)
Sep 16, 2020, 07:08 PM
-1 votes
2 answers
1466 views
fortran in fedora linux
I have installed Fedora Linux on my computer. I would like to have the following software installed on it: fortran gnuplot xfig latex dvips ghostview dvipdf How can I do it?
I have installed Fedora Linux on my computer. I would like to have the following software installed on it: fortran gnuplot xfig latex dvips ghostview dvipdf How can I do it?
Razee (69 rep)
Apr 21, 2017, 09:39 PM • Last activity: Sep 11, 2020, 12:47 PM
5 votes
3 answers
6589 views
LAPACK make fails: "recipe for target 'znep.out' failed" error
My main problem is getting this error: Makefile:463: recipe for target 'znep.out' failed after running `make` I was trying to install [GPAW][1] (g Projector Augmented Wave method, for [DFT][2] simulations) on my machine. ASE is working, and I already installed the [Libxc][3], and compiled the BLAS l...
My main problem is getting this error: Makefile:463: recipe for target 'znep.out' failed after running make I was trying to install GPAW (g Projector Augmented Wave method, for DFT simulations) on my machine. ASE is working, and I already installed the Libxc , and compiled the BLAS libraries as specified here but when performing 'make' on the extracted package I always get the same error: ~/Downloads/lapack-3.8.0$ make gfortran -O2 -frecursive -c -o zunt03.o zunt03.f gfortran -o xeigtstz zchkee.o zbdt01.o zbdt02.o zbdt03.o zbdt05.o zchkbb.o zchkbd.o zchkbk.o zchkbl.o zchkec.o zchkgg.o zchkgk.o zchkgl.o zchkhb.o zchkhs.o zchkst.o zchkst2stg.o zchkhb2stg.o zckcsd.o zckglm.o zckgqr.o zckgsv.o zcklse.o zcsdts.o zdrges.o zdrgev.o zdrges3.o zdrgev3.o zdrgsx.o zdrgvx.o zdrvbd.o zdrves.o zdrvev.o zdrvsg.o zdrvsg2stg.o zdrvst.o zdrvst2stg.o zdrvsx.o zdrvvx.o zerrbd.o zerrec.o zerred.o zerrgg.o zerrhs.o zerrst.o zget02.o zget10.o zget22.o zget23.o zget24.o zget35.o zget36.o zget37.o zget38.o zget51.o zget52.o zget54.o zglmts.o zgqrts.o zgrqts.o zgsvts3.o zhbt21.o zhet21.o zhet22.o zhpt21.o zhst01.o zlarfy.o zlarhs.o zlatm4.o zlctes.o zlctsx.o zlsets.o zsbmv.o zsgt01.o zslect.o zstt21.o zstt22.o zunt01.o zunt03.o dlafts.o dlahd2.o dlasum.o dlatb9.o dstech.o dstect.o dsvdch.o dsvdct.o dsxt1.o alahdg.o alasum.o alasvm.o alareq.o ilaenv.o xerbla.o xlaenv.o chkxer.o ../../libtmglib.a ../../liblapack.a ../../librefblas.a make[2] : Leaving directory '/home/joshua/Downloads/lapack-3.8.0/TESTING/EIG' NEP: Testing Nonsymmetric Eigenvalue Problem routines ./EIG/xeigtstz znep.out 2>&1 Makefile:463: recipe for target 'znep.out' failed make[1] : *** [znep.out] Error 139 make[1] : Leaving directory '/home/joshua/Downloads/lapack-3.8.0/TESTING' Makefile:42: recipe for target 'lapack_testing' failed make: *** [lapack_testing] Error 2 I used the default configuration for the 'Makefile' which is proposed in the Installation instructions. The default file is in here . Any suggestion? I use Kubuntu 17.10
Joshua Salazar (385 rep)
Mar 6, 2018, 12:41 AM • Last activity: Jul 30, 2020, 05:59 AM
0 votes
0 answers
68 views
Environment allowing Fortran to call a C function
I'm trying to install a large atmospheric model (WRF) on my newly set up Centos 7 machine. To start the installation process, the model's developers give a series of environmental tests. My set up fails the fourth one--Fortran Calling a C Function. (I passed the first three: fixed and free format Fo...
I'm trying to install a large atmospheric model (WRF) on my newly set up Centos 7 machine. To start the installation process, the model's developers give a series of environmental tests. My set up fails the fourth one--Fortran Calling a C Function. (I passed the first three: fixed and free format Fortran and C only.) This test consists of two small programs. First, TEST_4_fortran+c_c.c:
::::::::::::::
TEST_4_fortran+c_c.c
::::::::::::::
#ifndef CRAY
# ifdef NOUNDERSCORE
#      define C_TEST c_test
# else
#   ifdef F2CSTYLE
#      define C_TEST c_test__
#   else
#      define C_TEST c_test_
#   endif
# endif
#endif
#include 

int C_TEST ( float *xx, int *ii )

{
 printf("   C function called by Fortran\n" ) ;
 printf("   Values are xx = %5.2f and ii = %d \n", *xx, *ii ) ;
 return(0) ;
}
Compiling it "gcc -c -m64 TEST_4_fortran+c_c.c" went fine with no errors. The second program, TEST_4_fortran+c_f.f90:
PROGRAM foo
   INTEGER :: ii
   REAL    :: xx

   ii = 1
   xx = 2

   CALL c_test ( xx , ii )

   print *,'SUCCESS test 4 fortran calling c'

END PROGRAM foo
Compiling gfortran -c -m64 TEST_4_fortran+c_f.f90 also had no errors. When I attempt to execute the fortran gfortran -m64 TEST_4_fortran+c_f.o I get:
TEST_4_fortran+c_f.o: In function `MAIN__':
TEST_4_fortran+c_f.f90:(.text+0x2f): undefined reference to `c_test_'
collect2: error: ld returned 1 exit status
I just installed Centos 7, so everything is "out of the box."
MrCatDad (11 rep)
Dec 3, 2019, 04:54 PM • Last activity: Dec 3, 2019, 05:07 PM
Showing page 1 of 20 total questions