replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Reading and writing compass azimuth.
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading and writing compass azimuth.

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Jim



Joined: 21 Jul 2006
Posts: 24
Location: USA

PostPosted: Fri Nov 04, 2011 12:27 am    Post subject: Reading and writing compass azimuth. Reply with quote

How would you structure a READ and WRITE statement for compass azimuths in the following format:

N45.00E or N45.00W
S45.00E or S45.00W

It has to be generic since the azimuth will be in 1 or 4 quadrants. N or S is always first and E or W follows the degrees of rotation. Degrees of rotation is 0 - 90 degrees.

Thanks,

Smile
Back to top
View user's profile Send private message
Wilfried Linder



Joined: 14 Nov 2007
Posts: 314
Location: D�sseldorf, Germany

PostPosted: Fri Nov 04, 2011 9:04 am    Post subject: Reply with quote

May be like this?

Code:
      WINAPP
      OPTIONS(INTL)

      PROGRAM TEST

      IMPLICIT NONE

      real*8         alfa
      character*1    A,B
      character*7    string

c     read data. alfa is converted to 0 ... 360 degrees

      open(10,err=200,file='input.dat',status='old')
      read(10,'(A)',err=200,end=200)string
      call upcase@(string)
      A = string(1:1)
      B = string(7:7)
      read(string(2:6),*,err=200)alfa
      if (A .eq. 'S' .and. B .eq. 'E') then
        alfa = alfa+90.D0
      else if (A .eq. 'S' .and. B .eq. 'W') then
        alfa = alfa+180.D0
      else if (A .eq. 'N' .and. B .eq. 'W') then
        alfa = alfa+270.D0
      end if
      print*,alfa
200   close(10)

c     write data. example:

      alfa = 127.D0

      open(20,err=400,file='output.dat',status='unknown')
      if (alfa .gt. 0.D0 .and. alfa .le. 90.D0) then
        A = 'N'
        B = 'E'
      else if (alfa .gt. 90.D0 .and. alfa .le. 180.D0) then
        A = 'S'
        B = 'E'
        alfa = alfa-90.D0
      else if (alfa .gt. 180.D0 .and. alfa .le. 270.D0) then
        A = 'S'
        B = 'W'
        alfa = alfa-180.D0
      else
        A = 'N'
        B = 'W'
        alfa = alfa-270.D0
      end if
      string(1:1) = A
      string(7:7) = B
      write(string(2:6),'(F5.2)',err=400)alfa
      write(20,'(A)',err=400)string
      print*,string
400   close(20)

      end

Regards - Wilfried
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group