command line arguments - How to convert character to integer in fortran? -


how manipulate command line argument? example


te.f90

   program print_    integer ::    character(len = 32) :: arg    = 1              call get_command_argument(i, arg)       if ( len_trim(arg) == 0) exit           write(*,*) trim(arg)           write(*,*) trim(arg)**2           = + 1    end    end program print_ 


te.sh

#!/bin/bash  (( x = 1; x <=3; x++ ))    ./te $x done 

i pass $x arg has type character, want manipulate arg number, when execute ./te.sh, got error promotion operands of binary numeric operator '**' @ (1) character(1)/integer(4).

what do?

you'll need convert string (arg) integer.

program print_    integer :: i, iarg    character(len = 32) :: arg    = 1              call get_command_argument(i, arg)       if ( len_trim(arg) == 0) exit           write(*,*) trim(arg)           read(arg,"(i)") iarg           write(*,*) iarg**2           = + 1    end    end program print_ 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -