!------------------------------------------------------------------------ ! ! Subroutine for - reading in the conductance data from a file ! !------------------------------------------------------------------------ subroutine read_conductances use ModAMIE use ModFiles use ModData use ModConductance use ModIndices implicit none integer, external :: jday integer :: iLunCond, iyr, imon, iday, ihr, minute, isec, ierr integer :: nlines_to_read, i, j, n, k, ll, l, ifile, npt, iNC real*8 :: time_start, time, dt_magfile, time_before_all, ctime real :: alon, ang, alat, hp, glat, glon, amlt real :: zmag, ymag, xmag, bmag, a, v, rtime character (len=100) :: line character (len=1) :: ErrorString, ErrorStringPast integer, dimension(7) :: itime integer :: iConductanceSolutions, iJulianDay logical :: IsGeographic, IsFirstTime = .true. iLunCond = lun_conductivity ifile = 1 do ifile = 1, ncond_files if (IsFirstTime) call merge_str(cond_dir, cond_file(ifile)) iLunCond = iLunCond + ifile - 1 open(iLunCond, file = cond_file(ifile), status='old', iostat = ierr) if (ierr /= 0) then write(6,*) 'Error opening file :',cond_file endif read(iLunCond,'(a)') line if (index(line,"Geographic") > 1) then IsGeographic = .true. call time_real_to_int(currenttime, itime) iJulianDay = jday(itime(1), itime(2), itime(3)) rtime = float(itime(1)) + float(ijulianday)/jday(itime(1),12,31) else IsGeographic = .false. read(iLunCond,*) line endif ! if (timelist(1) > -1.0e32) then ! ctime = timelist(1) ! else ctime = currenttime ! endif itime(7) = 0 if (DebugLevel > 2) & write(*,*) " ===> read_conductances, n = ", ifile, ntimes time = 0.0 ctime = ctime - window_dt/2.0 do while (time < ctime) read(iLunCond,"(i4,5i3)", iostat = ierr) itime(1:6) if (ierr /= 0) then time = 1.0e32 else call time_int_to_real(itime, time) endif enddo if (time < 1.0e32) backspace(iLunCond) npts_cond(ifile) = 1 ! if (timelist(ntimes) > -1.0e32) then ! ctime = timelist(ntimes) ! else ! ctime = currenttime + dt * (ntimes-1) ! endif ctime = ctime + window_dt * 2 / 2.0 ErrorStringPast = "B" do while (time < ctime) itime = 0 iNC = npts_cond(ifile) read(iLunCond,"(i4,5i3,f6.2,f7.2,f6.2,i5,5f7.2,f6.2,4f7.2,1x,1a)", & iostat = ierr) itime(1:6), & ConductanceLocations(ifile, iNC, mag_lat_), & alon, ConductanceLocations(ifile, iNC, mlt_), & npt, ang, & ConductanceData(ifile, iNC, pedersen_), & ConductanceDataError(ifile, iNC, pedersen_), & ConductanceData(ifile, iNC, hall_), & ConductanceDataError(ifile, iNC, hall_), hp, & ConductanceData(ifile, iNC, eflux_), & ConductanceDataError(ifile, iNC, eflux_), & ConductanceData(ifile, iNC, avee_), & ConductanceDataError(ifile, iNC, avee_), & ErrorString if (ConductanceData(ifile, iNC, hall_) > 100.0) then ConductanceDataError(ifile, iNC, hall_) = & ConductanceData(ifile, iNC, hall_) * 5.0 ConductanceDataError(ifile, iNC, eflux_) = & ConductanceData(ifile, iNC, eflux_) * 5.0 ConductanceDataError(ifile, iNC, avee_) = & ConductanceData(ifile, iNC, avee_) * 5.0 endif if (IsGeographic) then glat = ConductanceLocations(ifile, iNC, mag_lat_) glon = ConductanceLocations(ifile, iNC, mlt_) call apex(rtime, glat, glon, 110.0, a, & alat, alon, bmag, xmag, ymag, zmag, v) call magloctm(alon, subsolar_lat, subsolar_lon, & pole_colat, pole_east_lon, amlt) ConductanceLocations(ifile, iNC, mag_lat_) = alat ConductanceLocations(ifile, iNC, mlt_) = amlt endif !\ ! There are 2 possible reasons why ierr /= 0: ! (1) EOF was reached. ! (2) a data value was missing from the row. ! Therefore, we have to check to see which is true. !/ !\ ! This is option 2 above !/ if (ierr /= 0 .and. itime(1) /= 0) ierr = 0 if (ierr /= 0) then !\ ! This is option 1 above !/ time = ctime + 1.0 else alat = ConductanceLocations(ifile, iNC, mag_lat_) if (ihsoln*alat > 0 .and. ErrorString /= "B") then call time_int_to_real(itime, time) ConductanceTimes(ifile, iNC) = time do iConductanceSolutions = 1, nConductanceSolutions if (ConductanceData(ifile, iNC, iConductanceSolutions) < & ConductanceBackground(iConductanceSolutions)) & ConductanceData(ifile, iNC, iConductanceSolutions) = & ConductanceBackground(iConductanceSolutions) if (ConductanceDataError(ifile, iNC, iConductanceSolutions)< & ConductanceBackground(iConductanceSolutions)) & ConductanceDataError(ifile, iNC, iConductanceSolutions)=& ConductanceBackground(iConductanceSolutions) enddo ! ! This section tries to cut off the auroral oval a little sharper ! if (ErrorString == "Q" .and. ErrorStringPast == "G") then ! ! Make sure the measurements are in the same orbital plane ! if (abs(ConductanceLocations(ifile, iNC, mlt_)- & ConductanceLocations(ifile, iNC-1, mlt_)) < 1.0) then ! ! This is quite different than the way that the ! old AMIE did it. ! ! Here we scale the error according to the ratio of the ! good and questionable points. That way, if the cut ! off is huge, then the error will be huge. ! ConductanceDataError(ifile, iNC, eflux_) = & ConductanceDataError(ifile, iNC, eflux_) * & ConductanceData(ifile, iNC-1, eflux_) / & ConductanceData(ifile, iNC, eflux_) endif endif ! ! Now do the same thing in reverse order (see comments above) ! if (ErrorString == "G" .and. ErrorStringPast == "Q") then if (abs(ConductanceLocations(ifile, iNC, mlt_)- & ConductanceLocations(ifile, iNC-1, mlt_)) < 1.0) then ConductanceDataError(ifile, iNC-1, eflux_) = & ConductanceDataError(ifile, iNC-1, eflux_) * & ConductanceData(ifile, iNC, eflux_) / & ConductanceData(ifile, iNC-1, eflux_) endif endif ErrorStringPast = ErrorString ! ! this implies iNC = iNC + 1 ! npts_cond(ifile) = npts_cond(ifile) + 1 endif endif enddo close(iLunCond) npts_cond(ifile) = npts_cond(ifile) - 1 if (DebugLevel > 1) write(*,*) " ==> ",npts_cond(ifile), & " points read from file ",cond_file(ifile) enddo IsFirstTime = .false. end subroutine read_conductances !------------------------------------------------------------------------ ! ! ! !------------------------------------------------------------------------ !subroutine Fill_Conductances ! use ModData !end subroutine Fill_Conductances