- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I tried to compile my codes with commanding "$ ifort -o Weibull Weibull.for", but it gave me an error that
'$' is not recognized as an internal or external command,
operable program or batch file.
$ should be used right?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yanmei,
You can use the command line, but you have to set up the compiler environment. Intel installs shortcuts that do it for you as I showed above. You can also use the compiler from a command prompt you started some other way (cmd.exe, etc.) but first must type the command:
call "%IFORT_COMPILER20%bin\ipsxe-comp-vars.bat" intel64
This assumes you have the current version. Replace 20 with 19 for the 2019 version, etc.
Now to your code. I am going to guess that you stayed with calling the program Weibull.for, which makes it fixed-form source (read the Doctor Fortran article I linked to above.) The only line you have where that matters is the FORMAT line. In fixed-form source, statement labels (the 5) must be in columns 1-5. So you could move the 5 into column 1, making sure the word "format" is in column 7 or higher. The alternative, which I would recommend, is to rename the file Weilbull.f90, in which case it will compile as it is.
I see one error in your code, though. You have:
read*,Elem_array
twice. I think the second time you want to read into Ts_array.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, don't use $. $ is a command processor prompt used by some shells on Linux systems, but that was a Windows error message. If you saw it in an example, it was meant to represent the prompt, not something to type.
I would also suggest that you're reading instructions for a non-Windows system. The command you wrote would be accepted, but probably doesn't do what you intend. On Windows use:
ifort Weibull.for
You don't need any other options - the executable will be named Weibull.exe.
If this is a program you wrote, may I strongly suggest that you learn about free-form source and use that for your code rather than fixed-form? (See Doctor Fortran in “Source Form Just Wants to be Free”) .for as a file type indicates fixed-form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Thank you so much for the explanation. I tried
ifort Weibull.for
it turns out that
'ifort' is not recognized as an internal or external command,
operable program or batch file.
Is there anything wrong with my system?
Yanmei
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How are you getting to the command prompt? Use Start > Intel Parallel Studio XE 20xx > Compiler 1x.x for Intel 64 ... (select the option that seems best for you.)
Note that this will set you up in a default directory you can't use, so you would need to "cd" to a writable directory. What I like to do is copy one of those shortcuts to my desktop and change the properties so that the shortcut is (for example):
C:\Windows\System32\cmd.exe /E:ON /V:ON /K ""%IFORT_COMPILER20%bin\ipsxe-comp-vars.bat" intel64 vs2019"
and the Start in is my projects folder.
IFORT_COMPILER20 is for the Compiler XE 2020 product - change this to IFORT_COMPILER19 for 2019, etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
I found that I need to use Intel Composer Intel Visual studio instead of cmd.exe.
Now I have another problem, that I need to read two text files and write them in a file. I wrote it as below. The label of the format statement which I use as 5, seems to be wrong.
PROGRAM Weibull
INTEGER Elem_array(33)
REAL Ts_array(33)
open (unit=12, file="Elem_array")
read*,Elem_array
open (unit=12, file="Ts_array")
read*,Elem_array
do 33 i =1,33
write(*,5), (Element(i),Ts_array(i))
5 format (I8,F10.5)
end do
close(12)
end
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yanmei,
You can use the command line, but you have to set up the compiler environment. Intel installs shortcuts that do it for you as I showed above. You can also use the compiler from a command prompt you started some other way (cmd.exe, etc.) but first must type the command:
call "%IFORT_COMPILER20%bin\ipsxe-comp-vars.bat" intel64
This assumes you have the current version. Replace 20 with 19 for the 2019 version, etc.
Now to your code. I am going to guess that you stayed with calling the program Weibull.for, which makes it fixed-form source (read the Doctor Fortran article I linked to above.) The only line you have where that matters is the FORMAT line. In fixed-form source, statement labels (the 5) must be in columns 1-5. So you could move the 5 into column 1, making sure the word "format" is in column 7 or higher. The alternative, which I would recommend, is to rename the file Weilbull.f90, in which case it will compile as it is.
I see one error in your code, though. You have:
read*,Elem_array
twice. I think the second time you want to read into Ts_array.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unit 12 is opened twice in the program with no CLOSE in between, and no I/O is done on that unit. That is probably an error, and the READ statements probably were meant to read from unit 12.
The I/O list in the WRITE statement has an extra pair of parentheses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your program is only 14 lines long, and it would be beneficial to you to examine the program critically and assure yourself that the program will accomplish what you wanted it to do.
The program of #8 opens two formatted files, but does nothing useful with them. (I commented on this problem in #7, but you seem to have ignored those comments.)
Instead of reading those files, your program would read from the console, reading an array of 33 integers twice. If the console input that you provide does not match, the program may abort, but you may not see the error messages because those messages are output to a new window and the window gets closed in such a short time that you may not even notice that it ever existed.
Array Ts_array is never initialized, yet you attempt to output the values in the array. You can only expect junk output for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some comments...
Opening the same unit with different files does what you want - it implicitly closes the previous one - but I hate this feature of the language ("OPEN on a connected unit"). I see you changed that in your later file and am glad you did so. However, you haven't fixed the problem that you read into Elem_array twice when you meant to read intio Ts_array after opening the second file.
The reason the output disappears is that when, in Visual Studio, you tell it to "start debugging" and have not set any breakpoints, the output window closes when the program exits. If you select "Start without debugging", the window will stay around until you tell it to close.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
Thank you for the help, the problems are solved! You are really helpful!
Yanmei

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page