1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Fortran reading csv

  1. Apr 24, 2010 #1
    Hi guys and gals,

    I'm trying to use fortran 77 to read a csv file which has data like this
    Code (Text):

    1969231S09068,1970,1, SI, SI,ALINE,19/08/1969 6:00,TS,-9.1,67.8,2,0,22,-1,22,22,22,0,1,-1,-1,-1,-1,2,-1,1,spur,split,split,cyclolysis,1969231S09069,reunion:neumann,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
    1969231S09068,1970,1, SI, SI,ALINE,19/08/1969 12:00,NR,-9,66.2,2,0,22,-1,22,22,22,0,1,-1,-1,-1,-1,2,-1,1,spur,split,split,cyclolysis,1969231S09069,reunion:neumann,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
    1969231S09068,1970,1, SI, SI,ALINE,19/08/1969 18:00,NR,-9,64.3,2,0,22,-1,22,22,22,0,1,-1,-1,-1,-1,2,-1,1,spur,split,split,cyclolysis,1969231S09069,reunion:neumann,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,25,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
    I have no programming knowledge and what I want to do is create a program that will output when tropical cyclones are within specific latitudes and longitudes. Given my lack of experience I've tried to write a simple program to output the time, latitude and longitude. I've found that the formatting in the ISO_time column is making things tricky and when I get the output from the code below it ignores everything after the first forwardslash giving incorrect output such as:
    Code (Text):
    Time=19 lat= 1.5606261E-41 long= -2.24924502E-37
    Could someone please tell me how to fix this?

    Here's my code so far, it's very novice =P
    Code (Text):
          program read_ibtracs
          implicit none
          character*50 a,d,e,f,g,h
          real b,c,i,j
          open (1,file="1970-2008.txt")
          close (1)
    The data opened by this program (1970-2008.txt) has been modified so that there the first line is not "Serial_Num,Season,Num,etc..."

    If anyone wants to look at the original data set, it is available at from IBTrACS: "ftp://eclipse.ncdc.noaa.gov/pub/ibtracs/v02r01/ibtracs_csv/basin"[/URL]

    Thank you for the help, I'll probably post more questions as I attempt to make the program more complicated =).
    Last edited by a moderator: Apr 25, 2017
  2. jcsd
  3. Apr 24, 2010 #2
    Change g to CHARACTER*10. It's reading 50 characters into the date field because there is no comma to stop it.
  4. Apr 24, 2010 #3
    Thanks for the reply. I added another line/declaration character*10 g leaving everything else the same and the output is basically the same as before.
    Code (Text):
    Time=19 lag= 0.long= 0.
    I'm wondering if there's a way to tell fortran to read the date 'as is' because at the moment I think it's treating the forward slash as a special character.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook