Hello everyone. I'm used to use C::B for C programming, but recently I had to run a Fortran code, then I changed specifications in C::B in order to do it (1-downloaded Mingw additional files such as gfortran, 2- Have set properly the environment variables path in Settings->Compiler->Toolchain executables and the rest of setting in this box). I'm aware that Fortran has several versions and I'm not sure in which version this code I want to run was written, probably a version more recent or at least equal to Fortran2003, since it has the command "get_command_argument" which I figured out was not present in f90 and f95. Said all of that I'm not sure if I need to choose "Fortran application" or "Console application" (as I used to do with C) when starting my project and if I need to do anything else besides what I already explained.
After errors like "At line 18 of file C:\..path..\Untitle1.f90 Fortran runtime error: End of file" I realized that the problem in my code was related to "get_command_argument" function and I tried a simple code I posted below..
PROGRAM cmdlnsum
IMPLICIT NONE
CHARACTER(100) :: num1char
CHARACTER(100) :: num2char
REAL :: num1
REAL :: num2
REAL :: numsum
!First, make sure the right number of inputs have been provided
IF(COMMAND_ARGUMENT_COUNT().NE.2)THEN
WRITE(*,*)'ERROR, TWO COMMAND-LINE ARGUMENTS REQUIRED, STOPPING'
STOP
ENDIF
CALL GET_COMMAND_ARGUMENT(1,num1char) !first, read in the two values
CALL GET_COMMAND_ARGUMENT(2,num2char)
READ(num1char,*)num1 !then, convert them to REALs
READ(num2char,*)num2
numsum=num1+num2 !sum numbers
WRITE(*,*)numsum !write out value
END PROGRAM
It always stops the program after accessing the first "if" statement. I verified and my "command_argument_count ()" returns 0 what I think is not supposed to happen, it was supposed to return 2, if I understood Fortran correctly so far.. I would appreciate if anyone of you guys could help me to really make this function "command_argument_count()" work.
I can run a simpler code from where I verify my "command_argument_count()" returns me 0
program test_command_argument_count
integer :: count
count = command_argument_count()
print *, count
end program test_command_argument_count
Build Log:
Warning: Nonexistent include directory 'C\..path..\Untitled1.os_output_dir'
Thank you all in advance!
P.S.: First time posting and I did not find any post template (if there is any). If I need to rewrite my post let me know my steps. In our discussions if you find it better I can show first the true code I want to run.