Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Search results

  1. kkhhhkk

    Fortran, Using a loop and combined string to read a file

    Yeah I'm a student doing honours in physics, I need to use fortran for my specific project (molecule rotations and calculations). I'm sure what I need to do can be done in c++ (I dont know how to use c++) however my supervisor told me to use fortran cause she said she could check over it (but...
  2. kkhhhkk

    Fortran, Using a loop and combined string to read a file

    Alright update: The following script is able to read all the file and print its contents: program rotate implicit none integer :: i integer :: unit character(len=50) :: filename integer, parameter :: n = 10, m = 3 real :: matrix(n,m) integer :: j, k...
  3. kkhhhkk

    Fortran, Using a loop and combined string to read a file

    So I tried that, also dropped the "(A)", and I end up with the error: rotate.f90:19:8: filename = "(A)",trim(str1)//trim(adjustl(MyStr))//trim(str2) 1 Error: Unclassifiable statement at (1)
  4. kkhhhkk

    Fortran, Using a loop and combined string to read a file

    Hello, I'm trying to use f90 to read multiple files using do loop, here is what I have: program rotate implicit none integer :: i character(len=20) :: MyStr, str1, str2, str_combined character(len=50) :: filename integer, parameter :: n = 10, m = 3 real :: matrix(n,m)...
  5. kkhhhkk

    Python Change values in one list by referring to a second one

    I have two lists, we'll call them x and n, I've been trying to write a script that goes through the elements of list n and if they are negative then to change the corresponding index element of x to a positive value I've tried for i in range(0,len(n),1): if n[i]<0: x[i] = abs(x[i])...
  6. kkhhhkk

    Python Write an empty line at the end of my files

    Yes! it worked, sorry I dont get emails or notifs for this. The always_print and continue is there since the occurrence happens over 1300 times within a large text file, if I remove this from the code it doesn't write everything I want.
  7. kkhhhkk

    Python Write an empty line at the end of my files

    I have the following code that writes out multiple files. I want this code to also write out an empty line at the end of each file produced, I've tried adding ('\n\') inside the loop however it adds an empty line to every line which is annoying i = 0 f = open('innput.txt','r') always_print =...
  8. kkhhhkk

    Python Write in lines from a txt that is called by the occurrence of two strings

    I have a current way that does it by line index, but this is not some I can use for generalised data: writefile = open("input_two.txt","a") with open("input_n.txt","r") as myfile: lines = myfile.readlines() for index, line in enumerate(lines): if "Optimized" in line...
  9. kkhhhkk

    Python Write in lines from a txt that is called by the occurrence of two strings

    I have a data file with has lines that look like this: input lines lines optimized input lines lines input lines lines optimized I want my script to go through this file, find the lines with input, find the line with optmized and write all the lines between them but only if its input lines...
Back
Top Bottom