CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

[FORTRAN] - equivalent to sqort() and realloc() in C?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 23, 2021, 04:08
Default [FORTRAN] - equivalent to sqort() and realloc() in C?
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 362
Rep Power: 11
Gerry Kan is on a distinguished road
Howdy Folks:

I am wondering if there are standardized (i.e., portable) equivalent functions in Fortran (90/'03) that serve similar functions in C:

qsort() - I know there is a qsort subroutine, but I don't know if it is a standard subroutine across all Fortran compilers

realloc() - I seem to have problem looking for a Fortran equivalent. The workaround is to use temporary storage.

Thanks very much in advance, Gerry.
Gerry Kan is offline   Reply With Quote

Old   February 23, 2021, 06:07
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
The answer to both is no, there aren't portable equivalents (i.e., intrinsic functions from the standard). The closer you can get to realloc (that I am aware of) is with the following:

Code:
allocate(a, source=[b,c])
where you allocate a concatenating b and c, but you are still in charge for what happens then to b and c (e.g., you have to deallocate them if you need their memory)
Gerry Kan likes this.
sbaffini is offline   Reply With Quote

Old   February 24, 2021, 12:09
Default
  #3
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 362
Rep Power: 11
Gerry Kan is on a distinguished road
Paolo:

Thanks. I ended up writing them both from scratch. It is a pity that there is not really something like (void *) that will let me write my sort implementation with any data type in mind.

Gerry.
Gerry Kan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 23:38.