- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone, I have the following code which is supposed to convert an integer i to a string, create a folder called i, and then covert a double Oh to stiring, and make a file called Oh. I can get this to work using gfortran, however I am having issues using IFORT. From what I gathered on these forum is that the appropriate intel call system(mkdir) equivalent is MakeDirQQ, however it appears I am not using it correctly. Does anyone see what I am doing wrong here. I am getting a no such file or directory error.
!-*- mode: f90;-*- Program Main implicit none integer, parameter :: rk = selected_real_kind(p=15), ik = 4 logical :: e,result integer :: i double precision :: Oh character(LEN=150) :: folder !Make sure these are long enough character(LEN=40) :: file !Shows how to create file names and folders automatically based on values !stored in variables !First we want to create a numbered folder with the same value as i i = 8 !This prints the value of i to the string folder with format i8 write(folder,'(i8)') i !Removes leading whitespace, always use this after printing value into string folder = ADJUSTL(folder) !This adds the slash for the end of the folder, trim removes empty space at the end folder = trim(folder)//'/' !INQUIRE will check if this folder already exists, if not it will create it INQUIRE(FILE=trim(folder),EXIST=e) if (.not.e) then !call system('mkdir '//trim(folder)) !system issues terminal commands, in this case creates directory result = MakeDirQQ('i') write(*,*) 'Created directory '//trim(folder) else write(*,*) trim(folder)//' already exists' end if !Now say we want to create a file in the folder we just created Oh = 0.5 write(file,'(f5.3)') Oh !Write value of Oh to file file = ADJUSTL(file) !Remove leading whitespace file = trim(file)//'.dat' !Append file extension Open(unit = 11,file = trim(folder)//trim(file), status = 'replace') write(11,'(A)') 'Test' close(11) !Notice how I always use trim when using strings return end Program Main
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have never used MakeDirQQ() before but I’m guessing your issue is on line 30. Here it looks like you are creating a folder called ‘i’ rather than the folder name you have constructed. Replace ‘i’ with trim(folder) as the argument to MakeDirQQ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That worked! thank you!

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