unix - How to create multiple directories in a fortran program -


this question has answer here:

i trying design fortran77 program creates 17 directories in unix various other things, creating directories has been biggest problem that's i'd focus on @ moment.

for example:

do i=1,17 cmd="mkdir" ,i call system(cmd)  call chdir("i") end 

from portion of code want command "mkdir" create 17 separate directories in unix named 1-17, when try compile program error says "invalid radix specifier" focusing on second line of code listed.

another error produced focusing on same line of code. "concatenation operator @ (^) must operate on 2 sub expressions of character type, sub expression @ (^) not of character type.

is there way convert integers strings?

all appreciated thanks.

to answer 1 of questions, can convert integer string writing it. consider example code:

program main integer :: character(len=80) :: cmd  i=1,4    write(cmd,'(a,i0.2)') 'mkdir directory_',    write(*,*) 'calling "', trim(cmd), '"'    call system(cmd) enddo  end program main 

which gives output

mach5% pgfortran main.f90; ./a.out   calling "mkdir directory_01"  calling "mkdir directory_02"  calling "mkdir directory_03"  calling "mkdir directory_04" mach5% ls total 860 -rwx------ 1 chaud106 806765 jul  1 15:37 a.out* drwx------ 2 chaud106   4096 jul  1 15:37 directory_01/ drwx------ 2 chaud106   4096 jul  1 15:37 directory_02/ drwx------ 2 chaud106   4096 jul  1 15:37 directory_03/ drwx------ 2 chaud106   4096 jul  1 15:37 directory_04/ -rw------- 1 chaud106    195 jul  1 15:37 main.f90 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -