Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6739949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:32:53+00:00 2026-05-26T11:32:53+00:00

I have a simple function that returns a time object based on a time

  • 0

I have a simple function that returns a time object based on a time string:

FUNCTION getTime(timeStr)RESULT(time)
IMPLICIT NONE
CHARACTER(LEN=19),INTENT(IN) :: timeStr
TYPE timeType
 INTEGER :: yyyy,mo,dd,hh,mm,ss
ENDTYPE timeType
TYPE(timeType) :: time
READ(UNIT=timeStr( 1: 4),'(I4)')time%yyyy
READ(UNIT=timeStr( 6: 7),'(I2)')time%mo
READ(UNIT=timeStr( 9:10),'(I2)')time%dd
READ(UNIT=timeStr(12:13),'(I2)')time%hh
READ(UNIT=timeStr(15:16),'(I2)')time%mm
READ(UNIT=timeStr(18:19),'(I2)')time%ss
ENDFUNCTION getTime

I call it from the parent routine as:

umwmTime1=getTime(umwmStartTimeStr)
umwmTime2=getTime(umwmStopTimeStr)

where umwmTime 1 and 2 are declared as:

TYPE timeType
  INTEGER :: yyyy,mo,dd,hh,mm,ss
ENDTYPE timeType
TYPE(timeType) :: umwmTime1,umwmTime2

The compile error message I get is:

PGF90-S-0099-Illegal use of derived type (ESMF_interface_UMWM.F90: 282)
PGF90-S-0099-Illegal use of derived type (ESMF_interface_UMWM.F90: 283)
  0 inform,   0 warnings,   2 severes, 0 fatal for umwm_component_run

Lines 282 and 283 point are function calls in the parent routine.

However if I use subroutine (instead of function) to get umwmTime1 and umwmTime2 as INTENT(OUT) arguments, I get no problems. What am I doing wrong with the function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:32:54+00:00Added an answer on May 26, 2026 at 11:32 am

    The problem is the compiler doesn’t know that the timetype you defined in the main program is the same as the timetype that you defined in the function. You should define that one place, preferably in a module, and let that define the type everywhere.

    For instance, in a simple one-file program, the code you provided doesn’t work for me in gfortran, but this does:

    MODULE timeTypeDef
    TYPE timeType
        INTEGER :: yyyy,mo,dd,hh,mm,ss
    ENDTYPE timeType
    END MODULE timeTypeDef
    
    PROGRAM foo
    USE timeTypeDef
    IMPLICIT NONE
    
    TYPE(timeType) :: umwmTime1, umwmTime2
    
    umwmTime1=getTime('2010-10-10-14:39:03')
    umwmTime2=getTime('2011-11-11-09:17:53')
    
    contains
    
    FUNCTION getTime(timeStr)RESULT(time)
        USE timeTypeDef
        IMPLICIT NONE
        CHARACTER(LEN=19),INTENT(IN) :: timeStr
        TYPE(timeType) :: time
    
        READ(UNIT=timeStr( 1: 4),FMT='(I4)')time%yyyy
        READ(UNIT=timeStr( 6: 7),FMT='(I2)')time%mo
        READ(UNIT=timeStr( 9:10),FMT='(I2)')time%dd
        READ(UNIT=timeStr(12:13),FMT='(I2)')time%hh
        READ(UNIT=timeStr(15:16),FMT='(I2)')time%mm
        READ(UNIT=timeStr(18:19),FMT='(I2)')time%ss
    ENDFUNCTION getTime
    
    END PROGRAM foo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple function that returns an NSString after decoding it. I use
I have a function that returns a modified copy of the object that was
I have a simple function that I want to call in the code behind
I have a very simple function that takes a list of comma separated (x,y)
I have a simple recursive function RCompare() that calls a more complex function Compare()
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I am using BeautifulSoup in a simple function to extract links that have all
I have a simple JavaScript file that has three jQuery $document.ready functions. All three
I have a fairly simple python loop that calls a few functions, and writes
I have a simple function in which an array is declared with size depending

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.