string - Fortran: how to remove file extension from character -


i have fortran code asks user input file name. code processes file , write out file based on original file name. think if can understand how remove file extension can concatenate whatever want end of that.

how strip off file extension in character?

character(len=256):: input_file, output_file

original file: anyname.xxx

output file: anyname_output.csv

you can use scan locate position of last dot in string input_file. can use position extract input_file no extension , concatenate new one.

character(len=256):: input_file, output_file integer :: ppos character(len=3)  :: new_ext="csv"  ppos = scan(trim(input_file),".", back= .true.) if ( ppos > 0 ) output_file = input_file(1:ppos)//new_ext 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -