Initialize the ephemeris. This routine may be called to load a different ephemeris file. Otherwise, it is called on the first call to get_state, and loads the file specified in the module header.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(jpl_ephemeris), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
ephemeris file name |
||
integer, | intent(in), | optional | :: | ksize |
corresponding |
|
logical, | intent(in), | optional | :: | km |
defining physical units of the output states.
|
|
logical, | intent(in), | optional | :: | bary |
logical flag defining output center.
only the 9 planets are affected.
|
|
logical, | intent(out) | :: | status_ok |
true if there were not problems. |
subroutine initialize_ephemeris(me,filename,ksize,km,bary,status_ok) implicit none class(jpl_ephemeris),intent(inout) :: me character(len=*),intent(in) :: filename !! ephemeris file name integer,intent(in),optional :: ksize !! corresponding `ksize` logical,intent(in),optional :: km !! defining physical units of the output states. !! `km = .true.` : km and km/sec [default], !! `km = .false.` : au and au/day. logical,intent(in),optional :: bary !! logical flag defining output center. !! only the 9 planets are affected. !! `bary = .true.` : center is solar-system barycenter, !! `bary = .false.` : center is sun [default]. logical,intent(out) :: status_ok !! true if there were not problems. !local variables: integer :: irecsz,istat,i,j,k,l !just in case it was already open: call me%close() ! clears everything in the class !ephemeris file name: me%namfil = trim(filename) !optional inputs: if (present(ksize)) me%ksize = ksize if (present(km)) me%km = km if (present(bary)) me%bary = bary irecsz = nrecl*me%ksize me%ncoeffs = me%ksize/2 open(newunit = me%nrfile, & file = me%namfil, & access = 'DIRECT', & form = 'UNFORMATTED', & action = 'READ', & !JW added recl = irecsz, & iostat = istat, & status = 'OLD' ) !write(*,*) "istat=",istat status_ok = (istat==0) !if there were no problems opening the file if (status_ok) then read(me%nrfile,rec=1,iostat=istat) & me%ttl,(me%cnam(k),k=1,oldmax),me%ss,me%ncon,me%au,me%emrat,& ((me%ipt(i,j),i=1,3),j=1,12),me%numde,(me%ipt(i,13),i=1,3), & (me%cnam(l),l=oldmax+1,me%ncon) if (istat==0) then if (me%ncon <= oldmax) then read(me%nrfile,rec=2,iostat=istat) (me%cval(i),i=1,oldmax) else read(me%nrfile,rec=2,iostat=istat) (me%cval(i),i=1,me%ncon) endif if (istat==0) then me%nrl = 0 me%initialized = .true. end if end if ! check if the reads went OK: status_ok = me%initialized if (status_ok) then !initialize some of the class variables: ! [note: this was formerly done in the interp routine] me%pc(1) = 1.0_wp me%vc(2) = 1.0_wp else write(error_unit,'(A)') 'Error reading ephemeris file: '//trim(me%namfil) end if else write(error_unit,'(A)') 'Error opening ephemeris file: '//trim(me%namfil) end if end subroutine initialize_ephemeris