Sublimetext 3 doesn't work with gfortran - build

I am trying to run Fortran in SublimeText on Windows 10.
I have installed MinGW and so I expected to have gfortran installed. But it doesn't work in SublimeText 3 even though there is a possibility to build with gfortran. My code is like this:
program Hi
write(*,*) "Hello"
end program Hi
But it gives me this error:
gfortran: error: 'C:\Users\Steven\Documents\Hi.f90': Invalid argument
When I try to run it in cmd, it does nothing
Can anyone help me to make it run?

Related

Mlton compiler not working (not giving any output)

Installed the MLton compiler on Ubuntu (sudo apt-get install mlton) and had no problems (seemingly) with installation.
When I try to use it (e.g. "mlton test.sml") it sits for a second and then returns nothing. If I try to print something in the file I'm trying to compile, nothing. However, weird part is if I give it bad ML code ("x = 2", without val), it spits out regular errors like "Undefined variable," etc.
I've looked on here, and elsewhere online, and nothing seems to concern what I'm experiencing.
Perhaps I'm just using it wrong?
Thanks in advance.
mlton is a non-interactive compiler; it compiles the program, and that's it. You can run the program later if you want.
So, for example, if test.sml is a valid Standard ML program, then this:
mlton test.sml # compile the program
will compile it and emit a Linux executable file named test. You then run that executable file like this:
./test # run the program
If you want to compile and run the program with a single command, you can use your shell's && feature to run two programs (but only running the second if the first one had succeeded):
mlton test.sml && ./test

Fortran running error

I have a Fortran code that I have to run but unfortunately I don't have any experience with Fortran. I tried to run the code using different Fortran version and nothing works.
Here is the link for the code: http://cpc.cs.qub.ac.uk/summaries/adpw.
It would be great if someone could tell me which Fortran version should I use.
Here are the details:
When I try to run with gfortran:
gfortran numcbas.f < numcbas_c.data
Segmentation fault: 11
and when I run with g77:
g77 numcbas.f < numcbas_c.data
ld: warning: -macosx_version_min not specified, assuming 10.10
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in __start from /usr/lib/crt1.o.
To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
And here is start of the code:
program NUMCBAS
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
MAIN DRIVING ROUTINE
CHARACTER*120 TITLE
DIMENSION IBUG(3),HRXS(10),IRXS(10)
COMMON /BASCON/ HRX(10),IRX(10),NIX,IRA
DATA TITLE /' '/
DATA HRXS/1.D-02,2.D-02,2.605D-02,7*0.D0/
DATA IRXS/30,120,500,7*0/,IBUG/3*0/
INTEGER :: NFTA=6,LUNUMB=13, LVAL=0
DOUBLE PRECISION :: BTOL=0.2D0, TINY=1.D-11
DOUBLE PRECISION :: ECMAX=10.D0, RLIM=10.D0, CHARGE=0.D0
NAMELIST /INPUT/ TITLE,LUNUMB,NIX,IRX,HRX,lval,IBUG,BTOL,
* TINY,ECMAX,RLIM,CHARGE
WRITE (6,1000)
and the input file:
&INPUT
TITLE='IONIC TARGET',
lval=0, ECMAX = 5.00D0,
RLIM = 12.0D0, CHARGE=1.0D0,/
It seems to me you are completely misunderstanding tho processes of compilation and running.
These lines are suspicious:
gfortran numcbas.f < numcbas_c.data
g77 numcbas.f < numcbas_c.data
There is no reason to redirect a data file to the compiler command. The compiler first has to create an executable program which you then can run with your data. Normally, a file ./a.out is created and you then run it
./a.out < some_data_to_stdin
It is very strange that you get a Segmentation fault from running gfortran without any other error message. Are you sure the commands you show above are exactly what you are running?

XCode shell script error

I just moved over to a new MacBook Air (10.8) and a 64-bit project that compiled before gives me Shell Script Invocation Error: /bin/sh failed with exit code 2
It looks like XCode 4.6 is failing on one of the intermediate files, saying unexpected EOF while looking for matching '"' in a file ending in .sh
Any ideas how to fix this?
Thank
Bill

Error in compiling when installing Stan for R and when using Rcpp

I need to install Rstan for a data analysis class. The instructions are posted here http://code.google.com/p/stan/wiki/RStanGettingStarted. I'm running Mac OS 10.5.8 and R 2.15.1 GUI 1.52 Leopard build 32-bit (6188). I just installed Xcode version 3.1.4, the Xcode c++ compiler that is compatible with leopard (I had to get a mac developer account to do this).
Per the Stan installation instruction, I entered the following code to see if my compiler was working:
library(inline)
library(Rcpp)
src <- '
std::vector<std::string> s;
s.push_back("hello");
s.push_back("world");
return Rcpp::wrap(s);
'
hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
cat(hellofun(), '\n')
It returns the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
Library/Frameworks/R.framework/Versions/2.15/Resources/library/
Rcpp/include/Rcpp/internal/export.h: In function ‘void
Rcpp::internal::export_range__dispatch(SEXPREC*, InputIterator,
Rcpp::traits::r_type_primitive_tag)’:
/Library/Frameworks/R.framework/Versions/2.15/Resources/
library/Rcpp/include/Rcpp/internal/export.h:56: internal
compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for
instructions.
make: *** [file795214e66510.o] Error 1
In addition: Warning message:
running command '/Library/Frameworks/R.framework/Resources/bin/
R CMD SHLIB file795214e66510.cpp 2>
file795214e66510.cpp.err.txt' had status 1
When I try to install stan:
install.packages('rstan', type = 'source') ]
I get this warning:
Warning message:
In install.packages("rstan", type = "source") :
installation of package ‘rstan’ had non-zero exit status
I have no idea how C++ works. All of my coding experience is in R and has not before required compiling into C++. I've been trying really hard to figure out what's wrong for the last 4 hours or so, googling these error messages over and over without much luck. Any help would be greatly appreciated and would also help about 10 other students in my class who are having identical or analogous problems. Thank you very, very much.
This looks to me like an issue with the installation of your C++ compiler or with your installation of the Rcpp package, rather than an issue with the rstan package. However, if g++ is causing an intractable problem for you, an alternative is the clang compiler, which should work with Rcpp and rstan if you create $HOME/.R/Makevars with these two lines
CC=clang
CXX=clang++
As mentioned in another answer, the first step is to get Rcpp working on your Mac (i.e,. at least pass the hello world example).
A similar issue for Rcpp previously:
https://stat.ethz.ch/pipermail/r-sig-mac/2010-July/007574.html
In addition, from this webpage http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html, it seems that gcc 4.2 and 4.0 are both in Xcode 3.14 (not sure as it does not say it's 3.14). So try to make sure gcc 4.2.1 is used by R is important. Executing the following in a terminal will show what is the current version of gcc.
$ g++ -v

How can I solve Fortran runtime error: End of file?

I am using Codeblock 13.12. My file is not readable. and getting the runtime error
program asd
implicit none
integer :: x
open(unit = 2, file = "text.txt")
read(2,*)x
write(*,*)x
end program
and my text.txt file is :
1
I've seen many answers, but none of them worked for my code
Your program is just fine. As a matter of fact, even if the first line is not properly terminated, gfortran will take the EOF as the EOL and still work.
Your problem is you are working in the IDE CodeBlock. The IDE does not run the program in your working directory so the file text.txt is not where the program is running, hence the end of file error.
Check out this post Codeblock working directory which will guide you to solving your problem.